Revision: 4216
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4216&view=rev
Author:   atkac
Date:     2010-12-08 13:47:41 +0000 (Wed, 08 Dec 2010)

Log Message:
-----------
[Development] Add glue code for -SecurityTypes option and GUI Security dialog.

Modified Paths:
--------------
    trunk/win/vncviewer/CConn.cxx
    trunk/win/vncviewer/CConn.h
    trunk/win/vncviewer/OptionsDialog.cxx

Modified: trunk/win/vncviewer/CConn.cxx
===================================================================
--- trunk/win/vncviewer/CConn.cxx       2010-12-08 13:45:40 UTC (rev 4215)
+++ trunk/win/vncviewer/CConn.cxx       2010-12-08 13:47:41 UTC (rev 4216)
@@ -16,6 +16,10 @@
  * USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <winsock2.h>
 #include <vncviewer/UserPasswdDialog.h>
 #include <vncviewer/CConn.h>
@@ -25,6 +29,9 @@
 #include <rfb/Security.h>
 #include <rfb/CMsgWriter.h>
 #include <rfb/Configuration.h>
+#ifdef HAVE_GNUTLS
+#include <rfb/CSecurityTLS.h>
+#endif
 #include <rfb/LogWriter.h>
 #include <rfb_win32/AboutDialog.h>
 
@@ -97,6 +104,9 @@
   applyOptions(options);
 
   CSecurity::upg = this;
+#ifdef HAVE_GNUTLS
+  CSecurityTLS::msg = this;
+#endif
 
   // Start the RFB protocol
   sock = s;
@@ -473,7 +483,35 @@
   sock->shutdown();
 }
 
+bool CConn::showMsgBox(int flags, const char* title, const char* text)
+{
+  UINT winflags = 0;
+  int ret;
 
+  /* Translate flags */
+  if ((flags & M_OK) != 0)
+    winflags |= MB_OK;
+  if ((flags & M_OKCANCEL) != 0)
+    winflags |= MB_OKCANCEL;
+  if ((flags & M_YESNO) != 0)
+    winflags |= MB_YESNO;
+  if ((flags & M_ICONERROR) != 0)
+    winflags |= MB_ICONERROR;
+  if ((flags & M_ICONQUESTION) != 0)
+    winflags |= MB_ICONQUESTION;
+  if ((flags & M_ICONWARNING) != 0)
+    winflags |= MB_ICONWARNING;
+  if ((flags & M_ICONINFORMATION) != 0)
+    winflags |= MB_ICONINFORMATION;
+  if ((flags & M_DEFBUTTON1) != 0)
+    winflags |= MB_DEFBUTTON1;
+  if ((flags & M_DEFBUTTON2) != 0)
+    winflags |= MB_DEFBUTTON2;
+
+  ret = MessageBox(NULL, text, title, flags);
+  return (ret == IDOK || ret == IDYES) ? true : false;
+}
+
 void
 CConn::showOptionsDialog() {
   optionsDialog.showDialog(this);

Modified: trunk/win/vncviewer/CConn.h
===================================================================
--- trunk/win/vncviewer/CConn.h 2010-12-08 13:45:40 UTC (rev 4215)
+++ trunk/win/vncviewer/CConn.h 2010-12-08 13:47:41 UTC (rev 4216)
@@ -26,6 +26,7 @@
 #include <network/Socket.h>
 #include <rfb/CConnection.h>
 #include <rfb/Cursor.h>
+#include <rfb/UserMsgBox.h>
 #include <rfb/UserPasswdGetter.h>
 #include <rfb_win32/Registry.h>
 #include <rfb_win32/Handle.h>
@@ -43,7 +44,8 @@
     class CConn : public CConnection,
                   UserPasswdGetter,
                   DesktopWindow::Callback,
-                  rdr::FdInStreamBlockCallback
+                  rdr::FdInStreamBlockCallback,
+                  UserMsgBox
     {
     public:
       CConn();
@@ -77,6 +79,9 @@
       // - Get the server's preferred format
       const PixelFormat& getServerDefaultPF() const { return serverDefaultPF; }
 
+      // - Display message box
+      virtual bool showMsgBox(int flags, const char* title, const char* text);
+
       // Global user-config registry key
       static RegKey userConfigKey;
 

Modified: trunk/win/vncviewer/OptionsDialog.cxx
===================================================================
--- trunk/win/vncviewer/OptionsDialog.cxx       2010-12-08 13:45:40 UTC (rev 
4215)
+++ trunk/win/vncviewer/OptionsDialog.cxx       2010-12-08 13:47:41 UTC (rev 
4216)
@@ -354,6 +354,8 @@
   OptionsInfo* dlg;
 };
 
+#ifdef HAVE_GNUTLS
+/* XXX: This class contains bunch of similar code to unix/vncviewer/CConn.cxx 
*/
 class SecurityPage : public PropSheetPage {
 public:
   SecurityPage(OptionsInfo* dlg_, Security *security_)
@@ -369,18 +371,18 @@
 
     for (i = secTypes.begin(); i != secTypes.end(); i++) {
       switch (*i) {
-        case secTypeVeNCrypt:
-          enableVeNCryptFeatures(true);
-         setItemChecked(IDC_VENCRYPT, true);
-          break;
-        case secTypeNone:
-          setItemChecked(IDC_ENC_NONE, true);
-          setItemChecked(IDC_AUTH_NONE, true);
-          break;
-        case secTypeVncAuth:
-          setItemChecked(IDC_ENC_NONE, true);
-          setItemChecked(IDC_AUTH_VNC, true);
-          break;
+      case secTypeVeNCrypt:
+        enableVeNCryptFeatures(true);
+        setItemChecked(IDC_VENCRYPT, true);
+        break;
+      case secTypeNone:
+        setItemChecked(IDC_ENC_NONE, true);
+        setItemChecked(IDC_AUTH_NONE, true);
+        break;
+      case secTypeVncAuth:
+        setItemChecked(IDC_ENC_NONE, true);
+        setItemChecked(IDC_AUTH_VNC, true);
+        break;
       }
     }
 
@@ -428,34 +430,126 @@
       }
     }
   }
+
   virtual bool onCommand(int id, int cmd) {
     switch (id) {
     case IDC_VENCRYPT:
-      enableVeNCryptFeatures(isItemChecked(IDC_VENCRYPT));
+      if (isItemChecked(IDC_VENCRYPT)) {
+        enableVeNCryptFeatures(true);
+        security->EnableSecType(secTypeVeNCrypt);
+      } else {
+        enableVeNCryptFeatures(false);
+        security->DisableSecType(secTypeVeNCrypt);
+      }
       break;
+
+    /* Process types without encryption */
     case IDC_ENC_NONE:
+      if (isItemChecked(IDC_ENC_NONE)) {
+      vlog.debug("here");
+        if (isItemChecked(IDC_AUTH_NONE))
+          security->EnableSecType(secTypeNone);
+        if (isItemChecked(IDC_AUTH_VNC))
+          security->EnableSecType(secTypeVncAuth);
+        if (isItemChecked(IDC_AUTH_PLAIN))
+          security->EnableSecType(secTypePlain);
+      } else {
+        security->DisableSecType(secTypeNone);
+        security->DisableSecType(secTypeVncAuth); 
+        security->DisableSecType(secTypePlain);
+      }
       break;
+
+    /* Process security types which use TLS encryption */
     case IDC_ENC_TLS:
+      if (isItemChecked(IDC_ENC_TLS)) {
+        if (isItemChecked(IDC_AUTH_NONE))
+          security->EnableSecType(secTypeTLSNone);
+        if (isItemChecked(IDC_AUTH_VNC))
+          security->EnableSecType(secTypeTLSVnc);
+        if (isItemChecked(IDC_AUTH_PLAIN))
+          security->EnableSecType(secTypeTLSPlain);
+      } else {
+        security->DisableSecType(secTypeTLSNone);
+        security->DisableSecType(secTypeTLSVnc);
+        security->DisableSecType(secTypeTLSPlain);
+      } 
       break;
+
+    /* Process security types which use X509 encryption */
     case IDC_ENC_X509:
       if (isItemChecked(IDC_ENC_X509)) {
         enableItem(IDC_LOAD_CACERT, true);
         enableItem(IDC_LOAD_CRLCERT, true);
+        if (isItemChecked(IDC_AUTH_NONE))
+          security->EnableSecType(secTypeX509None);
+        if (isItemChecked(IDC_AUTH_VNC))
+          security->EnableSecType(secTypeX509Vnc);
+        if (isItemChecked(IDC_AUTH_PLAIN))
+          security->EnableSecType(secTypeX509Plain);
       } else {
         enableItem(IDC_LOAD_CACERT, false);
         enableItem(IDC_LOAD_CRLCERT, false);
+        security->DisableSecType(secTypeX509None);
+        security->DisableSecType(secTypeX509Vnc);
+        security->DisableSecType(secTypeX509Plain);
       }
       break;
+
     case IDC_LOAD_CACERT:
       break;
+
     case IDC_LOAD_CRLCERT:
       break;
+
+    /* Process *None security types */
     case IDC_AUTH_NONE:
+      if (isItemChecked(IDC_AUTH_NONE)) {
+        if (isItemChecked(IDC_ENC_NONE))
+          security->EnableSecType(secTypeNone);
+        if (isItemChecked(IDC_ENC_TLS))
+          security->EnableSecType(secTypeTLSNone);
+        if (isItemChecked(IDC_ENC_X509))
+          security->EnableSecType(secTypeX509None);
+      } else {
+        security->DisableSecType(secTypeNone);
+        security->DisableSecType(secTypeTLSNone);
+        security->DisableSecType(secTypeX509None);
+      }
       break;
+
+    /* Process *Vnc security types */
     case IDC_AUTH_VNC:
+      if (isItemChecked(IDC_AUTH_VNC)) {
+        if (isItemChecked(IDC_ENC_NONE))
+          security->EnableSecType(secTypeVncAuth);
+        if (isItemChecked(IDC_ENC_TLS))
+          security->EnableSecType(secTypeTLSVnc);
+        if (isItemChecked(IDC_ENC_X509))
+          security->EnableSecType(secTypeX509Vnc);
+      } else {
+        security->DisableSecType(secTypeVncAuth);
+        security->DisableSecType(secTypeTLSVnc);
+        security->DisableSecType(secTypeX509Vnc);
+      }
       break;
+
+    /* Process *Plain security types */
     case IDC_AUTH_PLAIN:
+      if (isItemChecked(IDC_AUTH_PLAIN)) {
+        if (isItemChecked(IDC_ENC_NONE))
+          security->EnableSecType(secTypePlain);
+        if (isItemChecked(IDC_ENC_TLS))
+          security->EnableSecType(secTypeTLSPlain);
+        if (isItemChecked(IDC_ENC_X509))
+          security->EnableSecType(secTypeX509Plain);
+      } else {
+        security->DisableSecType(secTypePlain);
+        security->DisableSecType(secTypeTLSPlain);
+        security->DisableSecType(secTypeX509Plain);
+      }
       break;
+
     default:
       throw rdr::Exception("Unhandled action in SecurityPage");
     }
@@ -485,8 +579,8 @@
     setItemChecked(id, false);
   }
 };
+#endif
 
-
 OptionsDialog::OptionsDialog() : visible(false) {
 }
 
@@ -506,7 +600,9 @@
   InputsPage inputsPage(&info); pages.push_back(&inputsPage);
   MiscPage miscPage(&info); pages.push_back(&miscPage);
   DefaultsPage defPage(&info); if (view) pages.push_back(&defPage);
+#ifdef HAVE_GNUTLS
   SecurityPage secPage(&info, view->security); pages.push_back(&secPage);
+#endif
 
   // Show the property sheet
   ViewerOptions dialog(info, pages);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Tigervnc-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to