diff --git a/HotspotShield.png b/HotspotShield.png new file mode 100644 index 0000000..9673edd Binary files /dev/null and b/HotspotShield.png differ diff --git a/HotspotShield.pro b/HotspotShield.pro new file mode 100644 index 0000000..d01e364 --- /dev/null +++ b/HotspotShield.pro @@ -0,0 +1,24 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/HotspotShield.pro.user b/HotspotShield.pro.user new file mode 100644 index 0000000..4da40ab --- /dev/null +++ b/HotspotShield.pro.user @@ -0,0 +1,355 @@ + + + + + + EnvironmentId + {d980c07e-5cf7-43df-a0ef-6a4e92e6ff48} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + true + + + 0 + true + + true + Builtin.Questionable + + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {7e35625a-3dc6-4a68-a3e5-359fb9d3d1aa} + 0 + 0 + 0 + + true + 0 + /home/mrfluffy/Documents/C++/build-HotspotShield-Desktop-Debug + /home/mrfluffy/Documents/C++/build-HotspotShield-Desktop-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 2 + 2 + + + true + 2 + /home/mrfluffy/Documents/C++/build-HotspotShield-Desktop-Release + /home/mrfluffy/Documents/C++/build-HotspotShield-Desktop-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 2 + + + true + 0 + /home/mrfluffy/Documents/C++/build-HotspotShield-Desktop-Profile + /home/mrfluffy/Documents/C++/build-HotspotShield-Desktop-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/mrfluffy/Documents/C++/HotspotShield/HotspotShield.pro + /home/mrfluffy/Documents/C++/HotspotShield/HotspotShield.pro + + false + + false + true + true + false + false + true + + /home/mrfluffy/Documents/C++/build-HotspotShield-Desktop-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/HotspotShield.pro.user.86c6db0 b/HotspotShield.pro.user.86c6db0 new file mode 100644 index 0000000..7e86a09 --- /dev/null +++ b/HotspotShield.pro.user.86c6db0 @@ -0,0 +1,355 @@ + + + + + + EnvironmentId + {86c6db0a-a8d9-470d-991a-fb8f8767f3a1} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + true + + + 0 + true + + false + Builtin.Questionable + + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {07443001-3d65-4d24-9b41-1689e6beeecb} + 0 + 0 + 0 + + true + 0 + /home/mrfluffy/build-HotspotShield-Desktop-Debug + /home/mrfluffy/build-HotspotShield-Desktop-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 2 + 2 + + + true + 2 + /home/mrfluffy/build-HotspotShield-Desktop-Release + /home/mrfluffy/build-HotspotShield-Desktop-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 2 + + + true + 0 + /home/mrfluffy/build-HotspotShield-Desktop-Profile + /home/mrfluffy/build-HotspotShield-Desktop-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/mrfluffy/HotspotShield/HotspotShield.pro + /home/mrfluffy/HotspotShield/HotspotShield.pro + + false + + false + true + true + false + false + true + + /home/mrfluffy/build-HotspotShield-Desktop-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..bdc1bb8 --- /dev/null +++ b/main.cpp @@ -0,0 +1,12 @@ +#include "mainwindow.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + a.setWindowIcon(QIcon("./HotspotShield.png")); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..c8e179c --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,71 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include +#include +#include +#include +using namespace std; +bool connected = false; +string labletext ; + +string GetStdoutFromCommand(string cmd) { + string data; + FILE * stream; + const int max_buffer = 256; + char buffer[max_buffer]; + cmd.append(" 2>&1"); + + stream = popen(cmd.c_str(), "r"); + if (stream) { + while (!feof(stream)) + if (fgets(buffer, max_buffer, stream) != NULL) data.append(buffer); + pclose(stream); + } + return data; +} +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); + connect(ui->BtnConDis, SIGNAL(clicked(bool)), this, SLOT(onButtonClicked())); + timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, &MainWindow::TimerSlot ); + ConnectStatus(); +} +void MainWindow::ConnectStatus(){ + ui->label->setText(GetStdoutFromCommand("hotspotshield status").c_str()); + if(ui->label->text().contains("disconnected")){ + ui->BtnConDis->setText("Connect"); + connected = false; + } + else { + ui->BtnConDis->setText("Disconnect"); + connected = true; + } + timer->start(1000); +} +MainWindow::~MainWindow() +{ + delete ui; +} +void MainWindow::onButtonClicked() +{ + if(connected == false){ + string location = "hotspotshield connect " + ui->Location->currentText().toStdString(); + const char *lc = location.c_str(); + system(lc); + } + else { + string location = "hotspotshield disconnect"; + const char *lc = location.c_str(); + system(lc); + } + ConnectStatus(); +} +void MainWindow::TimerSlot() +{ + ConnectStatus(); +} + diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..5d0bfbc --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,28 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + QTimer *timer; // NEW + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +public slots: + void onButtonClicked(); + void ConnectStatus(); + void connectionUpdate(); + void TimerSlot(); + +private: + Ui::MainWindow *ui; +}; +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..56e16b8 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,99 @@ + + + MainWindow + + + + 0 + 0 + 488 + 490 + + + + Hotspot Shield + + + + + + 154 + 280 + 180 + 161 + + + + Connect + + + + + + 0 + 0 + 131 + 51 + + + + US + + + + + + + US + + + + + ZA + + + + + IN + + + + + GB + + + + + JP + + + + + + + 7 + 77 + 401 + 161 + + + + + + + + + + + 0 + 0 + 488 + 23 + + + + + + + +