📄 pkprops.c
字号:
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
PKProps.c - handle PGPkeys object properties dialogs
$Id: PKProps.c,v 1.10 2002/08/06 20:09:46 dallen Exp $
____________________________________________________________________________*/
#include "pgpPFLConfig.h"
// project header files
#include "PGPkeysx.h"
#include "pgpImageList.h"
// typedefs
typedef struct _PROPLISTSTRUCT {
struct _PROPLISTSTRUCT* next;
HWND hwnd;
HWND hwndGeneral;
PGPKeyDBObjRef obj;
PPGPKEYSSTRUCT ppks;
} PROPLISTSTRUCT, *PPROPLISTSTRUCT;
typedef struct {
FARPROC pfnCallback;
PPGPKEYSSTRUCT ppks;
PGPUInt32 uObjectType;
} PROPSTRUCT, *PPROPSTRUCT;
// external globals
extern PGPContextRef g_context;
extern PGPtlsContextRef g_tlscontext;
// local globals
static PPROPLISTSTRUCT s_proplist;
// ___________________________________________________
//
// search the list for the window for this object
static PPROPLISTSTRUCT
sFindPropertiesWindowForObject (
PGPKeyDBObjRef obj)
{
PPROPLISTSTRUCT ppls = s_proplist;
while (ppls)
{
if (ppls->obj == obj)
{
return ppls;
}
ppls = ppls->next;
}
return NULL;
}
// ___________________________________________________
//
// search the list for the window for this object
static VOID
sAddPropertiesWindowToList (
PGPKeyDBObjRef obj,
HWND hwnd,
PPGPKEYSSTRUCT ppks)
{
PPROPLISTSTRUCT ppls;
ppls = pkAlloc (sizeof(PROPLISTSTRUCT));
if (ppls)
{
ppls->hwnd = hwnd;
ppls->hwndGeneral = NULL;
ppls->obj = obj;
ppls->ppks = ppks;
ppls->next = s_proplist;
s_proplist = ppls;
}
PKAddRemoveWindowList (hwnd, TRUE, TRUE, TRUE);
}
// ___________________________________________________
//
// search the list for the window for this object and remove it
static VOID
sRemovePropertiesWindowFromList (
PGPKeyDBObjRef obj)
{
PPROPLISTSTRUCT* pppls;
PPROPLISTSTRUCT ppls;
pppls = &s_proplist;
while (*pppls)
{
if ((*pppls)->obj == obj)
{
ppls = *pppls;
PKAddRemoveWindowList (ppls->hwnd, FALSE, TRUE, TRUE);
*pppls = (*pppls)->next;
pkFree (ppls);
return;
}
pppls = &((*pppls)->next);
}
}
// ___________________________________________________
//
// Display properties for all selected objects
HWND
PKSingleObjectProperties (
PPGPKEYSSTRUCT ppks,
PGPKeyDBObjRef obj,
PGPUInt32 uObjectType)
{
PGPUInt32 uFlags = 0;
HWND hwnd;
PPROPLISTSTRUCT ppls;
PGPKeyDBObjRef objSearch;
if (uObjectType == kPGPclKeyList_UserID)
objSearch = PGPPeekKeyDBObjKey (obj);
else
objSearch = obj;
ppls = sFindPropertiesWindowForObject (objSearch);
if (ppls)
{
if (uObjectType == kPGPclKeyList_UserID)
{
PostMessage (ppls->hwndGeneral, PGPCL_M_PROPERTYMESSAGE,
kPGPclProperties_RefreshPhotoID, (LPARAM)obj);
}
SetForegroundWindow (ppls->hwnd);
return ppls->hwnd;
}
if (uObjectType == kPGPclKeyList_Key)
uFlags = kPGPclProperties_Key;
else if (uObjectType == kPGPclKeyList_UserID)
uFlags = kPGPclProperties_UserID;
else if (uObjectType == kPGPclKeyList_Signature)
uFlags = kPGPclProperties_Signature;
if (uFlags == 0)
return FALSE;
uFlags |= kPGPclProperties_Modeless;
if (ppks->bReadOnly)
uFlags |= kPGPclProperties_ReadOnly;
if (s_proplist == NULL)
uFlags |= kPGPclProperties_CenterWindow;
PGPclKeyDBObjProperties (g_context, g_tlscontext, ppks->hwndMain,
obj, ppks->keydbMain, uFlags, &hwnd);
sAddPropertiesWindowToList (objSearch, hwnd, ppks);
return hwnd;
}
// ___________________________________________________
//
// Get key or cert ref to display properties for
static BOOL CALLBACK
sSingleProperties (
TL_TREEITEM* lptli,
LPARAM lParam)
{
PGPKeyDBObjRef key = kInvalidPGPKeyDBObjRef;
PPROPSTRUCT pps = (PROPSTRUCT*)lParam;
PGPUInt32 uType;
PGPKeyDBObjRef obj;
switch (lptli->iImage) {
case IDX_RSASECKEY :
case IDX_RSASECDISKEY :
case IDX_RSASECREVKEY :
case IDX_RSASECEXPKEY :
case IDX_RSASECSHRKEY :
case IDX_RSAPUBKEY :
case IDX_RSAPUBDISKEY :
case IDX_RSAPUBREVKEY :
case IDX_RSAPUBEXPKEY :
case IDX_DSASECKEY :
case IDX_DSASECDISKEY :
case IDX_DSASECREVKEY :
case IDX_DSASECEXPKEY :
case IDX_DSASECSHRKEY :
case IDX_DSAPUBKEY :
case IDX_DSAPUBDISKEY :
case IDX_DSAPUBREVKEY :
case IDX_DSAPUBEXPKEY :
case IDX_RSAV4SECKEY :
case IDX_RSAV4SECDISKEY :
case IDX_RSAV4SECREVKEY :
case IDX_RSAV4SECEXPKEY :
case IDX_RSAV4SECSHRKEY :
case IDX_RSAV4PUBKEY :
case IDX_RSAV4PUBDISKEY :
case IDX_RSAV4PUBREVKEY :
case IDX_RSAV4PUBEXPKEY :
case IDX_RSATOKKEY :
case IDX_RSATOKDISKEY :
case IDX_RSATOKREVKEY :
case IDX_RSATOKEXPKEY :
case IDX_RSAV4TOKKEY :
case IDX_RSAV4TOKDISKEY :
case IDX_RSAV4TOKREVKEY :
case IDX_RSAV4TOKEXPKEY :
case IDX_ECPUBKEY :
case IDX_ECPUBDISKEY :
case IDX_ECPUBREVKEY :
case IDX_ECPUBEXPKEY :
case IDX_ECSECKEY :
case IDX_ECSECDISKEY :
case IDX_ECSECREVKEY :
case IDX_ECSECEXPKEY :
case IDX_ECSECSHRKEY :
obj = (PGPKeyDBObjRef)(lptli->lParam);
uType = kPGPclKeyList_Key;
break;
case IDX_RSAUSERID :
case IDX_DSAUSERID :
case IDX_INVALIDUSERID :
case IDX_PHOTOUSERID :
obj = (PGPKeyDBObjRef)(lptli->lParam);
uType = kPGPclKeyList_UserID;
break;
case IDX_CERT :
case IDX_EXPCERT :
case IDX_REVCERT :
case IDX_BADCERT :
case IDX_EXPORTCERT :
case IDX_TRUSTEDCERT :
case IDX_METACERT :
case IDX_X509CERT :
case IDX_X509EXPCERT :
case IDX_X509REVCERT :
obj = (PGPKeyDBObjRef)(lptli->lParam);
uType = kPGPclKeyList_Signature;
break;
default :
return FALSE;
}
PKSingleObjectProperties (pps->ppks, obj, uType);
return TRUE;
}
// ___________________________________________________
//
// Put up object properties dialog(s)
BOOL
PKObjectProperties (
PPGPKEYSSTRUCT ppks)
{
PROPSTRUCT ps;
ps.ppks = ppks;
ps.uObjectType = 0;
ps.pfnCallback = sSingleProperties;
TreeList_IterateSelected (ppks->hwndTreeList, &ps);
return TRUE;
}
// ___________________________________________________
//
// Update all existing propertysheets
VOID
PKUpdateAllObjectPropertiesWindows (
PPGPKEYSSTRUCT ppks)
{
PPROPLISTSTRUCT ppls = s_proplist;
while (ppls)
{
if (ppls->ppks == ppks)
{
PostMessage (ppls->hwndGeneral, PGPCL_M_PROPERTYMESSAGE,
kPGPclProperties_UpdateObject, 0);
}
ppls = ppls->next;
}
}
// ___________________________________________________
//
// Delete existing propertysheet
VOID
PKDeletePropertiesWindow (
HWND hwnd)
{
PPROPLISTSTRUCT ppls = s_proplist;
PGPKeyDBObjRef obj;
while (ppls)
{
if (ppls->hwnd == hwnd)
{
DestroyWindow (ppls->hwnd);
obj = ppls->obj;
ppls = ppls->next;
sRemovePropertiesWindowFromList (obj);
}
else
ppls = ppls->next;
}
}
// ___________________________________________________
//
// Delete existing propertysheet
VOID
PKDeletePropertiesWindowForObject (
PGPKeyDBObjRef obj)
{
PPROPLISTSTRUCT ppls;
ppls = sFindPropertiesWindowForObject (obj);
if (ppls)
{
DestroyWindow (ppls->hwnd);
sRemovePropertiesWindowFromList (obj);
}
}
// ___________________________________________________
//
// Register the child window of existing propertysheet
VOID
PKRegisterPropertiesWindow (
HWND hwndParent,
HWND hwndChild)
{
PPROPLISTSTRUCT ppls = s_proplist;
while (ppls)
{
if (ppls->hwnd == hwndParent)
{
ppls->hwndGeneral = hwndChild;
return;
}
ppls = ppls->next;
}
}
// ___________________________________________________
//
// Delete existing propertysheets
VOID
PKDeleteAllObjectPropertiesWindows (
PPGPKEYSSTRUCT ppks)
{
PPROPLISTSTRUCT ppls = s_proplist;
PGPKeyDBObjRef obj;
while (ppls)
{
if (ppls->ppks == ppks)
{
DestroyWindow (ppls->hwnd);
obj = ppls->obj;
ppls = ppls->next;
sRemovePropertiesWindowFromList (obj);
}
else
ppls = ppls->next;
}
}
// ___________________________________________________
//
// Enable/Disable existing propertysheets
VOID
PKEnableAllObjectPropertiesWindows (
PPGPKEYSSTRUCT ppks,
BOOL bEnable)
{
PPROPLISTSTRUCT ppls = s_proplist;
while (ppls)
{
if (ppls->ppks == ppks)
{
EnableWindow (GetParent (ppls->hwnd), bEnable);
}
ppls = ppls->next;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -