|
@@ -38,6 +38,7 @@ void CmdManager::init() {
|
|
cmdmap["extendedstatus"] = &CmdManager::handleExtendedStatus;
|
|
cmdmap["extendedstatus"] = &CmdManager::handleExtendedStatus;
|
|
cmdmap["keyfile"] = &CmdManager::handleKeyfile;
|
|
cmdmap["keyfile"] = &CmdManager::handleKeyfile;
|
|
cmdmap["closekey"] = &CmdManager::handleClosekey;
|
|
cmdmap["closekey"] = &CmdManager::handleClosekey;
|
|
|
|
+ cmdmap["disconnect"] = &CmdManager::handleDisconnect;
|
|
|
|
|
|
filemap.clear();
|
|
filemap.clear();
|
|
}
|
|
}
|
|
@@ -69,11 +70,11 @@ void CmdManager::emitFileList() {
|
|
progstr = it->second.type + " via " + it->second.method + "\n" + std::to_string(it->second.progress) + "%" + " @ " + speedbuf;
|
|
progstr = it->second.type + " via " + it->second.method + "\n" + std::to_string(it->second.progress) + "%" + " @ " + speedbuf;
|
|
} else
|
|
} else
|
|
progstr = it->second.type + "\n" + std::to_string(it->second.progress) + "%";
|
|
progstr = it->second.type + "\n" + std::to_string(it->second.progress) + "%";
|
|
- emit qmlHandler->receivingUpdateFile(it->first.c_str(), progstr.c_str(), it->second.type == "Queued" || it->second.type == "Sending");
|
|
|
|
|
|
+ emit qmlHandler->serverFilesUpdateFile(it->first.c_str(), progstr.c_str(), it->second.type == "Queued" || it->second.type == "Sending");
|
|
}
|
|
}
|
|
// else emit plain entry
|
|
// else emit plain entry
|
|
else
|
|
else
|
|
- emit qmlHandler->receivingUpdateFile(it->first.c_str(), "", false);
|
|
|
|
|
|
+ emit qmlHandler->serverFilesUpdateFile(it->first.c_str(), "", false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -109,6 +110,7 @@ void CmdManager::executeCmd(string cmd, Json::Value root) {
|
|
}
|
|
}
|
|
|
|
|
|
void CmdManager::setCachedIP(QString ip) { cachedIP = ip; }
|
|
void CmdManager::setCachedIP(QString ip) { cachedIP = ip; }
|
|
|
|
+
|
|
void CmdManager::setCachedPort(QString port) { cachedPort = port; }
|
|
void CmdManager::setCachedPort(QString port) { cachedPort = port; }
|
|
|
|
|
|
void CmdManager::handleError(Json::Value root) { emit qmlHandler->log(root["error"].asString().c_str()); }
|
|
void CmdManager::handleError(Json::Value root) { emit qmlHandler->log(root["error"].asString().c_str()); }
|
|
@@ -121,14 +123,14 @@ void CmdManager::handleList(Json::Value root) {
|
|
char sizebuf[256];
|
|
char sizebuf[256];
|
|
snprintf(sizebuf, 256, "%.2f", 4.2f);
|
|
snprintf(sizebuf, 256, "%.2f", 4.2f);
|
|
if (root["accept"] == true) {
|
|
if (root["accept"] == true) {
|
|
- emit qmlHandler->receivingClearFileList();
|
|
|
|
|
|
+ emit qmlHandler->serverFilesClearFileList();
|
|
filemap.clear();
|
|
filemap.clear();
|
|
|
|
|
|
// 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 qmlHandler->receivingListFile(QString::fromStdString(fileNames[i].asString()), QString::fromStdString(sizebuf), QString("Decryptable"),
|
|
|
|
- !!ifstream(fileNames[i].asString()));
|
|
|
|
|
|
+ emit qmlHandler->serverFilesListFile(QString::fromStdString(fileNames[i].asString()), QString::fromStdString(sizebuf), QString("Decryptable"),
|
|
|
|
+ !!ifstream(fileNames[i].asString()));
|
|
filemap[fileNames[i].asString()] = {false, "", "", 0, 0};
|
|
filemap[fileNames[i].asString()] = {false, "", "", 0, 0};
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -139,15 +141,15 @@ void CmdManager::handleList(Json::Value root) {
|
|
void CmdManager::handleExtendedList(Json::Value root) {
|
|
void CmdManager::handleExtendedList(Json::Value root) {
|
|
char sizebuf[256];
|
|
char sizebuf[256];
|
|
if (root["accept"] == true) {
|
|
if (root["accept"] == true) {
|
|
- emit qmlHandler->receivingClearFileList();
|
|
|
|
|
|
+ emit qmlHandler->serverFilesClearFileList();
|
|
filemap.clear();
|
|
filemap.clear();
|
|
|
|
|
|
// Get the array of file Names
|
|
// Get the array of file Names
|
|
auto files = root["files"];
|
|
auto files = root["files"];
|
|
for (Json::Value f : files) {
|
|
for (Json::Value f : files) {
|
|
snprintf(sizebuf, 256, "%.2f", f["size"].asFloat());
|
|
snprintf(sizebuf, 256, "%.2f", f["size"].asFloat());
|
|
- emit qmlHandler->receivingListFile(QString::fromStdString(f["name"].asString()), QString::fromStdString(sizebuf),
|
|
|
|
- QString::fromStdString(f["encrypted"].asString()), !!ifstream(f["name"].asString()));
|
|
|
|
|
|
+ emit qmlHandler->serverFilesListFile(QString::fromStdString(f["name"].asString()), QString::fromStdString(sizebuf),
|
|
|
|
+ QString::fromStdString(f["encrypted"].asString()), !!ifstream(f["name"].asString()));
|
|
filemap[f["name"].asString()] = {false, "", "", 0, 0};
|
|
filemap[f["name"].asString()] = {false, "", "", 0, 0};
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -206,7 +208,10 @@ void CmdManager::handlePut(Json::Value root) {
|
|
}
|
|
}
|
|
|
|
|
|
void CmdManager::handlePutData(Json::Value root) {
|
|
void CmdManager::handlePutData(Json::Value root) {
|
|
- // TODO: Show speed and handle Error
|
|
|
|
|
|
+ if (root["cancel"] == true) {
|
|
|
|
+ QString errorMessage = QString::fromStdString(string("Error when uploading file " + root["file"].asString() + ":\n" + root["error"].asString()));
|
|
|
|
+ emit qmlHandler->log(errorMessage);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void CmdManager::handleGet(Json::Value root) {
|
|
void CmdManager::handleGet(Json::Value root) {
|
|
@@ -215,17 +220,20 @@ void CmdManager::handleGet(Json::Value root) {
|
|
emit qmlHandler->log(errorMessage);
|
|
emit qmlHandler->log(errorMessage);
|
|
} else {
|
|
} else {
|
|
string fileName = root["file"].asString();
|
|
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 qmlHandler->receivingDisableDownloadButton(QString::fromStdString(fileName));
|
|
|
|
|
|
+ emit qmlHandler->serverFilesDisableDownloadButton(QString::fromStdString(fileName));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void CmdManager::handleGetData(Json::Value root) {
|
|
void CmdManager::handleGetData(Json::Value root) {
|
|
- // TODO: Show speed and handle Error
|
|
|
|
|
|
+ if (root["cancel"] == true) {
|
|
|
|
+ QString errorMessage = QString::fromStdString(string("Error when downloading file " + root["file"].asString() + ":\n" + root["error"].asString()));
|
|
|
|
+ emit qmlHandler->log(errorMessage);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void CmdManager::handleDeleteMe(Json::Value root) {
|
|
void CmdManager::handleDeleteMe(Json::Value root) {
|
|
if (root["accept"] == true) {
|
|
if (root["accept"] == true) {
|
|
|
|
+ CliManager::loggedin = true;
|
|
qmlHandler->setRestart(true);
|
|
qmlHandler->setRestart(true);
|
|
emit qmlHandler->closeWindow();
|
|
emit qmlHandler->closeWindow();
|
|
} else {
|
|
} else {
|
|
@@ -235,7 +243,7 @@ void CmdManager::handleDeleteMe(Json::Value root) {
|
|
}
|
|
}
|
|
|
|
|
|
void CmdManager::handleDeleteFile(Json::Value root) {
|
|
void CmdManager::handleDeleteFile(Json::Value root) {
|
|
- emit qmlHandler->receivingCloseConfirmDeletePopup();
|
|
|
|
|
|
+ emit qmlHandler->serverFilesCloseConfirmDeletePopup();
|
|
if (root["accept"] == false) {
|
|
if (root["accept"] == false) {
|
|
QString errorMessage = QString::fromStdString(string("Error when deleting file " + root["file"].asString() + ":\n" + root["error"].asString()));
|
|
QString errorMessage = QString::fromStdString(string("Error when deleting file " + root["file"].asString() + ":\n" + root["error"].asString()));
|
|
emit qmlHandler->log(errorMessage);
|
|
emit qmlHandler->log(errorMessage);
|
|
@@ -325,4 +333,10 @@ void CmdManager::handleClosekey(Json::Value root) {
|
|
} else {
|
|
} else {
|
|
emit qmlHandler->keyfileClosedOK();
|
|
emit qmlHandler->keyfileClosedOK();
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void CmdManager::handleDisconnect(Json::Value root) {
|
|
|
|
+ if (root["accept"] == true) {
|
|
|
|
+ CliManager::loggedin = false;
|
|
|
|
+ }
|
|
|
|
+}
|