فهرست منبع

Merge branch 'removing-boost-from-gui' into 'develop'

Removing boost from GUI

See merge request tobias.wach/ccats!92
Sander, Paul 4 سال پیش
والد
کامیت
845086c542
5فایلهای تغییر یافته به همراه27 افزوده شده و 37 حذف شده
  1. 2 3
      gui/CMakeLists.txt
  2. 0 3
      gui/src/climanager.cpp
  3. 4 9
      gui/src/cmdmanager.cpp
  4. 3 8
      gui/src/config.cpp
  5. 18 14
      gui/src/qmlhandler.cpp

+ 2 - 3
gui/CMakeLists.txt

@@ -9,7 +9,6 @@ set(CMAKE_CXX_STANDARD 11)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 find_package(Threads)
-find_package(Boost 1.67 REQUIRED COMPONENTS system filesystem)
 find_package(Qt5 COMPONENTS Core Quick Widgets REQUIRED)
 find_package(PkgConfig REQUIRED)
 pkg_check_modules(JSONCPP REQUIRED jsoncpp)
@@ -18,5 +17,5 @@ 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 Qt5::Widgets)
+include_directories(${JSONCPP_INCLUDEDIR} include)
+target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${JSONCPP_LIBRARIES} Qt5::Core Qt5::Quick Qt5::Widgets)

+ 0 - 3
gui/src/climanager.cpp

@@ -14,9 +14,6 @@
 #include <thread>
 #include <unistd.h>
 
-#include <boost/asio.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
 #include <iostream>
 #include <json/json.h>
 

+ 4 - 9
gui/src/cmdmanager.cpp

@@ -4,13 +4,8 @@
 #include "../include/climanager.h"
 #include "../include/cmdmanager.h"
 #include "../include/config.h"
-#include <boost/asio.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
 #include <json/json.h>
 
-using boost::lexical_cast;
-using boost::asio::buffer;
 using namespace std;
 
 namespace CmdManager {
@@ -68,8 +63,8 @@ void CmdManager::emitFileList() {
 			if (it->second.method.size()) {
 				snprintf(speedbuf, 256, "%.2f B/s", it->second.speed);
 				progstr = it->second.type + " via " + it->second.method + "\n" + std::to_string(it->second.progress) + "%" + " @ " + speedbuf;
-			}
-			else progstr = it->second.type + "\n" + std::to_string(it->second.progress) + "%";
+			} else
+				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");
 		}
 		// else emit plain entry
@@ -126,7 +121,7 @@ void CmdManager::handleList(Json::Value root) {
 		auto fileNames = root["names"];
 		for (int i = 0; i < fileNames.size(); i++) {
 			emit qmlHandler->receivingListFile(QString::fromStdString(fileNames[i].asString()), QString::fromStdString(sizebuf), QString("Decryptable"),
-			                                   boost::filesystem::exists(fileNames[i].asString()));
+			                                   !!ifstream(fileNames[i].asString()));
 			filemap[fileNames[i].asString()] = {false, "", "", 0, 0};
 		}
 	} else {
@@ -145,7 +140,7 @@ void CmdManager::handleExtendedList(Json::Value root) {
 		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()));
+			                                   QString::fromStdString(f["encrypted"].asString()), !!ifstream(f["name"].asString()));
 			filemap[f["name"].asString()] = {false, "", "", 0, 0};
 		}
 	} else {

+ 3 - 8
gui/src/config.cpp

@@ -1,9 +1,5 @@
 #include "config.h"
 #include <QDebug>
-#include <boost/lexical_cast.hpp>
-
-using boost::bad_lexical_cast;
-using boost::lexical_cast;
 
 namespace Config {
 std::map<std::string, std::string> configuration;
@@ -37,11 +33,10 @@ bool Config::checkConfig() {
 	if (autofill_user != "0" && autofill_user != "1")
 		return false;
 
-	try {
-		int covert_method = lexical_cast<int>(getValue("Covert-Channel-Method"));
-	} catch (bad_lexical_cast &e) {
+	std::istringstream iss(getValue("Covert-Channel-Method"));
+	int covert_method;
+	if (!(iss >> covert_method))
 		return false;
-	}
 
 	return true;
 }

+ 18 - 14
gui/src/qmlhandler.cpp

@@ -16,15 +16,9 @@
 #include "../include/config.h"
 #include "../include/jsonhandler.h"
 #include "../include/qmlhandler.h"
-#include <boost/asio.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
 #include <iostream>
 #include <json/json.h>
 
-using boost::lexical_cast;
-using boost::asio::buffer;
-
 using namespace std;
 
 QUrl sendFileUrl = QUrl("");
@@ -33,9 +27,20 @@ bool _RESTART = false;
 QMLHandler::QMLHandler(QObject *parent) : QObject(parent) {}
 
 void QMLHandler::loadSettingsToGUI() {
-	int covertMethod = lexical_cast<int>(Config::getValue("Covert-Channel-Method"));
-	bool saveIP = lexical_cast<bool>(Config::getValue("Autofill-IP"));
-	bool saveUsername = lexical_cast<bool>(Config::getValue("Autofill-Username"));
+	stringstream ss;
+
+	int covertMethod;
+	ss << Config::getValue("Covert-Channel-Method");
+	ss >> covertMethod;
+
+	bool saveIP;
+	ss << Config::getValue("Autofill-IP");
+	ss >> saveIP;
+
+	bool saveUsername;
+	ss << Config::getValue("Autofill-Username");
+	ss >> saveUsername;
+
 	QString cliPath = QString::fromStdString(Config::getValue("CLI-Path"));
 	emit loadSettings(covertMethod, saveIP, saveUsername, cliPath);
 }
@@ -49,8 +54,7 @@ void QMLHandler::onStart() {
 		// Config exists
 		if (Config::checkConfig() == true) {
 			// Config is valid
-			if (!boost::filesystem::is_regular_file(Config::getValue("CLI-Path")) ||
-			    boost::filesystem::path(Config::getValue("CLI-Path")).filename().compare("ccats-cli")) {
+			if (!ifstream(Config::getValue("CLI-Path"))) {
 				// Invalid CLI Path
 				emit invalidCliPathPopupOpen();
 			}
@@ -155,9 +159,9 @@ void QMLHandler::onSettingsResetButton() {
 }
 
 void QMLHandler::onSettingsSaveButton(int covertMethod, bool saveIP, bool saveUsername, QString cliPath) {
-	Config::setValue("Covert-Channel-Method", lexical_cast<string>(covertMethod));
-	Config::setValue("Autofill-IP", lexical_cast<string>(saveIP));
-	Config::setValue("Autofill-Username", lexical_cast<string>(saveUsername));
+	Config::setValue("Covert-Channel-Method", to_string(covertMethod));
+	Config::setValue("Autofill-IP", to_string(saveIP));
+	Config::setValue("Autofill-Username", to_string(saveUsername));
 	Config::setValue("CLI-Path", cliPath.toUtf8().constData());
 	Config::saveFile();
 	emit log("Settings saved.");