diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-01-17 10:36:58 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-01-17 10:36:58 -0800 |
| commit | 8be664cca9ca6b95515fb1bda961f5c844af7d0f (patch) | |
| tree | 6ebf94344136d7f6b3d2fe8d178bf7489f2f895b /ZeroTierUI/mainwindow.cpp | |
| parent | 866edd41a7328da35136cd93640f4ad2630f98ed (diff) | |
| download | infinitytier-8be664cca9ca6b95515fb1bda961f5c844af7d0f.tar.gz infinitytier-8be664cca9ca6b95515fb1bda961f5c844af7d0f.zip | |
UI cleanup and license dialog.
Diffstat (limited to 'ZeroTierUI/mainwindow.cpp')
| -rw-r--r-- | ZeroTierUI/mainwindow.cpp | 49 |
1 files changed, 11 insertions, 38 deletions
diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp index 61578237..07df1964 100644 --- a/ZeroTierUI/mainwindow.cpp +++ b/ZeroTierUI/mainwindow.cpp @@ -25,12 +25,6 @@ * LLC. Start here: http://www.zerotier.com/ */ -#include "mainwindow.h" -#include "aboutwindow.h" -#include "networkwidget.h" -#include "ui_mainwindow.h" -#include "installdialog.h" - #include <string> #include <map> #include <set> @@ -51,6 +45,12 @@ #include <QScrollBar> #include <QEventLoop> +#include "main.h" +#include "mainwindow.h" +#include "aboutwindow.h" +#include "networkwidget.h" +#include "ui_mainwindow.h" + #ifdef __APPLE__ #include <stdio.h> #include <string.h> @@ -60,14 +60,13 @@ #include "mac_doprivileged.h" #endif -QNetworkAccessManager *nam; - // Globally visible ZeroTier::Node::LocalClient *zeroTierClient = (ZeroTier::Node::LocalClient *)0; // Main window instance for app static MainWindow *mainWindow = (MainWindow *)0; +// Handles message from ZeroTier One service static void handleZTMessage(void *arg,unsigned long id,const char *line) { static std::map< unsigned long,std::vector<std::string> > ztReplies; @@ -80,6 +79,8 @@ static void handleZTMessage(void *arg,unsigned long id,const char *line) } else { // empty lines conclude transmissions std::map< unsigned long,std::vector<std::string> >::iterator r(ztReplies.find(id)); if (r != ztReplies.end()) { + // The message is packed into an event and sent to the main window where + // the actual parsing code lives. MainWindow::ZTMessageEvent *event = new MainWindow::ZTMessageEvent(r->second); ztReplies.erase(r); ztReplies_m.unlock(); @@ -93,6 +94,8 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow), pollServiceTimerId(-1) { + mainWindow = this; + ui->setupUi(this); if (ui->networkListWidget->verticalScrollBar()) ui->networkListWidget->verticalScrollBar()->setSingleStep(8); @@ -101,8 +104,6 @@ MainWindow::MainWindow(QWidget *parent) : widget->setAttribute(Qt::WA_MacShowFocusRect,false); ui->noNetworksLabel->setText("Connecting to Service..."); // changed when result is received - mainWindow = this; - this->pollServiceTimerId = this->startTimer(1000); this->setEnabled(false); // gets enabled when updates are received this->cyclesSinceResponseFromService = 0; @@ -168,10 +169,6 @@ void MainWindow::timerEvent(QTimerEvent *event) macExecutePrivilegedShellCommand((std::string("'")+tmpPath+"' >>/dev/null 2>&1").c_str()); unlink(tmpPath.c_str()); - } else { - // Install service and other support files if service isn't there - doInstallDialog(); - return; } #endif @@ -305,15 +302,6 @@ void MainWindow::customEvent(QEvent *event) } } -void MainWindow::showEvent(QShowEvent *event) -{ -#ifdef __APPLE__ - // If service isn't installed, download and install it - if (!QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) - doInstallDialog(); -#endif -} - void MainWindow::on_joinNetworkButton_clicked() { QString toJoin(ui->networkIdLineEdit->text()); @@ -375,18 +363,3 @@ void MainWindow::on_addressButton_clicked() { QApplication::clipboard()->setText(this->myAddress); } - -void MainWindow::doInstallDialog() -{ -#ifdef __APPLE__ - this->setEnabled(false); - if (pollServiceTimerId >= 0) { - this->killTimer(pollServiceTimerId); - pollServiceTimerId = -1; - } - - InstallDialog *id = new InstallDialog(this); - id->setModal(true); - id->show(); -#endif -} |
