diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-11-22 16:20:36 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2025-02-25 16:52:01 +0100 |
commit | cf1bc662e42cfd91bcd82138c0ca5211b1ac75c7 (patch) | |
tree | c665e76751d3e097cfcd279a479317d7b8141aba /vncviewer | |
parent | 803bdb558f13c9000a3cc4818ce3391baeb043bd (diff) | |
download | tigervnc-cf1bc662e42cfd91bcd82138c0ca5211b1ac75c7.tar.gz tigervnc-cf1bc662e42cfd91bcd82138c0ca5211b1ac75c7.zip |
Move configuration to core library
Make it clearer what is protocol handling and what is just general
plumbing.
This is one step of several.
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/MonitorIndicesParameter.h | 4 | ||||
-rw-r--r-- | vncviewer/parameters.cxx | 321 | ||||
-rw-r--r-- | vncviewer/parameters.h | 81 | ||||
-rw-r--r-- | vncviewer/vncviewer.cxx | 4 |
4 files changed, 234 insertions, 176 deletions
diff --git a/vncviewer/MonitorIndicesParameter.h b/vncviewer/MonitorIndicesParameter.h index d91c84fe..fa6a2045 100644 --- a/vncviewer/MonitorIndicesParameter.h +++ b/vncviewer/MonitorIndicesParameter.h @@ -22,9 +22,9 @@ #include <set> #include <vector> -#include <rfb/Configuration.h> +#include <core/Configuration.h> -class MonitorIndicesParameter: public rfb::StringParameter { +class MonitorIndicesParameter: public core::StringParameter { public: MonitorIndicesParameter(const char* name_, const char* desc_, const char* v); std::set<int> getParam(); diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index 0af990e9..ce402785 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -55,125 +55,180 @@ using namespace std; static LogWriter vlog("Parameters"); - -IntParameter pointerEventInterval("PointerEventInterval", - "Time in milliseconds to rate-limit" - " successive pointer events", 17); -BoolParameter emulateMiddleButton("EmulateMiddleButton", - "Emulate middle mouse button by pressing " - "left and right mouse buttons simultaneously", - false); -BoolParameter dotWhenNoCursor("DotWhenNoCursor", - "[DEPRECATED] Show the dot cursor when the server sends an " - "invisible cursor", false); -BoolParameter alwaysCursor("AlwaysCursor", - "Show the local cursor when the server sends an " - "invisible cursor", false); -StringParameter cursorType("CursorType", - "Specify which cursor type the local cursor should be. " - "Should be either Dot or System", - "Dot"); - -BoolParameter alertOnFatalError("AlertOnFatalError", - "Give a dialog on connection problems rather " - "than exiting immediately", true); - -BoolParameter reconnectOnError("ReconnectOnError", - "Give a dialog on connection problems rather " - "than exiting immediately and ask for a reconnect.", true); - -StringParameter passwordFile("PasswordFile", - "Password file for VNC authentication", ""); -AliasParameter passwd("passwd", "Alias for PasswordFile", &passwordFile); - -BoolParameter autoSelect("AutoSelect", - "Auto select pixel format and encoding. " - "Default if PreferredEncoding and FullColor are not specified.", - true); -BoolParameter fullColour("FullColor", - "Use full color", true); -AliasParameter fullColourAlias("FullColour", "Alias for FullColor", &fullColour); -IntParameter lowColourLevel("LowColorLevel", - "Color level to use on slow connections. " - "0 = Very Low, 1 = Low, 2 = Medium", 2); -AliasParameter lowColourLevelAlias("LowColourLevel", "Alias for LowColorLevel", &lowColourLevel); -StringParameter preferredEncoding("PreferredEncoding", - "Preferred encoding to use (Tight, ZRLE, Hextile or" - " Raw)", "Tight"); -BoolParameter customCompressLevel("CustomCompressLevel", - "Use custom compression level. " - "Default if CompressLevel is specified.", false); -IntParameter compressLevel("CompressLevel", - "Use specified compression level 0 = Low, 9 = High", - 2); -BoolParameter noJpeg("NoJPEG", - "Disable lossy JPEG compression in Tight encoding.", - false); -IntParameter qualityLevel("QualityLevel", - "JPEG quality level. 0 = Low, 9 = High", - 8); - -BoolParameter maximize("Maximize", "Maximize viewer window", false); -BoolParameter fullScreen("FullScreen", "Enable full screen", false); -StringParameter fullScreenMode("FullScreenMode", "Specify which monitors to use when in full screen. " - "Should be either Current, Selected or All", - "Current"); -BoolParameter fullScreenAllMonitors("FullScreenAllMonitors", - "[DEPRECATED] Enable full screen over all monitors", - false); -MonitorIndicesParameter fullScreenSelectedMonitors("FullScreenSelectedMonitors", - "Use the given list of monitors in full screen" - " when -FullScreenMode=Selected.", - "1"); -StringParameter desktopSize("DesktopSize", - "Reconfigure desktop size on the server on " - "connect (if possible)", ""); -StringParameter geometry("geometry", - "Specify size and position of viewer window", ""); - -BoolParameter listenMode("listen", "Listen for connections from VNC servers", false); - -BoolParameter remoteResize("RemoteResize", - "Dynamically resize the remote desktop size as " - "the size of the local client window changes. " - "(Does not work with all servers)", true); - -BoolParameter viewOnly("ViewOnly", - "Don't send any mouse or keyboard events to the server", - false); -BoolParameter shared("Shared", - "Don't disconnect other viewers upon connection - " - "share the desktop instead", - false); - -BoolParameter acceptClipboard("AcceptClipboard", - "Accept clipboard changes from the server", - true); -BoolParameter sendClipboard("SendClipboard", - "Send clipboard changes to the server", true); +core::IntParameter + pointerEventInterval("PointerEventInterval", + "Time in milliseconds to rate-limit successive " + "pointer events", + 17); +core::BoolParameter + emulateMiddleButton("EmulateMiddleButton", + "Emulate middle mouse button by pressing left " + "and right mouse buttons simultaneously", + false); +core::BoolParameter + dotWhenNoCursor("DotWhenNoCursor", + "[DEPRECATED] Show the dot cursor when the server " + "sends an invisible cursor", + false); +core::BoolParameter + alwaysCursor("AlwaysCursor", + "Show the local cursor when the server sends an " + "invisible cursor", + false); +core::StringParameter + cursorType("CursorType", + "Specify which cursor type the local cursor should be. " + "Should be either Dot or System", + "Dot"); + +core::BoolParameter + alertOnFatalError("AlertOnFatalError", + "Give a dialog on connection problems rather than " + "exiting immediately", + true); + +core::BoolParameter + reconnectOnError("ReconnectOnError", + "Give a dialog on connection problems rather than " + "exiting immediately and ask for a reconnect.", + true); + +core::StringParameter + passwordFile("PasswordFile", + "Password file for VNC authentication", + ""); +core::AliasParameter + passwd("passwd", "Alias for PasswordFile", &passwordFile); + +core::BoolParameter + autoSelect("AutoSelect", + "Auto select pixel format and encoding. Default if " + "PreferredEncoding and FullColor are not specified.", + true); +core::BoolParameter + fullColour("FullColor", "Use full color", true); +core::AliasParameter + fullColourAlias("FullColour", "Alias for FullColor", &fullColour); +core::IntParameter + lowColourLevel("LowColorLevel", + "Color level to use on slow connections. " + "0 = Very Low, 1 = Low, 2 = Medium", + 2); +core::AliasParameter + lowColourLevelAlias("LowColourLevel", + "Alias for LowColorLevel", &lowColourLevel); +core::StringParameter + preferredEncoding("PreferredEncoding", + "Preferred encoding to use (Tight, ZRLE, Hextile " + "or Raw)", + "Tight"); +core::BoolParameter + customCompressLevel("CustomCompressLevel", + "Use custom compression level. Default if " + "CompressLevel is specified.", + false); +core::IntParameter + compressLevel("CompressLevel", + "Use specified compression level 0 = Low, 9 = High", + 2); +core::BoolParameter + noJpeg("NoJPEG", + "Disable lossy JPEG compression in Tight encoding.", + false); +core::IntParameter + qualityLevel("QualityLevel", + "JPEG quality level. 0 = Low, 9 = High", + 8); + +core::BoolParameter + maximize("Maximize", "Maximize viewer window", false); +core::BoolParameter + fullScreen("FullScreen", "Enable full screen", false); +core::StringParameter + fullScreenMode("FullScreenMode", + "Specify which monitors to use when in full screen. " + "Should be either Current, Selected or All", + "Current"); +core::BoolParameter + fullScreenAllMonitors("FullScreenAllMonitors", + "[DEPRECATED] Enable full screen over all " + "monitors", + false); +MonitorIndicesParameter + fullScreenSelectedMonitors("FullScreenSelectedMonitors", + "Use the given list of monitors in full " + "screen when -FullScreenMode=Selected.", + "1"); +core::StringParameter + desktopSize("DesktopSize", + "Reconfigure desktop size on the server on connect (if " + "possible)", + ""); +core::StringParameter + geometry("geometry", + "Specify size and position of viewer window", + ""); + +core::BoolParameter + listenMode("listen", + "Listen for connections from VNC servers", + false); + +core::BoolParameter + remoteResize("RemoteResize", + "Dynamically resize the remote desktop size as the size " + "of the local client window changes. (Does not work " + "with all servers)", + true); + +core::BoolParameter + viewOnly("ViewOnly", + "Don't send any mouse or keyboard events to the server", + false); +core::BoolParameter + shared("Shared", + "Don't disconnect other viewers upon connection - " + "share the desktop instead", + false); + +core::BoolParameter + acceptClipboard("AcceptClipboard", + "Accept clipboard changes from the server", + true); +core::BoolParameter + sendClipboard("SendClipboard", + "Send clipboard changes to the server", + true); #if !defined(WIN32) && !defined(__APPLE__) -BoolParameter setPrimary("SetPrimary", - "Set the primary selection as well as the " - "clipboard selection", true); -BoolParameter sendPrimary("SendPrimary", - "Send the primary selection to the " - "server as well as the clipboard selection", - true); -StringParameter display("display", - "Specifies the X display on which the VNC viewer window should appear.", - ""); +core::BoolParameter + setPrimary("SetPrimary", + "Set the primary selection as well as the clipboard " + "selection", + true); +core::BoolParameter + sendPrimary("SendPrimary", + "Send the primary selection to the server as well as the " + "clipboard selection", + true); +core::StringParameter + display("display", + "Specifies the X display on which the VNC viewer window " + "should appear.", + ""); #endif -StringParameter menuKey("MenuKey", "The key which brings up the popup menu", - "F8"); +core::StringParameter + menuKey("MenuKey", "The key which brings up the popup menu", "F8"); -BoolParameter fullscreenSystemKeys("FullscreenSystemKeys", - "Pass special keys (like Alt+Tab) directly " - "to the server when in full-screen mode.", - true); +core::BoolParameter + fullscreenSystemKeys("FullscreenSystemKeys", + "Pass special keys (like Alt+Tab) directly to " + "the server when in full-screen mode.", + true); #ifndef WIN32 -StringParameter via("via", "Gateway to tunnel via", ""); +core::StringParameter + via("via", "Gateway to tunnel via", ""); #endif static const char* IDENTIFIER_STRING = "TigerVNC Configuration file Version 1.0"; @@ -182,7 +237,7 @@ static const char* IDENTIFIER_STRING = "TigerVNC Configuration file Version 1.0" * We only save the sub set of parameters that can be modified from * the graphical user interface */ -static VoidParameter* parameterArray[] = { +static core::VoidParameter* parameterArray[] = { /* Security */ #ifdef HAVE_GNUTLS &CSecurityTLS::X509CA, @@ -220,7 +275,7 @@ static VoidParameter* parameterArray[] = { &fullscreenSystemKeys }; -static VoidParameter* readOnlyParameterArray[] = { +static core::VoidParameter* readOnlyParameterArray[] = { &fullScreenAllMonitors, &dotWhenNoCursor }; @@ -480,9 +535,9 @@ static void saveToReg(const char* servername) { _("Failed to save \"%s\": %s"), "ServerName", e.what())); } - for (VoidParameter* param : parameterArray) { - IntParameter* iparam; - BoolParameter* bparam; + for (core::VoidParameter* param : parameterArray) { + core::IntParameter* iparam; + core::BoolParameter* bparam; if (param->isDefault()) { try { @@ -496,8 +551,8 @@ static void saveToReg(const char* servername) { continue; } - iparam = dynamic_cast<IntParameter*>(param); - bparam = dynamic_cast<BoolParameter*>(param); + iparam = dynamic_cast<core::IntParameter*>(param); + bparam = dynamic_cast<core::BoolParameter*>(param); try { if (iparam != nullptr) { @@ -518,7 +573,7 @@ static void saveToReg(const char* servername) { // Remove read-only parameters to replicate the behaviour of Linux/macOS when they // store a config to disk. If the parameter hasn't been migrated at this point it // will be lost. - for (VoidParameter* param : readOnlyParameterArray) { + for (core::VoidParameter* param : readOnlyParameterArray) { try { removeValue(param->getName(), &hKey); } catch (std::exception& e) { @@ -579,7 +634,7 @@ list<string> loadHistoryFromRegKey() { return serverHistory; } -static void getParametersFromReg(VoidParameter* parameters[], +static void getParametersFromReg(core::VoidParameter* parameters[], size_t parameters_len, HKEY* hKey) { const size_t buffersize = 256; @@ -587,11 +642,11 @@ static void getParametersFromReg(VoidParameter* parameters[], char stringValue[buffersize]; for (size_t i = 0; i < parameters_len; i++) { - IntParameter* iparam; - BoolParameter* bparam; + core::IntParameter* iparam; + core::BoolParameter* bparam; - iparam = dynamic_cast<IntParameter*>(parameters[i]); - bparam = dynamic_cast<BoolParameter*>(parameters[i]); + iparam = dynamic_cast<core::IntParameter*>(parameters[i]); + bparam = dynamic_cast<core::BoolParameter*>(parameters[i]); try { if (iparam != nullptr) { @@ -642,11 +697,12 @@ static char* loadFromReg() { } getParametersFromReg(parameterArray, - sizeof(parameterArray) / sizeof(VoidParameter*), + sizeof(parameterArray) / + sizeof(core::VoidParameter*), &hKey); getParametersFromReg(readOnlyParameterArray, sizeof(readOnlyParameterArray) / - sizeof(VoidParameter*), + sizeof(core::VoidParameter*), &hKey); res = RegCloseKey(hKey); @@ -698,7 +754,7 @@ void saveViewerParameters(const char *filename, const char *servername) { } fprintf(f, "ServerName=%s\n", encodingBuffer); - for (VoidParameter* param : parameterArray) { + for (core::VoidParameter* param : parameterArray) { if (param->isDefault()) continue; if (!encodeValue(param->getValueStr().c_str(), @@ -714,7 +770,7 @@ void saveViewerParameters(const char *filename, const char *servername) { } static bool findAndSetViewerParameterFromValue( - VoidParameter* parameters[], size_t parameters_len, + core::VoidParameter* parameters[], size_t parameters_len, char* value, char* line) { const size_t buffersize = 256; @@ -843,13 +899,14 @@ char* loadViewerParameters(const char *filename) { } else { invalidParameterName = findAndSetViewerParameterFromValue( parameterArray, - sizeof(parameterArray) / sizeof(VoidParameter *), + sizeof(parameterArray) / sizeof(core::VoidParameter *), value, line); if (invalidParameterName) { invalidParameterName = findAndSetViewerParameterFromValue( readOnlyParameterArray, - sizeof(readOnlyParameterArray) / sizeof(VoidParameter *), + sizeof(readOnlyParameterArray) / + sizeof(core::VoidParameter *), value, line); } } diff --git a/vncviewer/parameters.h b/vncviewer/parameters.h index f9ee28fa..36b07241 100644 --- a/vncviewer/parameters.h +++ b/vncviewer/parameters.h @@ -20,7 +20,8 @@ #ifndef __PARAMETERS_H__ #define __PARAMETERS_H__ -#include <rfb/Configuration.h> +#include <core/Configuration.h> + #include "MonitorIndicesParameter.h" #ifdef _WIN32 @@ -31,55 +32,55 @@ #define SERVER_HISTORY_SIZE 20 -extern rfb::IntParameter pointerEventInterval; -extern rfb::BoolParameter emulateMiddleButton; -extern rfb::BoolParameter dotWhenNoCursor; // deprecated -extern rfb::BoolParameter alwaysCursor; -extern rfb::StringParameter cursorType; - -extern rfb::StringParameter passwordFile; - -extern rfb::BoolParameter autoSelect; -extern rfb::BoolParameter fullColour; -extern rfb::AliasParameter fullColourAlias; -extern rfb::IntParameter lowColourLevel; -extern rfb::AliasParameter lowColourLevelAlias; -extern rfb::StringParameter preferredEncoding; -extern rfb::BoolParameter customCompressLevel; -extern rfb::IntParameter compressLevel; -extern rfb::BoolParameter noJpeg; -extern rfb::IntParameter qualityLevel; - -extern rfb::BoolParameter maximize; -extern rfb::BoolParameter fullScreen; -extern rfb::StringParameter fullScreenMode; -extern rfb::BoolParameter fullScreenAllMonitors; // deprecated +extern core::IntParameter pointerEventInterval; +extern core::BoolParameter emulateMiddleButton; +extern core::BoolParameter dotWhenNoCursor; // deprecated +extern core::BoolParameter alwaysCursor; +extern core::StringParameter cursorType; + +extern core::StringParameter passwordFile; + +extern core::BoolParameter autoSelect; +extern core::BoolParameter fullColour; +extern core::AliasParameter fullColourAlias; +extern core::IntParameter lowColourLevel; +extern core::AliasParameter lowColourLevelAlias; +extern core::StringParameter preferredEncoding; +extern core::BoolParameter customCompressLevel; +extern core::IntParameter compressLevel; +extern core::BoolParameter noJpeg; +extern core::IntParameter qualityLevel; + +extern core::BoolParameter maximize; +extern core::BoolParameter fullScreen; +extern core::StringParameter fullScreenMode; +extern core::BoolParameter fullScreenAllMonitors; // deprecated extern MonitorIndicesParameter fullScreenSelectedMonitors; -extern rfb::StringParameter desktopSize; -extern rfb::StringParameter geometry; -extern rfb::BoolParameter remoteResize; +extern core::StringParameter desktopSize; +extern core::StringParameter geometry; +extern core::BoolParameter remoteResize; -extern rfb::BoolParameter listenMode; +extern core::BoolParameter listenMode; -extern rfb::BoolParameter viewOnly; -extern rfb::BoolParameter shared; +extern core::BoolParameter viewOnly; +extern core::BoolParameter shared; -extern rfb::BoolParameter acceptClipboard; -extern rfb::BoolParameter setPrimary; -extern rfb::BoolParameter sendClipboard; +extern core::BoolParameter acceptClipboard; +extern core::BoolParameter setPrimary; +extern core::BoolParameter sendClipboard; #if !defined(WIN32) && !defined(__APPLE__) -extern rfb::BoolParameter sendPrimary; -extern rfb::StringParameter display; +extern core::BoolParameter sendPrimary; +extern core::StringParameter display; #endif -extern rfb::StringParameter menuKey; +extern core::StringParameter menuKey; -extern rfb::BoolParameter fullscreenSystemKeys; -extern rfb::BoolParameter alertOnFatalError; -extern rfb::BoolParameter reconnectOnError; +extern core::BoolParameter fullscreenSystemKeys; +extern core::BoolParameter alertOnFatalError; +extern core::BoolParameter reconnectOnError; #ifndef WIN32 -extern rfb::StringParameter via; +extern core::StringParameter via; #endif void saveViewerParameters(const char *filename, const char *servername=nullptr); diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index dd252625..db4c43b9 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -478,7 +478,7 @@ static void usage(const char *programName) "Other valid forms are <param>=<value> -<param>=<value> " "--<param>=<value>\n" "Parameter names are case-insensitive. The parameters are:\n\n")); - Configuration::listParams(79, 14); + core::Configuration::listParams(79, 14); #ifdef WIN32 // Just wait for the user to kill the console window @@ -683,7 +683,7 @@ int main(int argc, char** argv) for (int i = 1; i < argc;) { int ret; - ret = Configuration::handleParamArg(argc, argv, i); + ret = core::Configuration::handleParamArg(argc, argv, i); if (ret > 0) { i += ret; continue; |