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

📄 npgpnts.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
📖 第 1 页 / 共 5 页
字号:
/*______________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.


	$Id: nPGPNts.c,v 1.17 2002/11/21 22:28:19 sdas Exp $
______________________________________________________________________________*/

/*::: MODULE OVERVIEW :::::::::::::
Provides central management services for the back-end infrastructure of the 
Lotus Notes PGP Plug-In.

--- revision history --------
10/30/02 Version 1.2.2 Paul Ryan
+ logic enhancement to support gracefully user-cancelation during key-server 
  searches [creation of i_MatchPgpKeys(), i_PgpMatchSmtpAddresses(), 
  associated adjustment of i_PgpMatchNotesNames(), xs_PgpSecureMessage()]
+ listing format adjustment, token renaming, documentation improvement

9/6/02 Version 1.2.1 Paul Ryan
+ logic enhancemnt during message decoding to wrap PGP-encoded attachments in 
  messages not generated by the Notes plug-in so that special PGP handling can 
  be provided
+ logic enhancement to support high-ASCII (international) characters in the 
  message body and in attachment handling
+ removed unnecessary critical-section variable
+ explicitly set WINVER preprocessor token to 0x0400 (Win95/NT4 baseline)
+ much listing format adjustment, documentation adjustment, token renaming

7/2/01 Version 1.2 Paul Ryan
+ logic enhancement in support of robust plug-in version handling
+ listing format adjustment, documentation adjustment

11/16/00 Version 1.1.8 Paul Ryan
+ added work-around method for marking a document as read

11/14/00 Version 1.1.7 Paul Ryan
+ added support for resetting the view/folder context associated with a 
  document currenty being shown to the user in the Notes R5 user interface, see 
  xs_vetFolderCtx()
+ documentation adjustment

10/7/00 Version 1.1.6 Paul Ryan
+ Revamped the plug-in setup procedure. See xs_VetPluginReadiness().
+ bug fixes to es_SpecialDecryptAttachment()
+ documentation adjustment

9/16/00 Version 1.1.5 Paul Ryan
+ enhancements surrounding special handling of PGP-encoded attachments in a 
  Notes message
+ design improvement to internals controlling the checkmark toggling of the 
  PGP drop-down action-bar menu
+ documentation adjustment, token renaming

8/9/00 Version 1.1.2 Paul Ryan
+ manufacture of checkmark toggling for the PGP drop-down action-bar menu
+ work towards improved file-attachment handling (not enabled)
+ got rid of hack in i_PgpEncodeAttachments() for attaching encoded files 
  without Notes trying to sign them when sending the message in MIME format
+ documentation improvement

3/20/00 Version 1.1.1 Paul Ryan
+ adjustment to support Notes R5, Notes Mail R5 template and PGP 7.0
+ documentation adjustments, logic enhancements
+ Bug fix of behavior where a pre-existing encoded rich-text attachment was 
  not being removed during a new encoding. Fix relates primarily to message 
  forward and "reply with history" operations.

9/12/99 Version 1.1 Paul Ryan
+ PGP 6.5.1 compatibility
+ logic enhancements
   - support for reading into memory rich-text content resident in a 
     compressed attachment
   - default handling of Notes addresses in the user-friendlier abbreviated 
     format
   - improved Domino Directory name-lookup functionality to emulate better 
     Notes' normal algorithm, and thereby enhanced the plug-in's group-
	 resolution capability
+ documentation enhancements

1/29/99 Version 1.0 Paul Ryan
::::::::::::::::::::::::::::::::::::*/

#include "nPGPNts.h"


//global-scope declarations
HINSTANCE  eh_Instance;

//module-scope declarations
static const char  mpc_PGP_ARMOR_EXT_ASC[] = ".asc", 
					mpc_PGP_ARMOR_EXT_PGP[] = ".pgp", 
					mpc_ROOTFILENM_PGP_RTF[] = "pgp.rtf", 
					mpc_PROPNM_ORIG_WNDPROC[] = "OrigWndProc", 
					mpc_PROPNM_EXTR_DLG_CHOICE[] = "ActionChoice";
static const UINT  mui_LEN_ARMOR_EXT_ASC = sizeof( mpc_PGP_ARMOR_EXT_ASC) - 1, 
					mui_LEN_ARMOR_EXT_PGP = sizeof( mpc_PGP_ARMOR_EXT_PGP) - 1;
static const int  mi_CANCEL = 2, mi_SUCCESS = 3, 
					mi_MASK_DCRYPTD = 0x8000;

static char  mpc_fileNmPgpRtf[ sizeof( mpc_ROOTFILENM_PGP_RTF) + 
											sizeof( mpc_PGP_ARMOR_EXT_ASC) - 1];
static ResettableRtfInfo  mt_RtfResettable;
static HFONT  mh_fntFileCaption;
static OSVERSIONINFO  mt_Os = {sizeof( OSVERSIONINFO)};


