Cyamond 5 年之前
父節點
當前提交
81774cb350
共有 2 個文件被更改,包括 12 次插入19 次删除
  1. 1 1
      gui/src/LoginForm.ui.qml
  2. 11 18
      gui/src/qmlhandler.cpp

+ 1 - 1
gui/src/LoginForm.ui.qml

@@ -83,7 +83,7 @@ Page {
                 // @disable-check M223
                 if (loginLoginButton.enabled) {
                     // @disable-check M222
-
+                    _qmlHandler.onLoginLoginButton(loginUsernameInput.text, loginPasswordInput.text)
                 }
             }
         }

+ 11 - 18
gui/src/qmlhandler.cpp

@@ -110,15 +110,15 @@ void QMLHandler::handleJSON(string buffer) {
   string cmd = command.asString();
   qInfo() << QString::fromStdString("Received command " + cmd);
 
-  if (cmd.compare("status")) {
+  if (!cmd.compare("status")) {
     emit footerSetStatus(root["response"].asString().c_str());
   }
 
-  else if (cmd.compare("close")) {
+  else if (!cmd.compare("close")) {
     programActive = false;
   }
 
-  else if (cmd.compare("list")) {
+  else if (!cmd.compare("list")) {
     if (root["accept"] == true) {
       emit receivingClearFileList();
 
@@ -133,7 +133,7 @@ void QMLHandler::handleJSON(string buffer) {
     }
   }
 
-  else if (cmd == "connect") {
+  else if (!cmd.compare("connect")) {
     if (root["accept"].asBool()) {
     } else {
       emit ipPopupSetStatus(root["error"].asString().c_str());
@@ -141,7 +141,7 @@ void QMLHandler::handleJSON(string buffer) {
     }
   }
 
-  else if (cmd.compare("version")) {
+  else if (!cmd.compare("version")) {
     if (root["accept"] == true) {
       emit ipPopupClose();
       emit loginSignupPopupOpen();
@@ -154,7 +154,7 @@ void QMLHandler::handleJSON(string buffer) {
     }
   }
 
-  else if (cmd.compare("login")) {
+  else if (!cmd.compare("login")) {
     if (root["accept"] == true) {
       emit loginSignupPopupClose();
     } else {
@@ -163,7 +163,7 @@ void QMLHandler::handleJSON(string buffer) {
     }
   }
 
-  else if (cmd.compare("signup")) {
+  else if (!cmd.compare("signup")) {
     if (root["accept"] == true) {
       emit loginSignupPopupClose();
     } else {
@@ -172,7 +172,7 @@ void QMLHandler::handleJSON(string buffer) {
     }
   }
 
-  else if (cmd.compare("put")) {
+  else if (!cmd.compare("put")) {
     if (root["accept"] == false) {
       QString errorMessage = QString::fromStdString(
           string("Error when uploading file " + root["file"].asString() +
@@ -181,11 +181,11 @@ void QMLHandler::handleJSON(string buffer) {
     }
   }
 
-  else if (cmd.compare("putdata")) {
+  else if (!cmd.compare("putdata")) {
     // TODO: Show speed and handle Error
   }
 
-  else if (cmd.compare("get")) {
+  else if (!cmd.compare("get")) {
     if (root["accept"] == false) {
       QString errorMessage = QString::fromStdString(
           string("Error when downloading file " + root["file"].asString() +
@@ -194,7 +194,7 @@ void QMLHandler::handleJSON(string buffer) {
     }
   }
 
-  else if (cmd.compare("getdata")) {
+  else if (!cmd.compare("getdata")) {
     // TODO: Show speed and handle Error
   }
 }
@@ -217,13 +217,6 @@ void QMLHandler::readPipeLoop() {
 
     if (inPipeStatus.revents & POLLIN) {
       readOffset += read(inpipefd[0], buf + readOffset, 1);
-
-      if (buf[readOffset - 1] == '\n') {
-        pollCount = 10;
-      } else {
-        pollCount = 0;
-      }
-
       pollCount = 0;
 
     } else {