2012-06-10 16:50:54 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2016-09-07 14:24:00 +00:00
|
|
|
* Copyright (C) 2012-2016 Symless Ltd.
|
2012-06-10 16:50:54 +00:00
|
|
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
2015-07-29 21:34:21 +00:00
|
|
|
*
|
2012-06-10 16:50:54 +00:00
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2015-05-03 02:33:52 +00:00
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
2015-07-29 21:34:21 +00:00
|
|
|
*
|
2012-06-10 16:50:54 +00:00
|
|
|
* 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-08-03 15:58:23 +00:00
|
|
|
#pragma once
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
2024-07-02 19:07:06 +00:00
|
|
|
#include <QMutex>
|
2012-06-10 16:50:54 +00:00
|
|
|
#include <QProcess>
|
2024-07-02 19:07:06 +00:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QSystemTrayIcon>
|
2012-06-10 16:50:54 +00:00
|
|
|
#include <QThread>
|
2024-07-22 16:48:02 +00:00
|
|
|
#include <memory>
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
#include "ui_MainWindowBase.h"
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
#include "ActivationDialog.h"
|
|
|
|
|
#include "ClientConnection.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
#include "ServerConfig.h"
|
2021-04-22 07:29:46 +00:00
|
|
|
#include "ServerConnection.h"
|
2021-01-10 13:31:56 +00:00
|
|
|
#include "TrayIcon.h"
|
2024-07-26 22:53:52 +00:00
|
|
|
#include "global/Ipc.h"
|
2024-08-01 00:13:01 +00:00
|
|
|
#include "gui/AppConfig.h"
|
|
|
|
|
#include "gui/ConfigScopes.h"
|
2024-07-23 19:17:40 +00:00
|
|
|
#include "gui/QIpcClient.h"
|
2024-07-26 22:53:52 +00:00
|
|
|
#include "gui/TlsUtility.h"
|
2024-07-23 19:17:40 +00:00
|
|
|
#include "gui/VersionChecker.h"
|
2014-11-24 11:59:24 +00:00
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
class QAction;
|
|
|
|
|
class QMenu;
|
|
|
|
|
class QLineEdit;
|
|
|
|
|
class QGroupBox;
|
|
|
|
|
class QPushButton;
|
|
|
|
|
class QTextEdit;
|
|
|
|
|
class QComboBox;
|
|
|
|
|
class QTabWidget;
|
|
|
|
|
class QCheckBox;
|
|
|
|
|
class QRadioButton;
|
2014-11-13 11:02:48 +00:00
|
|
|
class QMessageBox;
|
2014-11-13 12:09:11 +00:00
|
|
|
class QAbstractButton;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
class LogDialog;
|
|
|
|
|
class QSynergyApplication;
|
|
|
|
|
class SetupWizard;
|
2014-11-13 11:02:48 +00:00
|
|
|
class DataDownloader;
|
2014-11-28 12:57:57 +00:00
|
|
|
class CommandProcess;
|
2024-07-26 22:53:52 +00:00
|
|
|
class TlsCertificate;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
class MainWindow : public QMainWindow, public Ui::MainWindowBase {
|
|
|
|
|
Q_OBJECT
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
friend class QSynergyApplication;
|
|
|
|
|
friend class SetupWizard;
|
|
|
|
|
friend class ActivationDialog;
|
|
|
|
|
friend class SettingsDialog;
|
|
|
|
|
friend class ServerConnection;
|
|
|
|
|
friend class ClientConnection;
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
public:
|
2024-07-22 16:48:02 +00:00
|
|
|
enum class CoreState {
|
|
|
|
|
Disconnected,
|
|
|
|
|
Connecting,
|
|
|
|
|
Connected,
|
|
|
|
|
Listening,
|
|
|
|
|
PendingRetry
|
2024-07-02 19:07:06 +00:00
|
|
|
};
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
enum class CoreMode { None, Client, Server };
|
2024-07-22 16:48:02 +00:00
|
|
|
enum class LogLevel { Error, Info };
|
|
|
|
|
enum class RuningState { Started, Stopped };
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
public:
|
2024-08-03 00:17:29 +00:00
|
|
|
explicit MainWindow(
|
|
|
|
|
synergy::gui::ConfigScopes &configScopes, AppConfig &appConfig);
|
2024-07-22 16:48:02 +00:00
|
|
|
~MainWindow() override;
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-23 19:17:40 +00:00
|
|
|
void setVisible(bool visible) override;
|
2024-07-26 22:53:52 +00:00
|
|
|
CoreMode coreMode() const;
|
2024-08-03 00:17:29 +00:00
|
|
|
QString coreModeString() const;
|
2024-07-02 19:07:06 +00:00
|
|
|
QString address() const;
|
2024-07-26 22:53:52 +00:00
|
|
|
QString appPath(const QString &name) const;
|
2024-07-02 19:07:06 +00:00
|
|
|
void open();
|
|
|
|
|
ServerConfig &serverConfig() { return m_ServerConfig; }
|
|
|
|
|
void autoAddScreen(const QString name);
|
2024-07-26 22:53:52 +00:00
|
|
|
int showActivationDialog();
|
2024-07-02 19:07:06 +00:00
|
|
|
void appendLogInfo(const QString &text);
|
|
|
|
|
void appendLogDebug(const QString &text);
|
|
|
|
|
void appendLogError(const QString &text);
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-26 22:53:52 +00:00
|
|
|
signals:
|
|
|
|
|
void created();
|
|
|
|
|
void shown();
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void onAppAboutToQuit();
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void onCreated();
|
|
|
|
|
void onShown();
|
2024-08-03 00:17:29 +00:00
|
|
|
void onConfigScopesSaving();
|
2024-07-26 22:53:52 +00:00
|
|
|
void onAppConfigTlsChanged();
|
|
|
|
|
void onAppConfigScreenNameChanged();
|
|
|
|
|
void onAppConfigInvertConnection();
|
|
|
|
|
void onLicenseHandlerSerialKeyChanged(const QString &serialKey);
|
|
|
|
|
void onLicenseHandlerInvalidLicense();
|
|
|
|
|
void onIpcClientReadLogLine(const QString &text);
|
|
|
|
|
void onIpcClientErrorMessage(const QString &text);
|
|
|
|
|
void onIpcClientInfoMessage(const QString &text);
|
|
|
|
|
void onCoreProcessFinished(int exitCode, QProcess::ExitStatus);
|
|
|
|
|
void onVersionCheckerUpdateFound(const QString &version);
|
|
|
|
|
void onTrayIconCreate(QSystemTrayIcon::ActivationReason reason);
|
|
|
|
|
void onActionStartCoreTriggered();
|
|
|
|
|
void onActionStopCoreTriggered();
|
|
|
|
|
void onCoreProcessReadyReadStandardOutput();
|
|
|
|
|
void onCoreProcessReadyReadStandardError();
|
2024-08-01 00:13:01 +00:00
|
|
|
void onWindowSaveTimerTimeout();
|
|
|
|
|
|
|
|
|
|
// autoconnect slots
|
2024-07-26 22:53:52 +00:00
|
|
|
void on_m_pButtonApply_clicked();
|
|
|
|
|
void on_m_pLabelComputerName_linkActivated(const QString &link);
|
|
|
|
|
void on_m_pLabelFingerprint_linkActivated(const QString &link);
|
|
|
|
|
void on_m_pButtonConnect_clicked();
|
|
|
|
|
void on_m_pButtonConnectToClient_clicked();
|
2024-07-02 19:07:06 +00:00
|
|
|
void on_m_pRadioGroupServer_clicked(bool);
|
|
|
|
|
void on_m_pRadioGroupClient_clicked(bool);
|
|
|
|
|
void on_m_pButtonConfigureServer_clicked();
|
|
|
|
|
bool on_m_pActionSave_triggered();
|
|
|
|
|
void on_m_pActionAbout_triggered();
|
|
|
|
|
void on_m_pActionHelp_triggered();
|
|
|
|
|
void on_m_pActionSettings_triggered();
|
|
|
|
|
void on_m_pActivate_triggered();
|
2024-08-03 00:17:29 +00:00
|
|
|
void on_m_pLineEditHostname_returnPressed();
|
|
|
|
|
void on_m_pLineEditClientIp_returnPressed();
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-26 22:53:52 +00:00
|
|
|
private:
|
2024-07-22 16:48:02 +00:00
|
|
|
AppConfig &appConfig() { return m_AppConfig; }
|
|
|
|
|
AppConfig const &appConfig() const { return m_AppConfig; }
|
2024-07-02 19:07:06 +00:00
|
|
|
void createMenuBar();
|
|
|
|
|
void createStatusBar();
|
|
|
|
|
void createTrayIcon();
|
2024-07-26 22:53:52 +00:00
|
|
|
void applyConfig();
|
2024-08-03 00:17:29 +00:00
|
|
|
void applyCloseToTray() const;
|
2024-07-22 16:48:02 +00:00
|
|
|
void setIcon(CoreState state) const;
|
|
|
|
|
void setCoreState(CoreState state);
|
2024-07-02 19:07:06 +00:00
|
|
|
bool checkForApp(int which, QString &app);
|
|
|
|
|
bool clientArgs(QStringList &args, QString &app);
|
|
|
|
|
bool serverArgs(QStringList &args, QString &app);
|
|
|
|
|
void setStatus(const QString &status);
|
2024-07-18 07:04:39 +00:00
|
|
|
void sendIpcMessage(IpcMessageType type, const char *buffer, bool showErrors);
|
2024-07-02 19:07:06 +00:00
|
|
|
void updateFromLogLine(const QString &line);
|
2024-07-26 22:53:52 +00:00
|
|
|
QString getIPAddresses() const;
|
2024-07-02 19:07:06 +00:00
|
|
|
void stopService();
|
|
|
|
|
void stopDesktop();
|
|
|
|
|
void enableServer(bool enable);
|
|
|
|
|
void enableClient(bool enable);
|
2024-07-26 22:53:52 +00:00
|
|
|
QString getProfileRootForArg() const;
|
2024-07-02 19:07:06 +00:00
|
|
|
void checkConnected(const QString &line);
|
|
|
|
|
void checkFingerprint(const QString &line);
|
2024-07-16 08:30:35 +00:00
|
|
|
bool checkSecureSocket(const QString &line);
|
2024-07-02 19:07:06 +00:00
|
|
|
void checkLicense(const QString &line);
|
2024-07-26 22:53:52 +00:00
|
|
|
QString getTimeStamp() const;
|
2024-07-22 16:48:02 +00:00
|
|
|
void restartCore();
|
|
|
|
|
void showEvent(QShowEvent *) override;
|
2024-08-03 00:17:29 +00:00
|
|
|
void closeEvent(QCloseEvent *event) override;
|
2024-07-02 19:07:06 +00:00
|
|
|
void secureSocket(bool secureSocket);
|
|
|
|
|
void windowStateChanged();
|
2024-07-26 22:53:52 +00:00
|
|
|
void connectSlots() const;
|
2024-07-22 16:48:02 +00:00
|
|
|
void updateWindowTitle();
|
2024-07-26 22:53:52 +00:00
|
|
|
void processCoreLogLine(const QString &line);
|
|
|
|
|
void startCore();
|
|
|
|
|
void onCoreProcessRetryStart();
|
|
|
|
|
void updateLocalFingerprint();
|
|
|
|
|
void updateScreenName();
|
|
|
|
|
void saveSettings();
|
|
|
|
|
QString configFilename();
|
2024-08-03 00:17:29 +00:00
|
|
|
bool isCoreActive() const;
|
2024-07-26 22:53:52 +00:00
|
|
|
void showConfigureServer(const QString &message);
|
|
|
|
|
void showConfigureServer() { showConfigureServer(""); }
|
|
|
|
|
void showLicenseNotice();
|
|
|
|
|
void stopCore();
|
2024-08-01 00:13:01 +00:00
|
|
|
void restoreWindow();
|
|
|
|
|
void saveWindow();
|
|
|
|
|
void setupControls();
|
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
|
void moveEvent(QMoveEvent *event) override;
|
2024-08-03 00:17:29 +00:00
|
|
|
void showFirstRunMessage();
|
|
|
|
|
void showDevThanksMessage();
|
|
|
|
|
QString productName() const;
|
2024-07-22 16:48:02 +00:00
|
|
|
|
2024-07-26 22:53:52 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
void checkOSXNotification(const QString &line);
|
2018-08-03 15:58:23 +00:00
|
|
|
#endif
|
2024-07-22 16:48:02 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
VersionChecker m_VersionChecker;
|
2024-07-16 08:30:35 +00:00
|
|
|
QIpcClient m_IpcClient;
|
2024-07-26 22:53:52 +00:00
|
|
|
TrayIcon m_TrayIcon;
|
2024-07-02 19:07:06 +00:00
|
|
|
QMutex m_StopDesktopMutex;
|
2024-07-22 16:48:02 +00:00
|
|
|
bool m_ActivationDialogRunning = false;
|
|
|
|
|
QStringList m_PendingClientNames;
|
|
|
|
|
RuningState m_ExpectedRunningState = RuningState::Stopped;
|
|
|
|
|
std::unique_ptr<QProcess> m_pCoreProcess;
|
|
|
|
|
QMenuBar *m_pMenuBar = nullptr;
|
|
|
|
|
QMenu *m_pMenuFile = nullptr;
|
|
|
|
|
QMenu *m_pMenuEdit = nullptr;
|
|
|
|
|
QMenu *m_pMenuWindow = nullptr;
|
|
|
|
|
QMenu *m_pMenuHelp = nullptr;
|
|
|
|
|
QAbstractButton *m_pCancelButton = nullptr;
|
|
|
|
|
CoreState m_CoreState = CoreState::Disconnected;
|
|
|
|
|
bool m_AlreadyHidden = false;
|
|
|
|
|
bool m_SecureSocket = false;
|
|
|
|
|
QString m_SecureSocketVersion = "";
|
2024-08-01 00:13:01 +00:00
|
|
|
bool m_SaveWindow = false;
|
2024-08-03 00:17:29 +00:00
|
|
|
LicenseHandler m_LicenseHandler;
|
2019-08-02 12:11:47 +00:00
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
synergy::gui::ConfigScopes &m_ConfigScopes;
|
2024-07-26 22:53:52 +00:00
|
|
|
AppConfig &m_AppConfig;
|
|
|
|
|
ServerConfig m_ServerConfig;
|
|
|
|
|
ServerConnection m_ServerConnection;
|
|
|
|
|
ClientConnection m_ClientConnection;
|
|
|
|
|
synergy::gui::TlsUtility m_TlsUtility;
|
2024-08-01 00:13:01 +00:00
|
|
|
QTimer m_WindowSaveTimer;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|