deskflow/src/lib/gui/config/ServerConfig.h

262 lines
5.4 KiB
C
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 Synergy App Ltd
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
2012-06-10 16:50:54 +00:00
*/
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
#pragma once
2012-06-10 16:50:54 +00:00
#include "common/Constants.h"
#include "common/NetworkProtocol.h"
#include "gui/Hotkey.h"
#include "gui/config/ScreenConfig.h"
#include "gui/config/ScreenList.h"
#include <QList>
2012-06-10 16:50:54 +00:00
const auto kDefaultRows = 3;
2012-06-10 16:50:54 +00:00
class QTextStream;
class QSettings;
class QString;
class QFile;
class ServerConfigDialog;
namespace deskflow::gui {
// The default protocol was decided by a community vote.
const auto kDefaultProtocol = NetworkProtocol::Barrier;
} // namespace deskflow::gui
class ServerConfig : public ScreenConfig
{
friend class ServerConfigDialog;
friend QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);
public:
explicit ServerConfig(int columns = kServerGridWidth, int rows = kDefaultRows);
~ServerConfig() = default;
bool operator==(const ServerConfig &sc) const;
const ScreenList &screens() const
{
return m_Screens;
}
//
// New methods
//
int numColumns() const
{
return m_Columns;
}
int numRows() const
{
return m_Rows;
}
bool hasHeartbeat() const
{
return m_HasHeartbeat;
}
int heartbeat() const
{
return m_Heartbeat;
}
NetworkProtocol protocol() const
{
return m_Protocol;
}
bool relativeMouseMoves() const
{
return m_RelativeMouseMoves;
}
bool win32KeepForeground() const
{
return m_Win32KeepForeground;
}
bool hasSwitchDelay() const
{
return m_HasSwitchDelay;
}
int switchDelay() const
{
return m_SwitchDelay;
}
bool hasSwitchDoubleTap() const
{
return m_HasSwitchDoubleTap;
}
int switchDoubleTap() const
{
return m_SwitchDoubleTap;
}
bool switchCorner(int c) const
{
return m_SwitchCorners[c];
}
int switchCornerSize() const
{
return m_SwitchCornerSize;
}
const QList<bool> &switchCorners() const
{
return m_SwitchCorners;
}
const HotkeyList &hotkeys() const
{
return m_Hotkeys;
}
bool defaultLockToScreenState() const
{
return m_DefaultLockToScreenState;
}
bool disableLockToScreen() const
{
return m_DisableLockToScreen;
}
bool clipboardSharing() const
{
return m_ClipboardSharing;
}
size_t clipboardSharingSize() const
{
return m_ClipboardSharingSize;
}
static size_t defaultClipboardSharingSize();
bool save(const QString &fileName) const;
bool screenExists(const QString &screenName) const;
void save(QFile &file) const;
bool isFull() const;
void commit();
int numScreens() const;
QString getServerName() const;
void updateServerName();
QString configFile() const;
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
bool useExternalConfig() const;
void addClient(const QString &clientName);
private:
void recall();
void setupScreens();
QSettingsProxy &settings();
ScreenList &screens()
{
return m_Screens;
}
void setScreens(const ScreenList &screens)
{
m_Screens = screens;
}
void addScreen(const Screen &screen)
{
m_Screens.append(screen);
}
void setNumColumns(int n)
{
m_Columns = n;
}
void setNumRows(int n)
{
m_Rows = n;
}
void haveHeartbeat(bool on)
{
m_HasHeartbeat = on;
}
void setHeartbeat(int val)
{
m_Heartbeat = val;
}
void setProtocol(NetworkProtocol val)
{
m_Protocol = val;
}
void setRelativeMouseMoves(bool on)
{
m_RelativeMouseMoves = on;
}
void setWin32KeepForeground(bool on)
{
m_Win32KeepForeground = on;
}
void haveSwitchDelay(bool on)
{
m_HasSwitchDelay = on;
}
void setSwitchDelay(int val)
{
m_SwitchDelay = val;
}
void haveSwitchDoubleTap(bool on)
{
m_HasSwitchDoubleTap = on;
}
void setSwitchDoubleTap(int val)
{
m_SwitchDoubleTap = val;
}
void setSwitchCorner(int c, bool on)
{
m_SwitchCorners[c] = on;
}
void setSwitchCornerSize(int val)
{
m_SwitchCornerSize = val;
}
void setDefaultLockToScreenState(bool on)
{
m_DefaultLockToScreenState = on;
}
void setDisableLockToScreen(bool on)
{
m_DisableLockToScreen = on;
}
void setClipboardSharing(bool on)
{
m_ClipboardSharing = on;
}
void setConfigFile(const QString &configFile) const;
void setUseExternalConfig(bool useExternalConfig) const;
size_t setClipboardSharingSize(size_t size);
QList<bool> &switchCorners()
{
return m_SwitchCorners;
}
HotkeyList &hotkeys()
{
return m_Hotkeys;
}
int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
bool findScreenName(const QString &name, int &index);
bool fixNoServer(const QString &name, int &index);
private:
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
bool m_HasHeartbeat = false;
int m_Heartbeat = 0;
NetworkProtocol m_Protocol = deskflow::gui::kDefaultProtocol;
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
bool m_RelativeMouseMoves = false;
bool m_Win32KeepForeground = false;
bool m_HasSwitchDelay = false;
int m_SwitchDelay = 0;
bool m_HasSwitchDoubleTap = false;
int m_SwitchDoubleTap = 0;
int m_SwitchCornerSize = 0;
bool m_DefaultLockToScreenState = false;
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
bool m_DisableLockToScreen = false;
bool m_ClipboardSharing = true;
QString m_ClientAddress = "";
QList<bool> m_SwitchCorners;
HotkeyList m_Hotkeys;
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
ScreenList m_Screens;
int m_Columns;
int m_Rows;
size_t m_ClipboardSharingSize = defaultClipboardSharingSize();
2012-06-10 16:50:54 +00:00
};
QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);