/** xs_markRead( ***
Mark the specified note as read. Works around strange unread-marks behaviors 
seen with the Notes R5 client.

--- parameter & return ----
h_NOTE: handle to the note to be marked as read
RETURN:
	eus_SUCCESS if no errors occurred
	eus_ERR_INVLD_ARG if any passed-in parameter is obviously invalid
	the Notes API error code otherwise

--- revision history ------
9/6/02 PR: listing format adjustment, minor exception-handling adjustment
11/16/00 PR: created		*/
short xs_markRead( NOTEHANDLE  h_NOTE)	{
	static char  pc_userNm[ MAXUSERNAME + 1];
	static WORD  us_lenUserNm;

	NOTEID  nid;
	DBHANDLE  h_db;
	HANDLE  h_unrd, h_unrdOrig = NULL;
	BOOL  f_chngd;
	STATUS  us_err, us_error;

	if (!h_NOTE)
		return (short) eus_ERR_INVLD_ARG;

	//if necessary, get the username associated with the ID associated with the 
	//	execution going on here
	if (!us_lenUserNm)	{
		if (us_err = SECKFMGetUserName( pc_userNm))
			return us_err;
		us_lenUserNm = strlen( pc_userNm);
	}

	//derive the NoteID and the handle to the database containing the note
	NSFNoteGetInfo( h_NOTE, _NOTE_ID, &nid);
	NSFNoteGetInfo( h_NOTE, _NOTE_DB, &h_db);

	//get the current unread table
	if (us_err = NSFDbGetUnreadNoteTable( h_db, pc_userNm, us_lenUserNm, TRUE, 
																	&h_unrd))
		return us_err;
	if (us_err = NSFDbUpdateUnread( h_db, h_unrd))
		goto errJump;
	if (us_err = IDTableCopy( h_unrd, &h_unrdOrig))
		goto errJump;

	//if the NoteID of the specified note is present in the unread table, 
	//	delete that entry 
	if (us_err = IDDelete( h_unrd, nid, &f_chngd))
		goto errJump;

	//if a deletion did occur, update the operative unread table
	if (f_chngd)
		us_err = NSFDbSetUnreadNoteTable( h_db, pc_userNm, us_lenUserNm, FALSE, 
															h_unrdOrig, h_unrd);

errJump:
	//free allocated resources, as necessary
	if (h_unrdOrig)
		if (( us_error = IDDestroyTable( h_unrdOrig)) && !us_err)
			us_err = us_error;
	if (( us_error = IDDestroyTable( h_unrd)) && !us_err)
		us_err = us_error;

	return us_err;
} //xs_markRead(


/** xs_vetFolderCtx( ***
Handles the determining and resetting of the view/folder context associated 
with a document currently being shown to the user in the Notes R5 user 
interface. The view/folder context allows the @Commands "@Command( [Folder])" 
and "@Command( [EditClear])" to function with the parent view/folder from which 
the document was opened as well as with the document itself. In terms of 
immediately obvious effects, with @Command( [Folder]) this means that if the 
parent view/folder is a folder, the "Move" button will be enabled. And with 
@Command( [EditClear], it means that the view line associated with the document 
will be marked with the trash icon.

The ability to reset the view/folder context is useful when the document 
currently being shown to the user was opened programmatically, not directly by 
the user herself through the view/folder. Opening documents programmatically 
does not populate a view/folder context, so the @Commands noted above operate 
differently in that their functioning does not interact with a parent 
view/folder as described: the Move button in the folder dialog is never 
enabled, and no trash icon mark will be placed as the user might expect.

NOTE: The memory mapping and manipulation conducted by this procedure was 
arrived at purely by means of reverse-engineering the Notes user-interface DLL 
nnotesws.dll. Naturally, this approach is a "hack" that would have been avoided 
if it were possible to accomplish the aims of the procedure in another way. As 
with most any hack, the approach is prone to maintenance problems as product 
changes or upgrades occur. The procedure has been verified to work with Notes 
R5.0.2 and R5.0.4, and cannot be guaranteed to succeed with other (or future) 
versions of Notes.

--- parameters & return -----
pnid: Input & Output. Address of variable containing the NoteID of the parent 
	view/folder of the document currently being shown to the user. If variable 
	is null, it signifies that procedure should populate the variable with the 
	NoteID found within the workspace context maintained by the Notes system. 
	If variable is non-null, it's value is written to the workspace context 
	provided that the context currently has that value as null. That is, the 
	procedure will not allow a non-blank value to be overwritten.
pus: Input & Output: Address of variable containing the type-value of the 
	parent view/folder. If the view/folder NoteID is being written to the 
	workspace context, the type-value held by this variable will be written as 
	as well. If the view/folder NoteID is being output to the variable pointed 
	to by the pnid argument, the type-value will also be output.
RETURN: ms_VB_TRUE if procedure encountered no errors; ms_VB_FALSE otherwise

--- revision history --------
9/6/02 PR: listing format adjustment
11/14/00 PR: created			*/
short xs_vetFolderCtx( NOTEID *const pnid, 
						short *const  pus)	{
	//static for speed
	static const char  pc_CLASSNM_SBPRG_FRMST[] = "FramesetSubprog", 
						pc_CLASSNM_SBPRG_NOTES[] = "NotesSubprog";
	static const UINT  ui_OFST_T16_NID_VW = 0x98, ui_OFST_T16_VW_TYP = 0xDA;

	HWND  h;
	char  pc[ 21];
	BYTE * puc_tsbprg, * puc_t16;
	NOTEID  nid;

	//if parameters are obviously invalid, short-circuit with failure
	if (!( pnid && pus))
		goto errJump;

	//Get address of subprogram structure associated with the main message 
	//	window. Do so in a consistent way of navigating to the first parent 
	//	frameset subprogram, and then down to the first child Notes subprogram.
	if (!( h = GetFocus()))
		goto errJump;
	if (!( h = GetParent( h)))
		goto errJump;
	if (!( h = GetParent( h)))
		goto errJump;
	if (!GetClassName( h, pc, sizeof( pc)))
		goto errJump;
	if (strcmp( pc, pc_CLASSNM_SBPRG_FRMST) != ei_SAME)	{
		if (!( h = GetParent( h)))
			goto errJump;
		if (strcmp( pc, pc_CLASSNM_SBPRG_FRMST) != ei_SAME)
			goto errJump;
	}
	if (!( h = FindWindowEx( h, NULL, pc_CLASSNM_SBPRG_NOTES, NULL)))
		goto errJump;
	if (!( puc_tsbprg = (BYTE *) GetWindowLong( h, 0)))
		goto errJump;

	//if we've been asked to output the current view/folder context...
	puc_t16 = (BYTE *) *(long *) *(long *) (puc_tsbprg + 0x8E);
	nid = *(long *) (puc_t16 + ui_OFST_T16_NID_VW);
	if (!*pnid)	{
		//do so
		*pnid = nid;
		*pus = *(puc_t16 + ui_OFST_T16_VW_TYP);
	//else, provided that we're not overwriting a current context, populate the 
	//	current document context with the folder context we acquired in a prior 
	//	call
	}else if (!nid)	{
		*(NOTEID *) (puc_t16 + ui_OFST_T16_NID_VW) = *pnid;
		*(puc_t16 + ui_OFST_T16_VW_TYP) = (BYTE) *pus;
	} //if (!*pnid)

	return ms_VB_TRUE;

errJump:
	return ms_VB_FALSE;
} //xs_vetFolderCtx(


