|
@@ -13,6 +13,7 @@
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
|
|
|
|
#include "../include/climanager.h"
|
|
#include "../include/climanager.h"
|
|
|
|
+#include "../include/cmdmanager.h"
|
|
#include "../include/config.h"
|
|
#include "../include/config.h"
|
|
#include "../include/jsonhandler.h"
|
|
#include "../include/jsonhandler.h"
|
|
#include "../include/qmlhandler.h"
|
|
#include "../include/qmlhandler.h"
|
|
@@ -29,20 +30,14 @@ QMLHandler::QMLHandler(QObject *parent) : QObject(parent) {}
|
|
void QMLHandler::loadSettingsToGUI() {
|
|
void QMLHandler::loadSettingsToGUI() {
|
|
stringstream ss;
|
|
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;
|
|
|
|
|
|
+ // The space is needed to get the stringstream to perform proper formatting of multiple values
|
|
|
|
+ bool saveIP, saveUsername;
|
|
|
|
+ ss << Config::getValue("Autofill-IP") << " " << Config::getValue("Autofill-Username");
|
|
|
|
+ ss >> saveIP >> saveUsername;
|
|
|
|
|
|
QString cliPath = QString::fromStdString(Config::getValue("CLI-Path"));
|
|
QString cliPath = QString::fromStdString(Config::getValue("CLI-Path"));
|
|
- emit loadSettings(covertMethod, saveIP, saveUsername, cliPath);
|
|
|
|
|
|
+ QString keyPath = QString::fromStdString(Config::getValue("Keyfile-Path"));
|
|
|
|
+ emit loadSettings(saveIP, saveUsername, cliPath, keyPath);
|
|
}
|
|
}
|
|
|
|
|
|
// ### QML Handlers ###
|
|
// ### QML Handlers ###
|
|
@@ -50,14 +45,10 @@ void QMLHandler::loadSettingsToGUI() {
|
|
void QMLHandler::onStart() {
|
|
void QMLHandler::onStart() {
|
|
bool configExists = Config::loadFile();
|
|
bool configExists = Config::loadFile();
|
|
|
|
|
|
- if (configExists == true) {
|
|
|
|
|
|
+ if (configExists) {
|
|
// Config exists
|
|
// Config exists
|
|
- if (Config::checkConfig() == true) {
|
|
|
|
|
|
+ if (Config::checkConfig()) {
|
|
// Config is valid
|
|
// Config is valid
|
|
- if (!ifstream(Config::getValue("CLI-Path"))) {
|
|
|
|
- // Invalid CLI Path
|
|
|
|
- emit invalidCliPathPopupOpen();
|
|
|
|
- }
|
|
|
|
if (Config::getValue("Autofill-IP") == "1") {
|
|
if (Config::getValue("Autofill-IP") == "1") {
|
|
emit ipPopupSetIP(QString::fromStdString(Config::getValue("Default-IP")));
|
|
emit ipPopupSetIP(QString::fromStdString(Config::getValue("Default-IP")));
|
|
emit ipPopupCheckSaveCheckbox();
|
|
emit ipPopupCheckSaveCheckbox();
|
|
@@ -66,6 +57,13 @@ void QMLHandler::onStart() {
|
|
emit loginSetUsername(QString::fromStdString(Config::getValue("Default-Username")));
|
|
emit loginSetUsername(QString::fromStdString(Config::getValue("Default-Username")));
|
|
emit loginSignupCheckSaveCheckbox();
|
|
emit loginSignupCheckSaveCheckbox();
|
|
}
|
|
}
|
|
|
|
+ if (!ifstream(Config::getValue("CLI-Path"))) {
|
|
|
|
+ // Invalid CLI Path
|
|
|
|
+ emit invalidCliPathPopupOpen();
|
|
|
|
+ } else {
|
|
|
|
+ // Everything OK, init CLI
|
|
|
|
+ CliManager::init();
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
// Config is invalid
|
|
// Config is invalid
|
|
emit invalidConfigPopupOpen();
|
|
emit invalidConfigPopupOpen();
|
|
@@ -75,20 +73,20 @@ void QMLHandler::onStart() {
|
|
Config::setupDefaultConfig();
|
|
Config::setupDefaultConfig();
|
|
emit noConfigFoundPopupOpen();
|
|
emit noConfigFoundPopupOpen();
|
|
}
|
|
}
|
|
-
|
|
|
|
- CliManager::init();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// No Config Found Popup
|
|
// No Config Found Popup
|
|
void QMLHandler::onNoConfigFoundPopupContinueButton(QString cli_path) {
|
|
void QMLHandler::onNoConfigFoundPopupContinueButton(QString cli_path) {
|
|
Config::setValue("CLI-Path", cli_path.toUtf8().constData());
|
|
Config::setValue("CLI-Path", cli_path.toUtf8().constData());
|
|
Config::saveFile();
|
|
Config::saveFile();
|
|
|
|
+ onStart();
|
|
}
|
|
}
|
|
|
|
|
|
// Invalid Cli Path Popup
|
|
// Invalid Cli Path Popup
|
|
void QMLHandler::onInvalidCliPathPopupContinueButton(QString cli_path) {
|
|
void QMLHandler::onInvalidCliPathPopupContinueButton(QString cli_path) {
|
|
Config::setValue("CLI-Path", cli_path.toUtf8().constData());
|
|
Config::setValue("CLI-Path", cli_path.toUtf8().constData());
|
|
Config::saveFile();
|
|
Config::saveFile();
|
|
|
|
+ onStart();
|
|
}
|
|
}
|
|
|
|
|
|
void QMLHandler::onInvalidCliPathPopupQuitButton() { emit closeWindow(); }
|
|
void QMLHandler::onInvalidCliPathPopupQuitButton() { emit closeWindow(); }
|
|
@@ -140,12 +138,18 @@ void QMLHandler::onReceivingConfirmDeleteFileButton(QString fileName) {
|
|
void QMLHandler::onMessagesSendButton(QString msg) { emit message(msg); }
|
|
void QMLHandler::onMessagesSendButton(QString msg) { emit message(msg); }
|
|
|
|
|
|
// Settings
|
|
// Settings
|
|
|
|
+void QMLHandler::onKeyfileSelected(QString path) {
|
|
|
|
+ QString command = "keyfile \"" + path + "\"";
|
|
|
|
+ CliManager::writeToCli(command);
|
|
|
|
+}
|
|
|
|
+void QMLHandler::onKeyfileClosed() { CliManager::writeToCli("closekey"); }
|
|
void QMLHandler::onSettingsDeleteMeButton(QString password) {
|
|
void QMLHandler::onSettingsDeleteMeButton(QString password) {
|
|
QString command = "deleteme " + password;
|
|
QString command = "deleteme " + password;
|
|
CliManager::writeToCli(command);
|
|
CliManager::writeToCli(command);
|
|
}
|
|
}
|
|
|
|
|
|
void QMLHandler::onSettingsRevertChangesButton() {
|
|
void QMLHandler::onSettingsRevertChangesButton() {
|
|
|
|
+ Config::loadFile();
|
|
loadSettingsToGUI();
|
|
loadSettingsToGUI();
|
|
emit log("Settings changes reverted.");
|
|
emit log("Settings changes reverted.");
|
|
}
|
|
}
|
|
@@ -158,18 +162,26 @@ void QMLHandler::onSettingsResetButton() {
|
|
emit log("Settings resetted to default.");
|
|
emit log("Settings resetted to default.");
|
|
}
|
|
}
|
|
|
|
|
|
-void QMLHandler::onSettingsSaveButton(int covertMethod, bool saveIP, bool saveUsername, QString cliPath) {
|
|
|
|
- Config::setValue("Covert-Channel-Method", to_string(covertMethod));
|
|
|
|
|
|
+void QMLHandler::onSettingsSaveButton(bool saveIP, bool saveUsername, QString cliPath, QString keyPath) {
|
|
Config::setValue("Autofill-IP", to_string(saveIP));
|
|
Config::setValue("Autofill-IP", to_string(saveIP));
|
|
Config::setValue("Autofill-Username", to_string(saveUsername));
|
|
Config::setValue("Autofill-Username", to_string(saveUsername));
|
|
Config::setValue("CLI-Path", cliPath.toUtf8().constData());
|
|
Config::setValue("CLI-Path", cliPath.toUtf8().constData());
|
|
|
|
+ Config::setValue("Keyfile-Path", keyPath.toUtf8().constData());
|
|
Config::saveFile();
|
|
Config::saveFile();
|
|
emit log("Settings saved.");
|
|
emit log("Settings saved.");
|
|
}
|
|
}
|
|
|
|
|
|
// Ip Popup
|
|
// Ip Popup
|
|
void QMLHandler::onIpPopupConnectButton(QString ip, bool saveAsDefault) {
|
|
void QMLHandler::onIpPopupConnectButton(QString ip, bool saveAsDefault) {
|
|
- QString command = "connect " + ip;
|
|
|
|
|
|
+ QStringList ipport = ip.split(":");
|
|
|
|
+ QString command = "connect " + ipport[0];
|
|
|
|
+
|
|
|
|
+ CmdManager::setCachedIP(ipport[0]);
|
|
|
|
+ if (ipport.size() > 1) {
|
|
|
|
+ command += " " + ipport[1];
|
|
|
|
+ CmdManager::setCachedPort(ipport[1]);
|
|
|
|
+ }
|
|
|
|
+
|
|
CliManager::writeToCli(command);
|
|
CliManager::writeToCli(command);
|
|
|
|
|
|
emit ipPopupDisableConnectButton();
|
|
emit ipPopupDisableConnectButton();
|
|
@@ -177,6 +189,7 @@ void QMLHandler::onIpPopupConnectButton(QString ip, bool saveAsDefault) {
|
|
Config::setValue("Default-IP", ip.toUtf8().constData());
|
|
Config::setValue("Default-IP", ip.toUtf8().constData());
|
|
Config::setValue("Autofill-IP", "1");
|
|
Config::setValue("Autofill-IP", "1");
|
|
Config::saveFile();
|
|
Config::saveFile();
|
|
|
|
+ loadSettingsToGUI();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -189,6 +202,7 @@ void QMLHandler::onLoginLoginButton(QString username, QString password, bool sav
|
|
Config::setValue("Default-Username", username.toUtf8().constData());
|
|
Config::setValue("Default-Username", username.toUtf8().constData());
|
|
Config::setValue("Autofill-Username", "1");
|
|
Config::setValue("Autofill-Username", "1");
|
|
Config::saveFile();
|
|
Config::saveFile();
|
|
|
|
+ loadSettingsToGUI();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -205,6 +219,7 @@ void QMLHandler::onSignupRegisterButton(QString username, QString passwordOne, Q
|
|
Config::setValue("Default-Username", username.toUtf8().constData());
|
|
Config::setValue("Default-Username", username.toUtf8().constData());
|
|
Config::setValue("Autofill-Username", "1");
|
|
Config::setValue("Autofill-Username", "1");
|
|
Config::saveFile();
|
|
Config::saveFile();
|
|
|
|
+ loadSettingsToGUI();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|