⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pkkeyops.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
📖 第 1 页 / 共 4 页
字号:
							 g_hinst, NULL);
		SetWindowPos (pccs->hwndDTPicker,
						GetDlgItem (hDlg, IDC_EXPIRATIONDATE),
						0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
		SendMessage (pccs->hwndDTPicker, DTM_SETMCCOLOR,
						MCSC_MONTHBK, (LPARAM)GetSysColor (COLOR_3DFACE));

		// initialize to one year from today
		GetLocalTime (&st);
		st.wYear++;
		SendMessage (pccs->hwndDTPicker, DTM_SETSYSTEMTIME,
							GDT_VALID, (LPARAM)&st);

		EnableWindow (pccs->hwndDTPicker, FALSE);
		CheckDlgButton (hDlg, IDC_NEVEREXPIRES, BST_CHECKED);

		// user "more" button as desired Y location
		hwndControl = GetDlgItem (hDlg, IDC_MORECHOICES);
		GetWindowRect (hwndControl, &rectControl);
		MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);

		GetWindowRect (hDlg, &rc);
		iOffset = rc.bottom-rc.top;
		GetClientRect (hDlg, &rc);
		iOffset -= rc.bottom;
		iOffset += (rectControl.bottom - rectControl.top) / 2;

		iNewY = rectControl.top;
		iNewWindowHeight = rectControl.bottom + iOffset;

		// move OK Button
		hwndControl = GetDlgItem (hDlg, IDOK);
		GetWindowRect (hwndControl, &rectControl);
		MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
		MoveWindow(	hwndControl,
					rectControl.left,
					iNewY,
					rectControl.right - rectControl.left,
					rectControl.bottom - rectControl.top,
					TRUE);

		// move Cancel Button
		hwndControl = GetDlgItem (hDlg, IDCANCEL);
		GetWindowRect (hwndControl, &rectControl);
		MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
		MoveWindow(	hwndControl,
					rectControl.left,
					iNewY,
					rectControl.right - rectControl.left,
					rectControl.bottom - rectControl.top,
					TRUE);

		// move Help Button
		hwndControl = GetDlgItem (hDlg, IDHELP);
		GetWindowRect (hwndControl, &rectControl);
		MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
		MoveWindow(	hwndControl,
					rectControl.left,
					iNewY,
					rectControl.right - rectControl.left,
					rectControl.bottom - rectControl.top,
					TRUE);

		// size Window
		GetWindowRect (hDlg, &rectControl);
		MoveWindow(	hDlg,
					rectControl.left,
					rectControl.top,
					rectControl.right - rectControl.left,
					iNewWindowHeight,
					TRUE);

		// ListView uses bad unicode font here, so we must set
		// it ourselves.
		pccs->hUTF8Font=SetUTF8Font(GetDlgItem(hDlg,IDC_KEYLIST));
		break;
	}

	case WM_DRAWITEM:
    {
        KeyDrawItem((LPDRAWITEMSTRUCT) lParam);
        return TRUE;
    }

	case WM_HELP :
	case WM_CONTEXTMENU :
		return PGPclHtmlHelp (hDlg, uMsg, wParam, lParam, 
				(char*)kPGPclHelpFile, aSignKeyIds);

	case WM_DESTROY :
		pccs = (PCERTIFYCONFIRMSTRUCT)GetWindowLong (hDlg, GWL_USERDATA);
		ListView_SetImageList (pccs->hwndList, NULL, LVSIL_SMALL);
		DeleteObject(pccs->hUTF8Font);
		break;

	case WM_NOTIFY:
	{
		LPNMHDR pnmh = (LPNMHDR) lParam;

		if (pnmh->code == DTN_DATETIMECHANGE) 
		{
			SYSTEMTIME st;

			pccs = (PCERTIFYCONFIRMSTRUCT) GetWindowLong(hDlg, GWL_USERDATA);
			SendMessage (pccs->hwndDTPicker, 
					DTM_GETSYSTEMTIME, 0, (LPARAM)&st);
			PGPclSystemTimeToDays (&st, &(pccs->iExpireDays));

			if (pccs->iExpireDays > 0)
				EnableWindow (GetDlgItem (hDlg, IDOK), TRUE);
			else
				EnableWindow (GetDlgItem (hDlg, IDOK), FALSE);
		}
		break;
	}

	case WM_PAINT :
		pccs = (PCERTIFYCONFIRMSTRUCT)GetWindowLong (hDlg, GWL_USERDATA);
		if (pccs->bExpandedChoices)
		{
			// paint icons
			HDC	hdc = GetDC (hDlg);

			GetWindowRect (GetDlgItem (hDlg, IDC_NONEXPORTABLE), &rc);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rc, 2);
			ImageList_Draw (g_hilKeys, IDX_CERT, hdc,
							rc.left-22, rc.top, ILD_TRANSPARENT);

			GetWindowRect (GetDlgItem (hDlg, IDC_EXPORTABLE), &rc);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rc, 2);
			ImageList_Draw (g_hilKeys, IDX_EXPORTCERT, hdc,
							rc.left-22, rc.top, ILD_TRANSPARENT);

			GetWindowRect (GetDlgItem (hDlg, IDC_TRUSTED), &rc);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rc, 2);
			ImageList_Draw (g_hilKeys, IDX_TRUSTEDCERT, hdc,
							rc.left-22, rc.top, ILD_TRANSPARENT);

			GetWindowRect (GetDlgItem (hDlg, IDC_META), &rc);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rc, 2);
			ImageList_Draw (g_hilKeys, IDX_METACERT, hdc,
							rc.left-22, rc.top, ILD_TRANSPARENT);

			ReleaseDC (hDlg, hdc);
		}
		break;

	case WM_COMMAND:

		pccs = (PCERTIFYCONFIRMSTRUCT)GetWindowLong (hDlg, GWL_USERDATA);
		if (IsNull (pccs))
			return TRUE;

		switch (LOWORD(wParam)) {
		case IDCANCEL:
			pccs->bSyncWithServer = FALSE;
			EndDialog (hDlg, 1);
			break;

		case IDOK:
			if (!(pccs->bExpandedChoices)) 
			{
				pccs->bExpires = FALSE;
				if (IsDlgButtonChecked (hDlg, IDC_EXPORTABLECHECK)
														== BST_CHECKED)
				{
					pccs->iSigType = SIG_EXPORTABLE;
				}
				else 
					pccs->iSigType = SIG_NONEXPORTABLE;
			}
			else {
				if (IsDlgButtonChecked (hDlg, IDC_NEVEREXPIRES) == BST_CHECKED)
					pccs->bExpires = FALSE;
				else 
				{
					SYSTEMTIME st;
					pccs->bExpires = TRUE;
					SendMessage (pccs->hwndDTPicker, DTM_GETSYSTEMTIME, 0,
									(LPARAM)&st);
					PGPclSystemTimeToDays (&st, &(pccs->iExpireDays));
				}
			}

			pccs->uTrustLevel = GetDlgItemInt (hDlg, IDC_DEPTH, NULL, FALSE);
			GetDlgItemText (hDlg, 
					IDC_DOMAIN, pccs->szDomain, sizeof(pccs->szDomain));
			EndDialog (hDlg, 0);
			break;

		case IDC_EXPORTABLECHECK :
			if (IsDlgButtonChecked (hDlg, IDC_EXPORTABLECHECK) == BST_CHECKED)
				pccs->iSigType = SIG_EXPORTABLE;
			else 
				pccs->iSigType = SIG_NONEXPORTABLE;
			break;

		case IDC_NONEXPORTABLE :
			pccs->iSigType = SIG_NONEXPORTABLE;
			pccs->uTrustLoLimit = 0;
			EnableWindow (GetDlgItem (hDlg, IDC_DOMAIN), FALSE);
			SendDlgItemMessage (hDlg, IDC_DEPTHSPIN, UDM_SETRANGE,
					0, (LPARAM)MAKELONG (MAXTRUSTDEPTH, pccs->uTrustLoLimit));
			SetDlgItemInt (hDlg, IDC_DEPTH, 0, FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTH), FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTHSPIN), FALSE);
			break;

		case IDC_EXPORTABLE :
			pccs->iSigType = SIG_EXPORTABLE;
			pccs->uTrustLoLimit = 0;
			EnableWindow (GetDlgItem (hDlg, IDC_DOMAIN), FALSE);
			SendDlgItemMessage (hDlg, IDC_DEPTHSPIN, UDM_SETRANGE,
					0, (LPARAM)MAKELONG (MAXTRUSTDEPTH, pccs->uTrustLoLimit));
			SetDlgItemInt (hDlg, IDC_DEPTH, 0, FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTH), FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTHSPIN), FALSE);
			break;

		case IDC_META :
			pccs->iSigType = SIG_META;
			pccs->uTrustLoLimit = 2;
			EnableWindow (GetDlgItem (hDlg, IDC_DOMAIN), FALSE);
			SendDlgItemMessage (hDlg, IDC_DEPTHSPIN, UDM_SETRANGE,
					0, (LPARAM)MAKELONG (MAXTRUSTDEPTH, pccs->uTrustLoLimit));
			SetDlgItemInt (hDlg, IDC_DEPTH, 2, FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTH), TRUE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTHSPIN), TRUE);
			break;

		case IDC_TRUSTED :
			pccs->iSigType = SIG_TRUST;
			pccs->uTrustLoLimit = 1;
			EnableWindow (GetDlgItem (hDlg, IDC_DOMAIN), TRUE);
			SendDlgItemMessage (hDlg, IDC_DEPTHSPIN, UDM_SETRANGE,
					0, (LPARAM)MAKELONG (MAXTRUSTDEPTH, pccs->uTrustLoLimit));
			SetDlgItemInt (hDlg, IDC_DEPTH, 1, FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTH), TRUE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTHSPIN), TRUE);
			break;

		case IDC_DEPTH :
			if (HIWORD (wParam) == EN_CHANGE)
			{
				UINT	uIn, uOut;

				uIn = GetDlgItemInt (hDlg, IDC_DEPTH, NULL, FALSE);
				uOut = uIn;

				if (uIn < pccs->uTrustLoLimit)
					uOut = pccs->uTrustLoLimit;
				else if (uIn > MAXTRUSTDEPTH)
					uOut = MAXTRUSTDEPTH;

				if (uIn != uOut)
					SetDlgItemInt (hDlg, IDC_DEPTH, uOut, FALSE);
			}
			break;

		case IDC_NEVEREXPIRES :
		case IDC_EXPIRES :
			if (IsDlgButtonChecked (hDlg, IDC_EXPIRES) == BST_CHECKED) 
			{
				SYSTEMTIME st;
				EnableWindow (pccs->hwndDTPicker, TRUE);

				SendMessage (pccs->hwndDTPicker, DTM_GETSYSTEMTIME,
										0, (LPARAM)&st);
				PGPclSystemTimeToDays (&st, &(pccs->iExpireDays));
				if (pccs->iExpireDays > 0)
					EnableWindow (GetDlgItem (hDlg, IDOK), TRUE);
				else
					EnableWindow (GetDlgItem (hDlg, IDOK), FALSE);
			}
			else 
			{
				EnableWindow (pccs->hwndDTPicker, FALSE);
				EnableWindow (GetDlgItem (hDlg, IDOK), TRUE);
			}
			break;

		case IDC_MORECHOICES :
			pccs->bExpandedChoices = TRUE;
			ShowWindow (GetDlgItem (hDlg, IDC_MORECHOICES), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_EXPORTABLECHECK), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_FEWERCHOICES), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_SIGTYPE), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_NONEXPORTABLE), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_EXPORTABLE), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_TRUSTED), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_META), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_EXPIRATION), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_NEVEREXPIRES), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_EXPIRES), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_DOMAINTEXT), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_DOMAIN), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_DEPTH), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_DEPTHSPIN), SW_SHOW);
			ShowWindow (pccs->hwndDTPicker, SW_SHOW);

			// user "fewer" button as desired Y location
			hwndControl = GetDlgItem (hDlg, IDC_FEWERCHOICES);
			GetWindowRect (hwndControl, &rectControl);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);

			GetWindowRect (hDlg, &rc);
			iOffset = rc.bottom-rc.top;
			GetClientRect (hDlg, &rc);
			iOffset -= rc.bottom;
			iOffset += (rectControl.bottom - rectControl.top) / 2;

			iNewY = rectControl.top;
			iNewWindowHeight = rectControl.bottom + iOffset;

			// move OK Button
			hwndControl = GetDlgItem (hDlg, IDOK);
			GetWindowRect (hwndControl, &rectControl);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
			MoveWindow(	hwndControl,
						rectControl.left,
						iNewY,
						rectControl.right - rectControl.left,
						rectControl.bottom - rectControl.top,
						TRUE);

			// move Cancel Button
			hwndControl = GetDlgItem (hDlg, IDCANCEL);
			GetWindowRect (hwndControl, &rectControl);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
			MoveWindow(	hwndControl,
						rectControl.left,
						iNewY,
						rectControl.right - rectControl.left,
						rectControl.bottom - rectControl.top,
						TRUE);

			// move Help Button
			hwndControl = GetDlgItem (hDlg, IDHELP);
			GetWindowRect (hwndControl, &rectControl);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
			MoveWindow(	hwndControl,
						rectControl.left,
						iNewY,
						rectControl.right - rectControl.left,
						rectControl.bottom - rectControl.top,
						TRUE);

			// set radio buttons
			CheckRadioButton (hDlg, IDC_NONEXPORTABLE, IDC_TRUSTED,
								IDC_NONEXPORTABLE + pccs->iSigType);

			// size Window
			GetWindowRect (hDlg, &rectControl);
			MoveWindow(	hDlg,
						rectControl.left,
						rectControl.top,
						rectControl.right - rectControl.left,
						iNewWindowHeight,
						TRUE);

			break;

		case IDC_FEWERCHOICES :
			pccs->bExpandedChoices = FALSE;
			ShowWindow (GetDlgItem (hDlg, IDC_MORECHOICES), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_EXPORTABLECHECK), SW_SHOW);
			ShowWindow (GetDlgItem (hDlg, IDC_FEWERCHOICES), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_SIGTYPE), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_NONEXPORTABLE), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_EXPORTABLE), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_TRUSTED), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_META), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_EXPIRATION), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_NEVEREXPIRES), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_EXPIRES), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_DOMAINTEXT), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_DOMAIN), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_DEPTH), SW_HIDE);
			ShowWindow (GetDlgItem (hDlg, IDC_DEPTHSPIN), SW_HIDE);
			ShowWindow (pccs->hwndDTPicker, SW_HIDE);

			// user "more" button as desired Y location
			hwndControl = GetDlgItem (hDlg, IDC_MORECHOICES);
			GetWindowRect (hwndControl, &rectControl);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);

			GetWindowRect (hDlg, &rc);
			iOffset = rc.bottom-rc.top;
			GetClientRect (hDlg, &rc);
			iOffset -= rc.bottom;
			iOffset += (rectControl.bottom - rectControl.top) / 2;

			iNewY = rectControl.top;
			iNewWindowHeight = rectControl.bottom + iOffset;

			// move OK Button
			hwndControl = GetDlgItem (hDlg, IDOK);
			GetWindowRect (hwndControl, &rectControl);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
			MoveWindow(	hwndControl,
						rectControl.left,
						iNewY,
						rectControl.right - rectControl.left,
						rectControl.bottom - rectControl.top,
						TRUE);

			// move Cancel Button
			hwndControl = GetDlgItem (hDlg, IDCANCEL);
			GetWindowRect (hwndControl, &rectControl);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
			MoveWindow(	hwndControl,
						rectControl.left,
						iNewY,
						rectControl.right - rectControl.left,
						rectControl.bottom - rectControl.top,
						TRUE);

			// move Help Button
			hwndControl = GetDlgItem (hDlg, IDHELP);
			GetWindowRect (hwndControl, &rectControl);
			MapWindowPoints (NULL, hDlg, (LPPOINT)&rectControl, 2);
			MoveWindow(	hwndControl,
						rectControl.left,
						iNewY,
						rectControl.right - rectControl.left,
						rectControl.bottom - rectControl.top,
						TRUE);

			// set radio buttons
			if (pccs->iSigType == SIG_EXPORTABLE)
				CheckDlgButton (hDlg, IDC_EXPORTABLECHECK, BST_CHECKED);
			else
			{
				pccs->iSigType = SIG_NONEXPORTABLE;
				CheckDlgButton (hDlg, IDC_EXPORTABLECHECK, BST_UNCHECKED);
			}

			// disable controls
			SendDlgItemMessage (hDlg, IDC_DEPTHSPIN, UDM_SETRANGE,
					0, (LPARAM)MAKELONG (MAXTRUSTDEPTH, 0));
			SetDlgItemInt (hDlg, IDC_DEPTH, 0, FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTH), FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DEPTHSPIN), FALSE);
			EnableWindow (GetDlgItem (hDlg, IDC_DOMAIN), FALSE);

			// size Window
			GetWindowRect (hDlg, &rectControl);
			MoveWindow(	hDlg,
						rectControl.left,
						rectControl.top,
						rectControl.right - rectControl.left,
						iNewWindowHeight,
						TRUE);
			break;

		case IDHELP :
			PGPclHtmlHelp (hDlg, kPGPclHelpContext, 0, 0, 
					(char*)kPGPclHelpFile, (DWORD*)IDH_PGPPK_SIGNDIALOG);
			break;

		}
		return FALSE;
	}
	return FALSE;
}


