From e4861adbc26131f8ba081814afaf3aee1973647e Mon Sep 17 00:00:00 2001 From: lukas Date: Mon, 1 Feb 2021 18:07:08 +0100 Subject: [PATCH] remove unneccessary files --- conanfile.txt | 2 +- inc/gui/MainWindow.h | 63 -------- src/gui/MainWindow.cpp | 129 ----------------- src/gui/mainwindow.ui | 320 ----------------------------------------- src/maingui.cpp | 14 -- 5 files changed, 1 insertion(+), 527 deletions(-) delete mode 100644 inc/gui/MainWindow.h delete mode 100644 src/gui/MainWindow.cpp delete mode 100644 src/gui/mainwindow.ui delete mode 100644 src/maingui.cpp diff --git a/conanfile.txt b/conanfile.txt index ba490db..62c50f7 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,7 +1,7 @@ [requires] libcurl/7.72.0 openssl/1.1.1i -libconfig/1.7.2 +LibConfig/1.7.2 [generators] cmake diff --git a/inc/gui/MainWindow.h b/inc/gui/MainWindow.h deleted file mode 100644 index 88879e7..0000000 --- a/inc/gui/MainWindow.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Main GUI controller - User IO handlings - * - * @author Lukas Heiligenbrunner - * @date 09.05.2020 - */ - -#pragma once - -#include - -namespace Ui { - class MainWindow; -} - -class MainWindow : public QMainWindow { -Q_OBJECT - -public: - /** - * constructor with basic initializations - */ - explicit MainWindow(); - - /** - * destruct all gui elements - */ - ~MainWindow(); - -private: - Ui::MainWindow *ui; - - /** - * all static initializations of custom gui elements - */ - void initGui(); - -private slots: - - /** - * executed click handler for config button - */ - void checkConfigBtn(); - - /** - * executed click handler for refresh btn - */ - void refreshIPBtn(); - - /** - * executed click handler for save config btn - */ - void saveConfigBtn(); - -signals: - - /** - * append a String line to the Log field - * - * @param QString string to be appended - */ - void appendLogField(QString); -}; \ No newline at end of file diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp deleted file mode 100644 index 0a4c720..0000000 --- a/src/gui/MainWindow.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include "inc/gui/MainWindow.h" -#include "ui_mainwindow.h" - -#include "api/IPAPI.h" -#include "IPRefresher.h" -#include "Config.h" -#include "Logger.h" - -#include - -MainWindow::MainWindow() : QMainWindow(), ui(new Ui::MainWindow) { - ui->setupUi(this); - - // initialize gui with start parameters - initGui(); - - connect(ui->buttonCheckConfig, SIGNAL(clicked()), this, SLOT(checkConfigBtn())); - connect(ui->buttonRefreshIP, SIGNAL(clicked()), this, SLOT(refreshIPBtn())); - connect(ui->buttonSaveConfig, SIGNAL(clicked()), this, SLOT(saveConfigBtn())); - - connect(this, SIGNAL(appendLogField(QString)), ui->textLog, SLOT(appendPlainText(QString))); -} - -MainWindow::~MainWindow() { - // todo check if disconnects are really necessary - disconnect(ui->buttonCheckConfig); - disconnect(ui->buttonRefreshIP); - this->destroy(); - delete ui; -} - -void MainWindow::checkConfigBtn() { - Logger::message("checking config!"); - appendLogField("checking config!"); - - if (Config::validateConfig()) { - Logger::message("Config file is OK"); - appendLogField("Config file is OK"); - ui->labelConfig->setText("Config is: OK"); - } else { - Logger::error("There are errors in config file!"); - appendLogField("There are errors in config file!"); - } - appendLogField(""); -} - -void MainWindow::refreshIPBtn() { - Logger::message("start refreshing Dynu IP."); - appendLogField(""); - appendLogField("start refreshing Dynu IP."); - new std::thread([this]() { - if (Config::readConfig()) { - int code = IPRefresher::checkIPAdress(false); - switch (code) { - case IPRefresher::Status_Code::SUCCESS: - appendLogField("successfully refreshed IP!"); - break; - case IPRefresher::Status_Code::NOREFRESH: - appendLogField("IP is already correct."); - break; - case IPRefresher::Status_Code::ERROR_NO_INTERNET: - appendLogField("Error: No Internet connection"); - break; - case IPRefresher::Status_Code::ERROR: - appendLogField("An error occured while refreshing."); - break; - default: - appendLogField("An unknown error code occured"); - } - } else { - std::cout << "incorrect credentials!" << std::endl; - } - - Logger::message("Finished refreshing Dynu IP."); - this->appendLogField("Finished refreshing Dynu IP."); - }); -} - -void MainWindow::saveConfigBtn() { - if (ui->telegramsupportCheckbox->isChecked()) { - Config::setValues( - ui->domainnameedit->text().toStdString(), - ui->dynuapikeyedit->text().toStdString(), - ui->domainidedit->text().toStdString(), - ui->telegramapikeyedit->text().toStdString(), - ui->chatidedit->text().toStdString()); - } else { - Config::setValues( - ui->domainnameedit->text().toStdString(), - ui->dynuapikeyedit->text().toStdString(), - ui->domainidedit->text().toStdString()); - } - Config::saveConfig(); -} - -void MainWindow::initGui() { - // needs to be defined with new -- would be termintated after the constructor call. - new std::thread([this]() { - IPAPI ipapi; - std::string ip = ipapi.getGlobalIp(); - Logger::message("Current global IP: " + ip); - std::string msg = "Your current global IP: " + ip; - this->ui->labelCurrentIP->setText(msg.c_str()); - }); - - // set config info label and initial check if config is valid - ui->labelConfig->setText(Config::validateConfig() ? "Config is: OK" : "Config is: NOT OK"); - - if (Config::readConfig()) { - ui->dynuapikeyedit->setText(Config::getDynuapikey().c_str()); - ui->domainidedit->setText(Config::getDomainid().c_str()); - ui->domainnameedit->setText(Config::getDomainname().c_str()); - - if (Config::isTelegramSupported()) { - ui->telegramsupportCheckbox->setCheckState(Qt::Checked); - ui->telegramapikeyedit->setText(Config::getTelegramApiKey().c_str()); - ui->chatidedit->setText(Config::getChatId().c_str()); - } else { - ui->telegramsupportCheckbox->setCheckState(Qt::Unchecked); - ui->telegramapikeyedit->setDisabled(true); - ui->chatidedit->setDisabled(true); - } - } else { - // todo duplicate code with above - ui->telegramsupportCheckbox->setCheckState(Qt::Unchecked); - ui->telegramapikeyedit->setDisabled(true); - ui->chatidedit->setDisabled(true); - } -} \ No newline at end of file diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui deleted file mode 100644 index d0fb62d..0000000 --- a/src/gui/mainwindow.ui +++ /dev/null @@ -1,320 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 823 - 618 - - - - ArrowCursor - - - MainWindow - - - /*background-color: rgb(69, 196, 255); - - - - - false - - - - 40 - 410 - 741 - 191 - - - - IBeamCursor - - - - - - 40 - 380 - 64 - 17 - - - - Log: - - - - - - 40 - 20 - 741 - 351 - - - - 0 - - - - Basic - - - - - 20 - 30 - 301 - 17 - - - - Your current global IP: - - - - - - 20 - 70 - 141 - 17 - - - - Config is: undefined - - - - - - 20 - 120 - 231 - 151 - - - - Actions - - - - - 30 - 50 - 91 - 33 - - - - ArrowCursor - - - Check Config - - - - - - 30 - 100 - 91 - 33 - - - - Refresh IP - - - - - - - Config - - - - - 30 - 120 - 181 - 21 - - - - Telegram Notifications - - - - - - 630 - 270 - 91 - 33 - - - - Save Config - - - - - - 30 - 20 - 101 - 17 - - - - Dynu API Key - - - - - - 460 - 20 - 111 - 17 - - - - Domain ID - - - - - - 30 - 170 - 131 - 17 - - - - Telegram API Key - - - - - - 30 - 240 - 64 - 17 - - - - Chat ID - - - - - - 30 - 40 - 211 - 31 - - - - - - - 460 - 40 - 113 - 31 - - - - - - - 30 - 260 - 113 - 31 - - - - - - - 30 - 190 - 311 - 31 - - - - - - - 280 - 40 - 161 - 31 - - - - domain.dynu.net - - - - - - 280 - 20 - 111 - 17 - - - - Domainname - - - - - - Settings - - - - - 20 - 30 - 161 - 17 - - - - Select your language: - - - - - - 20 - 60 - 94 - 31 - - - - - - - - - - - diff --git a/src/maingui.cpp b/src/maingui.cpp deleted file mode 100644 index 21df7b6..0000000 --- a/src/maingui.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include "gui/MainWindow.h" - -/** - * application entry point - */ -int main(int argc, char *argv[]) { - QApplication a(argc, argv); - MainWindow w; - w.setWindowTitle("Dynu IP Refresher"); - w.show(); - - return QApplication::exec(); -} \ No newline at end of file