Jelajahi Sumber

Merge branch 'us41-3-covert-channel-queueing-gui' into 'develop'

US41.3: Covert Channel Queueing (GUI)

Closes #75

See merge request tobias.wach/ccats!74
Serdyukov, Denys 4 tahun lalu
induk
melakukan
3dcd506742

+ 2 - 2
gui/CMakeLists.txt

@@ -10,7 +10,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 find_package(Threads)
 find_package(Boost 1.67 REQUIRED COMPONENTS system filesystem)
-find_package(Qt5 COMPONENTS Core Quick REQUIRED)
+find_package(Qt5 COMPONENTS Core Quick Widgets REQUIRED)
 find_package(PkgConfig REQUIRED)
 pkg_check_modules(JSONCPP REQUIRED jsoncpp)
 
@@ -19,4 +19,4 @@ add_definitions(-DQT_NO_DEBUG_OUTPUT)
 add_executable(${PROJECT_NAME} src/main.cpp src/cmdmanager.cpp src/qmlhandler.cpp src/jsonhandler.cpp src/qml.qrc src/config.cpp src/climanager.cpp include/qmlhandler.h)
 
 include_directories(${Boost_INCLUDE_DIR} ${JSONCPP_INCLUDEDIR} include)
-target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${JSONCPP_LIBRARIES} ${Boost_LIBRARIES} Qt5::Core Qt5::Quick)
+target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${JSONCPP_LIBRARIES} ${Boost_LIBRARIES} Qt5::Core Qt5::Quick Qt5::Widgets)

+ 2 - 0
gui/include/cmdmanager.h

@@ -30,6 +30,8 @@ void handleGetData(Json::Value root);
 void handleDeleteMe(Json::Value root);
 void handleDeleteFile(Json::Value root);
 void handleNotifications(Json::Value root);
+void handleQueue(Json::Value root);
+void handleDequeue(Json::Value root);
 } // namespace CmdManager
 
 #endif // CMDMANAGER_H

+ 5 - 0
gui/include/qmlhandler.h

@@ -137,6 +137,11 @@ public slots:
 
 	// Notifications
 	void onDismissNotificationButton(int id);
+
+	// Queueing
+	void onReceivingQueueFileButton(QString fileName);
+
+	void onReceivingDequeueFileButton(QString fileName);
 };
 
 #endif // QMLHANDLER_H

+ 22 - 2
gui/src/Forms/Receiving/ReceivingFileTemplate.ui.qml

@@ -41,7 +41,7 @@ Item {
             id: fileTemplateFileSize
             Layout.alignment: Qt.AlignCenter
             Layout.preferredHeight: parent.height
-            Layout.preferredWidth: 200
+            Layout.preferredWidth: 100
             verticalAlignment: Text.AlignVCenter
             horizontalAlignment: Text.AlignHCenter
             text: fileSizeText
@@ -52,13 +52,33 @@ Item {
             id: fileTemplateFileDecryptable
             Layout.alignment: Qt.AlignCenter
             Layout.preferredHeight: parent.height
-            Layout.preferredWidth: 200
+            Layout.preferredWidth: 150
             verticalAlignment: Text.AlignVCenter
             horizontalAlignment: Text.AlignHCenter
             text: fileDecryptableText
             color: "#ffffff"
         }
 
+        Button {
+            id: fileTemplateQueueButton
+            Layout.alignment: Qt.AlignCenter
+            Layout.preferredHeight: parent.height
+            Layout.preferredWidth: 100
+            text: qsTr("Enqueue")
+
+            onClicked: _qmlHandler.onReceivingQueueFileButton(fileNameText)
+        }
+
+        Button {
+            id: fileTemplateDequeueButton
+            Layout.alignment: Qt.AlignCenter
+            Layout.preferredHeight: parent.height
+            Layout.preferredWidth: 100
+            text: qsTr("Dequeue")
+
+            onClicked: _qmlHandler.onReceivingDequeueFileButton(fileNameText)
+        }
+
         Button {
             id: fileTemplateDownloadButton
             Layout.alignment: Qt.AlignCenter

+ 16 - 0
gui/src/cmdmanager.cpp

@@ -34,6 +34,8 @@ void CmdManager::init() {
 	cmdmap["deleteme"] = &CmdManager::handleDeleteMe;
 	cmdmap["deletefile"] = &CmdManager::handleDeleteFile;
 	cmdmap["notifications"] = &CmdManager::handleNotifications;
+	cmdmap["queue"] = &CmdManager::handleQueue;
+	cmdmap["dequeue"] = &CmdManager::handleDequeue;
 }
 
 void CmdManager::setQmlHandler(QMLHandler *q) { qmlHandler = q; }
@@ -169,3 +171,17 @@ void CmdManager::handleNotifications(Json::Value root) {
 		emit qmlHandler->log(root["error"].asString().c_str());
 	}
 }
+
+void CmdManager::handleQueue(Json::Value root) {
+	if (root["accept"] == false) {
+		QString errorMessage = QString::fromStdString(string("Error when queueing file " + root["file"].asString() + ":\n" + root["error"].asString()));
+		emit qmlHandler->log(errorMessage);
+	}
+}
+
+void CmdManager::handleDequeue(Json::Value root) {
+	if (root["accept"] == false) {
+		QString errorMessage = QString::fromStdString(string("Error when dequeueing file " + root["file"].asString() + ":\n" + root["error"].asString()));
+		emit qmlHandler->log(errorMessage);
+	}
+}

+ 2 - 2
gui/src/main.cpp

@@ -1,4 +1,4 @@
-#include <QGuiApplication>
+#include <QApplication>
 #include <QObject>
 #include <QQmlApplicationEngine>
 #include <QQmlComponent>
@@ -26,7 +26,7 @@ int main(int argc, char *argv[]) {
 	// This has to be here to fix warnings
 	QCoreApplication::setOrganizationName("CCats");
 
-	QGuiApplication app(argc, argv);
+	QApplication app(argc, argv);
 
 	QQmlApplicationEngine engine;
 

+ 11 - 0
gui/src/qmlhandler.cpp

@@ -208,4 +208,15 @@ void QMLHandler::onFooterGetStatusButton() { CliManager::writeToCli("status"); }
 // Notifications
 void QMLHandler::onDismissNotificationButton(int index) { emit dismissNotification(index); }
 
+// Queueing
+void QMLHandler::onReceivingQueueFileButton(QString fileName) {
+	QString command = "queue " + fileName;
+	CliManager::writeToCli(command);
+}
+
+void QMLHandler::onReceivingDequeueFileButton(QString fileName) {
+	QString command = "dequeue " + fileName;
+	CliManager::writeToCli(command);
+}
+
 void QMLHandler::setRestart(bool restart) { _RESTART = restart; }