From: Adam Tkac Date: Tue, 1 Feb 2011 14:36:14 +0000 (+0000) Subject: [Development] Win vncviewer: use SecurityPage class for Security dialog X-Git-Tag: v1.0.90~71 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9fa84ffce44f2d5f4cd6db8216198f04cf5c42a6;p=tigervnc.git [Development] Win vncviewer: use SecurityPage class for Security dialog git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4247 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/win/vncviewer/OptionsDialog.cxx b/win/vncviewer/OptionsDialog.cxx index c7188e13..721b9b4f 100644 --- a/win/vncviewer/OptionsDialog.cxx +++ b/win/vncviewer/OptionsDialog.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -354,239 +355,39 @@ protected: OptionsInfo* dlg; }; -#ifdef HAVE_GNUTLS -/* XXX: This class contains bunch of similar code to unix/vncviewer/CConn.cxx */ -class SecurityPage : public PropSheetPage { +class SecPage : public SecurityPage { public: - SecurityPage(OptionsInfo* dlg_, Security *security_) - : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_SECURITY)), - dlg(dlg_), security(security_) { + SecPage(Security *security_, OptionsInfo *dlg_) + : SecurityPage(security_), dlg(dlg_) { } - virtual void initDialog() { - enableVeNCryptFeatures(false); - - /* Process non-VeNCrypt sectypes */ - list secTypes = security->GetEnabledSecTypes(); - list::iterator i; - - 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; - } - } - /* Process VeNCrypt subtypes */ - if (isItemChecked(IDC_VENCRYPT)) { - list secTypesExt = security->GetEnabledExtSecTypes(); - list::iterator iext; - for (iext = secTypesExt.begin(); iext != secTypesExt.end(); iext++) { - switch (*iext) { - case secTypePlain: - setItemChecked(IDC_ENC_NONE, true); - setItemChecked(IDC_AUTH_PLAIN, true); - break; - case secTypeTLSNone: - setItemChecked(IDC_ENC_TLS, true); - setItemChecked(IDC_AUTH_NONE, true); - break; - case secTypeTLSVnc: - setItemChecked(IDC_ENC_TLS, true); - setItemChecked(IDC_AUTH_VNC, true); - break; - case secTypeTLSPlain: - setItemChecked(IDC_ENC_TLS, true); - setItemChecked(IDC_AUTH_PLAIN, true); - break; - case secTypeX509None: - setItemChecked(IDC_ENC_X509, true); - setItemChecked(IDC_AUTH_NONE, true); - enableItem(IDC_LOAD_CACERT, true); - enableItem(IDC_LOAD_CRLCERT, true); - break; - case secTypeX509Vnc: - setItemChecked(IDC_ENC_X509, true); - setItemChecked(IDC_AUTH_VNC, true); - enableItem(IDC_LOAD_CACERT, true); - enableItem(IDC_LOAD_CRLCERT, true); - break; - case secTypeX509Plain: - setItemChecked(IDC_ENC_X509, true); - setItemChecked(IDC_AUTH_PLAIN, true); - enableItem(IDC_LOAD_CACERT, true); - enableItem(IDC_LOAD_CRLCERT, true); - break; - } - } - } + virtual void enableX509Dialogs() { + enableItem(IDC_LOAD_CACERT, true); + enableItem(IDC_LOAD_CRLCERT, true); + } + + virtual void disableX509Dialogs() { + enableItem(IDC_LOAD_CACERT, false); + enableItem(IDC_LOAD_CRLCERT, false); } virtual bool onOk() { + SecurityPage::onOk(); + dlg->options.secTypes = security->GetEnabledExtSecTypes(); + if (isItemChecked(IDC_VENCRYPT)) dlg->options.secTypes.push_front(secTypeVeNCrypt); + return true; } - virtual bool onCommand(int id, int cmd) { - switch (id) { - case 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; + virtual void loadX509Certs() {} + virtual void loadVncPasswd() {} - /* 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"); - } - return true; - } protected: OptionsInfo* dlg; -private: - Security *security; - - void enableVeNCryptFeatures(bool enable) { - if (enable) { - enableItem(IDC_ENC_TLS, true); - enableItem(IDC_ENC_X509, true); - enableItem(IDC_AUTH_PLAIN, true); - } else { - disableFeature(IDC_ENC_TLS); - disableFeature(IDC_ENC_X509); - disableFeature(IDC_AUTH_PLAIN); - enableItem(IDC_LOAD_CACERT, false); - enableItem(IDC_LOAD_CRLCERT, false); - } - } - - void disableFeature(int id) { - enableItem(id, false); - setItemChecked(id, false); - } }; -#endif OptionsDialog::OptionsDialog() : visible(false) { } @@ -607,9 +408,7 @@ bool OptionsDialog::showDialog(CConn* view, bool capture) { 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 + SecPage secPage(view->security, &info); pages.push_back(&secPage); // Show the property sheet ViewerOptions dialog(info, pages); diff --git a/win/vncviewer/resource.h b/win/vncviewer/resource.h index 03d9d766..efb977c1 100644 --- a/win/vncviewer/resource.h +++ b/win/vncviewer/resource.h @@ -1,7 +1,7 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. // Used by vncviewer.rc -// + +#include + #define IDR_MANIFEST 1 #define IDI_ICON 101 #define IDD_VNC_AUTH_DLG 102 @@ -16,7 +16,6 @@ #define IDR_TRAY 112 #define IDD_CONNECTION_INFO 113 #define IDD_DEFAULTS 116 -#define IDD_SECURITY 117 #define IDB_BITMAP 120 #define IDB_TOOLBAR 122 #define IDC_PASSWORD 1000 @@ -86,15 +85,8 @@ #define IDC_STATIC_SCALE 1097 #define IDC_COMBO_SCALE 1098 #define IDC_STATIC_PERCENT 1099 -#define IDC_VENCRYPT 1200 -#define IDC_ENC_NONE 1201 -#define IDC_ENC_TLS 1202 -#define IDC_ENC_X509 1203 -#define IDC_LOAD_CACERT 1204 -#define IDC_LOAD_CRLCERT 1205 -#define IDC_AUTH_NONE 1206 -#define IDC_AUTH_VNC 1207 -#define IDC_AUTH_PLAIN 1208 +#define IDC_LOAD_CACERT 1100 +#define IDC_LOAD_CRLCERT 1101 #define ID_TOOLBAR 4002 #define ID_CLOSE 4003 #define ID_OPTIONS 4004