deskflow/src/gui/src/ServerConfig.cpp

558 lines
16 KiB
C++
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* synergy -- mouse and keyboard sharing utility
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
* Copyright (C) 2012 Symless Ltd.
2012-06-10 16:50:54 +00:00
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
2012-06-10 16:50:54 +00:00
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
2012-06-10 16:50:54 +00:00
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ServerConfig.h"
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
#include "AddClientDialog.h"
2012-06-10 16:50:54 +00:00
#include "Hotkey.h"
#include "MainWindow.h"
#include "gui/ConfigScopes.h"
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
#include "gui/constants.h"
2012-06-10 16:50:54 +00:00
#include <QAbstractButton>
#include <QMessageBox>
#include <QPushButton>
#include <QtCore>
2012-06-10 16:50:54 +00:00
static const struct {
int x;
int y;
const char *name;
} neighbourDirs[] = {
{1, 0, "right"},
{-1, 0, "left"},
{0, -1, "up"},
{0, 1, "down"},
2012-06-10 16:50:54 +00:00
};
const int serverDefaultIndex = 7;
2012-06-10 16:50:54 +00:00
ServerConfig::ServerConfig(
int numColumns, int numRows, AppConfig *appConfig, MainWindow *mainWindow)
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
: m_pAppConfig(appConfig),
m_pMainWindow(mainWindow),
m_Screens(numColumns),
m_NumColumns(numColumns),
m_NumRows(numRows),
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
m_ClipboardSharingSize(defaultClipboardSharingSize()) {
appConfig->scopes().registerReceiver(this);
2012-06-10 16:50:54 +00:00
}
ServerConfig::~ServerConfig() {
try {
ServerConfig::saveSettings();
} catch (const std::exception &e) {
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
qDebug() << e.what();
m_pMainWindow->appendLogError(e.what());
}
2012-06-10 16:50:54 +00:00
}
bool ServerConfig::save(const QString &fileName) const {
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
2012-06-10 16:50:54 +00:00
save(file);
file.close();
2012-06-10 16:50:54 +00:00
return true;
2012-06-10 16:50:54 +00:00
}
bool ServerConfig::operator==(const ServerConfig &sc) const {
return m_Screens == sc.m_Screens && m_NumColumns == sc.m_NumColumns &&
m_NumRows == sc.m_NumRows && m_HasHeartbeat == sc.m_HasHeartbeat &&
m_Heartbeat == sc.m_Heartbeat &&
m_RelativeMouseMoves == sc.m_RelativeMouseMoves &&
m_Win32KeepForeground == sc.m_Win32KeepForeground &&
m_HasSwitchDelay == sc.m_HasSwitchDelay &&
m_SwitchDelay == sc.m_SwitchDelay &&
m_HasSwitchDoubleTap == sc.m_HasSwitchDoubleTap &&
m_SwitchDoubleTap == sc.m_SwitchDoubleTap &&
m_SwitchCornerSize == sc.m_SwitchCornerSize &&
m_SwitchCorners == sc.m_SwitchCorners && m_Hotkeys == sc.m_Hotkeys &&
m_pAppConfig == sc.m_pAppConfig &&
m_EnableDragAndDrop == sc.m_EnableDragAndDrop &&
m_DisableLockToScreen == sc.m_DisableLockToScreen &&
m_ClipboardSharing == sc.m_ClipboardSharing &&
m_ClipboardSharingSize == sc.m_ClipboardSharingSize &&
m_pMainWindow == sc.m_pMainWindow;
}
void ServerConfig::save(QFile &file) const {
QTextStream outStream(&file);
outStream << *this;
2012-06-10 16:50:54 +00:00
}
void ServerConfig::init() {
switchCorners().clear();
screens().clear();
hotkeys().clear();
2012-06-10 16:50:54 +00:00
// m_NumSwitchCorners is used as a fixed size array. See Screen::init()
for (int i = 0; i < NumSwitchCorners; i++)
switchCorners() << false;
2012-06-10 16:50:54 +00:00
// There must always be screen objects for each cell in the screens QList.
// Unused screens are identified by having an empty name.
for (int i = 0; i < numColumns() * numRows(); i++)
addScreen(Screen());
2012-06-10 16:50:54 +00:00
}
void ServerConfig::saveSettings() {
settings().beginGroup("internalConfig");
settings().remove("");
settings().setValue("numColumns", numColumns());
settings().setValue("numRows", numRows());
settings().setValue("hasHeartbeat", hasHeartbeat());
settings().setValue("heartbeat", heartbeat());
settings().setValue("relativeMouseMoves", relativeMouseMoves());
settings().setValue("win32KeepForeground", win32KeepForeground());
settings().setValue("hasSwitchDelay", hasSwitchDelay());
settings().setValue("switchDelay", switchDelay());
settings().setValue("hasSwitchDoubleTap", hasSwitchDoubleTap());
settings().setValue("switchDoubleTap", switchDoubleTap());
settings().setValue("switchCornerSize", switchCornerSize());
settings().setValue("disableLockToScreen", disableLockToScreen());
settings().setValue("enableDragAndDrop", enableDragAndDrop());
settings().setValue("clipboardSharing", clipboardSharing());
settings().setValue(
"clipboardSharingSize", QVariant::fromValue(clipboardSharingSize()));
if (!getClientAddress().isEmpty()) {
settings().setValue("clientAddress", getClientAddress());
}
writeSettings(settings(), switchCorners(), "switchCorner");
settings().beginWriteArray("screens");
for (int i = 0; i < screens().size(); i++) {
settings().setArrayIndex(i);
auto &screen = screens()[i];
screen.saveSettings(settings());
if (screen.isServer() && m_pAppConfig->screenName() != screen.name()) {
m_pAppConfig->setScreenName(screen.name());
}
}
settings().endArray();
settings().beginWriteArray("hotkeys");
for (int i = 0; i < hotkeys().size(); i++) {
settings().setArrayIndex(i);
hotkeys()[i].saveSettings(settings());
}
settings().endArray();
settings().endGroup();
2012-06-10 16:50:54 +00:00
}
void ServerConfig::loadSettings() {
settings().beginGroup("internalConfig");
setNumColumns(settings().value("numColumns", 5).toInt());
setNumRows(settings().value("numRows", 3).toInt());
// we need to know the number of columns and rows before we can set up
// ourselves
init();
haveHeartbeat(settings().value("hasHeartbeat", false).toBool());
setHeartbeat(settings().value("heartbeat", 5000).toInt());
setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool());
setWin32KeepForeground(
settings().value("win32KeepForeground", false).toBool());
haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool());
setSwitchDelay(settings().value("switchDelay", 250).toInt());
haveSwitchDoubleTap(settings().value("hasSwitchDoubleTap", false).toBool());
setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt());
setSwitchCornerSize(settings().value("switchCornerSize").toInt());
setDisableLockToScreen(
settings().value("disableLockToScreen", false).toBool());
setEnableDragAndDrop(settings().value("enableDragAndDrop", false).toBool());
setClipboardSharingSize(
settings()
.value(
"clipboardSharingSize",
(int)ServerConfig::defaultClipboardSharingSize())
.toULongLong());
setClipboardSharing(settings().value("clipboardSharing", true).toBool());
setClientAddress(settings().value("clientAddress", "").toString());
readSettings(
settings(), switchCorners(), "switchCorner", false, NumSwitchCorners);
int numScreens = settings().beginReadArray("screens");
Q_ASSERT(numScreens <= screens().size());
for (int i = 0; i < numScreens; i++) {
settings().setArrayIndex(i);
screens()[i].loadSettings(settings());
if (getServerName() == screens()[i].name()) {
screens()[i].markAsServer();
}
}
settings().endArray();
int numHotkeys = settings().beginReadArray("hotkeys");
for (int i = 0; i < numHotkeys; i++) {
settings().setArrayIndex(i);
Hotkey h;
h.loadSettings(settings());
hotkeys().append(h);
}
settings().endArray();
settings().endGroup();
2012-06-10 16:50:54 +00:00
}
int ServerConfig::adjacentScreenIndex(
int idx, int deltaColumn, int deltaRow) const {
if (screens()[idx].isNull())
return -1;
2012-06-10 16:50:54 +00:00
// if we're at the left or right end of the table, don't find results going
// further left or right
if ((deltaColumn > 0 && (idx + 1) % numColumns() == 0) ||
(deltaColumn < 0 && idx % numColumns() == 0))
return -1;
2012-06-10 16:50:54 +00:00
int arrayPos = idx + deltaColumn + deltaRow * numColumns();
2012-06-10 16:50:54 +00:00
if (arrayPos >= screens().size() || arrayPos < 0)
return -1;
2012-06-10 16:50:54 +00:00
return arrayPos;
2012-06-10 16:50:54 +00:00
}
QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config) {
outStream << "section: screens" << Qt::endl;
2012-06-10 16:50:54 +00:00
foreach (const Screen &s, config.screens())
if (!s.isNull())
s.writeScreensSection(outStream);
2012-06-10 16:50:54 +00:00
outStream << "end" << Qt::endl << Qt::endl;
2012-06-10 16:50:54 +00:00
outStream << "section: aliases" << Qt::endl;
2012-06-10 16:50:54 +00:00
foreach (const Screen &s, config.screens())
if (!s.isNull())
s.writeAliasesSection(outStream);
2012-06-10 16:50:54 +00:00
outStream << "end" << Qt::endl << Qt::endl;
2012-06-10 16:50:54 +00:00
outStream << "section: links" << Qt::endl;
2012-06-10 16:50:54 +00:00
for (int i = 0; i < config.screens().size(); i++)
if (!config.screens()[i].isNull()) {
outStream << "\t" << config.screens()[i].name() << ":" << Qt::endl;
2012-06-10 16:50:54 +00:00
for (unsigned int j = 0;
j < sizeof(neighbourDirs) / sizeof(neighbourDirs[0]); j++) {
int idx = config.adjacentScreenIndex(
i, neighbourDirs[j].x, neighbourDirs[j].y);
if (idx != -1 && !config.screens()[idx].isNull())
outStream << "\t\t" << neighbourDirs[j].name << " = "
<< config.screens()[idx].name() << Qt::endl;
}
}
outStream << "end" << Qt::endl << Qt::endl;
outStream << "section: options" << Qt::endl;
if (config.hasHeartbeat())
outStream << "\t"
<< "heartbeat = " << config.heartbeat() << Qt::endl;
outStream << "\t"
<< "relativeMouseMoves = "
<< (config.relativeMouseMoves() ? "true" : "false") << Qt::endl;
outStream << "\t"
<< "win32KeepForeground = "
<< (config.win32KeepForeground() ? "true" : "false") << Qt::endl;
outStream << "\t"
<< "disableLockToScreen = "
<< (config.disableLockToScreen() ? "true" : "false") << Qt::endl;
outStream << "\t"
<< "clipboardSharing = "
<< (config.clipboardSharing() ? "true" : "false") << Qt::endl;
outStream << "\t"
<< "clipboardSharingSize = " << config.clipboardSharingSize()
<< Qt::endl;
if (!config.getClientAddress().isEmpty()) {
outStream << "\t"
<< "clientAddress = " << config.getClientAddress() << Qt::endl;
}
if (config.hasSwitchDelay())
outStream << "\t"
<< "switchDelay = " << config.switchDelay() << Qt::endl;
if (config.hasSwitchDoubleTap())
outStream << "\t"
<< "switchDoubleTap = " << config.switchDoubleTap() << Qt::endl;
outStream << "\t"
<< "switchCorners = none ";
for (int i = 0; i < config.switchCorners().size(); i++)
if (config.switchCorners()[i])
outStream << "+" << config.switchCornerName(i) << " ";
outStream << Qt::endl;
outStream << "\t"
<< "switchCornerSize = " << config.switchCornerSize() << Qt::endl;
foreach (const Hotkey &hotkey, config.hotkeys())
outStream << hotkey;
outStream << "end" << Qt::endl << Qt::endl;
return outStream;
2012-06-10 16:50:54 +00:00
}
int ServerConfig::numScreens() const {
int rval = 0;
2012-06-10 16:50:54 +00:00
foreach (const Screen &s, screens())
if (!s.isNull())
rval++;
2012-06-10 16:50:54 +00:00
return rval;
2012-06-10 16:50:54 +00:00
}
int ServerConfig::autoAddScreen(const QString name) {
int serverIndex = -1;
int targetIndex = -1;
if (!findScreenName(m_pAppConfig->screenName(), serverIndex) &&
!fixNoServer(m_pAppConfig->screenName(), serverIndex)) {
return kAutoAddScreenManualServer;
}
if (findScreenName(name, targetIndex)) {
m_pMainWindow->appendLogDebug(
QString("ignoring screen already in config: %1").arg(name));
return kAutoAddScreenIgnore;
}
int result = showAddClientDialog(name);
if (result == kAddClientIgnore) {
return kAutoAddScreenIgnore;
}
if (result == kAddClientOther) {
addToFirstEmptyGrid(name);
return kAutoAddScreenManualClient;
}
bool success = false;
int startIndex = serverIndex;
int offset = 1;
int dirIndex = 0;
if (result == kAddClientLeft) {
offset = -1;
dirIndex = 1;
} else if (result == kAddClientUp) {
offset = -5;
dirIndex = 2;
} else if (result == kAddClientDown) {
offset = 5;
dirIndex = 3;
}
int idx = adjacentScreenIndex(
startIndex, neighbourDirs[dirIndex].x, neighbourDirs[dirIndex].y);
while (idx != -1) {
if (screens()[idx].isNull()) {
m_Screens[idx].setName(name);
success = true;
break;
}
startIndex += offset;
idx = adjacentScreenIndex(
startIndex, neighbourDirs[dirIndex].x, neighbourDirs[dirIndex].y);
}
if (!success) {
addToFirstEmptyGrid(name);
return kAutoAddScreenManualClient;
}
saveSettings();
return kAutoAddScreenOk;
}
const QString &ServerConfig::getServerName() const {
return m_pAppConfig->screenName();
}
void ServerConfig::updateServerName() {
for (auto &screen : screens()) {
if (screen.isServer()) {
screen.setName(m_pAppConfig->screenName());
saveSettings();
break;
}
}
}
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
const QString &ServerConfig::configFile() const {
return m_pAppConfig->configFile();
}
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 ServerConfig::useExternalConfig() const {
return m_pAppConfig->useExternalConfig();
}
bool ServerConfig::isFull() const {
bool isFull = true;
for (const auto &screen : screens()) {
if (screen.isNull()) {
isFull = false;
break;
}
}
return isFull;
}
bool ServerConfig::isScreenExists(const QString &screenName) const {
bool isExists = false;
for (const auto &screen : screens()) {
if (!screen.isNull() && screen.name() == screenName) {
isExists = true;
break;
}
}
return isExists;
}
void ServerConfig::addClient(const QString &clientName) {
int serverIndex = -1;
if (findScreenName(m_pAppConfig->screenName(), serverIndex)) {
m_Screens[serverIndex].markAsServer();
} else {
fixNoServer(m_pAppConfig->screenName(), serverIndex);
}
m_Screens.addScreenByPriority(clientName);
2021-05-18 10:05:59 +00:00
}
void ServerConfig::setConfigFile(const QString &configFile) {
m_pAppConfig->setConfigFile(configFile);
}
void ServerConfig::setUseExternalConfig(bool useExternalConfig) {
m_pAppConfig->setUseExternalConfig(useExternalConfig);
}
bool ServerConfig::findScreenName(const QString &name, int &index) {
bool found = false;
for (int i = 0; i < screens().size(); i++) {
if (!screens()[i].isNull() && screens()[i].name().compare(name) == 0) {
index = i;
found = true;
break;
}
}
return found;
}
bool ServerConfig::fixNoServer(const QString &name, int &index) {
bool fixed = false;
if (screens()[serverDefaultIndex].isNull()) {
m_Screens[serverDefaultIndex].setName(name);
m_Screens[serverDefaultIndex].markAsServer();
index = serverDefaultIndex;
fixed = true;
}
return fixed;
}
int ServerConfig::showAddClientDialog(const QString &clientName) {
int result = kAddClientIgnore;
if (!m_pMainWindow->isActiveWindow()) {
m_pMainWindow->showNormal();
m_pMainWindow->activateWindow();
}
AddClientDialog addClientDialog(clientName, m_pMainWindow);
addClientDialog.exec();
result = addClientDialog.addResult();
return result;
}
void ::ServerConfig::addToFirstEmptyGrid(const QString &clientName) {
for (int i = 0; i < screens().size(); i++) {
if (screens()[i].isNull()) {
m_Screens[i].setName(clientName);
break;
}
}
}
size_t ServerConfig::defaultClipboardSharingSize() {
return 3 * 1024; // 3 MiB
}
size_t ServerConfig::setClipboardSharingSize(size_t size) {
if (size) {
size += 512; // Round up to the nearest megabyte
size /= 1024;
size *= 1024;
setClipboardSharing(true);
} else {
setClipboardSharing(false);
}
using std::swap;
swap(size, m_ClipboardSharingSize);
return size;
}
void ServerConfig::setClientAddress(const QString &address) {
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
if (m_pAppConfig->invertConnection()) {
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
m_ClientAddress = address;
}
}
QString ServerConfig::getClientAddress() const {
QString clientAddress;
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
if (m_pAppConfig->invertConnection()) {
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
clientAddress = m_ClientAddress.trimmed();
}
return clientAddress;
}
QSettings &ServerConfig::settings() {
return *m_pAppConfig->scopes().currentSettings();
}