Browse Source

made GUI ready for protocol 0.2

Cyamond 5 years ago
parent
commit
6edb89ef18
1 changed files with 12 additions and 6 deletions
  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"];
   const Json::Value command = root["command"];
   string cmd = command.asString();
   string cmd = command.asString();
 
 
-  if (cmd == "status") {
+  if (cmd.compare("status")) {
     emit footerSetStatus(root["response"].asString().c_str());
     emit footerSetStatus(root["response"].asString().c_str());
   }
   }
 
 
-  else if (cmd == "close") {
+  else if (cmd.compare("close")) {
     programActive = false;
     programActive = false;
   }
   }
 
 
-  else if (cmd == "list") {
+  else if (cmd.compare("listdata")) {
     emit receivingClearFileList();
     emit receivingClearFileList();
     // Get the array of file Names
     // Get the array of file Names
     auto fileNames = root["names"];
     auto fileNames = root["names"];
@@ -69,6 +69,12 @@ void QMLHandler::handleJSON(string buffer) {
           QString::fromStdString(fileNames[i].asString().c_str()));
           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.
 // This method is a loop which runs in a seperate thread.
@@ -88,12 +94,12 @@ void QMLHandler::readPipeLoop() {
     if (inPipeStatus.revents & POLLIN) {
     if (inPipeStatus.revents & POLLIN) {
       readOffset += read(inpipefd[0], buf + readOffset, 1);
       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;
         pollCount = 10;
       } else {
       } else {
         pollCount = 0;
         pollCount = 0;
-      }*/
+      }
+
       pollCount = 0;
       pollCount = 0;
 
 
     } else {
     } else {