|
@@ -48,26 +48,30 @@ 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") {
|
|
|
- emit receivingClearFileList();
|
|
|
-
|
|
|
- // Get the array of file Names
|
|
|
- auto fileNames = root["names"];
|
|
|
- for (int i = 0; i < fileNames.size(); i++) {
|
|
|
- emit receivingListFile(
|
|
|
- QString::fromStdString(fileNames[i].asString().c_str()));
|
|
|
+ else if (cmd.compare("list")) {
|
|
|
+ if (root["accept"] == true) {
|
|
|
+ emit receivingClearFileList();
|
|
|
+
|
|
|
+ // Get the array of file Names
|
|
|
+ auto fileNames = root["names"];
|
|
|
+ for (int i = 0; i < fileNames.size(); i++) {
|
|
|
+ emit receivingListFile(
|
|
|
+ QString::fromStdString(fileNames[i].asString().c_str()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ emit log(root["error"].asString().c_str());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- else if (cmd == "connect") {
|
|
|
+ else if (cmd.compare("connect")) {
|
|
|
if (root["accept"] == false) {
|
|
|
emit ipPopupSetStatus(root["error"].asString().c_str());
|
|
|
close(outpipefd[1]);
|
|
@@ -75,7 +79,7 @@ void QMLHandler::handleJSON(string buffer) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- else if (cmd == "version") {
|
|
|
+ else if (cmd.compare("version")) {
|
|
|
if (root["accept"] == true) {
|
|
|
write(outpipefd[1], _USERNAME.toUtf8().constData(),
|
|
|
strlen(_USERNAME.toUtf8().constData()));
|
|
@@ -91,7 +95,7 @@ void QMLHandler::handleJSON(string buffer) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- else if (cmd == "login") {
|
|
|
+ else if (cmd.compare("login")) {
|
|
|
if (root["accept"] == true) {
|
|
|
emit ipPopupClose();
|
|
|
} else {
|
|
@@ -100,6 +104,32 @@ void QMLHandler::handleJSON(string buffer) {
|
|
|
close(inpipefd[0]);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ else if (cmd.compare("put")) {
|
|
|
+ if (root["accept"] == false) {
|
|
|
+ QString errorMessage = QString::fromStdString(
|
|
|
+ string("Error when uploading file " + root["file"].asString() +
|
|
|
+ ":\n" + root["error"].asString()));
|
|
|
+ emit log(errorMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (cmd.compare("putdata")) {
|
|
|
+ // TODO: Show speed and handle Error
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (cmd.compare("get")) {
|
|
|
+ if (root["accept"] == false) {
|
|
|
+ QString errorMessage = QString::fromStdString(
|
|
|
+ string("Error when downloading file " + root["file"].asString() +
|
|
|
+ ":\n" + root["error"].asString()));
|
|
|
+ emit log(errorMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (cmd.compare("getdata")) {
|
|
|
+ // TODO: Show speed and handle Error
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void QMLHandler::readPipeLoop() {
|