Juan Lang : cryptui: Select export format based on input in CryptUIWizExport.
Alexandre Julliard
julliard at winehq.org
Tue Jan 27 09:06:54 CST 2009
Module: wine
Branch: master
Commit: 214045988fc21368303f72293039452565f913d7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=214045988fc21368303f72293039452565f913d7
Author: Juan Lang <juan.lang at gmail.com>
Date: Sat Jan 24 14:11:24 2009 -0800
cryptui: Select export format based on input in CryptUIWizExport.
---
dlls/cryptui/main.c | 53 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/dlls/cryptui/main.c b/dlls/cryptui/main.c
index 18d809f..d2c438e 100644
--- a/dlls/cryptui/main.c
+++ b/dlls/cryptui/main.c
@@ -5527,6 +5527,24 @@ static LRESULT CALLBACK export_welcome_dlg_proc(HWND hwnd, UINT msg, WPARAM wp,
return ret;
}
+static BOOL export_info_has_private_key(PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo)
+{
+ BOOL ret = FALSE;
+
+ if (pExportInfo->dwSubjectChoice == CRYPTUI_WIZ_EXPORT_CERT_CONTEXT)
+ {
+ DWORD size;
+
+ /* If there's a CRYPT_KEY_PROV_INFO set for this cert, assume the
+ * cert has a private key.
+ */
+ if (CertGetCertificateContextProperty(pExportInfo->u.pCertContext,
+ CERT_KEY_PROV_INFO_PROP_ID, NULL, &size))
+ ret = TRUE;
+ }
+ return ret;
+}
+
static LRESULT CALLBACK export_format_dlg_proc(HWND hwnd, UINT msg, WPARAM wp,
LPARAM lp)
{
@@ -5538,10 +5556,28 @@ static LRESULT CALLBACK export_format_dlg_proc(HWND hwnd, UINT msg, WPARAM wp,
case WM_INITDIALOG:
{
PROPSHEETPAGEW *page = (PROPSHEETPAGEW *)lp;
+ int defaultFormatID;
data = (struct ExportWizData *)page->lParam;
SetWindowLongPtrW(hwnd, DWLP_USER, (LPARAM)data);
- SendMessageW(GetDlgItem(hwnd, IDC_EXPORT_FORMAT_DER), BM_CLICK, 0, 0);
+ switch (data->contextInfo.dwExportFormat)
+ {
+ case CRYPTUI_WIZ_EXPORT_FORMAT_BASE64:
+ defaultFormatID = IDC_EXPORT_FORMAT_BASE64;
+ break;
+ case CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7:
+ defaultFormatID = IDC_EXPORT_FORMAT_CMS;
+ break;
+ case CRYPTUI_WIZ_EXPORT_FORMAT_PFX:
+ if (export_info_has_private_key(data->pExportInfo))
+ defaultFormatID = IDC_EXPORT_FORMAT_PFX;
+ else
+ defaultFormatID = IDC_EXPORT_FORMAT_DER;
+ break;
+ default:
+ defaultFormatID = IDC_EXPORT_FORMAT_DER;
+ }
+ SendMessageW(GetDlgItem(hwnd, defaultFormatID), BM_CLICK, 0, 0);
break;
}
case WM_NOTIFY:
@@ -5846,19 +5882,8 @@ static LRESULT CALLBACK export_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp,
data = (struct ExportWizData *)page->lParam;
SetWindowLongPtrW(hwnd, DWLP_USER, (LPARAM)data);
- if (data->pExportInfo->dwSubjectChoice ==
- CRYPTUI_WIZ_EXPORT_CERT_CONTEXT)
- {
- DWORD size;
-
- /* If there's a CRYPT_KEY_PROV_INFO set for this cert, assume the
- * cert has a private key.
- */
- if (CertGetCertificateContextProperty(
- data->pExportInfo->u.pCertContext, CERT_KEY_PROV_INFO_PROP_ID,
- NULL, &size))
- EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_FORMAT_PFX), TRUE);
- }
+ if (export_info_has_private_key(data->pExportInfo))
+ EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_FORMAT_PFX), TRUE);
break;
}
case WM_NOTIFY:
More information about the wine-cvs
mailing list