clprefsnetidr.c

来自「PGP8.0源码 请认真阅读您的文件包然后写出其具体功能」· C语言 代码 · 共 553 行 · 第 1/2 页

C
553
字号
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.
	
	CLprefsNetGen.c - handle PGPnet general preferences dialogs

	$Id: CLprefsNetIDR.c,v 1.18 2002/08/06 20:09:19 dallen Exp $
____________________________________________________________________________*/
#include "pgpPFLConfig.h"

// project header files
#include "PGPclx.h"
#include "PGPfireHelp.h"
#include "CLprefs.h"

// definitions
#define MAXBLOCKMINUTESDIGITS	4

// external globals
extern HINSTANCE	g_hInst;

static DWORD aIDRIds[] = {			// Help IDs
	IDC_ENABLEDETECTION,		IDH_PGPCLPREF_NETINTRUSIONDETECT,
	IDC_ENABLEAUTOBLOCK,		IDH_PGPCLPREF_NETAUTOBLOCKATTACK,
	IDC_BLOCKUNTILREMOVED,		IDH_PGPCLPREF_NETBLOCKUNTILREMOVED,
	IDC_BLOCKFOR,				IDH_PGPCLPREF_NETBLOCKFORMINUTES,
	IDC_BLOCKMINUTES,			IDH_PGPCLPREF_NETBLOCKFORMINUTES,
	IDC_ENABLEEMAILALERTS,		IDH_PGPCLPREF_NETSENDALERTEMAIL,
	IDC_ALERTEMAILADDR,			IDH_PGPCLPREF_NETALERTEMAILADDRESS,
	IDC_ALERTSMTPSERVER,		IDH_PGPCLPREF_NETALERTSMTPSERVER,
	IDC_SMTPTEXT,				IDH_PGPCLPREF_NETALERTSMTPSERVER,
	IDC_ENABLEATTACKDIALOG,		IDH_PGPCLPREF_NETDIALOGATTACK,
	IDC_ENABLEATTACKSOUND,		IDH_PGPCLPREF_NETSOUNDATTACK,
	IDC_ENABLEFLASHTRAY,		IDH_PGPCLPREF_NETTRAYFLASHATTACK,
	IDC_EPO,					IDH_PGPCLPREF_REPORTTOEPO,
	0,0
};


//	_____________________________________________________
//
//  determine if EPO Agent is installed and running

static BOOL
sEPOAgentActive (VOID)
{
	HKEY		hkey;
	LONG		lResult;
	DWORD		dwValueType, dwSize;

	lResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE, 
			"SOFTWARE\\Network Associates\\ePolicy Orchestrator\\Agent", 
			0, KEY_READ, &hkey);

	if (lResult == ERROR_SUCCESS)
	{
		lResult = RegQueryValueEx (hkey, 
				"Installed Path", 0, &dwValueType, NULL, &dwSize);
		RegCloseKey (hkey);

		if (lResult == ERROR_SUCCESS)
		{
			if ((dwValueType == REG_SZ) && 
				(dwSize > 0))
			{
				return TRUE;
			}
		}
	}

	return FALSE;
}


//	____________________________________
//
//	PGPnet IDR options dialog proc

LRESULT WINAPI
CLNetIDRPropDlgProc (
		HWND	hwnd,
		UINT	uMsg,
		WPARAM	wParam,
		LPARAM	lParam)
{
	PPREFSDLGSTRUCT		ppds;

	switch (uMsg)
	{
	case WM_INITDIALOG :
	{
		PGPBoolean	b, bEnabled, bBlockTilRemove;
		UINT		u;
		CHAR		sz[80];
		PGPPrefRef	prefref, prefrefNet;

		SetWindowLong (hwnd, GWL_USERDATA, ((PROPSHEETPAGE*)lParam)->lParam);
		ppds = (PPREFSDLGSTRUCT)GetWindowLong (hwnd, GWL_USERDATA);

		if (ppds->bNeedsCentering) 
		{
			PGPclCenterWindowOnMonitor (GetParent (hwnd), kPGPclWindowMonitor);
			ppds->bNeedsCentering = FALSE;
		}

		prefrefNet = CLGetPrefRefNet (ppds);

		// initialize radio buttons and edit controls
		PGPGetPrefBoolean (prefrefNet, 
				kPGPNetPrefBlockUntilRemoved, &bBlockTilRemove);
		if (bBlockTilRemove)
		{
			CheckRadioButton (hwnd, IDC_BLOCKUNTILREMOVED, 
					IDC_BLOCKFOR, IDC_BLOCKUNTILREMOVED);
		}
		else
		{
			CheckRadioButton (hwnd, IDC_BLOCKUNTILREMOVED, 
					IDC_BLOCKFOR, IDC_BLOCKFOR);
		}

		SendDlgItemMessage (hwnd, IDC_BLOCKMINUTES, EM_SETLIMITTEXT,
				MAXBLOCKMINUTESDIGITS, 0);
		PGPGetPrefNumber (prefrefNet, kPGPnetPrefBlockMinutes, &u);
		SetDlgItemInt (hwnd, IDC_BLOCKMINUTES, u, FALSE);

		sz[0] = '\0';
		PGPGetPrefStringBuffer (prefrefNet, 
				kPGPNetPrefAttackNotifyEmail, sizeof(sz), sz);
		SetDlgItemText (hwnd, IDC_ALERTEMAILADDR, sz);

		sz[0] = '\0';
		PGPGetPrefStringBuffer (prefrefNet, 
				kPGPNetPrefAttackNotifySMTPServer, sizeof(sz), sz);
		SetDlgItemText (hwnd, IDC_ALERTSMTPSERVER, sz);

		// initialize checkboxes and disable controls
		bEnabled = CLLoadCheckBoxPref (hwnd, IDC_ENABLEDETECTION, 
				ppds, prefrefNet, kPGPNetPrefUseIntrusionDetection);

		EnableWindow (GetDlgItem (hwnd, IDC_ENABLEAUTOBLOCK), bEnabled);
		b = CLLoadCheckBoxPref (hwnd, IDC_ENABLEAUTOBLOCK, 
				ppds, prefrefNet, kPGPNetPrefAutoBlockAttacks);
		if (b && bEnabled)
		{
			EnableWindow (GetDlgItem (hwnd, IDC_BLOCKUNTILREMOVED), b);
			EnableWindow (GetDlgItem (hwnd, IDC_BLOCKFOR), b);

			CLDisablePrefControl (hwnd, IDC_BLOCKUNTILREMOVED, 
					ppds, prefrefNet, kPGPNetPrefBlockUntilRemoved);
			CLDisablePrefControl (hwnd, IDC_BLOCKFOR, 
					ppds, prefrefNet, kPGPNetPrefBlockUntilRemoved);

			if (!bBlockTilRemove) 
			{
				EnableWindow (GetDlgItem (hwnd, IDC_BLOCKMINUTES), b);
				CLDisablePrefControl (hwnd, IDC_BLOCKMINUTES, 
						ppds, prefrefNet, kPGPnetPrefBlockMinutes);
			}
		}

		EnableWindow (GetDlgItem (hwnd, IDC_ENABLEEMAILALERTS), bEnabled);
		b = CLLoadCheckBoxPref (hwnd, IDC_ENABLEEMAILALERTS, 
				ppds, prefrefNet, kPGPNetPrefAttackEmailNotify);
		if (b && bEnabled)
		{
			EnableWindow (GetDlgItem (hwnd, IDC_ALERTEMAILADDR), b);
			CLDisablePrefControl (hwnd, IDC_ALERTEMAILADDR, 
					ppds, prefrefNet, kPGPNetPrefAttackNotifyEmail);

			EnableWindow (GetDlgItem (hwnd, IDC_SMTPTEXT), b);
			EnableWindow (GetDlgItem (hwnd, IDC_ALERTSMTPSERVER), b);
			CLDisablePrefControl (hwnd, IDC_ALERTSMTPSERVER, 
					ppds, prefrefNet, kPGPNetPrefAttackNotifyEmail);
		}

		EnableWindow (GetDlgItem (hwnd, IDC_ENABLEATTACKDIALOG), bEnabled);
		CLLoadCheckBoxPref (hwnd, IDC_ENABLEATTACKDIALOG, 
				ppds, prefrefNet, kPGPNetPrefAttackDialog);

		EnableWindow (GetDlgItem (hwnd, IDC_ENABLEATTACKSOUND), bEnabled);
		CLLoadCheckBoxPref (hwnd, IDC_ENABLEATTACKSOUND, 
				ppds, prefrefNet, kPGPNetPrefAttackSound);

		EnableWindow (GetDlgItem (hwnd, IDC_ENABLEFLASHTRAY), bEnabled);
		CLLoadCheckBoxPref (hwnd, IDC_ENABLEFLASHTRAY, 
				ppds, prefrefNet, kPGPNetPrefAttackNotify);

		prefref = CLGetPrefRef (ppds);

		CLLoadCheckBoxPref (hwnd, IDC_EPO,
				ppds, prefref, kPGPPrefReportToEPO);
		if (!sEPOAgentActive ())
			EnableWindow (GetDlgItem (hwnd, IDC_EPO), FALSE);

		return FALSE;
	}

	case WM_HELP :
	case WM_CONTEXTMENU :
		return PGPclHtmlHelp (hwnd, uMsg, wParam, lParam, 
				(char*)kPGPclFireHelpFile, aIDRIds);

	case WM_HSCROLL :
		PostMessage (hwnd, WM_APP, 0, 0);
		break;

	case WM_COMMAND :
	{
		PGPBoolean	b;
		PGPPrefRef	prefrefNet;

		ppds = (PPREFSDLGSTRUCT)GetWindowLong (hwnd, GWL_USERDATA);

		switch (LOWORD (wParam)) {

		case IDC_ENABLEDETECTION :
			prefrefNet = CLGetPrefRefNet (ppds);
			b = CLDisablePrefControl (hwnd, IDC_ENABLEDETECTION, ppds,
					prefrefNet, kPGPNetPrefUseIntrusionDetection);
			if (!b)
			{
				b = (IsDlgButtonChecked (
						hwnd, IDC_ENABLEDETECTION) == BST_CHECKED);

				EnableWindow (GetDlgItem (hwnd, IDC_ENABLEAUTOBLOCK), b);
				EnableWindow (GetDlgItem (hwnd, IDC_ENABLEEMAILALERTS), b);
				EnableWindow (GetDlgItem (hwnd, IDC_ENABLEATTACKDIALOG), b);
				EnableWindow (GetDlgItem (hwnd, IDC_ENABLEATTACKSOUND), b);
				EnableWindow (GetDlgItem (hwnd, IDC_ENABLEFLASHTRAY), b);

				if (b)
				{
					EnableWindow (
							GetDlgItem (hwnd, IDC_ENABLEDETECTION), TRUE);
					CLDisablePrefControl (hwnd, IDC_ENABLEDETECTION, ppds,
							prefrefNet, kPGPNetPrefAutoBlockAttacks);
					b = (IsDlgButtonChecked (
							hwnd, IDC_ENABLEAUTOBLOCK) == BST_CHECKED);
					if (b)
					{
						EnableWindow (
								GetDlgItem (hwnd, IDC_BLOCKUNTILREMOVED), b);
						EnableWindow (GetDlgItem (hwnd, IDC_BLOCKFOR), b);

						CLDisablePrefControl (hwnd, IDC_BLOCKUNTILREMOVED, ppds,
								prefrefNet, kPGPNetPrefBlockUntilRemoved);
						CLDisablePrefControl (hwnd, IDC_BLOCKFOR, ppds,
								prefrefNet, kPGPNetPrefBlockUntilRemoved);
						b = (IsDlgButtonChecked (
								hwnd, IDC_BLOCKFOR) == BST_CHECKED);
						if (b)
						{
							EnableWindow (
									GetDlgItem (hwnd, IDC_BLOCKMINUTES), b);
							CLDisablePrefControl (hwnd, IDC_BLOCKMINUTES, ppds,
									prefrefNet, kPGPnetPrefBlockMinutes);
						}
					}

					EnableWindow (
							GetDlgItem (hwnd, IDC_ENABLEEMAILALERTS), TRUE);
					CLDisablePrefControl (hwnd, IDC_ENABLEEMAILALERTS, ppds,
							prefrefNet, kPGPNetPrefAttackEmailNotify);
					b = (IsDlgButtonChecked (
							hwnd, IDC_ENABLEEMAILALERTS) == BST_CHECKED);
					if (b)
					{
						EnableWindow (
								GetDlgItem (hwnd, IDC_ALERTEMAILADDR), b);
						CLDisablePrefControl (hwnd, IDC_ALERTEMAILADDR, ppds,
								prefrefNet, kPGPNetPrefAttackNotifyEmail);

						EnableWindow (
								GetDlgItem (hwnd, IDC_ALERTSMTPSERVER), b);
						CLDisablePrefControl (hwnd, IDC_ALERTSMTPSERVER, ppds,
								prefrefNet, kPGPNetPrefAttackNotifyEmail);

⌨️ 快捷键说明

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