remove unneccessary files
This commit is contained in:
parent
17a3722d7a
commit
e4861adbc2
@ -1,7 +1,7 @@
|
||||
[requires]
|
||||
libcurl/7.72.0
|
||||
openssl/1.1.1i
|
||||
libconfig/1.7.2
|
||||
LibConfig/1.7.2
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
|
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* Main GUI controller - User IO handlings
|
||||
*
|
||||
* @author Lukas Heiligenbrunner
|
||||
* @date 09.05.2020
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
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);
|
||||
};
|
@ -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 <thread>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,320 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>823</width>
|
||||
<height>618</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>ArrowCursor</cursorShape>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">/*background-color: rgb(69, 196, 255);</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QPlainTextEdit" name="textLog">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>410</y>
|
||||
<width>741</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor" stdset="0">
|
||||
<cursorShape>IBeamCursor</cursorShape>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>380</y>
|
||||
<width>64</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Log:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>20</y>
|
||||
<width>741</width>
|
||||
<height>351</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="basic">
|
||||
<attribute name="title">
|
||||
<string>Basic</string>
|
||||
</attribute>
|
||||
<widget class="QLabel" name="labelCurrentIP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>301</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Your current global IP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>141</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Config is: undefined</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>120</y>
|
||||
<width>231</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="buttonCheckConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>50</y>
|
||||
<width>91</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>ArrowCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check Config</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="buttonRefreshIP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>100</y>
|
||||
<width>91</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh IP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="config">
|
||||
<attribute name="title">
|
||||
<string>Config</string>
|
||||
</attribute>
|
||||
<widget class="QCheckBox" name="telegramsupportCheckbox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>120</y>
|
||||
<width>181</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Telegram Notifications</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="buttonSaveConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>630</x>
|
||||
<y>270</y>
|
||||
<width>91</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Config</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>101</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dynu API Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>20</y>
|
||||
<width>111</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Domain ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>170</y>
|
||||
<width>131</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Telegram API Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>64</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Chat ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="dynuapikeyedit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>40</y>
|
||||
<width>211</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="domainidedit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>40</y>
|
||||
<width>113</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="chatidedit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>260</y>
|
||||
<width>113</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="telegramapikeyedit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>190</y>
|
||||
<width>311</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="domainnameedit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>40</y>
|
||||
<width>161</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>domain.dynu.net</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>111</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Domainname</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="settings">
|
||||
<attribute name="title">
|
||||
<string>Settings</string>
|
||||
</attribute>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>161</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select your language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="languageComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>94</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,14 +0,0 @@
|
||||
#include <QApplication>
|
||||
#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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user