Added new parameter NoJPEG, hooked up with GUI


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@57 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/rfb/ConnParams.cxx b/rfb/ConnParams.cxx
index 3a406ac..33cd21d 100644
--- a/rfb/ConnParams.cxx
+++ b/rfb/ConnParams.cxx
@@ -28,7 +28,7 @@
 ConnParams::ConnParams()
   : majorVersion(0), minorVersion(0), width(0), height(0), useCopyRect(false),
     supportsLocalCursor(false), supportsDesktopResize(false),
-    supportsLastRect(false), qualityLevel(-1),
+    supportsLastRect(false), qualityLevel(-1), noJpeg(false),
     name_(0), nEncodings_(0), encodings_(0),
     currentEncoding_(encodingRaw), verStrPos(0)
 {
@@ -90,6 +90,7 @@
   supportsLocalCursor = false;
   supportsLastRect = false;
   qualityLevel = -1;
+  noJpeg = false;
   currentEncoding_ = encodingRaw;
 
   for (int i = nEncodings-1; i >= 0; i--) {
@@ -105,7 +106,7 @@
       supportsLastRect = true;
     else if (encodings[i] >= pseudoEncodingQualityLevel0 &&
              encodings[i] <= pseudoEncodingQualityLevel9)
-      qualityLevel = encodings[i] - pseudoEncodingQualityLevel0;
+	qualityLevel = encodings[i] - pseudoEncodingQualityLevel0;
     else if (encodings[i] <= encodingMax && Encoder::supported(encodings[i]))
       currentEncoding_ = encodings[i];
   }
diff --git a/rfb/ConnParams.h b/rfb/ConnParams.h
index 9946bd0..4d08b6d 100644
--- a/rfb/ConnParams.h
+++ b/rfb/ConnParams.h
@@ -74,6 +74,7 @@
     bool supportsLastRect;
 
     int qualityLevel;
+    bool noJpeg;
 
   private:
 
diff --git a/vncviewer/CViewOptions.cxx b/vncviewer/CViewOptions.cxx
index d4c647a..199ddb5 100644
--- a/vncviewer/CViewOptions.cxx
+++ b/vncviewer/CViewOptions.cxx
@@ -86,6 +86,10 @@
 				 "0 = Low, 9 = High",
 				 5);
 
+static BoolParameter noJpeg("NoJPEG",
+			    "Disable lossy JPEG compression in Tight encoding.",
+			    false);
+
 CViewOptions::CViewOptions()
 : useLocalCursor(::useLocalCursor), useDesktopResize(::useDesktopResize),
 autoSelect(::autoSelect), fullColour(::fullColour), fullScreen(::fullScreen),
@@ -93,7 +97,7 @@
 preferredEncoding(encodingZRLE), clientCutText(::clientCutText), serverCutText(::serverCutText),
 protocol3_3(::protocol3_3), acceptBell(::acceptBell), lowColourLevel(::lowColourLevel),
 pointerEventInterval(ptrEventInterval), emulate3(::emulate3), monitor(::monitor.getData()),
-qualityLevel(::qualityLevel)
+qualityLevel(::qualityLevel), noJpeg(::noJpeg)
 {
   CharArray encodingName(::preferredEncoding.getData());
   preferredEncoding = encodingNum(encodingName.buf);
@@ -195,7 +199,8 @@
             setMenuKey(value.buf);
           } else if (stricmp(name.buf, "QualityLevel") == 0) {
 	    qualityLevel = atoi(value.buf);
-
+          } else if (stricmp(name.buf, "NoJPEG") == 0) {
+	    noJpeg = atoi(value.buf);
             // Legacy options
           } else if (stricmp(name.buf, "Preferred_Encoding") == 0) {
             preferredEncoding = atoi(value.buf);
@@ -280,6 +285,7 @@
       fprintf(f, "Monitor=%s\n", monitor.buf);
     fprintf(f, "MenuKey=%s\n", CharArray(menuKeyName()).buf);
     fprintf(f, "QualityLevel=%d\n", qualityLevel);
+    fprintf(f, "NoJPEG=%d\n", noJpeg);
     fclose(f); f=0;
 
     setConfigFileName(filename);
@@ -313,6 +319,7 @@
     key.setString(_T("Monitor"), TStr(monitor.buf));
   key.setString(_T("MenuKey"), TCharArray(menuKeyName()).buf);
   key.setInt(_T("QualityLevel"), qualityLevel);
+  key.setInt(_T("NoJPEG"), noJpeg);
 }
 
 
@@ -368,5 +375,6 @@
   setMonitor(o.monitor.buf);
   menuKey = o.menuKey;
   qualityLevel = o.qualityLevel;
+  noJpeg = o.noJpeg;
   return *this;
 }
diff --git a/vncviewer/CViewOptions.h b/vncviewer/CViewOptions.h
index 31e4ead..88b659f 100644
--- a/vncviewer/CViewOptions.h
+++ b/vncviewer/CViewOptions.h
@@ -78,6 +78,7 @@
       void setMenuKey(const char* keyName);
       char* menuKeyName();
       int qualityLevel;
+      bool noJpeg;
     };
 
 
diff --git a/vncviewer/OptionsDialog.cxx b/vncviewer/OptionsDialog.cxx
index 49a19c3..4ff4600 100644
--- a/vncviewer/OptionsDialog.cxx
+++ b/vncviewer/OptionsDialog.cxx
@@ -93,12 +93,14 @@
     case encodingHextile: setItemChecked(IDC_ENCODING_HEXTILE, true); break;
     case encodingRaw: setItemChecked(IDC_ENCODING_RAW, true); break;
     }
+    setItemChecked(IDC_ALLOW_JPEG, !dlg->options.noJpeg);
     setItemInt(IDC_QUALITYLEVEL, dlg->options.qualityLevel);
     onCommand(IDC_ENCODING_AUTO, 0 /* ? */); // Force enableItem status to refresh
   }
   virtual bool onOk() {
     dlg->options.autoSelect = isItemChecked(IDC_ENCODING_AUTO);
     dlg->options.fullColour = isItemChecked(IDC_FORMAT_FULLCOLOUR);
+    dlg->options.noJpeg = !isItemChecked(IDC_ALLOW_JPEG);
     dlg->options.qualityLevel = getItemInt(IDC_QUALITYLEVEL);
     if (isItemChecked(IDC_FORMAT_VERYLOWCOLOUR))
       dlg->options.lowColourLevel = 0;
diff --git a/vncviewer/cview.cxx b/vncviewer/cview.cxx
index a9a15ff..ef0aa3e 100644
--- a/vncviewer/cview.cxx
+++ b/vncviewer/cview.cxx
@@ -253,6 +253,7 @@
   cp.supportsLocalCursor = options.useLocalCursor = opt.useLocalCursor;
   cp.supportsDesktopResize = options.useDesktopResize = opt.useDesktopResize;
   cp.qualityLevel = options.qualityLevel = opt.qualityLevel;
+  cp.noJpeg = options.noJpeg = opt.noJpeg;
   if (cursorAvailable)
     hideLocalCursor();
   cursorAvailable = cursorAvailable && options.useLocalCursor;