Make Clang param and arg alignment more readable (#7387)

* Turn off alignment of params

* Apply Clang format

* Change AlignAfterOpenBracket to AlwaysBreak and add extra bin pack settings

* Restore default bin packing

* Apply format
This commit is contained in:
Nick Bolton 2024-07-16 14:36:44 +01:00 committed by GitHub
parent f82c6716bb
commit e435953af7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
320 changed files with 5242 additions and 3930 deletions

View file

@ -9,3 +9,20 @@
# $ pip install clang-format==<version> # $ pip install clang-format==<version>
BasedOnStyle: LLVM BasedOnStyle: LLVM
# Turn off LLVM default alignment of params with the opening bracket,
# which can be less readable in some cases in our code base.
#
# Using `AlwaysBreak` will result in:
# void fooBarBazQuxHelloWorld(
# int a,
# int b);
#
# Instead of:
# void fooBarBazQuxHelloWorld(int a,
# int b);
AlignAfterOpenBracket: AlwaysBreak
# Turn off LLVM default packing of ctor initializers.
# This makes it easier to see which members were initialized and in what order.
PackConstructorInitializers: CurrentLine

View file

@ -40,7 +40,9 @@ const UINT MSWindowsClientTaskBarReceiver::s_stateToIconID[kMaxState] = {
MSWindowsClientTaskBarReceiver::MSWindowsClientTaskBarReceiver( MSWindowsClientTaskBarReceiver::MSWindowsClientTaskBarReceiver(
HINSTANCE appInstance, const BufferedLogOutputter *logBuffer, HINSTANCE appInstance, const BufferedLogOutputter *logBuffer,
IEventQueue *events) IEventQueue *events)
: ClientTaskBarReceiver(events), m_appInstance(appInstance), m_window(NULL), : ClientTaskBarReceiver(events),
m_appInstance(appInstance),
m_window(NULL),
m_logBuffer(logBuffer) { m_logBuffer(logBuffer) {
for (UInt32 i = 0; i < kMaxState; ++i) { for (UInt32 i = 0; i < kMaxState; ++i) {
m_icon[i] = loadIcon(s_stateToIconID[i]); m_icon[i] = loadIcon(s_stateToIconID[i]);
@ -135,8 +137,8 @@ void MSWindowsClientTaskBarReceiver::runMenu(int x, int y) {
HMENU menu = GetSubMenu(m_menu, 0); HMENU menu = GetSubMenu(m_menu, 0);
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE); SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
HMENU logLevelMenu = GetSubMenu(menu, 3); HMENU logLevelMenu = GetSubMenu(menu, 3);
CheckMenuRadioItem(logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, CheckMenuRadioItem(
MF_BYPOSITION); logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, MF_BYPOSITION);
int n = TrackPopupMenu( int n = TrackPopupMenu(
menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, x, menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, x,
y, 0, m_window, NULL); y, 0, m_window, NULL);
@ -226,8 +228,8 @@ void MSWindowsClientTaskBarReceiver::onStatusChanged() {
HICON HICON
MSWindowsClientTaskBarReceiver::loadIcon(UINT id) { MSWindowsClientTaskBarReceiver::loadIcon(UINT id) {
HANDLE icon = LoadImage(m_appInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, HANDLE icon = LoadImage(
LR_DEFAULTCOLOR); m_appInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
return static_cast<HICON>(icon); return static_cast<HICON>(icon);
} }
@ -267,8 +269,8 @@ void MSWindowsClientTaskBarReceiver::destroyWindow() {
} }
} }
BOOL MSWindowsClientTaskBarReceiver::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, BOOL MSWindowsClientTaskBarReceiver::dlgProc(
LPARAM) { HWND hwnd, UINT msg, WPARAM wParam, LPARAM) {
switch (msg) { switch (msg) {
case WM_INITDIALOG: case WM_INITDIALOG:
// use default focus // use default focus
@ -284,9 +286,8 @@ BOOL MSWindowsClientTaskBarReceiver::dlgProc(HWND hwnd, UINT msg, WPARAM wParam,
return FALSE; return FALSE;
} }
BOOL CALLBACK MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd, UINT msg, BOOL CALLBACK MSWindowsClientTaskBarReceiver::staticDlgProc(
WPARAM wParam, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
LPARAM lParam) {
// if msg is WM_INITDIALOG, extract the MSWindowsClientTaskBarReceiver* // if msg is WM_INITDIALOG, extract the MSWindowsClientTaskBarReceiver*
// and put it in the extra window data then forward the call. // and put it in the extra window data then forward the call.
MSWindowsClientTaskBarReceiver *self = NULL; MSWindowsClientTaskBarReceiver *self = NULL;
@ -310,14 +311,14 @@ BOOL CALLBACK MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd, UINT msg,
} }
} }
IArchTaskBarReceiver * IArchTaskBarReceiver *createTaskBarReceiver(
createTaskBarReceiver(const BufferedLogOutputter *logBuffer, const BufferedLogOutputter *logBuffer, IEventQueue *events) {
IEventQueue *events) { ArchMiscWindows::setIcons(
ArchMiscWindows::setIcons((HICON)LoadImage(ArchMiscWindows::instanceWin32(), (HICON)LoadImage(
MAKEINTRESOURCE(IDI_SYNERGY), ArchMiscWindows::instanceWin32(), MAKEINTRESOURCE(IDI_SYNERGY),
IMAGE_ICON, 32, 32, LR_SHARED), IMAGE_ICON, 32, 32, LR_SHARED),
(HICON)LoadImage(ArchMiscWindows::instanceWin32(), (HICON)LoadImage(
MAKEINTRESOURCE(IDI_SYNERGY), ArchMiscWindows::instanceWin32(), MAKEINTRESOURCE(IDI_SYNERGY),
IMAGE_ICON, 16, 16, LR_SHARED)); IMAGE_ICON, 16, 16, LR_SHARED));
return new MSWindowsClientTaskBarReceiver( return new MSWindowsClientTaskBarReceiver(

View file

@ -29,8 +29,8 @@ class IEventQueue;
//! Implementation of ClientTaskBarReceiver for Microsoft Windows //! Implementation of ClientTaskBarReceiver for Microsoft Windows
class MSWindowsClientTaskBarReceiver : public ClientTaskBarReceiver { class MSWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
public: public:
MSWindowsClientTaskBarReceiver(HINSTANCE, const BufferedLogOutputter *, MSWindowsClientTaskBarReceiver(
IEventQueue *events); HINSTANCE, const BufferedLogOutputter *, IEventQueue *events);
virtual ~MSWindowsClientTaskBarReceiver(); virtual ~MSWindowsClientTaskBarReceiver();
// IArchTaskBarReceiver overrides // IArchTaskBarReceiver overrides
@ -53,8 +53,8 @@ private:
void destroyWindow(); void destroyWindow();
BOOL dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); BOOL dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static BOOL CALLBACK staticDlgProc(HWND hwnd, UINT msg, WPARAM wParam, static BOOL CALLBACK
LPARAM lParam); staticDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
private: private:
HINSTANCE m_appInstance; HINSTANCE m_appInstance;

View file

@ -23,8 +23,8 @@
// OSXClientTaskBarReceiver // OSXClientTaskBarReceiver
// //
OSXClientTaskBarReceiver::OSXClientTaskBarReceiver(const BufferedLogOutputter *, OSXClientTaskBarReceiver::OSXClientTaskBarReceiver(
IEventQueue *events) const BufferedLogOutputter *, IEventQueue *events)
: ClientTaskBarReceiver(events) { : ClientTaskBarReceiver(events) {
// add ourself to the task bar // add ourself to the task bar
ARCH->addReceiver(this); ARCH->addReceiver(this);
@ -50,8 +50,7 @@ const IArchTaskBarReceiver::Icon OSXClientTaskBarReceiver::getIcon() const {
return NULL; return NULL;
} }
IArchTaskBarReceiver * IArchTaskBarReceiver *createTaskBarReceiver(
createTaskBarReceiver(const BufferedLogOutputter *logBuffer, const BufferedLogOutputter *logBuffer, IEventQueue *events) {
IEventQueue *events) {
return new OSXClientTaskBarReceiver(logBuffer, events); return new OSXClientTaskBarReceiver(logBuffer, events);
} }

View file

@ -51,8 +51,7 @@ CXWindowsClientTaskBarReceiver::getIcon() const {
return NULL; return NULL;
} }
IArchTaskBarReceiver * IArchTaskBarReceiver *createTaskBarReceiver(
createTaskBarReceiver(const BufferedLogOutputter *logBuffer, const BufferedLogOutputter *logBuffer, IEventQueue *events) {
IEventQueue *events) {
return new CXWindowsClientTaskBarReceiver(logBuffer, events); return new CXWindowsClientTaskBarReceiver(logBuffer, events);
} }

View file

@ -26,8 +26,8 @@ class IEventQueue;
//! Implementation of ClientTaskBarReceiver for X Windows //! Implementation of ClientTaskBarReceiver for X Windows
class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver { class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
public: public:
CXWindowsClientTaskBarReceiver(const BufferedLogOutputter *, CXWindowsClientTaskBarReceiver(
IEventQueue *events); const BufferedLogOutputter *, IEventQueue *events);
CXWindowsClientTaskBarReceiver(const CXWindowsClientTaskBarReceiver &) = CXWindowsClientTaskBarReceiver(const CXWindowsClientTaskBarReceiver &) =
delete; delete;
CXWindowsClientTaskBarReceiver(CXWindowsClientTaskBarReceiver &&) = delete; CXWindowsClientTaskBarReceiver(CXWindowsClientTaskBarReceiver &&) = delete;

View file

@ -41,8 +41,11 @@ const UINT MSWindowsServerTaskBarReceiver::s_stateToIconID[kMaxState] = {
MSWindowsServerTaskBarReceiver::MSWindowsServerTaskBarReceiver( MSWindowsServerTaskBarReceiver::MSWindowsServerTaskBarReceiver(
HINSTANCE appInstance, const BufferedLogOutputter *logBuffer, HINSTANCE appInstance, const BufferedLogOutputter *logBuffer,
IEventQueue *events) IEventQueue *events)
: ServerTaskBarReceiver(events), m_events(events), : ServerTaskBarReceiver(events),
m_appInstance(appInstance), m_window(NULL), m_logBuffer(logBuffer) { m_events(events),
m_appInstance(appInstance),
m_window(NULL),
m_logBuffer(logBuffer) {
for (UInt32 i = 0; i < kMaxState; ++i) { for (UInt32 i = 0; i < kMaxState; ++i) {
m_icon[i] = loadIcon(s_stateToIconID[i]); m_icon[i] = loadIcon(s_stateToIconID[i]);
} }
@ -150,8 +153,8 @@ void MSWindowsServerTaskBarReceiver::runMenu(int x, int y) {
HMENU menu = GetSubMenu(m_menu, 0); HMENU menu = GetSubMenu(m_menu, 0);
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE); SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
HMENU logLevelMenu = GetSubMenu(menu, 3); HMENU logLevelMenu = GetSubMenu(menu, 3);
CheckMenuRadioItem(logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, CheckMenuRadioItem(
MF_BYPOSITION); logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, MF_BYPOSITION);
int n = TrackPopupMenu( int n = TrackPopupMenu(
menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, x, menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, x,
y, 0, m_window, NULL); y, 0, m_window, NULL);
@ -172,18 +175,19 @@ void MSWindowsServerTaskBarReceiver::runMenu(int x, int y) {
break; break;
case IDC_RELOAD_CONFIG: case IDC_RELOAD_CONFIG:
m_events->addEvent(Event(m_events->forServerApp().reloadConfig(), m_events->addEvent(Event(
m_events->getSystemTarget())); m_events->forServerApp().reloadConfig(), m_events->getSystemTarget()));
break; break;
case IDC_FORCE_RECONNECT: case IDC_FORCE_RECONNECT:
m_events->addEvent(Event(m_events->forServerApp().forceReconnect(), m_events->addEvent(Event(
m_events->forServerApp().forceReconnect(),
m_events->getSystemTarget())); m_events->getSystemTarget()));
break; break;
case ID_SYNERGY_RESETSERVER: case ID_SYNERGY_RESETSERVER:
m_events->addEvent(Event(m_events->forServerApp().resetServer(), m_events->addEvent(Event(
m_events->getSystemTarget())); m_events->forServerApp().resetServer(), m_events->getSystemTarget()));
break; break;
case IDC_TASKBAR_LOG_LEVEL_ERROR: case IDC_TASKBAR_LOG_LEVEL_ERROR:
@ -256,8 +260,8 @@ void MSWindowsServerTaskBarReceiver::onStatusChanged() {
HICON HICON
MSWindowsServerTaskBarReceiver::loadIcon(UINT id) { MSWindowsServerTaskBarReceiver::loadIcon(UINT id) {
HANDLE icon = LoadImage(m_appInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, HANDLE icon = LoadImage(
LR_DEFAULTCOLOR); m_appInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
return static_cast<HICON>(icon); return static_cast<HICON>(icon);
} }
@ -297,8 +301,8 @@ void MSWindowsServerTaskBarReceiver::destroyWindow() {
} }
} }
BOOL MSWindowsServerTaskBarReceiver::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, BOOL MSWindowsServerTaskBarReceiver::dlgProc(
LPARAM) { HWND hwnd, UINT msg, WPARAM wParam, LPARAM) {
switch (msg) { switch (msg) {
case WM_INITDIALOG: case WM_INITDIALOG:
// use default focus // use default focus
@ -314,9 +318,8 @@ BOOL MSWindowsServerTaskBarReceiver::dlgProc(HWND hwnd, UINT msg, WPARAM wParam,
return FALSE; return FALSE;
} }
BOOL CALLBACK MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd, UINT msg, BOOL CALLBACK MSWindowsServerTaskBarReceiver::staticDlgProc(
WPARAM wParam, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
LPARAM lParam) {
// if msg is WM_INITDIALOG, extract the MSWindowsServerTaskBarReceiver* // if msg is WM_INITDIALOG, extract the MSWindowsServerTaskBarReceiver*
// and put it in the extra window data then forward the call. // and put it in the extra window data then forward the call.
MSWindowsServerTaskBarReceiver *self = NULL; MSWindowsServerTaskBarReceiver *self = NULL;
@ -341,14 +344,14 @@ BOOL CALLBACK MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd, UINT msg,
} }
} }
IArchTaskBarReceiver * IArchTaskBarReceiver *createTaskBarReceiver(
createTaskBarReceiver(const BufferedLogOutputter *logBuffer, const BufferedLogOutputter *logBuffer, IEventQueue *events) {
IEventQueue *events) { ArchMiscWindows::setIcons(
ArchMiscWindows::setIcons((HICON)LoadImage(ArchMiscWindows::instanceWin32(), (HICON)LoadImage(
MAKEINTRESOURCE(IDI_SYNERGY), ArchMiscWindows::instanceWin32(), MAKEINTRESOURCE(IDI_SYNERGY),
IMAGE_ICON, 32, 32, LR_SHARED), IMAGE_ICON, 32, 32, LR_SHARED),
(HICON)LoadImage(ArchMiscWindows::instanceWin32(), (HICON)LoadImage(
MAKEINTRESOURCE(IDI_SYNERGY), ArchMiscWindows::instanceWin32(), MAKEINTRESOURCE(IDI_SYNERGY),
IMAGE_ICON, 16, 16, LR_SHARED)); IMAGE_ICON, 16, 16, LR_SHARED));
return new MSWindowsServerTaskBarReceiver( return new MSWindowsServerTaskBarReceiver(

View file

@ -29,8 +29,8 @@ class IEventQueue;
//! Implementation of ServerTaskBarReceiver for Microsoft Windows //! Implementation of ServerTaskBarReceiver for Microsoft Windows
class MSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver { class MSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
public: public:
MSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter *, MSWindowsServerTaskBarReceiver(
IEventQueue *events); HINSTANCE, const BufferedLogOutputter *, IEventQueue *events);
virtual ~MSWindowsServerTaskBarReceiver(); virtual ~MSWindowsServerTaskBarReceiver();
// IArchTaskBarReceiver overrides // IArchTaskBarReceiver overrides
@ -53,8 +53,8 @@ private:
void destroyWindow(); void destroyWindow();
BOOL dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); BOOL dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static BOOL CALLBACK staticDlgProc(HWND hwnd, UINT msg, WPARAM wParam, static BOOL CALLBACK
LPARAM lParam); staticDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
private: private:
HINSTANCE m_appInstance; HINSTANCE m_appInstance;

View file

@ -23,8 +23,8 @@
// OSXServerTaskBarReceiver // OSXServerTaskBarReceiver
// //
OSXServerTaskBarReceiver::OSXServerTaskBarReceiver(const BufferedLogOutputter *, OSXServerTaskBarReceiver::OSXServerTaskBarReceiver(
IEventQueue *events) const BufferedLogOutputter *, IEventQueue *events)
: ServerTaskBarReceiver(events) { : ServerTaskBarReceiver(events) {
// add ourself to the task bar // add ourself to the task bar
ARCH->addReceiver(this); ARCH->addReceiver(this);
@ -50,8 +50,7 @@ const IArchTaskBarReceiver::Icon OSXServerTaskBarReceiver::getIcon() const {
return NULL; return NULL;
} }
IArchTaskBarReceiver * IArchTaskBarReceiver *createTaskBarReceiver(
createTaskBarReceiver(const BufferedLogOutputter *logBuffer, const BufferedLogOutputter *logBuffer, IEventQueue *events) {
IEventQueue *events) {
return new OSXServerTaskBarReceiver(logBuffer, events); return new OSXServerTaskBarReceiver(logBuffer, events);
} }

View file

@ -51,8 +51,7 @@ CXWindowsServerTaskBarReceiver::getIcon() const {
return NULL; return NULL;
} }
IArchTaskBarReceiver * IArchTaskBarReceiver *createTaskBarReceiver(
createTaskBarReceiver(const BufferedLogOutputter *logBuffer, const BufferedLogOutputter *logBuffer, IEventQueue *events) {
IEventQueue *events) {
return new CXWindowsServerTaskBarReceiver(logBuffer, events); return new CXWindowsServerTaskBarReceiver(logBuffer, events);
} }

View file

@ -26,8 +26,8 @@ class IEventQueue;
//! Implementation of ServerTaskBarReceiver for X Windows //! Implementation of ServerTaskBarReceiver for X Windows
class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver { class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
public: public:
CXWindowsServerTaskBarReceiver(const BufferedLogOutputter *, CXWindowsServerTaskBarReceiver(
IEventQueue *events); const BufferedLogOutputter *, IEventQueue *events);
CXWindowsServerTaskBarReceiver(const CXWindowsServerTaskBarReceiver &) = CXWindowsServerTaskBarReceiver(const CXWindowsServerTaskBarReceiver &) =
delete; delete;
CXWindowsServerTaskBarReceiver(CXWindowsServerTaskBarReceiver &&) = delete; CXWindowsServerTaskBarReceiver(CXWindowsServerTaskBarReceiver &&) = delete;

View file

@ -91,6 +91,6 @@ QString AboutDialog::getCopyright() const {
QString copyright("Copyright © 2012-%%YEAR%% Symless Ltd.\n" QString copyright("Copyright © 2012-%%YEAR%% Symless Ltd.\n"
"Copyright © 2009-2012 Nick Bolton\n" "Copyright © 2009-2012 Nick Bolton\n"
"Copyright © 2002-2009 Chris Schoeneman"); "Copyright © 2002-2009 Chris Schoeneman");
return copyright.replace(QString("%%YEAR%%"), return copyright.replace(
QString::number(buildDate.year())); QString("%%YEAR%%"), QString::number(buildDate.year()));
} }

View file

@ -32,15 +32,19 @@ const char *Action::m_SwitchDirectionNames[] = {"left", "right", "up", "down"};
const char *Action::m_LockCursorModeNames[] = {"toggle", "on", "off"}; const char *Action::m_LockCursorModeNames[] = {"toggle", "on", "off"};
Action::Action() Action::Action()
: m_KeySequence(), m_Type(keystroke), m_TypeScreenNames(), : m_KeySequence(),
m_SwitchScreenName(), m_SwitchDirection(switchLeft), m_Type(keystroke),
m_LockCursorMode(lockCursorToggle), m_ActiveOnRelease(false), m_TypeScreenNames(),
m_SwitchScreenName(),
m_SwitchDirection(switchLeft),
m_LockCursorMode(lockCursorToggle),
m_ActiveOnRelease(false),
m_HasScreens(false) {} m_HasScreens(false) {}
QString Action::text() const { QString Action::text() const {
QString text = QString text =
QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 QString(m_ActionTypeNames
: type()]) + [keySequence().isMouseButton() ? type() + 6 : type()]) +
"("; "(";
switch (type()) { switch (type()) {

View file

@ -27,16 +27,20 @@
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
ActionDialog::ActionDialog(QWidget *parent, ServerConfig &config, ActionDialog::ActionDialog(
Hotkey &hotkey, Action &action) QWidget *parent, ServerConfig &config, Hotkey &hotkey, Action &action)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
Ui::ActionDialogBase(), m_ServerConfig(config), m_Hotkey(hotkey), Ui::ActionDialogBase(),
m_Action(action), m_pButtonGroupType(new QButtonGroup(this)) { m_ServerConfig(config),
m_Hotkey(hotkey),
m_Action(action),
m_pButtonGroupType(new QButtonGroup(this)) {
setupUi(this); setupUi(this);
// work around Qt Designer's lack of a QButtonGroup; we need it to get // work around Qt Designer's lack of a QButtonGroup; we need it to get
// at the button id of the checked radio button // at the button id of the checked radio button
QRadioButton *const typeButtons[] = {m_pRadioPress, QRadioButton *const typeButtons[] = {
m_pRadioPress,
m_pRadioRelease, m_pRadioRelease,
m_pRadioPressAndRelease, m_pRadioPressAndRelease,
m_pRadioSwitchToScreen, m_pRadioSwitchToScreen,

View file

@ -34,8 +34,8 @@ class ActionDialog : public QDialog, public Ui::ActionDialogBase {
Q_OBJECT Q_OBJECT
public: public:
ActionDialog(QWidget *parent, ServerConfig &config, Hotkey &hotkey, ActionDialog(
Action &action); QWidget *parent, ServerConfig &config, Hotkey &hotkey, Action &action);
protected slots: protected slots:
void accept(); void accept();

View file

@ -13,9 +13,11 @@
#include <QThread> #include <QThread>
#include <iostream> #include <iostream>
ActivationDialog::ActivationDialog(QWidget *parent, AppConfig &appConfig, ActivationDialog::ActivationDialog(
LicenseManager &licenseManager) QWidget *parent, AppConfig &appConfig, LicenseManager &licenseManager)
: QDialog(parent), ui(new Ui::ActivationDialog), m_appConfig(&appConfig), : QDialog(parent),
ui(new Ui::ActivationDialog),
m_appConfig(&appConfig),
m_LicenseManager(&licenseManager) { m_LicenseManager(&licenseManager) {
ui->setupUi(this); ui->setupUi(this);
refreshSerialKey(); refreshSerialKey();
@ -92,7 +94,8 @@ void ActivationDialog::accept() {
if (m_LicenseManager->serialKey().isTrial()) { if (m_LicenseManager->serialKey().isTrial()) {
message.information(this, "Thanks!", thanksMessage); message.information(this, "Thanks!", thanksMessage);
} else { } else {
message.information(this, "Activated!", message.information(
this, "Activated!",
tr("Thanks for activating %1!") tr("Thanks for activating %1!")
.arg(m_LicenseManager->getEditionName(edition))); .arg(m_LicenseManager->getEditionName(edition)));
} }

View file

@ -14,8 +14,8 @@ class ActivationDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
ActivationDialog(QWidget *parent, AppConfig &appConfig, ActivationDialog(
LicenseManager &licenseManager); QWidget *parent, AppConfig &appConfig, LicenseManager &licenseManager);
~ActivationDialog(); ~ActivationDialog();
public slots: public slots:

View file

@ -25,8 +25,8 @@ void ActivationNotifier::setIdentity(QString identity) {
m_Identity = identity; m_Identity = identity;
} }
void ActivationNotifier::setUpdateInfo(QString const &fromVersion, void ActivationNotifier::setUpdateInfo(
QString const &toVersion, QString const &fromVersion, QString const &toVersion,
QString const &serialKey) { QString const &serialKey) {
m_fromVersion = fromVersion; m_fromVersion = fromVersion;
m_toVersion = toVersion; m_toVersion = toVersion;

View file

@ -26,7 +26,8 @@ public:
explicit ActivationNotifier(QObject *parent = 0); explicit ActivationNotifier(QObject *parent = 0);
void setIdentity(QString identity); void setIdentity(QString identity);
void setUpdateInfo(QString const &fromVersion, QString const &toVersion, void setUpdateInfo(
QString const &fromVersion, QString const &toVersion,
QString const &serialKey); QString const &serialKey);
public slots: public slots:

View file

@ -23,10 +23,12 @@
AddClientDialog::AddClientDialog(const QString &clientName, QWidget *parent) AddClientDialog::AddClientDialog(const QString &clientName, QWidget *parent)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
Ui::AddClientDialog(), m_AddResult(kAddClientIgnore) { Ui::AddClientDialog(),
m_AddResult(kAddClientIgnore) {
setupUi(this); setupUi(this);
m_pLabelHead->setText("A client wants to connect. " m_pLabelHead->setText(
"A client wants to connect. "
"Please choose a location for " + "Please choose a location for " +
clientName + "."); clientName + ".");

View file

@ -85,13 +85,26 @@ const char *AppConfig::m_SynergySettingsName[] = {
static const char *logLevelNames[] = {"INFO", "DEBUG", "DEBUG1", "DEBUG2"}; static const char *logLevelNames[] = {"INFO", "DEBUG", "DEBUG1", "DEBUG2"};
AppConfig::AppConfig(bool globalLoad) AppConfig::AppConfig(bool globalLoad)
: m_ScreenName(), m_Port(24800), m_Interface(), m_LogLevel(0), : m_ScreenName(),
m_LogToFile(), m_WizardLastRun(0), m_ProcessMode(kDefaultProcessMode), m_Port(24800),
m_StartedBefore(), m_ElevateMode(kDefaultElevateMode), m_Interface(),
m_Edition(kUnregistered), m_CryptoEnabled(false), m_AutoHide(false), m_LogLevel(0),
m_LastExpiringWarningTime(0), m_ActivationHasRun(), m_LogToFile(),
m_MinimizeToTray(false), m_ServerGroupChecked(), m_UseExternalConfig(), m_WizardLastRun(0),
m_UseInternalConfig(), m_ClientGroupChecked(), m_LoadFromSystemScope() { m_ProcessMode(kDefaultProcessMode),
m_StartedBefore(),
m_ElevateMode(kDefaultElevateMode),
m_Edition(kUnregistered),
m_CryptoEnabled(false),
m_AutoHide(false),
m_LastExpiringWarningTime(0),
m_ActivationHasRun(),
m_MinimizeToTray(false),
m_ServerGroupChecked(),
m_UseExternalConfig(),
m_UseInternalConfig(),
m_ClientGroupChecked(),
m_LoadFromSystemScope() {
auto writer = ConfigWriter::make(); auto writer = ConfigWriter::make();
@ -105,13 +118,13 @@ AppConfig::AppConfig(bool globalLoad)
} }
// User settings exist and the load from system scope variable is true // User settings exist and the load from system scope variable is true
if (writer->hasSetting(settingName(Setting::kLoadSystemSettings), if (writer->hasSetting(
ConfigWriter::kUser)) { settingName(Setting::kLoadSystemSettings), ConfigWriter::kUser)) {
setLoadFromSystemScope(m_LoadFromSystemScope); setLoadFromSystemScope(m_LoadFromSystemScope);
} }
// If user setting don't exist but system ones do, load the system settings // If user setting don't exist but system ones do, load the system settings
else if (writer->hasSetting(settingName(Setting::kScreenName), else if (writer->hasSetting(
ConfigWriter::kSystem)) { settingName(Setting::kScreenName), ConfigWriter::kSystem)) {
setLoadFromSystemScope(true); setLoadFromSystemScope(true);
} }
} }
@ -187,8 +200,8 @@ void AppConfig::loadSettings() {
// TODO Investigate why kElevateModeEnum isn't loaded fully // TODO Investigate why kElevateModeEnum isn't loaded fully
QVariant elevateMode = loadSetting(Setting::kElevateModeEnum); QVariant elevateMode = loadSetting(Setting::kElevateModeEnum);
if (!elevateMode.isValid()) { if (!elevateMode.isValid()) {
elevateMode = elevateMode = loadSetting(
loadSetting(Setting::kElevateModeSetting, Setting::kElevateModeSetting,
QVariant(static_cast<int>(kDefaultElevateMode))); QVariant(static_cast<int>(kDefaultElevateMode)));
} }
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt()); m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
@ -208,8 +221,9 @@ void AppConfig::loadSettings() {
loadSetting(Setting::kGroupServerCheck, false).toBool(); loadSetting(Setting::kGroupServerCheck, false).toBool();
m_UseExternalConfig = m_UseExternalConfig =
loadSetting(Setting::kUseExternalConfig, false).toBool(); loadSetting(Setting::kUseExternalConfig, false).toBool();
m_ConfigFile = loadSetting(Setting::kConfigFile, m_ConfigFile =
QDir::homePath() + "/" + m_SynergyConfigName) loadSetting(
Setting::kConfigFile, QDir::homePath() + "/" + m_SynergyConfigName)
.toString(); .toString();
m_UseInternalConfig = m_UseInternalConfig =
loadSetting(Setting::kUseInternalConfig, false).toBool(); loadSetting(Setting::kUseInternalConfig, false).toBool();
@ -221,8 +235,8 @@ void AppConfig::loadSettings() {
m_InvertScrollDirection = m_InvertScrollDirection =
loadSetting(Setting::kInvertScrollDirection, false).toBool(); loadSetting(Setting::kInvertScrollDirection, false).toBool();
m_guid = loadCommonSetting(Setting::kGuid, QUuid::createUuid()).toString(); m_guid = loadCommonSetting(Setting::kGuid, QUuid::createUuid()).toString();
m_licenseRegistryUrl = m_licenseRegistryUrl = loadCommonSetting(
loadCommonSetting(Setting::kLicenseRegistryUrl, Setting::kLicenseRegistryUrl,
"https://api2.prod.symless.com/license/register") "https://api2.prod.symless.com/license/register")
.toString(); .toString();
m_licenseNextCheck = m_licenseNextCheck =
@ -394,8 +408,9 @@ bool AppConfig::isCryptoAvailable() const {
bool result{true}; bool result{true};
#ifdef SYNERGY_ENABLE_LICENSING #ifdef SYNERGY_ENABLE_LICENSING
result = (edition() == kPro || edition() == kProChina || result =
edition() == kBusiness || edition() == kUltimate); (edition() == kPro || edition() == kProChina || edition() == kBusiness ||
edition() == kUltimate);
#endif // SYNERGY_ENABLE_LICENSING #endif // SYNERGY_ENABLE_LICENSING
return result; return result;
@ -471,18 +486,18 @@ template <typename T> void AppConfig::setSetting(Setting name, T value) {
} }
template <typename T> void AppConfig::setCommonSetting(Setting name, T value) { template <typename T> void AppConfig::setCommonSetting(Setting name, T value) {
ConfigWriter::make()->setSetting(settingName(name), value, ConfigWriter::make()->setSetting(
ConfigWriter::kUser); settingName(name), value, ConfigWriter::kUser);
ConfigWriter::make()->setSetting(settingName(name), value, ConfigWriter::make()->setSetting(
ConfigWriter::kSystem); settingName(name), value, ConfigWriter::kSystem);
} }
QVariant AppConfig::loadSetting(Setting name, const QVariant &defaultValue) { QVariant AppConfig::loadSetting(Setting name, const QVariant &defaultValue) {
return ConfigWriter::make()->loadSetting(settingName(name), defaultValue); return ConfigWriter::make()->loadSetting(settingName(name), defaultValue);
} }
QVariant AppConfig::loadCommonSetting(Setting name, QVariant
const QVariant &defaultValue) const { AppConfig::loadCommonSetting(Setting name, const QVariant &defaultValue) const {
QVariant result(defaultValue); QVariant result(defaultValue);
QString setting(settingName(name)); QString setting(settingName(name));
auto &writer = *ConfigWriter::make(); auto &writer = *ConfigWriter::make();
@ -506,8 +521,8 @@ void AppConfig::loadScope(ConfigWriter::Scope scope) {
if (writer->getScope() != scope) { if (writer->getScope() != scope) {
setDefaultValues(); setDefaultValues();
writer->setScope(scope); writer->setScope(scope);
if (writer->hasSetting(settingName(Setting::kScreenName), if (writer->hasSetting(
writer->getScope())) { settingName(Setting::kScreenName), writer->getScope())) {
// If the user already has settings, then load them up now. // If the user already has settings, then load them up now.
writer->globalLoad(); writer->globalLoad();
} }
@ -608,7 +623,7 @@ void AppConfig::setTLSKeyLength(const QString &length) {
void AppConfig::generateCertificate(bool forceGeneration) const { void AppConfig::generateCertificate(bool forceGeneration) const {
SslCertificate sslCertificate; SslCertificate sslCertificate;
sslCertificate.generateCertificate(getTLSCertPath(), getTLSKeyLength(), sslCertificate.generateCertificate(
forceGeneration); getTLSCertPath(), getTLSKeyLength(), forceGeneration);
emit sslToggled(); emit sslToggled();
} }

View file

@ -303,14 +303,14 @@ private:
/// @brief Loads a setting /// @brief Loads a setting
/// @param [in] name The setting to be loaded /// @param [in] name The setting to be loaded
/// @param [in] defaultValue The default value of the setting /// @param [in] defaultValue The default value of the setting
QVariant loadSetting(AppConfig::Setting name, QVariant loadSetting(
const QVariant &defaultValue = QVariant()); AppConfig::Setting name, const QVariant &defaultValue = QVariant());
/// @brief Loads a common setting /// @brief Loads a common setting
/// @param [in] name The setting to be loaded /// @param [in] name The setting to be loaded
/// @param [in] defaultValue The default value of the setting /// @param [in] defaultValue The default value of the setting
QVariant loadCommonSetting(AppConfig::Setting name, QVariant loadCommonSetting(
const QVariant &defaultValue = QVariant()) const; AppConfig::Setting name, const QVariant &defaultValue = QVariant()) const;
/// @brief As the settings will be accessible by multiple objects this lock /// @brief As the settings will be accessible by multiple objects this lock
/// will ensure that /// will ensure that

View file

@ -8,7 +8,8 @@ extern "C" {
#if OSX_DEPLOYMENT_TARGET >= 1014 #if OSX_DEPLOYMENT_TARGET >= 1014
#import <UserNotifications/UNUserNotificationCenter.h> #import <UserNotifications/UNUserNotificationCenter.h>
@interface AppDelegate @interface AppDelegate
: NSObject <NSApplicationDelegate, NSUserNotificationCenterDelegate, : NSObject <
NSApplicationDelegate, NSUserNotificationCenterDelegate,
UNUserNotificationCenterDelegate> UNUserNotificationCenterDelegate>
#else #else
@interface AppDelegate @interface AppDelegate

View file

@ -25,5 +25,5 @@ const char *BaseConfig::m_FixNames[] = {
"halfDuplexCapsLock", "halfDuplexNumLock", "halfDuplexScrollLock", "halfDuplexCapsLock", "halfDuplexNumLock", "halfDuplexScrollLock",
"xtestIsXineramaUnaware"}; "xtestIsXineramaUnaware"};
const char *BaseConfig::m_SwitchCornerNames[] = {"top-left", "top-right", const char *BaseConfig::m_SwitchCornerNames[] = {
"bottom-left", "bottom-right"}; "top-left", "top-right", "bottom-left", "bottom-right"};

View file

@ -51,7 +51,8 @@ protected:
protected: protected:
template <typename T1, typename T2> template <typename T1, typename T2>
void readSettings(QSettings &settings, T1 &array, const QString &arrayName, void readSettings(
QSettings &settings, T1 &array, const QString &arrayName,
const T2 &deflt) { const T2 &deflt) {
int entries = settings.beginReadArray(arrayName + "Array"); int entries = settings.beginReadArray(arrayName + "Array");
array.clear(); array.clear();
@ -64,8 +65,9 @@ protected:
} }
template <typename T1, typename T2> template <typename T1, typename T2>
void readSettings(QSettings &settings, T1 &array, const QString &arrayName, void readSettings(
const T2 &deflt, int entries) { QSettings &settings, T1 &array, const QString &arrayName, const T2 &deflt,
int entries) {
Q_ASSERT(array.size() >= entries); Q_ASSERT(array.size() >= entries);
settings.beginReadArray(arrayName + "Array"); settings.beginReadArray(arrayName + "Array");
for (int i = 0; i < entries; i++) { for (int i = 0; i < entries; i++) {
@ -77,8 +79,8 @@ protected:
} }
template <typename T> template <typename T>
void writeSettings(QSettings &settings, const T &array, void writeSettings(
const QString &arrayName) const { QSettings &settings, const T &array, const QString &arrayName) const {
settings.beginWriteArray(arrayName + "Array"); settings.beginWriteArray(arrayName + "Array");
for (int i = 0; i < array.size(); i++) { for (int i = 0; i < array.size(); i++) {
settings.setArrayIndex(i); settings.setArrayIndex(i);

View file

@ -2,7 +2,8 @@
#include "ui_CancelActivationDialog.h" #include "ui_CancelActivationDialog.h"
CancelActivationDialog::CancelActivationDialog(QWidget *parent) CancelActivationDialog::CancelActivationDialog(QWidget *parent)
: QDialog(parent), ui(new Ui::CancelActivationDialog) { : QDialog(parent),
ui(new Ui::CancelActivationDialog) {
ui->setupUi(this); ui->setupUi(this);
} }

View file

@ -20,9 +20,11 @@
#include <QProcess> #include <QProcess>
#include <stdexcept> #include <stdexcept>
CommandProcess::CommandProcess(QString cmd, QStringList arguments, CommandProcess::CommandProcess(
QString input) QString cmd, QStringList arguments, QString input)
: m_Command(cmd), m_Arguments(arguments), m_Input(input) {} : m_Command(cmd),
m_Arguments(arguments),
m_Input(input) {}
QString CommandProcess::run() { QString CommandProcess::run() {
QProcess process; QProcess process;

View file

@ -48,9 +48,10 @@ QString getSystemSettingPath() {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
void loadOldSystemSettings(QSettings &settings) { void loadOldSystemSettings(QSettings &settings) {
if (!QFile(settings.fileName()).exists()) { if (!QFile(settings.fileName()).exists()) {
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QSettings::setPath(
"SystemConfig.ini"); QSettings::IniFormat, QSettings::SystemScope, "SystemConfig.ini");
QSettings oldSystemSettings(QSettings::IniFormat, QSettings::SystemScope, QSettings oldSystemSettings(
QSettings::IniFormat, QSettings::SystemScope,
QCoreApplication::organizationName(), QCoreApplication::organizationName(),
QCoreApplication::applicationName()); QCoreApplication::applicationName());
@ -61,8 +62,8 @@ void loadOldSystemSettings(QSettings &settings) {
} }
// Restore system settings path // Restore system settings path
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QSettings::setPath(
getSystemSettingPath()); QSettings::IniFormat, QSettings::SystemScope, getSystemSettingPath());
} }
} }
#endif #endif
@ -83,13 +84,14 @@ ConfigWriter *ConfigWriter::make() {
} }
ConfigWriter::ConfigWriter() { ConfigWriter::ConfigWriter() {
QSettings::setPath(QSettings::Format::IniFormat, QSettings::setPath(
QSettings::Scope::SystemScope, getSystemSettingPath()); QSettings::Format::IniFormat, QSettings::Scope::SystemScope,
getSystemSettingPath());
// Config will default to User settings if they exist, // Config will default to User settings if they exist,
// otherwise it will load System setting and save them to User settings // otherwise it will load System setting and save them to User settings
m_pSettingsSystem = m_pSettingsSystem = new QSettings(
new QSettings(QSettings::Format::IniFormat, QSettings::Scope::SystemScope, QSettings::Format::IniFormat, QSettings::Scope::SystemScope,
QCoreApplication::organizationName(), QCoreApplication::organizationName(),
QCoreApplication::applicationName()); QCoreApplication::applicationName());
@ -134,8 +136,8 @@ bool ConfigWriter::isWritable() const {
return m_pSettingsCurrent->isWritable(); return m_pSettingsCurrent->isWritable();
} }
QVariant ConfigWriter::loadSetting(const QString &name, QVariant ConfigWriter::loadSetting(
const QVariant &defaultValue, Scope scope) { const QString &name, const QVariant &defaultValue, Scope scope) {
switch (scope) { switch (scope) {
case kUser: case kUser:
return m_pSettingsUser->value(name, defaultValue); return m_pSettingsUser->value(name, defaultValue);

View file

@ -67,8 +67,8 @@ public:
/// @param [in] defaultValue The default value of the setting /// @param [in] defaultValue The default value of the setting
/// @param [in] scope The scope to get the value from, default is current /// @param [in] scope The scope to get the value from, default is current
/// scope /// scope
QVariant loadSetting(const QString &name, QVariant loadSetting(
const QVariant &defaultValue = QVariant(), const QString &name, const QVariant &defaultValue = QVariant(),
Scope scope = kCurrent); Scope scope = kCurrent);
/// @brief Changes the setting save and load location between System and User /// @brief Changes the setting save and load location between System and User

View file

@ -18,8 +18,11 @@
#include "DataDownloader.h" #include "DataDownloader.h"
DataDownloader::DataDownloader(QObject *parent) DataDownloader::DataDownloader(QObject *parent)
: QObject(parent), m_pReply(nullptr), m_IsFinished(false) { : QObject(parent),
connect(&m_NetworkManager, SIGNAL(finished(QNetworkReply *)), m_pReply(nullptr),
m_IsFinished(false) {
connect(
&m_NetworkManager, SIGNAL(finished(QNetworkReply *)),
SLOT(complete(QNetworkReply *))); SLOT(complete(QNetworkReply *)));
} }

View file

@ -2,7 +2,8 @@
#include "ui_FailedLoginDialog.h" #include "ui_FailedLoginDialog.h"
FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message) FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message)
: QDialog(parent), ui(new Ui::FailedLoginDialog) { : QDialog(parent),
ui(new Ui::FailedLoginDialog) {
ui->setupUi(this); ui->setupUi(this);
ui->messageLabel->setText(ui->messageLabel->text().arg(message)); ui->messageLabel->setText(ui->messageLabel->text().arg(message));
} }

View file

@ -23,7 +23,8 @@
HotkeyDialog::HotkeyDialog(QWidget *parent, Hotkey &hotkey) HotkeyDialog::HotkeyDialog(QWidget *parent, Hotkey &hotkey)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
Ui::HotkeyDialogBase(), m_Hotkey(hotkey) { Ui::HotkeyDialogBase(),
m_Hotkey(hotkey) {
setupUi(this); setupUi(this);
m_pKeySequenceWidgetHotkey->setText(m_Hotkey.text()); m_pKeySequenceWidgetHotkey->setText(m_Hotkey.text());

View file

@ -26,7 +26,8 @@
static const struct { static const struct {
int key; int key;
const char *name; const char *name;
} keyname[] = {{Qt::Key_Space, "Space"}, } keyname[] = {
{Qt::Key_Space, "Space"},
{Qt::Key_Escape, "Escape"}, {Qt::Key_Escape, "Escape"},
{Qt::Key_Tab, "Tab"}, {Qt::Key_Tab, "Tab"},
{Qt::Key_Backtab, "LeftTab"}, {Qt::Key_Backtab, "LeftTab"},
@ -207,8 +208,8 @@ QString KeySequence::keyToString(int key) {
// representable in ucs2? // representable in ucs2?
if (key < 0x10000) if (key < 0x10000)
return QString("\\u%1").arg(QChar(key).toLower().unicode(), 4, 16, return QString("\\u%1").arg(
QChar('0')); QChar(key).toLower().unicode(), 4, 16, QChar('0'));
// give up, synergy probably won't handle this // give up, synergy probably won't handle this
return ""; return "";

View file

@ -22,9 +22,14 @@
#include <iostream> #include <iostream>
KeySequenceWidget::KeySequenceWidget(QWidget *parent, const KeySequence &seq) KeySequenceWidget::KeySequenceWidget(QWidget *parent, const KeySequence &seq)
: QPushButton(parent), m_KeySequence(seq), m_BackupSequence(seq), : QPushButton(parent),
m_Status(Stopped), m_MousePrefix("mousebutton("), m_MousePostfix(")"), m_KeySequence(seq),
m_KeyPrefix("keystroke("), m_KeyPostfix(")") { m_BackupSequence(seq),
m_Status(Stopped),
m_MousePrefix("mousebutton("),
m_MousePostfix(")"),
m_KeyPrefix("keystroke("),
m_KeyPostfix(")") {
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);
updateOutput(); updateOutput();
} }

View file

@ -66,7 +66,8 @@ void checkSerialKey(const SerialKey &serialKey, bool acceptExpired) {
} // namespace } // namespace
LicenseManager::LicenseManager(AppConfig *appConfig) LicenseManager::LicenseManager(AppConfig *appConfig)
: m_AppConfig(appConfig), m_serialKey(appConfig->edition()), : m_AppConfig(appConfig),
m_serialKey(appConfig->edition()),
m_registry(*appConfig) {} m_registry(*appConfig) {}
void LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired) { void LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired) {
@ -88,15 +89,15 @@ void LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired) {
} }
} }
void LicenseManager::notifyUpdate(QString fromVersion, void LicenseManager::notifyUpdate(
QString toVersion) const { QString fromVersion, QString toVersion) const {
if ((fromVersion == "Unknown") && (m_serialKey == SerialKey(kUnregistered))) { if ((fromVersion == "Unknown") && (m_serialKey == SerialKey(kUnregistered))) {
return; return;
} }
ActivationNotifier *notifier = new ActivationNotifier(); ActivationNotifier *notifier = new ActivationNotifier();
notifier->setUpdateInfo(fromVersion, toVersion, notifier->setUpdateInfo(
QString::fromStdString(m_serialKey.toString())); fromVersion, toVersion, QString::fromStdString(m_serialKey.toString()));
QThread *thread = new QThread(); QThread *thread = new QThread();
connect(notifier, SIGNAL(finished()), thread, SLOT(quit())); connect(notifier, SIGNAL(finished()), thread, SLOT(quit()));
@ -227,8 +228,8 @@ QString LicenseManager::getTemporaryNotice() const {
void LicenseManager::validateSerialKey() const { void LicenseManager::validateSerialKey() const {
if (m_serialKey.isValid()) { if (m_serialKey.isValid()) {
if (m_serialKey.isTemporary()) { if (m_serialKey.isTemporary()) {
QTimer::singleShot(m_serialKey.getSpanLeft(), this, QTimer::singleShot(
SLOT(validateSerialKey())); m_serialKey.getSpanLeft(), this, SLOT(validateSerialKey()));
} }
} else { } else {
emit InvalidLicense(); emit InvalidLicense();

View file

@ -37,7 +37,8 @@ void LicenseRegistry::registerLicense() {
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
m_manager.post(request, getRequestData()); m_manager.post(request, getRequestData());
connect(&m_manager, SIGNAL(finished(QNetworkReply *)), this, connect(
&m_manager, SIGNAL(finished(QNetworkReply *)), this,
SLOT(handleResponse(QNetworkReply *))); SLOT(handleResponse(QNetworkReply *)));
} }
} }

View file

@ -83,15 +83,24 @@ MainWindow::MainWindow(AppConfig &appConfig)
#endif #endif
: :
#ifdef SYNERGY_ENABLE_LICENSING #ifdef SYNERGY_ENABLE_LICENSING
m_LicenseManager(&licenseManager), m_ActivationDialogRunning(false), m_LicenseManager(&licenseManager),
m_ActivationDialogRunning(false),
#endif #endif
m_AppConfig(&appConfig), m_pSynergy(NULL), m_AppConfig(&appConfig),
m_pSynergy(NULL),
m_SynergyState(synergyDisconnected), m_SynergyState(synergyDisconnected),
m_ServerConfig(5, 3, m_AppConfig, this), m_AlreadyHidden(false), m_ServerConfig(5, 3, m_AppConfig, this),
m_pMenuBar(NULL), m_pMenuFile(NULL), m_pMenuEdit(NULL), m_AlreadyHidden(false),
m_pMenuWindow(NULL), m_pMenuHelp(NULL), m_pCancelButton(NULL), m_pMenuBar(NULL),
m_ExpectedRunningState(kStopped), m_SecureSocket(false), m_pMenuFile(NULL),
m_serverConnection(*this), m_clientConnection(*this) { m_pMenuEdit(NULL),
m_pMenuWindow(NULL),
m_pMenuHelp(NULL),
m_pCancelButton(NULL),
m_ExpectedRunningState(kStopped),
m_SecureSocket(false),
m_serverConnection(*this),
m_clientConnection(*this) {
setupUi(this); setupUi(this);
@ -108,21 +117,25 @@ MainWindow::MainWindow(AppConfig &appConfig)
m_VersionChecker.setApp(appPath(appConfig.synergycName())); m_VersionChecker.setApp(appPath(appConfig.synergycName()));
updateScreenName(); updateScreenName();
connect(m_AppConfig, SIGNAL(screenNameChanged()), this, connect(
SLOT(updateScreenName())); m_AppConfig, SIGNAL(screenNameChanged()), this, SLOT(updateScreenName()));
m_pLabelIpAddresses->setText( m_pLabelIpAddresses->setText(
tr("This computer's IP addresses: %1").arg(getIPAddresses())); tr("This computer's IP addresses: %1").arg(getIPAddresses()));
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
// ipc must always be enabled, so that we can disable command when switching // ipc must always be enabled, so that we can disable command when switching
// to desktop mode. // to desktop mode.
connect(&m_IpcClient, SIGNAL(readLogLine(const QString &)), this, connect(
&m_IpcClient, SIGNAL(readLogLine(const QString &)), this,
SLOT(appendLogRaw(const QString &))); SLOT(appendLogRaw(const QString &)));
connect(&m_IpcClient, SIGNAL(errorMessage(const QString &)), this, connect(
&m_IpcClient, SIGNAL(errorMessage(const QString &)), this,
SLOT(appendLogError(const QString &))); SLOT(appendLogError(const QString &)));
connect(&m_IpcClient, SIGNAL(infoMessage(const QString &)), this, connect(
&m_IpcClient, SIGNAL(infoMessage(const QString &)), this,
SLOT(appendLogInfo(const QString &))); SLOT(appendLogInfo(const QString &)));
connect(&m_IpcClient, SIGNAL(readLogLine(const QString &)), this, connect(
&m_IpcClient, SIGNAL(readLogLine(const QString &)), this,
SLOT(handleIdleService(const QString &))); SLOT(handleIdleService(const QString &)));
m_IpcClient.connectToHost(); m_IpcClient.connectToHost();
#endif #endif
@ -141,21 +154,26 @@ MainWindow::MainWindow(AppConfig &appConfig)
// hide padlock icon // hide padlock icon
secureSocket(false); secureSocket(false);
connect(this, SIGNAL(windowShown()), this, SLOT(on_windowShown()), connect(
this, SIGNAL(windowShown()), this, SLOT(on_windowShown()),
Qt::QueuedConnection); Qt::QueuedConnection);
#ifdef SYNERGY_ENABLE_LICENSING #ifdef SYNERGY_ENABLE_LICENSING
connect(m_LicenseManager, SIGNAL(editionChanged(Edition)), this, connect(
m_LicenseManager, SIGNAL(editionChanged(Edition)), this,
SLOT(setEdition(Edition)), Qt::QueuedConnection); SLOT(setEdition(Edition)), Qt::QueuedConnection);
connect(m_LicenseManager, SIGNAL(showLicenseNotice(QString)), this, connect(
m_LicenseManager, SIGNAL(showLicenseNotice(QString)), this,
SLOT(showLicenseNotice(QString)), Qt::QueuedConnection); SLOT(showLicenseNotice(QString)), Qt::QueuedConnection);
connect(m_LicenseManager, SIGNAL(InvalidLicense()), this, connect(
SLOT(InvalidLicense()), Qt::QueuedConnection); m_LicenseManager, SIGNAL(InvalidLicense()), this, SLOT(InvalidLicense()),
Qt::QueuedConnection);
#endif #endif
connect(m_AppConfig, SIGNAL(sslToggled()), this, connect(
SLOT(updateLocalFingerprint()), Qt::QueuedConnection); m_AppConfig, SIGNAL(sslToggled()), this, SLOT(updateLocalFingerprint()),
Qt::QueuedConnection);
updateWindowTitle(); updateWindowTitle();
@ -260,11 +278,12 @@ void MainWindow::loadSettings() {
void MainWindow::initConnections() { void MainWindow::initConnections() {
connect(m_pActionMinimize, SIGNAL(triggered()), this, SLOT(hide())); connect(m_pActionMinimize, SIGNAL(triggered()), this, SLOT(hide()));
connect(m_pActionRestore, SIGNAL(triggered()), this, SLOT(showNormal())); connect(m_pActionRestore, SIGNAL(triggered()), this, SLOT(showNormal()));
connect(m_pActionStartSynergy, SIGNAL(triggered()), this, connect(
SLOT(actionStart())); m_pActionStartSynergy, SIGNAL(triggered()), this, SLOT(actionStart()));
connect(m_pActionStopSynergy, SIGNAL(triggered()), this, SLOT(stopSynergy())); connect(m_pActionStopSynergy, SIGNAL(triggered()), this, SLOT(stopSynergy()));
connect(m_pActionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(m_pActionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(&m_VersionChecker, SIGNAL(updateFound(const QString &)), this, connect(
&m_VersionChecker, SIGNAL(updateFound(const QString &)), this,
SLOT(updateFound(const QString &))); SLOT(updateFound(const QString &)));
} }
@ -421,7 +440,8 @@ void MainWindow::checkConnected(const QString &line) {
} }
} else if (line.contains("started server")) { } else if (line.contains("started server")) {
setSynergyState(synergyListening); setSynergyState(synergyListening);
} else if (line.contains("disconnected from server") || } else if (
line.contains("disconnected from server") ||
line.contains("process exited")) { line.contains("process exited")) {
setSynergyState(synergyDisconnected); setSynergyState(synergyDisconnected);
} else if (line.contains("connecting to")) { } else if (line.contains("connecting to")) {
@ -497,8 +517,8 @@ void MainWindow::checkOSXNotification(const QString &line) {
if (line.contains(OSXNotificationSubstring) && line.contains('|')) { if (line.contains(OSXNotificationSubstring) && line.contains('|')) {
int delimterPosition = line.indexOf('|'); int delimterPosition = line.indexOf('|');
int notificationStartPosition = line.indexOf(OSXNotificationSubstring); int notificationStartPosition = line.indexOf(OSXNotificationSubstring);
QString title = QString title = line.mid(
line.mid(notificationStartPosition + OSXNotificationSubstring.length(), notificationStartPosition + OSXNotificationSubstring.length(),
delimterPosition - notificationStartPosition - delimterPosition - notificationStartPosition -
OSXNotificationSubstring.length()); OSXNotificationSubstring.length());
QString body = QString body =
@ -616,7 +636,8 @@ void MainWindow::startSynergy() {
if (!m_pLogOutput->toPlainText().isEmpty()) if (!m_pLogOutput->toPlainText().isEmpty())
appendLogRaw(""); appendLogRaw("");
appendLogInfo("starting " + appendLogInfo(
"starting " +
QString(synergyType() == synergyServer ? "server" : "client")); QString(synergyType() == synergyServer ? "server" : "client"));
if ((synergyType() == synergyClient && !clientArgs(args, app)) || if ((synergyType() == synergyClient && !clientArgs(args, app)) ||
@ -626,11 +647,14 @@ void MainWindow::startSynergy() {
} }
if (desktopMode) { if (desktopMode) {
connect(synergyProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this, connect(
synergyProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this,
SLOT(synergyFinished(int, QProcess::ExitStatus))); SLOT(synergyFinished(int, QProcess::ExitStatus)));
connect(synergyProcess(), SIGNAL(readyReadStandardOutput()), this, connect(
synergyProcess(), SIGNAL(readyReadStandardOutput()), this,
SLOT(logOutput())); SLOT(logOutput()));
connect(synergyProcess(), SIGNAL(readyReadStandardError()), this, connect(
synergyProcess(), SIGNAL(readyReadStandardError()), this,
SLOT(logError())); SLOT(logError()));
} }
@ -712,7 +736,8 @@ bool MainWindow::clientArgs(QStringList &args, QString &app) {
if (m_pLineEditHostname->text().isEmpty() && if (m_pLineEditHostname->text().isEmpty() &&
!appConfig().getClientHostMode()) { !appConfig().getClientHostMode()) {
show(); show();
QMessageBox::warning(this, tr("Hostname is empty"), QMessageBox::warning(
this, tr("Hostname is empty"),
tr("Please fill in a hostname for the synergy " tr("Please fill in a hostname for the synergy "
"client to connect to.")); "client to connect to."));
return false; return false;
@ -769,8 +794,8 @@ QString MainWindow::configFilename() {
} }
if (configFullPath.isEmpty()) { if (configFullPath.isEmpty()) {
QMessageBox::critical(this, tr("Cannot write configuration file"), QMessageBox::critical(
errors.join('\n')); this, tr("Cannot write configuration file"), errors.join('\n'));
} }
} }
@ -807,7 +832,8 @@ bool MainWindow::serverArgs(QStringList &args, QString &app) {
if (appConfig().getServerClientMode() && if (appConfig().getServerClientMode() &&
m_pLineEditClienIp->text().isEmpty()) { m_pLineEditClienIp->text().isEmpty()) {
QMessageBox::warning(this, tr("Client IP address or name is empty"), QMessageBox::warning(
this, tr("Client IP address or name is empty"),
tr("Please fill in a client IP address or name.")); tr("Please fill in a client IP address or name."));
return false; return false;
} }
@ -911,16 +937,20 @@ void MainWindow::setSynergyState(qSynergyState state) {
if ((state == synergyConnected) || (state == synergyConnecting) || if ((state == synergyConnected) || (state == synergyConnecting) ||
(state == synergyListening) || (state == synergyPendingRetry)) { (state == synergyListening) || (state == synergyPendingRetry)) {
disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, disconnect(
m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy,
SLOT(trigger())); SLOT(trigger()));
connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy, connect(
m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy,
SLOT(trigger())); SLOT(trigger()));
m_pButtonToggleStart->setText(tr("&Stop")); m_pButtonToggleStart->setText(tr("&Stop"));
m_pButtonApply->setEnabled(true); m_pButtonApply->setEnabled(true);
} else if (state == synergyDisconnected) { } else if (state == synergyDisconnected) {
disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy, disconnect(
m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy,
SLOT(trigger())); SLOT(trigger()));
connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, connect(
m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy,
SLOT(trigger())); SLOT(trigger()));
m_pButtonToggleStart->setText(tr("&Start")); m_pButtonToggleStart->setText(tr("&Start"));
m_pButtonApply->setEnabled(false); m_pButtonApply->setEnabled(false);
@ -1060,8 +1090,8 @@ bool MainWindow::on_m_pActionSave_triggered() {
QFileDialog::getSaveFileName(this, tr("Save configuration as...")); QFileDialog::getSaveFileName(this, tr("Save configuration as..."));
if (!fileName.isEmpty() && !serverConfig().save(fileName)) { if (!fileName.isEmpty() && !serverConfig().save(fileName)) {
QMessageBox::warning(this, tr("Save failed"), QMessageBox::warning(
tr("Could not save configuration to file.")); this, tr("Save failed"), tr("Could not save configuration to file."));
return true; return true;
} }
@ -1218,8 +1248,8 @@ void MainWindow::on_m_pLabelComputerName_linkActivated(const QString &) {
} }
void MainWindow::on_m_pLabelFingerprint_linkActivated(const QString &) { void MainWindow::on_m_pLabelFingerprint_linkActivated(const QString &) {
QMessageBox::information(this, "SSL/TLS fingerprint", QMessageBox::information(
Fingerprint::local().readFirst()); this, "SSL/TLS fingerprint", Fingerprint::local().readFirst());
} }
void MainWindow::windowStateChanged() { void MainWindow::windowStateChanged() {

View file

@ -169,8 +169,8 @@ protected:
bool clientArgs(QStringList &args, QString &app); bool clientArgs(QStringList &args, QString &app);
bool serverArgs(QStringList &args, QString &app); bool serverArgs(QStringList &args, QString &app);
void setStatus(const QString &status); void setStatus(const QString &status);
void sendIpcMessage(qIpcMessageType type, const char *buffer, void
bool showErrors); sendIpcMessage(qIpcMessageType type, const char *buffer, bool showErrors);
void updateFromLogLine(const QString &line); void updateFromLogLine(const QString &line);
QString getIPAddresses(); QString getIPAddresses();
void stopService(); void stopService();

View file

@ -24,7 +24,8 @@
#include <QTimer> #include <QTimer>
QIpcClient::QIpcClient(const StreamProvider &streamProvider) QIpcClient::QIpcClient(const StreamProvider &streamProvider)
: m_ReaderStarted(false), m_Enabled(false), : m_ReaderStarted(false),
m_Enabled(false),
m_StreamProvider(streamProvider) { m_StreamProvider(streamProvider) {
m_Socket = new QTcpSocket(this); m_Socket = new QTcpSocket(this);
@ -36,11 +37,13 @@ QIpcClient::QIpcClient(const StreamProvider &streamProvider)
} }
connect(m_Socket, SIGNAL(connected()), this, SLOT(connected())); connect(m_Socket, SIGNAL(connected()), this, SLOT(connected()));
connect(m_Socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, connect(
m_Socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this,
SLOT(error(QAbstractSocket::SocketError))); SLOT(error(QAbstractSocket::SocketError)));
m_Reader = new IpcReader(m_Socket); m_Reader = new IpcReader(m_Socket);
connect(m_Reader, SIGNAL(readLogLine(const QString &)), this, connect(
m_Reader, SIGNAL(readLogLine(const QString &)), this,
SLOT(handleReadLogLine(const QString &))); SLOT(handleReadLogLine(const QString &)));
} }
@ -106,8 +109,8 @@ void QIpcClient::sendHello() {
stream->writeRawData(typeBuf, 1); stream->writeRawData(typeBuf, 1);
} }
void QIpcClient::sendCommand(const QString &command, void QIpcClient::sendCommand(
ElevateMode const elevate) { const QString &command, ElevateMode const elevate) {
auto stream = m_StreamProvider(); auto stream = m_StreamProvider();
stream->writeRawData(kIpcMsgCommand, 4); stream->writeRawData(kIpcMsgCommand, 4);

View file

@ -64,10 +64,11 @@ void Screen::loadSettings(QSettings &settings) {
setSwitchCornerSize(settings.value("switchCornerSize").toInt()); setSwitchCornerSize(settings.value("switchCornerSize").toInt());
readSettings(settings, aliases(), "alias", QString("")); readSettings(settings, aliases(), "alias", QString(""));
readSettings(settings, modifiers(), "modifier", static_cast<int>(DefaultMod), readSettings(
settings, modifiers(), "modifier", static_cast<int>(DefaultMod),
NumModifiers); NumModifiers);
readSettings(settings, switchCorners(), "switchCorner", false, readSettings(
NumSwitchCorners); settings, switchCorners(), "switchCorner", false, NumSwitchCorners);
readSettings(settings, fixes(), "fix", false, NumFixes); readSettings(settings, fixes(), "fix", false, NumFixes);
} }

View file

@ -25,10 +25,11 @@
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
ScreenSettingsDialog::ScreenSettingsDialog(QWidget *parent, Screen *pScreen, ScreenSettingsDialog::ScreenSettingsDialog(
const ScreenList *pScreens) QWidget *parent, Screen *pScreen, const ScreenList *pScreens)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
Ui::ScreenSettingsDialogBase(), m_pScreen(pScreen) { Ui::ScreenSettingsDialogBase(),
m_pScreen(pScreen) {
setupUi(this); setupUi(this);
m_pLineEditName->setText(m_pScreen->name()); m_pLineEditName->setText(m_pScreen->name());
@ -97,14 +98,14 @@ void ScreenSettingsDialog::accept() {
m_pScreen->setModifier(Screen::Meta, m_pComboBoxMeta->currentIndex()); m_pScreen->setModifier(Screen::Meta, m_pComboBoxMeta->currentIndex());
m_pScreen->setModifier(Screen::Super, m_pComboBoxSuper->currentIndex()); m_pScreen->setModifier(Screen::Super, m_pComboBoxSuper->currentIndex());
m_pScreen->setSwitchCorner(Screen::TopLeft, m_pScreen->setSwitchCorner(
m_pCheckBoxCornerTopLeft->isChecked()); Screen::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
m_pScreen->setSwitchCorner(Screen::TopRight, m_pScreen->setSwitchCorner(
m_pCheckBoxCornerTopRight->isChecked()); Screen::TopRight, m_pCheckBoxCornerTopRight->isChecked());
m_pScreen->setSwitchCorner(Screen::BottomLeft, m_pScreen->setSwitchCorner(
m_pCheckBoxCornerBottomLeft->isChecked()); Screen::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
m_pScreen->setSwitchCorner(Screen::BottomRight, m_pScreen->setSwitchCorner(
m_pCheckBoxCornerBottomRight->isChecked()); Screen::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
m_pScreen->setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value()); m_pScreen->setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
m_pScreen->setFix(Screen::CapsLock, m_pCheckBoxCapsLock->isChecked()); m_pScreen->setFix(Screen::CapsLock, m_pCheckBoxCapsLock->isChecked());
@ -126,8 +127,8 @@ void ScreenSettingsDialog::on_m_pButtonAddAlias_clicked() {
void ScreenSettingsDialog::on_m_pLineEditAlias_textChanged( void ScreenSettingsDialog::on_m_pLineEditAlias_textChanged(
const QString &text) { const QString &text) {
m_pButtonAddAlias->setEnabled(!text.isEmpty() && m_pButtonAddAlias->setEnabled(
m_pLabelAliasError->text().isEmpty()); !text.isEmpty() && m_pLabelAliasError->text().isEmpty());
} }
void ScreenSettingsDialog::on_m_pButtonRemoveAlias_clicked() { void ScreenSettingsDialog::on_m_pButtonRemoveAlias_clicked() {

View file

@ -36,7 +36,8 @@ class ScreenSettingsDialog : public QDialog,
Q_OBJECT Q_OBJECT
public: public:
ScreenSettingsDialog(QWidget *parent, Screen *pScreen = nullptr, ScreenSettingsDialog(
QWidget *parent, Screen *pScreen = nullptr,
const ScreenList *pScreens = nullptr); const ScreenList *pScreens = nullptr);
public slots: public slots:

View file

@ -24,12 +24,15 @@
const QString ScreenSetupModel::m_MimeType = "application/x-qsynergy-screen"; const QString ScreenSetupModel::m_MimeType = "application/x-qsynergy-screen";
ScreenSetupModel::ScreenSetupModel(ScreenList &screens, int numColumns, ScreenSetupModel::ScreenSetupModel(
int numRows) ScreenList &screens, int numColumns, int numRows)
: QAbstractTableModel(NULL), m_Screens(screens), m_NumColumns(numColumns), : QAbstractTableModel(NULL),
m_Screens(screens),
m_NumColumns(numColumns),
m_NumRows(numRows) { m_NumRows(numRows) {
if (m_NumColumns * m_NumRows > screens.size()) if (m_NumColumns * m_NumRows > screens.size())
qFatal("Not enough elements (%lld) in screens QList for %d columns and %d " qFatal(
"Not enough elements (%lld) in screens QList for %d columns and %d "
"rows", "rows",
screens.size(), m_NumColumns, m_NumRows); screens.size(), m_NumColumns, m_NumRows);
} }
@ -96,8 +99,8 @@ QMimeData *ScreenSetupModel::mimeData(const QModelIndexList &indexes) const {
return pMimeData; return pMimeData;
} }
bool ScreenSetupModel::dropMimeData(const QMimeData *data, bool ScreenSetupModel::dropMimeData(
Qt::DropAction action, int row, int column, const QMimeData *data, Qt::DropAction action, int row, int column,
const QModelIndex &parent) { const QModelIndex &parent) {
if (action == Qt::IgnoreAction) if (action == Qt::IgnoreAction)
return true; return true;
@ -145,8 +148,8 @@ void ScreenSetupModel::addScreen(const Screen &newScreen) {
} }
bool ScreenSetupModel::isFull() const { bool ScreenSetupModel::isFull() const {
auto emptyScreen = auto emptyScreen = std::find_if(
std::find_if(m_Screens.cbegin(), m_Screens.cend(), m_Screens.cbegin(), m_Screens.cend(),
[](const Screen &item) { return item.isNull(); }); [](const Screen &item) { return item.isNull(); });
return (emptyScreen == m_Screens.cend()); return (emptyScreen == m_Screens.cend());

View file

@ -56,8 +56,9 @@ signals:
void screensChanged(); void screensChanged();
protected: protected:
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, bool dropMimeData(
int column, const QModelIndex &parent); const QMimeData *data, Qt::DropAction action, int row, int column,
const QModelIndex &parent);
const Screen &screen(const QModelIndex &index) const { const Screen &screen(const QModelIndex &index) const {
return screen(index.column(), index.row()); return screen(index.column(), index.row());
} }

View file

@ -65,8 +65,8 @@ void ScreenSetupView::mouseDoubleClickEvent(QMouseEvent *event) {
int row = rowAt(event->pos().y()); int row = rowAt(event->pos().y());
if (!model()->screen(col, row).isNull()) { if (!model()->screen(col, row).isNull()) {
ScreenSettingsDialog dlg(this, &model()->screen(col, row), ScreenSettingsDialog dlg(
&model()->m_Screens); this, &model()->screen(col, row), &model()->m_Screens);
dlg.exec(); dlg.exec();
emit model() -> screensChanged(); emit model() -> screensChanged();
} }

View file

@ -40,13 +40,17 @@ static const struct {
const int serverDefaultIndex = 7; const int serverDefaultIndex = 7;
ServerConfig::ServerConfig(int numColumns, int numRows, AppConfig *appConfig, ServerConfig::ServerConfig(
MainWindow *mainWindow) int numColumns, int numRows, AppConfig *appConfig, MainWindow *mainWindow)
: :
m_Screens(numColumns), m_NumColumns(numColumns), m_NumRows(numRows), m_Screens(numColumns),
m_pAppConfig(appConfig), m_EnableDragAndDrop(false), m_NumColumns(numColumns),
m_DisableLockToScreen(false), m_ClipboardSharing(true), m_NumRows(numRows),
m_pAppConfig(appConfig),
m_EnableDragAndDrop(false),
m_DisableLockToScreen(false),
m_ClipboardSharing(true),
m_ClipboardSharingSize(defaultClipboardSharingSize()), m_ClipboardSharingSize(defaultClipboardSharingSize()),
m_pMainWindow(mainWindow) { m_pMainWindow(mainWindow) {
GUI::Config::ConfigWriter::make()->registerClass(this); GUI::Config::ConfigWriter::make()->registerClass(this);
@ -131,8 +135,8 @@ void ServerConfig::saveSettings() {
settings().setValue("disableLockToScreen", disableLockToScreen()); settings().setValue("disableLockToScreen", disableLockToScreen());
settings().setValue("enableDragAndDrop", enableDragAndDrop()); settings().setValue("enableDragAndDrop", enableDragAndDrop());
settings().setValue("clipboardSharing", clipboardSharing()); settings().setValue("clipboardSharing", clipboardSharing());
settings().setValue("clipboardSharingSize", settings().setValue(
QVariant::fromValue(clipboardSharingSize())); "clipboardSharingSize", QVariant::fromValue(clipboardSharingSize()));
if (!getClientAddress().isEmpty()) { if (!getClientAddress().isEmpty()) {
settings().setValue("clientAddress", getClientAddress()); settings().setValue("clientAddress", getClientAddress());
@ -190,14 +194,15 @@ void ServerConfig::loadSettings() {
setEnableDragAndDrop(settings().value("enableDragAndDrop", false).toBool()); setEnableDragAndDrop(settings().value("enableDragAndDrop", false).toBool());
setClipboardSharingSize( setClipboardSharingSize(
settings() settings()
.value("clipboardSharingSize", .value(
"clipboardSharingSize",
(int)ServerConfig::defaultClipboardSharingSize()) (int)ServerConfig::defaultClipboardSharingSize())
.toULongLong()); .toULongLong());
setClipboardSharing(settings().value("clipboardSharing", true).toBool()); setClipboardSharing(settings().value("clipboardSharing", true).toBool());
setClientAddress(settings().value("clientAddress", "").toString()); setClientAddress(settings().value("clientAddress", "").toString());
readSettings(settings(), switchCorners(), "switchCorner", false, readSettings(
NumSwitchCorners); settings(), switchCorners(), "switchCorner", false, NumSwitchCorners);
int numScreens = settings().beginReadArray("screens"); int numScreens = settings().beginReadArray("screens");
Q_ASSERT(numScreens <= screens().size()); Q_ASSERT(numScreens <= screens().size());
@ -222,8 +227,8 @@ void ServerConfig::loadSettings() {
settings().endGroup(); settings().endGroup();
} }
int ServerConfig::adjacentScreenIndex(int idx, int deltaColumn, int ServerConfig::adjacentScreenIndex(
int deltaRow) const { int idx, int deltaColumn, int deltaRow) const {
if (screens()[idx].isNull()) if (screens()[idx].isNull())
return -1; return -1;
@ -266,8 +271,8 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config) {
for (unsigned int j = 0; for (unsigned int j = 0;
j < sizeof(neighbourDirs) / sizeof(neighbourDirs[0]); j++) { j < sizeof(neighbourDirs) / sizeof(neighbourDirs[0]); j++) {
int idx = config.adjacentScreenIndex(i, neighbourDirs[j].x, int idx = config.adjacentScreenIndex(
neighbourDirs[j].y); i, neighbourDirs[j].x, neighbourDirs[j].y);
if (idx != -1 && !config.screens()[idx].isNull()) if (idx != -1 && !config.screens()[idx].isNull())
outStream << "\t\t" << neighbourDirs[j].name << " = " outStream << "\t\t" << neighbourDirs[j].name << " = "
<< config.screens()[idx].name() << Qt::endl; << config.screens()[idx].name() << Qt::endl;
@ -380,8 +385,8 @@ int ServerConfig::autoAddScreen(const QString name) {
dirIndex = 3; dirIndex = 3;
} }
int idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x, int idx = adjacentScreenIndex(
neighbourDirs[dirIndex].y); startIndex, neighbourDirs[dirIndex].x, neighbourDirs[dirIndex].y);
while (idx != -1) { while (idx != -1) {
if (screens()[idx].isNull()) { if (screens()[idx].isNull()) {
m_Screens[idx].setName(name); m_Screens[idx].setName(name);
@ -390,8 +395,8 @@ int ServerConfig::autoAddScreen(const QString name) {
} }
startIndex += offset; startIndex += offset;
idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x, idx = adjacentScreenIndex(
neighbourDirs[dirIndex].y); startIndex, neighbourDirs[dirIndex].x, neighbourDirs[dirIndex].y);
} }
if (!success) { if (!success) {

View file

@ -38,11 +38,12 @@ class AppConfig;
class ServerConfig : public BaseConfig, public GUI::Config::ConfigBase { class ServerConfig : public BaseConfig, public GUI::Config::ConfigBase {
friend class ServerConfigDialog; friend class ServerConfigDialog;
friend class ServerConnection; friend class ServerConnection;
friend QTextStream &operator<<(QTextStream &outStream, friend QTextStream &
const ServerConfig &config); operator<<(QTextStream &outStream, const ServerConfig &config);
public: public:
ServerConfig(int numColumns, int numRows, AppConfig *appConfig, ServerConfig(
int numColumns, int numRows, AppConfig *appConfig,
MainWindow *mainWindow); MainWindow *mainWindow);
ServerConfig(const ServerConfig &src) = default; ServerConfig(const ServerConfig &src) = default;

View file

@ -29,16 +29,19 @@
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, ServerConfigDialog::ServerConfigDialog(
AppConfig &appConfig) QWidget *parent, ServerConfig &config, AppConfig &appConfig)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
Ui::ServerConfigDialogBase(), m_OrigServerConfig(config), Ui::ServerConfigDialogBase(),
m_OrigServerConfig(config),
m_OrigServerAppConfigUseExternalConfig(config.getUseExternalConfig()), m_OrigServerAppConfigUseExternalConfig(config.getUseExternalConfig()),
m_OrigServerAppConfigExternalConfigFile(config.getConfigFile()), m_OrigServerAppConfigExternalConfigFile(config.getConfigFile()),
m_ServerConfig(config), m_ServerConfig(config),
m_ScreenSetupModel(serverConfig().screens(), serverConfig().numColumns(), m_ScreenSetupModel(
serverConfig().screens(), serverConfig().numColumns(),
serverConfig().numRows()), serverConfig().numRows()),
m_Message(""), m_appConfig(appConfig) { m_Message(""),
m_appConfig(appConfig) {
setupUi(this); setupUi(this);
m_pEditConfigFile->setText(serverConfig().getConfigFile()); m_pEditConfigFile->setText(serverConfig().getConfigFile());
@ -90,103 +93,122 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config,
if (server == screens.end()) { if (server == screens.end()) {
Screen serverScreen(serverConfig().getServerName()); Screen serverScreen(serverConfig().getServerName());
serverScreen.markAsServer(); serverScreen.markAsServer();
model().screen(serverConfig().numColumns() / 2, model().screen(
serverConfig().numRows() / 2) = serverScreen; serverConfig().numColumns() / 2, serverConfig().numRows() / 2) =
serverScreen;
} else { } else {
server->markAsServer(); server->markAsServer();
} }
m_pButtonAddComputer->setEnabled(!model().isFull()); m_pButtonAddComputer->setEnabled(!model().isFull());
connect(m_pTrashScreenWidget, SIGNAL(screenRemoved()), this, connect(
m_pTrashScreenWidget, SIGNAL(screenRemoved()), this,
SLOT(onScreenRemoved())); SLOT(onScreenRemoved()));
onChange(); onChange();
// computers // computers
connect(&m_ScreenSetupModel, &ScreenSetupModel::screensChanged, this, connect(
&m_ScreenSetupModel, &ScreenSetupModel::screensChanged, this,
&ServerConfigDialog::onChange); &ServerConfigDialog::onChange);
// advanced // advanced
connect(m_pCheckBoxSwitchDelay, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxSwitchDelay, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().haveSwitchDelay(v); serverConfig().haveSwitchDelay(v);
onChange(); onChange();
}); });
connect(m_pSpinBoxSwitchDelay, connect(
m_pSpinBoxSwitchDelay,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](const int &v) { [this](const int &v) {
serverConfig().setSwitchDelay(v); serverConfig().setSwitchDelay(v);
onChange(); onChange();
}); });
connect(m_pCheckBoxSwitchDoubleTap, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxSwitchDoubleTap, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().haveSwitchDoubleTap(v); serverConfig().haveSwitchDoubleTap(v);
onChange(); onChange();
}); });
connect(m_pSpinBoxSwitchDoubleTap, connect(
m_pSpinBoxSwitchDoubleTap,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](const int &v) { [this](const int &v) {
serverConfig().setSwitchDoubleTap(v); serverConfig().setSwitchDoubleTap(v);
onChange(); onChange();
}); });
connect(m_pCheckBoxEnableClipboard, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxEnableClipboard, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setClipboardSharing(v); serverConfig().setClipboardSharing(v);
onChange(); onChange();
}); });
connect(m_pSpinBoxClipboardSizeLimit, connect(
m_pSpinBoxClipboardSizeLimit,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](const int &v) { [this](const int &v) {
serverConfig().setClipboardSharingSize(v * 1024); serverConfig().setClipboardSharingSize(v * 1024);
onChange(); onChange();
}); });
connect(m_pCheckBoxHeartbeat, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxHeartbeat, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().haveHeartbeat(v); serverConfig().haveHeartbeat(v);
onChange(); onChange();
}); });
connect(m_pSpinBoxHeartbeat, connect(
m_pSpinBoxHeartbeat,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](const int &v) { [this](const int &v) {
serverConfig().setHeartbeat(v); serverConfig().setHeartbeat(v);
onChange(); onChange();
}); });
connect(m_pCheckBoxRelativeMouseMoves, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxRelativeMouseMoves, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setRelativeMouseMoves(v); serverConfig().setRelativeMouseMoves(v);
onChange(); onChange();
}); });
connect(m_pCheckBoxWin32KeepForeground, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxWin32KeepForeground, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setWin32KeepForeground(v); serverConfig().setWin32KeepForeground(v);
onChange(); onChange();
}); });
connect(m_pCheckBoxDisableLockToScreen, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxDisableLockToScreen, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setDisableLockToScreen(v); serverConfig().setDisableLockToScreen(v);
onChange(); onChange();
}); });
connect(m_pCheckBoxCornerTopLeft, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxCornerTopLeft, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setSwitchCorner(BaseConfig::TopLeft, v); serverConfig().setSwitchCorner(BaseConfig::TopLeft, v);
onChange(); onChange();
}); });
connect(m_pCheckBoxCornerTopRight, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxCornerTopRight, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setSwitchCorner(BaseConfig::TopRight, v); serverConfig().setSwitchCorner(BaseConfig::TopRight, v);
onChange(); onChange();
}); });
connect(m_pCheckBoxCornerBottomLeft, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxCornerBottomLeft, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setSwitchCorner(BaseConfig::BottomLeft, v); serverConfig().setSwitchCorner(BaseConfig::BottomLeft, v);
onChange(); onChange();
}); });
connect(m_pCheckBoxCornerBottomRight, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxCornerBottomRight, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setSwitchCorner(BaseConfig::BottomRight, v); serverConfig().setSwitchCorner(BaseConfig::BottomRight, v);
onChange(); onChange();
}); });
connect(m_pSpinBoxSwitchCornerSize, connect(
m_pSpinBoxSwitchCornerSize,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](const int &v) { [this](const int &v) {
serverConfig().setSwitchCornerSize(v); serverConfig().setSwitchCornerSize(v);
@ -194,7 +216,8 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config,
}); });
// config // config
connect(m_pCheckBoxUseExternalConfig, &QCheckBox::stateChanged, this, connect(
m_pCheckBoxUseExternalConfig, &QCheckBox::stateChanged, this,
[this](const int &v) { [this](const int &v) {
serverConfig().setUseExternalConfig(v); serverConfig().setUseExternalConfig(v);
onChange(); onChange();
@ -441,6 +464,6 @@ void ServerConfigDialog::onChange() {
serverConfig().getUseExternalConfig() && serverConfig().getUseExternalConfig() &&
m_OrigServerAppConfigExternalConfigFile == serverConfig().getConfigFile(); m_OrigServerAppConfigExternalConfigFile == serverConfig().getConfigFile();
m_pButtonBox->button(QDialogButtonBox::Ok) m_pButtonBox->button(QDialogButtonBox::Ok)
->setEnabled(!isAppConfigDataEqual || ->setEnabled(
!(m_OrigServerConfig == m_ServerConfig)); !isAppConfigDataEqual || !(m_OrigServerConfig == m_ServerConfig));
} }

View file

@ -32,8 +32,8 @@ class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase {
Q_OBJECT Q_OBJECT
public: public:
ServerConfigDialog(QWidget *parent, ServerConfig &config, ServerConfigDialog(
AppConfig &appConfig); QWidget *parent, ServerConfig &config, AppConfig &appConfig);
bool addClient(const QString &clientName); bool addClient(const QString &clientName);
public slots: public slots:

View file

@ -55,8 +55,8 @@ void ServerConnection::addClient(const QString &clientName) {
checkMainWindow()) { checkMainWindow()) {
QMessageBox message(&m_parent); QMessageBox message(&m_parent);
message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole); message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole);
message.addButton(QObject::tr("Accept and configure"), message.addButton(
QMessageBox::AcceptRole); QObject::tr("Accept and configure"), QMessageBox::AcceptRole);
message.setText( message.setText(
QObject::tr("%1 client has made a connection request").arg(clientName)); QObject::tr("%1 client has made a connection request").arg(clientName));
@ -69,8 +69,8 @@ void ServerConnection::addClient(const QString &clientName) {
} }
void ServerConnection::configureClient(const QString &clientName) { void ServerConnection::configureClient(const QString &clientName) {
ServerConfigDialog dlg(&m_parent, m_parent.serverConfig(), ServerConfigDialog dlg(
m_parent.appConfig()); &m_parent, m_parent.serverConfig(), m_parent.appConfig());
if (dlg.addClient(clientName) && dlg.exec() == QDialog::Accepted) { if (dlg.addClient(clientName) && dlg.exec() == QDialog::Accepted) {
m_parent.restartSynergy(); m_parent.restartSynergy();

View file

@ -18,7 +18,8 @@
#include "ServerMessage.h" #include "ServerMessage.h"
ServerMessage::ServerMessage(const QString &message) ServerMessage::ServerMessage(const QString &message)
: m_message(message), m_clienName(parseClientName(message)) {} : m_message(message),
m_clienName(parseClientName(message)) {}
bool ServerMessage::isNewClientMessage() const { bool ServerMessage::isNewClientMessage() const {
return m_message.contains("unrecognised client name"); return m_message.contains("unrecognised client name");

View file

@ -34,7 +34,8 @@
SettingsDialog::SettingsDialog(QWidget *parent, AppConfig &config) SettingsDialog::SettingsDialog(QWidget *parent, AppConfig &config)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
Ui::SettingsDialogBase(), m_appConfig(config) { Ui::SettingsDialogBase(),
m_appConfig(config) {
setupUi(this); setupUi(this);
// TODO: maybe just accept MainWindow type in ctor? // TODO: maybe just accept MainWindow type in ctor?
@ -52,28 +53,34 @@ SettingsDialog::SettingsDialog(QWidget *parent, AppConfig &config)
m_pLineEditScreenName->setValidator(new validators::ScreenNameValidator( m_pLineEditScreenName->setValidator(new validators::ScreenNameValidator(
m_pLineEditScreenName, m_pLabelNameError, (&serveConfig.screens()))); m_pLineEditScreenName, m_pLabelNameError, (&serveConfig.screens())));
connect(m_pLineEditLogFilename, SIGNAL(textChanged(QString)), this, connect(
m_pLineEditLogFilename, SIGNAL(textChanged(QString)), this,
SLOT(onChange())); SLOT(onChange()));
connect(m_pComboLogLevel, SIGNAL(currentIndexChanged(int)), this, connect(
m_pComboLogLevel, SIGNAL(currentIndexChanged(int)), this,
SLOT(onChange())); SLOT(onChange()));
connect(m_pLineEditCertificatePath, SIGNAL(textChanged(QString)), this, connect(
m_pLineEditCertificatePath, SIGNAL(textChanged(QString)), this,
SLOT(onChange())); SLOT(onChange()));
connect(m_pCheckBoxMinimizeToTray, SIGNAL(clicked()), this, SLOT(onChange())); connect(m_pCheckBoxMinimizeToTray, SIGNAL(clicked()), this, SLOT(onChange()));
connect(m_pCheckBoxAutoHide, SIGNAL(clicked()), this, SLOT(onChange())); connect(m_pCheckBoxAutoHide, SIGNAL(clicked()), this, SLOT(onChange()));
connect(m_pCheckBoxPreventSleep, SIGNAL(clicked()), this, SLOT(onChange())); connect(m_pCheckBoxPreventSleep, SIGNAL(clicked()), this, SLOT(onChange()));
connect(m_pLineEditInterface, SIGNAL(textEdited(QString)), this, connect(
m_pLineEditInterface, SIGNAL(textEdited(QString)), this,
SLOT(onChange())); SLOT(onChange()));
connect(m_pSpinBoxPort, SIGNAL(valueChanged(int)), this, SLOT(onChange())); connect(m_pSpinBoxPort, SIGNAL(valueChanged(int)), this, SLOT(onChange()));
connect(m_pLineEditScreenName, SIGNAL(textEdited(QString)), this, connect(
m_pLineEditScreenName, SIGNAL(textEdited(QString)), this,
SLOT(onChange())); SLOT(onChange()));
connect(m_pComboElevate, SIGNAL(currentIndexChanged(int)), this, connect(
m_pComboElevate, SIGNAL(currentIndexChanged(int)), this,
SLOT(onChange())); SLOT(onChange()));
connect(m_pCheckBoxLanguageSync, SIGNAL(clicked()), this, SLOT(onChange())); connect(m_pCheckBoxLanguageSync, SIGNAL(clicked()), this, SLOT(onChange()));
connect(m_pCheckBoxScrollDirection, SIGNAL(clicked()), this, connect(
SLOT(onChange())); m_pCheckBoxScrollDirection, SIGNAL(clicked()), this, SLOT(onChange()));
connect(m_pCheckBoxClientHostMode, SIGNAL(clicked()), this, SLOT(onChange())); connect(m_pCheckBoxClientHostMode, SIGNAL(clicked()), this, SLOT(onChange()));
connect(m_pCheckBoxServerClientMode, SIGNAL(clicked()), this, connect(
SLOT(onChange())); m_pCheckBoxServerClientMode, SIGNAL(clicked()), this, SLOT(onChange()));
adjustSize(); adjustSize();
} }
@ -266,8 +273,8 @@ void SettingsDialog::updateRegenButton() {
// NOR the above bools, if any have changed regen should be disabled as it // NOR the above bools, if any have changed regen should be disabled as it
// will be done on save // will be done on save
auto nor = !(keyChanged || pathChanged); auto nor = !(keyChanged || pathChanged);
m_pPushButtonRegenCert->setEnabled(nor && m_pPushButtonRegenCert->setEnabled(
m_pCheckBoxEnableCrypto->isChecked()); nor && m_pCheckBoxEnableCrypto->isChecked());
} }
void SettingsDialog::on_m_pPushButtonRegenCert_clicked() { void SettingsDialog::on_m_pPushButtonRegenCert_clicked() {

View file

@ -34,10 +34,10 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase {
public: public:
SettingsDialog(QWidget *parent, AppConfig &config); SettingsDialog(QWidget *parent, AppConfig &config);
static QString browseForSynergyc(QWidget *parent, const QString &programDir, static QString browseForSynergyc(
const QString &synergycName); QWidget *parent, const QString &programDir, const QString &synergycName);
static QString browseForSynergys(QWidget *parent, const QString &programDir, static QString browseForSynergys(
const QString &synergysName); QWidget *parent, const QString &programDir, const QString &synergysName);
protected: protected:
void accept() override; void accept() override;

View file

@ -27,7 +27,8 @@ SetupWizard::SetupWizard(MainWindow &mainWindow) : m_MainWindow(mainWindow) {
new validators::ScreenNameValidator(m_pLineEditName, label_ErrorMessage)); new validators::ScreenNameValidator(m_pLineEditName, label_ErrorMessage));
connect(m_pButtonApply, SIGNAL(clicked()), this, SLOT(accept())); connect(m_pButtonApply, SIGNAL(clicked()), this, SLOT(accept()));
connect(m_pLineEditName, SIGNAL(textEdited(QString)), this, connect(
m_pLineEditName, SIGNAL(textEdited(QString)), this,
SLOT(onNameChanged())); SLOT(onNameChanged()));
} }

View file

@ -32,8 +32,8 @@ static const std::vector<const char *> blockerText = {
"Please switch to Xorg if you wish to continue using Synergy today.", "Please switch to Xorg if you wish to continue using Synergy today.",
}; };
SetupWizardBlocker::SetupWizardBlocker(MainWindow &mainWindow, SetupWizardBlocker::SetupWizardBlocker(
qBlockerType type) MainWindow &mainWindow, qBlockerType type)
: m_MainWindow(mainWindow) { : m_MainWindow(mainWindow) {
setupUi(this); setupUi(this);
@ -41,9 +41,11 @@ SetupWizardBlocker::SetupWizardBlocker(MainWindow &mainWindow,
label_HelpInfo->setText(blockerText[static_cast<int>(type)]); label_HelpInfo->setText(blockerText[static_cast<int>(type)]);
connect(m_pButtonSupport, &QPushButton::released, this, connect(
m_pButtonSupport, &QPushButton::released, this,
&SetupWizardBlocker::onlineSupport); &SetupWizardBlocker::onlineSupport);
connect(m_pButtonCancel, &QPushButton::released, this, connect(
m_pButtonCancel, &QPushButton::released, this,
&SetupWizardBlocker::cancel); &SetupWizardBlocker::cancel);
} }

View file

@ -85,9 +85,8 @@ bool SslCertificate::runTool(const QStringList &args) {
return true; return true;
} }
void SslCertificate::generateCertificate(const QString &path, void SslCertificate::generateCertificate(
const QString &keyLength, const QString &path, const QString &keyLength, bool forceGen) {
bool forceGen) {
QString sslDirPath = QString sslDirPath =
QString("%1%2%3").arg(m_ProfileDir).arg(QDir::separator()).arg(kSslDir); QString("%1%2%3").arg(m_ProfileDir).arg(QDir::separator()).arg(kSslDir);

View file

@ -34,8 +34,8 @@ public slots:
/// @param [in] QString keyLength The size of the private key. default: 2048 /// @param [in] QString keyLength The size of the private key. default: 2048
/// @param [in] bool Should the file be created regardless of if the file /// @param [in] bool Should the file be created regardless of if the file
/// already exists /// already exists
void generateCertificate(const QString &path = QString(), void generateCertificate(
const QString &keyLength = "2048", const QString &path = QString(), const QString &keyLength = "2048",
bool forceGen = false); bool forceGen = false);
/// @brief Get the key length of a TLS private key /// @brief Get the key length of a TLS private key

View file

@ -9,7 +9,8 @@ void TrayIcon::tryCreate() const {
// underlying DBus connection // underlying DBus connection
// (on DBus) // (on DBus)
m_pTrayIcon->show(); m_pTrayIcon->show();
m_connector(m_pTrayIcon.get(), m_connector(
m_pTrayIcon.get(),
SIGNAL(activated(QSystemTrayIcon::ActivationReason))); SIGNAL(activated(QSystemTrayIcon::ActivationReason)));
} else { } else {
QTimer::singleShot(2500, this, &TrayIcon::tryCreate); QTimer::singleShot(2500, this, &TrayIcon::tryCreate);

View file

@ -18,8 +18,8 @@ public:
} }
template <typename TActionContainer> template <typename TActionContainer>
void create(TActionContainer const &actionContainer, void
TConnector const &connector) { create(TActionContainer const &actionContainer, TConnector const &connector) {
m_connector = connector; m_connector = connector;
m_pTrayIconMenu = std::make_unique<QMenu>(); m_pTrayIconMenu = std::make_unique<QMenu>();

View file

@ -29,7 +29,8 @@ void UpgradeDialog::showDialog(const QString &text) {
setText(QObject::tr(text.toStdString().c_str())); setText(QObject::tr(text.toStdString().c_str()));
if (exec() == QMessageBox::Accepted) { if (exec() == QMessageBox::Accepted) {
QDesktopServices::openUrl(QUrl(QCoreApplication::organizationDomain() + QDesktopServices::openUrl(QUrl(
QCoreApplication::organizationDomain() +
"/synergy/purchase/upgrade?source=gui")); "/synergy/purchase/upgrade?source=gui"));
} }
} }

View file

@ -28,18 +28,20 @@
VersionChecker::VersionChecker(std::shared_ptr<QNetworkAccessManager> nam) VersionChecker::VersionChecker(std::shared_ptr<QNetworkAccessManager> nam)
: m_manager(nam ? nam : std::make_shared<QNetworkAccessManager>(this)) { : m_manager(nam ? nam : std::make_shared<QNetworkAccessManager>(this)) {
connect(m_manager.get(), SIGNAL(finished(QNetworkReply *)), this, connect(
m_manager.get(), SIGNAL(finished(QNetworkReply *)), this,
SLOT(replyFinished(QNetworkReply *))); SLOT(replyFinished(QNetworkReply *)));
} }
void VersionChecker::checkLatest() { void VersionChecker::checkLatest() {
auto request = QNetworkRequest(QUrl(SYNERGY_VERSION_URL)); auto request = QNetworkRequest(QUrl(SYNERGY_VERSION_URL));
request.setHeader(QNetworkRequest::UserAgentHeader, request.setHeader(
QString("Synergy (") + SYNERGY_VERSION + ") " + QNetworkRequest::UserAgentHeader, QString("Synergy (") + SYNERGY_VERSION +
") " +
QSysInfo::prettyProductName()); QSysInfo::prettyProductName());
request.setRawHeader("X-Synergy-Version", SYNERGY_VERSION); request.setRawHeader("X-Synergy-Version", SYNERGY_VERSION);
request.setRawHeader("X-Synergy-Language", request.setRawHeader(
QLocale::system().name().toStdString().c_str()); "X-Synergy-Language", QLocale::system().name().toStdString().c_str());
m_manager->get(request); m_manager->get(request);
} }

View file

@ -66,7 +66,8 @@ int main(int argc, char *argv[]) {
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
if (app.applicationDirPath().startsWith("/Volumes/")) { if (app.applicationDirPath().startsWith("/Volumes/")) {
QMessageBox::information(NULL, "Synergy", QMessageBox::information(
NULL, "Synergy",
"Please drag Synergy to the Applications folder, " "Please drag Synergy to the Applications folder, "
"and open it from there."); "and open it from there.");
return 1; return 1;
@ -93,8 +94,9 @@ int main(int argc, char *argv[]) {
MainWindow mainWindow(appConfig); MainWindow mainWindow(appConfig);
#endif #endif
QObject::connect(dynamic_cast<QObject *>(&app), SIGNAL(aboutToQuit()), QObject::connect(
&mainWindow, SLOT(saveSettings())); dynamic_cast<QObject *>(&app), SIGNAL(aboutToQuit()), &mainWindow,
SLOT(saveSettings()));
std::unique_ptr<SetupWizardBlocker> setupBlocker; std::unique_ptr<SetupWizardBlocker> setupBlocker;
if (qgetenv("XDG_SESSION_TYPE") == "wayland") { if (qgetenv("XDG_SESSION_TYPE") == "wayland") {
@ -143,7 +145,8 @@ bool checkMacAssistiveDevices() {
// now deprecated in mavericks. // now deprecated in mavericks.
bool result = AXAPIEnabled(); bool result = AXAPIEnabled();
if (!result) { if (!result) {
QMessageBox::information(NULL, "Synergy", QMessageBox::information(
NULL, "Synergy",
"Please enable access to assistive devices " "Please enable access to assistive devices "
"System Preferences -> Security & Privacy -> " "System Preferences -> Security & Privacy -> "
"Privacy -> Accessibility, then re-open Synergy."); "Privacy -> Accessibility, then re-open Synergy.");

View file

@ -24,8 +24,8 @@ namespace validators {
class AliasValidator : public LineEditValidator { class AliasValidator : public LineEditValidator {
public: public:
explicit AliasValidator(QLineEdit *parent = nullptr, explicit AliasValidator(
QLabel *errors = nullptr); QLineEdit *parent = nullptr, QLabel *errors = nullptr);
}; };
} // namespace validators } // namespace validators

View file

@ -25,8 +25,8 @@ ComputerNameValidator::ComputerNameValidator(const QString &message)
: IStringValidator(message) {} : IStringValidator(message) {}
bool ComputerNameValidator::validate(const QString &input) const { bool ComputerNameValidator::validate(const QString &input) const {
const QRegularExpression re("^[\\w\\._-]{0,255}$", const QRegularExpression re(
QRegularExpression::CaseInsensitiveOption); "^[\\w\\._-]{0,255}$", QRegularExpression::CaseInsensitiveOption);
auto match = re.match(input); auto match = re.match(input);
auto result = match.hasMatch(); auto result = match.hasMatch();
return result; return result;

View file

@ -20,7 +20,8 @@
namespace validators { namespace validators {
LineEditValidator::LineEditValidator(QLineEdit *parent, QLabel *errors) LineEditValidator::LineEditValidator(QLineEdit *parent, QLabel *errors)
: m_pErrors(errors), m_pControl(parent) { : m_pErrors(errors),
m_pControl(parent) {
if (m_pErrors) { if (m_pErrors) {
m_pErrors->hide(); m_pErrors->hide();
} }

View file

@ -31,8 +31,8 @@ namespace validators {
class LineEditValidator : public QValidator { class LineEditValidator : public QValidator {
public: public:
explicit LineEditValidator(QLineEdit *parent = nullptr, explicit LineEditValidator(
QLabel *errors = nullptr); QLineEdit *parent = nullptr, QLabel *errors = nullptr);
QValidator::State validate(QString &input, int &pos) const override; QValidator::State validate(QString &input, int &pos) const override;
void addValidator(std::unique_ptr<IStringValidator> validator); void addValidator(std::unique_ptr<IStringValidator> validator);

View file

@ -22,7 +22,8 @@ namespace validators {
ScreenDuplicationsValidator::ScreenDuplicationsValidator( ScreenDuplicationsValidator::ScreenDuplicationsValidator(
const QString &message, const QString &defaultName, const QString &message, const QString &defaultName,
const ScreenList *pScreens) const ScreenList *pScreens)
: IStringValidator(message), m_defaultName(defaultName), : IStringValidator(message),
m_defaultName(defaultName),
m_pScreenList(pScreens) {} m_pScreenList(pScreens) {}
bool ScreenDuplicationsValidator::validate(const QString &input) const { bool ScreenDuplicationsValidator::validate(const QString &input) const {

View file

@ -28,8 +28,8 @@ class ScreenDuplicationsValidator : public IStringValidator {
const ScreenList *m_pScreenList = nullptr; const ScreenList *m_pScreenList = nullptr;
public: public:
ScreenDuplicationsValidator(const QString &message, ScreenDuplicationsValidator(
const QString &defaultName, const QString &message, const QString &defaultName,
const ScreenList *pScreens); const ScreenList *pScreens);
bool validate(const QString &input) const override; bool validate(const QString &input) const override;
}; };

View file

@ -27,8 +27,8 @@
namespace validators { namespace validators {
ScreenNameValidator::ScreenNameValidator(QLineEdit *parent, QLabel *errors, ScreenNameValidator::ScreenNameValidator(
const ScreenList *pScreens) QLineEdit *parent, QLabel *errors, const ScreenList *pScreens)
: LineEditValidator(parent, errors) { : LineEditValidator(parent, errors) {
addValidator( addValidator(
std::make_unique<EmptyStringValidator>("Computer name cannot be empty")); std::make_unique<EmptyStringValidator>("Computer name cannot be empty"));

View file

@ -25,8 +25,8 @@ namespace validators {
class ScreenNameValidator : public LineEditValidator { class ScreenNameValidator : public LineEditValidator {
public: public:
explicit ScreenNameValidator(QLineEdit *parent = nullptr, explicit ScreenNameValidator(
QLabel *errors = nullptr, QLineEdit *parent = nullptr, QLabel *errors = nullptr,
const ScreenList *pScreens = nullptr); const ScreenList *pScreens = nullptr);
}; };

View file

@ -24,7 +24,8 @@ ClientStateLabel::ClientStateLabel(QWidget *parent) : QLabel(parent) { hide(); }
void ClientStateLabel::updateClientState(const QString &line) { void ClientStateLabel::updateClientState(const QString &line) {
if (line.contains("connected to server")) { if (line.contains("connected to server")) {
show(); show();
} else if (line.contains("disconnected from server") || } else if (
line.contains("disconnected from server") ||
line.contains("process exited")) { line.contains("process exited")) {
hide(); hide();
} }

View file

@ -30,8 +30,8 @@ ArchDaemonNone::~ArchDaemonNone() {
// do nothing // do nothing
} }
void ArchDaemonNone::installDaemon(const char *, const char *, const char *, void ArchDaemonNone::installDaemon(
const char *, const char *) { const char *, const char *, const char *, const char *, const char *) {
// do nothing // do nothing
} }

View file

@ -35,9 +35,9 @@ public:
virtual ~ArchDaemonNone(); virtual ~ArchDaemonNone();
// IArchDaemon overrides // IArchDaemon overrides
virtual void installDaemon(const char *name, const char *description, virtual void installDaemon(
const char *pathname, const char *commandLine, const char *name, const char *description, const char *pathname,
const char *dependencies); const char *commandLine, const char *dependencies);
virtual void uninstallDaemon(const char *name); virtual void uninstallDaemon(const char *name);
virtual int daemonize(const char *name, DaemonFunc func); virtual int daemonize(const char *name, DaemonFunc func);
virtual bool canInstallDaemon(const char *name); virtual bool canInstallDaemon(const char *name);

View file

@ -47,9 +47,9 @@ public:
followed by a NUL; the daemon will be configured to startup after followed by a NUL; the daemon will be configured to startup after
the listed daemons. Throws an \c XArchDaemon exception on failure. the listed daemons. Throws an \c XArchDaemon exception on failure.
*/ */
virtual void installDaemon(const char *name, const char *description, virtual void installDaemon(
const char *pathname, const char *commandLine, const char *name, const char *description, const char *pathname,
const char *dependencies) = 0; const char *commandLine, const char *dependencies) = 0;
//! Uninstall daemon //! Uninstall daemon
/*! /*!

View file

@ -85,8 +85,8 @@ public:
is longer than allowed by the system; we'll rely on the is longer than allowed by the system; we'll rely on the
system calls to tell us that. system calls to tell us that.
*/ */
virtual std::string concatPath(const std::string &prefix, virtual std::string
const std::string &suffix) = 0; concatPath(const std::string &prefix, const std::string &suffix) = 0;
//@} //@}
//! Set the user's profile directory //! Set the user's profile directory

View file

@ -37,8 +37,8 @@ IArchString::~IArchString() {
} }
} }
int IArchString::convStringWCToMB(char *dst, const wchar_t *src, UInt32 n, int IArchString::convStringWCToMB(
bool *errors) { char *dst, const wchar_t *src, UInt32 n, bool *errors) {
ptrdiff_t len = 0; ptrdiff_t len = 0;
bool dummyErrors; bool dummyErrors;
@ -94,8 +94,8 @@ int IArchString::convStringWCToMB(char *dst, const wchar_t *src, UInt32 n,
return static_cast<int>(len); return static_cast<int>(len);
} }
int IArchString::convStringMBToWC(wchar_t *dst, const char *src, UInt32 n, int IArchString::convStringMBToWC(
bool *errors) { wchar_t *dst, const char *src, UInt32 n, bool *errors) {
ptrdiff_t len = 0; ptrdiff_t len = 0;
wchar_t dummy; wchar_t dummy;

View file

@ -54,7 +54,7 @@ public:
/*! /*!
Writes a Synergy setting from the system. Writes a Synergy setting from the system.
*/ */
virtual void setting(const std::string &valueName, virtual void setting(
const std::string &valueString) const = 0; const std::string &valueName, const std::string &valueString) const = 0;
//@} //@}
}; };

View file

@ -113,8 +113,8 @@ std::string ArchFileUnix::getProfileDirectory() {
return dir; return dir;
} }
std::string ArchFileUnix::concatPath(const std::string &prefix, std::string
const std::string &suffix) { ArchFileUnix::concatPath(const std::string &prefix, const std::string &suffix) {
std::string path; std::string path;
path.reserve(prefix.size() + 1 + suffix.size()); path.reserve(prefix.size() + 1 + suffix.size());
path += prefix; path += prefix;

View file

@ -36,8 +36,8 @@ public:
virtual std::string getLogDirectory(); virtual std::string getLogDirectory();
virtual std::string getPluginDirectory(); virtual std::string getPluginDirectory();
virtual std::string getProfileDirectory(); virtual std::string getProfileDirectory();
virtual std::string concatPath(const std::string &prefix, virtual std::string
const std::string &suffix); concatPath(const std::string &prefix, const std::string &suffix);
virtual void setProfileDirectory(const String &s); virtual void setProfileDirectory(const String &s);
virtual void setPluginDirectory(const String &s); virtual void setPluginDirectory(const String &s);

View file

@ -77,8 +77,14 @@ public:
}; };
ArchThreadImpl::ArchThreadImpl() ArchThreadImpl::ArchThreadImpl()
: m_refCount(1), m_id(0), m_func(NULL), m_userData(NULL), m_cancel(false), : m_refCount(1),
m_cancelling(false), m_exited(false), m_result(NULL), m_id(0),
m_func(NULL),
m_userData(NULL),
m_cancel(false),
m_cancelling(false),
m_exited(false),
m_result(NULL),
m_networkData(NULL) { m_networkData(NULL) {
// do nothing // do nothing
} }
@ -90,7 +96,8 @@ ArchThreadImpl::ArchThreadImpl()
ArchMultithreadPosix *ArchMultithreadPosix::s_instance = NULL; ArchMultithreadPosix *ArchMultithreadPosix::s_instance = NULL;
ArchMultithreadPosix::ArchMultithreadPosix() ArchMultithreadPosix::ArchMultithreadPosix()
: m_newThreadCalled(false), m_nextID(0) { : m_newThreadCalled(false),
m_nextID(0) {
assert(s_instance == NULL); assert(s_instance == NULL);
s_instance = this; s_instance = this;
@ -186,8 +193,8 @@ void ArchMultithreadPosix::broadcastCondVar(ArchCond cond) {
assert(status == 0); assert(status == 0);
} }
bool ArchMultithreadPosix::waitCondVar(ArchCond cond, ArchMutex mutex, bool ArchMultithreadPosix::waitCondVar(
double timeout) { ArchCond cond, ArchMutex mutex, double timeout) {
// we can't wait on a condition variable and also wake it up for // we can't wait on a condition variable and also wake it up for
// cancellation since we don't use posix cancellation. so we // cancellation since we don't use posix cancellation. so we
// must wake up periodically to check for cancellation. we // must wake up periodically to check for cancellation. we
@ -326,8 +333,8 @@ ArchThread ArchMultithreadPosix::newThread(ThreadFunc func, void *data) {
pthread_attr_t attr; pthread_attr_t attr;
int status = pthread_attr_init(&attr); int status = pthread_attr_init(&attr);
if (status == 0) { if (status == 0) {
status = pthread_create(&thread->m_thread, &attr, status = pthread_create(
&ArchMultithreadPosix::threadFunc, thread); &thread->m_thread, &attr, &ArchMultithreadPosix::threadFunc, thread);
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
} }
@ -471,8 +478,8 @@ bool ArchMultithreadPosix::wait(ArchThread target, double timeout) {
} }
} }
bool ArchMultithreadPosix::isSameThread(ArchThread thread1, bool ArchMultithreadPosix::isSameThread(
ArchThread thread2) { ArchThread thread1, ArchThread thread2) {
return (thread1 == thread2); return (thread1 == thread2);
} }
@ -495,8 +502,8 @@ ArchMultithreadPosix::getIDOfThread(ArchThread thread) {
return thread->m_id; return thread->m_id;
} }
void ArchMultithreadPosix::setSignalHandler(ESignal signal, SignalFunc func, void ArchMultithreadPosix::setSignalHandler(
void *userData) { ESignal signal, SignalFunc func, void *userData) {
lockMutex(m_threadMutex); lockMutex(m_threadMutex);
m_signalFunc[signal] = func; m_signalFunc[signal] = func;
m_signalUserData[signal] = userData; m_signalUserData[signal] = userData;
@ -528,8 +535,9 @@ void ArchMultithreadPosix::startSignalHandler() {
pthread_attr_t attr; pthread_attr_t attr;
int status = pthread_attr_init(&attr); int status = pthread_attr_init(&attr);
if (status == 0) { if (status == 0) {
status = pthread_create(&m_signalThread, &attr, status = pthread_create(
&ArchMultithreadPosix::threadSignalHandler, NULL); &m_signalThread, &attr, &ArchMultithreadPosix::threadSignalHandler,
NULL);
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
} }
if (status != 0) { if (status != 0) {

View file

@ -406,7 +406,8 @@ int ArchNetworkBSD::pollSocket(PollEntry pe[], int num, double timeout) {
} }
// do the select // do the select
n = select((SELECT_TYPE_ARG1)n + 1, SELECT_TYPE_ARG234 readSetP, n = select(
(SELECT_TYPE_ARG1)n + 1, SELECT_TYPE_ARG234 readSetP,
SELECT_TYPE_ARG234 writeSetP, SELECT_TYPE_ARG234 errSetP, SELECT_TYPE_ARG234 writeSetP, SELECT_TYPE_ARG234 errSetP,
SELECT_TYPE_ARG5 timeout2P); SELECT_TYPE_ARG5 timeout2P);
@ -493,8 +494,9 @@ void ArchNetworkBSD::throwErrorOnSocket(ArchSocket s) {
// get the error from the socket layer // get the error from the socket layer
int err = 0; int err = 0;
auto size = static_cast<socklen_t>(sizeof(err)); auto size = static_cast<socklen_t>(sizeof(err));
if (getsockopt(s->m_fd, SOL_SOCKET, SO_ERROR, if (getsockopt(
reinterpret_cast<optval_t *>(&err), &size) == -1) { s->m_fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<optval_t *>(&err),
&size) == -1) {
err = errno; err = errno;
} }
@ -527,14 +529,16 @@ bool ArchNetworkBSD::setNoDelayOnSocket(ArchSocket s, bool noDelay) {
// get old state // get old state
int oflag; int oflag;
auto size = static_cast<socklen_t>(sizeof(oflag)); auto size = static_cast<socklen_t>(sizeof(oflag));
if (getsockopt(s->m_fd, IPPROTO_TCP, TCP_NODELAY, if (getsockopt(
s->m_fd, IPPROTO_TCP, TCP_NODELAY,
reinterpret_cast<optval_t *>(&oflag), &size) == -1) { reinterpret_cast<optval_t *>(&oflag), &size) == -1) {
throwError(errno); throwError(errno);
} }
int flag = noDelay ? 1 : 0; int flag = noDelay ? 1 : 0;
size = static_cast<socklen_t>(sizeof(flag)); size = static_cast<socklen_t>(sizeof(flag));
if (setsockopt(s->m_fd, IPPROTO_TCP, TCP_NODELAY, if (setsockopt(
s->m_fd, IPPROTO_TCP, TCP_NODELAY,
reinterpret_cast<optval_t *>(&flag), size) == -1) { reinterpret_cast<optval_t *>(&flag), size) == -1) {
throwError(errno); throwError(errno);
} }
@ -548,14 +552,16 @@ bool ArchNetworkBSD::setReuseAddrOnSocket(ArchSocket s, bool reuse) {
// get old state // get old state
int oflag; int oflag;
auto size = static_cast<socklen_t>(sizeof(oflag)); auto size = static_cast<socklen_t>(sizeof(oflag));
if (getsockopt(s->m_fd, SOL_SOCKET, SO_REUSEADDR, if (getsockopt(
s->m_fd, SOL_SOCKET, SO_REUSEADDR,
reinterpret_cast<optval_t *>(&oflag), &size) == -1) { reinterpret_cast<optval_t *>(&oflag), &size) == -1) {
throwError(errno); throwError(errno);
} }
int flag = reuse ? 1 : 0; int flag = reuse ? 1 : 0;
size = static_cast<socklen_t>(sizeof(flag)); size = static_cast<socklen_t>(sizeof(flag));
if (setsockopt(s->m_fd, SOL_SOCKET, SO_REUSEADDR, if (setsockopt(
s->m_fd, SOL_SOCKET, SO_REUSEADDR,
reinterpret_cast<optval_t *>(&flag), size) == -1) { reinterpret_cast<optval_t *>(&flag), size) == -1) {
throwError(errno); throwError(errno);
} }
@ -648,8 +654,8 @@ ArchNetworkBSD::nameToAddr(const std::string &name) {
addresses.back()->m_len = (socklen_t)sizeof(struct sockaddr_in6); addresses.back()->m_len = (socklen_t)sizeof(struct sockaddr_in6);
} }
memcpy(&addresses.back()->m_addr, address->ai_addr, memcpy(
addresses.back()->m_len); &addresses.back()->m_addr, address->ai_addr, addresses.back()->m_len);
} }
freeaddrinfo(pResult); freeaddrinfo(pResult);
@ -671,8 +677,9 @@ std::string ArchNetworkBSD::addrToName(ArchNetAddress addr) {
ARCH->lockMutex(m_mutex); ARCH->lockMutex(m_mutex);
char host[1024]; char host[1024];
char service[20]; char service[20];
int ret = getnameinfo(TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, int ret = getnameinfo(
sizeof(host), service, sizeof(service), 0); TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, sizeof(host),
service, sizeof(service), 0);
if (ret != 0) { if (ret != 0) {
ARCH->unlockMutex(m_mutex); ARCH->unlockMutex(m_mutex);
throwNameError(ret); throwNameError(ret);
@ -777,16 +784,18 @@ bool ArchNetworkBSD::isAnyAddr(ArchNetAddress addr) {
switch (getAddrFamily(addr)) { switch (getAddrFamily(addr)) {
case kINET: { case kINET: {
auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr);
return (ipAddr->sin_addr.s_addr == INADDR_ANY && return (
ipAddr->sin_addr.s_addr == INADDR_ANY &&
addr->m_len == static_cast<socklen_t>(sizeof(struct sockaddr_in))); addr->m_len == static_cast<socklen_t>(sizeof(struct sockaddr_in)));
} }
case kINET6: { case kINET6: {
struct sockaddr_in6 *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); struct sockaddr_in6 *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr);
return (addr->m_len == (socklen_t)sizeof(struct sockaddr_in6) && return (
memcmp(static_cast<const void *>(&ipAddr->sin6_addr), addr->m_len == (socklen_t)sizeof(struct sockaddr_in6) &&
static_cast<const void *>(&in6addr_any), memcmp(
sizeof(in6_addr)) == 0); static_cast<const void *>(&ipAddr->sin6_addr),
static_cast<const void *>(&in6addr_any), sizeof(in6_addr)) == 0);
} }
default: default:
@ -796,8 +805,8 @@ bool ArchNetworkBSD::isAnyAddr(ArchNetAddress addr) {
} }
bool ArchNetworkBSD::isEqualAddr(ArchNetAddress a, ArchNetAddress b) { bool ArchNetworkBSD::isEqualAddr(ArchNetAddress a, ArchNetAddress b) {
return (a->m_len == b->m_len && return (
memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0); a->m_len == b->m_len && memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0);
} }
const int *ArchNetworkBSD::getUnblockPipe() { const int *ArchNetworkBSD::getUnblockPipe() {

View file

@ -77,9 +77,9 @@ void ArchSleepUnix::sleep(double timeout) {
struct timeval timeout2; struct timeval timeout2;
timeout2.tv_sec = static_cast<int>(timeLeft); timeout2.tv_sec = static_cast<int>(timeLeft);
timeout2.tv_usec = static_cast<int>(1.0e+6 * (timeLeft - timeout2.tv_sec)); timeout2.tv_usec = static_cast<int>(1.0e+6 * (timeLeft - timeout2.tv_sec));
select((SELECT_TYPE_ARG1)0, SELECT_TYPE_ARG234 NULL, select(
SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG234 NULL, (SELECT_TYPE_ARG1)0, SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG234 NULL,
SELECT_TYPE_ARG5 & timeout2); SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG5 & timeout2);
ARCH->testCancelThread(); ARCH->testCancelThread();
timeLeft = timeout - (ARCH->time() - startTime); timeLeft = timeout - (ARCH->time() - startTime);
} }

View file

@ -69,13 +69,13 @@ std::string ArchSystemUnix::getLibsUsed(void) const {
} }
#ifndef __APPLE__ #ifndef __APPLE__
bool ArchSystemUnix::DBusInhibitScreenCall(InhibitScreenServices serviceID, bool ArchSystemUnix::DBusInhibitScreenCall(
bool state, std::string &error) { InhibitScreenServices serviceID, bool state, std::string &error) {
error = ""; error = "";
static const std::array<QString, 2> services = {"org.freedesktop.ScreenSaver", static const std::array<QString, 2> services = {
"org.gnome.SessionManager"}; "org.freedesktop.ScreenSaver", "org.gnome.SessionManager"};
static const std::array<QString, 2> paths = {"/org/freedesktop/ScreenSaver", static const std::array<QString, 2> paths = {
"/org/gnome/SessionManager"}; "/org/freedesktop/ScreenSaver", "/org/gnome/SessionManager"};
static std::array<uint, 2> cookies; static std::array<uint, 2> cookies;
auto serviceNum = static_cast<uint8_t>(serviceID); auto serviceNum = static_cast<uint8_t>(serviceID);
@ -86,8 +86,8 @@ bool ArchSystemUnix::DBusInhibitScreenCall(InhibitScreenServices serviceID,
return false; return false;
} }
QDBusInterface screenSaverInterface(services[serviceNum], paths[serviceNum], QDBusInterface screenSaverInterface(
services[serviceNum], bus); services[serviceNum], paths[serviceNum], services[serviceNum], bus);
if (!screenSaverInterface.isValid()) { if (!screenSaverInterface.isValid()) {
error = "screen saver interface failed to initialize"; error = "screen saver interface failed to initialize";

View file

@ -37,7 +37,7 @@ public:
#ifndef __APPLE__ #ifndef __APPLE__
enum class InhibitScreenServices { kScreenSaver, kSessionManager }; enum class InhibitScreenServices { kScreenSaver, kSessionManager };
static bool DBusInhibitScreenCall(InhibitScreenServices serviceID, bool state, static bool DBusInhibitScreenCall(
std::string &error); InhibitScreenServices serviceID, bool state, std::string &error);
#endif #endif
}; };

View file

@ -62,10 +62,9 @@ void ArchDaemonWindows::daemonFailed(int result) {
throw XArchDaemonRunFailed(result); throw XArchDaemonRunFailed(result);
} }
void ArchDaemonWindows::installDaemon(const char *name, const char *description, void ArchDaemonWindows::installDaemon(
const char *pathname, const char *name, const char *description, const char *pathname,
const char *commandLine, const char *commandLine, const char *dependencies) {
const char *dependencies) {
// open service manager // open service manager
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE); SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
if (mgr == NULL) { if (mgr == NULL) {
@ -74,11 +73,11 @@ void ArchDaemonWindows::installDaemon(const char *name, const char *description,
} }
// create the service // create the service
SC_HANDLE service = SC_HANDLE service = CreateService(
CreateService(mgr, name, name, 0, mgr, name, name, 0,
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, pathname, NULL, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, pathname, NULL, NULL,
NULL, dependencies, NULL, NULL); dependencies, NULL, NULL);
if (service == NULL) { if (service == NULL) {
// can't create service // can't create service
@ -255,8 +254,8 @@ bool ArchDaemonWindows::isDaemonInstalled(const char *name) {
} }
HKEY ArchDaemonWindows::openNTServicesKey() { HKEY ArchDaemonWindows::openNTServicesKey() {
static const char *s_keyNames[] = {_T("SYSTEM"), _T("CurrentControlSet"), static const char *s_keyNames[] = {
_T("Services"), NULL}; _T("SYSTEM"), _T("CurrentControlSet"), _T("Services"), NULL};
return ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_keyNames); return ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_keyNames);
} }
@ -606,8 +605,8 @@ void ArchDaemonWindows::installDaemon() {
ss << path; ss << path;
ss << '"'; ss << '"';
installDaemon(DEFAULT_DAEMON_NAME, DEFAULT_DAEMON_INFO, ss.str().c_str(), installDaemon(
"", ""); DEFAULT_DAEMON_NAME, DEFAULT_DAEMON_INFO, ss.str().c_str(), "", "");
} }
start(DEFAULT_DAEMON_NAME); start(DEFAULT_DAEMON_NAME);

View file

@ -75,9 +75,9 @@ public:
static UINT getDaemonQuitMessage(); static UINT getDaemonQuitMessage();
// IArchDaemon overrides // IArchDaemon overrides
virtual void installDaemon(const char *name, const char *description, virtual void installDaemon(
const char *pathname, const char *commandLine, const char *name, const char *description, const char *pathname,
const char *dependencies); const char *commandLine, const char *dependencies);
virtual void uninstallDaemon(const char *name); virtual void uninstallDaemon(const char *name);
virtual void installDaemon(); virtual void installDaemon();
virtual void uninstallDaemon(); virtual void uninstallDaemon();

View file

@ -155,8 +155,8 @@ std::string ArchFileWindows::getProfileDirectory() {
return dir; return dir;
} }
std::string ArchFileWindows::concatPath(const std::string &prefix, std::string ArchFileWindows::concatPath(
const std::string &suffix) { const std::string &prefix, const std::string &suffix) {
std::string path; std::string path;
path.reserve(prefix.size() + 1 + suffix.size()); path.reserve(prefix.size() + 1 + suffix.size());
path += prefix; path += prefix;

View file

@ -36,8 +36,8 @@ public:
virtual std::string getLogDirectory(); virtual std::string getLogDirectory();
virtual std::string getPluginDirectory(); virtual std::string getPluginDirectory();
virtual std::string getProfileDirectory(); virtual std::string getProfileDirectory();
virtual std::string concatPath(const std::string &prefix, virtual std::string
const std::string &suffix); concatPath(const std::string &prefix, const std::string &suffix);
virtual void setProfileDirectory(const String &s); virtual void setProfileDirectory(const String &s);
virtual void setPluginDirectory(const String &s); virtual void setPluginDirectory(const String &s);

View file

@ -74,7 +74,8 @@ void ArchLogWindows::writeLog(ELevel level, const char *msg) {
// just dump our string into the raw data section of the event // just dump our string into the raw data section of the event
// so users can at least see the message. note that we use our // so users can at least see the message. note that we use our
// level as the event category. // level as the event category.
ReportEvent(m_eventLog, type, static_cast<WORD>(level), ReportEvent(
m_eventLog, type, static_cast<WORD>(level),
0, // event ID 0, // event ID
NULL, 0, NULL, 0,
(DWORD)strlen(msg) + 1, // raw data size (DWORD)strlen(msg) + 1, // raw data size

View file

@ -114,8 +114,9 @@ HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *keyName, bool create) {
RegOpenKeyEx(key, keyName, 0, KEY_WRITE | KEY_QUERY_VALUE, &newKey); RegOpenKeyEx(key, keyName, 0, KEY_WRITE | KEY_QUERY_VALUE, &newKey);
if (result != ERROR_SUCCESS && create) { if (result != ERROR_SUCCESS && create) {
DWORD disp; DWORD disp;
result = RegCreateKeyEx(key, keyName, 0, NULL, 0, result = RegCreateKeyEx(
KEY_WRITE | KEY_QUERY_VALUE, NULL, &newKey, &disp); key, keyName, 0, NULL, 0, KEY_WRITE | KEY_QUERY_VALUE, NULL, &newKey,
&disp);
} }
if (result != ERROR_SUCCESS) { if (result != ERROR_SUCCESS) {
RegCloseKey(key); RegCloseKey(key);
@ -127,8 +128,8 @@ HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *keyName, bool create) {
return newKey; return newKey;
} }
HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *const *keyNames, HKEY ArchMiscWindows::openKey(
bool create) { HKEY key, const TCHAR *const *keyNames, bool create) {
for (size_t i = 0; key != NULL && keyNames[i] != NULL; ++i) { for (size_t i = 0; key != NULL && keyNames[i] != NULL; ++i) {
// open next key // open next key
key = openKey(key, keyNames[i], create); key = openKey(key, keyNames[i], create);
@ -165,8 +166,8 @@ bool ArchMiscWindows::hasValue(HKEY key, const TCHAR *name) {
return (result == ERROR_SUCCESS && (type == REG_DWORD || type == REG_SZ)); return (result == ERROR_SUCCESS && (type == REG_DWORD || type == REG_SZ));
} }
ArchMiscWindows::EValueType ArchMiscWindows::typeOfValue(HKEY key, ArchMiscWindows::EValueType
const TCHAR *name) { ArchMiscWindows::typeOfValue(HKEY key, const TCHAR *name) {
DWORD type; DWORD type;
LONG result = RegQueryValueEx(key, name, 0, &type, NULL, NULL); LONG result = RegQueryValueEx(key, name, 0, &type, NULL, NULL);
if (result != ERROR_SUCCESS) { if (result != ERROR_SUCCESS) {
@ -187,15 +188,15 @@ ArchMiscWindows::EValueType ArchMiscWindows::typeOfValue(HKEY key,
} }
} }
void ArchMiscWindows::setValue(HKEY key, const TCHAR *name, void ArchMiscWindows::setValue(
const std::string &value) { HKEY key, const TCHAR *name, const std::string &value) {
assert(key != NULL); assert(key != NULL);
if (key == NULL) { if (key == NULL) {
// TODO: throw exception // TODO: throw exception
return; return;
} }
RegSetValueEx(key, name, 0, REG_SZ, RegSetValueEx(
reinterpret_cast<const BYTE *>(value.c_str()), key, name, 0, REG_SZ, reinterpret_cast<const BYTE *>(value.c_str()),
(DWORD)value.size() + 1); (DWORD)value.size() + 1);
} }
@ -205,25 +206,26 @@ void ArchMiscWindows::setValue(HKEY key, const TCHAR *name, DWORD value) {
// TODO: throw exception // TODO: throw exception
return; return;
} }
RegSetValueEx(key, name, 0, REG_DWORD, reinterpret_cast<CONST BYTE *>(&value), RegSetValueEx(
key, name, 0, REG_DWORD, reinterpret_cast<CONST BYTE *>(&value),
sizeof(DWORD)); sizeof(DWORD));
} }
void ArchMiscWindows::setValueBinary(HKEY key, const TCHAR *name, void ArchMiscWindows::setValueBinary(
const std::string &value) { HKEY key, const TCHAR *name, const std::string &value) {
assert(key != NULL); assert(key != NULL);
assert(name != NULL); assert(name != NULL);
if (key == NULL || name == NULL) { if (key == NULL || name == NULL) {
// TODO: throw exception // TODO: throw exception
return; return;
} }
RegSetValueEx(key, name, 0, REG_BINARY, RegSetValueEx(
reinterpret_cast<const BYTE *>(value.data()), key, name, 0, REG_BINARY, reinterpret_cast<const BYTE *>(value.data()),
(DWORD)value.size()); (DWORD)value.size());
} }
std::string ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR *name, std::string
DWORD type) { ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR *name, DWORD type) {
// get the size of the string // get the size of the string
DWORD actualType; DWORD actualType;
DWORD size = 0; DWORD size = 0;
@ -241,8 +243,8 @@ std::string ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR *name,
char *buffer = new char[size]; char *buffer = new char[size];
// read it // read it
result = RegQueryValueEx(key, name, 0, &actualType, result = RegQueryValueEx(
reinterpret_cast<BYTE *>(buffer), &size); key, name, 0, &actualType, reinterpret_cast<BYTE *>(buffer), &size);
if (result != ERROR_SUCCESS || actualType != type) { if (result != ERROR_SUCCESS || actualType != type) {
delete[] buffer; delete[] buffer;
return std::string(); return std::string();
@ -271,8 +273,8 @@ ArchMiscWindows::readValueInt(HKEY key, const TCHAR *name) {
DWORD type; DWORD type;
DWORD value; DWORD value;
DWORD size = sizeof(value); DWORD size = sizeof(value);
LONG result = RegQueryValueEx(key, name, 0, &type, LONG result = RegQueryValueEx(
reinterpret_cast<BYTE *>(&value), &size); key, name, 0, &type, reinterpret_cast<BYTE *>(&value), &size);
if (result != ERROR_SUCCESS || type != REG_DWORD) { if (result != ERROR_SUCCESS || type != REG_DWORD) {
return 0; return 0;
} }
@ -396,13 +398,13 @@ BOOL WINAPI ArchMiscWindows::getParentProcessEntry(PROCESSENTRY32 &entry) {
return getProcessEntry(entry, selfEntry.th32ParentProcessID); return getProcessEntry(entry, selfEntry.th32ParentProcessID);
} }
BOOL WINAPI ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry, BOOL WINAPI
DWORD processID) { ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry, DWORD processID) {
// first we need to take a snapshot of the running processes // first we need to take a snapshot of the running processes
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot == INVALID_HANDLE_VALUE) { if (snapshot == INVALID_HANDLE_VALUE) {
LOG((CLOG_ERR "could not get process snapshot (error: %i)", LOG((
GetLastError())); CLOG_ERR "could not get process snapshot (error: %i)", GetLastError()));
return FALSE; return FALSE;
} }
@ -412,7 +414,8 @@ BOOL WINAPI ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry,
// unlikely we can go any further // unlikely we can go any further
BOOL gotEntry = Process32First(snapshot, &entry); BOOL gotEntry = Process32First(snapshot, &entry);
if (!gotEntry) { if (!gotEntry) {
LOG((CLOG_ERR "could not get first process entry (error: %i)", LOG(
(CLOG_ERR "could not get first process entry (error: %i)",
GetLastError())); GetLastError()));
return FALSE; return FALSE;
} }

View file

@ -114,8 +114,8 @@ public:
/*! /*!
Sets the \p name value of \p key to \p value.data(). Sets the \p name value of \p key to \p value.data().
*/ */
static void setValueBinary(HKEY key, const TCHAR *name, static void
const std::string &value); setValueBinary(HKEY key, const TCHAR *name, const std::string &value);
//! Read a string value from the registry //! Read a string value from the registry
static std::string readValueString(HKEY, const TCHAR *name); static std::string readValueString(HKEY, const TCHAR *name);

View file

@ -59,8 +59,14 @@ public:
}; };
ArchThreadImpl::ArchThreadImpl() ArchThreadImpl::ArchThreadImpl()
: m_refCount(1), m_thread(NULL), m_id(0), m_func(NULL), m_userData(NULL), : m_refCount(1),
m_cancelling(false), m_result(NULL), m_networkData(NULL) { m_thread(NULL),
m_id(0),
m_func(NULL),
m_userData(NULL),
m_cancelling(false),
m_result(NULL),
m_networkData(NULL) {
m_exit = CreateEvent(NULL, TRUE, FALSE, NULL); m_exit = CreateEvent(NULL, TRUE, FALSE, NULL);
m_cancel = CreateEvent(NULL, TRUE, FALSE, NULL); m_cancel = CreateEvent(NULL, TRUE, FALSE, NULL);
} }
@ -177,8 +183,8 @@ void ArchMultithreadWindows::broadcastCondVar(ArchCond cond) {
} }
} }
bool ArchMultithreadWindows::waitCondVar(ArchCond cond, ArchMutex mutex, bool ArchMultithreadWindows::waitCondVar(
double timeout) { ArchCond cond, ArchMutex mutex, double timeout) {
// prepare to wait // prepare to wait
const DWORD winTimeout = const DWORD winTimeout =
(timeout < 0.0) ? INFINITE : static_cast<DWORD>(1000.0 * timeout); (timeout < 0.0) ? INFINITE : static_cast<DWORD>(1000.0 * timeout);
@ -451,8 +457,8 @@ bool ArchMultithreadWindows::wait(ArchThread target, double timeout) {
} }
} }
bool ArchMultithreadWindows::isSameThread(ArchThread thread1, bool ArchMultithreadWindows::isSameThread(
ArchThread thread2) { ArchThread thread1, ArchThread thread2) {
return (thread1 == thread2); return (thread1 == thread2);
} }
@ -473,8 +479,8 @@ ArchMultithreadWindows::getIDOfThread(ArchThread thread) {
return static_cast<ThreadID>(thread->m_id); return static_cast<ThreadID>(thread->m_id);
} }
void ArchMultithreadWindows::setSignalHandler(ESignal signal, SignalFunc func, void ArchMultithreadWindows::setSignalHandler(
void *userData) { ESignal signal, SignalFunc func, void *userData) {
lockMutex(m_threadMutex); lockMutex(m_threadMutex);
m_signalFunc[signal] = func; m_signalFunc[signal] = func;
m_signalUserData[signal] = userData; m_signalUserData[signal] = userData;

View file

@ -31,34 +31,32 @@ static const int s_family[] = {
}; };
static const int s_type[] = {SOCK_DGRAM, SOCK_STREAM}; static const int s_type[] = {SOCK_DGRAM, SOCK_STREAM};
static SOCKET(PASCAL FAR *accept_winsock)(SOCKET s, struct sockaddr FAR *addr, static SOCKET(PASCAL FAR *accept_winsock)(
int FAR *addrlen); SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen);
static int(PASCAL FAR *bind_winsock)(SOCKET s, const struct sockaddr FAR *addr, static int(PASCAL FAR *bind_winsock)(
int namelen); SOCKET s, const struct sockaddr FAR *addr, int namelen);
static int(PASCAL FAR *close_winsock)(SOCKET s); static int(PASCAL FAR *close_winsock)(SOCKET s);
static int(PASCAL FAR *connect_winsock)(SOCKET s, static int(PASCAL FAR *connect_winsock)(
const struct sockaddr FAR *name, SOCKET s, const struct sockaddr FAR *name, int namelen);
int namelen);
static int(PASCAL FAR *gethostname_winsock)(char FAR *name, int namelen); static int(PASCAL FAR *gethostname_winsock)(char FAR *name, int namelen);
static int(PASCAL FAR *getsockerror_winsock)(void); static int(PASCAL FAR *getsockerror_winsock)(void);
static int(PASCAL FAR *getsockopt_winsock)(SOCKET s, int level, int optname, static int(PASCAL FAR *getsockopt_winsock)(
void FAR *optval, int FAR *optlen); SOCKET s, int level, int optname, void FAR *optval, int FAR *optlen);
static u_short(PASCAL FAR *htons_winsock)(u_short v); static u_short(PASCAL FAR *htons_winsock)(u_short v);
static char FAR *(PASCAL FAR *inet_ntoa_winsock)(struct in_addr in); static char FAR *(PASCAL FAR *inet_ntoa_winsock)(struct in_addr in);
static unsigned long(PASCAL FAR *inet_addr_winsock)(const char FAR *cp); static unsigned long(PASCAL FAR *inet_addr_winsock)(const char FAR *cp);
static int(PASCAL FAR *ioctl_winsock)(SOCKET s, int cmd, void FAR *data); static int(PASCAL FAR *ioctl_winsock)(SOCKET s, int cmd, void FAR *data);
static int(PASCAL FAR *listen_winsock)(SOCKET s, int backlog); static int(PASCAL FAR *listen_winsock)(SOCKET s, int backlog);
static u_short(PASCAL FAR *ntohs_winsock)(u_short v); static u_short(PASCAL FAR *ntohs_winsock)(u_short v);
static int(PASCAL FAR *recv_winsock)(SOCKET s, void FAR *buf, int len, static int(PASCAL FAR *recv_winsock)(
int flags); SOCKET s, void FAR *buf, int len, int flags);
static int(PASCAL FAR *select_winsock)(int nfds, fd_set FAR *readfds, static int(PASCAL FAR *select_winsock)(
fd_set FAR *writefds, int nfds, fd_set FAR *readfds, fd_set FAR *writefds, fd_set FAR *exceptfds,
fd_set FAR *exceptfds,
const struct timeval FAR *timeout); const struct timeval FAR *timeout);
static int(PASCAL FAR *send_winsock)(SOCKET s, const void FAR *buf, int len, static int(PASCAL FAR *send_winsock)(
int flags); SOCKET s, const void FAR *buf, int len, int flags);
static int(PASCAL FAR *setsockopt_winsock)(SOCKET s, int level, int optname, static int(PASCAL FAR *setsockopt_winsock)(
const void FAR *optval, int optlen); SOCKET s, int level, int optname, const void FAR *optval, int optlen);
static int(PASCAL FAR *shutdown_winsock)(SOCKET s, int how); static int(PASCAL FAR *shutdown_winsock)(SOCKET s, int how);
static SOCKET(PASCAL FAR *socket_winsock)(int af, int type, int protocol); static SOCKET(PASCAL FAR *socket_winsock)(int af, int type, int protocol);
static struct hostent FAR *(PASCAL FAR *gethostbyaddr_winsock)( static struct hostent FAR *(PASCAL FAR *gethostbyaddr_winsock)(
@ -72,11 +70,10 @@ static BOOL(PASCAL FAR *WSACloseEvent_winsock)(WSAEVENT);
static BOOL(PASCAL FAR *WSASetEvent_winsock)(WSAEVENT); static BOOL(PASCAL FAR *WSASetEvent_winsock)(WSAEVENT);
static BOOL(PASCAL FAR *WSAResetEvent_winsock)(WSAEVENT); static BOOL(PASCAL FAR *WSAResetEvent_winsock)(WSAEVENT);
static int(PASCAL FAR *WSAEventSelect_winsock)(SOCKET, WSAEVENT, long); static int(PASCAL FAR *WSAEventSelect_winsock)(SOCKET, WSAEVENT, long);
static DWORD(PASCAL FAR *WSAWaitForMultipleEvents_winsock)(DWORD, static DWORD(PASCAL FAR *WSAWaitForMultipleEvents_winsock)(
const WSAEVENT FAR *, DWORD, const WSAEVENT FAR *, BOOL, DWORD, BOOL);
BOOL, DWORD, BOOL); static int(PASCAL FAR *WSAEnumNetworkEvents_winsock)(
static int(PASCAL FAR *WSAEnumNetworkEvents_winsock)(SOCKET, WSAEVENT, SOCKET, WSAEVENT, LPWSANETWORKEVENTS);
LPWSANETWORKEVENTS);
#undef FD_ISSET #undef FD_ISSET
#define FD_ISSET(fd, set) WSAFDIsSet_winsock((SOCKET)(fd), (fd_set FAR *)(set)) #define FD_ISSET(fd, set) WSAFDIsSet_winsock((SOCKET)(fd), (fd_set FAR *)(set))
@ -167,69 +164,89 @@ void ArchNetworkWinsock::initModule(HMODULE module) {
} }
// get function addresses // get function addresses
setfunc(accept_winsock, accept, setfunc(
SOCKET(PASCAL FAR *)(SOCKET s, struct sockaddr FAR * addr, accept_winsock, accept,
int FAR *addrlen)); SOCKET(PASCAL FAR *)(
setfunc(bind_winsock, bind, SOCKET s, struct sockaddr FAR * addr, int FAR *addrlen));
int(PASCAL FAR *)(SOCKET s, const struct sockaddr FAR *addr, setfunc(
int namelen)); bind_winsock, bind,
int(PASCAL FAR *)(
SOCKET s, const struct sockaddr FAR *addr, int namelen));
setfunc(close_winsock, closesocket, int(PASCAL FAR *)(SOCKET s)); setfunc(close_winsock, closesocket, int(PASCAL FAR *)(SOCKET s));
setfunc(connect_winsock, connect, setfunc(
int(PASCAL FAR *)(SOCKET s, const struct sockaddr FAR *name, connect_winsock, connect,
int namelen)); int(PASCAL FAR *)(
setfunc(gethostname_winsock, gethostname, SOCKET s, const struct sockaddr FAR *name, int namelen));
setfunc(
gethostname_winsock, gethostname,
int(PASCAL FAR *)(char FAR *name, int namelen)); int(PASCAL FAR *)(char FAR *name, int namelen));
setfunc(getsockerror_winsock, WSAGetLastError, int(PASCAL FAR *)(void)); setfunc(getsockerror_winsock, WSAGetLastError, int(PASCAL FAR *)(void));
setfunc(getsockopt_winsock, getsockopt, setfunc(
int(PASCAL FAR *)(SOCKET s, int level, int optname, void FAR *optval, getsockopt_winsock, getsockopt,
int FAR *optlen)); int(PASCAL FAR *)(
SOCKET s, int level, int optname, void FAR *optval, int FAR *optlen));
setfunc(htons_winsock, htons, u_short(PASCAL FAR *)(u_short v)); setfunc(htons_winsock, htons, u_short(PASCAL FAR *)(u_short v));
setfunc(inet_ntoa_winsock, inet_ntoa, setfunc(
inet_ntoa_winsock, inet_ntoa,
char FAR *(PASCAL FAR *)(struct in_addr in)); char FAR *(PASCAL FAR *)(struct in_addr in));
setfunc(inet_addr_winsock, inet_addr, setfunc(
inet_addr_winsock, inet_addr,
unsigned long(PASCAL FAR *)(const char FAR *cp)); unsigned long(PASCAL FAR *)(const char FAR *cp));
setfunc(ioctl_winsock, ioctlsocket, setfunc(
ioctl_winsock, ioctlsocket,
int(PASCAL FAR *)(SOCKET s, int cmd, void FAR *)); int(PASCAL FAR *)(SOCKET s, int cmd, void FAR *));
setfunc(listen_winsock, listen, int(PASCAL FAR *)(SOCKET s, int backlog)); setfunc(listen_winsock, listen, int(PASCAL FAR *)(SOCKET s, int backlog));
setfunc(ntohs_winsock, ntohs, u_short(PASCAL FAR *)(u_short v)); setfunc(ntohs_winsock, ntohs, u_short(PASCAL FAR *)(u_short v));
setfunc(recv_winsock, recv, setfunc(
recv_winsock, recv,
int(PASCAL FAR *)(SOCKET s, void FAR *buf, int len, int flags)); int(PASCAL FAR *)(SOCKET s, void FAR *buf, int len, int flags));
setfunc(select_winsock, select, setfunc(
int(PASCAL FAR *)(int nfds, fd_set FAR *readfds, fd_set FAR *writefds, select_winsock, select,
fd_set FAR *exceptfds, int(PASCAL FAR *)(
const struct timeval FAR *timeout)); int nfds, fd_set FAR *readfds, fd_set FAR *writefds,
setfunc(send_winsock, send, fd_set FAR *exceptfds, const struct timeval FAR *timeout));
setfunc(
send_winsock, send,
int(PASCAL FAR *)(SOCKET s, const void FAR *buf, int len, int flags)); int(PASCAL FAR *)(SOCKET s, const void FAR *buf, int len, int flags));
setfunc(setsockopt_winsock, setsockopt, setfunc(
int(PASCAL FAR *)(SOCKET s, int level, int optname, setsockopt_winsock, setsockopt,
const void FAR *optval, int optlen)); int(PASCAL FAR *)(
SOCKET s, int level, int optname, const void FAR *optval,
int optlen));
setfunc(shutdown_winsock, shutdown, int(PASCAL FAR *)(SOCKET s, int how)); setfunc(shutdown_winsock, shutdown, int(PASCAL FAR *)(SOCKET s, int how));
setfunc(socket_winsock, socket, setfunc(
socket_winsock, socket,
SOCKET(PASCAL FAR *)(int af, int type, int protocol)); SOCKET(PASCAL FAR *)(int af, int type, int protocol));
setfunc(gethostbyaddr_winsock, gethostbyaddr, setfunc(
gethostbyaddr_winsock, gethostbyaddr,
struct hostent FAR * struct hostent FAR *
(PASCAL FAR *)(const char FAR *addr, int len, int type)); (PASCAL FAR *)(const char FAR *addr, int len, int type));
setfunc(gethostbyname_winsock, gethostbyname, setfunc(
gethostbyname_winsock, gethostbyname,
struct hostent FAR * (PASCAL FAR *)(const char FAR *name)); struct hostent FAR * (PASCAL FAR *)(const char FAR *name));
setfunc(WSACleanup_winsock, WSACleanup, int(PASCAL FAR *)(void)); setfunc(WSACleanup_winsock, WSACleanup, int(PASCAL FAR *)(void));
setfunc(WSAFDIsSet_winsock, __WSAFDIsSet, setfunc(
WSAFDIsSet_winsock, __WSAFDIsSet,
int(PASCAL FAR *)(SOCKET, fd_set FAR *)); int(PASCAL FAR *)(SOCKET, fd_set FAR *));
setfunc(WSACreateEvent_winsock, WSACreateEvent, WSAEVENT(PASCAL FAR *)(void)); setfunc(WSACreateEvent_winsock, WSACreateEvent, WSAEVENT(PASCAL FAR *)(void));
setfunc(WSACloseEvent_winsock, WSACloseEvent, BOOL(PASCAL FAR *)(WSAEVENT)); setfunc(WSACloseEvent_winsock, WSACloseEvent, BOOL(PASCAL FAR *)(WSAEVENT));
setfunc(WSASetEvent_winsock, WSASetEvent, BOOL(PASCAL FAR *)(WSAEVENT)); setfunc(WSASetEvent_winsock, WSASetEvent, BOOL(PASCAL FAR *)(WSAEVENT));
setfunc(WSAResetEvent_winsock, WSAResetEvent, BOOL(PASCAL FAR *)(WSAEVENT)); setfunc(WSAResetEvent_winsock, WSAResetEvent, BOOL(PASCAL FAR *)(WSAEVENT));
setfunc(WSAEventSelect_winsock, WSAEventSelect, setfunc(
WSAEventSelect_winsock, WSAEventSelect,
int(PASCAL FAR *)(SOCKET, WSAEVENT, long)); int(PASCAL FAR *)(SOCKET, WSAEVENT, long));
setfunc(WSAWaitForMultipleEvents_winsock, WSAWaitForMultipleEvents, setfunc(
WSAWaitForMultipleEvents_winsock, WSAWaitForMultipleEvents,
DWORD(PASCAL FAR *)(DWORD, const WSAEVENT FAR *, BOOL, DWORD, BOOL)); DWORD(PASCAL FAR *)(DWORD, const WSAEVENT FAR *, BOOL, DWORD, BOOL));
setfunc(WSAEnumNetworkEvents_winsock, WSAEnumNetworkEvents, setfunc(
WSAEnumNetworkEvents_winsock, WSAEnumNetworkEvents,
int(PASCAL FAR *)(SOCKET, WSAEVENT, LPWSANETWORKEVENTS)); int(PASCAL FAR *)(SOCKET, WSAEVENT, LPWSANETWORKEVENTS));
s_networkModule = module; s_networkModule = module;
} }
ArchSocket ArchNetworkWinsock::newSocket(EAddressFamily family, ArchSocket
ESocketType type) { ArchNetworkWinsock::newSocket(EAddressFamily family, ESocketType type) {
// create socket // create socket
SOCKET fd = socket_winsock(s_family[family], s_type[type], 0); SOCKET fd = socket_winsock(s_family[family], s_type[type], 0);
if (fd == INVALID_SOCKET) { if (fd == INVALID_SOCKET) {
@ -314,8 +331,9 @@ void ArchNetworkWinsock::bindSocket(ArchSocket s, ArchNetAddress addr) {
assert(s != NULL); assert(s != NULL);
assert(addr != NULL); assert(addr != NULL);
if (bind_winsock(s->m_socket, TYPED_ADDR(struct sockaddr, addr), if (bind_winsock(
addr->m_len) == SOCKET_ERROR) { s->m_socket, TYPED_ADDR(struct sockaddr, addr), addr->m_len) ==
SOCKET_ERROR) {
throwError(getsockerror_winsock()); throwError(getsockerror_winsock());
} }
} }
@ -329,8 +347,8 @@ void ArchNetworkWinsock::listenOnSocket(ArchSocket s) {
} }
} }
ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchSocket
ArchNetAddress *const addr) { ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress *const addr) {
assert(s != NULL); assert(s != NULL);
// create new socket and temporary address // create new socket and temporary address
@ -338,8 +356,8 @@ ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s,
ArchNetAddress tmp = ArchNetAddressImpl::alloc(sizeof(struct sockaddr_in6)); ArchNetAddress tmp = ArchNetAddressImpl::alloc(sizeof(struct sockaddr_in6));
// accept on socket // accept on socket
SOCKET fd = accept_winsock(s->m_socket, TYPED_ADDR(struct sockaddr, tmp), SOCKET fd = accept_winsock(
&tmp->m_len); s->m_socket, TYPED_ADDR(struct sockaddr, tmp), &tmp->m_len);
if (fd == INVALID_SOCKET) { if (fd == INVALID_SOCKET) {
int err = getsockerror_winsock(); int err = getsockerror_winsock();
delete socket; delete socket;
@ -384,8 +402,9 @@ bool ArchNetworkWinsock::connectSocket(ArchSocket s, ArchNetAddress addr) {
assert(s != NULL); assert(s != NULL);
assert(addr != NULL); assert(addr != NULL);
if (connect_winsock(s->m_socket, TYPED_ADDR(struct sockaddr, addr), if (connect_winsock(
addr->m_len) == SOCKET_ERROR) { s->m_socket, TYPED_ADDR(struct sockaddr, addr), addr->m_len) ==
SOCKET_ERROR) {
if (getsockerror_winsock() == WSAEISCONN) { if (getsockerror_winsock() == WSAEISCONN) {
return true; return true;
} }
@ -437,8 +456,8 @@ int ArchNetworkWinsock::pollSocket(PollEntry pe[], int num, double timeout) {
} }
// select socket for desired events // select socket for desired events
WSAEventSelect_winsock(pe[i].m_socket->m_socket, pe[i].m_socket->m_event, WSAEventSelect_winsock(
socketEvents); pe[i].m_socket->m_socket, pe[i].m_socket->m_event, socketEvents);
// add socket event to wait list // add socket event to wait list
events[n++] = pe[i].m_socket->m_event; events[n++] = pe[i].m_socket->m_event;
@ -500,9 +519,9 @@ int ArchNetworkWinsock::pollSocket(PollEntry pe[], int num, double timeout) {
// get events // get events
WSANETWORKEVENTS info; WSANETWORKEVENTS info;
if (WSAEnumNetworkEvents_winsock(pe[i].m_socket->m_socket, if (WSAEnumNetworkEvents_winsock(
pe[i].m_socket->m_event, pe[i].m_socket->m_socket, pe[i].m_socket->m_event, &info) ==
&info) == SOCKET_ERROR) { SOCKET_ERROR) {
continue; continue;
} }
if ((info.lNetworkEvents & FD_READ) != 0) { if ((info.lNetworkEvents & FD_READ) != 0) {
@ -569,8 +588,8 @@ size_t ArchNetworkWinsock::readSocket(ArchSocket s, void *buf, size_t len) {
return static_cast<size_t>(n); return static_cast<size_t>(n);
} }
size_t ArchNetworkWinsock::writeSocket(ArchSocket s, const void *buf, size_t
size_t len) { ArchNetworkWinsock::writeSocket(ArchSocket s, const void *buf, size_t len) {
assert(s != NULL); assert(s != NULL);
int n = send_winsock(s->m_socket, buf, (int)len, 0); int n = send_winsock(s->m_socket, buf, (int)len, 0);
@ -620,8 +639,9 @@ bool ArchNetworkWinsock::setNoDelayOnSocket(ArchSocket s, bool noDelay) {
// get old state // get old state
BOOL oflag; BOOL oflag;
int size = sizeof(oflag); int size = sizeof(oflag);
if (getsockopt_winsock(s->m_socket, IPPROTO_TCP, TCP_NODELAY, &oflag, if (getsockopt_winsock(
&size) == SOCKET_ERROR) { s->m_socket, IPPROTO_TCP, TCP_NODELAY, &oflag, &size) ==
SOCKET_ERROR) {
throwError(getsockerror_winsock()); throwError(getsockerror_winsock());
} }
@ -642,8 +662,9 @@ bool ArchNetworkWinsock::setReuseAddrOnSocket(ArchSocket s, bool reuse) {
// get old state // get old state
BOOL oflag; BOOL oflag;
int size = sizeof(oflag); int size = sizeof(oflag);
if (getsockopt_winsock(s->m_socket, SOL_SOCKET, SO_REUSEADDR, &oflag, if (getsockopt_winsock(
&size) == SOCKET_ERROR) { s->m_socket, SOL_SOCKET, SO_REUSEADDR, &oflag, &size) ==
SOCKET_ERROR) {
throwError(getsockerror_winsock()); throwError(getsockerror_winsock());
} }
@ -728,8 +749,8 @@ ArchNetworkWinsock::nameToAddr(const std::string &name) {
addresses.back()->m_len = (socklen_t)sizeof(struct sockaddr_in6); addresses.back()->m_len = (socklen_t)sizeof(struct sockaddr_in6);
} }
memcpy(&addresses.back()->m_addr, address->ai_addr, memcpy(
addresses.back()->m_len); &addresses.back()->m_addr, address->ai_addr, addresses.back()->m_len);
} }
freeaddrinfo(pResult); freeaddrinfo(pResult);
@ -748,8 +769,9 @@ std::string ArchNetworkWinsock::addrToName(ArchNetAddress addr) {
char host[1024]; char host[1024];
char service[20]; char service[20];
int ret = getnameinfo(TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, int ret = getnameinfo(
sizeof(host), service, sizeof(service), 0); TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, sizeof(host),
service, sizeof(service), 0);
if (ret != NULL) { if (ret != NULL) {
throwNameError(ret); throwNameError(ret);
@ -846,13 +868,15 @@ bool ArchNetworkWinsock::isAnyAddr(ArchNetAddress addr) {
switch (getAddrFamily(addr)) { switch (getAddrFamily(addr)) {
case kINET: { case kINET: {
struct sockaddr_in *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); struct sockaddr_in *ipAddr = TYPED_ADDR(struct sockaddr_in, addr);
return (addr->m_len == sizeof(struct sockaddr_in) && return (
addr->m_len == sizeof(struct sockaddr_in) &&
ipAddr->sin_addr.s_addr == INADDR_ANY); ipAddr->sin_addr.s_addr == INADDR_ANY);
} }
case kINET6: { case kINET6: {
struct sockaddr_in6 *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); struct sockaddr_in6 *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr);
return (addr->m_len == sizeof(struct sockaddr_in) && return (
addr->m_len == sizeof(struct sockaddr_in) &&
memcmp(&ipAddr->sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0); memcmp(&ipAddr->sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0);
} }
@ -863,8 +887,9 @@ bool ArchNetworkWinsock::isAnyAddr(ArchNetAddress addr) {
} }
bool ArchNetworkWinsock::isEqualAddr(ArchNetAddress a, ArchNetAddress b) { bool ArchNetworkWinsock::isEqualAddr(ArchNetAddress a, ArchNetAddress b) {
return (a == b || (a->m_len == b->m_len && return (
memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0)); a == b ||
(a->m_len == b->m_len && memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0));
} }
void ArchNetworkWinsock::throwError(int err) { void ArchNetworkWinsock::throwError(int err) {

View file

@ -85,8 +85,8 @@ std::string ArchSystemWindows::setting(const std::string &valueName) const {
return ArchMiscWindows::readValueString(key, valueName.c_str()); return ArchMiscWindows::readValueString(key, valueName.c_str());
} }
void ArchSystemWindows::setting(const std::string &valueName, void ArchSystemWindows::setting(
const std::string &valueString) const { const std::string &valueName, const std::string &valueString) const {
HKEY key = ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_settingsKeyNames); HKEY key = ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_settingsKeyNames);
if (key == NULL) if (key == NULL)
throw XArch(std::string("could not access registry key: ") + valueName); throw XArch(std::string("could not access registry key: ") + valueName);

View file

@ -32,8 +32,8 @@ public:
virtual std::string getOSName() const; virtual std::string getOSName() const;
virtual std::string getPlatformName() const; virtual std::string getPlatformName() const;
virtual std::string setting(const std::string &valueName) const; virtual std::string setting(const std::string &valueName) const;
virtual void setting(const std::string &valueName, virtual void
const std::string &valueString) const; setting(const std::string &valueName, const std::string &valueString) const;
bool isWOW64() const; bool isWOW64() const;
}; };

View file

@ -39,8 +39,13 @@ static const UINT kFirstReceiverID = WM_USER + 14;
ArchTaskBarWindows *ArchTaskBarWindows::s_instance = NULL; ArchTaskBarWindows *ArchTaskBarWindows::s_instance = NULL;
ArchTaskBarWindows::ArchTaskBarWindows() ArchTaskBarWindows::ArchTaskBarWindows()
: m_mutex(NULL), m_condVar(NULL), m_ready(false), m_result(0), : m_mutex(NULL),
m_thread(NULL), m_hwnd(NULL), m_taskBarRestart(0), m_condVar(NULL),
m_ready(false),
m_result(0),
m_thread(NULL),
m_hwnd(NULL),
m_taskBarRestart(0),
m_nextID(kFirstReceiverID) { m_nextID(kFirstReceiverID) {
// save the singleton instance // save the singleton instance
s_instance = this; s_instance = this;
@ -256,8 +261,8 @@ void ArchTaskBarWindows::removeIconNoLock(UINT id) {
} }
} }
void ArchTaskBarWindows::handleIconMessage(IArchTaskBarReceiver *receiver, void ArchTaskBarWindows::handleIconMessage(
LPARAM lParam) { IArchTaskBarReceiver *receiver, LPARAM lParam) {
// process message // process message
switch (lParam) { switch (lParam) {
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
@ -375,9 +380,8 @@ ArchTaskBarWindows::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
return DefWindowProc(hwnd, msg, wParam, lParam); return DefWindowProc(hwnd, msg, wParam, lParam);
} }
LRESULT CALLBACK ArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg, LRESULT CALLBACK ArchTaskBarWindows::staticWndProc(
WPARAM wParam, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
LPARAM lParam) {
// if msg is WM_NCCREATE, extract the ArchTaskBarWindows* and put // if msg is WM_NCCREATE, extract the ArchTaskBarWindows* and put
// it in the extra window data then forward the call. // it in the extra window data then forward the call.
ArchTaskBarWindows *self = NULL; ArchTaskBarWindows *self = NULL;
@ -385,8 +389,8 @@ LRESULT CALLBACK ArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg,
CREATESTRUCT *createInfo; CREATESTRUCT *createInfo;
createInfo = reinterpret_cast<CREATESTRUCT *>(lParam); createInfo = reinterpret_cast<CREATESTRUCT *>(lParam);
self = static_cast<ArchTaskBarWindows *>(createInfo->lpCreateParams); self = static_cast<ArchTaskBarWindows *>(createInfo->lpCreateParams);
SetWindowLongPtr(hwnd, 0, SetWindowLongPtr(
reinterpret_cast<LONG_PTR>(createInfo->lpCreateParams)); hwnd, 0, reinterpret_cast<LONG_PTR>(createInfo->lpCreateParams));
} else { } else {
// get the extra window data and forward the call // get the extra window data and forward the call
LONG_PTR data = GetWindowLongPtr(hwnd, 0); LONG_PTR data = GetWindowLongPtr(hwnd, 0);
@ -425,9 +429,9 @@ void ArchTaskBarWindows::threadMainLoop() {
ATOM windowClass = RegisterClassEx(&classInfo); ATOM windowClass = RegisterClassEx(&classInfo);
// create window // create window
m_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW, className, TEXT("Synergy Task Bar"), m_hwnd = CreateWindowEx(
WS_POPUP, 0, 0, 1, 1, NULL, NULL, instanceWin32(), WS_EX_TOOLWINDOW, className, TEXT("Synergy Task Bar"), WS_POPUP, 0, 0, 1,
static_cast<void *>(this)); 1, NULL, NULL, instanceWin32(), static_cast<void *>(this));
// signal ready // signal ready
ARCH->lockMutex(m_mutex); ARCH->lockMutex(m_mutex);

View file

@ -74,8 +74,8 @@ private:
void updateIcon(UINT); void updateIcon(UINT);
void addAllIcons(); void addAllIcons();
void removeAllIcons(); void removeAllIcons();
void modifyIconNoLock(ReceiverToInfoMap::const_iterator, void
DWORD taskBarMessage); modifyIconNoLock(ReceiverToInfoMap::const_iterator, DWORD taskBarMessage);
void removeIconNoLock(UINT id); void removeIconNoLock(UINT id);
void handleIconMessage(IArchTaskBarReceiver *, LPARAM); void handleIconMessage(IArchTaskBarReceiver *, LPARAM);

View file

@ -26,11 +26,11 @@
std::string XArchEvalWindows::eval() const throw() { std::string XArchEvalWindows::eval() const throw() {
char *cmsg; char *cmsg;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | if (FormatMessage(
FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM, FORMAT_MESSAGE_FROM_SYSTEM,
0, m_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 0, m_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&cmsg,
(LPTSTR)&cmsg, 0, NULL) == 0) { 0, NULL) == 0) {
cmsg = NULL; cmsg = NULL;
return synergy::string::sprintf("Unknown error, code %d", m_error); return synergy::string::sprintf("Unknown error, code %d", m_error);
} }

View file

@ -24,19 +24,28 @@
// //
Event::Event() Event::Event()
: m_type(kUnknown), m_target(NULL), m_data(NULL), m_flags(0), : m_type(kUnknown),
m_target(NULL),
m_data(NULL),
m_flags(0),
m_dataObject(nullptr) { m_dataObject(nullptr) {
// do nothing // do nothing
} }
Event::Event(Type type, void *target, void *data, Flags flags) Event::Event(Type type, void *target, void *data, Flags flags)
: m_type(type), m_target(target), m_data(data), m_flags(flags), : m_type(type),
m_target(target),
m_data(data),
m_flags(flags),
m_dataObject(nullptr) { m_dataObject(nullptr) {
// do nothing // do nothing
} }
Event::Event(Type type, void *target, EventData *dataObject) Event::Event(Type type, void *target, EventData *dataObject)
: m_type(type), m_target(target), m_data(nullptr), m_flags(kNone), : m_type(type),
m_target(target),
m_data(nullptr),
m_flags(kNone),
m_dataObject(dataObject) {} m_dataObject(dataObject) {}
Event::Type Event::getType() const { return m_type; } Event::Type Event::getType() const { return m_type; }

View file

@ -60,16 +60,28 @@ static void interrupt(Arch::ESignal, void *data) {
// //
EventQueue::EventQueue() EventQueue::EventQueue()
: m_systemTarget(0), m_nextType(Event::kLast), m_typesForClient(NULL), : m_systemTarget(0),
m_typesForIStream(NULL), m_typesForIpcClient(NULL), m_nextType(Event::kLast),
m_typesForIpcClientProxy(NULL), m_typesForIpcServer(NULL), m_typesForClient(NULL),
m_typesForIpcServerProxy(NULL), m_typesForIDataSocket(NULL), m_typesForIStream(NULL),
m_typesForIListenSocket(NULL), m_typesForISocket(NULL), m_typesForIpcClient(NULL),
m_typesForOSXScreen(NULL), m_typesForClientListener(NULL), m_typesForIpcClientProxy(NULL),
m_typesForClientProxy(NULL), m_typesForClientProxyUnknown(NULL), m_typesForIpcServer(NULL),
m_typesForServer(NULL), m_typesForServerApp(NULL), m_typesForIpcServerProxy(NULL),
m_typesForIKeyState(NULL), m_typesForIPrimaryScreen(NULL), m_typesForIDataSocket(NULL),
m_typesForIScreen(NULL), m_typesForClipboard(NULL), m_typesForFile(NULL), m_typesForIListenSocket(NULL),
m_typesForISocket(NULL),
m_typesForOSXScreen(NULL),
m_typesForClientListener(NULL),
m_typesForClientProxy(NULL),
m_typesForClientProxyUnknown(NULL),
m_typesForServer(NULL),
m_typesForServerApp(NULL),
m_typesForIKeyState(NULL),
m_typesForIPrimaryScreen(NULL),
m_typesForIScreen(NULL),
m_typesForClipboard(NULL),
m_typesForFile(NULL),
m_readyMutex(new Mutex), m_readyMutex(new Mutex),
m_readyCondVar(new CondVar<bool>(m_readyMutex, false)) { m_readyCondVar(new CondVar<bool>(m_readyMutex, false)) {
m_mutex = ARCH->newMutex(); m_mutex = ARCH->newMutex();
@ -328,8 +340,8 @@ void EventQueue::deleteTimer(EventQueueTimer *timer) {
m_buffer->deleteTimer(timer); m_buffer->deleteTimer(timer);
} }
void EventQueue::adoptHandler(Event::Type type, void *target, void EventQueue::adoptHandler(
IEventJob *handler) { Event::Type type, void *target, IEventJob *handler) {
ArchMutexLock lock(m_mutex); ArchMutexLock lock(m_mutex);
IEventJob *&job = m_handlers[target][type]; IEventJob *&job = m_handlers[target][type];
delete job; delete job;
@ -508,9 +520,13 @@ void EventQueue::waitForReady() const {
// EventQueue::Timer // EventQueue::Timer
// //
EventQueue::Timer::Timer(EventQueueTimer *timer, double timeout, EventQueue::Timer::Timer(
double initialTime, void *target, bool oneShot) EventQueueTimer *timer, double timeout, double initialTime, void *target,
: m_timer(timer), m_timeout(timeout), m_target(target), m_oneShot(oneShot), bool oneShot)
: m_timer(timer),
m_timeout(timeout),
m_target(target),
m_oneShot(oneShot),
m_time(initialTime) { m_time(initialTime) {
assert(m_timeout > 0.0); assert(m_timeout > 0.0);
} }

Some files were not shown because too many files have changed in this diff Show more