Browse Source

updated UI
using instatask messaging schema for as named
updated dev test button to make testing easier

logicp 5 years ago
parent
commit
c7f3a0d6d4
10 changed files with 473 additions and 100 deletions
  1. 81 32
      argdialog.ui
  2. 16 0
      headers/instatask.fbs
  3. 217 0
      headers/instatask_generated.h
  4. 17 25
      headers/util.hpp
  5. 11 0
      include/client.hpp
  6. 1 0
      ky_gui.pro
  7. 2 2
      ky_gui.pro.user
  8. 5 3
      src/argdialog.cpp
  9. 59 12
      src/client.cpp
  10. 64 26
      ui_argdialog.h

+ 81 - 32
argdialog.ui

@@ -18,17 +18,24 @@
     <normaloff>favicon.ico</normaloff>favicon.ico</iconset>
   </property>
   <property name="styleSheet">
-   <string notr="true">background-color: rgb(33, 33, 33);</string>
+   <string notr="true">border-color: rgb(0, 0, 0);
+background-color: rgb(0, 43, 54);</string>
   </property>
   <widget class="QDialogButtonBox" name="argCommandButtons">
    <property name="geometry">
     <rect>
-     <x>340</x>
+     <x>330</x>
      <y>510</y>
-     <width>201</width>
+     <width>211</width>
      <height>32</height>
     </rect>
    </property>
+   <property name="sizePolicy">
+    <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+     <horstretch>0</horstretch>
+     <verstretch>0</verstretch>
+    </sizepolicy>
+   </property>
    <property name="layoutDirection">
     <enum>Qt::LeftToRight</enum>
    </property>
@@ -36,8 +43,11 @@
     <bool>false</bool>
    </property>
    <property name="styleSheet">
-    <string notr="true">background-color: rgb(203, 0, 239);
-color: rgb(16, 16, 16);</string>
+    <string notr="true">background-color: rgb(255, 85, 0);
+font: 87 11pt &quot;Noto Sans&quot;;
+color: rgb(0, 43, 54);
+font-weight: 700;
+padding: 4px;</string>
    </property>
    <property name="orientation">
     <enum>Qt::Horizontal</enum>
@@ -59,8 +69,11 @@ color: rgb(16, 16, 16);</string>
     </rect>
    </property>
    <property name="styleSheet">
-    <string notr="true">background-color: rgb(203, 0, 239);
-color: rgb(16, 16, 16);</string>
+    <string notr="true">background-color: rgb(255, 85, 0);
+font: 87 11pt &quot;Noto Sans&quot;;
+color: rgb(0, 43, 54);
+font-weight: 700;
+padding: 4px;</string>
    </property>
    <property name="text">
     <string>Add</string>
@@ -99,8 +112,11 @@ color: rgb(16, 16, 16);</string>
     </rect>
    </property>
    <property name="styleSheet">
-    <string notr="true">background-color: rgb(203, 0, 239);
-color: rgb(16, 16, 16);</string>
+    <string notr="true">background-color: rgb(255, 85, 0);
+font: 87 11pt &quot;Noto Sans&quot;;
+color: rgb(0, 43, 54);
+font-weight: 700;
+padding: 4px;</string>
    </property>
    <property name="text">
     <string>File</string>
@@ -111,10 +127,15 @@ color: rgb(16, 16, 16);</string>
     <rect>
      <x>60</x>
      <y>290</y>
-     <width>91</width>
+     <width>111</width>
      <height>18</height>
     </rect>
    </property>
+   <property name="styleSheet">
+    <string notr="true">font: 75 11pt &quot;Noto Sans&quot;;
+color: rgb(131, 148, 150);
+font-weight: 700;</string>
+   </property>
    <property name="text">
     <string>Items to send</string>
    </property>
@@ -129,10 +150,11 @@ color: rgb(16, 16, 16);</string>
     </rect>
    </property>
    <property name="styleSheet">
-    <string notr="true">background-color: rgb(255, 255, 255);
-color: rgb(5, 5, 5);
-font: 87 10pt &quot;Noto Sans&quot;;
-selection-background-color: rgb(255, 0, 174);</string>
+    <string notr="true">font: 87 11pt &quot;Noto Sans&quot;;
+background-color: rgb(7, 54, 66);
+color: rgb(131, 148, 150);
+font-weight: 700;
+</string>
    </property>
    <property name="columnCount">
     <number>2</number>
@@ -164,6 +186,11 @@ selection-background-color: rgb(255, 0, 174);</string>
      <height>18</height>
     </rect>
    </property>
+   <property name="styleSheet">
+    <string notr="true">font: 75 11pt &quot;Noto Sans&quot;;
+color: rgb(131, 148, 150);
+font-weight: 700;</string>
+   </property>
    <property name="text">
     <string>Type</string>
    </property>
@@ -171,12 +198,17 @@ selection-background-color: rgb(255, 0, 174);</string>
   <widget class="QLabel" name="label_3">
    <property name="geometry">
     <rect>
-     <x>120</x>
+     <x>110</x>
      <y>130</y>
-     <width>41</width>
-     <height>18</height>
+     <width>51</width>
+     <height>20</height>
     </rect>
    </property>
+   <property name="styleSheet">
+    <string notr="true">font: 75 11pt &quot;Noto Sans&quot;;
+color: rgb(131, 148, 150);
+font-weight: 700;</string>
+   </property>
    <property name="text">
     <string>Input</string>
    </property>
@@ -184,12 +216,17 @@ selection-background-color: rgb(255, 0, 174);</string>
   <widget class="QLabel" name="label_4">
    <property name="geometry">
     <rect>
-     <x>90</x>
+     <x>60</x>
      <y>220</y>
-     <width>71</width>
+     <width>101</width>
      <height>20</height>
     </rect>
    </property>
+   <property name="styleSheet">
+    <string notr="true">font: 75 11pt &quot;Noto Sans&quot;;
+color: rgb(131, 148, 150);
+font-weight: 700;</string>
+   </property>
    <property name="text">
     <string>Attachment</string>
    </property>
@@ -204,20 +241,27 @@ selection-background-color: rgb(255, 0, 174);</string>
     </rect>
    </property>
    <property name="styleSheet">
-    <string notr="true">background-color: rgb(255, 255, 255);
-color: rgb(5, 5, 5);
-font: 87 10pt &quot;Noto Sans&quot;;</string>
+    <string notr="true">font: 87 11pt &quot;Noto Sans&quot;;
+background-color: rgb(7, 54, 66);
+color: rgb(131, 148, 150);
+font-weight: 700;
+</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_5">
    <property name="geometry">
     <rect>
-     <x>130</x>
+     <x>120</x>
      <y>260</y>
-     <width>31</width>
+     <width>41</width>
      <height>20</height>
     </rect>
    </property>
+   <property name="styleSheet">
+    <string notr="true">font: 75 11pt &quot;Noto Sans&quot;;
+color: rgb(131, 148, 150);
+font-weight: 700;</string>
+   </property>
    <property name="text">
     <string>Time</string>
    </property>
@@ -242,10 +286,11 @@ font: 87 10pt &quot;Noto Sans&quot;;</string>
     </rect>
    </property>
    <property name="styleSheet">
-    <string notr="true">background-color: rgb(255, 255, 255);
-color: rgb(5, 5, 5);
-font: 87 10pt &quot;Noto Sans&quot;;
-selection-background-color: rgb(255, 0, 174);</string>
+    <string notr="true">font: 87 11pt &quot;Noto Sans&quot;;
+background-color: rgb(7, 54, 66);
+color: rgb(131, 148, 150);
+font-weight: 700;
+</string>
    </property>
    <item>
     <property name="text">
@@ -278,13 +323,17 @@ selection-background-color: rgb(255, 0, 174);</string>
     <rect>
      <x>240</x>
      <y>590</y>
-     <width>80</width>
-     <height>26</height>
+     <width>81</width>
+     <height>31</height>
     </rect>
    </property>
    <property name="styleSheet">
-    <string notr="true">background-color: rgb(59, 255, 0);
-color: rgb(0, 0, 0);</string>
+    <string notr="true">background-color: rgb(130, 255, 121);
+background-color: rgb(2, 180, 43);
+font: 87 11pt &quot;Noto Sans&quot;;
+color: rgb(0, 0, 0);
+font-weight: 700;
+padding: 4px;</string>
    </property>
    <property name="text">
     <string>TEST</string>

+ 16 - 0
headers/instatask.fbs

@@ -0,0 +1,16 @@
+namespace IGData;
+
+table IGTask {
+  id: int;
+  filename: string;
+  time: string;
+  description: string;
+  hashtags: string;
+  requested_by: string;
+  requested_by_phrase: string;
+  promote_share: string;
+  link_bio: string;
+  mask: int;
+}
+
+root_type IGTask;

+ 217 - 0
headers/instatask_generated.h

@@ -0,0 +1,217 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+
+#ifndef FLATBUFFERS_GENERATED_INSTATASK_IGDATA_H_
+#define FLATBUFFERS_GENERATED_INSTATASK_IGDATA_H_
+
+#include "flatbuffers/flatbuffers.h"
+
+namespace IGData {
+
+struct IGTask;
+
+struct IGTask FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+  enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+    VT_ID = 4,
+    VT_FILENAME = 6,
+    VT_TIME = 8,
+    VT_DESCRIPTION = 10,
+    VT_HASHTAGS = 12,
+    VT_REQUESTED_BY = 14,
+    VT_REQUESTED_BY_PHRASE = 16,
+    VT_PROMOTE_SHARE = 18,
+    VT_LINK_BIO = 20,
+    VT_MASK = 22
+  };
+  int32_t id() const {
+    return GetField<int32_t>(VT_ID, 0);
+  }
+  const flatbuffers::String *filename() const {
+    return GetPointer<const flatbuffers::String *>(VT_FILENAME);
+  }
+  const flatbuffers::String *time() const {
+    return GetPointer<const flatbuffers::String *>(VT_TIME);
+  }
+  const flatbuffers::String *description() const {
+    return GetPointer<const flatbuffers::String *>(VT_DESCRIPTION);
+  }
+  const flatbuffers::String *hashtags() const {
+    return GetPointer<const flatbuffers::String *>(VT_HASHTAGS);
+  }
+  const flatbuffers::String *requested_by() const {
+    return GetPointer<const flatbuffers::String *>(VT_REQUESTED_BY);
+  }
+  const flatbuffers::String *requested_by_phrase() const {
+    return GetPointer<const flatbuffers::String *>(VT_REQUESTED_BY_PHRASE);
+  }
+  const flatbuffers::String *promote_share() const {
+    return GetPointer<const flatbuffers::String *>(VT_PROMOTE_SHARE);
+  }
+  const flatbuffers::String *link_bio() const {
+    return GetPointer<const flatbuffers::String *>(VT_LINK_BIO);
+  }
+  int32_t mask() const {
+    return GetField<int32_t>(VT_MASK, 0);
+  }
+  bool Verify(flatbuffers::Verifier &verifier) const {
+    return VerifyTableStart(verifier) &&
+           VerifyField<int32_t>(verifier, VT_ID) &&
+           VerifyOffset(verifier, VT_FILENAME) &&
+           verifier.VerifyString(filename()) &&
+           VerifyOffset(verifier, VT_TIME) &&
+           verifier.VerifyString(time()) &&
+           VerifyOffset(verifier, VT_DESCRIPTION) &&
+           verifier.VerifyString(description()) &&
+           VerifyOffset(verifier, VT_HASHTAGS) &&
+           verifier.VerifyString(hashtags()) &&
+           VerifyOffset(verifier, VT_REQUESTED_BY) &&
+           verifier.VerifyString(requested_by()) &&
+           VerifyOffset(verifier, VT_REQUESTED_BY_PHRASE) &&
+           verifier.VerifyString(requested_by_phrase()) &&
+           VerifyOffset(verifier, VT_PROMOTE_SHARE) &&
+           verifier.VerifyString(promote_share()) &&
+           VerifyOffset(verifier, VT_LINK_BIO) &&
+           verifier.VerifyString(link_bio()) &&
+           VerifyField<int32_t>(verifier, VT_MASK) &&
+           verifier.EndTable();
+  }
+};
+
+struct IGTaskBuilder {
+  flatbuffers::FlatBufferBuilder &fbb_;
+  flatbuffers::uoffset_t start_;
+  void add_id(int32_t id) {
+    fbb_.AddElement<int32_t>(IGTask::VT_ID, id, 0);
+  }
+  void add_filename(flatbuffers::Offset<flatbuffers::String> filename) {
+    fbb_.AddOffset(IGTask::VT_FILENAME, filename);
+  }
+  void add_time(flatbuffers::Offset<flatbuffers::String> time) {
+    fbb_.AddOffset(IGTask::VT_TIME, time);
+  }
+  void add_description(flatbuffers::Offset<flatbuffers::String> description) {
+    fbb_.AddOffset(IGTask::VT_DESCRIPTION, description);
+  }
+  void add_hashtags(flatbuffers::Offset<flatbuffers::String> hashtags) {
+    fbb_.AddOffset(IGTask::VT_HASHTAGS, hashtags);
+  }
+  void add_requested_by(flatbuffers::Offset<flatbuffers::String> requested_by) {
+    fbb_.AddOffset(IGTask::VT_REQUESTED_BY, requested_by);
+  }
+  void add_requested_by_phrase(flatbuffers::Offset<flatbuffers::String> requested_by_phrase) {
+    fbb_.AddOffset(IGTask::VT_REQUESTED_BY_PHRASE, requested_by_phrase);
+  }
+  void add_promote_share(flatbuffers::Offset<flatbuffers::String> promote_share) {
+    fbb_.AddOffset(IGTask::VT_PROMOTE_SHARE, promote_share);
+  }
+  void add_link_bio(flatbuffers::Offset<flatbuffers::String> link_bio) {
+    fbb_.AddOffset(IGTask::VT_LINK_BIO, link_bio);
+  }
+  void add_mask(int32_t mask) {
+    fbb_.AddElement<int32_t>(IGTask::VT_MASK, mask, 0);
+  }
+  explicit IGTaskBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+        : fbb_(_fbb) {
+    start_ = fbb_.StartTable();
+  }
+  IGTaskBuilder &operator=(const IGTaskBuilder &);
+  flatbuffers::Offset<IGTask> Finish() {
+    const auto end = fbb_.EndTable(start_);
+    auto o = flatbuffers::Offset<IGTask>(end);
+    return o;
+  }
+};
+
+inline flatbuffers::Offset<IGTask> CreateIGTask(
+    flatbuffers::FlatBufferBuilder &_fbb,
+    int32_t id = 0,
+    flatbuffers::Offset<flatbuffers::String> filename = 0,
+    flatbuffers::Offset<flatbuffers::String> time = 0,
+    flatbuffers::Offset<flatbuffers::String> description = 0,
+    flatbuffers::Offset<flatbuffers::String> hashtags = 0,
+    flatbuffers::Offset<flatbuffers::String> requested_by = 0,
+    flatbuffers::Offset<flatbuffers::String> requested_by_phrase = 0,
+    flatbuffers::Offset<flatbuffers::String> promote_share = 0,
+    flatbuffers::Offset<flatbuffers::String> link_bio = 0,
+    int32_t mask = 0) {
+  IGTaskBuilder builder_(_fbb);
+  builder_.add_mask(mask);
+  builder_.add_link_bio(link_bio);
+  builder_.add_promote_share(promote_share);
+  builder_.add_requested_by_phrase(requested_by_phrase);
+  builder_.add_requested_by(requested_by);
+  builder_.add_hashtags(hashtags);
+  builder_.add_description(description);
+  builder_.add_time(time);
+  builder_.add_filename(filename);
+  builder_.add_id(id);
+  return builder_.Finish();
+}
+
+inline flatbuffers::Offset<IGTask> CreateIGTaskDirect(
+    flatbuffers::FlatBufferBuilder &_fbb,
+    int32_t id = 0,
+    const char *filename = nullptr,
+    const char *time = nullptr,
+    const char *description = nullptr,
+    const char *hashtags = nullptr,
+    const char *requested_by = nullptr,
+    const char *requested_by_phrase = nullptr,
+    const char *promote_share = nullptr,
+    const char *link_bio = nullptr,
+    int32_t mask = 0) {
+  auto filename__ = filename ? _fbb.CreateString(filename) : 0;
+  auto time__ = time ? _fbb.CreateString(time) : 0;
+  auto description__ = description ? _fbb.CreateString(description) : 0;
+  auto hashtags__ = hashtags ? _fbb.CreateString(hashtags) : 0;
+  auto requested_by__ = requested_by ? _fbb.CreateString(requested_by) : 0;
+  auto requested_by_phrase__ = requested_by_phrase ? _fbb.CreateString(requested_by_phrase) : 0;
+  auto promote_share__ = promote_share ? _fbb.CreateString(promote_share) : 0;
+  auto link_bio__ = link_bio ? _fbb.CreateString(link_bio) : 0;
+  return IGData::CreateIGTask(
+      _fbb,
+      id,
+      filename__,
+      time__,
+      description__,
+      hashtags__,
+      requested_by__,
+      requested_by_phrase__,
+      promote_share__,
+      link_bio__,
+      mask);
+}
+
+inline const IGData::IGTask *GetIGTask(const void *buf) {
+  return flatbuffers::GetRoot<IGData::IGTask>(buf);
+}
+
+inline const IGData::IGTask *GetSizePrefixedIGTask(const void *buf) {
+  return flatbuffers::GetSizePrefixedRoot<IGData::IGTask>(buf);
+}
+
+inline bool VerifyIGTaskBuffer(
+    flatbuffers::Verifier &verifier) {
+  return verifier.VerifyBuffer<IGData::IGTask>(nullptr);
+}
+
+inline bool VerifySizePrefixedIGTaskBuffer(
+    flatbuffers::Verifier &verifier) {
+  return verifier.VerifySizePrefixedBuffer<IGData::IGTask>(nullptr);
+}
+
+inline void FinishIGTaskBuffer(
+    flatbuffers::FlatBufferBuilder &fbb,
+    flatbuffers::Offset<IGData::IGTask> root) {
+  fbb.Finish(root);
+}
+
+inline void FinishSizePrefixedIGTaskBuffer(
+    flatbuffers::FlatBufferBuilder &fbb,
+    flatbuffers::Offset<IGData::IGTask> root) {
+  fbb.FinishSizePrefixed(root);
+}
+
+}  // namespace IGData
+
+#endif  // FLATBUFFERS_GENERATED_INSTATASK_IGDATA_H_

+ 17 - 25
headers/util.hpp

@@ -52,35 +52,27 @@ static QString escapeText(QString s) {
     if (s.contains("\t")) {
         s.replace("\t", "\\t");
     }
-    if (s.contains("🙋‍♀️")) {
-        qDebug() << "Replacing woman raising hand emoji";
-        s.replace("🙋‍♀️", ":woman raising hand:");
-    }
-    if (s.contains("❤️")) {
-        qDebug() << "Replacing heart";
-        s.replace("❤️", ":heart:");
-    }
+//    if (s.contains("🙋‍♀️")) {
+//        qDebug() << "Replacing woman raising hand emoji";
+//        s.replace("🙋‍♀️", ":woman raising hand:");
+//    }
+//    if (s.contains("❤️")) {
+//        qDebug() << "Replacing heart";
+//        s.replace("❤️", ":heart:");
+//    }
+//    if (s.contains("🔗")) {
+//        qDebug() << "Replacing link";
+//        s.replace("🔗", ":link:");
+//    }
+//    if (s.contains("⬆️")) {
+//        qDebug() << "Replacing arrow";
+//        s.replace("⬆️", ":arrow_up:");
+//    }
     return s;
 }
 
 static QString escapeTextToRaw(QString s) {
-    qDebug() << "Escaping text";
-    if (s.contains("'")) {
-        qDebug() << "Replacing single quote";
-        s.replace("'", "'\"'\"'");
-    }
-    if (s.contains("\t")) {
-        s.replace("\t", "\\t");
-    }
-    if (s.contains("🙋‍♀️")) {
-        qDebug() << "Replacing woman raising hand emoji";
-        s.replace("🙋‍♀️", ":woman raising hand:");
-    }
-    if (s.contains("❤️")) {
-        qDebug() << "Replacing heart";
-        s.replace("❤️", ":heart:");
-    }
-    return s.toUtf8().constData();
+    return escapeText(s).toUtf8().constData();
 }
 
 std::string getJsonString(std::string s) {

+ 11 - 0
include/client.hpp

@@ -21,6 +21,16 @@ static constexpr int COMMANDS_UPDATE_TYPE = 2;
 static constexpr int EVENT_UPDATE_TYPE = 3;
 static constexpr int PROCESS_REQUEST_TYPE = 4;
 
+enum TaskType {
+    INSTAGRAM = 1,
+    OTHER = 2
+};
+
+namespace TaskCode {
+static constexpr int IGTASKBYTE = 0xFF;
+static constexpr int GENMSGBYTE = 0xFE;
+}
+
 typedef std::map<int, std::string> CommandMap;
 typedef std::map<int, std::vector<std::string>> CommandArgMap;
 typedef QVector<QString> StringVec;
@@ -60,6 +70,7 @@ public slots:
     void sendMessage(const QString& s);
     void sendEncoded(std::string message);
     void sendFileEncoded(QByteArray bytes);
+    void sendTaskEncoded(TaskType type, std::vector<std::string> args);
     void setSelectedApp(std::vector<QString> app_names);
     void sendFile(QByteArray bytes);
 

+ 1 - 0
ky_gui.pro

@@ -39,6 +39,7 @@ HEADERS += \
         include/client.hpp \
         headers/ktextedit.hpp \
         headers/kmessage_codec.hpp \
+        headers/instatask_generated.h \
         headers/json.hpp \
         headers/util.hpp \
         headers/rapidjson/writer.h \

+ 2 - 2
ky_gui.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.11.0, 2020-01-18T00:40:16. -->
+<!-- Written by QtCreator 4.11.0, 2020-01-22T17:14:48. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
@@ -345,7 +345,7 @@
     <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
     <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
     <value type="QString" key="RunConfiguration.WorkingDirectory"></value>
-    <value type="QString" key="RunConfiguration.WorkingDirectory.default">/data/c/ky_gui</value>
+    <value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
    </valuemap>
    <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
   </valuemap>

+ 5 - 3
src/argdialog.cpp

@@ -93,13 +93,15 @@ ArgDialog::ArgDialog(QWidget *parent) :
 
     QObject::connect(ui->devTestButton, &QPushButton::clicked, this, [this]() {
         clearPost();
+
         m_ig_post = IGPost{
             .description = escapeText("My description yay!!!").toUtf8().constData(),
             .datetime = std::to_string(QDateTime::currentDateTime().toTime_t() + 12000),
-            .promote_share = escapeText("Please promote and share ❤️").toUtf8().constData(),
-            .link_in_bio = escapeText("Link in bio!!").toUtf8().constData(),
+            .promote_share = escapeText("If you enjoy the phrase, please like and share 🙋‍♀️").toUtf8().constData(),
+            .link_in_bio = escapeText("Download a FREE PDF of 245 basic verbs (link 🔗 in bio 👆").toUtf8().constData(),
             .hashtags = {"love", "life"},
-            .requested_by = {"unwillingagent"}
+            .requested_by = {"unwillingagent"},
+            .video = {.name = "holy.jpg", .path = "/data/c/ky_gui/assets/holy.jpg"}
         };
     });
 }

+ 59 - 12
src/client.cpp

@@ -13,10 +13,13 @@
 #include <iostream>
 #include <vector>
 #include <future>
+#define FLATBUFFERS_DEBUG_VERIFICATION_FAILURE
 #include <headers/kmessage_codec.hpp>
+#include <headers/instatask_generated.h>
 #include <headers/util.hpp>
 
 using namespace KData;
+using namespace IGData;
 
 static const int MAX_BUFFER_SIZE = 2048;
 static const int MAX_PACKET_SIZE = 4096;
@@ -83,8 +86,7 @@ void Client::handleMessages() {
             emit Client::messageReceived(EVENT_UPDATE_TYPE, event, args);
             if (isUploadCompleteEvent(event.toUtf8().constData())) {
                 outgoing_file.clear();
-                std::string operation_string = createOperation("Schedule", m_task);
-                sendEncoded(operation_string);
+                sendTaskEncoded(TaskType::INSTAGRAM, m_task);
             }
         }
         std::string formatted_json = getJsonString(data_string);
@@ -170,26 +172,71 @@ void Client::sendEncoded(std::string message) {
     uint8_t* encoded_message_buffer = builder.GetBufferPointer();
     uint32_t size = builder.GetSize();
 
-    qDebug() << "Size is " << size;
-
-    uint8_t send_buffer[MAX_BUFFER_SIZE];
-    memset(send_buffer, 0, MAX_BUFFER_SIZE);
+    uint8_t send_buffer[MAX_PACKET_SIZE];
+    memset(send_buffer, 0, MAX_PACKET_SIZE);
     send_buffer[0] = (size & 0xFF) >> 24;
     send_buffer[1] = (size & 0xFF) >> 16;
     send_buffer[2] = (size & 0xFF) >> 8;
     send_buffer[3] = (size & 0xFF);
-    std::memcpy(send_buffer + 4, encoded_message_buffer, size);
+    send_buffer[4] = (TaskCode::GENMSGBYTE & 0xFF);
+    std::memcpy(send_buffer + 5, encoded_message_buffer, size);
     qDebug() << "Ready to send:";
     std::string message_to_send{};
-    for (unsigned int i = 0; i < (size + 4); i++) {
+    for (unsigned int i = 0; i < (size + 5); i++) {
         message_to_send += (char)*(send_buffer + i);
+        qDebug() << (char)*(send_buffer + i);
     }
-    qDebug() << message_to_send.c_str();
+    qDebug() << "Final size: " << (size + 5);
     // Send start operation
-    ::send(m_client_socket_fd, send_buffer, size + 4, 0);
+    ::send(m_client_socket_fd, send_buffer, size + 5, 0);
     builder.Clear();
 }
 
+void Client::sendTaskEncoded(TaskType type, std::vector<std::string> args) {
+    if (type == TaskType::INSTAGRAM) {
+        if (args.size() < 7) {
+            qDebug() << "Not enough arguments to send an IGTask";
+            return;
+        }
+        auto filename = builder.CreateString(args.at(0).c_str(), args.at(0).size());
+        auto time = builder.CreateString(args.at(1).c_str(), args.at(1).size());
+        auto description = builder.CreateString(args.at(2).c_str(), args.at(2).size());
+        auto hashtags = builder.CreateString(args.at(3).c_str(), args.at(3).size());
+        auto requested_by = builder.CreateString(args.at(4).c_str(), args.at(4).size());
+        auto requested_by_phrase = builder.CreateString(args.at(5).c_str(), args.at(5).size());
+        auto promote_share = builder.CreateString(args.at(6).c_str(), args.at(6).size());
+        auto link_bio = builder.CreateString(args.at(7).c_str(), args.at(7).size());
+//        auto mask = std::stoi(args.at(8));
+
+        flatbuffers::Offset<IGTask> ig_task = CreateIGTask(builder, 96, filename, time, description, hashtags, requested_by, requested_by_phrase, promote_share, link_bio, 16);
+
+        builder.Finish(ig_task);
+
+        uint8_t* encoded_message_buffer = builder.GetBufferPointer();
+        uint32_t size = builder.GetSize();
+
+        uint8_t send_buffer[MAX_PACKET_SIZE];
+        memset(send_buffer, 0, MAX_PACKET_SIZE);
+        send_buffer[0] = (size >> 24) & 0xFF;
+        send_buffer[1] = (size >> 16) & 0xFF;
+        send_buffer[2] = (size >> 8) & 0xFF;
+        send_buffer[3] = size & 0xFF;
+        send_buffer[4] = (TaskCode::IGTASKBYTE & 0xFF);
+
+        std::memcpy(send_buffer + 5, encoded_message_buffer, size);
+        qDebug() << "Ready to send:";
+        std::string message_to_send{};
+        for (unsigned int i = 0; i < (size + 5); i++) {
+            message_to_send += (char)*(send_buffer + i);
+            qDebug() << (char)*(send_buffer + i);
+        }
+        qDebug() << "Final size: " << (size + 5);
+        // Send start operation
+        ::send(m_client_socket_fd, send_buffer, size + 5, 0);
+        builder.Clear();
+    }
+}
+
 void Client::sendPackets(uint8_t* data, int size) {
     uint32_t total_size = static_cast<uint32_t>(size + HEADER_SIZE);
     uint32_t total_packets = static_cast<uint32_t>(ceil(
@@ -307,8 +354,8 @@ void Client::scheduleTask(std::vector<std::string> task_args, bool file_pending)
         m_task = task_args;
     } else {
         qDebug() << "Requesting a task to be scheduled";
-        std::string operation_string = createOperation("Schedule", task_args);
-        sendEncoded(operation_string);
+//        std::string operation_string = createOperation("Schedule", task_args);
+        sendTaskEncoded(TaskType::INSTAGRAM, task_args);
     }
 }
 

+ 64 - 26
ui_argdialog.h

@@ -50,22 +50,34 @@ public:
         QIcon icon;
         icon.addFile(QString::fromUtf8("favicon.ico"), QSize(), QIcon::Normal, QIcon::Off);
         ArgDialog->setWindowIcon(icon);
-        ArgDialog->setStyleSheet(QString::fromUtf8("background-color: rgb(33, 33, 33);"));
+        ArgDialog->setStyleSheet(QString::fromUtf8("border-color: rgb(0, 0, 0);\n"
+"background-color: rgb(0, 43, 54);"));
         argCommandButtons = new QDialogButtonBox(ArgDialog);
         argCommandButtons->setObjectName(QString::fromUtf8("argCommandButtons"));
-        argCommandButtons->setGeometry(QRect(340, 510, 201, 32));
+        argCommandButtons->setGeometry(QRect(330, 510, 211, 32));
+        QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+        sizePolicy.setHorizontalStretch(0);
+        sizePolicy.setVerticalStretch(0);
+        sizePolicy.setHeightForWidth(argCommandButtons->sizePolicy().hasHeightForWidth());
+        argCommandButtons->setSizePolicy(sizePolicy);
         argCommandButtons->setLayoutDirection(Qt::LeftToRight);
         argCommandButtons->setAutoFillBackground(false);
-        argCommandButtons->setStyleSheet(QString::fromUtf8("background-color: rgb(203, 0, 239);\n"
-"color: rgb(16, 16, 16);"));
+        argCommandButtons->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 85, 0);\n"
+"font: 87 11pt \"Noto Sans\";\n"
+"color: rgb(0, 43, 54);\n"
+"font-weight: 700;\n"
+"padding: 4px;"));
         argCommandButtons->setOrientation(Qt::Horizontal);
         argCommandButtons->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);
         argCommandButtons->setCenterButtons(true);
         addArgument = new QPushButton(ArgDialog);
         addArgument->setObjectName(QString::fromUtf8("addArgument"));
         addArgument->setGeometry(QRect(380, 190, 80, 26));
-        addArgument->setStyleSheet(QString::fromUtf8("background-color: rgb(203, 0, 239);\n"
-"color: rgb(16, 16, 16);"));
+        addArgument->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 85, 0);\n"
+"font: 87 11pt \"Noto Sans\";\n"
+"color: rgb(0, 43, 54);\n"
+"font-weight: 700;\n"
+"padding: 4px;"));
         argDialogTitle = new QLabel(ArgDialog);
         argDialogTitle->setObjectName(QString::fromUtf8("argDialogTitle"));
         argDialogTitle->setGeometry(QRect(210, 10, 231, 51));
@@ -78,20 +90,27 @@ public:
         addFile = new QPushButton(ArgDialog);
         addFile->setObjectName(QString::fromUtf8("addFile"));
         addFile->setGeometry(QRect(190, 220, 80, 26));
-        addFile->setStyleSheet(QString::fromUtf8("background-color: rgb(203, 0, 239);\n"
-"color: rgb(16, 16, 16);"));
+        addFile->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 85, 0);\n"
+"font: 87 11pt \"Noto Sans\";\n"
+"color: rgb(0, 43, 54);\n"
+"font-weight: 700;\n"
+"padding: 4px;"));
         label = new QLabel(ArgDialog);
         label->setObjectName(QString::fromUtf8("label"));
