Make it possible to load and save configuration files. Also, when
connecting, the options are saved as default settings. This patch
fixes SF bugs 3481470 and 3499216.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4950 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index fd1243e..79d7935 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -43,6 +43,7 @@
#endif
#include <rfb/LogWriter.h>
#include <rfb/Timer.h>
+#include <rfb/Exception.h>
#include <network/TcpSocket.h>
#include <os/os.h>
@@ -307,6 +308,14 @@
Configuration::enableViewerParams();
+ /* Load the default parameter settings */
+ const char* defaultServerName;
+ try {
+ defaultServerName = loadViewerParameters(NULL);
+ } catch (rfb::Exception& e) {
+ fl_alert("%s", e.str());
+ }
+
int i = 1;
if (!Fl::args(argc, argv, i) || i < argc)
for (; i < argc; i++) {
@@ -328,9 +337,10 @@
if (!::autoSelect.hasBeenSet()) {
// Default to AutoSelect=0 if -PreferredEncoding or -FullColor is used
- ::autoSelect.setParam(!::preferredEncoding.hasBeenSet() &&
- !::fullColour.hasBeenSet() &&
- !::fullColourAlias.hasBeenSet());
+ if (::preferredEncoding.hasBeenSet() || ::fullColour.hasBeenSet() ||
+ ::fullColourAlias.hasBeenSet()) {
+ ::autoSelect.setParam(false);
+ }
}
if (!::fullColour.hasBeenSet() && !::fullColourAlias.hasBeenSet()) {
// Default to FullColor=0 if AutoSelect=0 && LowColorLevel is set
@@ -341,7 +351,9 @@
}
if (!::customCompressLevel.hasBeenSet()) {
// Default to CustomCompressLevel=1 if CompressLevel is used.
- ::customCompressLevel.setParam(::compressLevel.hasBeenSet());
+ if(::compressLevel.hasBeenSet()) {
+ ::customCompressLevel.setParam(true);
+ }
}
mkvnchomedir();
@@ -352,7 +364,7 @@
#endif
if (vncServerName == NULL) {
- vncServerName = ServerDialog::run();
+ vncServerName = ServerDialog::run(defaultServerName);
if ((vncServerName == NULL) || (vncServerName[0] == '\0'))
return 1;
}