/** xs_DecryptVerifyNote( ***
Purpose is to PGP decrypt/verify the PGP encrypted/signed content present in 
the specified note.

--- parameters & return ----
h_NOTE: handle to the note to undergo PGP decoding
pc_ITMNM_RTF: pointer to a string telling the name of the rich-text field to be 
	used in the decryption/verification
ps_msgChanged: pointer to the variable of VisualBasic integer type in which to 
	return whether message content was changed (ms_VB_TRUE) or not (ms_VB_FALSE)
RETURN: eus_SUCCESS if no error occured. If the user canceled a PGP dialog, 
	ei_USER_ABORT. Otherwise !eus_SUCCESS or, if available, the Notes API error 
	code.

--- revision history -------
9/6/02 PR: listing format adjustment, minor documentation change, token renaming
11/14/00 PR: minor token renaming
9/12/99 PR: documentation adjustment
2/2/99 PR: created			*/
short xs_DecryptVerifyNote( NOTEHANDLE  h_NOTE, 
							char  pc_ITMNM_RTF[], 
							short *const  ps_msgChanged)	{
	RtfCursor  t_crsr;
	RtfContext  t_RtfContext;
	DWORD  ul_objId, ul_lenContent;
	BLOCKID  bid_item;
	STATUS  us_err;
	int  i_err, i_errNonFatal = NULL;

	if (!( h_NOTE && pc_ITMNM_RTF && ps_msgChanged))
		return !eus_SUCCESS;

	//default the message-changed flag to say that no change has occurred
	*ps_msgChanged = ms_VB_FALSE;

	//initialize resources associated with the rich-text handling we're going 
	//	to do
	if (us_err = eus_InitializeRtfContext( h_NOTE, pc_ITMNM_RTF, &t_crsr, 
																&t_RtfContext))
		return us_err;

	//if the special PGP-Armored file attachment containing Notes rich-text is 
	//	present on the note...
	if (us_err = us_LocatePgpRtfAttachment( t_crsr, &t_RtfContext, h_NOTE, 
										&ul_objId, &ul_lenContent, &bid_item))
		i_errNonFatal = us_err;
	if (bid_item.pool && !i_errNonFatal)	{
		//PGP decode the attachment's rich-text content
		i_err = i_PgpDecodeUsingRichTextObj( ul_objId, ul_lenContent, bid_item, 
												h_NOTE, pc_ITMNM_RTF, 
												&t_RtfContext, &i_errNonFatal);
		if (i_err && !i_errNonFatal)
			goto errJump;

		//if no error occurred, inform the caller that the message content 
		//	changed
		if (!i_errNonFatal)
			*ps_msgChanged = ms_VB_TRUE;
	} //if (bid_item.pool && !i_errNonFatal)

⌨️ 快捷键说明

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