klnotificationproc.c
来自「PGP8.0源码 请认真阅读您的文件包然后写出其具体功能」· C语言 代码 · 共 281 行
C
281 行
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
KLNotificationProc - notification processing and associated routines
$Id: KLNotificationProc.c,v 1.9 2002/10/09 13:02:54 pbj Exp $
____________________________________________________________________________*/
#include "pgpPFLConfig.h"
// project header files
#include "PGPclx.h"
#include "PGPklx.h"
#include "pgpUnicode.h"
// External globals
extern HINSTANCE g_hInst;
// Local globals
static WCHAR szToolTipText[256];
// ___________________________________________________
//
// reorder columns according to new header order
static VOID
sReorderColumns (
PKEYLIST pKL)
{
INT iOrderArray[NUMBERFIELDS];
WORD wColumnField[NUMBERFIELDS];
INT i, iNumCols;
// save order
KLSetColumnPreferences (pKL);
iNumCols = 1;
for (i=0; i<NUMBERFIELDS; i++)
{
wColumnField[i] = pKL->wColumnField[i];
if (wColumnField[i])
iNumCols++;
}
TreeList_GetOrderArray (pKL->hwndTree, iNumCols, &iOrderArray);
for (i=0; i<iNumCols; i++)
{
pKL->wColumnField[i] = wColumnField[iOrderArray[i]];
}
KLDeleteAllUserValues (pKL);
KLSetFocus (pKL, NULL, FALSE);
TreeList_DeleteTree (pKL->hwndTree, TRUE);
TreeList_DeleteAllColumns (pKL->hwndTree);
KLAddColumns (pKL);
KLLoadKeyRingIntoTree (pKL, FALSE, FALSE, TRUE);
InvalidateRect (pKL->hwndTree, NULL, TRUE);
UpdateWindow (pKL->hwndTree);
KLSetColumnPreferences (pKL);
}
// ___________________________________________________
//
// create text string for tooltip control
static VOID
sConstructTooltipText (
PGPKeyDBObjRef obj,
INT itype,
LPSTR psz,
INT ilen)
{
INT i;
PGPKeyID keyid;
CHAR sz[32];
switch (itype) {
case kPGPclKeyList_Key :
LoadString (g_hInst, IDS_TOOLTIPKEYID, sz, sizeof(sz));
lstrcat (psz, sz);
i = lstrlen (psz);
psz += i;
ilen -= i;
if (ilen > 12)
{
PGPGetKeyID (obj, &keyid);
PGPGetKeyIDString (&keyid, kPGPKeyIDString_Abbreviated, psz);
LoadString (g_hInst, IDS_TOOLTIPKEYSIZE, sz, sizeof(sz));
lstrcat (psz, sz);
i = lstrlen (psz);
psz += i;
ilen -= i;
}
CLGetKeyBitsString (obj, psz, ilen);
break;
case kPGPclKeyList_UserID :
// just use string from treelist
break;
case kPGPclKeyList_Signature :
// just use string from treelist
break;
default :
psz[0] = '\0';
break;
}
}
// ___________________________________________________
//
// Key manager notification processing procedure
PGPError PGPclExport
PGPclKeyListDefaultNotificationProc (
HKEYLIST hKL,
LPARAM lParam)
{
PKEYLIST pKL = (PKEYLIST)hKL;
LPNM_TREELIST lpntl = (LPNM_TREELIST)lParam;
HTLITEM hFocused;
BOOL bMultiple;
INT i, iField;
if (!hKL)
return kPGPError_BadParams;
switch (lpntl->hdr.code) {
case TLN_SELCHANGED :
if (pKL->ulOptionFlags & kPGPclKeyList_SelectKeysOnly)
{
TL_TREEITEM tli;
HTLITEM hItem, hInitialItem;
hInitialItem = lpntl->itemNew.hItem;
tli.hItem = hInitialItem;
do {
hItem = tli.hItem;
tli.mask = TLIF_PARENTHANDLE;
TreeList_GetItem (pKL->hwndTree, &tli);
} while (tli.hItem);
if (hItem != hInitialItem)
{
tli.hItem = hItem;
TreeList_Select (pKL->hwndTree, &tli, TRUE);
}
else
{
bMultiple = lpntl->flags & TLC_MULTIPLE;
hFocused = lpntl->itemNew.hItem;
KLSetFocus (pKL, hFocused, bMultiple);
}
}
else
{
bMultiple = lpntl->flags & TLC_MULTIPLE;
hFocused = lpntl->itemNew.hItem;
KLSetFocus (pKL, hFocused, bMultiple);
}
lpntl->flags = KLSelectedFlags (pKL);
break;
case TLN_TOOLTIPQUERY :
{
TL_TREEITEM tli;
CHAR sz[256];
INT iObjectType;
tli.hItem = lpntl->itemNew.hItem;
tli.mask = TLIF_PARAM | TLIF_IMAGE | TLIF_TEXT;
tli.pszText = sz;
tli.cchTextMax = sizeof(sz);
TreeList_GetItem (pKL->hwndTree, &tli);
iObjectType = KLGetObjectType (tli.iImage);
sConstructTooltipText ((PGPKeyDBObjRef)tli.lParam,
iObjectType, sz, sizeof(sz));
pgpUTF8StringToUCS2 (sz, sizeof(sz), szToolTipText,
sizeof(szToolTipText)/sizeof(WCHAR), NULL);
lpntl->pszText = szToolTipText;
break;
}
case TLN_CONTEXTMENU :
lpntl->flags = KLSelectedFlags (pKL);
break;
case TLN_HEADERREORDERED :
sReorderColumns (pKL);
break;
case TLN_HEADERCLICKED :
i = pKL->lKeyListSortField;
iField = pKL->wColumnField[lpntl->index];
switch (iField) {
case KLI_NAME :
if (pKL->lKeyListSortField == kPGPKeyOrdering_UserID)
pKL->bKeyListSortInvert = !pKL->bKeyListSortInvert;
else
{
pKL->lKeyListSortField = kPGPKeyOrdering_UserID;
pKL->bKeyListSortInvert = FALSE;
}
break;
case KLI_VALIDITY :
if (pKL->lKeyListSortField == kPGPKeyOrdering_Validity)
pKL->bKeyListSortInvert = !pKL->bKeyListSortInvert;
else
{
pKL->lKeyListSortField = kPGPKeyOrdering_Validity;
pKL->bKeyListSortInvert = FALSE;
}
break;
case KLI_TRUST :
if (pKL->lKeyListSortField == kPGPKeyOrdering_Trust)
pKL->bKeyListSortInvert = !pKL->bKeyListSortInvert;
else
{
pKL->lKeyListSortField = kPGPKeyOrdering_Trust;
pKL->bKeyListSortInvert = FALSE;
}
break;
case KLI_CREATION :
if (pKL->lKeyListSortField == kPGPKeyOrdering_CreationDate)
pKL->bKeyListSortInvert = !pKL->bKeyListSortInvert;
else
{
pKL->lKeyListSortField = kPGPKeyOrdering_CreationDate;
pKL->bKeyListSortInvert = FALSE;
}
break;
case KLI_EXPIRATION :
if (pKL->lKeyListSortField == kPGPKeyOrdering_ExpirationDate)
pKL->bKeyListSortInvert = !pKL->bKeyListSortInvert;
else
{
pKL->lKeyListSortField = kPGPKeyOrdering_ExpirationDate;
pKL->bKeyListSortInvert = FALSE;
}
break;
case KLI_SIZE :
if (pKL->lKeyListSortField == kPGPKeyOrdering_EncryptionKeySize)
pKL->bKeyListSortInvert = !pKL->bKeyListSortInvert;
else
{
pKL->lKeyListSortField = kPGPKeyOrdering_EncryptionKeySize;
pKL->bKeyListSortInvert = FALSE;
}
break;
default : break;
}
TreeList_DeleteTree (pKL->hwndTree, FALSE);
KLLoadKeyRingIntoTree (pKL, TRUE, FALSE, FALSE);
InvalidateRect (pKL->hwndTree, NULL, TRUE);
UpdateWindow (pKL->hwndTree);
break;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?