aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/CMakeLists.txt2
-rw-r--r--src/gui/src/CoreInterface.cpp96
-rw-r--r--src/gui/src/CoreInterface.h36
-rw-r--r--src/gui/src/Fingerprint.cpp5
-rw-r--r--src/gui/src/Fingerprint.h8
-rw-r--r--src/gui/src/MainWindow.cpp39
-rw-r--r--src/gui/src/MainWindow.h1
-rw-r--r--src/gui/src/SettingsDialog.cpp1
-rw-r--r--src/gui/src/SettingsDialog.h2
-rw-r--r--src/gui/src/SetupWizard.cpp1
-rw-r--r--src/gui/src/SslCertificate.cpp4
-rw-r--r--src/gui/src/SslCertificate.h3
-rw-r--r--src/gui/src/WebClient.cpp83
-rw-r--r--src/gui/src/WebClient.h49
14 files changed, 20 insertions, 310 deletions
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 5d24891..9c90286 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -45,6 +45,8 @@ if (HAVE_X11)
target_link_libraries (barrier X11)
endif()
+target_link_libraries (barrier common)
+
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
install (TARGETS barrier DESTINATION ${BARRIER_BUNDLE_BINARY_DIR})
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
diff --git a/src/gui/src/CoreInterface.cpp b/src/gui/src/CoreInterface.cpp
deleted file mode 100644
index d5ed40d..0000000
--- a/src/gui/src/CoreInterface.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * barrier -- mouse and keyboard sharing utility
- * Copyright (C) 2015-2016 Symless Ltd.
- *
- * This package is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * found in the file LICENSE that should have accompanied this file.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "CoreInterface.h"
-
-#include "CommandProcess.h"
-#include "QUtility.h"
-
-#include <QCoreApplication>
-#include <QProcess>
-#include <QtGlobal>
-#include <QDir>
-#include <stdexcept>
-
-static const char kCoreBinary[] = "syntool";
-
-#ifdef Q_WS_WIN
-static const char kSerialKeyFilename[] = "Barrier.subkey";
-#else
-static const char kSerialKeyFilename[] = ".barrier.subkey";
-#endif
-
-CoreInterface::CoreInterface()
-{
-}
-
-QString CoreInterface::getProfileDir()
-{
- QStringList args("--get-profile-dir");
- return run(args);
-}
-
-QString CoreInterface::getInstalledDir()
-{
- QStringList args("--get-installed-dir");
- return run(args);
-}
-
-QString CoreInterface::getArch()
-{
- QStringList args("--get-arch");
- return run(args);
-}
-
-QString CoreInterface::getSerialKeyFilePath()
-{
- QString filename = getProfileDir() + QDir::separator() + kSerialKeyFilename;
- return filename;
-}
-
-QString CoreInterface::notifyUpdate (QString const& fromVersion,
- QString const& toVersion,
- QString const& serialKey) {
- QStringList args("--notify-update");
- QString input(fromVersion + ":" + toVersion + ":" + serialKey);
- input.append("\n");
- return run(args, input);
-}
-
-QString CoreInterface::notifyActivation(const QString& identity)
-{
- QStringList args("--notify-activation");
-
- QString input(identity + ":" + hash(getFirstMacAddress()));
- QString os= getOSInformation();
- if (!os.isEmpty()) {
- input.append(":").append(os);
- }
- input.append("\n");
-
- return run(args, input);
-}
-
-QString CoreInterface::run(const QStringList& args, const QString& input)
-{
- QString program(
- QCoreApplication::applicationDirPath()
- + "/" + kCoreBinary);
-
- CommandProcess commandProcess(program, args, input);
- return commandProcess.run();
-}
diff --git a/src/gui/src/CoreInterface.h b/src/gui/src/CoreInterface.h
deleted file mode 100644
index 26b9c0a..0000000
--- a/src/gui/src/CoreInterface.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * barrier -- mouse and keyboard sharing utility
- * Copyright (C) 2015-2016 Symless Ltd.
- *
- * This package is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * found in the file LICENSE that should have accompanied this file.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include <QString>
-
-class CoreInterface
-{
-public:
- CoreInterface();
-
- QString getProfileDir();
- QString getInstalledDir();
- QString getArch();
- QString getSerialKeyFilePath();
- QString notifyActivation(const QString& identity);
- QString notifyUpdate (QString const& fromVersion,
- QString const& toVersion,
- QString const& serialKey);
- QString run(const QStringList& args, const QString& input = "");
-};
diff --git a/src/gui/src/Fingerprint.cpp b/src/gui/src/Fingerprint.cpp
index be8b401..24c8a1a 100644
--- a/src/gui/src/Fingerprint.cpp
+++ b/src/gui/src/Fingerprint.cpp
@@ -17,7 +17,7 @@
#include "Fingerprint.h"
-#include "CoreInterface.h"
+#include "common/DataDirectories.h"
#include <QDir>
#include <QTextStream>
@@ -125,8 +125,7 @@ void Fingerprint::persistDirectory()
QString Fingerprint::directoryPath()
{
- CoreInterface coreInterface;
- QString profileDir = coreInterface.getProfileDir();
+ auto profileDir = QString::fromStdString(DataDirectories::profile());
return QString("%1/%2")
.arg(profileDir)
diff --git a/src/gui/src/Fingerprint.h b/src/gui/src/Fingerprint.h
index ad5ce59..5a38d20 100644
--- a/src/gui/src/Fingerprint.h
+++ b/src/gui/src/Fingerprint.h
@@ -21,9 +21,6 @@
class Fingerprint
{
-private:
- Fingerprint(const QString& filename);
-
public:
void trust(const QString& fingerprintText, bool append = true);
bool isTrusted(const QString& fingerprintText);
@@ -32,15 +29,14 @@ public:
QString filePath() const;
bool fileExists() const;
-public:
static Fingerprint local();
static Fingerprint trustedServers();
static Fingerprint trustedClients();
static QString directoryPath();
- static QString localFingerprint();
- static bool localFingerprintExists();
static void persistDirectory();
private:
+ Fingerprint(const QString& filename);
+
QString m_Filename;
};
diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp
index b92e5f7..6829c22 100644
--- a/src/gui/src/MainWindow.cpp
+++ b/src/gui/src/MainWindow.cpp
@@ -31,6 +31,7 @@
#include "ProcessorArch.h"
#include "SslCertificate.h"
#include "ShutdownCh.h"
+#include "common/DataDirectories.h"
#include <QtCore>
#include <QtGui>
@@ -72,6 +73,8 @@ static const char* barrierIconFiles[] =
":/res/icons/16x16/barrier-transfering.png"
};
+static const char* barrierLargeIcon = ":/res/icons/256x256/barrier.ico";
+
MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
m_Settings(settings),
m_AppConfig(&appConfig),
@@ -104,7 +107,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
setAttribute(Qt::WA_X11NetWmWindowTypeDialog, true);
setupUi(this);
-
+ setWindowIcon(QIcon(barrierLargeIcon));
createMenuBar();
loadSettings();
initConnections();
@@ -285,13 +288,8 @@ void MainWindow::saveSettings()
void MainWindow::setIcon(qBarrierState state)
{
- QIcon icon;
- icon.addFile(barrierIconFiles[state]);
-
- setWindowIcon(icon);
-
if (m_pTrayIcon)
- m_pTrayIcon->setIcon(icon);
+ m_pTrayIcon->setIcon(QIcon(barrierIconFiles[state]));
}
void MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason)
@@ -503,7 +501,7 @@ void MainWindow::startBarrier()
// launched the process (e.g. when launched with elevation). setting the
// profile dir on launch ensures it uses the same profile dir is used
// no matter how its relaunched.
- args << "--profile-dir" << getProfileRootForArg();
+ args << "--profile-dir" << QString::fromStdString("\"" + DataDirectories::profile() + "\"");
#endif
if ((barrierType() == barrierClient && !clientArgs(args, app))
@@ -583,7 +581,7 @@ bool MainWindow::clientArgs(QStringList& args, QString& app)
if (m_pCheckBoxAutoConfig->isChecked()) {
if (m_pComboServerList->count() != 0) {
QString serverIp = m_pComboServerList->currentText();
- args << serverIp + ":" + QString::number(appConfig().port());
+ args << "[" + serverIp + "]:" + QString::number(appConfig().port());
return true;
}
}
@@ -597,7 +595,7 @@ bool MainWindow::clientArgs(QStringList& args, QString& app)
return false;
}
- args << m_pLineEditHostname->text() + ":" + QString::number(appConfig().port());
+ args << "[" + m_pLineEditHostname->text() + "]:" + QString::number(appConfig().port());
return true;
}
@@ -639,8 +637,10 @@ QString MainWindow::configFilename()
QString MainWindow::address()
{
- QString i = appConfig().networkInterface();
- return (!i.isEmpty() ? i : "") + ":" + QString::number(appConfig().port());
+ QString address = appConfig().networkInterface();
+ if (!address.isEmpty())
+ address = "[" + address + "]";
+ return address + ":" + QString::number(appConfig().port());
}
QString MainWindow::appPath(const QString& name)
@@ -1252,21 +1252,6 @@ void MainWindow::bonjourInstallFinished()
m_pCheckBoxAutoConfig->setChecked(true);
}
-QString MainWindow::getProfileRootForArg()
-{
- CoreInterface coreInterface;
- QString dir = coreInterface.getProfileDir();
-
- // HACK: strip our app name since we're returning the root dir.
-#if defined(Q_OS_WIN)
- dir.replace("\\Barrier", "");
-#else
- dir.replace("/.barrier", "");
-#endif
-
- return QString("\"%1\"").arg(dir);
-}
-
void MainWindow::windowStateChanged()
{
if (windowState() == Qt::WindowMinimized && appConfig().getMinimizeToTray())
diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h
index 27b30d1..5bb2895 100644
--- a/src/gui/src/MainWindow.h
+++ b/src/gui/src/MainWindow.h
@@ -166,7 +166,6 @@ public slots:
bool isBonjourRunning();
void downloadBonjour();
void promptAutoConfig();
- QString getProfileRootForArg();
void checkConnected(const QString& line);
void checkFingerprint(const QString& line);
void restartBarrier();
diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp
index dc07313..15f7067 100644
--- a/src/gui/src/SettingsDialog.cpp
+++ b/src/gui/src/SettingsDialog.cpp
@@ -18,7 +18,6 @@
#include "SettingsDialog.h"
-#include "CoreInterface.h"
#include "BarrierLocale.h"
#include "QBarrierApplication.h"
#include "QUtility.h"
diff --git a/src/gui/src/SettingsDialog.h b/src/gui/src/SettingsDialog.h
index c16b821..b733bcc 100644
--- a/src/gui/src/SettingsDialog.h
+++ b/src/gui/src/SettingsDialog.h
@@ -23,7 +23,6 @@
#include <QDialog>
#include "ui_SettingsDialogBase.h"
#include "BarrierLocale.h"
-#include "CoreInterface.h"
class AppConfig;
@@ -43,7 +42,6 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
private:
AppConfig& m_appConfig;
BarrierLocale m_Locale;
- CoreInterface m_CoreInterface;
private slots:
void on_m_pComboLanguage_currentIndexChanged(int index);
diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp
index 313e48b..0cfdb81 100644
--- a/src/gui/src/SetupWizard.cpp
+++ b/src/gui/src/SetupWizard.cpp
@@ -17,7 +17,6 @@
#include "SetupWizard.h"
#include "MainWindow.h"
-#include "WebClient.h"
#include "QBarrierApplication.h"
#include "QUtility.h"
diff --git a/src/gui/src/SslCertificate.cpp b/src/gui/src/SslCertificate.cpp
index 7de7eaa..9b31c5d 100644
--- a/src/gui/src/SslCertificate.cpp
+++ b/src/gui/src/SslCertificate.cpp
@@ -16,8 +16,8 @@
*/
#include "SslCertificate.h"
-
#include "Fingerprint.h"
+#include "common/DataDirectories.h"
#include <QProcess>
#include <QDir>
@@ -37,7 +37,7 @@ static const char kConfigFile[] = "barrier.conf";
SslCertificate::SslCertificate(QObject *parent) :
QObject(parent)
{
- m_ProfileDir = m_CoreInterface.getProfileDir();
+ m_ProfileDir = QString::fromStdString(DataDirectories::profile());
if (m_ProfileDir.isEmpty()) {
emit error(tr("Failed to get profile directory."));
}
diff --git a/src/gui/src/SslCertificate.h b/src/gui/src/SslCertificate.h
index 8acda4b..8b20913 100644
--- a/src/gui/src/SslCertificate.h
+++ b/src/gui/src/SslCertificate.h
@@ -17,8 +17,6 @@
#pragma once
-#include "CoreInterface.h"
-
#include <QObject>
class SslCertificate : public QObject
@@ -43,5 +41,4 @@ private:
private:
QString m_ProfileDir;
QString m_ToolOutput;
- CoreInterface m_CoreInterface;
};
diff --git a/src/gui/src/WebClient.cpp b/src/gui/src/WebClient.cpp
deleted file mode 100644
index 8cded2c..0000000
--- a/src/gui/src/WebClient.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * barrier -- mouse and keyboard sharing utility
- * Copyright (C) 2015-2016 Symless Ltd.
- *
- * This package is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * found in the file LICENSE that should have accompanied this file.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "WebClient.h"
-
-#include "QUtility.h"
-
-#include <QProcess>
-#include <QMessageBox>
-#include <QCoreApplication>
-#include <stdexcept>
-
-bool
-WebClient::getEdition (int& edition, QString& errorOut) {
- QString responseJson = request();
-
- /* TODO: This is horrible and should be ripped out as soon as we move
- * to Qt 5. See issue #5630
- */
-
- QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
- if (resultRegex.exactMatch (responseJson)) {
- QString boolString = resultRegex.cap(1);
- if (boolString == "true") {
- QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
- if (editionRegex.exactMatch(responseJson)) {
- QString e = editionRegex.cap(1);
- edition = e.toInt();
- return true;
- } else {
- throw std::runtime_error ("Unrecognised server response.");
- }
- } else {
- errorOut = tr("Login failed. Invalid email address or password.");
- return false;
- }
- } else {
- QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
- if (errorRegex.exactMatch (responseJson)) {
- errorOut = errorRegex.cap(1).replace("\\n", "\n");
- return false;
- } else {
- throw std::runtime_error ("Unrecognised server response.");
- }
- }
-}
-
-bool
-WebClient::setEmail (QString email, QString& errorOut) {
- if (email.isEmpty()) {
- errorOut = tr("Your email address cannot be left blank.");
- return false;
- }
- m_Email = email;
- return true;
-}
-
-bool
-WebClient::setPassword (QString password, QString&) {
- m_Password = password;
- return true;
-}
-
-QString
-WebClient::request() {
- QStringList args("--login-auth");
- QString credentials (m_Email + ":" + hash(m_Password) + "\n");
- return m_CoreInterface.run (args, credentials);
-}
diff --git a/src/gui/src/WebClient.h b/src/gui/src/WebClient.h
deleted file mode 100644
index 9874bd5..0000000
--- a/src/gui/src/WebClient.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * barrier -- mouse and keyboard sharing utility
- * Copyright (C) 2015-2016 Symless Ltd.
- *
- * This package is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * found in the file LICENSE that should have accompanied this file.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef WEBCLIENT_H
-#define WEBCLIENT_H
-
-#include <QString>
-#include <QObject>
-
-#include "CoreInterface.h"
-
-class QMessageBox;
-class QWidget;
-class QStringList;
-
-class WebClient : public QObject
-{
- Q_OBJECT
-
-public:
- bool getEdition (int& edition, QString& errorOut);
- bool setEmail (QString email, QString& errorOut);
- bool setPassword (QString password, QString& errorOut);
-signals:
- void error(QString e);
-
-private:
- QString request();
-
- QString m_Email;
- QString m_Password;
- CoreInterface m_CoreInterface;
-};
-
-#endif // WEBCLIENT_H