|
@@ -23,6 +23,7 @@ void CmdManager::init() {
|
|
|
cmdmap["status"] = &CmdManager::handleStatus;
|
|
|
cmdmap["close"] = &CmdManager::handleClose;
|
|
|
cmdmap["list"] = &CmdManager::handleList;
|
|
|
+ cmdmap["extendedlist"] = &CmdManager::handleExtendedList;
|
|
|
cmdmap["connect"] = &CmdManager::handleConnect;
|
|
|
cmdmap["version"] = &CmdManager::handleVersion;
|
|
|
cmdmap["login"] = &CmdManager::handleLogin;
|
|
@@ -55,13 +56,33 @@ void CmdManager::handleStatus(Json::Value root) { emit qmlHandler->footerSetStat
|
|
|
void CmdManager::handleClose(Json::Value root) { CliManager::setProgramActive(false); }
|
|
|
|
|
|
void CmdManager::handleList(Json::Value root) {
|
|
|
+ char sizebuf[256];
|
|
|
+ snprintf(sizebuf, 256, "%.2f", 4.2f);
|
|
|
if (root["accept"] == true) {
|
|
|
emit qmlHandler->receivingClearFileList();
|
|
|
|
|
|
// Get the array of file Names
|
|
|
auto fileNames = root["names"];
|
|
|
for (int i = 0; i < fileNames.size(); i++) {
|
|
|
- emit qmlHandler->receivingListFile(QString::fromStdString(fileNames[i].asString().c_str()), boost::filesystem::exists(fileNames[i].asString()));
|
|
|
+ emit qmlHandler->receivingListFile(QString::fromStdString(fileNames[i].asString()), QString::fromStdString(sizebuf), QString("Decryptable"),
|
|
|
+ boost::filesystem::exists(fileNames[i].asString()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ emit qmlHandler->log(root["error"].asString().c_str());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CmdManager::handleExtendedList(Json::Value root) {
|
|
|
+ char sizebuf[256];
|
|
|
+ if (root["accept"] == true) {
|
|
|
+ emit qmlHandler->receivingClearFileList();
|
|
|
+
|
|
|
+ // Get the array of file Names
|
|
|
+ auto files = root["files"];
|
|
|
+ for (Json::Value f : files) {
|
|
|
+ snprintf(sizebuf, 256, "%.2f", f["size"].asFloat());
|
|
|
+ emit qmlHandler->receivingListFile(QString::fromStdString(f["name"].asString()), QString::fromStdString(sizebuf),
|
|
|
+ QString::fromStdString(f["encrypted"].asString()), boost::filesystem::exists(f["name"].asString()));
|
|
|
}
|
|
|
} else {
|
|
|
emit qmlHandler->log(root["error"].asString().c_str());
|
|
@@ -90,7 +111,7 @@ void CmdManager::handleVersion(Json::Value root) {
|
|
|
void CmdManager::handleLogin(Json::Value root) {
|
|
|
if (root["accept"] == true) {
|
|
|
emit qmlHandler->loginSignupPopupClose();
|
|
|
- CliManager::writeToCli("list");
|
|
|
+ CliManager::writeToCli("extendedlist");
|
|
|
qmlHandler->loadSettingsToGUI();
|
|
|
} else {
|
|
|
emit qmlHandler->loginSetStatus(root["error"].asString().c_str());
|
|
@@ -156,17 +177,19 @@ void CmdManager::handleDeleteFile(Json::Value root) {
|
|
|
|
|
|
void CmdManager::handleNotifications(Json::Value root) {
|
|
|
if (root["accept"] == true) {
|
|
|
- // Get the array of notifications
|
|
|
- auto notifications = root["messages"];
|
|
|
- for (int i = 0; i < notifications.size(); i++) {
|
|
|
- emit qmlHandler->notification(QString::fromStdString(notifications[i].asString().c_str()));
|
|
|
+ if (!root["messages"].isNull()) {
|
|
|
+ // Get the array of notifications
|
|
|
+ auto notifications = root["messages"];
|
|
|
+ for (int i = 0; i < notifications.size(); i++) {
|
|
|
+ emit qmlHandler->notification(QString::fromStdString(notifications[i].asString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (notifications.size() > 1)
|
|
|
+ emit qmlHandler->showDesktopNotification("Covert Channel - New Notifications",
|
|
|
+ "You have multiple new notifications. Open the program to see them.");
|
|
|
+ else if (notifications.size() == 1)
|
|
|
+ emit qmlHandler->showDesktopNotification("Covert Channel - New Notification", QString::fromStdString(notifications[0].asString()));
|
|
|
}
|
|
|
-
|
|
|
- if (notifications.size() > 1)
|
|
|
- emit qmlHandler->showDesktopNotification("Covert Channel - New Notifications",
|
|
|
- "You have multiple new notifications. Open the program to see them.");
|
|
|
- else if (notifications.size() == 1)
|
|
|
- emit qmlHandler->showDesktopNotification("Covert Channel - New Notification", QString::fromStdString(notifications[0].asString().c_str()));
|
|
|
} else {
|
|
|
emit qmlHandler->log(root["error"].asString().c_str());
|
|
|
}
|