зеркало из https://github.com/mozilla/pjs.git
Bug #172844 Installer for Mozilla PalmSync Conduit
This is the implementation for the PalmSync Conduit which enables the synchronization between Mozilla AB and Palm. This is built as a separate executable, to build this Palm CDK should be installed and PALM_CDK_DIR environment variable should be set to it's location. r=ssu, sr=dveditz
This commit is contained in:
Родитель
731cd7ee22
Коммит
828e1c135a
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2002 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
PALM_CDK_INC = $(PALM_CDK_DIR)/C++/Include
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
PROGRAM = PalmSyncInstall$(BIN_SUFFIX)
|
||||
REQUIRES = $(ZLIB_REQUIRES)
|
||||
RESFILE = PalmSyncInstall.res
|
||||
USE_NON_MT_LIBS = 1
|
||||
|
||||
LOCAL_INCLUDES += -I$(PALM_CDK_INC) \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = PalmSyncInstall.cpp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
LDFLAGS += /SUBSYSTEM:WINDOWS /MACHINE:i386
|
||||
|
||||
libs:: $(PROGRAM)
|
||||
$(INSTALL) $(PROGRAM) $(DIST)/install
|
||||
$(DIST)/install/nszip$(BIN_SUFFIX) $(DIST)/install/nsinstall$(BIN_SUFFIX)
|
||||
|
||||
install:: $(PROGRAM)
|
||||
$(SYSINSTALL) $(IFLAGS2) $(PROGRAM) $(DESTDIR)$(mozappdir)/install
|
||||
$(DIST)/install/$(PROGRAM) -g $(DESTDIR)$(mozappdir)/install/nszip$(BIN_SUFFIX) $(DESTDIR)$(mozappdir)/install/nsinstall$(BIN_SUFFIX)
|
||||
|
||||
clean clobber clobber_all realclean::
|
||||
$(RM) $(DIST)/install/$(PROGRAM)
|
|
@ -0,0 +1,511 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Rajiv Dayal <rdayal@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "CondMgr.h"
|
||||
#include "HSAPI.h"
|
||||
#include "resource.h"
|
||||
|
||||
#define CONDMGR_HSAPI_DIR "."
|
||||
#define CREATOR "addr"
|
||||
#define CONDUIT_FILENAME "mozABConduit.dll"
|
||||
#define REMOTE_DB "AddressDB"
|
||||
#define CONDUIT_NAME "address"
|
||||
#define CONDUIT_PRIORITY 2
|
||||
|
||||
#define CONDMGR_FILENAME "CondMgr.dll"
|
||||
#define HSAPI_FILENAME "HsApi.dll"
|
||||
#define DIRECTORY_SEPARATOR '\\'
|
||||
#define DIRECTORY_SEPARATOR_STR "\\"
|
||||
#define EXECUTABLE_EXTENSION ".exe"
|
||||
#define HOTSYNC_MAX_WAIT 30 // wait for HotSync to start/stop in seconds
|
||||
|
||||
#define MAX_LOADSTRING 256
|
||||
|
||||
// Define any Conduit Manager function pointer types
|
||||
typedef int (WINAPI *CmGetCorePathPtr)(TCHAR *pPath, int *piSize);
|
||||
typedef int (WINAPI *CmGetHotSyncExecPathPtr)(char *szPath, int *iSize);
|
||||
|
||||
typedef int (WINAPI *CmInstallCreatorPtr)(const char *pCreator, int iType);
|
||||
typedef int (WINAPI *CmRemoveConduitByCreatorIDPtr)(const char *pCreator);
|
||||
typedef int (WINAPI *CmRestoreHotSyncSettingsPtr)(BOOL bToDefaults);
|
||||
typedef int (WINAPI *CmSetCreatorRemotePtr)(const char *pCreator, const TCHAR *pRemote);
|
||||
typedef int (WINAPI *CmSetCreatorNamePtr)(const char *pCreator, const TCHAR *pConduitName);
|
||||
typedef int (WINAPI *CmSetCreatorPriorityPtr)(const char *pCreator, DWORD dwPriority);
|
||||
typedef int (WINAPI *CmSetCreatorIntegratePtr)(const char *pCreator, DWORD dwIntegrate);
|
||||
typedef int (WINAPI *CmSetCreatorValueDwordPtr)(const char *pCreator, TCHAR *pValue, DWORD dwValue);
|
||||
|
||||
// Define any HSAPI function pointer types
|
||||
typedef int (WINAPI *HsCheckApiStatusPtr)(void);
|
||||
typedef int (WINAPI *HsGetSyncStatusPtr)(DWORD *dwStatus);
|
||||
typedef int (WINAPI *HsSetAppStatusPtr)(HsStatusType statusType, DWORD dwStartFlags);
|
||||
|
||||
// forward declaration
|
||||
int InstallConduit();
|
||||
int UninstallConduit();
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
TCHAR appTitle[128];
|
||||
LoadString(hInstance, IDS_APP_TITLE, appTitle, MAX_LOADSTRING);
|
||||
|
||||
TCHAR msgStr[256];
|
||||
int strResource=0;
|
||||
int res=-1;
|
||||
if(!strcmp(lpCmdLine,"/u")) // un-install
|
||||
{
|
||||
LoadString(hInstance, IDS_CONFIRM_UNINSTALL, msgStr, MAX_LOADSTRING);
|
||||
if (MessageBox(NULL, msgStr, appTitle, MB_YESNO) == IDYES)
|
||||
{
|
||||
res = UninstallConduit();
|
||||
if(!res)
|
||||
res = IDS_SUCCESS_UNINSTALL;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(lpCmdLine,"/us")) // silent un-install
|
||||
{
|
||||
res = UninstallConduit();
|
||||
if(!res)
|
||||
return TRUE; // success
|
||||
return res;
|
||||
}
|
||||
else if (!strcmp(lpCmdLine,"/s")) // silent install
|
||||
{
|
||||
res = InstallConduit();
|
||||
if(!res)
|
||||
return TRUE; // success
|
||||
return res;
|
||||
}
|
||||
else // install
|
||||
{
|
||||
LoadString(hInstance, IDS_CONFIRM_INSTALL, msgStr, MAX_LOADSTRING);
|
||||
if (MessageBox(NULL, msgStr, appTitle, MB_YESNO) == IDYES)
|
||||
{
|
||||
res = InstallConduit();
|
||||
if(!res)
|
||||
res = IDS_SUCCESS_INSTALL;
|
||||
}
|
||||
}
|
||||
|
||||
// if user hits no
|
||||
if(res == -1)
|
||||
return TRUE;
|
||||
|
||||
if(res > IDS_ERR_MAX || res < IDS_ERR_GENERAL)
|
||||
res = IDS_ERR_GENERAL;
|
||||
LoadString(hInstance, res, msgStr, MAX_LOADSTRING);
|
||||
MessageBox(NULL, msgStr, appTitle, MB_OK);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// this function gets the install dir for installation
|
||||
int GetPalmDesktopInstallDirectory(HINSTANCE hCondMgrDll, TCHAR *pPDInstallDirectory,
|
||||
int *pSize )
|
||||
{
|
||||
int dwReturnCode;
|
||||
|
||||
// Get the Palm Desktop Installation directory
|
||||
CmGetHotSyncExecPathPtr lpfnCmGetHotSyncExecPath;
|
||||
lpfnCmGetHotSyncExecPath = (CmGetHotSyncExecPathPtr) GetProcAddress(hCondMgrDll, "CmGetHotSyncExecPath");
|
||||
|
||||
if( lpfnCmGetHotSyncExecPath == NULL )
|
||||
// Invalid Conduit Manager Library - missing functions
|
||||
return IDS_ERR_LOADING_CONDMGR;
|
||||
|
||||
if( (dwReturnCode=(*lpfnCmGetHotSyncExecPath)(pPDInstallDirectory, pSize)) != 0)
|
||||
// Error determining Palm Desktop install directory,
|
||||
// return the Conduit Manager error code.
|
||||
return dwReturnCode;
|
||||
|
||||
if( strstr( pPDInstallDirectory, EXECUTABLE_EXTENSION ) != NULL )
|
||||
{
|
||||
// Remove the "HotSync.exe" portion
|
||||
char* cPtr = &(pPDInstallDirectory[*pSize]);
|
||||
while( cPtr >= pPDInstallDirectory )
|
||||
{
|
||||
if( *cPtr == DIRECTORY_SEPARATOR )
|
||||
{
|
||||
*cPtr = '\0';
|
||||
break;
|
||||
}
|
||||
cPtr--;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the size of the returned path
|
||||
*pSize = strlen(pPDInstallDirectory);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// this function loads the Conduit Manager
|
||||
int LoadConduitManagerDll(HINSTANCE* hCondMgrDll)
|
||||
{
|
||||
int dwReturnCode;
|
||||
HINSTANCE hInstallerCondMgrDll;
|
||||
|
||||
// Initialize the return value
|
||||
*hCondMgrDll=NULL;
|
||||
|
||||
// load the temporary Conduit Manager Dll shipped with our Installer
|
||||
TCHAR szInstallerCondMgrPath[_MAX_PATH];
|
||||
strncpy(szInstallerCondMgrPath, CONDMGR_HSAPI_DIR, _MAX_PATH);
|
||||
strncat(szInstallerCondMgrPath, DIRECTORY_SEPARATOR_STR, _MAX_PATH-strlen(szInstallerCondMgrPath));
|
||||
strncat(szInstallerCondMgrPath, CONDMGR_FILENAME, _MAX_PATH-strlen(szInstallerCondMgrPath));
|
||||
if( (hInstallerCondMgrDll=LoadLibrary(szInstallerCondMgrPath)) == NULL )
|
||||
// Error loading temporary Conduit Manager Library
|
||||
return IDS_ERR_LOADING_CONDMGR;
|
||||
|
||||
// Get the Palm Desktop Installation directory
|
||||
TCHAR szPalmDesktopDir[_MAX_PATH];
|
||||
int size=_MAX_PATH;
|
||||
if( (dwReturnCode=GetPalmDesktopInstallDirectory(hInstallerCondMgrDll, szPalmDesktopDir, &size)) != 0 )
|
||||
return IDS_ERR_FINDING_INSTALL_DIR;
|
||||
|
||||
// Construct the path of the Palm Desktop Conduit Manager
|
||||
TCHAR szPDCondMgrPath[_MAX_PATH];
|
||||
strncpy(szPDCondMgrPath, szPalmDesktopDir, _MAX_PATH);
|
||||
strncat(szPDCondMgrPath, DIRECTORY_SEPARATOR_STR, _MAX_PATH-strlen(szPDCondMgrPath));
|
||||
strncat(szPDCondMgrPath, CONDMGR_FILENAME, _MAX_PATH-strlen(szPDCondMgrPath));
|
||||
|
||||
// Load the Conduit Manager library from the Palm Desktop directory
|
||||
if( (*hCondMgrDll=LoadLibrary(szPDCondMgrPath)) == NULL )
|
||||
{
|
||||
// Error loading Palm Desktop Conduit Manager library
|
||||
// use the one we shipped with the installer
|
||||
*hCondMgrDll = hInstallerCondMgrDll;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Success loading the Palm Desktop Conduit Manager
|
||||
// free the Conduit Manager shipped with our installer
|
||||
FreeLibrary(hInstallerCondMgrDll);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// this function loads the Hsapi Dll
|
||||
int LoadHsapiDll(HINSTANCE* hHsapiDLL, const char* szPalmDesktopDirectory)
|
||||
{
|
||||
// Initialize the return value
|
||||
*hHsapiDLL=NULL;
|
||||
|
||||
// First, try loading the HSAPI Dll from the Palm Desktop directory
|
||||
TCHAR szHsapiPath[_MAX_PATH];
|
||||
strncpy(szHsapiPath, szPalmDesktopDirectory, _MAX_PATH);
|
||||
strncat(szHsapiPath, DIRECTORY_SEPARATOR_STR, _MAX_PATH-strlen(szHsapiPath));
|
||||
strncat(szHsapiPath, HSAPI_FILENAME, _MAX_PATH-strlen(szHsapiPath));
|
||||
if( (*hHsapiDLL=LoadLibrary(szHsapiPath)) != NULL )
|
||||
// Successfully loaded HSAPI Library from Palm Desktop Directory
|
||||
return 0;
|
||||
|
||||
// Second, try loading the HSAPI Dll included with the our installer
|
||||
strncpy(szHsapiPath, CONDMGR_HSAPI_DIR, _MAX_PATH);
|
||||
strncat(szHsapiPath, DIRECTORY_SEPARATOR_STR, _MAX_PATH-strlen(szHsapiPath));
|
||||
strncat(szHsapiPath, HSAPI_FILENAME, _MAX_PATH-strlen(szHsapiPath));
|
||||
if( (*hHsapiDLL=LoadLibrary(szHsapiPath)) != NULL )
|
||||
// Successfully loaded HSAPI Library from support directory
|
||||
return 0;
|
||||
|
||||
// If we get here, then there was an error loading the library
|
||||
return IDS_ERR_HSAPI_NOT_FOUND;
|
||||
}
|
||||
|
||||
// finds if HotSync Manager is running
|
||||
BOOL IsHotSyncRunning(HINSTANCE hHsapiDLL)
|
||||
{
|
||||
BOOL bRetVal = FALSE;
|
||||
|
||||
if(!hHsapiDLL)
|
||||
return bRetVal;
|
||||
|
||||
// Prepare to use the HSAPI functions
|
||||
HsCheckApiStatusPtr lpfnHsCheckApiStatus;
|
||||
lpfnHsCheckApiStatus = (HsCheckApiStatusPtr) GetProcAddress(hHsapiDLL, "HsCheckApiStatus");
|
||||
|
||||
if( lpfnHsCheckApiStatus )
|
||||
{
|
||||
if( (*lpfnHsCheckApiStatus)() == 0 )
|
||||
bRetVal = TRUE;
|
||||
}
|
||||
return bRetVal;
|
||||
}
|
||||
|
||||
// finds if a sync process is going on
|
||||
BOOL IsHotSyncInProgress(HINSTANCE hHsapiDLL)
|
||||
{
|
||||
DWORD dwStatus;
|
||||
|
||||
if(!hHsapiDLL)
|
||||
return FALSE;
|
||||
|
||||
if(IsHotSyncRunning(hHsapiDLL))
|
||||
{
|
||||
// Prepare to use the HSAPI functions
|
||||
HsGetSyncStatusPtr lpfnHsGetSyncStatus;
|
||||
lpfnHsGetSyncStatus = (HsGetSyncStatusPtr) GetProcAddress(hHsapiDLL, "HsGetSyncStatus");
|
||||
|
||||
if( lpfnHsGetSyncStatus )
|
||||
{
|
||||
if( (*lpfnHsGetSyncStatus)(&dwStatus) == 0 )
|
||||
if( dwStatus == HOTSYNC_STATUS_IDLE )
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// shuts down the HotSync Manager
|
||||
void ShutdownHotSync(HINSTANCE hHsapiDLL)
|
||||
{
|
||||
if(!hHsapiDLL)
|
||||
return;
|
||||
|
||||
BOOL bHotSyncRunning=IsHotSyncRunning(hHsapiDLL);
|
||||
|
||||
if(bHotSyncRunning)
|
||||
{
|
||||
// Prepare to use the HSAPI functions
|
||||
HsSetAppStatusPtr lpfnHsSetAppStatus;
|
||||
lpfnHsSetAppStatus = (HsSetAppStatusPtr) GetProcAddress(hHsapiDLL, "HsSetAppStatus");
|
||||
|
||||
if( lpfnHsSetAppStatus )
|
||||
(*lpfnHsSetAppStatus)(HsCloseApp, HSFLAG_NONE);
|
||||
|
||||
// Wait for HotSync to stop
|
||||
for( int i=0; (i<HOTSYNC_MAX_WAIT*2) && bHotSyncRunning; i++ )
|
||||
{
|
||||
if( (bHotSyncRunning=IsHotSyncRunning(hHsapiDLL)) == TRUE )
|
||||
Sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// starts HotSync Manager if not runnning
|
||||
void StartHotSync(HINSTANCE hHsapiDLL)
|
||||
{
|
||||
if(!hHsapiDLL)
|
||||
return;
|
||||
|
||||
BOOL bHotSyncRunning=IsHotSyncRunning(hHsapiDLL);
|
||||
|
||||
if(!bHotSyncRunning)
|
||||
{
|
||||
// Prepare to use the HSAPI functions
|
||||
HsSetAppStatusPtr lpfnHsSetAppStatus;
|
||||
lpfnHsSetAppStatus = (HsSetAppStatusPtr) GetProcAddress(hHsapiDLL, "HsSetAppStatus");
|
||||
|
||||
if( lpfnHsSetAppStatus )
|
||||
(*lpfnHsSetAppStatus)(HsStartApp, HSFLAG_NONE);
|
||||
|
||||
// Wait for HotSync to start
|
||||
for( int i=0; (i<HOTSYNC_MAX_WAIT*2) && !bHotSyncRunning; i++ )
|
||||
{
|
||||
if( (bHotSyncRunning=IsHotSyncRunning(hHsapiDLL)) == FALSE )
|
||||
Sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// installs our Conduit
|
||||
int InstallConduit()
|
||||
{
|
||||
int dwReturnCode;
|
||||
BOOL bHotSyncRunning = FALSE;
|
||||
|
||||
// Prepare the full path of the conduit.
|
||||
// Applications should not place conduits in the Palm Desktop directory.
|
||||
// The Palm Desktop installer only manages the Palm Desktop conduits.
|
||||
TCHAR szConduitPath[_MAX_PATH];
|
||||
if(!GetCurrentDirectory(_MAX_PATH, szConduitPath))
|
||||
return IDS_ERR_CONDUIT_NOT_FOUND;
|
||||
strncat(szConduitPath, DIRECTORY_SEPARATOR_STR, _MAX_PATH-strlen(szConduitPath));
|
||||
strncat(szConduitPath, CONDUIT_FILENAME, _MAX_PATH-strlen(szConduitPath));
|
||||
|
||||
// Make sure the conduit dll exists
|
||||
struct _finddata_t dll_file;
|
||||
long hFile;
|
||||
if( (hFile = _findfirst( szConduitPath, &dll_file )) == -1L )
|
||||
return IDS_ERR_CONDUIT_NOT_FOUND;
|
||||
|
||||
// Load the Conduit Manager DLL.
|
||||
HINSTANCE hConduitManagerDLL;
|
||||
if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL)) != 0 )
|
||||
return(dwReturnCode);
|
||||
|
||||
// Prepare to install the conduit using Conduit Manager functions
|
||||
CmInstallCreatorPtr lpfnCmInstallCreator;
|
||||
lpfnCmInstallCreator = (CmInstallCreatorPtr) GetProcAddress(hConduitManagerDLL, "CmInstallCreator");
|
||||
CmSetCreatorRemotePtr lpfnCmSetCreatorRemote;
|
||||
lpfnCmSetCreatorRemote = (CmSetCreatorRemotePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorRemote");
|
||||
CmSetCreatorNamePtr lpfnCmSetCreatorName;
|
||||
lpfnCmSetCreatorName = (CmSetCreatorNamePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorName");
|
||||
CmSetCreatorPriorityPtr lpfnCmSetCreatorPriority;
|
||||
lpfnCmSetCreatorPriority = (CmSetCreatorPriorityPtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorPriority");
|
||||
CmSetCreatorIntegratePtr lpfnCmSetCreatorIntegrate;
|
||||
lpfnCmSetCreatorIntegrate = (CmSetCreatorIntegratePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorIntegrate");
|
||||
CmRemoveConduitByCreatorIDPtr lpfnCmRemoveConduitByCreatorID;
|
||||
lpfnCmRemoveConduitByCreatorID = (CmRemoveConduitByCreatorIDPtr) GetProcAddress(hConduitManagerDLL, "CmRemoveConduitByCreatorID");
|
||||
|
||||
if( (lpfnCmInstallCreator == NULL)
|
||||
|| (lpfnCmSetCreatorRemote == NULL)
|
||||
|| (lpfnCmSetCreatorName == NULL)
|
||||
|| (lpfnCmSetCreatorPriority == NULL)
|
||||
|| (lpfnCmSetCreatorIntegrate == NULL)
|
||||
)
|
||||
{
|
||||
// Return error code.
|
||||
return(IDS_ERR_LOADING_CONDMGR);
|
||||
}
|
||||
|
||||
// Get the Palm Desktop Installation directory
|
||||
TCHAR szPalmDesktopDir[_MAX_PATH];
|
||||
int size=_MAX_PATH;
|
||||
if( (dwReturnCode=GetPalmDesktopInstallDirectory(hConduitManagerDLL, szPalmDesktopDir, &size)) != 0 )
|
||||
return dwReturnCode;
|
||||
|
||||
// Load the HSAPI DLL.
|
||||
HINSTANCE hHsapiDLL;
|
||||
if( (dwReturnCode = LoadHsapiDll(&hHsapiDLL, szPalmDesktopDir)) != 0 )
|
||||
return(dwReturnCode);
|
||||
|
||||
// Shutdown the HotSync Process if it is running
|
||||
if( (bHotSyncRunning=IsHotSyncRunning(hHsapiDLL)) )
|
||||
{
|
||||
// Check for any synchronizations in progress
|
||||
if( IsHotSyncInProgress(hHsapiDLL) )
|
||||
return IDS_ERR_HOTSYNC_IN_PROGRESS;
|
||||
|
||||
ShutdownHotSync(hHsapiDLL);
|
||||
}
|
||||
|
||||
// Actually install the conduit as an Application Conduit
|
||||
dwReturnCode = (*lpfnCmInstallCreator)(CREATOR, CONDUIT_APPLICATION);
|
||||
if(dwReturnCode == ERR_CREATORID_ALREADY_IN_USE) {
|
||||
dwReturnCode = (*lpfnCmRemoveConduitByCreatorID)(CREATOR);
|
||||
if(dwReturnCode >= 0 ) {
|
||||
//free the library so that the existing AB Conduit is unloaded properly
|
||||
FreeLibrary(hConduitManagerDLL);
|
||||
FreeLibrary(hHsapiDLL);
|
||||
return InstallConduit();
|
||||
}
|
||||
}
|
||||
if( dwReturnCode == 0 )
|
||||
{
|
||||
dwReturnCode = (*lpfnCmSetCreatorName)(CREATOR, szConduitPath);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
dwReturnCode = (*lpfnCmSetCreatorRemote)(CREATOR, REMOTE_DB);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
dwReturnCode = (*lpfnCmSetCreatorPriority)(CREATOR, CONDUIT_PRIORITY);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
// Applications should always set Integrate to 0
|
||||
dwReturnCode = (*lpfnCmSetCreatorIntegrate)(CREATOR, (DWORD)0);
|
||||
}
|
||||
|
||||
// Re-start HotSync if it was running before
|
||||
if( bHotSyncRunning )
|
||||
StartHotSync(hHsapiDLL);
|
||||
|
||||
return(dwReturnCode);
|
||||
}
|
||||
|
||||
// uninstalls our conduit
|
||||
int UninstallConduit()
|
||||
{
|
||||
int dwReturnCode;
|
||||
BOOL bHotSyncRunning = FALSE;
|
||||
|
||||
// Load the Conduit Manager DLL.
|
||||
HINSTANCE hConduitManagerDLL;
|
||||
if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL)) != 0 )
|
||||
return(dwReturnCode);
|
||||
|
||||
// Prepare to uninstall the conduit using Conduit Manager functions
|
||||
CmRemoveConduitByCreatorIDPtr lpfnCmRemoveConduitByCreatorID;
|
||||
lpfnCmRemoveConduitByCreatorID = (CmRemoveConduitByCreatorIDPtr) GetProcAddress(hConduitManagerDLL, "CmRemoveConduitByCreatorID");
|
||||
if( (lpfnCmRemoveConduitByCreatorID == NULL) )
|
||||
return(IDS_ERR_LOADING_CONDMGR);
|
||||
CmRestoreHotSyncSettingsPtr lpfnCmRestoreHotSyncSettings;
|
||||
lpfnCmRestoreHotSyncSettings = (CmRestoreHotSyncSettingsPtr) GetProcAddress(hConduitManagerDLL, "CmRestoreHotSyncSettings");
|
||||
if( (lpfnCmRestoreHotSyncSettings == NULL) )
|
||||
return(IDS_ERR_LOADING_CONDMGR);
|
||||
|
||||
// Get the Palm Desktop Installation directory
|
||||
TCHAR szPalmDesktopDir[_MAX_PATH];
|
||||
int size=_MAX_PATH;
|
||||
if( (dwReturnCode=GetPalmDesktopInstallDirectory(hConduitManagerDLL, szPalmDesktopDir, &size)) != 0 )
|
||||
return dwReturnCode;
|
||||
|
||||
// Load the HSAPI DLL.
|
||||
HINSTANCE hHsapiDLL;
|
||||
if( (dwReturnCode = LoadHsapiDll(&hHsapiDLL, szPalmDesktopDir)) != 0 )
|
||||
return(dwReturnCode);
|
||||
|
||||
// Shutdown the HotSync Process if it is running
|
||||
if( (bHotSyncRunning=IsHotSyncRunning(hHsapiDLL)) )
|
||||
{
|
||||
// Check for any synchronizations in progress
|
||||
if( IsHotSyncInProgress(hHsapiDLL) )
|
||||
return IDS_ERR_HOTSYNC_IN_PROGRESS;
|
||||
|
||||
ShutdownHotSync(hHsapiDLL);
|
||||
}
|
||||
|
||||
// Actually uninstall the conduit
|
||||
dwReturnCode = (*lpfnCmRemoveConduitByCreatorID)(CREATOR);
|
||||
if(dwReturnCode >= 0)
|
||||
dwReturnCode = (*lpfnCmRestoreHotSyncSettings)(TRUE);
|
||||
|
||||
// Re-start HotSync if it was running before
|
||||
if( bHotSyncRunning )
|
||||
StartHotSync(hHsapiDLL);
|
||||
|
||||
if( dwReturnCode < 0 )
|
||||
return dwReturnCode;
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Rajiv Dayal <rdayal@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "resource.h"
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APP_TITLE "Mozilla PalmSync Install"
|
||||
IDC_PALMSYNCINSTALL "PALMSYNCINSTALL"
|
||||
IDS_ERR_GENERAL "Error in installing the Mozilla Address Book Palm Sync Conduit"
|
||||
IDS_ERR_LOADING_CONDMGR "Error in loading the Conduit Manager while installing the Mozilla Address Book Palm Sync Conduit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_ERR_HSAPI_NOT_FOUND "Could not find the HSAPI.dll while installing the Mozilla Address Book Palm Sync Conduit"
|
||||
IDS_ERR_CONDUIT_NOT_FOUND
|
||||
"Could not find the Mozilla Address Book Palm Sync Conduit to install"
|
||||
IDS_ERR_HOTSYNC_IN_PROGRESS
|
||||
"A Palm HotSync operation is in progress, let it complete first then install the Mozilla Address Book Palm Sync Conduit"
|
||||
IDS_ERR_FINDING_INSTALL_DIR
|
||||
"Could not find the directory to install the Mozilla Address Book Palm Sync Conduit."
|
||||
IDS_SUCCESS_INSTALL "Mozilla Address Book Palm Sync Conduit has been successfully installed. Now when you do an HotSync operation from your Palm handheld device, the Address Book on the handheld will sync with Mozilla's Address Book."
|
||||
IDS_SUCCESS_UNINSTALL "Mozilla Address Book Palm Sync Conduit has been successfully Uninstalled. The Palm Desktop configuration has been restored for you to enable synchronization of your Address Book on the handheld with Palm Desktop."
|
||||
IDS_CONFIRM_INSTALL "Click Yes to Install the Mozilla Address Book PalmSync Conduit, which will enable address book synchronization between Mozilla Address Book and Palm handheld Address Book. Note this will replace the synchronization with Palm Desktop."
|
||||
IDS_CONFIRM_UNINSTALL "Click Yes to Un-Install the Mozilla Address Book PalmSync Conduit. Note this will restore the synchronization with Palm Desktop."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,56 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Rajiv Dayal <rdayal@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define IDS_APP_TITLE 103
|
||||
#define IDI_PALMSYNCINSTALL 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_PALMSYNCINSTALL 109
|
||||
|
||||
// all error messages should be between the range of 110 and 140
|
||||
#define IDS_ERR_GENERAL 110
|
||||
#define IDS_ERR_LOADING_CONDMGR 111
|
||||
#define IDS_ERR_HSAPI_NOT_FOUND 112
|
||||
#define IDS_ERR_CONDUIT_NOT_FOUND 113
|
||||
#define IDS_ERR_HOTSYNC_IN_PROGRESS 114
|
||||
#define IDS_ERR_FINDING_INSTALL_DIR 115
|
||||
#define IDS_SUCCESS_INSTALL 116
|
||||
#define IDS_CONFIRM_INSTALL 117
|
||||
#define IDS_CONFIRM_UNINSTALL 118
|
||||
#define IDS_SUCCESS_UNINSTALL 119
|
||||
#define IDS_ERR_MAX 140
|
||||
|
Загрузка…
Ссылка в новой задаче