|
@@ -15,10 +15,11 @@ using namespace std;
|
|
|
|
|
|
namespace CmdManager {
|
|
|
QMLHandler *qmlHandler;
|
|
|
-map<string, void (*)(Json::Value root)> cmdmap;
|
|
|
+map<string, void (*)(Json::Value)> cmdmap;
|
|
|
} // namespace CmdManager
|
|
|
|
|
|
void CmdManager::init() {
|
|
|
+ cmdmap["error"] = &CmdManager::handleError;
|
|
|
cmdmap["status"] = &CmdManager::handleStatus;
|
|
|
cmdmap["close"] = &CmdManager::handleClose;
|
|
|
cmdmap["list"] = &CmdManager::handleList;
|
|
@@ -32,11 +33,20 @@ void CmdManager::init() {
|
|
|
cmdmap["getdata"] = &CmdManager::handleGetData;
|
|
|
cmdmap["deleteme"] = &CmdManager::handleDeleteMe;
|
|
|
cmdmap["deletefile"] = &CmdManager::handleDeleteFile;
|
|
|
+ cmdmap["notifications"] = &CmdManager::handleNotifications;
|
|
|
}
|
|
|
|
|
|
void CmdManager::setQmlHandler(QMLHandler *q) { qmlHandler = q; }
|
|
|
|
|
|
-void CmdManager::executeCmd(string cmd, Json::Value root) { cmdmap[cmd](root); }
|
|
|
+void CmdManager::executeCmd(string cmd, Json::Value root) {
|
|
|
+ map<string, void (*)(Json::Value)>::iterator it = cmdmap.find(cmd);
|
|
|
+ if (it == cmdmap.end()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ cmdmap[cmd](root);
|
|
|
+}
|
|
|
+
|
|
|
+void CmdManager::handleError(Json::Value root) { emit qmlHandler->log(root["error"].asString().c_str()); }
|
|
|
|
|
|
void CmdManager::handleStatus(Json::Value root) { emit qmlHandler->footerSetStatus(root["response"].asString().c_str()); }
|
|
|
|
|
@@ -141,3 +151,21 @@ void CmdManager::handleDeleteFile(Json::Value root) {
|
|
|
emit qmlHandler->log(message);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+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 (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());
|
|
|
+ }
|
|
|
+}
|