cryptui: Show (empty) certificate dialog.
This commit is contained in:
parent
104b366d07
commit
20dfbb3d64
|
@ -3,13 +3,15 @@ TOPOBJDIR = ../..
|
|||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
MODULE = cryptui.dll
|
||||
IMPORTS = crypt32 kernel32
|
||||
IMPORTS = crypt32 comctl32 user32 kernel32
|
||||
DELAYIMPORTS = wintrust
|
||||
IMPORTLIB = cryptui
|
||||
|
||||
C_SRCS = \
|
||||
main.c
|
||||
|
||||
RC_SRCS = cryptui.rc
|
||||
|
||||
@MAKE_DLL_RULES@
|
||||
|
||||
@DEPENDENCIES@ # everything below this line is overwritten by make depend
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* cryptui dll resources
|
||||
*
|
||||
* Copyright 2008 Juan Lang
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "commctrl.h"
|
||||
#include "dlgs.h"
|
||||
|
||||
#include "cryptuires.h"
|
||||
|
||||
#include "cryptui_En.rc"
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* cryptui dll resources
|
||||
*
|
||||
* Copyright 2008 Juan Lang
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
{
|
||||
IDS_CERTIFICATE "Certificate"
|
||||
}
|
||||
|
||||
IDD_GENERAL DIALOG DISCARDABLE 0, 0, 255, 236
|
||||
CAPTION "General"
|
||||
STYLE WS_VISIBLE
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
CONTROL "", IDC_STATIC, "Static", WS_BORDER|SS_WHITERECT, 6,10,241,200
|
||||
CONTROL "", IDC_CERTIFICATE_ICON,"RichEdit20W",
|
||||
ES_READONLY|WS_DISABLED,8,11,26,26
|
||||
CONTROL "", IDC_CERTIFICATE_INFO,"RichEdit20W",
|
||||
ES_READONLY|WS_DISABLED,34,11,212,26
|
||||
CONTROL "", IDC_STATIC, "Static", SS_BLACKFRAME, 16,37,222,1
|
||||
CONTROL "", IDC_CERTIFICATE_STATUS,"RichEdit20W",
|
||||
ES_READONLY|ES_MULTILINE|WS_DISABLED,8,38,238,78
|
||||
CONTROL "", IDC_STATIC, "Static", SS_BLACKFRAME, 16,116,222,1
|
||||
CONTROL "", IDC_CERTIFICATE_NAMES,"RichEdit20W",
|
||||
ES_READONLY|ES_MULTILINE|WS_DISABLED,8,117,238,91
|
||||
PUSHBUTTON "&Install Certificate...", IDC_ADDTOSTORE,103,216,70,14
|
||||
PUSHBUTTON "Issuer &Statement", IDC_ISSUERSTATEMENT,177,216,70,14
|
||||
END
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2008 Juan Lang
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
#ifndef __CRYPTUIRES_H_
|
||||
#define __CRYPTUIRES_H_
|
||||
|
||||
#define IDS_CERTIFICATE 1000
|
||||
|
||||
#define IDD_GENERAL 100
|
||||
|
||||
#define IDC_STATIC 2000
|
||||
#define IDC_CERTIFICATE_ICON 2001
|
||||
#define IDC_CERTIFICATE_INFO 2002
|
||||
#define IDC_CERTIFICATE_STATUS 2003
|
||||
#define IDC_CERTIFICATE_NAMES 2004
|
||||
#define IDC_ADDTOSTORE 2005
|
||||
#define IDC_ISSUERSTATEMENT 2006
|
||||
|
||||
#endif /* ndef __CRYPTUIRES_H_ */
|
|
@ -28,10 +28,13 @@
|
|||
#include "winuser.h"
|
||||
#include "softpub.h"
|
||||
#include "cryptuiapi.h"
|
||||
#include "cryptuires.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(cryptui);
|
||||
|
||||
static HINSTANCE hInstance;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
||||
|
@ -41,6 +44,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
case DLL_WINE_PREATTACH:
|
||||
return FALSE; /* prefer native version */
|
||||
case DLL_PROCESS_ATTACH:
|
||||
hInstance = hinstDLL;
|
||||
DisableThreadLibraryCalls(hinstDLL);
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
|
@ -102,6 +106,166 @@ error:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK general_dlg_proc(HWND hwnd, UINT msg, WPARAM wp,
|
||||
LPARAM lp)
|
||||
{
|
||||
PROPSHEETPAGEW *page;
|
||||
PCCRYPTUI_VIEWCERTIFICATE_STRUCTW pCertViewInfo;
|
||||
|
||||
TRACE("(%p, %08x, %08lx, %08lx)\n", hwnd, msg, wp, lp);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
page = (PROPSHEETPAGEW *)lp;
|
||||
pCertViewInfo = (PCCRYPTUI_VIEWCERTIFICATE_STRUCTW)page->lParam;
|
||||
if (pCertViewInfo->dwFlags & CRYPTUI_DISABLE_ADDTOSTORE)
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_ADDTOSTORE), FALSE);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_ISSUERSTATEMENT), FALSE);
|
||||
FIXME("show cert properties\n");
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (wp)
|
||||
{
|
||||
case IDC_ADDTOSTORE:
|
||||
FIXME("call CryptUIWizImport\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void init_general_page(PCCRYPTUI_VIEWCERTIFICATE_STRUCTW pCertViewInfo,
|
||||
PROPSHEETPAGEW *page)
|
||||
{
|
||||
memset(page, 0, sizeof(PROPSHEETPAGEW));
|
||||
page->dwSize = sizeof(PROPSHEETPAGEW);
|
||||
page->hInstance = hInstance;
|
||||
page->u.pszTemplate = MAKEINTRESOURCEW(IDD_GENERAL);
|
||||
page->pfnDlgProc = general_dlg_proc;
|
||||
page->lParam = (LPARAM)pCertViewInfo;
|
||||
}
|
||||
|
||||
static int CALLBACK cert_prop_sheet_proc(HWND hwnd, UINT msg, LPARAM lp)
|
||||
{
|
||||
RECT rc;
|
||||
POINT topLeft;
|
||||
|
||||
TRACE("(%p, %08x, %08lx)\n", hwnd, msg, lp);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case PSCB_INITIALIZED:
|
||||
/* Get cancel button's position.. */
|
||||
GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rc);
|
||||
topLeft.x = rc.left;
|
||||
topLeft.y = rc.top;
|
||||
ScreenToClient(hwnd, &topLeft);
|
||||
/* hide the cancel button.. */
|
||||
ShowWindow(GetDlgItem(hwnd, IDCANCEL), FALSE);
|
||||
/* get the OK button's size.. */
|
||||
GetWindowRect(GetDlgItem(hwnd, IDOK), &rc);
|
||||
/* and move the OK button to the cancel button's original position. */
|
||||
MoveWindow(GetDlgItem(hwnd, IDOK), topLeft.x, topLeft.y,
|
||||
rc.right - rc.left, rc.bottom - rc.top, FALSE);
|
||||
GetWindowRect(GetDlgItem(hwnd, IDOK), &rc);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL show_cert_dialog(PCCRYPTUI_VIEWCERTIFICATE_STRUCTW pCertViewInfo,
|
||||
CRYPT_PROVIDER_CERT *provCert, BOOL *pfPropertiesChanged)
|
||||
{
|
||||
static const WCHAR riched[] = { 'r','i','c','h','e','d','2','0',0 };
|
||||
DWORD nPages;
|
||||
PROPSHEETPAGEW *pages;
|
||||
BOOL ret = FALSE;
|
||||
HMODULE lib = LoadLibraryW(riched);
|
||||
|
||||
nPages = pCertViewInfo->cPropSheetPages + 1; /* one for the General tab */
|
||||
if (!(pCertViewInfo->dwFlags & CRYPTUI_HIDE_DETAILPAGE))
|
||||
FIXME("show detail page\n");
|
||||
if (!(pCertViewInfo->dwFlags & CRYPTUI_HIDE_HIERARCHYPAGE))
|
||||
FIXME("show hierarchy page\n");
|
||||
pages = HeapAlloc(GetProcessHeap(), 0, nPages * sizeof(PROPSHEETPAGEW));
|
||||
if (pages)
|
||||
{
|
||||
PROPSHEETHEADERW hdr;
|
||||
CRYPTUI_INITDIALOG_STRUCT *init = NULL;
|
||||
DWORD i;
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
hdr.dwSize = sizeof(hdr);
|
||||
hdr.dwFlags = PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
|
||||
hdr.hInstance = hInstance;
|
||||
if (pCertViewInfo->szTitle)
|
||||
hdr.pszCaption = pCertViewInfo->szTitle;
|
||||
else
|
||||
hdr.pszCaption = MAKEINTRESOURCEW(IDS_CERTIFICATE);
|
||||
init_general_page(pCertViewInfo, &pages[hdr.nPages++]);
|
||||
/* Copy each additional page, and create the init dialog struct for it
|
||||
*/
|
||||
if (pCertViewInfo->cPropSheetPages)
|
||||
{
|
||||
init = HeapAlloc(GetProcessHeap(), 0,
|
||||
pCertViewInfo->cPropSheetPages *
|
||||
sizeof(CRYPTUI_INITDIALOG_STRUCT));
|
||||
if (init)
|
||||
{
|
||||
for (i = 0; i < pCertViewInfo->cPropSheetPages; i++)
|
||||
{
|
||||
memcpy(&pages[hdr.nPages + i],
|
||||
&pCertViewInfo->rgPropSheetPages[i],
|
||||
sizeof(PROPSHEETPAGEW));
|
||||
init[i].lParam = pCertViewInfo->rgPropSheetPages[i].lParam;
|
||||
init[i].pCertContext = pCertViewInfo->pCertContext;
|
||||
pages[hdr.nPages + i].lParam = (LPARAM)&init[i];
|
||||
}
|
||||
if (pCertViewInfo->nStartPage & 0x8000)
|
||||
{
|
||||
/* Start page index is relative to the number of default
|
||||
* pages
|
||||
*/
|
||||
hdr.u2.nStartPage = pCertViewInfo->nStartPage + hdr.nPages;
|
||||
}
|
||||
else
|
||||
hdr.u2.nStartPage = pCertViewInfo->nStartPage;
|
||||
hdr.nPages = nPages;
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
SetLastError(ERROR_OUTOFMEMORY);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Ignore the relative flag if there aren't any additional pages */
|
||||
hdr.u2.nStartPage = pCertViewInfo->nStartPage & 0x7fff;
|
||||
ret = TRUE;
|
||||
}
|
||||
if (ret)
|
||||
{
|
||||
INT_PTR l;
|
||||
|
||||
hdr.u3.ppsp = pages;
|
||||
hdr.pfnCallback = cert_prop_sheet_proc;
|
||||
l = PropertySheetW(&hdr);
|
||||
if (l == 0)
|
||||
{
|
||||
SetLastError(ERROR_CANCELLED);
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, init);
|
||||
HeapFree(GetProcessHeap(), 0, pages);
|
||||
}
|
||||
else
|
||||
SetLastError(ERROR_OUTOFMEMORY);
|
||||
FreeLibrary(lib);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* CryptUIDlgViewCertificateW (CRYPTUI.@)
|
||||
*/
|
||||
|
@ -166,8 +330,7 @@ BOOL WINAPI CryptUIDlgViewCertificateW(
|
|||
}
|
||||
if (ret)
|
||||
{
|
||||
FIXME("show cert dialog\n");
|
||||
ret = FALSE;
|
||||
ret = show_cert_dialog(&viewInfo, provCert, pfPropertiesChanged);
|
||||
if (!viewInfo.u.hWVTStateData)
|
||||
{
|
||||
wvt.dwStateAction = WTD_STATEACTION_CLOSE;
|
||||
|
|
Loading…
Reference in New Issue