📄 revoker.c
字号:
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
$Id: Revoker.c,v 1.11 2002/10/07 16:20:09 wjb Exp $
____________________________________________________________________________*/
#include <windows.h>
#include "PGPadmin.h"
#include <commctrl.h>
#include "resource.h"
#include "Utils.h"
#include "keydrawitem.h"
#include "PGPadminHelp.h"
#include "pgpClientLib.h"
static void sInitGUI(HWND hwndDlg, pgpConfigInfo *pConfig);
static DWORD aHelpIds[] = {
IDC_ENABLEREVOKER, IDH_PGPADMIN_ENABLEREVOKER,
IDC_REVOKER_ID, IDH_PGPADMIN_REVOKER_ID,
IDC_AUTOCRL, IDH_PGPADMIN_AUTOCRL,
IDC_REVOKERLABEL, -1,
0,0
};
HFONT g_hFont;
BOOL CALLBACK RevokerDlgProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
BOOL bReturnCode = FALSE;
pgpConfigInfo * pConfig = NULL;
HWND hList;
g_hCurrentDlgWnd = hwndDlg;
pConfig = (pgpConfigInfo *) GetWindowLong(hwndDlg, GWL_USERDATA);
hList = GetDlgItem(hwndDlg, IDC_REVOKER_ID);
switch(uMsg)
{
case WM_INITDIALOG:
{
CommonDlgProc(hwndDlg, uMsg, wParam, lParam);
pConfig = (pgpConfigInfo *) GetWindowLong(hwndDlg, GWL_USERDATA);
ShowKeyring(hwndDlg, IDC_REVOKER_ID, pConfig->pgpContext,
pConfig->keyDB, NULL, FALSE, TRUE, FALSE, TRUE);
SelectKeys(hwndDlg, IDC_REVOKER_ID, 1, &(pConfig->revokerKeyID));
// Property sheets use bad unicode font, so we must set
// it ourselves for listviews
g_hFont=SetUTF8Font(GetDlgItem(hwndDlg,IDC_REVOKER_ID));
sInitGUI(hwndDlg, pConfig);
break;
}
case WM_DRAWITEM:
{
KeyDrawItem((LPDRAWITEMSTRUCT) lParam);
return TRUE;
}
case WM_DESTROY:
FreeKeyring(hwndDlg, IDC_REVOKER_ID);
DeleteObject(g_hFont);
break;
case WM_HELP:
case WM_CONTEXTMENU:
return PGPclHtmlHelp (hwndDlg, uMsg, wParam, lParam,
(char *) kPGPclAdminHelpFile, aHelpIds);
case WM_NOTIFY:
{
LPNMHDR pnmh;
pnmh = (LPNMHDR) lParam;
switch(pnmh->code)
{
case PSN_HELP:
PGPclHtmlHelp (hwndDlg, kPGPclHelpContext, 0, 0,
(char *) kPGPclAdminHelpFile,
(DWORD *) IDH_PGPADMIN_REVOKERDIALOG);
break;
case PSN_KILLACTIVE:
{
int nIndex;
LV_ITEM lviKey;
char szUserID[kPGPMaxUserIDSize+1];
PGPKeyID *pKeyID;
// Save user data for this page
nIndex = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
if (nIndex > -1)
{
lviKey.mask = LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT;
lviKey.iItem = nIndex;
lviKey.iSubItem = 0;
lviKey.pszText = szUserID;
lviKey.cchTextMax = kPGPMaxUserIDSize;
ListView_GetItem(hList, &lviKey);
pKeyID = (PGPKeyID *) lviKey.lParam;
memcpy(pConfig->revokerKeyID.opaqueBytes,
pKeyID->opaqueBytes, sizeof(pKeyID->opaqueBytes));
}
else if (pConfig->bAutoAddRevoker)
{
char szErrorMsg[255];
char szTitle[255];
LoadString(g_hInstance, IDS_TITLE, szTitle, 254);
LoadString(g_hInstance, IDS_E_SELECTKEY, szErrorMsg,
254);
MessageBox(hwndDlg, szErrorMsg, szTitle,
MB_ICONEXCLAMATION);
SetFocus(GetDlgItem(hwndDlg, IDC_REVOKER_ID));
SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
}
bReturnCode = TRUE;
break;
}
case NM_CLICK:
case TVN_KEYDOWN:
if (pnmh->idFrom == IDC_REVOKER_ID)
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
bReturnCode = CommonDlgProc(hwndDlg, uMsg, wParam, lParam);
break;
default:
bReturnCode = CommonDlgProc(hwndDlg, uMsg, wParam, lParam);
break;
}
break;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_ENABLEREVOKER:
if (IsDlgButtonChecked(hwndDlg, IDC_ENABLEREVOKER) == BST_CHECKED)
pConfig->bAutoAddRevoker = TRUE;
else
pConfig->bAutoAddRevoker = FALSE;
sInitGUI(hwndDlg, pConfig);
bReturnCode = TRUE;
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
case IDC_AUTOCRL:
if (IsDlgButtonChecked(hwndDlg, IDC_AUTOCRL) == BST_CHECKED)
pConfig->bAutoUpdateCRL = TRUE;
else
pConfig->bAutoUpdateCRL = FALSE;
sInitGUI(hwndDlg, pConfig);
bReturnCode = TRUE;
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
break;
default:
bReturnCode = CommonDlgProc(hwndDlg, uMsg, wParam, lParam);
break;
}
return(bReturnCode);
}
static void sInitGUI(HWND hwndDlg, pgpConfigInfo *pConfig)
{
if (pConfig->bAutoAddRevoker)
CheckDlgButton(hwndDlg, IDC_ENABLEREVOKER, BST_CHECKED);
else
{
CheckDlgButton(hwndDlg, IDC_ENABLEREVOKER, BST_UNCHECKED);
ListView_SetItemState(GetDlgItem(hwndDlg, IDC_REVOKER_ID), -1, 0,
LVIS_SELECTED);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_REVOKERLABEL),
pConfig->bAutoAddRevoker);
EnableWindow(GetDlgItem(hwndDlg, IDC_REVOKER_ID),
pConfig->bAutoAddRevoker);
if (pConfig->bAutoUpdateCRL)
CheckDlgButton(hwndDlg, IDC_AUTOCRL, BST_CHECKED);
else
CheckDlgButton(hwndDlg, IDC_AUTOCRL, BST_UNCHECKED);
return;
}
/*__Editor_settings____
Local Variables:
tab-width: 4
End:
vi: ts=4 sw=4
vim: si
_____________________*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -