Ejemplo n.º 1
0
//----------------------------------------------------
MainWindow::MainWindow(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::MainWindow), mADBProcess(NULL), mDebugWidget(nullptr), mServiceShouldRun(false),
	mCrashCount(0)
{
	ui->setupUi(this);

	// Setup UDP discovery socket
	mAnnouncer = new QUdpSocket(this);
	mAnnouncer->bind(QHostAddress::Any, 9876);
	connect(mAnnouncer, SIGNAL(readyRead()), this, SLOT(onDiscoveryReadyRead()));

	// Connect UI slots
	connect(ui->listDevices, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onSelectDevice(QListWidgetItem*)));
	connect(ui->listDevices, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(onDoubleClickDevice(QListWidgetItem*)));
	connect(ui->btnBootstrapUSB, SIGNAL(clicked()), this, SLOT(onClickBootstrapUSB()));
	connect(ui->btnConnectUSB, SIGNAL(clicked()), this, SLOT(onClickConnectUSB()));
	connect(ui->btnConnect, SIGNAL(clicked()), this, SLOT(onClickConnect()));
	connect(ui->btnWebsite, SIGNAL(clicked()), this, SLOT(onClickWebsite()));
	connect(ui->btnDebugLog, SIGNAL(clicked()), this, SLOT(onClickShowDebugLog()));
	connect(ui->cbQuality, SIGNAL(currentIndexChanged(int)), this, SLOT(onQualityChanged(int)));
	connect(ui->spinBitrate, SIGNAL(valueChanged(int)), this, SLOT(onBitrateChanged(int)));

	// Check if we have an update available
	QNetworkAccessManager* netAM = new QNetworkAccessManager(this);
	QNetworkRequest request(QUrl(UPDATE_URL));

	QNetworkReply* reply = netAM->get(request);
	connect(reply, SIGNAL(finished()), this, SLOT(onUpdateChecked()));

	ui->lblClientVersion->setText("Client version " CLIENT_VERSION);

	// Start timeout timer
	startTimer(500);
}
Ejemplo n.º 2
0
//----------------------------------------------------
MainWindow::MainWindow(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	//setWindowFlags( Qt::CustomizeWindowHint );
	this->setFixedSize(this->width(),this->height());

	connect(ui->btnConnect, SIGNAL(clicked()), this, SLOT(onClickConnect()));
	connect(ui->btnWebsite, SIGNAL(clicked()), this, SLOT(onClickWebsite()));
}
Ejemplo n.º 3
0
//----------------------------------------------------
void MainWindow::onClickConnectUSB()
{
	// Forward TCP port to localhost and connect to it
	QStringList args;
	args << "forward";
	args << "tcp:9876";
	args << "tcp:9876";

	runAdb(args);

	ui->ebIP->setText("127.0.0.1");
	onClickConnect();
}
Ejemplo n.º 4
0
void ConnectWindow::autoConnect()
{
	onClickConnect();
}
Ejemplo n.º 5
0
ConnectWindow::ConnectWindow(QMenu *settingsMenu, QWidget *parent)
    : QWidget(parent),
      state_(STATE_DISCONNECTED),
      pbCancelCon(0),
      pbRestoreGateway(0),
      killSwitch_(NULL),
      getMyVpnIp_(NULL),
      mode_(MODE_OPEN_VPN),
      logDialog_(NULL)
{
    ui.setupUi(this);

#if defined Q_OS_WIN
    QString strUpdatedStyleSheet;
    QString strStyleSheet = ui.tabWidget->styleSheet();
    QString matchStr = "QTabWidget:tab-bar{}";
    int ind = strStyleSheet.indexOf(matchStr);
    Q_ASSERT(ind != -1);
    strUpdatedStyleSheet = strStyleSheet.left(ind);
    strUpdatedStyleSheet += "QTabWidget:tab-bar{left: 100px; top: 10px;}";
    strUpdatedStyleSheet += strStyleSheet.right(strStyleSheet.length() - (ind + matchStr.length()));
    ui.tabWidget->setStyleSheet(strUpdatedStyleSheet);
#endif

    ui.btnSettings->setMenu( settingsMenu );

    showStatistics( false );

    mainWindow_ = (MainWindow *)parent;

    killSwitch_ = new KillSwitch(this);

    QSettings settings;
    ui.cbEnableSmartDNS->setChecked(settings.value("openVpnDNSEnabled", true).toBool());

    /*if (!connection_.initialize())
	{
		QMessageBox::information(this, QApplication::applicationName(), tr("OpenVPN initialize error"));
		QTimer::singleShot(1, parent, SLOT(close()));
		return;
	}

    if (!connection_.tapInstalled())
	{
		QMessageBox::question(this, QApplication::applicationName(), tr("TAP drivers not installed."));
		QTimer::singleShot(1, this, SLOT(close()));
		return;
    }   */

    ui.cbServer->installEventFilter(this);

    logDialog_ = new ShowLog(this);
    connect(g_openVPNConnection, SIGNAL(log(QString)), logDialog_, SLOT(onUpdateLog(QString)));

    updateIP();

    qRegisterMetaType<OPENVPN_ERROR>("OPENVPN_ERROR");

	connect(ui.btnConnect, SIGNAL(clicked()), SLOT(onClickConnect()));
    connect(ui.cbEnableSmartDNS, SIGNAL(stateChanged(int)), SLOT(onDNSEnabledStateChanged(int)));
    connect(ui.pbSmartDnsHelp, SIGNAL(clicked()), SLOT(onSmartDnsHelp()));
    connect(ui.pbSmartDns, SIGNAL(clicked()), SLOT(onClickSmartDns()));
    connect(g_openVPNConnection, SIGNAL(connected()), SLOT(onConnected()));
    connect(g_openVPNConnection, SIGNAL(disconnected()), SLOT(onDisconnected()));
    connect(g_openVPNConnection, SIGNAL(error(OPENVPN_ERROR)), SLOT(onConnectionError(OPENVPN_ERROR)));
    connect(g_openVPNConnection, SIGNAL(disconnected()), SLOT(onDisconnected()));
    connect(g_openVPNConnection, SIGNAL(statisticsUpdated(long, long)), SLOT(onStatisticsChanged(long, long)));
}
Ejemplo n.º 6
0
//----------------------------------------------------
void MainWindow::onDoubleClickDevice(QListWidgetItem* item)
{
	onSelectDevice(item);
	onClickConnect();
}
Ejemplo n.º 7
0
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags), loginWindow_(NULL), connectWindow_(NULL), serverListWindow_(0),
      timer_(NULL), settingsMenu_(0), connected_(0), getServers_(NULL)
{
	QCoreApplication::setOrganizationName("CPPP");
    QCoreApplication::setApplicationName("VPNht");

	ui.setupUi(this);
    setWindowTitle("VPN.ht " + QString(VERSION));

    g_openVPNConnection = new OpenVPNConnectorQt(this);
    if (!g_openVPNConnection->installHelper(SERVICE_NAME))
    {
        QMessageBox::information(this,
                                 "VPNht", "Failed to install helper for program. Please contact support.");
        QTimer::singleShot(1, this, SLOT(close()));
        return;
    }

#if defined Q_OS_MAC
    //setAttribute(Qt::WA_QuitOnClose, false);
#endif

    trayIcon_ = new QSystemTrayIcon(this);       

    trayMenu_ = new QMenu(this);
    actConnect_ = new QAction("Connect", this);
    actDisconnect_ = new QAction("Disconnect", this);
    actHelp_ = new QAction("Help", this);
    actLiveChat_ = new QAction("Live chat", this);
    actExit_ = new QAction("Quit", this);
    trayMenu_->addAction(actConnect_);
    trayMenu_->addAction(actDisconnect_);
    trayMenu_->addSeparator();
    trayMenu_->addAction(actHelp_);
    trayMenu_->addAction(actLiveChat_);
    trayMenu_->addAction(actExit_);
    trayIcon_->setContextMenu(trayMenu_);
    trayIcon_->hide();    

    setTrayStatusDisconnected(false);

    settingsMenu_ = new QMenu(this);
    settingsMenu_->addAction("Settings", this, SLOT(onSettings()));
    settingsMenu_->addAction("Status", this, SLOT(onStatus()));
    settingsMenu_->addAction("Help", this, SLOT(onHelp()));
    settingsMenu_->addAction("Proxy", this, SLOT(onProxy()));
    settingsMenu_->addAction("Show logs", this, SLOT(onShowLogs()));
    settingsMenu_->addAction("Logout", this, SLOT(onReturnToSignUp()));
    settingsMenu_->setStyleSheet(ctxMenuStyle);    

    loginWindow_ = new LoginWindow(this);
	ui.verticalLayout->addWidget(loginWindow_);
	loginWindow_->loadSettings();
    loginWindow_->hide();
	connect(loginWindow_, SIGNAL(signedIn(QString, QString)), SLOT(onSignIn(QString, QString)));

    waitWindow_ = new WaitWindow(this);
    ui.verticalLayout->addWidget(waitWindow_);

    settingsWindow_ = new SettingsWindow(settingsMenu_, this);
    connect(settingsWindow_, SIGNAL(back()), SLOT(onBack()));
	ui.verticalLayout->addWidget(settingsWindow_);
    settingsWindow_->hide();

    connectWindow_ = new ConnectWindow(settingsMenu_, this);
    connect(connectWindow_, SIGNAL(serverList()), SLOT(onServerList()));
    connect(connectWindow_, SIGNAL(connected()), SLOT(onConnected()));
        ui.verticalLayout->addWidget(connectWindow_);

    ui.verticalLayout->addWidget(connectWindow_);
	connectWindow_->hide();

    serverListWindow_ = new ServerListWindow(this);
    connect(serverListWindow_, SIGNAL(serverSelected(const QString &)),
            this, SLOT( onChangeServer(const QString &) ));
    ui.verticalLayout->addWidget(serverListWindow_);
    serverListWindow_->hide();

    proxySettingsWindow_ = new ProxySettingsWindow(settingsMenu_, this);
    connect(proxySettingsWindow_, SIGNAL(back()), SLOT(onBack()));
    ui.verticalLayout->addWidget(proxySettingsWindow_);
    proxySettingsWindow_->hide();


    // tray action
    connect(actConnect_, SIGNAL(triggered()), connectWindow_, SLOT(onClickConnect()));
    connect(actDisconnect_, SIGNAL(triggered()), connectWindow_, SLOT(onClickConnect()));
    connect(actHelp_, SIGNAL(triggered()), SLOT(onActHelp()));
    connect(actLiveChat_, SIGNAL(triggered()), SLOT(onLiveChat()));
    connect(actExit_, SIGNAL(triggered()), SLOT(onExit()));


#if defined Q_OS_WIN
    connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            SLOT( onTrayActivated(QSystemTrayIcon::ActivationReason) ));
#endif

    QSettings settings;
    if (settings.value("savePass", "true").toString() == "true")
    {
		QString username = settings.value("login", "").toString();
		QString password = settings.value("password", "").toString();
		if (!username.isEmpty() && !password.isEmpty())
        {
            adjustSize();
            setFixedSize(size());
            skipLoginScreen(username, password);
		}
		else
		{
            waitWindow_->hide();
            loginWindow_->show();
            adjustSize();
            setFixedSize(size());
		}
    }
    else
    {
        waitWindow_->hide();
        loginWindow_->show();
        adjustSize();
        setFixedSize(size());
    }
}