📄 installer.c
字号:
/*______________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
$Id: Installer.c,v 1.11 2002/09/09 00:31:43 sdas Exp $
______________________________________________________________________________*/
/*::: MODULE OVERVIEW :::::::::::::
Provides un/installation and administration services to the PGP Lotus Notes
Plug-In.
--- suggested enhancements ----
3/16/00 PR: provide more flexibility at install time by implementing
suggestion specified in xus_InstallNotesComponents()
2/23/00 PR: see description of suggestion in us_PgpEnableEmailForm()
documentation
1/11/99 PR: decompose ACL stuff into an AclHandling module, maybe
--- revision history ----------
7/2/01 Version 1.1.3.2: Paul Ryan
+ removed remmed-out code in us_PgpEnableEmailForm()
4/24/01 Version 1.1.3.1: Paul Ryan
+ removed remmed-out code in us_GetSourceEnvInfo()
8/9/00 Version 1.1.3: Paul Ryan
+ made xus_InstallNotesComponents() and xus_UninstallNotesComponents() adhere
to the __stdcall calling convention because in certain situations the
stack was not being cleaned up by the caller
3/16/00 Version 1.1.2: Paul Ryan
+ documentation adjustment
+ minor logic adjustment
2/23/00 Version 1.1.1: Paul Ryan
+ to prevent "corrupted note" error message in Notes 4.5.1 client, added
OPEN_EXPAND flag when opening notes to be signed
+ minor documentation adjustment
9/20/99 Version 1.1: Paul Ryan
+ integrated uninstall services
+ made install process more robust
+ decomposed database-handling services into own module incorporated here via
LibDbAndNote.h
+ documentation adjustment, logic enhancement
2/8/99 Version 1.0: Paul Ryan
::::::::::::::::::::::::::::::::::::*/
#include "Installer.h"
static char mpc_APPNM[] = "Lotus Notes PGP Plugin",
mpc_SUBFORMNM_PGP[] = "s-PGP E-Mail Plug-In",
mpc_ABT_DOC_LIB[] = "sl-About Document Manipulation",
mpc_FORMNM_MEMO[] = "Memo", mpc_FORMNM_REPLY[] = "Reply",
mpc_FORMNM_REPLY_WH[] = "Reply With History",
mpc_FORMNM_DEFAULT[] = "(Default)", mpc_DELIMITER[] = "|\n",
mpc_FILENM_PGP_TEMPLATE_DEFAULT[] = "PGP Plugin Template.nsf";
static STATUS mus_HANDLED_EXCEPTION = 0xFFFF;
static HANDLE mh_mainWnd, mh_Instance;
/** DllMain( ***
Win32 entry point for loading and unloading this DLL. We use the unload
event to release all Extension Manager hooks and for freeing allocated memory.
--- parameters & return ---
h_DllInstance: the overall handle to this DLL's runtime information, settings
ul_reason: parameter tells why the function was called
pv_reserved: just that, reserved
--- revision history ------
9/20/99 PR: adjusted algorithm for hooking to an expected parent window
2/5/99 PR: created */
BOOL WINAPI DllMain( HINSTANCE h_DllInstance,
DWORD ul_reason,
LPVOID pv_reserved) {
STATUS us_err;
switch (ul_reason) {
case DLL_PROCESS_ATTACH:
//Set up debugging aids and the memory-leak detector in
// particular. Lines are preprocessed out in Release builds.
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG |
_CRTDBG_MODE_WNDW);
_CrtSetDbgFlag( _CRTDBG_LEAK_CHECK_DF |
_CrtSetDbgFlag( _CRTDBG_REPORT_FLAG));
//if the DLL is being invoked by the InstallShield installer...
mh_Instance = h_DllInstance;
if (!( mh_mainWnd = FindWindow( "InstallShield_Win", NULL)))
mh_mainWnd = FindWindow( NULL, "PGPinstl"
/*"c:\\Notes\\client\\PGPinstl.exe"*/);
if (mh_mainWnd) {
char pc_ModuleNm[ MAX_PATH];
//initialize a Notes session
if (!GetModuleFileName( h_DllInstance, pc_ModuleNm, MAX_PATH))
return FALSE;
if (us_err = NotesInitExtended( 1, (char * *) &pc_ModuleNm))
return FALSE;
//else it must be that the DLL is being invoked by the refresh
// button in the plug-in template's About document
}else {
const char pc_CLASSNM_NOTES[] = "NOTES",
pc_CLASSNM_NOTES_FRAME[] = "NOTESframe";
HWND h;
char pc[ sizeof( pc_CLASSNM_NOTES_FRAME) >
sizeof( pc_CLASSNM_NOTES) ?
sizeof( pc_CLASSNM_NOTES_FRAME) :
sizeof( pc_CLASSNM_NOTES)];
//Store the handle of the main window associated with the rich-text
// window currently being operated on by user. Loop is used because
// the different releases of Notes have different window hierarchies.
if (h = GetFocus()) {
do
if (GetClassName( h, pc, sizeof( pc)))
if (strcmp( pc, pc_CLASSNM_NOTES) == ei_SAME ||
strcmp( pc,
pc_CLASSNM_NOTES_FRAME) ==
ei_SAME) {
mh_mainWnd = h;
break;
}
while (h = GetParent( h));
if (!mh_mainWnd)
MessageBox( NULL, "The parent Lotus Notes "
"window\ncould not be "
"determined", mpc_APPNM,
MB_OK | MB_ICONEXCLAMATION);
} //if (h = GetFocus())
} //if (mh_mainWnd)
} //switch (ul_reason)
return TRUE;
} //DllMain(
/** xus_InstallNotesComponents( ***
Controlling procedure for selectively installing the Lotus Notes components
of the PGP Lotus Notes Plug-In into a target Lotus Domino environment.
The tasks of the procedure vary substantially depending on which of the
last four optional parameters are provided. Read parameter description
carefully.
--- suggested enhancement ---
3/16/00 PR: honor input of existing plug-in template filename when refreshing
the template with the template contained in the installer (i.e. the
Create/Refresh wizard option that's indicated by input of the mail
template's filename), thus no longer forcing an organization to use our
default filename for the plug-in template
--- parameters & return ----
pc_SERVERNM: pointer to the name of the Domino server on which the plug-in's
components are to be installed
pc_EXTFILENM_MAIL_TEMPLATE: Optional. Address of the extended filename of the
Notes Mail template whose e-mail forms will be copied to populate/refresh
the PGP Plugin Template database whose base filename is hardcoded in this
module. If NULL, procedure will perform no design refresh; the "install"
is limited to the PGP enabling of particular Notes Mail databases.
pc_EXTFILENM_PGP_TEMPLATE: Optional. Address of the extended filename of the
already installed PGP Plugin Template database. Parameter required if the
Notes Mail template parameter (pc_EXTFILENM_MAIL_TEMPLATE) is not
provided and specific Notes Mail databases are to be PGP enabled (i.e.
either pc_EXTFILENM_DB_LIST or pc_MailDbs was provided). Parameter
ignored if the Notes Mail template parameter is provided.
pc_EXTFILENM_DB_LIST: Optional. Pointer to a string indicating the extended
filename of a text file that contains the list of extended filenames of
the the Notes Mail databases to be PGP enabled. The filenames must be
delimited by a pipe character or linefeed character; whitespace
surrounding each filename is ignored. A pass of NULL or pointer to a null
string indicates that any list of Notes Mail databases to be enabled is
provided via the pc_MailDbs parameter.
pc_MailDbs: Optional Input & Undefined Output. Pointer to a string indicating
the extended filenames of the particular Notes Mail databases to PGP
enable. Each filename must be delimited by a pipe character or linefeed
character; whitespace surrounding each filename is ignored. String will
be tokenized and therefore changed in a way not worth defining (see
documentation on standard strtok() function if understanding is
required). Parameter is ignored if the pc_EXTFILENM_DB_LIST parameter is
non-NULL. A pass of NULL or pointer to a null string indicates that no
explicitly named Notes Mail database are to be enabled by the procedure.
RETURN:
eus_SUCCESS if no error occured
mus_EXCEPTION_HANDLED if any Notes API or module-defined error occurs
undefined error code if some sort of subsystem error occurs (memory
depletion, file system access denied, etc.)
--- revision history -------
8/9/00 PR: changed to the __stdcall calling convention to force the function
to clean up the stack itself
3/16/00 PR: documentation adjustment
9/20/99 PR
+ logic adjustment in conjunction with recast of install routine
+ completed standard documentation
2/6/99 PR: created */
STATUS __stdcall xus_InstallNotesComponents(
char pc_SERVERNM[],
char pc_EXTFILENM_MAIL_TEMPLATE[],
char pc_EXTFILENM_PGP_TEMPLATE[],
const char pc_EXTFILENM_DB_LIST[],
char pc_MailDbs[]) {
const f_MAIL_TEMPLATE = pc_EXTFILENM_MAIL_TEMPLATE &&
*pc_EXTFILENM_MAIL_TEMPLATE,
f_DB_LIST = pc_EXTFILENM_DB_LIST && *pc_EXTFILENM_DB_LIST,
f_MAIL_DBS = pc_MailDbs && *pc_MailDbs;
EnvInfo t_env;
BOOL f_fileInput = FALSE, f_failure = FALSE;
STATUS us_err, us_error;
if (!mh_mainWnd) {
MessageBox( NULL, "PGPinstl.dll failed to attach to an apporpriate\n"
"application parent window",
mpc_APPNM, MB_ICONSTOP);
return !eus_SUCCESS;
}
if (!( pc_SERVERNM && (f_MAIL_TEMPLATE || f_DB_LIST || f_MAIL_DBS) &&
(!f_MAIL_TEMPLATE ?
pc_EXTFILENM_PGP_TEMPLATE &&
*pc_EXTFILENM_PGP_TEMPLATE : TRUE))) {
MessageBox( mh_mainWnd, "Incorrect parameters provided to\n"
"xus_InstallNotesComponents",
mpc_APPNM, MB_ICONSTOP);
return !eus_SUCCESS;
}
if (f_MAIL_TEMPLATE) {
if (us_err = us_InstallPlugInTemplate( pc_SERVERNM,
pc_EXTFILENM_MAIL_TEMPLATE,
mpc_FILENM_PGP_TEMPLATE_DEFAULT, &t_env))
goto errJump;
}else if (f_DB_LIST || f_MAIL_DBS) {
memset( &t_env, NULL, sizeof( EnvInfo));
if (us_err = us_GetSourceEnvInfo( pc_SERVERNM,
pc_EXTFILENM_PGP_TEMPLATE, &t_env))
goto errJump;
if (us_err = NIFFindDesignNote( t_env.h_template,
mpc_SUBFORMNM_PGP, NOTE_CLASS_FORM,
&t_env.nid_PgpSubform))
goto errJump;
} //if (f_MAIL_TEMPLATE)
if (f_DB_LIST || f_MAIL_DBS) {
char * pc_mereErrLog;
us_err = us_RefreshMailDbs( pc_SERVERNM, f_DB_LIST ?
pc_EXTFILENM_DB_LIST : NULL,
pc_MailDbs, &t_env, &pc_mereErrLog);
if (pc_mereErrLog) {
FILE * pfl;
//let the user know about any "mere" errors
if (f_failure = !(pfl = fopen( "PGPLog.txt", "wtc")))
goto errJump;
fprintf( pfl, pc_mereErrLog);
fclose( pfl); //ignore failure
MessageBox( mh_mainWnd, f_DB_LIST ? "Some databases could not "
"be processed. Refer to\nPGPLog.txt "
"in the Notes Program directory "
"for details." : pc_mereErrLog,
mpc_APPNM, MB_ICONEXCLAMATION);
free( pc_mereErrLog);
} //if (pc_mereErrLog)
} //if (f_DB_LIST || f_MAIL_DBS)
errJump:
if (t_env.h_template)
if ((us_error = NSFDbClose( t_env.h_template)) && !us_err)
us_err = us_error;
if (us_err && us_err != mus_HANDLED_EXCEPTION) {
char pc_msg[ 512] = "An unexpected error occurred, translated by "
"Notes as\n\"";
OSLoadString( mh_Instance, ERR( us_err), pc_msg + strlen( pc_msg),
(WORD) (512 - 2 - strlen( pc_msg)));
sprintf( pc_msg + strlen( pc_msg), "\" (%hx)", us_err);
MessageBox( mh_mainWnd, pc_msg, mpc_APPNM, MB_ICONSTOP);
us_err = mus_HANDLED_EXCEPTION;
} //if (us_err &&
return us_err + f_failure;
} //xus_InstallNotesComponents(
/** xus_RefreshPgpTemplateForms( ***
Refreshes the e-mail forms in the PGP Plug-In template using the counterpart
forms stored in the specified Notes Mail template.
--- parameters & return ----
pc_EXTFILENM_MAIL_TEMPLATE: Pointer to the extended filename of the Notes
Mail template on the given server. The path component of the filename is
used to construct the required directory location of the PGP Plugin
Template database (thus the location to check for that template's
presence).
pc_SERVERNM: pointer to the name of the server on which the Notes Mail
template resides
pc_FILENM_PGP_TEMPLATE: pointer to the filename of the PGP Plugin Template
database, shorn of any path information as the template must reside in
the same directory as the specified Notes Mail template
RETURN:
eus_SUCCESS if no error occured
!eus_SUCCESS if obviously invalid parameters were passed in the procedure
call
mus_EXCEPTION_HANDLED if an anticipated error condition was handled via a
message-box prompt
the Notes API error code otherwise
--- revision history -------
3/16/00 PR
+ adjustment to support change in how subforms are inserted in R5
+ safety improvement
9/20/99 PR: created */
WORD xus_RefreshPgpTemplateForms( char pc_SERVERNM[],
char pc_EXTFILENM_MAIL_TEMPLATE[],
char pc_FILENM_PGP_TEMPLATE[]) {
DBHANDLE h_MailTemplate, h_PgpTemplate = NULLHANDLE;
NOTEID nid;
STATUS us_err, us_error;
if (!( pc_SERVERNM && pc_EXTFILENM_MAIL_TEMPLATE &&
pc_FILENM_PGP_TEMPLATE))
return !eus_SUCCESS;
if (us_err = us_OpenMailTemplate( pc_EXTFILENM_MAIL_TEMPLATE,
pc_SERVERNM, &h_MailTemplate, NULL))
return us_err;
if (!h_MailTemplate)
return mus_HANDLED_EXCEPTION;
//open the PGP plug-in template that should be in the same directory as
// the mail template
if (us_err = us_TestPgpTemplatePlaced( pc_FILENM_PGP_TEMPLATE,
pc_SERVERNM, pc_EXTFILENM_MAIL_TEMPLATE,
&h_PgpTemplate, NULL, NULL))
goto errJump;
if (!h_PgpTemplate) {
us_err = mus_HANDLED_EXCEPTION;
goto errJump;
}
//confirm that the plug-in subform is present, then PGP-enable each of
// the significant e-mail forms, copying them from the mail template
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -