瀏覽代碼

made GUI ready for protocol 0.2

Cyamond 5 年之前
父節點
當前提交
6edb89ef18
共有 1 個文件被更改,包括 12 次插入6 次删除
  1. 12 6
      gui/src/qmlhandler.cpp

+ 12 - 6
gui/src/qmlhandler.cpp

@@ -52,15 +52,15 @@ void QMLHandler::handleJSON(string buffer) {
   const Json::Value command = root["command"];
   string cmd = command.asString();
 
-  if (cmd == "status") {
+  if (cmd.compare("status")) {
     emit footerSetStatus(root["response"].asString().c_str());
   }
 
-  else if (cmd == "close") {
+  else if (cmd.compare("close")) {
     programActive = false;
   }
 
-  else if (cmd == "list") {
+  else if (cmd.compare("listdata")) {
     emit receivingClearFileList();
     // Get the array of file Names
     auto fileNames = root["names"];
@@ -69,6 +69,12 @@ void QMLHandler::handleJSON(string buffer) {
           QString::fromStdString(fileNames[i].asString().c_str()));
     }
   }
+
+  else if (cmd.compare("version")) {
+    // TODO: Change hardcoded login details to input values
+    write(outpipefd[1], "user\n", strlen("user\n"));
+    write(outpipefd[1], "pass\n", strlen("pass\n"));
+  }
 }
 
 // This method is a loop which runs in a seperate thread.
@@ -88,12 +94,12 @@ void QMLHandler::readPipeLoop() {
     if (inPipeStatus.revents & POLLIN) {
       readOffset += read(inpipefd[0], buf + readOffset, 1);
 
-      // We need this once we receive minimized JSON from the CLI
-      /*if(buf[readOffset-1] == '\n') {
+      if(buf[readOffset-1] == '\n') {
         pollCount = 10;
       } else {
         pollCount = 0;
-      }*/
+      }
+
       pollCount = 0;
 
     } else {