-        label->setGeometry(QRect(60, 290, 91, 18));
+        label->setGeometry(QRect(60, 290, 111, 18));
+        label->setStyleSheet(QString::fromUtf8("font: 75 11pt \"Noto Sans\";\n"
+"color: rgb(131, 148, 150);\n"
+"font-weight: 700;"));
         argList = new QTableWidget(ArgDialog);
         if (argList->columnCount() < 2)
             argList->setColumnCount(2);
         argList->setObjectName(QString::fromUtf8("argList"));
         argList->setGeometry(QRect(60, 320, 481, 171));
-        argList->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 255, 255);\n"
-"color: rgb(5, 5, 5);\n"
-"font: 87 10pt \"Noto Sans\";\n"
-"selection-background-color: rgb(255, 0, 174);"));
+        argList->setStyleSheet(QString::fromUtf8("font: 87 11pt \"Noto Sans\";\n"
+"background-color: rgb(7, 54, 66);\n"
+"color: rgb(131, 148, 150);\n"
+"font-weight: 700;\n"
+""));
         argList->setColumnCount(2);
         argList->horizontalHeader()->setCascadingSectionResizes(false);
         argList->horizontalHeader()->setMinimumSectionSize(100);
@@ -101,21 +120,35 @@ public:
         label_2 = new QLabel(ArgDialog);
         label_2->setObjectName(QString::fromUtf8("label_2"));
         label_2->setGeometry(QRect(130, 80, 58, 18));