//	_______________________________________________
//
//  Certify selected key or userid

BOOL
PKCertifyKeyOrUserID (
		PGPKEYSSTRUCT*	ppks)
{
	PGPPrefRef				prefref			= kInvalidPGPPrefRef;
	CHAR					sz256[256];
	PGPError				err;
	CERTIFYSTRUCT			cs;
	CERTIFYCONFIRMSTRUCT	ccs;
	PGPBoolean				bAllow			= TRUE;

	if(PGPlnEnterprise())
	{
		if (IsPGPError (PGPclPeekClientLibPrefRefs (&prefref, NULL)))
			return FALSE;

		PGPGetPrefBoolean (prefref, kPGPPrefAllowKeySigning, &bAllow);
		if (!bAllow)
		{
			PKMessageBox (ppks->hwndMain, IDS_CAPTIONINFO,
					IDS_KEYSIGNINGNOTALLOWED, MB_OK|MB_ICONINFORMATION);
			return FALSE;
		}
	}

	// initialize structures
	cs.pfnCallback = sCertifySingleObject;
	cs.ppks = ppks;
	cs.bItemModified = FALSE;
	cs.keySigning = NULL;
	cs.pPasskey = NULL;

	ccs.ppks = ppks;
	ccs.iSigType = SIG_NONEXPORTABLE;
	ccs.bExpires = FALSE;
	ccs.iExpireDays = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -