|
@@ -10,9 +10,11 @@
|
|
#include <sys/wait.h>
|
|
#include <sys/wait.h>
|
|
#include <thread>
|
|
#include <thread>
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
|
|
#include "qmlhandler.h"
|
|
#include "qmlhandler.h"
|
|
#include <boost/asio.hpp>
|
|
#include <boost/asio.hpp>
|
|
|
|
+#include <boost/filesystem.hpp>
|
|
#include <iostream>
|
|
#include <iostream>
|
|
#include <json/json.h>
|
|
#include <json/json.h>
|
|
|
|
|
|
@@ -122,7 +124,7 @@ void QMLHandler::handleJSON(string buffer) {
|
|
// Get the array of file Names
|
|
// Get the array of file Names
|
|
auto fileNames = root["names"];
|
|
auto fileNames = root["names"];
|
|
for (int i = 0; i < fileNames.size(); i++) {
|
|
for (int i = 0; i < fileNames.size(); i++) {
|
|
- emit receivingListFile(QString::fromStdString(fileNames[i].asString().c_str()));
|
|
|
|
|
|
+ emit receivingListFile(QString::fromStdString(fileNames[i].asString().c_str()), boost::filesystem::exists(fileNames[i].asString()));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
emit log(root["error"].asString().c_str());
|
|
emit log(root["error"].asString().c_str());
|
|
@@ -154,6 +156,7 @@ void QMLHandler::handleJSON(string buffer) {
|
|
else if (!cmd.compare("login")) {
|
|
else if (!cmd.compare("login")) {
|
|
if (root["accept"] == true) {
|
|
if (root["accept"] == true) {
|
|
emit loginSignupPopupClose();
|
|
emit loginSignupPopupClose();
|
|
|
|
+ write(outpipefd[1], "list\n", strlen("list\n"));
|
|
} else {
|
|
} else {
|
|
emit loginSetStatus(root["error"].asString().c_str());
|
|
emit loginSetStatus(root["error"].asString().c_str());
|
|
reopenCLI(_IP);
|
|
reopenCLI(_IP);
|
|
@@ -187,6 +190,11 @@ void QMLHandler::handleJSON(string buffer) {
|
|
QString errorMessage = QString::fromStdString(string("Error when downloading file " + root["file"].asString() + ":\n" + root["error"].asString()));
|
|
QString errorMessage = QString::fromStdString(string("Error when downloading file " + root["file"].asString() + ":\n" + root["error"].asString()));
|
|
emit log(errorMessage);
|
|
emit log(errorMessage);
|
|
}
|
|
}
|
|
|
|
+ else {
|
|
|
|
+ string fileName = root["file"].asString();
|
|
|
|
+ //TODO: Only do this in getdata when remaining is 0 (when the file is fully downloaded) - maybe set text to "downloading.." in between
|
|
|
|
+ emit receivingDisableDownloadButton(QString::fromStdString(string(fileName)));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
else if (!cmd.compare("getdata")) {
|
|
else if (!cmd.compare("getdata")) {
|
|
@@ -279,7 +287,7 @@ void QMLHandler::onSendingClearSelectionButton() {
|
|
// Receiving
|
|
// Receiving
|
|
void QMLHandler::onReceivingListFilesButton() { write(outpipefd[1], "list\n", strlen("list\n")); }
|
|
void QMLHandler::onReceivingListFilesButton() { write(outpipefd[1], "list\n", strlen("list\n")); }
|
|
|
|
|
|
-void QMLHandler::onReceivingGetFileButton(QString fileName) {
|
|
|
|
|
|
+void QMLHandler::onReceivingDownloadFileButton(QString fileName) {
|
|
QString command = "get " + fileName + "\n";
|
|
QString command = "get " + fileName + "\n";
|
|
write(outpipefd[1], command.toUtf8().constData(), strlen(command.toUtf8().constData()));
|
|
write(outpipefd[1], command.toUtf8().constData(), strlen(command.toUtf8().constData()));
|
|
}
|
|
}
|