+        label_2->setStyleSheet(QString::fromUtf8("font: 75 11pt \"Noto Sans\";\n"
+"color: rgb(131, 148, 150);\n"
+"font-weight: 700;"));
         label_3 = new QLabel(ArgDialog);
         label_3->setObjectName(QString::fromUtf8("label_3"));
-        label_3->setGeometry(QRect(120, 130, 41, 18));
+        label_3->setGeometry(QRect(110, 130, 51, 20));
+        label_3->setStyleSheet(QString::fromUtf8("font: 75 11pt \"Noto Sans\";\n"
+"color: rgb(131, 148, 150);\n"
+"font-weight: 700;"));
         label_4 = new QLabel(ArgDialog);
         label_4->setObjectName(QString::fromUtf8("label_4"));
-        label_4->setGeometry(QRect(90, 220, 71, 20));
+        label_4->setGeometry(QRect(60, 220, 101, 20));
+        label_4->setStyleSheet(QString::fromUtf8("font: 75 11pt \"Noto Sans\";\n"
+"color: rgb(131, 148, 150);\n"
+"font-weight: 700;"));
         argInput = new QTextEdit(ArgDialog);
         argInput->setObjectName(QString::fromUtf8("argInput"));
         argInput->setGeometry(QRect(190, 130, 281, 51));
-        argInput->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 255, 255);\n"
-"color: rgb(5, 5, 5);\n"
-"font: 87 10pt \"Noto Sans\";"));
+        argInput->setStyleSheet(QString::fromUtf8("font: 87 11pt \"Noto Sans\";\n"
+"background-color: rgb(7, 54, 66);\n"
+"color: rgb(131, 148, 150);\n"
+"font-weight: 700;\n"
+""));
         label_5 = new QLabel(ArgDialog);
         label_5->setObjectName(QString::fromUtf8("label_5"));
-        label_5->setGeometry(QRect(130, 260, 31, 20));
+        label_5->setGeometry(QRect(120, 260, 41, 20));
+        label_5->setStyleSheet(QString::fromUtf8("font: 75 11pt \"Noto Sans\";\n"
+"color: rgb(131, 148, 150);\n"
+"font-weight: 700;"));
         dateTime = new QDateTimeEdit(ArgDialog);
         dateTime->setObjectName(QString::fromUtf8("dateTime"));
         dateTime->setGeometry(QRect(200, 260, 194, 27));
@@ -127,15 +160,20 @@ public:
         argType->addItem(QString());
         argType->setObjectName(QString::fromUtf8("argType"));
         argType->setGeometry(QRect(190, 80, 141, 31));
-        argType->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 255, 255);\n"
-"color: rgb(5, 5, 5);\n"
-"font: 87 10pt \"Noto Sans\";\n"
-"selection-background-color: rgb(255, 0, 174);"));
+        argType->setStyleSheet(QString::fromUtf8("font: 87 11pt \"Noto Sans\";\n"
+"background-color: rgb(7, 54, 66);\n"
+"color: rgb(131, 148, 150);\n"
+"font-weight: 700;\n"
+""));
         devTestButton = new QPushButton(ArgDialog);
         devTestButton->setObjectName(QString::fromUtf8("devTestButton"));
-        devTestButton->setGeometry(QRect(240, 590, 80, 26));
-        devTestButton->setStyleSheet(QString::fromUtf8("background-color: rgb(59, 255, 0);\n"
-"color: rgb(0, 0, 0);"));
+        devTestButton->setGeometry(QRect(240, 590, 81, 31));
+        devTestButton->setStyleSheet(QString::fromUtf8("background-color: rgb(130, 255, 121);\n"
+"background-color: rgb(2, 180, 43);\n"
+"font: 87 11pt \"Noto Sans\";\n"
+"color: rgb(0, 0, 0);\n"
+"font-weight: 700;\n"
+"padding: 4px;"));
 
         retranslateUi(ArgDialog);
         QObject::connect(argCommandButtons, SIGNAL(accepted()), ArgDialog, SLOT(accept()));