Bug 495232 Drop support for the Palm Sync Extension. mailnews part. r=Mnyromyr,sr=bienvenu
This commit is contained in:
Родитель
d3cb0b952e
Коммит
0aae2ca5d6
|
@ -44,10 +44,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
MODULE = mailnews
|
||||
|
||||
PARALLEL_DIRS += base/search/src db/msgdb db/gloda news local mime compose imap addrbook import
|
||||
|
||||
# extensions (e.g. palmsync) can depend of things built in other dirs
|
||||
DIRS += extensions
|
||||
PARALLEL_DIRS += base/search/src db/msgdb db/gloda news local mime compose imap addrbook import extensions
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
ifndef GNU_CC
|
||||
|
|
|
@ -112,7 +112,6 @@ EXTRA_COMPONENTS += \
|
|||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsAbCardProperty.h \
|
||||
nsVCardObj.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -53,9 +53,5 @@ ifdef BUILD_SMIME
|
|||
PARALLEL_DIRS += smime
|
||||
endif
|
||||
|
||||
ifdef BUILD_PALMSYNC
|
||||
PARALLEL_DIRS += palmsync
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
#
|
||||
# ***** 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = palmsync
|
||||
XPI_NAME = palmsync
|
||||
USE_EXTENSION_MANIFEST = 1
|
||||
# make this id as short as possible due to a bug with the palm deskop and long path names.
|
||||
# Change installer/Makefile.in and nsPalmSyncSupport.cpp if this changes.
|
||||
INSTALL_EXTENSION_ID = p@m
|
||||
XPI_PKGNAME = palmsync-$(MOZ_APP_VERSION)
|
||||
DIST_FILES = install.rdf
|
||||
|
||||
DIRS = build public src installer
|
||||
|
||||
PREF_JS_EXPORTS = $(srcdir)/palmsync.js
|
||||
|
||||
ifdef MOZILLA_1_9_1_BRANCH
|
||||
THUNDERBIRD_VERSION := $(shell cat $(topsrcdir)/mail/config/version-191.txt)
|
||||
else
|
||||
THUNDERBIRD_VERSION := $(shell cat $(topsrcdir)/mail/config/version.txt)
|
||||
endif
|
||||
SEAMONKEY_VERSION := $(shell cat $(topsrcdir)/suite/config/version.txt)
|
||||
|
||||
XULAPP_DEFINES = \
|
||||
-DINSTALL_EXTENSION_ID=$(INSTALL_EXTENSION_ID) \
|
||||
-DTHUNDERBIRD_VERSION=$(THUNDERBIRD_VERSION) \
|
||||
-DSEAMONKEY_VERSION=$(SEAMONKEY_VERSION) \
|
||||
-DEXTENSION_VERSION=$(MOZILLA_VERSION) \
|
||||
$(NULL)
|
||||
|
||||
ifdef PALM_CDK_DIR
|
||||
DIRS += conduit
|
||||
else
|
||||
libs::
|
||||
@echo " "
|
||||
@echo "PLEASE SET 'PALM_CDK_DIR' ENV VARIABLE to THE DIR WHERE YOU HAVE PALM CDK INSTALLED IF YOU WANT TO BUILD THE CONDUIT"
|
||||
@echo " "
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -1,168 +0,0 @@
|
|||
/* ***** 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
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* 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 ***** */
|
||||
|
||||
// This idl will be compiled by MIDL. MS-COM is used
|
||||
// as brdige between MAPI clients and the Mozilla.
|
||||
|
||||
import "unknwn.idl";
|
||||
|
||||
// this is defined so that we can return an array of strings(i.e array of AB Description strings)
|
||||
typedef struct
|
||||
{
|
||||
LPTSTR lpszABName;
|
||||
LPTSTR lpszABUrl;
|
||||
}nsMozABDesc, *lpnsMozABDesc;
|
||||
|
||||
const int kFirstTimeSyncDirFlag = 0x1;
|
||||
const int kIsPabDirFlag = 0x2;
|
||||
|
||||
// This structure defines the data fields for MozAB based on "nsIAbCard.idl"
|
||||
// This structure is used for interaction with the other AddressBook Apps
|
||||
// nsIAbCard changes should be reflected here to take care of those changes
|
||||
// Take care when converting nsIAbCard to this struct
|
||||
typedef struct
|
||||
{
|
||||
unsigned long dwRecordId; // remote record Id for this card
|
||||
unsigned long dwCategoryId; // remote category Id for this card
|
||||
unsigned long dwStatus; // change status for this card
|
||||
|
||||
// standard AB fields for this card
|
||||
LPTSTR firstName;
|
||||
LPTSTR lastName;
|
||||
LPTSTR displayName;
|
||||
LPTSTR nickName;
|
||||
LPTSTR primaryEmail;
|
||||
LPTSTR secondEmail;
|
||||
LPTSTR workPhone;
|
||||
LPTSTR homePhone;
|
||||
LPTSTR faxNumber;
|
||||
LPTSTR pagerNumber;
|
||||
LPTSTR cellularNumber;
|
||||
LPTSTR homeAddress;
|
||||
LPTSTR homeAddress2;
|
||||
LPTSTR homeCity;
|
||||
LPTSTR homeState;
|
||||
LPTSTR homeZipCode;
|
||||
LPTSTR homeCountry;
|
||||
LPTSTR workAddress;
|
||||
LPTSTR workAddress2;
|
||||
LPTSTR workCity;
|
||||
LPTSTR workState;
|
||||
LPTSTR workZipCode;
|
||||
LPTSTR workCountry;
|
||||
LPTSTR jobTitle;
|
||||
LPTSTR department;
|
||||
LPTSTR company;
|
||||
/**
|
||||
* webPage1 is work web page
|
||||
*/
|
||||
LPTSTR webPage1;
|
||||
/**
|
||||
* webPage2 is home web page
|
||||
*/
|
||||
LPTSTR webPage2;
|
||||
LPTSTR birthYear;
|
||||
LPTSTR birthMonth;
|
||||
LPTSTR birthDay;
|
||||
LPTSTR custom1;
|
||||
LPTSTR custom2;
|
||||
LPTSTR custom3;
|
||||
LPTSTR custom4;
|
||||
LPTSTR notes;
|
||||
unsigned long lastModifiedDate;
|
||||
unsigned long addressToUse; // home, work, ...
|
||||
unsigned long preferredPhoneNum; // this is displayed in the contact list
|
||||
unsigned long preferMailFormat;
|
||||
boolean isMailList;
|
||||
/**
|
||||
* If isMailList is true then mailListURI
|
||||
* will contain the URI of the associated
|
||||
* mail list
|
||||
*/
|
||||
LPSTR mailListURI;
|
||||
}nsABCOMCardStruct, *lpnsABCOMCardStruct;
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(C8CE6FC1-CCF1-11d6-B8A5-000064657374),
|
||||
helpstring("nsIPalmSync Inteface"),
|
||||
pointer_default(unique)
|
||||
]
|
||||
|
||||
interface IPalmSync : IUnknown
|
||||
{
|
||||
HRESULT IsValid();
|
||||
|
||||
// Get the list of Address Books for the currently logged in user profile
|
||||
HRESULT nsGetABList([in] BOOL aIsUnicode, [out] short * aABListCount,
|
||||
[out, size_is(, *aABListCount)] lpnsMozABDesc * aABList,
|
||||
[out, size_is(, *aABListCount)] long ** aABCatIndexList,
|
||||
[out, size_is(, *aABListCount)] BOOL ** aFirstTimeSyncList);
|
||||
|
||||
// Synchronize the Address Book represented by the aCategoryIndex and the corresponding aABName in Mozilla
|
||||
// this will take care of ABs existing on both ends.
|
||||
HRESULT nsSynchronizeAB([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] long aCategoryId, [in] LPTSTR aABName,
|
||||
[in] int aModRemoteRecCount, [in, size_is(aModRemoteRecCount)] lpnsABCOMCardStruct aModRemoteRecList,
|
||||
[out] int * aModMozRecCount, [out, size_is(, *aModMozRecCount)] lpnsABCOMCardStruct * aModMozRecList);
|
||||
|
||||
// All records from a AB represented by aCategoryIndex and aABName into a new or existing Mozilla AB
|
||||
HRESULT nsAddAllABRecords([in] BOOL aIsUnicode, [in] BOOL aReplaceExisting, [in] long aCategoryIndex, [in] LPTSTR aABName,
|
||||
[in] int aRemoteRecCount, [in, size_is(aRemoteRecCount)] lpnsABCOMCardStruct aRemoteRecList);
|
||||
|
||||
// Get All records from a Mozilla AB
|
||||
HRESULT nsGetAllABCards([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] LPTSTR aABName,
|
||||
[out] int * aMozRecCount, [out, size_is(, *aMozRecCount)] lpnsABCOMCardStruct * aMozRecList);
|
||||
|
||||
// Send an ack for done and update the palm rec id for new records added
|
||||
HRESULT nsAckSyncDone([in] BOOL aIsSuccess, [in] long aCatIndex, [in] int aNewRecCount, [in, size_is(aNewRecCount)] unsigned long * aNewPalmRecIDList);
|
||||
|
||||
// Update the Address Book's category id and mod time.
|
||||
HRESULT nsUpdateABSyncInfo([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] LPTSTR aABName);
|
||||
|
||||
// Delete an addressbook
|
||||
HRESULT nsDeleteAB([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] LPTSTR aABName, [in] LPTSTR aABUrl);
|
||||
|
||||
// was this address book deleted in Mozilla?
|
||||
HRESULT nsGetABDeleted([in] LPTSTR aABName, [out] BOOL *abDeleted);
|
||||
|
||||
// Rename an addressbook
|
||||
HRESULT nsRenameAB([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] LPTSTR aABName, [in] LPTSTR aABUrl);
|
||||
|
||||
HRESULT nsUseABHomeAddressForPalmAddress ([out] BOOL *useHomeAddress);
|
||||
|
||||
HRESULT nsPreferABHomePhoneForPalmPhone ([out] BOOL * preferHomePhone);
|
||||
};
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
#
|
||||
# ***** 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = PalmSyncProxy
|
||||
LIBRARY_NAME = $(MODULE)
|
||||
DEFFILE = $(win_srcdir)/PalmSyncProxy.def
|
||||
ifndef MOZ_INCOMPLETE_EXTERNAL_LINKAGE
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
endif
|
||||
USE_STATIC_LIBS = 1
|
||||
XPI_NAME = palmsync
|
||||
|
||||
EXPORTS = IPalmSync.h
|
||||
|
||||
CSRCS = \
|
||||
dlldata.c \
|
||||
IPalmSync_p.c \
|
||||
IPalmSync_i.c \
|
||||
$(NULL)
|
||||
|
||||
OS_LIBS += rpcrt4.lib
|
||||
|
||||
MIDL_GENERATED_FILES = IPalmSync.h IPalmSync_p.c IPalmSync_i.c dlldata.c
|
||||
|
||||
SRCDIR_CSRCS = $(addprefix $(srcdir)/,$(CSRCS))
|
||||
|
||||
GARBAGE += $(MIDL_GENERATED_FILES) done_gen $(CSRCS) $(SRCDIR_CSRCS)
|
||||
|
||||
LOCAL_INCLUDES = -I.
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
SRCS_IN_OBJDIR = 1
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DREGISTER_PROXY_DLL -DUNICODE -D_UNICODE
|
||||
|
||||
$(MIDL_GENERATED_FILES): done_gen
|
||||
|
||||
done_gen: IPalmSync.idl
|
||||
$(RM) $(SRCDIR_CSRCS)
|
||||
$(MIDL) $(MIDL_FLAGS) -Oic $(UNICODE_FLAGS) $(srcdir)/IPalmSync.idl
|
||||
touch $@
|
||||
|
||||
export:: done_gen
|
||||
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
; ***** 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.
|
||||
;
|
||||
; The Initial Developer of the Original Code is
|
||||
; Netscape Communications Corp.
|
||||
; 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 *****
|
||||
|
||||
LIBRARY PalmSyncProxy.dll
|
||||
DESCRIPTION 'Proxy/Stub DLL'
|
||||
|
||||
EXPORTS
|
||||
DllGetClassObject @1 PRIVATE
|
||||
DllCanUnloadNow @2 PRIVATE
|
||||
GetProxyDllInfo @3 PRIVATE
|
||||
DllRegisterServer @4 PRIVATE
|
||||
DllUnregisterServer @5 PRIVATE
|
||||
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
#
|
||||
# ***** 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
PALM_CDK_INC = $(PALM_CDK_DIR)/C++/Include
|
||||
PALM_CDK_LIB = $(PALM_CDK_DIR)/C++/Lib
|
||||
PALM_PFC_INC = $(PALM_CDK_DIR)/C++/Pfc/include
|
||||
PALM_PFC_SRC = $(PALM_CDK_DIR)/C++/Pfc/Src
|
||||
PALM_CDK_BIN = $(PALM_CDK_DIR)/Common/Bin
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = mozABConduit
|
||||
EXPORT_LIBRARY = $(MODULE)
|
||||
LIBRARY_NAME = $(MODULE)
|
||||
RESFILE = MozABConduitGenCond.res
|
||||
USE_STATIC_LIBS = 1
|
||||
XPI_NAME = palmsync
|
||||
|
||||
REQUIRES = PalmSyncProxy \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = MozABConduitGenCond.cpp \
|
||||
MozABConduitRecord.cpp \
|
||||
MozABConduitSync.cpp \
|
||||
MozABHHManager.cpp \
|
||||
MozABPCManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += -I$(PALM_CDK_INC) \
|
||||
-I$(PALM_PFC_INC) \
|
||||
-I$(PALM_PFC_SRC) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(PALM_CDK_LIB)/sync20.$(LIB_SUFFIX) \
|
||||
$(PALM_CDK_LIB)/palmcmn.$(LIB_SUFFIX) \
|
||||
$(PALM_CDK_LIB)/hslog20.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
OS_LIBS += ole32.lib comctl32.lib
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,494 +0,0 @@
|
|||
/***************************************************************************
|
||||
*
|
||||
* EXPORTED FUNCTIONS Conduit Entry Points Source File
|
||||
*
|
||||
**************************************************************************/
|
||||
#define STRICT 1
|
||||
#define ASSERT(f) ((void)0)
|
||||
#define TRACE0(sz)
|
||||
#define TRACE(sz)
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
#include <CPalmRec.cpp>
|
||||
#include <CPString.cpp>
|
||||
#include <CPCatgry.cpp>
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifdef METROWERKS_WIN
|
||||
#include <wmem.h>
|
||||
#else
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <TCHAR.H>
|
||||
#include <COMMCTRL.H>
|
||||
|
||||
#include <syncmgr.h>
|
||||
#include "MozABConduitGenCond.h"
|
||||
#include "resource.h"
|
||||
|
||||
#include <logstrng.h>
|
||||
|
||||
// TODO - Include custom sync header
|
||||
|
||||
#include <PALM_CMN.H>
|
||||
#define CONDUIT_NAME "MozABConduit"
|
||||
#include "MozABConduitSync.h"
|
||||
|
||||
HANDLE hLangInstance;
|
||||
HANDLE hAppInstance;
|
||||
extern HANDLE hLangInstance;
|
||||
extern HANDLE hAppInstance;
|
||||
|
||||
long CALLBACK CondCfgDlgProc(HWND hWnd, UINT Message, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
void LdCfgDlgBmps(HWND hDlg);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function: DllMain()
|
||||
//
|
||||
// Description: main entry point to the MozABConduitProto component
|
||||
//
|
||||
// Parameters: hInstance - instance handle of the DLL
|
||||
// dwReason - why the entry point was called
|
||||
// lpReserved - reserved
|
||||
//
|
||||
// Returns: 1 if okay
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef _68K_
|
||||
|
||||
static int iTerminationCount = 0;
|
||||
|
||||
DWORD tId = 0;
|
||||
|
||||
|
||||
extern "C" int APIENTRY
|
||||
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
TRACE0("EXPORTED FUNCTIONS Initializing!\n");
|
||||
|
||||
if (!iTerminationCount ) {
|
||||
hAppInstance = hInstance;
|
||||
// use PalmLoadLanguage here to load different languages
|
||||
hLangInstance = hInstance;
|
||||
}
|
||||
++iTerminationCount;
|
||||
|
||||
tId = TlsAlloc();
|
||||
if (tId == 0xFFFFFFFF)
|
||||
return FALSE;
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
TRACE0("EXPORTED FUNCTIONS Terminating!\n");
|
||||
|
||||
--iTerminationCount;
|
||||
if (!iTerminationCount ) {
|
||||
// use PalmFreeLanguage here to unload different languages
|
||||
}
|
||||
TlsFree(tId);
|
||||
}
|
||||
return 1; // ok
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function: OpenConduit()
|
||||
//
|
||||
// Description: Extern "C" entry point into this conduit which starts
|
||||
// the process of synchronizing the local database table
|
||||
// with a remote conterpart residing on the remote view
|
||||
// device.
|
||||
//
|
||||
// Parameters: Pointer to a callback function used to report progress.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Returns:
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
ExportFunc long OpenConduit(PROGRESSFN pFn, CSyncProperties& rProps)
|
||||
{
|
||||
long retval = -1;
|
||||
if (pFn)
|
||||
{
|
||||
CMozABConduitSync * pABSync = new CMozABConduitSync(rProps);
|
||||
if (pABSync)
|
||||
{
|
||||
retval = pABSync->Perform();
|
||||
delete pABSync;
|
||||
}
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function: GetConduitName()
|
||||
//
|
||||
// Description: Extern "C" entry point into this conduit which returns
|
||||
// the name to be used when display messages
|
||||
// regarding this conduit.
|
||||
//
|
||||
// Parameters: pszName - buffer in which to place the name
|
||||
// nLen - maximum number of bytes of buffer
|
||||
//
|
||||
//
|
||||
//
|
||||
// Returns: -1 indicates erros
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
ExportFunc long GetConduitName(char* pszName,WORD nLen)
|
||||
{
|
||||
strncpy(pszName,CONDUIT_NAME, nLen-1);
|
||||
*(pszName+nLen-1) = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function: GetConduitVersion()
|
||||
//
|
||||
// Description: Extern "C" entry point into this conduit which returns
|
||||
// the conduits version
|
||||
//
|
||||
// Parameters: none
|
||||
//
|
||||
// Returns: DWORD indicating major and minor version number
|
||||
// HIWORD - reserved
|
||||
// HIBYTE(LOWORD) - major number
|
||||
// LOBYTE(LOWORD) - minor number
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
ExportFunc DWORD GetConduitVersion()
|
||||
{
|
||||
return GENERIC_CONDUIT_VERSION;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function: ConfigureConduit
|
||||
//
|
||||
// Description: Extern "C" entry point into this conduit which returns
|
||||
// should display the UI necessary to configure this
|
||||
// conduit.
|
||||
//
|
||||
// Parameters: none
|
||||
//
|
||||
// Returns: 0 - success, !0 - failure
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
ExportFunc long ConfigureConduit(CSyncPreference& pref)
|
||||
{
|
||||
|
||||
long nRtn = -1;
|
||||
CfgConduitInfoType cfgcond;
|
||||
cfgcond.dwVersion = CFGCONDUITINFO_VERSION_1;
|
||||
cfgcond.dwSize = sizeof(CfgConduitInfoType);
|
||||
cfgcond.dwCreatorId = 0;
|
||||
cfgcond.dwUserId = 0;
|
||||
memset(cfgcond.szUser , 0, sizeof(cfgcond.szUser));
|
||||
memset(cfgcond.m_PathName, 0, sizeof(cfgcond.m_PathName));
|
||||
cfgcond.syncPermanent = pref.m_SyncType;
|
||||
cfgcond.syncTemporary = pref.m_SyncType;
|
||||
cfgcond.syncNew = pref.m_SyncType;
|
||||
cfgcond.syncPref = eTemporaryPreference;
|
||||
|
||||
int irv;
|
||||
irv = DialogBoxParam((HINSTANCE)hLangInstance,
|
||||
MAKEINTRESOURCE(IDD_CONDUIT_ACTION),
|
||||
GetForegroundWindow(),
|
||||
(DLGPROC)CondCfgDlgProc,
|
||||
(LPARAM)&cfgcond);
|
||||
if (irv == 0)
|
||||
{
|
||||
pref.m_SyncType = cfgcond.syncNew;
|
||||
pref.m_SyncPref = cfgcond.syncPref;
|
||||
nRtn = 0;
|
||||
}
|
||||
|
||||
return nRtn;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Method: GetConduitInfo
|
||||
//
|
||||
// Description: This function provides a way for a Conduit to provide
|
||||
// info to the caller. In this version of the call, MFC
|
||||
// Version, Conduit Name, and Default sync action are the
|
||||
// types of information this call will return.
|
||||
//
|
||||
// Parameters: ConduitInfoEnum infoType - enum specifying what info is
|
||||
// being requested.
|
||||
//
|
||||
// void *pInArgs - This parameter may be null, except for
|
||||
// the Conduit name enum, this value will
|
||||
// be a ConduitRequestInfoType structure.
|
||||
//
|
||||
// This following two parameters vary depending upon the
|
||||
// info being requested.
|
||||
//
|
||||
// For enum eConduitName
|
||||
// void *pOut - will be a pointer to a character buffer
|
||||
// DWORD *pdwOutSize - will be a pointer to a DWORD
|
||||
// specifying the size of the
|
||||
// character buffer.
|
||||
//
|
||||
// For enum eMfcVersion
|
||||
// void *pOut - will be a pointer to a DWORD
|
||||
// DWORD *pdwOutSize - will be a pointer to a DWORD
|
||||
// specifying the size of pOut.
|
||||
//
|
||||
// For enum eDefaultAction
|
||||
// void *pOut - will be a pointer to a eSyncType variable
|
||||
// DWORD *pdwOutSize - will be a pointer to a DWORD
|
||||
// specifying the size of pOut.
|
||||
//
|
||||
// Returns: 0 - Success.
|
||||
// !0 - error code.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
ExportFunc long GetConduitInfo(ConduitInfoEnum infoType, void *pInArgs,
|
||||
void *pOut, DWORD *pdwOutSize)
|
||||
{
|
||||
if (!pOut)
|
||||
return CONDERR_INVALID_PTR;
|
||||
if (!pdwOutSize)
|
||||
return CONDERR_INVALID_OUTSIZE_PTR;
|
||||
|
||||
switch (infoType)
|
||||
{
|
||||
case eConduitName:
|
||||
|
||||
// This code is for example. This conduit does not use this code
|
||||
|
||||
if (!pInArgs)
|
||||
return CONDERR_INVALID_INARGS_PTR;
|
||||
ConduitRequestInfoType *pInfo;
|
||||
pInfo = (ConduitRequestInfoType *)pInArgs;
|
||||
if ((pInfo->dwVersion != CONDUITREQUESTINFO_VERSION_1) ||
|
||||
(pInfo->dwSize != SZ_CONDUITREQUESTINFO))
|
||||
return CONDERR_INVALID_INARGS_STRUCT;
|
||||
|
||||
pOut = CONDUIT_NAME;
|
||||
return CONDERR_CONDUIT_RESOURCE_FAILURE;
|
||||
break;
|
||||
case eDefaultAction:
|
||||
if (*pdwOutSize != sizeof(eSyncTypes))
|
||||
return CONDERR_INVALID_BUFFER_SIZE;
|
||||
(*(eSyncTypes*)pOut) = eFast;
|
||||
break;
|
||||
case eMfcVersion:
|
||||
if (*pdwOutSize != sizeof(DWORD))
|
||||
return CONDERR_INVALID_BUFFER_SIZE;
|
||||
(*(DWORD*)pOut) = MFC_NOT_USED;
|
||||
break;
|
||||
default:
|
||||
return CONDERR_UNSUPPORTED_CONDUITINFO_ENUM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long CALLBACK CondCfgDlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static CfgConduitInfoType *pCfgInfo;
|
||||
TCHAR szPath[256];
|
||||
|
||||
switch (Message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
|
||||
if (lParam != 0) {
|
||||
TCHAR szBuffer[256];
|
||||
TCHAR szBuf2[256];
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_SYNC_ACTION_TEXT, szBuffer,
|
||||
sizeof(szBuffer));
|
||||
SetDlgItemText(hWnd, IDC_ACTIONGROUPBOXTEXT, szBuffer);
|
||||
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_CONDUIT_NAME, szBuffer,
|
||||
sizeof(szBuffer));
|
||||
SetWindowText(hWnd, szBuffer);
|
||||
|
||||
// Load the bitmaps properly
|
||||
LdCfgDlgBmps(hWnd);
|
||||
|
||||
pCfgInfo = (CfgConduitInfoType *)lParam;
|
||||
switch (pCfgInfo->syncTemporary)
|
||||
{
|
||||
case eFast:
|
||||
case eSlow:
|
||||
CheckRadioButton(hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING,
|
||||
IDC_RADIO_SYNC);
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_SYNC_FILES, szBuffer,
|
||||
sizeof(szBuffer));
|
||||
break;
|
||||
case ePCtoHH:
|
||||
CheckRadioButton( hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING, IDC_RADIO_PCTOHH);
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_PCTOHH, szBuffer, sizeof(szBuffer));
|
||||
break;
|
||||
case eHHtoPC:
|
||||
CheckRadioButton( hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING, IDC_RADIO_HHTOPC);
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_HHTOPC, szBuffer, sizeof(szBuffer));
|
||||
break;
|
||||
case eDoNothing:
|
||||
default:
|
||||
CheckRadioButton(hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING,
|
||||
IDC_RADIO_DONOTHING);
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_DO_NOTHING, szBuffer,
|
||||
sizeof(szBuffer));
|
||||
break;
|
||||
}
|
||||
// did we get called from the old config call or the new cfg call?
|
||||
if (pCfgInfo->dwCreatorId != 0)
|
||||
{
|
||||
SetDlgItemText(hWnd, IDC_STATIC_TEMPORARY, szBuffer);
|
||||
|
||||
switch (pCfgInfo->syncPermanent)
|
||||
{
|
||||
case eFast:
|
||||
case eSlow:
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_SYNC_FILES, szBuffer,
|
||||
sizeof(szBuffer));
|
||||
break;
|
||||
case ePCtoHH:
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_PCTOHH, szBuffer,
|
||||
sizeof(szBuffer));
|
||||
break;
|
||||
|
||||
case eHHtoPC:
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_HHTOPC, szBuffer,
|
||||
sizeof(szBuffer));
|
||||
break;
|
||||
case eDoNothing:
|
||||
default:
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_DO_NOTHING, szBuffer,
|
||||
sizeof(szBuffer));
|
||||
break;
|
||||
}
|
||||
SetDlgItemText(hWnd, IDC_STATIC_PERMANENT, szBuffer);
|
||||
|
||||
LoadString((HINSTANCE)hLangInstance, IDS_CURRENT_SETTINGS_GROUP,
|
||||
szBuffer, sizeof(szBuffer));
|
||||
wsprintf(szBuf2, szBuffer, pCfgInfo->szUser);
|
||||
SetDlgItemText(hWnd, IDC_CURRENT_SETTINGS_GROUP, szBuf2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (wParam)
|
||||
{
|
||||
case IDC_RADIO_SYNC:
|
||||
case IDC_RADIO_DONOTHING:
|
||||
case IDC_RADIO_HHTOPC:
|
||||
case IDC_RADIO_PCTOHH:
|
||||
CheckRadioButton( hWnd, IDC_RADIO_SYNC, IDC_RADIO_DONOTHING, wParam);
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hWnd, 1);
|
||||
return TRUE;
|
||||
case IDOK:
|
||||
if (IsDlgButtonChecked(hWnd, IDC_RADIO_SYNC))
|
||||
pCfgInfo->syncNew = eFast;
|
||||
else if (IsDlgButtonChecked(hWnd, IDC_RADIO_PCTOHH))
|
||||
pCfgInfo->syncNew = ePCtoHH;
|
||||
else if (IsDlgButtonChecked(hWnd, IDC_RADIO_HHTOPC))
|
||||
pCfgInfo->syncNew = eHHtoPC;
|
||||
else
|
||||
pCfgInfo->syncNew = eDoNothing;
|
||||
pCfgInfo->syncPref = (IsDlgButtonChecked(hWnd, IDC_MAKEDEFAULT))
|
||||
? ePermanentPreference : eTemporaryPreference;
|
||||
EndDialog(hWnd, 0);
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SYSCOLORCHANGE:
|
||||
LdCfgDlgBmps(hWnd);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void LdCfgDlgBmps(HWND hDlg)
|
||||
{
|
||||
COLORMAP cMap;
|
||||
HWND hwndButton;
|
||||
HBITMAP hBmp, hOldBmp;
|
||||
|
||||
//
|
||||
// setup the bitmaps
|
||||
//
|
||||
cMap.to = GetSysColor(COLOR_BTNFACE);
|
||||
cMap.from = RGB(192,192,192);
|
||||
|
||||
// Sync
|
||||
hBmp = CreateMappedBitmap((HINSTANCE)hLangInstance, IDB_SYNC, 0, &cMap, 1);
|
||||
// associate the bitmap with the button.
|
||||
if ((hwndButton = GetDlgItem(hDlg, IDC_SYNC)) != NULL)
|
||||
{
|
||||
hOldBmp = (HBITMAP)SendMessage(hwndButton, STM_SETIMAGE,
|
||||
(WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBmp);
|
||||
if (hOldBmp != NULL)
|
||||
DeleteObject((HGDIOBJ)hOldBmp);
|
||||
}
|
||||
|
||||
// Do Nothing
|
||||
hBmp = CreateMappedBitmap((HINSTANCE)hLangInstance, IDB_DONOTHING, 0, &cMap, 1);
|
||||
// associate the bitmap with the button.
|
||||
if ((hwndButton = GetDlgItem(hDlg, IDC_DONOTHING)) != NULL)
|
||||
{
|
||||
hOldBmp = (HBITMAP)SendMessage(hwndButton, STM_SETIMAGE,
|
||||
(WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBmp);
|
||||
if (hOldBmp != NULL)
|
||||
DeleteObject((HGDIOBJ)hOldBmp);
|
||||
}
|
||||
hBmp = CreateMappedBitmap((HINSTANCE)hLangInstance, IDB_PCTOHH, 0, &cMap, 1);
|
||||
// associate the bitmap with the button.
|
||||
if ((hwndButton = GetDlgItem(hDlg, IDC_PCTOHH)) != NULL)
|
||||
{
|
||||
hOldBmp = (HBITMAP)SendMessage(hwndButton, STM_SETIMAGE,
|
||||
(WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBmp);
|
||||
if (hOldBmp != NULL)
|
||||
DeleteObject((HGDIOBJ)hOldBmp);
|
||||
}
|
||||
hBmp = CreateMappedBitmap((HINSTANCE)hLangInstance, IDB_HHTOPC, 0, &cMap, 1);
|
||||
// associate the bitmap with the button.
|
||||
if ((hwndButton = GetDlgItem(hDlg, IDC_HHTOPC)) != NULL)
|
||||
{
|
||||
hOldBmp = (HBITMAP)SendMessage(hwndButton, STM_SETIMAGE,
|
||||
(WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBmp);
|
||||
if (hOldBmp != NULL)
|
||||
DeleteObject((HGDIOBJ)hOldBmp);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* Generic Conduit Export Functions Header File
|
||||
*
|
||||
* THIS FILE IS GENERATED BY PALM CDK
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef __GENERIC_MAIN_CONDUIT__
|
||||
#define __GENERIC_MAIN_CONDUIT__
|
||||
#include <condapi.h>
|
||||
|
||||
#define GENERIC_CONDUIT_VERSION 0x00000102
|
||||
|
||||
#ifndef ExportFunc
|
||||
#ifdef _68K_
|
||||
#define ExportFunc
|
||||
#else
|
||||
#define ExportFunc __declspec( dllexport )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef long (*PROGRESSFN) (char*);
|
||||
ExportFunc long OpenConduit(PROGRESSFN, CSyncProperties&);
|
||||
ExportFunc long GetConduitName(char*,WORD);
|
||||
ExportFunc DWORD GetConduitVersion();
|
||||
ExportFunc long ConfigureConduit(CSyncPreference& pref);
|
||||
ExportFunc long GetConduitInfo(ConduitInfoEnum infoType, void *pInArgs, void *pOut, DWORD *dwOutSize);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winresrc.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
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""winresrc.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_CONDUIT_ACTION DIALOG DISCARDABLE 0, 0, 294, 114
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Change HotSync Action"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
RADIOBUTTON "&Synchronize the files",IDC_RADIO_SYNC,71,28,81,10,
|
||||
WS_GROUP | WS_TABSTOP
|
||||
RADIOBUTTON "&Desktop overwrites handheld",IDC_RADIO_PCTOHH,71,40,
|
||||
108,10,WS_GROUP
|
||||
RADIOBUTTON "&Handheld overwrites Desktop",IDC_RADIO_HHTOPC,71,52,
|
||||
109,10,WS_GROUP
|
||||
RADIOBUTTON "Do ¬hing",IDC_RADIO_DONOTHING,71,64,51,10,WS_GROUP
|
||||
CONTROL "Set &as default",IDC_MAKEDEFAULT,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,196,64,58,10
|
||||
DEFPUSHBUTTON "OK",IDOK,196,11,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,196,27,50,14
|
||||
GROUPBOX "<PlaceHolder>",IDC_ACTIONGROUPBOXTEXT,5,6,186,105,
|
||||
WS_GROUP
|
||||
CONTROL 103,IDC_SYNC,"Static",SS_BITMAP | WS_GROUP,18,26,32,15
|
||||
CONTROL 106,IDC_DONOTHING,"Static",SS_BITMAP | WS_GROUP,18,62,15,
|
||||
13
|
||||
CONTROL 105,IDC_PCTOHH,"Static",SS_BITMAP | WS_GROUP,18,39,32,15
|
||||
CONTROL 102,IDC_HHTOPC,"Static",SS_BITMAP | WS_GROUP,18,49,32,15
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_DONOTHING BITMAP DISCARDABLE "res\\DoNothing.bmp"
|
||||
IDB_SYNC BITMAP DISCARDABLE "res\\Synchronize.bmp"
|
||||
IDB_HHTOPC BITMAP DISCARDABLE "res\\HhToPc.bmp"
|
||||
IDB_PCTOHH BITMAP DISCARDABLE "res\\PcToHh.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_CONDUIT_NAME "Mozilla Address Book Conduit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_CONNECTION "Please check your connections and try again."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_CURRENT_SETTINGS_GROUP "%s's Current Settings:"
|
||||
IDS_SYNC_FILES "Synchronize the files."
|
||||
IDS_PCTOHH "Desktop overwrites Palm organizer."
|
||||
IDS_HHTOPC "Palm organizer overwrites Desktop."
|
||||
IDS_DO_NOTHING "Do Nothing."
|
||||
IDS_SYNC_ACTION_TEXT "HotSync Action for Mozilla Address Book"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
|
@ -1,604 +0,0 @@
|
|||
/* ***** 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 <string.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <sys/stat.h>
|
||||
#include <TCHAR.H>
|
||||
|
||||
#include "MozABConduitRecord.h"
|
||||
#include "MozABPCManager.h"
|
||||
#include "MozABConduitSync.h"
|
||||
|
||||
#define STR_CRETURN "\r"
|
||||
#define STR_NEWLINE "\n"
|
||||
|
||||
#define CH_CRETURN 0x0D
|
||||
#define CH_NEWLINE 0x0A
|
||||
|
||||
|
||||
// constructor
|
||||
CMozABConduitRecord::CMozABConduitRecord(void)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
// construct using Palm record
|
||||
CMozABConduitRecord::CMozABConduitRecord(CPalmRecord &rec)
|
||||
{
|
||||
ConvertFromGeneric(rec);
|
||||
}
|
||||
|
||||
// construct using Mozilla record
|
||||
CMozABConduitRecord::CMozABConduitRecord(nsABCOMCardStruct &rec)
|
||||
{
|
||||
Reset();
|
||||
|
||||
memcpy(&m_nsCard, &rec, sizeof(nsABCOMCardStruct));
|
||||
|
||||
m_dwRecordID = m_nsCard.dwRecordId;
|
||||
m_dwStatus = m_nsCard.dwStatus;
|
||||
m_dwCategoryID = m_nsCard.dwCategoryId;
|
||||
|
||||
m_dwPhone1LabelID = PHONE_LABEL_WORK;
|
||||
m_dwPhone2LabelID = PHONE_LABEL_HOME;
|
||||
m_dwPhone3LabelID = PHONE_LABEL_FAX;
|
||||
m_dwPhone4LabelID = PHONE_LABEL_MOBILE;
|
||||
m_dwPhone5LabelID = PHONE_LABEL_EMAIL;
|
||||
|
||||
m_csName = rec.lastName;
|
||||
m_csFirst = rec.firstName;
|
||||
m_csTitle = rec.jobTitle;
|
||||
m_csCompany = rec.company;
|
||||
|
||||
m_csPhone1 = rec.workPhone;
|
||||
m_csPhone2 = rec.homePhone;
|
||||
m_csPhone3 = rec.faxNumber;
|
||||
m_csPhone4 = rec.cellularNumber;
|
||||
m_csPhone5 = rec.primaryEmail;
|
||||
|
||||
m_csAddress = (MozABPCManager::gUseHomeAddress)
|
||||
? rec.homeAddress : rec.workAddress;
|
||||
|
||||
m_csCity = (MozABPCManager::gUseHomeAddress) ? rec.homeCity : rec.workCity;
|
||||
m_csState = (MozABPCManager::gUseHomeAddress) ? rec.homeState : rec.workState;
|
||||
m_csZipCode = (MozABPCManager::gUseHomeAddress) ? rec.homeZipCode : rec.workZipCode;
|
||||
m_csCountry = (MozABPCManager::gUseHomeAddress) ? rec.homeCountry : rec.workCountry;
|
||||
// CONDUIT_LOG3(gFD, "\nCMozABConduitRecord::CMozABConduitRecord(nsABCOMCardStruct &rec) gUseHomeAddress = %s card home address = %s card work address = %s\n",
|
||||
// (MozABPCManager::gUseHomeAddress) ? "true" : "false", (char *) rec.homeAddress, (char *) rec.workAddress);
|
||||
m_dwDisplayPhone = rec.preferredPhoneNum;
|
||||
|
||||
m_csNote = rec.notes;
|
||||
|
||||
m_csCustom1 = rec.custom1;
|
||||
m_csCustom2 = rec.custom2;
|
||||
m_csCustom3 = rec.custom3;
|
||||
m_csCustom4 = rec.custom4;
|
||||
}
|
||||
|
||||
// destructor
|
||||
CMozABConduitRecord::~CMozABConduitRecord()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// reset the internal data members
|
||||
void CMozABConduitRecord::Reset(void)
|
||||
{
|
||||
memset(&m_nsCard, 0, sizeof(nsABCOMCardStruct));
|
||||
|
||||
m_dwRecordID = 0;
|
||||
m_dwStatus = 0;
|
||||
m_dwPosition = 0;
|
||||
m_dwPhone1LabelID = 0;
|
||||
m_dwPhone2LabelID = 0;
|
||||
m_dwPhone3LabelID = 0;
|
||||
m_dwPhone4LabelID = 0;
|
||||
m_dwPhone5LabelID = 0;
|
||||
m_dwPrivate = 0;
|
||||
m_dwCategoryID = 0;
|
||||
m_dwDisplayPhone = 1; // work
|
||||
m_csName.Empty();
|
||||
m_csFirst.Empty();
|
||||
m_csTitle.Empty();
|
||||
m_csCompany.Empty();
|
||||
m_csPhone1.Empty();
|
||||
m_csPhone2.Empty();
|
||||
m_csPhone3.Empty();
|
||||
m_csPhone4.Empty();
|
||||
m_csCustom1.Empty();
|
||||
m_csCustom2.Empty();
|
||||
m_csCustom3.Empty();
|
||||
m_csCustom4.Empty();
|
||||
m_csPhone5.Empty();
|
||||
m_csAddress.Empty();
|
||||
m_csCity.Empty();
|
||||
m_csState.Empty();
|
||||
m_csZipCode.Empty();
|
||||
m_csCountry.Empty();
|
||||
m_csNote.Empty();
|
||||
}
|
||||
|
||||
// this method compares this object with another MozAB Conduit record
|
||||
eRecCompare CMozABConduitRecord::Compare(const CMozABConduitRecord &rec)
|
||||
{
|
||||
if ( (m_dwPhone1LabelID != rec.m_dwPhone1LabelID) ||
|
||||
(m_dwPhone2LabelID != rec.m_dwPhone2LabelID) ||
|
||||
(m_dwPhone3LabelID != rec.m_dwPhone3LabelID ) ||
|
||||
(m_dwPhone4LabelID != rec.m_dwPhone4LabelID ) ||
|
||||
(m_dwPhone5LabelID != rec.m_dwPhone5LabelID ) ||
|
||||
// comment this out until we can match 4.x's displayPhone algorithm
|
||||
// (m_dwDisplayPhone != rec.m_dwDisplayPhone ) ||
|
||||
(m_csName != rec.m_csName ) ||
|
||||
(m_csFirst != rec.m_csFirst ) ||
|
||||
(m_csTitle != rec.m_csTitle ) ||
|
||||
(m_csCompany != rec.m_csCompany ) ||
|
||||
(m_csPhone1 != rec.m_csPhone1 ) ||
|
||||
(m_csPhone2 != rec.m_csPhone2 ) ||
|
||||
(m_csPhone3 != rec.m_csPhone3 ) ||
|
||||
(m_csPhone4 != rec.m_csPhone4 ) ||
|
||||
(m_csCustom1 != rec.m_csCustom1 ) ||
|
||||
(m_csCustom2 != rec.m_csCustom2 ) ||
|
||||
(m_csCustom3 != rec.m_csCustom3 ) ||
|
||||
(m_csCustom4 != rec.m_csCustom4 ) ||
|
||||
(m_csPhone5 != rec.m_csPhone5 ) ||
|
||||
(m_csAddress != rec.m_csAddress ) ||
|
||||
(m_csCity != rec.m_csCity ) ||
|
||||
(m_csState != rec.m_csState ) ||
|
||||
(m_csZipCode != rec.m_csZipCode ) ||
|
||||
(m_csCountry != rec.m_csCountry ) ||
|
||||
(m_csNote != rec.m_csNote ))
|
||||
return eData;
|
||||
if (m_dwPrivate != rec.m_dwPrivate )
|
||||
return ePrivateFlag;
|
||||
if (m_dwCategoryID != rec.m_dwCategoryID )
|
||||
return eCategory;
|
||||
|
||||
return eEqual;
|
||||
}
|
||||
|
||||
#define COPY_FROM_GENERIC(m, d) { iLen = _tcslen((char *)pBuff); \
|
||||
CopyFromHHBuffer((char *)pBuff, m.GetBuffer(iLen * 2), iLen); \
|
||||
m.ReleaseBuffer(); \
|
||||
d = m.GetBuffer(0); \
|
||||
pBuff += iLen + 1; \
|
||||
} \
|
||||
|
||||
#define COPY_PHONE_FROM_GENERIC(m, d){ iLen = _tcslen((char *)pBuff); \
|
||||
CopyFromHHBuffer((char *)pBuff, m.GetBuffer(iLen * 2), iLen); \
|
||||
m.ReleaseBuffer(); \
|
||||
AssignPhoneToMozData(d, m.GetBuffer(0)); \
|
||||
pBuff += iLen + 1; \
|
||||
} \
|
||||
|
||||
|
||||
// this method converts CPalmRecord to MozAB Conduit record
|
||||
long CMozABConduitRecord::ConvertFromGeneric(CPalmRecord &rec)
|
||||
{
|
||||
long retval = 0;
|
||||
BYTE *pBuff;
|
||||
AddrDBRecordFlags flags;
|
||||
AddrOptionsType options;
|
||||
int iLen;
|
||||
|
||||
Reset();
|
||||
|
||||
if (rec.GetRawDataSize() == (sizeof(DWORD) + sizeof(DWORD) + sizeof(unsigned char))){
|
||||
// then this is a deleted record because it has no data
|
||||
return GEN_ERR_EMPTY_RECORD;
|
||||
}
|
||||
|
||||
// palm specific data
|
||||
m_dwRecordID = rec.GetID();
|
||||
m_dwCategoryID = rec.GetCategory();
|
||||
m_dwPrivate = rec.IsPrivate();
|
||||
m_dwStatus = rec.GetStatus();
|
||||
|
||||
m_nsCard.dwRecordId = m_dwRecordID;
|
||||
m_nsCard.dwCategoryId = m_dwCategoryID;
|
||||
m_nsCard.dwStatus = m_dwStatus;
|
||||
|
||||
// clear all values in the Address Record
|
||||
m_dwPhone1LabelID = PHONE_LABEL_WORK;
|
||||
m_dwPhone2LabelID = PHONE_LABEL_HOME;
|
||||
m_dwPhone3LabelID = PHONE_LABEL_FAX;
|
||||
m_dwPhone4LabelID = PHONE_LABEL_MOBILE;
|
||||
m_dwPhone5LabelID = PHONE_LABEL_EMAIL;
|
||||
m_dwDisplayPhone = m_nsCard.preferredPhoneNum;
|
||||
|
||||
DWORD dwRawSize = rec.GetRawDataSize();
|
||||
if (!dwRawSize) {
|
||||
// invalid record
|
||||
return 0;
|
||||
}
|
||||
|
||||
// get the data for moz card
|
||||
pBuff = rec.GetRawData();
|
||||
|
||||
// AddrOptionsType
|
||||
*(DWORD *)&options = CPalmRecord::SwapDWordToIntel(*((DWORD*)pBuff));
|
||||
m_dwDisplayPhone = (long)options.displayPhone + 1;
|
||||
m_dwPhone1LabelID = (DWORD)options.phone1;
|
||||
m_dwPhone2LabelID = (DWORD)options.phone2;
|
||||
m_dwPhone3LabelID = (DWORD)options.phone3;
|
||||
m_dwPhone4LabelID = (DWORD)options.phone4;
|
||||
m_dwPhone5LabelID = (DWORD)options.phone5;
|
||||
|
||||
pBuff += sizeof(DWORD);
|
||||
|
||||
// The flag bits are used to indicate which fields exist
|
||||
*(DWORD *)&flags = CPalmRecord::SwapDWordToIntel(*((DWORD*)pBuff));
|
||||
pBuff += sizeof(DWORD) + sizeof(unsigned char);
|
||||
|
||||
// Name
|
||||
if (flags.name) COPY_FROM_GENERIC(m_csName, m_nsCard.lastName)
|
||||
// FirstName
|
||||
if (flags.firstName) COPY_FROM_GENERIC(m_csFirst, m_nsCard.firstName)
|
||||
// DisplayName
|
||||
m_csDisplayName = m_nsCard.firstName;
|
||||
m_csDisplayName += " ";
|
||||
m_csDisplayName += m_nsCard.lastName;
|
||||
m_nsCard.displayName = m_csDisplayName.GetBuffer(0);
|
||||
// Company
|
||||
if (flags.company) COPY_FROM_GENERIC(m_csCompany, m_nsCard.company)
|
||||
// Phones
|
||||
if (flags.phone1) COPY_PHONE_FROM_GENERIC(m_csPhone1, m_dwPhone1LabelID)
|
||||
if (flags.phone2) COPY_PHONE_FROM_GENERIC(m_csPhone2, m_dwPhone2LabelID)
|
||||
if (flags.phone3) COPY_PHONE_FROM_GENERIC(m_csPhone3, m_dwPhone3LabelID)
|
||||
if (flags.phone4) COPY_PHONE_FROM_GENERIC(m_csPhone4, m_dwPhone4LabelID)
|
||||
if (flags.phone5) COPY_PHONE_FROM_GENERIC(m_csPhone5, m_dwPhone5LabelID)
|
||||
// Address
|
||||
if (flags.address)
|
||||
{
|
||||
if (MozABPCManager::gUseHomeAddress)
|
||||
COPY_FROM_GENERIC(m_csAddress, m_nsCard.homeAddress)
|
||||
else
|
||||
COPY_FROM_GENERIC(m_csAddress, m_nsCard.workAddress)
|
||||
|
||||
// CONDUIT_LOG4(gFD, "\nConvertFromGeneric gUseHomeAddress = %s card home address = %s card work address = %s result = %s\n",
|
||||
// (MozABPCManager::gUseHomeAddress) ? "true" : "false", (char *) m_nsCard.homeAddress, (char *) m_nsCard.workAddress, (char *) m_csAddress);
|
||||
}
|
||||
// City
|
||||
if (flags.city)
|
||||
{
|
||||
if (MozABPCManager::gUseHomeAddress)
|
||||
COPY_FROM_GENERIC(m_csCity, m_nsCard.homeCity)
|
||||
else
|
||||
COPY_FROM_GENERIC(m_csCity, m_nsCard.workCity)
|
||||
}
|
||||
// State
|
||||
if (flags.state)
|
||||
{
|
||||
if (MozABPCManager::gUseHomeAddress)
|
||||
COPY_FROM_GENERIC(m_csState, m_nsCard.homeState)
|
||||
else
|
||||
COPY_FROM_GENERIC(m_csState, m_nsCard.workState)
|
||||
}
|
||||
// ZipCode
|
||||
if (flags.zipCode)
|
||||
{
|
||||
if (MozABPCManager::gUseHomeAddress)
|
||||
COPY_FROM_GENERIC(m_csZipCode, m_nsCard.homeZipCode)
|
||||
else
|
||||
COPY_FROM_GENERIC(m_csZipCode, m_nsCard.workZipCode)
|
||||
}
|
||||
// Country
|
||||
if (flags.country)
|
||||
{
|
||||
if (MozABPCManager::gUseHomeAddress)
|
||||
COPY_FROM_GENERIC(m_csCountry, m_nsCard.homeCountry)
|
||||
else
|
||||
COPY_FROM_GENERIC(m_csCountry, m_nsCard.workCountry)
|
||||
}
|
||||
// Title
|
||||
if (flags.title) COPY_FROM_GENERIC(m_csTitle, m_nsCard.jobTitle)
|
||||
// Customs
|
||||
if (flags.custom1) COPY_FROM_GENERIC(m_csCustom1, m_nsCard.custom1)
|
||||
if (flags.custom2) COPY_FROM_GENERIC(m_csCustom2, m_nsCard.custom2)
|
||||
if (flags.custom3) COPY_FROM_GENERIC(m_csCustom3, m_nsCard.custom3)
|
||||
if (flags.custom4) COPY_FROM_GENERIC(m_csCustom4, m_nsCard.custom4)
|
||||
// Note
|
||||
if (flags.note) COPY_FROM_GENERIC(m_csNote, m_nsCard.notes)
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
// this method assigns the phone #s to the Moz card data from Palm Record Phone buffer
|
||||
void CMozABConduitRecord::AssignPhoneToMozData(DWORD labelID, LPTSTR buf)
|
||||
{
|
||||
switch(labelID) {
|
||||
case PHONE_LABEL_WORK:
|
||||
m_nsCard.workPhone = buf;
|
||||
break;
|
||||
case PHONE_LABEL_HOME:
|
||||
m_nsCard.homePhone = buf;
|
||||
break;
|
||||
case PHONE_LABEL_FAX:
|
||||
m_nsCard.faxNumber = buf;
|
||||
break;
|
||||
case PHONE_LABEL_OTHER:
|
||||
break;
|
||||
case PHONE_LABEL_EMAIL:
|
||||
m_nsCard.primaryEmail = buf;
|
||||
break;
|
||||
case PHONE_LABEL_MAIN:
|
||||
break;
|
||||
case PHONE_LABEL_PAGER:
|
||||
m_nsCard.pagerNumber = buf;
|
||||
break;
|
||||
case PHONE_LABEL_MOBILE:
|
||||
m_nsCard.cellularNumber = buf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define COPY_TO_GENERIC(m, f) iLen = m.length(); \
|
||||
if (iLen != 0) \
|
||||
{ \
|
||||
f = 1; \
|
||||
destLen = StripCRs(pBuff, m.c_str(), iLen); \
|
||||
pBuff += destLen; \
|
||||
dwRecSize += destLen; \
|
||||
} \
|
||||
|
||||
|
||||
// This method converts records from the Moz type to the CPalmRecord record type.
|
||||
long CMozABConduitRecord::ConvertToGeneric(CPalmRecord &rec)
|
||||
{
|
||||
long retval = 0;
|
||||
char *pBuff, *pFlags, *pCompany, *pFirst;
|
||||
AddrDBRecordFlags flags;
|
||||
AddrOptionsType options;
|
||||
int destLen;
|
||||
BYTE szRawData[MAX_RECORD_SIZE];
|
||||
DWORD dwRecSize = 0;
|
||||
int iLen=0;
|
||||
|
||||
|
||||
rec.SetID(m_dwRecordID);
|
||||
|
||||
rec.SetCategory(m_dwCategoryID);
|
||||
|
||||
rec.SetPrivate(m_dwPrivate);
|
||||
|
||||
rec.SetAttribs(m_dwStatus);
|
||||
|
||||
pBuff = (char*)szRawData;
|
||||
|
||||
// AddrOptionsType
|
||||
*(DWORD *)&options = 0;
|
||||
options.displayPhone = m_dwDisplayPhone - 1;
|
||||
options.phone1 = LOWORD(m_dwPhone1LabelID);
|
||||
options.phone2 = LOWORD(m_dwPhone2LabelID);
|
||||
options.phone3 = LOWORD(m_dwPhone3LabelID);
|
||||
options.phone4 = LOWORD(m_dwPhone4LabelID);
|
||||
options.phone5 = LOWORD(m_dwPhone5LabelID);
|
||||
*((DWORD *)pBuff) = CPalmRecord::SwapDWordToMotor(*(DWORD *)&options);
|
||||
|
||||
pBuff += sizeof(DWORD);
|
||||
dwRecSize += sizeof(DWORD);
|
||||
|
||||
// The flag bits are used to indicate which fields exist
|
||||
pFlags = pBuff;
|
||||
*(DWORD *)&flags = 0;
|
||||
pBuff += sizeof(DWORD);
|
||||
dwRecSize += sizeof(DWORD);
|
||||
|
||||
// Company Field Offset - Initialize to zero
|
||||
pCompany = pBuff;
|
||||
*((unsigned char *)pCompany) = 0;
|
||||
pBuff += sizeof(unsigned char);
|
||||
dwRecSize += sizeof(unsigned char);
|
||||
|
||||
// First Field
|
||||
pFirst = pBuff;
|
||||
|
||||
// Name
|
||||
COPY_TO_GENERIC(m_csName, flags.name)
|
||||
// FirstName
|
||||
COPY_TO_GENERIC(m_csFirst, flags.firstName)
|
||||
// Company
|
||||
COPY_TO_GENERIC(m_csCompany, flags.company)
|
||||
// Phone1
|
||||
COPY_TO_GENERIC(m_csPhone1, flags.phone1)
|
||||
// Phone2
|
||||
COPY_TO_GENERIC(m_csPhone2, flags.phone2)
|
||||
// Phone3
|
||||
COPY_TO_GENERIC(m_csPhone3, flags.phone3)
|
||||
// Phone4
|
||||
COPY_TO_GENERIC(m_csPhone4, flags.phone4)
|
||||
// Phone5
|
||||
COPY_TO_GENERIC(m_csPhone5, flags.phone5)
|
||||
// Address
|
||||
COPY_TO_GENERIC(m_csAddress, flags.address)
|
||||
// City
|
||||
COPY_TO_GENERIC(m_csCity, flags.city)
|
||||
// State
|
||||
COPY_TO_GENERIC(m_csState, flags.state)
|
||||
// ZipCode
|
||||
COPY_TO_GENERIC(m_csZipCode, flags.zipCode)
|
||||
// Country
|
||||
COPY_TO_GENERIC(m_csCountry, flags.country)
|
||||
// Title
|
||||
COPY_TO_GENERIC(m_csTitle, flags.title)
|
||||
// Custom1
|
||||
COPY_TO_GENERIC(m_csCustom1, flags.custom1)
|
||||
// Custom2
|
||||
COPY_TO_GENERIC(m_csCustom2, flags.custom2)
|
||||
// Custom3
|
||||
COPY_TO_GENERIC(m_csCustom3, flags.custom3)
|
||||
// Custom4
|
||||
COPY_TO_GENERIC(m_csCustom4, flags.custom4)
|
||||
// Note
|
||||
COPY_TO_GENERIC(m_csNote, flags.note)
|
||||
|
||||
// Store the AddrDBRecordFlags
|
||||
*((DWORD *)pFlags) = CPalmRecord::SwapDWordToMotor(*(DWORD *)&flags);
|
||||
|
||||
|
||||
if (dwRecSize == (sizeof(DWORD) + sizeof(DWORD) + sizeof(unsigned char))){
|
||||
// then this is a deleted record because it has no data
|
||||
rec.SetDeleted();
|
||||
}
|
||||
|
||||
retval = rec.SetRawData(dwRecSize, szRawData);
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
// this function copies data from the handheld into the passed destination,
|
||||
// and optionally adds carriage returns to handheld data
|
||||
long CMozABConduitRecord::CopyFromHHBuffer(TCHAR* pSrc, TCHAR* pDest, int len)
|
||||
{
|
||||
long retval = GEN_ERR_INVALID_POINTER;
|
||||
int off=0;
|
||||
|
||||
TCHAR* pCurr;
|
||||
|
||||
if (pDest) {
|
||||
|
||||
// Only add Cr's if newlines are present..
|
||||
pCurr = (TCHAR*) _tcspbrk(pSrc, STR_NEWLINE);
|
||||
if(pCurr)
|
||||
{
|
||||
while (off < len && *pSrc)
|
||||
{
|
||||
if (*pSrc == CH_NEWLINE)
|
||||
{
|
||||
*pDest = CH_CRETURN;
|
||||
pDest++;
|
||||
}
|
||||
*pDest = *pSrc;
|
||||
|
||||
pDest++ ; pSrc++;
|
||||
off++;
|
||||
}
|
||||
*pDest = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(pDest, pSrc, len);
|
||||
pDest[len] = 0;
|
||||
}
|
||||
retval = 0;
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
// this function strips extra carraige returns from PC data
|
||||
int CMozABConduitRecord::StripCRs(TCHAR* pDest, const TCHAR* pSrc, int len)
|
||||
{
|
||||
int retval = 0;
|
||||
int off = 0;
|
||||
TCHAR* pCurr;
|
||||
TCHAR* pStart = pDest;
|
||||
|
||||
// See if any cr's are present in the first place.
|
||||
pCurr = (TCHAR*) _tcspbrk(pSrc, STR_CRETURN);
|
||||
if (pCurr)
|
||||
{
|
||||
while (off < len && *pSrc)
|
||||
{
|
||||
if (*pSrc == CH_CRETURN)
|
||||
pSrc++;
|
||||
|
||||
*pDest = *pSrc;
|
||||
|
||||
off++;
|
||||
pDest++ ; pSrc++;
|
||||
}
|
||||
*pDest = 0;
|
||||
|
||||
retval = strlen(pStart) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(pDest, pSrc, len);
|
||||
*(pDest + len) = '\0';
|
||||
retval = len + 1;
|
||||
}
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
void CMozABConduitRecord::CleanUpABCOMCardStruct(nsABCOMCardStruct * card)
|
||||
{
|
||||
if(!card)
|
||||
return;
|
||||
|
||||
CoTaskMemFree(card->firstName);
|
||||
CoTaskMemFree(card->lastName);
|
||||
CoTaskMemFree(card->displayName);
|
||||
CoTaskMemFree(card->nickName);
|
||||
CoTaskMemFree(card->primaryEmail);
|
||||
CoTaskMemFree(card->secondEmail);
|
||||
CoTaskMemFree(card->workPhone);
|
||||
CoTaskMemFree(card->homePhone);
|
||||
CoTaskMemFree(card->faxNumber);
|
||||
CoTaskMemFree(card->pagerNumber);
|
||||
CoTaskMemFree(card->cellularNumber);
|
||||
CoTaskMemFree(card->homeAddress);
|
||||
CoTaskMemFree(card->homeAddress2);
|
||||
CoTaskMemFree(card->homeCity);
|
||||
CoTaskMemFree(card->homeState);
|
||||
CoTaskMemFree(card->homeZipCode);
|
||||
CoTaskMemFree(card->homeCountry);
|
||||
CoTaskMemFree(card->workAddress);
|
||||
CoTaskMemFree(card->workAddress2);
|
||||
CoTaskMemFree(card->workCity);
|
||||
CoTaskMemFree(card->workState);
|
||||
CoTaskMemFree(card->workZipCode);
|
||||
CoTaskMemFree(card->workCountry);
|
||||
CoTaskMemFree(card->jobTitle);
|
||||
CoTaskMemFree(card->department);
|
||||
CoTaskMemFree(card->company);
|
||||
CoTaskMemFree(card->webPage1);
|
||||
CoTaskMemFree(card->webPage2);
|
||||
CoTaskMemFree(card->birthYear);
|
||||
CoTaskMemFree(card->birthMonth);
|
||||
CoTaskMemFree(card->birthDay);
|
||||
CoTaskMemFree(card->custom1);
|
||||
CoTaskMemFree(card->custom2);
|
||||
CoTaskMemFree(card->custom3);
|
||||
CoTaskMemFree(card->custom4);
|
||||
CoTaskMemFree(card->notes);
|
||||
CoTaskMemFree(card->mailListURI);
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
/* ***** 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 ***** */
|
||||
|
||||
#ifndef __MOZABCONDUIT_RECORD_H_
|
||||
#define __MOZABCONDUIT_RECORD_H_
|
||||
|
||||
#include <syncmgr.h>
|
||||
#include "CPString.h"
|
||||
#include "CPalmRec.h"
|
||||
#include <PGenErr.h>
|
||||
#include <tables.h>
|
||||
|
||||
#include "IPalmSync.h"
|
||||
|
||||
// these identify the types of phone numbers in Palm record
|
||||
#define PHONE_LABEL_WORK 0
|
||||
#define PHONE_LABEL_HOME 1
|
||||
#define PHONE_LABEL_FAX 2
|
||||
#define PHONE_LABEL_OTHER 3
|
||||
#define PHONE_LABEL_EMAIL 4
|
||||
#define PHONE_LABEL_MAIN 5
|
||||
#define PHONE_LABEL_PAGER 6
|
||||
#define PHONE_LABEL_MOBILE 7
|
||||
|
||||
// these are flags which says if a field in Palm record exist or not
|
||||
struct AddrDBRecordFlags {
|
||||
unsigned name :1;
|
||||
unsigned firstName :1;
|
||||
unsigned company :1;
|
||||
unsigned phone1 :1;
|
||||
unsigned phone2 :1;
|
||||
unsigned phone3 :1;
|
||||
unsigned phone4 :1;
|
||||
unsigned phone5 :1;
|
||||
unsigned address :1;
|
||||
unsigned city :1;
|
||||
unsigned state :1;
|
||||
unsigned zipCode :1;
|
||||
unsigned country :1;
|
||||
unsigned title :1;
|
||||
unsigned custom1 :1;
|
||||
unsigned custom2 :1;
|
||||
unsigned custom3 :1;
|
||||
unsigned custom4 :1;
|
||||
unsigned note :1;
|
||||
unsigned reserved :13;
|
||||
};
|
||||
|
||||
// these are the flag that identify the type of phone #s in Palm record
|
||||
struct AddrOptionsType {
|
||||
unsigned phone1 :4;
|
||||
unsigned phone2 :4;
|
||||
unsigned phone3 :4;
|
||||
unsigned phone4 :4;
|
||||
unsigned phone5 :4;
|
||||
unsigned displayPhone :4;
|
||||
unsigned reserved :8;
|
||||
};
|
||||
|
||||
// class implementation that represents the Mozilla AB Record type
|
||||
// used along with Palm record type
|
||||
class CMozABConduitRecord {
|
||||
|
||||
public:
|
||||
CMozABConduitRecord(void);
|
||||
CMozABConduitRecord(CPalmRecord &rec);
|
||||
CMozABConduitRecord(nsABCOMCardStruct &rec);
|
||||
virtual ~CMozABConduitRecord();
|
||||
|
||||
public:
|
||||
// Mozilla AB card data structure member
|
||||
nsABCOMCardStruct m_nsCard;
|
||||
|
||||
// the following data members are for Palm Record
|
||||
DWORD m_dwRecordID;
|
||||
DWORD m_dwStatus;
|
||||
DWORD m_dwPosition;
|
||||
CPString m_csName;
|
||||
CPString m_csFirst;
|
||||
CPString m_csDisplayName;
|
||||
CPString m_csTitle;
|
||||
CPString m_csCompany;
|
||||
DWORD m_dwPhone1LabelID;
|
||||
CPString m_csPhone1;
|
||||
DWORD m_dwPhone2LabelID;
|
||||
CPString m_csPhone2;
|
||||
DWORD m_dwPhone3LabelID;
|
||||
CPString m_csPhone3;
|
||||
DWORD m_dwPhone4LabelID;
|
||||
CPString m_csPhone4;
|
||||
DWORD m_dwPhone5LabelID;
|
||||
CPString m_csPhone5;
|
||||
CPString m_csAddress;
|
||||
CPString m_csCity;
|
||||
CPString m_csState;
|
||||
CPString m_csZipCode;
|
||||
CPString m_csCountry;
|
||||
CPString m_csNote;
|
||||
DWORD m_dwPrivate;
|
||||
DWORD m_dwCategoryID;
|
||||
CPString m_csCustom1;
|
||||
CPString m_csCustom2;
|
||||
CPString m_csCustom3;
|
||||
CPString m_csCustom4;
|
||||
DWORD m_dwDisplayPhone;
|
||||
|
||||
protected:
|
||||
|
||||
// internal utility functions
|
||||
long CopyFromHHBuffer(TCHAR* pSrc, TCHAR* pDest, int len, int iBufSize);
|
||||
long CopyFromHHBuffer(TCHAR* pSrc, TCHAR* pDest, int len);
|
||||
int StripCRs(TCHAR* pDest, const TCHAR* pSrc, int len);
|
||||
|
||||
void AssignPhoneToMozData(DWORD labelID, LPTSTR buf);
|
||||
|
||||
public:
|
||||
// rests the data in this record object
|
||||
void Reset(void);
|
||||
// compares with another record object
|
||||
eRecCompare Compare(const CMozABConduitRecord &rec);
|
||||
|
||||
// converts from Palm record type to self(Mozilla AB) type
|
||||
long ConvertFromGeneric(CPalmRecord &rec);
|
||||
// converts from self(Mozilla AB) type to Palm record type
|
||||
long ConvertToGeneric(CPalmRecord &rec);
|
||||
|
||||
static void CleanUpABCOMCardStruct(nsABCOMCardStruct * card);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,114 +0,0 @@
|
|||
/* ***** 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 ***** */
|
||||
|
||||
#ifndef _MOZABCONDUIT_SYNC_H_
|
||||
#define _MOZABCONDUIT_SYNC_H_
|
||||
|
||||
#include <Cpalmrec.h>
|
||||
#include <Pgenerr.h>
|
||||
|
||||
#include "MozABHHManager.h"
|
||||
#include "MozABPCManager.h"
|
||||
|
||||
#define PERSONAL_ADDRBOOK_URL "moz-abmdbdirectory://abook.mab"
|
||||
#define COLLECTED_ADDRBOOK_URL "moz-abmdbdirectory://history.mab"
|
||||
|
||||
#define ENV_VAR_CONDUTI_LOG "MOZ_CONDUIT_LOG"
|
||||
|
||||
#define CONDUIT_LOG0(fd, format) \
|
||||
if (fd) \
|
||||
{fprintf(fd, format); fflush(fd);}
|
||||
#define CONDUIT_LOG1(fd, format, arg1) \
|
||||
if (fd) \
|
||||
{fprintf(fd, format, arg1); fflush(fd);}
|
||||
#define CONDUIT_LOG2(fd, format, arg1, arg2) \
|
||||
if (fd) \
|
||||
{fprintf(fd, format, arg1, arg2); fflush(fd);}
|
||||
#define CONDUIT_LOG3(fd, format, arg1, arg2, arg3) \
|
||||
if (fd) \
|
||||
{fprintf(fd, format, arg1, arg2, arg3); fflush(fd);}
|
||||
#define CONDUIT_LOG4(fd, format, arg1, arg2, arg3, arg4) \
|
||||
if (fd) \
|
||||
{fprintf(fd, format, arg1, arg2, arg3, arg4); fflush(fd);}
|
||||
#define CONDUIT_LOG5(fd, format, arg1, arg2, arg3, arg4, arg5) \
|
||||
if (fd) \
|
||||
{fprintf(fd, format, arg1, arg2, arg3, arg4, arg5); fflush(fd);}
|
||||
|
||||
extern FILE *gFD; // logging.
|
||||
|
||||
class CMozABConduitSync
|
||||
{
|
||||
public:
|
||||
// OpenConduit creates a new object using this constructor
|
||||
CMozABConduitSync(CSyncProperties& rProps);
|
||||
// destructor
|
||||
~CMozABConduitSync();
|
||||
|
||||
// OpenConduit calls this function to begin the sync process
|
||||
long Perform();
|
||||
|
||||
friend DWORD WINAPI DoFastSync(LPVOID lpParameter);
|
||||
|
||||
protected:
|
||||
// default constructor
|
||||
CMozABConduitSync();
|
||||
|
||||
// initialization method
|
||||
long GetRemoteDBInfo(int iIndex);
|
||||
|
||||
// synchronization methods
|
||||
long PerformFastSync();
|
||||
long PerformSlowSync();
|
||||
long CopyHHtoPC();
|
||||
long CopyPCtoHH();
|
||||
// utility methods
|
||||
BOOL CategoryExists(CPString &mozABName, BOOL isPAB);
|
||||
BOOL CategoryNameMatches(CPString &catName, CPString &cutOffMozABName, BOOL isPAB);
|
||||
|
||||
private:
|
||||
CSyncProperties m_rSyncProperties;
|
||||
|
||||
MozABHHManager *m_dbHH;
|
||||
MozABPCManager *m_dbPC;
|
||||
CDbList *m_remoteDB;
|
||||
short m_TotRemoteDBs;
|
||||
CSystemInfo m_SystemInfo;
|
||||
CONDHANDLE m_ConduitHandle;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,735 +0,0 @@
|
|||
/* ***** 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 <string.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <sys/stat.h>
|
||||
#include <TCHAR.H>
|
||||
#include <malloc.h>
|
||||
#include <syncmgr.h>
|
||||
#include <Pgenerr.h>
|
||||
|
||||
#include "MozABHHManager.h"
|
||||
|
||||
MozABHHManager::MozABHHManager(DWORD dwGenericFlags,
|
||||
char *pName,
|
||||
DWORD dwCreator,
|
||||
DWORD dwType,
|
||||
WORD dbFlags,
|
||||
WORD dbVersion,
|
||||
int iCardNum,
|
||||
eSyncTypes syncType)
|
||||
{
|
||||
m_hhDB = 0;
|
||||
|
||||
m_rInfo.m_pBytes = NULL;
|
||||
m_rInfo.m_TotalBytes = 0;
|
||||
|
||||
m_dwMaxRecordCount = 0;
|
||||
m_pCatMgr = NULL;
|
||||
// since we are dealing with AB which is a Record DB in Palm
|
||||
m_bRecordDB = TRUE;
|
||||
|
||||
m_szName[0] = '\0';
|
||||
SetName( pName);
|
||||
m_dwCreator = dwCreator;
|
||||
m_dwType = dwType;
|
||||
m_wFlags = dbFlags;
|
||||
m_wVersion = dbVersion;
|
||||
m_CardNum = iCardNum;
|
||||
|
||||
memset(&m_appInfo, 0, sizeof(CDbGenInfo));
|
||||
}
|
||||
|
||||
MozABHHManager::~MozABHHManager()
|
||||
{
|
||||
if (m_rInfo.m_pBytes != NULL) {
|
||||
delete m_rInfo.m_pBytes;
|
||||
}
|
||||
m_rInfo.m_pBytes = NULL;
|
||||
m_rInfo.m_TotalBytes = 0;
|
||||
|
||||
if (m_appInfo.m_pBytes) {
|
||||
delete m_appInfo.m_pBytes;
|
||||
m_appInfo.m_pBytes = NULL;
|
||||
}
|
||||
|
||||
if (m_pCatMgr) {
|
||||
delete m_pCatMgr;
|
||||
m_pCatMgr = NULL;
|
||||
}
|
||||
|
||||
CloseDB(TRUE);
|
||||
}
|
||||
|
||||
|
||||
long MozABHHManager::AllocateDBInfo(CDbGenInfo &info, BOOL bClearData)
|
||||
{
|
||||
BOOL bNew = FALSE;
|
||||
|
||||
if (!info.m_pBytes) {
|
||||
info.m_pBytes = (BYTE *) new char[MAX_RECORD_SIZE]; // deleted in d'ctor or by caller
|
||||
if (!info.m_pBytes)
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
info.m_TotalBytes = MAX_RECORD_SIZE;
|
||||
bNew = TRUE;
|
||||
}
|
||||
|
||||
if ((bClearData) || (bNew)) {
|
||||
memset(info.m_pBytes, 0, info.m_TotalBytes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MozABHHManager::GetInfoBlock(CDbGenInfo &info, BOOL bSortInfo)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
// Allocate storage for app/sort info blocks
|
||||
retval = AllocateDBInfo(info);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
_tcsncpy((char*)info.m_FileName, m_szName, sizeof(info.m_FileName)-1);
|
||||
info.m_FileName[sizeof(info.m_FileName)-1] = '\0';
|
||||
memset(info.m_pBytes, 0, info.m_TotalBytes);
|
||||
|
||||
if (!bSortInfo) {
|
||||
// Read the AppInfo block
|
||||
retval = SyncReadDBAppInfoBlock(m_hhDB, info);
|
||||
} else {
|
||||
// Read the SortInfo block
|
||||
retval = SyncReadDBSortInfoBlock(m_hhDB, info);
|
||||
}
|
||||
if (retval) {// if error then clean up
|
||||
delete info.m_pBytes;
|
||||
info.m_pBytes = NULL;
|
||||
info.m_TotalBytes = 0;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
long MozABHHManager::GetAppInfo(CDbGenInfo &rInfo)
|
||||
{
|
||||
long retval = 0;
|
||||
BYTE *pBuffer;
|
||||
|
||||
pBuffer = rInfo.m_pBytes;
|
||||
WORD wTotalBytes = rInfo.m_TotalBytes;
|
||||
memset(&rInfo, 0, sizeof(CDbGenInfo));
|
||||
if ((wTotalBytes > 0) && (pBuffer)) {
|
||||
memset(pBuffer, 0, wTotalBytes);
|
||||
rInfo.m_pBytes = pBuffer;
|
||||
rInfo.m_TotalBytes = wTotalBytes;
|
||||
}
|
||||
|
||||
retval = GetInfoBlock(rInfo);
|
||||
|
||||
if (retval) { // if error cleanup
|
||||
if (rInfo.m_pBytes) {
|
||||
delete rInfo.m_pBytes;
|
||||
rInfo.m_pBytes = NULL;
|
||||
rInfo.m_TotalBytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::SetName( char *pName)
|
||||
{
|
||||
if (m_hhDB)
|
||||
return GEN_ERR_DB_ALREADY_OPEN;
|
||||
|
||||
WORD wLen;
|
||||
if (!pName){
|
||||
*m_szName = '\0';
|
||||
return 0;
|
||||
}
|
||||
wLen = (WORD)strlen(pName);
|
||||
if (!wLen) {
|
||||
*m_szName = '\0';
|
||||
return 0;
|
||||
}
|
||||
if (wLen >= sizeof(m_szName))
|
||||
return GEN_ERR_DATA_TOO_LARGE;
|
||||
|
||||
strncpy(m_szName, pName, sizeof(m_szName)-1);
|
||||
m_szName[sizeof(m_szName)-1] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MozABHHManager::LoadCategories(void)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
if (m_pCatMgr) { // remove existing manager
|
||||
delete m_pCatMgr;
|
||||
m_pCatMgr = NULL;
|
||||
}
|
||||
|
||||
if (m_appInfo.m_BytesRead == 0){
|
||||
retval = GetAppInfo(m_appInfo);
|
||||
if (retval)
|
||||
return retval;
|
||||
}
|
||||
|
||||
if ((m_appInfo.m_BytesRead > 0) && (m_appInfo.m_pBytes)){
|
||||
m_pCatMgr = new CPCategoryMgr(m_appInfo.m_pBytes, m_appInfo.m_BytesRead); // deleted in d'ctor
|
||||
if (!m_pCatMgr)
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
} else {
|
||||
retval = GEN_ERR_NO_CATEGORIES;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::AddCategory(CPCategory & cat)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
if(!m_pCatMgr)
|
||||
retval = LoadCategories();
|
||||
|
||||
// generate a new ID and Add the category
|
||||
if(!retval) {
|
||||
int id;
|
||||
for(id = 0; id <= MAX_CATEGORIES; id++)
|
||||
if(!m_pCatMgr->FindID(id))
|
||||
break;
|
||||
// if ID doesnot already exist
|
||||
if(id < MAX_CATEGORIES) {
|
||||
cat.SetID(MAKELONG(id, 0));
|
||||
retval = m_pCatMgr->Add(cat);
|
||||
}
|
||||
else
|
||||
retval = CAT_NO_ID;
|
||||
}
|
||||
|
||||
if(!retval)
|
||||
m_pCatMgr->SetChanged();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::DeleteCategory(DWORD dwCategory, BOOL bMoveToUnfiled)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
if ((dwCategory < 0) || (dwCategory >= MAX_CATEGORIES))
|
||||
return CAT_ERR_INDEX_OUT_OF_RANGE;
|
||||
|
||||
BYTE sCategory = LOBYTE(LOWORD(dwCategory));
|
||||
|
||||
if (!bMoveToUnfiled)
|
||||
{
|
||||
retval = SyncPurgeAllRecsInCategory(m_hhDB, sCategory);
|
||||
m_pCatMgr->DeleteByIndex(dwCategory); // delete category itself
|
||||
}
|
||||
else
|
||||
retval = SyncChangeCategory(m_hhDB, sCategory, 0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::ChangeCategory(DWORD dwOldCatIndex, DWORD dwNewCatIndex)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
if ((dwOldCatIndex < 0) || (dwOldCatIndex >= MAX_CATEGORIES))
|
||||
return CAT_ERR_INDEX_OUT_OF_RANGE;
|
||||
|
||||
BYTE sCategory = LOBYTE(LOWORD(dwOldCatIndex));
|
||||
|
||||
if ((dwNewCatIndex < 0) || (dwNewCatIndex >= MAX_CATEGORIES))
|
||||
return CAT_ERR_INDEX_OUT_OF_RANGE;
|
||||
|
||||
BYTE sNewCategory = LOBYTE(LOWORD(dwNewCatIndex));
|
||||
|
||||
retval = SyncChangeCategory(m_hhDB, sCategory, sNewCategory);
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::CompactCategoriesToHH()
|
||||
{
|
||||
long retval = 0;
|
||||
|
||||
if ((!m_pCatMgr) || (!m_pCatMgr->IsChanged()))
|
||||
return 0;
|
||||
|
||||
retval = AllocateDBInfo(m_appInfo);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
DWORD dwRecSize;
|
||||
|
||||
dwRecSize = m_appInfo.m_TotalBytes;
|
||||
|
||||
retval = m_pCatMgr->Compact(m_appInfo.m_pBytes, &dwRecSize);
|
||||
if (!retval) {
|
||||
// more than just the categories may be stored in the app info structure
|
||||
// This code only replaces the category area.
|
||||
if (!m_appInfo.m_BytesRead)
|
||||
m_appInfo.m_BytesRead = LOWORD(dwRecSize);
|
||||
}
|
||||
|
||||
if(!retval)
|
||||
retval = SyncWriteDBAppInfoBlock(m_hhDB, m_appInfo);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::OpenDB(BOOL bCreate)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
if (bCreate) {
|
||||
CDbCreateDB createInfo;
|
||||
|
||||
// Delete any existing DB with the same name
|
||||
SyncDeleteDB(m_szName, m_CardNum);
|
||||
|
||||
memset(&createInfo, 0, sizeof(CDbCreateDB));
|
||||
|
||||
createInfo.m_Creator = m_dwCreator;
|
||||
createInfo.m_Type = m_dwType;
|
||||
createInfo.m_Flags = (eDbFlags) m_wFlags;
|
||||
createInfo.m_CardNo = m_CardNum;
|
||||
strncpy(createInfo.m_Name, m_szName, sizeof(createInfo.m_Name)-1);
|
||||
createInfo.m_Name[sizeof(createInfo.m_Name)-1] = '\0';
|
||||
createInfo.m_Version = m_wVersion;
|
||||
|
||||
if ((retval = SyncCreateDB(createInfo)) == SYNCERR_NONE)
|
||||
m_hhDB = createInfo.m_FileHandle;
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = SyncOpenDB(m_szName,
|
||||
m_CardNum,
|
||||
m_hhDB,
|
||||
eDbRead | eDbWrite);
|
||||
if ((retval) && (retval == SYNCERR_NOT_FOUND))
|
||||
retval = GEN_ERR_NO_HH_DB;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::CloseDB(BOOL bDontUpdate)
|
||||
{
|
||||
long retval = 0;
|
||||
long retval2 = 0;
|
||||
|
||||
if (m_hhDB == NULL)
|
||||
return GEN_ERR_DB_NOT_OPEN;
|
||||
|
||||
if (!bDontUpdate) {
|
||||
retval = SyncResetSyncFlags(m_hhDB);
|
||||
}
|
||||
retval2 = SyncCloseDB(m_hhDB);
|
||||
if (!retval)
|
||||
retval = retval2;
|
||||
m_hhDB = NULL;
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::LoadAllUpdatedRecords(CPalmRecord ***ppRecordList, DWORD * pListSize)
|
||||
{
|
||||
return LoadUpdatedRecords(0, ppRecordList, pListSize);
|
||||
}
|
||||
|
||||
long MozABHHManager::LoadUpdatedRecordsInCategory(DWORD catIndex, CPalmRecord ***ppRecordList, DWORD * pListSize)
|
||||
{
|
||||
return LoadUpdatedRecords(catIndex, ppRecordList, pListSize);
|
||||
}
|
||||
|
||||
// this function allocates the list as well as the records, caller should free list and delete records
|
||||
long MozABHHManager::LoadUpdatedRecords(DWORD catIndex, CPalmRecord ***ppRecordList, DWORD * pListSize)
|
||||
{
|
||||
long retval=0;
|
||||
WORD dwRecCount=0;
|
||||
|
||||
retval = SyncGetDBRecordCount(m_hhDB, dwRecCount);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
// resset the iteration index
|
||||
retval = SyncResetRecordIndex(m_hhDB);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
// allocate buffer initially for the total record size and adjust after getting records
|
||||
CPalmRecord ** palmRecordList = (CPalmRecord **) malloc(sizeof(CPalmRecord *) * dwRecCount);
|
||||
if (!palmRecordList)
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
memset(palmRecordList, 0, sizeof(CPalmRecord *) * dwRecCount);
|
||||
*ppRecordList = palmRecordList;
|
||||
|
||||
// SyncReadNextModifiedRecInCategory() does not seem to be returning
|
||||
// deleted palm records, so SyncReadNextModifiedRec() is used instead.
|
||||
CPalmRecord *pPalmRec;
|
||||
*pListSize = 0;
|
||||
while ((!retval) && (*pListSize < dwRecCount)) {
|
||||
retval = AllocateRawRecord();
|
||||
if(retval)
|
||||
break;
|
||||
m_rInfo.m_RecIndex = 0;
|
||||
retval = SyncReadNextModifiedRec(m_rInfo);
|
||||
// Does it belong to the category we care about?
|
||||
if (!retval && m_rInfo.m_CatId == catIndex)
|
||||
{
|
||||
pPalmRec = new CPalmRecord(m_rInfo);
|
||||
if (pPalmRec) {
|
||||
*palmRecordList = pPalmRec;
|
||||
palmRecordList++;
|
||||
(*pListSize)++;
|
||||
} else {
|
||||
retval = GEN_ERR_LOW_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reallocate to the correct size
|
||||
if((*pListSize) != dwRecCount)
|
||||
*ppRecordList=(CPalmRecord **) realloc(*ppRecordList, sizeof(CPalmRecord *) * (*pListSize));
|
||||
|
||||
if (retval == SYNCERR_FILE_NOT_FOUND) // if there are no more records
|
||||
retval = 0;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::AllocateRawRecord(void)
|
||||
{
|
||||
if (m_rInfo.m_pBytes != NULL) {
|
||||
BYTE *pBytes;
|
||||
|
||||
pBytes = m_rInfo.m_pBytes;
|
||||
memset(&m_rInfo, 0, sizeof(CRawRecordInfo));
|
||||
memset(pBytes, 0, MAX_RECORD_SIZE);
|
||||
|
||||
m_rInfo.m_pBytes = pBytes;
|
||||
m_rInfo.m_TotalBytes = MAX_RECORD_SIZE;
|
||||
m_rInfo.m_FileHandle = m_hhDB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&m_rInfo, 0, sizeof(CRawRecordInfo));
|
||||
m_rInfo.m_pBytes = (BYTE *) new char[MAX_RECORD_SIZE];
|
||||
if (!m_rInfo.m_pBytes)
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
|
||||
memset(m_rInfo.m_pBytes, 0, MAX_RECORD_SIZE);
|
||||
m_rInfo.m_TotalBytes = MAX_RECORD_SIZE;
|
||||
m_rInfo.m_FileHandle = m_hhDB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// this function allocates the list as well as the records, caller should free list and delete records
|
||||
long MozABHHManager::LoadAllRecords(CPalmRecord ***ppRecordList, DWORD * pListSize)
|
||||
{
|
||||
long retval=0;
|
||||
WORD dwRecCount, dwIndex;
|
||||
|
||||
retval = SyncGetDBRecordCount(m_hhDB, dwRecCount);
|
||||
if (!retval)
|
||||
return retval;
|
||||
*pListSize = dwRecCount;
|
||||
|
||||
*ppRecordList = (CPalmRecord **) malloc(sizeof(CPalmRecord *) * dwRecCount);
|
||||
if (!*ppRecordList)
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
memset(*ppRecordList, 0, sizeof(CPalmRecord *) * dwRecCount);
|
||||
|
||||
CPalmRecord *pPalmRec;
|
||||
for (dwIndex = 0; (dwIndex < dwRecCount) && (!retval); dwIndex++){
|
||||
retval = AllocateRawRecord();
|
||||
if(retval)
|
||||
break;
|
||||
|
||||
m_rInfo.m_RecIndex = LOWORD(dwIndex);
|
||||
|
||||
retval = SyncReadRecordByIndex(m_rInfo);
|
||||
if (!retval) {
|
||||
pPalmRec = new CPalmRecord(m_rInfo);
|
||||
if (pPalmRec) {
|
||||
*ppRecordList[dwIndex] = pPalmRec;
|
||||
} else {
|
||||
retval = GEN_ERR_LOW_MEMORY;
|
||||
}
|
||||
} else if (retval != SYNCERR_FILE_NOT_FOUND) {
|
||||
pPalmRec = new CPalmRecord(m_rInfo);
|
||||
pPalmRec->Initialize();
|
||||
pPalmRec->SetIndex(dwIndex);
|
||||
*ppRecordList[dwIndex] = pPalmRec;
|
||||
}
|
||||
}
|
||||
m_dwMaxRecordCount = dwIndex + 1;
|
||||
|
||||
if (retval == SYNCERR_FILE_NOT_FOUND) // if there are no more records
|
||||
retval = 0;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
// this function allocates the list as well as the records, caller should free list and delete records
|
||||
long MozABHHManager::LoadAllRecordsInCategory(DWORD catIndex, CPalmRecord ***ppRecordList, DWORD * pListSize)
|
||||
{
|
||||
long retval=0;
|
||||
WORD dwRecCount=0;
|
||||
|
||||
retval = SyncGetDBRecordCount(m_hhDB, dwRecCount);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
// resset the iteration index
|
||||
retval = SyncResetRecordIndex(m_hhDB);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
// allocate buffer initially for the total record size and adjust after getting records
|
||||
CPalmRecord ** palmRecordList = (CPalmRecord **) malloc(sizeof(CPalmRecord *) * dwRecCount);
|
||||
if (!palmRecordList)
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
memset(palmRecordList, 0, sizeof(CPalmRecord *) * dwRecCount);
|
||||
*ppRecordList = palmRecordList;
|
||||
|
||||
CPalmRecord *pPalmRec;
|
||||
|
||||
*pListSize = 0;
|
||||
while ((!retval) && (*pListSize < dwRecCount)) {
|
||||
retval = AllocateRawRecord();
|
||||
if (retval)
|
||||
break;
|
||||
m_rInfo.m_RecIndex = 0;
|
||||
m_rInfo.m_CatId = catIndex;
|
||||
retval = SyncReadNextRecInCategory(m_rInfo);
|
||||
if (!retval) {
|
||||
pPalmRec = new CPalmRecord(m_rInfo);
|
||||
if (pPalmRec) {
|
||||
*palmRecordList = pPalmRec;
|
||||
palmRecordList++;
|
||||
(*pListSize)++;
|
||||
} else {
|
||||
retval = GEN_ERR_LOW_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reallocate to the correct size
|
||||
if((*pListSize) != dwRecCount)
|
||||
*ppRecordList=(CPalmRecord **) realloc(*ppRecordList, sizeof(CPalmRecord *) * (*pListSize));
|
||||
|
||||
if (retval == SYNCERR_FILE_NOT_FOUND) // if there are no more records
|
||||
retval = 0;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::AddRecords(CPalmRecord **pRecordList, DWORD pCount)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
for (unsigned long i=0; i < pCount; i++)
|
||||
{
|
||||
CPalmRecord palmRec = *pRecordList[i];
|
||||
|
||||
palmRec.ResetAttribs();
|
||||
|
||||
retval = AllocateRawRecord();
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
retval = palmRec.ConvertToHH(m_rInfo);
|
||||
if (!retval) {
|
||||
m_rInfo.m_FileHandle = m_hhDB;
|
||||
m_rInfo.m_RecId = 0;
|
||||
if (m_bRecordDB)
|
||||
retval = SyncWriteRec(m_rInfo);
|
||||
else
|
||||
retval = SyncWriteResourceRec(m_rInfo);
|
||||
if (!retval) {
|
||||
palmRec.SetIndex(m_rInfo.m_RecIndex);
|
||||
palmRec.SetID(m_rInfo.m_RecId);
|
||||
}
|
||||
}
|
||||
else
|
||||
return retval;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::UpdateRecords(CPalmRecord **pRecordList, DWORD pCount)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
for (unsigned long i=0; i < pCount; i++)
|
||||
{
|
||||
CPalmRecord palmRec = *pRecordList[i];
|
||||
|
||||
retval = AllocateRawRecord();
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
retval = palmRec.ConvertToHH(m_rInfo);
|
||||
if (!retval) {
|
||||
m_rInfo.m_FileHandle = m_hhDB;
|
||||
if (m_bRecordDB)
|
||||
retval = SyncWriteRec(m_rInfo);
|
||||
else
|
||||
retval = SyncWriteResourceRec(m_rInfo);
|
||||
if (!retval) {
|
||||
palmRec.SetIndex(m_rInfo.m_RecIndex);
|
||||
palmRec.SetID(m_rInfo.m_RecId);
|
||||
}
|
||||
}
|
||||
else
|
||||
return retval;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::DeleteRecords(CPalmRecord **pRecordList, DWORD pCount)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
for (unsigned long i=0; i < pCount; i++)
|
||||
{
|
||||
CPalmRecord palmRec = *pRecordList[i];
|
||||
|
||||
retval = AllocateRawRecord();
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
retval = palmRec.ConvertToHH(m_rInfo);
|
||||
if (!retval) {
|
||||
m_rInfo.m_FileHandle = m_hhDB;
|
||||
if (m_bRecordDB)
|
||||
retval = SyncDeleteRec(m_rInfo);
|
||||
else
|
||||
retval = SyncDeleteResourceRec(m_rInfo);
|
||||
}
|
||||
else
|
||||
return retval;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
long MozABHHManager::AddARecord(CPalmRecord & palmRec)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
palmRec.ResetAttribs();
|
||||
|
||||
retval = AllocateRawRecord();
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
retval = palmRec.ConvertToHH(m_rInfo);
|
||||
if (!retval) {
|
||||
m_rInfo.m_FileHandle = m_hhDB;
|
||||
m_rInfo.m_RecId = 0;
|
||||
if (m_bRecordDB)
|
||||
retval = SyncWriteRec(m_rInfo);
|
||||
else
|
||||
retval = SyncWriteResourceRec(m_rInfo);
|
||||
if (!retval) {
|
||||
palmRec.SetIndex(m_rInfo.m_RecIndex);
|
||||
palmRec.SetID(m_rInfo.m_RecId);
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::UpdateARecord(CPalmRecord & palmRec)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
retval = AllocateRawRecord();
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
retval = palmRec.ConvertToHH(m_rInfo);
|
||||
if (!retval) {
|
||||
m_rInfo.m_FileHandle = m_hhDB;
|
||||
m_rInfo.m_Attribs = eRecAttrDirty;
|
||||
if (m_bRecordDB)
|
||||
retval = SyncWriteRec(m_rInfo);
|
||||
else
|
||||
retval = SyncWriteResourceRec(m_rInfo);
|
||||
if (!retval) {
|
||||
palmRec.SetIndex(m_rInfo.m_RecIndex);
|
||||
palmRec.SetID(m_rInfo.m_RecId);
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::DeleteARecord(CPalmRecord & palmRec)
|
||||
{
|
||||
long retval=0;
|
||||
|
||||
retval = AllocateRawRecord();
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
retval = palmRec.ConvertToHH(m_rInfo);
|
||||
if (!retval) {
|
||||
m_rInfo.m_FileHandle = m_hhDB;
|
||||
if (m_bRecordDB)
|
||||
retval = SyncDeleteRec(m_rInfo);
|
||||
else
|
||||
retval = SyncDeleteResourceRec(m_rInfo);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::PurgeDeletedRecs(void)
|
||||
{
|
||||
return (SyncPurgeDeletedRecs(m_hhDB));
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
/* ***** 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 ***** */
|
||||
|
||||
#ifndef _MOZAB_HHMANAGER_H_
|
||||
#define _MOZAB_HHMANAGERT_H_
|
||||
|
||||
#include <CPDbBMgr.h>
|
||||
|
||||
class MozABHHManager
|
||||
{
|
||||
public:
|
||||
MozABHHManager(DWORD dwGenericFlags,
|
||||
char *pName,
|
||||
DWORD dwCreator,
|
||||
DWORD dwType,
|
||||
WORD dbFlags,
|
||||
WORD dbVersion,
|
||||
int iCardNum,
|
||||
eSyncTypes syncType);
|
||||
~MozABHHManager();
|
||||
|
||||
long OpenDB(BOOL bCreate);
|
||||
long CloseDB(BOOL bDontUpdate);
|
||||
|
||||
// this will load categories in m_pCatMgr member
|
||||
long LoadCategories();
|
||||
CPCategory * GetFirstCategory() { return m_pCatMgr->FindFirst(); }
|
||||
CPCategory * GetNextCategory() { return m_pCatMgr->FindNext(); }
|
||||
long DeleteCategory(DWORD dwCategory, BOOL bMoveToUnfiled);
|
||||
long ChangeCategory(DWORD dwOldCatIndex, DWORD dwNewCatIndex);
|
||||
long AddCategory(CPCategory & cat);
|
||||
long CompactCategoriesToHH();
|
||||
|
||||
long LoadAllRecords(CPalmRecord ***ppRecordList, DWORD * pListSize);
|
||||
long LoadAllRecordsInCategory(DWORD catIndex, CPalmRecord ***ppRecordList, DWORD * pListSize);
|
||||
long LoadAllUpdatedRecords(CPalmRecord ***ppRecordList, DWORD * pListSize);
|
||||
long LoadUpdatedRecordsInCategory(DWORD catIndex, CPalmRecord ***ppRecordList, DWORD * pListSize);
|
||||
|
||||
long AddRecords(CPalmRecord **m_pRecordList, DWORD pCount);
|
||||
long DeleteRecords(CPalmRecord **m_pRecordList, DWORD pCount);
|
||||
long UpdateRecords(CPalmRecord **m_pRecordList, DWORD pCount);
|
||||
|
||||
long AddARecord(CPalmRecord & palmRec);
|
||||
long DeleteARecord(CPalmRecord & palmRec);
|
||||
long UpdateARecord(CPalmRecord & palmRec);
|
||||
long PurgeDeletedRecs(void);
|
||||
|
||||
protected:
|
||||
char m_szName[SYNC_DB_NAMELEN];
|
||||
DWORD m_dwCreator;
|
||||
DWORD m_dwType;
|
||||
WORD m_wFlags;
|
||||
WORD m_wVersion;
|
||||
int m_CardNum;
|
||||
BOOL m_bRecordDB;
|
||||
|
||||
DWORD m_dwMaxRecordCount;
|
||||
|
||||
CRawRecordInfo m_rInfo;
|
||||
CPCategoryMgr * m_pCatMgr;
|
||||
|
||||
BYTE m_hhDB;
|
||||
CDbGenInfo m_appInfo;
|
||||
|
||||
long AllocateRawRecord();
|
||||
long AllocateDBInfo(CDbGenInfo &info, BOOL bClearData=FALSE);
|
||||
long GetInfoBlock(CDbGenInfo &info, BOOL bSortInfo=FALSE);
|
||||
long GetAppInfo(CDbGenInfo &rInfo);
|
||||
long SetName( char *pName);
|
||||
long LoadUpdatedRecords(DWORD catIndex, CPalmRecord ***ppRecordList, DWORD * pListSize);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,382 +0,0 @@
|
|||
/* ***** 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 <string.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <sys/stat.h>
|
||||
#include <TCHAR.H>
|
||||
|
||||
#include <syncmgr.h>
|
||||
#include <Pgenerr.h>
|
||||
|
||||
#include "MozABConduitRecord.h"
|
||||
#include "MozABPCManager.h"
|
||||
|
||||
const IID IID_IPalmSync = {0xC8CE6FC1,0xCCF1,0x11d6,{0xB8,0xA5,0x00,0x00,0x64,0x65,0x73,0x74}};
|
||||
const CLSID CLSID_CPalmSyncImp = { 0xb20b4521, 0xccf8, 0x11d6, { 0xb8, 0xa5, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } };
|
||||
|
||||
extern DWORD tId;
|
||||
|
||||
/* static */BOOL MozABPCManager::gUseHomeAddress;
|
||||
/* static */ BOOL MozABPCManager::gPreferHomePhone;
|
||||
|
||||
|
||||
BOOL MozABPCManager::InitMozPalmSyncInstance(IPalmSync **aRetValue)
|
||||
{
|
||||
// Check wehther this thread has a valid Interface
|
||||
// by looking into thread-specific-data variable
|
||||
|
||||
*aRetValue = (IPalmSync *)TlsGetValue(tId);
|
||||
|
||||
// Check whether the pointer actually resolves to
|
||||
// a valid method call; otherwise mozilla is not running
|
||||
|
||||
if ((*aRetValue) && (*aRetValue)->IsValid() == S_OK)
|
||||
return TRUE;
|
||||
|
||||
HRESULT hRes = ::CoInitialize(NULL) ;
|
||||
|
||||
hRes = ::CoCreateInstance(CLSID_CPalmSyncImp, NULL, CLSCTX_LOCAL_SERVER,
|
||||
IID_IPalmSync, (LPVOID *)aRetValue);
|
||||
|
||||
if (hRes == S_OK)
|
||||
if (TlsSetValue(tId, (LPVOID)(*aRetValue)))
|
||||
{
|
||||
(*aRetValue)->nsUseABHomeAddressForPalmAddress(&gUseHomeAddress);
|
||||
(*aRetValue)->nsPreferABHomePhoneForPalmPhone(&gPreferHomePhone);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Either CoCreate or TlsSetValue failed; so return FALSE
|
||||
|
||||
if ((*aRetValue))
|
||||
(*aRetValue)->Release();
|
||||
|
||||
::CoUninitialize();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// this function allocates the list as well as the strings, caller should free list and delete strings
|
||||
long MozABPCManager::GetPCABList(DWORD * pCategoryCount, LONG ** pCategoryIndexList, CPString *** pCategoryNameList, CPString *** pCategoryUrlList, BOOL ** pDirFlags)
|
||||
{
|
||||
lpnsMozABDesc mozABNameList=NULL;
|
||||
|
||||
short dwMozABCount=0;
|
||||
long retval = 0;
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
// get the ABList
|
||||
HRESULT hres = pNsPalmSync->nsGetABList(FALSE, &dwMozABCount,
|
||||
&mozABNameList, pCategoryIndexList, pDirFlags);
|
||||
if (hres != S_OK) {
|
||||
retval = (long) hres;
|
||||
return retval;
|
||||
}
|
||||
|
||||
*pCategoryCount = dwMozABCount;
|
||||
|
||||
CPString ** abNameList = (CPString **) malloc(sizeof(CPString *) * dwMozABCount);
|
||||
if (!abNameList) {
|
||||
free(mozABNameList);
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
}
|
||||
memset(abNameList, 0, sizeof(CPString *) * dwMozABCount);
|
||||
*pCategoryNameList = abNameList;
|
||||
|
||||
CPString ** abUrlList = (CPString **) malloc(sizeof(CPString *) * dwMozABCount);
|
||||
if (!abUrlList) {
|
||||
free(mozABNameList);
|
||||
free(abNameList);
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
}
|
||||
memset(abUrlList, 0, sizeof(CPString *) * dwMozABCount);
|
||||
*pCategoryUrlList = abUrlList;
|
||||
|
||||
for (int i=0; i < dwMozABCount; i++) {
|
||||
CPString * pABName = new CPString((LPCTSTR) mozABNameList[i].lpszABName);
|
||||
if (pABName)
|
||||
*abNameList = pABName;
|
||||
else
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
CoTaskMemFree(mozABNameList[i].lpszABName);
|
||||
abNameList++;
|
||||
|
||||
CPString * pABUrl = new CPString((LPCTSTR) mozABNameList[i].lpszABUrl);
|
||||
if (pABUrl)
|
||||
*abUrlList = pABUrl;
|
||||
else
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
CoTaskMemFree(mozABNameList[i].lpszABUrl);
|
||||
abUrlList++;
|
||||
}
|
||||
|
||||
CoTaskMemFree(mozABNameList);
|
||||
return retval;
|
||||
}
|
||||
|
||||
// this function allocates the mozlist as well as the mozRecs, caller should free list and delete recs
|
||||
long MozABPCManager::SynchronizePCAB(LONG categoryIndex, LONG categoryId, CPString & categoryName,
|
||||
DWORD updatedPalmRecCount, CPalmRecord ** updatedPalmRecList,
|
||||
DWORD * pUpdatedPCRecListCount, CPalmRecord *** updatedPCRecList)
|
||||
{
|
||||
lpnsABCOMCardStruct mozCardList=NULL; // freed by MSCOM/Mozilla.
|
||||
int dwMozCardCount=0;
|
||||
long retval = 0;
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
CMozABConduitRecord ** tempMozABConduitRecList = new CMozABConduitRecord*[updatedPalmRecCount];
|
||||
nsABCOMCardStruct * palmCardList = new nsABCOMCardStruct[updatedPalmRecCount];
|
||||
if(palmCardList)
|
||||
{
|
||||
for(DWORD i=0; i<updatedPalmRecCount; i++)
|
||||
{
|
||||
if(*updatedPalmRecList)
|
||||
{
|
||||
CMozABConduitRecord * pConduitRecord = new CMozABConduitRecord(**updatedPalmRecList);
|
||||
memcpy(&palmCardList[i], &pConduitRecord->m_nsCard, sizeof(nsABCOMCardStruct));
|
||||
tempMozABConduitRecList[i]=pConduitRecord;
|
||||
}
|
||||
updatedPalmRecList++;
|
||||
}
|
||||
// synchronize and get the updated cards in MozAB
|
||||
HRESULT hres = pNsPalmSync->nsSynchronizeAB(FALSE, categoryIndex, categoryId, categoryName.GetBuffer(0),
|
||||
updatedPalmRecCount, palmCardList,
|
||||
&dwMozCardCount, &mozCardList);
|
||||
if(hres == S_OK && mozCardList)
|
||||
{
|
||||
*pUpdatedPCRecListCount = dwMozCardCount;
|
||||
CPalmRecord ** mozRecordList = (CPalmRecord **) malloc(sizeof(CPalmRecord *) * dwMozCardCount);
|
||||
*updatedPCRecList = mozRecordList;
|
||||
if (mozRecordList)
|
||||
{
|
||||
memset(mozRecordList, 0, sizeof(CPalmRecord *) * dwMozCardCount);
|
||||
int i=0;
|
||||
for (i=0; i < dwMozCardCount; i++)
|
||||
{
|
||||
CMozABConduitRecord * pConduitRecord = new CMozABConduitRecord(mozCardList[i]);
|
||||
CPalmRecord * pMozRecord = new CPalmRecord;
|
||||
pConduitRecord->ConvertToGeneric(*pMozRecord);
|
||||
*mozRecordList = pMozRecord;
|
||||
mozRecordList++;
|
||||
delete pConduitRecord;
|
||||
CMozABConduitRecord::CleanUpABCOMCardStruct(&mozCardList[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
retval = GEN_ERR_LOW_MEMORY;
|
||||
CoTaskMemFree(mozCardList);
|
||||
}
|
||||
else
|
||||
retval = (long) hres;
|
||||
}
|
||||
else
|
||||
retval = GEN_ERR_LOW_MEMORY;
|
||||
|
||||
|
||||
delete palmCardList;
|
||||
if(tempMozABConduitRecList)
|
||||
{
|
||||
for(DWORD j=0; j<updatedPalmRecCount; j++)
|
||||
delete tempMozABConduitRecList[j];
|
||||
delete tempMozABConduitRecList;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
// this will add all records in a Palm category into a new or existing Mozilla AB
|
||||
long MozABPCManager::AddRecords(BOOL replaceExisting, LONG categoryIndex, CPString & categoryName,
|
||||
DWORD updatedPalmRecCount, CPalmRecord ** updatedPalmRecList)
|
||||
{
|
||||
long retval = 0;
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
CMozABConduitRecord ** tempMozABConduitRecList = new CMozABConduitRecord*[updatedPalmRecCount];
|
||||
nsABCOMCardStruct * palmCardList = new nsABCOMCardStruct[updatedPalmRecCount];
|
||||
if(palmCardList)
|
||||
{
|
||||
for(DWORD i=0; i<updatedPalmRecCount; i++)
|
||||
{
|
||||
if(*updatedPalmRecList)
|
||||
{
|
||||
CMozABConduitRecord * pConduitRecord = new CMozABConduitRecord(**updatedPalmRecList);
|
||||
memcpy(&palmCardList[i], &pConduitRecord->m_nsCard, sizeof(nsABCOMCardStruct));
|
||||
tempMozABConduitRecList[i]=pConduitRecord;
|
||||
}
|
||||
updatedPalmRecList++;
|
||||
}
|
||||
// get the ABList
|
||||
HRESULT hres = pNsPalmSync->nsAddAllABRecords(FALSE, replaceExisting, categoryIndex, categoryName.GetBuffer(0),
|
||||
updatedPalmRecCount, palmCardList);
|
||||
if (hres != S_OK)
|
||||
retval = (long) hres;
|
||||
}
|
||||
else
|
||||
retval = GEN_ERR_LOW_MEMORY;
|
||||
|
||||
delete palmCardList;
|
||||
if(tempMozABConduitRecList)
|
||||
{
|
||||
|
||||
for(DWORD i=0; i<updatedPalmRecCount; i++)
|
||||
delete tempMozABConduitRecList[i];
|
||||
delete tempMozABConduitRecList;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool MozABPCManager::PCABDeleted(CPString &ABName)
|
||||
{
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return false;
|
||||
BOOL abDeleted;
|
||||
HRESULT hres = pNsPalmSync->nsGetABDeleted(ABName.GetBuffer(0), &abDeleted);
|
||||
return (hres == S_OK) ? abDeleted : false; // assume false;
|
||||
|
||||
}
|
||||
// this load all records in an Moz AB
|
||||
// this function allocates the mozlist as well as the mozRecs, caller should free list and delete recs
|
||||
long MozABPCManager::LoadAllRecords(CPString & ABName, DWORD * pPCRecListCount, CPalmRecord *** pPCRecList)
|
||||
{
|
||||
lpnsABCOMCardStruct mozCardList=NULL; // freed by MSCOM/Mozilla.
|
||||
int dwMozCardCount=0;
|
||||
long retval = 0;
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
// get the ABList
|
||||
HRESULT hres = pNsPalmSync->nsGetAllABCards(FALSE, -1, ABName.GetBuffer(0),
|
||||
&dwMozCardCount, &mozCardList);
|
||||
if (hres == S_OK && mozCardList) {
|
||||
*pPCRecListCount = dwMozCardCount;
|
||||
CPalmRecord ** mozRecordList = (CPalmRecord **) malloc(sizeof(CPalmRecord *) * dwMozCardCount);
|
||||
*pPCRecList = mozRecordList;
|
||||
if (mozRecordList) {
|
||||
memset(mozRecordList, 0, sizeof(CPalmRecord *) * dwMozCardCount);
|
||||
for (int i=0; i < dwMozCardCount; i++) {
|
||||
CMozABConduitRecord * pConduitRecord = new CMozABConduitRecord(mozCardList[i]);
|
||||
CPalmRecord * pMozRecord = new CPalmRecord;
|
||||
pConduitRecord->ConvertToGeneric(*pMozRecord);
|
||||
*mozRecordList = pMozRecord;
|
||||
mozRecordList++;
|
||||
delete pConduitRecord;
|
||||
CMozABConduitRecord::CleanUpABCOMCardStruct(&mozCardList[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
retval = GEN_ERR_LOW_MEMORY;
|
||||
CoTaskMemFree(mozCardList);
|
||||
}
|
||||
else
|
||||
retval = (long) hres;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABPCManager::NotifySyncDone(BOOL success, LONG catIndex, DWORD newRecCount, DWORD * newRecIDList)
|
||||
{
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
// MS COM Proxy stub Dll will not accept NULL for this address
|
||||
if(!newRecIDList)
|
||||
newRecIDList = &newRecCount;
|
||||
|
||||
HRESULT hres = pNsPalmSync->nsAckSyncDone(success, catIndex, newRecCount, newRecIDList);
|
||||
long retval = (long) hres;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABPCManager::UpdatePCABSyncInfo(LONG categoryIndex, CPString & categoryName)
|
||||
{
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
HRESULT hres = pNsPalmSync->nsUpdateABSyncInfo(FALSE, categoryIndex, categoryName);
|
||||
long retval = (long) hres;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABPCManager::DeletePCAB(LONG categoryIndex, CPString & categoryName, CPString & categoryUrl)
|
||||
{
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
HRESULT hres = pNsPalmSync->nsDeleteAB(FALSE, categoryIndex, categoryName, categoryUrl);
|
||||
long retval = (long) hres;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABPCManager::RenamePCAB(LONG categoryIndex, CPString & categoryName, CPString & categoryUrl)
|
||||
{
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
HRESULT hres = pNsPalmSync->nsRenameAB(FALSE, categoryIndex, categoryName, categoryUrl);
|
||||
return (long) hres;
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
/* ***** 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 ***** */
|
||||
|
||||
#ifndef _MOZAB_PCMANAGER_H_
|
||||
#define _MOZAB_PCMANAGER_H_
|
||||
|
||||
#include <CPString.h>
|
||||
#include <CPDbBMgr.h>
|
||||
|
||||
#include "IPalmSync.h"
|
||||
|
||||
class MozABPCManager
|
||||
{
|
||||
public:
|
||||
MozABPCManager() { }
|
||||
~MozABPCManager() { }
|
||||
|
||||
// this will return the list of ABs in Mozilla and some flags, including if they were synced before
|
||||
long GetPCABList(DWORD * pCategoryCount, LONG ** pCategoryIndexList,
|
||||
CPString *** pCategoryNameList, CPString *** pCategoryURLList, BOOL ** pDirFlags);
|
||||
// this will update a Mozilla AB with updated Palm records and
|
||||
// return updated records in a Mozilla AB after the last sync
|
||||
// this will take care of first time sync also in which case
|
||||
// updatedPalmRecList is the list of all palm records and
|
||||
// updatedPCRecList is the list of unique Moz AB cards / records.
|
||||
long SynchronizePCAB(LONG categoryIndex, LONG categoryId, CPString & categoryName,
|
||||
DWORD updatedPalmRecCount, CPalmRecord ** updatedPalmRecList,
|
||||
DWORD * pUpdatedPCRecList, CPalmRecord *** updatedPCRecList);
|
||||
// this will add all records in a Palm category into a new or existing Mozilla AB
|
||||
long AddRecords(BOOL replaceExisting, LONG categoryIndex, CPString & categoryName,
|
||||
DWORD updatedPalmRecCount, CPalmRecord ** updatedPalmRecList);
|
||||
// this load all records in an Moz AB
|
||||
long LoadAllRecords(CPString & ABName, DWORD * pPCRecListCount, CPalmRecord *** pPCRecList);
|
||||
|
||||
long NotifySyncDone(BOOL success, LONG catIndex=-1, DWORD newRecCount=0, DWORD * newRecIDList=NULL);
|
||||
|
||||
// Update/Reset category id and mod time in an Moz AB
|
||||
long UpdatePCABSyncInfo(LONG categoryIndex, CPString & categoryName);
|
||||
// Delete an Moz AB
|
||||
long DeletePCAB(LONG categoryIndex, CPString & categoryName, CPString & categoryUrl);
|
||||
// Rename an Moz AB
|
||||
long RenamePCAB(LONG categoryIndex, CPString & categoryName, CPString & categoryUrl);
|
||||
|
||||
bool PCABDeleted(CPString &abName);
|
||||
static BOOL gUseHomeAddress;
|
||||
static BOOL gPreferHomePhone;
|
||||
|
||||
private:
|
||||
// this will initiate the communication with Mozilla
|
||||
BOOL InitMozPalmSyncInstance(IPalmSync **aRetValue);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,105 +0,0 @@
|
|||
// Install script for palmsync
|
||||
|
||||
var err;
|
||||
|
||||
err = initInstall("Palmsync v0.4.0", // name for install UI
|
||||
"/palmsync", // registered name
|
||||
"0.4.0.0"); // package version
|
||||
|
||||
const APP_VERSION = "0.0.4";
|
||||
const APP_PACKAGE = "/XXX.mozdev.org/palmsync";
|
||||
|
||||
logComment("initInstall: " + err);
|
||||
|
||||
var srDest = 300; // Disk space required for installation (KB)
|
||||
|
||||
var fProgram = getFolder("Program");
|
||||
logComment("fProgram: " + fProgram);
|
||||
|
||||
if (!verifyDiskSpace(fProgram, srDest)) {
|
||||
cancelInstall(INSUFFICIENT_DISK_SPACE);
|
||||
|
||||
} else {
|
||||
|
||||
var fInstallDir = getFolder(".");
|
||||
var fComponentsDir = getFolder("components");
|
||||
err = addFile(APP_PACKAGE, APP_VERSION, "mozABConduit.dll", fProgram, null);
|
||||
err = addFile(APP_PACKAGE, APP_VERSION, "CondMgr.dll", fProgram, null);
|
||||
err = addFile(APP_PACKAGE, APP_VERSION, "HSAPI.dll", fProgram, null);
|
||||
err = addFile(APP_PACKAGE, APP_VERSION, "PalmSyncProxy.dll", fProgram, null);
|
||||
err = addFile(APP_PACKAGE, APP_VERSION, "PalmSyncInstall.exe", fProgram, null);
|
||||
err = addFile(APP_PACKAGE, APP_VERSION, "palmsync.dll", fComponentsDir, null);
|
||||
err = addFile(APP_PACKAGE, APP_VERSION, "palmSync.xpt", fComponentsDir, null);
|
||||
|
||||
err = getLastError();
|
||||
|
||||
if (err == ACCESS_DENIED) {
|
||||
alert("Unable to write to installation directory "+fInstallDir+".\n You will need to restart the browser with administrator/root privileges to install this software. After installing as root (or administrator), you will need to restart the browser one more time to register the installed software.\n After the second restart, you can go back to running the browser without privileges!");
|
||||
|
||||
cancelInstall(ACCESS_DENIED);
|
||||
|
||||
} else if (err != SUCCESS) {
|
||||
cancelInstall(err);
|
||||
|
||||
} else {
|
||||
var args = "/p";
|
||||
args += fProgram;
|
||||
err = execute("PalmSyncInstall.exe", args, true);
|
||||
performInstall();
|
||||
}
|
||||
}
|
||||
|
||||
// this function verifies disk space in kilobytes
|
||||
function verifyDiskSpace(dirPath, spaceRequired) {
|
||||
var spaceAvailable;
|
||||
|
||||
// Get the available disk space on the given path
|
||||
spaceAvailable = fileGetDiskSpaceAvailable(dirPath);
|
||||
|
||||
// Convert the available disk space into kilobytes
|
||||
spaceAvailable = parseInt(spaceAvailable / 1024);
|
||||
|
||||
// do the verification
|
||||
if(spaceAvailable < spaceRequired) {
|
||||
logComment("Insufficient disk space: " + dirPath);
|
||||
logComment(" required : " + spaceRequired + " K");
|
||||
logComment(" available: " + spaceAvailable + " K");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// OS type detection
|
||||
// which platform?
|
||||
function getPlatform() {
|
||||
var platformStr;
|
||||
var platformNode;
|
||||
|
||||
if('platform' in Install) {
|
||||
platformStr = new String(Install.platform);
|
||||
|
||||
if (!platformStr.search(/^Macintosh/))
|
||||
platformNode = 'mac';
|
||||
else if (!platformStr.search(/^Win/))
|
||||
platformNode = 'win';
|
||||
else
|
||||
platformNode = 'unix';
|
||||
}
|
||||
else {
|
||||
var fOSMac = getFolder("Mac System");
|
||||
var fOSWin = getFolder("Win System");
|
||||
|
||||
logComment("fOSMac: " + fOSMac);
|
||||
logComment("fOSWin: " + fOSWin);
|
||||
|
||||
if(fOSMac != null)
|
||||
platformNode = 'mac';
|
||||
else if(fOSWin != null)
|
||||
platformNode = 'win';
|
||||
else
|
||||
platformNode = 'unix';
|
||||
}
|
||||
|
||||
return platformNode;
|
||||
}
|
Двоичные данные
mailnews/extensions/palmsync/conduit/res/DoNothing.bmp
Двоичные данные
mailnews/extensions/palmsync/conduit/res/DoNothing.bmp
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 694 B |
Двоичные данные
mailnews/extensions/palmsync/conduit/res/HhToPc.bmp
Двоичные данные
mailnews/extensions/palmsync/conduit/res/HhToPc.bmp
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 694 B |
Двоичные данные
mailnews/extensions/palmsync/conduit/res/PcToHh.bmp
Двоичные данные
mailnews/extensions/palmsync/conduit/res/PcToHh.bmp
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 694 B |
Двоичные данные
mailnews/extensions/palmsync/conduit/res/Synchronize.bmp
Двоичные данные
mailnews/extensions/palmsync/conduit/res/Synchronize.bmp
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 694 B |
|
@ -1,41 +0,0 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by MozABConduitGenCond.rc
|
||||
//
|
||||
#define IDS_CONDUIT_NAME 1
|
||||
#define IDB_HHTOPC 102
|
||||
#define IDB_SYNC 103
|
||||
#define IDB_DONOTHING 104
|
||||
#define IDB_PCTOHH 105
|
||||
#define IDD_CONDUIT_ACTION 399
|
||||
#define IDC_ACTIONGROUPBOXTEXT 403
|
||||
#define IDC_RADIO_SYNC 404
|
||||
#define IDC_RADIO_PCTOHH 405
|
||||
#define IDC_RADIO_HHTOPC 406
|
||||
#define IDC_RADIO_DONOTHING 407
|
||||
#define IDC_MAKEDEFAULT 411
|
||||
#define IDC_SYNC 1000
|
||||
#define IDC_DONOTHING 1001
|
||||
#define IDC_STATIC_PERMANENT 1002
|
||||
#define IDC_STATIC_TEMPORARY 1003
|
||||
#define IDC_CURRENT_SETTINGS_GROUP 1004
|
||||
#define IDC_PCTOHH 1005
|
||||
#define IDC_HHTOPC 1006
|
||||
#define IDS_CONNECTION 3311
|
||||
#define IDS_CURRENT_SETTINGS_GROUP 8004
|
||||
#define IDS_SYNC_FILES 8005
|
||||
#define IDS_DO_NOTHING 8006
|
||||
#define IDS_PCTOHH 8007
|
||||
#define IDS_HHTOPC 8008
|
||||
#define IDS_SYNC_ACTION_TEXT 8009
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 106
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
#filter substitution
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>@INSTALL_EXTENSION_ID@</em:id>
|
||||
<em:version>@EXTENSION_VERSION@</em:version>
|
||||
|
||||
<em:targetApplication>
|
||||
<!-- Thunderbird -->
|
||||
<Description>
|
||||
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
|
||||
<em:minVersion>@THUNDERBIRD_VERSION@</em:minVersion>
|
||||
<em:maxVersion>@THUNDERBIRD_VERSION@</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<em:targetApplication>
|
||||
<!-- SeaMonkey -->
|
||||
<Description>
|
||||
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
|
||||
<em:minVersion>@SEAMONKEY_VERSION@</em:minVersion>
|
||||
<em:maxVersion>@SEAMONKEY_VERSION@</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<em:name>Palm Sync</em:name>
|
||||
<em:description>Palm address book synchronization.</em:description>
|
||||
<em:creator>Team Thunderbird</em:creator>
|
||||
<em:homepageURL>http://kb.mozillazine.org/PalmSync_-_Thunderbird</em:homepageURL>
|
||||
</Description>
|
||||
</RDF>
|
|
@ -1,65 +0,0 @@
|
|||
#
|
||||
# ***** 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
PALM_CDK_INC = $(PALM_CDK_DIR)/C++/Include
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
XPI_NAME = palmsync
|
||||
USE_EXTENSION_MANIFEST = 1
|
||||
# make this id as short as possible due to a bug with the palm deskop and long path names.
|
||||
# Change /mailnews/extensions/palmsync/Makefile.in and nsPalmSyncSupport.cpp if this changes.
|
||||
INSTALL_EXTENSION_ID = p@m
|
||||
XPI_PKGNAME = palmsync-$(MOZ_APP_VERSION)
|
||||
|
||||
PROGRAM = PalmSyncInstall$(BIN_SUFFIX)
|
||||
RESFILE = PalmSyncInstall.res
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
LOCAL_INCLUDES += -I$(PALM_CDK_INC) \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = PalmSyncInstall.cpp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
LDFLAGS += /SUBSYSTEM:WINDOWS /MACHINE:i386
|
|
@ -1,844 +0,0 @@
|
|||
/* ***** 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>
|
||||
* David Bienvenu <bienvenu@nventure.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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <Winreg.h>
|
||||
|
||||
#include "CondMgr.h"
|
||||
#include "HSAPI.h"
|
||||
#include "resource.h"
|
||||
|
||||
#define MOZ_PALMSYNC_PROXY ".\\PalmSyncProxy.dll"
|
||||
#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 *CmSetCreatorTitlePtr)(const char *pCreator, const TCHAR *pConduitTitle);
|
||||
typedef int (WINAPI *CmSetCreatorFilePtr)(const char *pCreator, const TCHAR *pConduitFile);
|
||||
typedef int (WINAPI *CmSetCreatorDirectoryPtr)(const char *pCreator, const TCHAR *pConduitDirectory);
|
||||
|
||||
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);
|
||||
typedef int (WINAPI *CmSetCreatorValueStringPtr)(const char *pCreator, TCHAR *pValueName, TCHAR *value);
|
||||
typedef int (WINAPI *CmSetCorePathPtr) (const char *pPath);
|
||||
typedef int (WINAPI *CmSetHotSyncExePathPtr) (const char *pPath);
|
||||
typedef int (WINAPI *CmSetCreatorModulePtr) (const char *pCreatorID, const TCHAR *pModule);
|
||||
|
||||
typedef int (WINAPI *CmGetCreatorNamePtr)(const char *pCreator, TCHAR *pConduitName, int *pSize);
|
||||
typedef int (WINAPI *CmGetCreatorTitlePtr)(const char *pCreator, TCHAR *pConduitTitle, int *pSize);
|
||||
typedef int (WINAPI *CmGetCreatorPriorityPtr)(const char *pCreator, DWORD *dwPriority);
|
||||
typedef int (WINAPI *CmGetCreatorTypePtr)(const char *pCreator);
|
||||
typedef int (WINAPI *CmGetCreatorIntegratePtr)(const char *pCreator, DWORD *dwIntegrate);
|
||||
typedef int (WINAPI *CmGetCreatorValueDwordPtr)(const char *pCreator, TCHAR *pValueName, DWORD dwValue, DWORD dwDefault);
|
||||
typedef int (WINAPI *CmGetCreatorValueStringPtr)(const char *pCreator, TCHAR *pValueName, TCHAR *pValue, int *pSize, TCHAR *pDefault);
|
||||
typedef int (WINAPI *CmGetCreatorFilePtr) (const TCHAR *pCreatorID, TCHAR *pFile, int *piSize);
|
||||
typedef int (WINAPI *CmGetCreatorDirectoryPtr) (const TCHAR *pCreatorID, TCHAR *pFile, int *piSize);
|
||||
typedef int (WINAPI *CmGetCreatorModulePtr) (const char *pCreatorID, TCHAR *pModule, int *piSize);
|
||||
typedef int (WINAPI *CmGetCreatorRemotePtr)(const char *pCreator, const TCHAR *pRemote, int*pSize);
|
||||
|
||||
// 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);
|
||||
|
||||
// Define general registration fn pointer types
|
||||
typedef int (WINAPI *mozDllRegisterServerPtr)(void);
|
||||
typedef int (WINAPI *mozDllUnregisterServerPtr)(void);
|
||||
|
||||
// forward declaration
|
||||
int InstallConduit(HINSTANCE hInstance, TCHAR *installPath, TCHAR *appName);
|
||||
int UninstallConduit();
|
||||
void ConstructMessage(HINSTANCE hInstance, TCHAR *appName, DWORD dwMessageId, TCHAR *formattedMsg);
|
||||
|
||||
// Global vars
|
||||
BOOL gWasHotSyncRunning = FALSE;
|
||||
|
||||
void ConstructMessage(HINSTANCE hInstance, TCHAR *appName, DWORD dwMessageId, TCHAR *formattedMsg)
|
||||
{
|
||||
// Load brand name and the format string.
|
||||
TCHAR formatString[MAX_LOADSTRING];
|
||||
LoadString(hInstance, dwMessageId, formatString, MAX_LOADSTRING-1);
|
||||
|
||||
// A few msgs needs two app name substitutions.
|
||||
if ((dwMessageId == IDS_SUCCESS_INSTALL) ||
|
||||
(dwMessageId == IDS_CONFIRM_INSTALL))
|
||||
_sntprintf(formattedMsg, MAX_LOADSTRING-1, formatString, appName, appName);
|
||||
else
|
||||
_sntprintf(formattedMsg, MAX_LOADSTRING-1, formatString, appName);
|
||||
|
||||
formattedMsg[MAX_LOADSTRING-1]='\0';
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
TCHAR appTitle[MAX_LOADSTRING];
|
||||
TCHAR appName[MAX_LOADSTRING] = {0};
|
||||
TCHAR msgStr[MAX_LOADSTRING];
|
||||
|
||||
enum eActionType
|
||||
{
|
||||
eInstall,
|
||||
eSilentInstall,
|
||||
eUninstall,
|
||||
eSilentUninstall
|
||||
};
|
||||
|
||||
int res = -1;
|
||||
|
||||
char* installDir = NULL;
|
||||
eActionType action = eInstall;
|
||||
|
||||
if (__argc > 1)
|
||||
{
|
||||
char* arg;
|
||||
// Skip the first arg
|
||||
for (int i = 1; i < __argc; ++i)
|
||||
{
|
||||
// The calling's app brand name
|
||||
arg = strstr(__argv[i], "/n");
|
||||
if (arg)
|
||||
{
|
||||
// advance pass app name
|
||||
arg += 2;
|
||||
|
||||
// now get the name
|
||||
strncpy(appName, arg, MAX_LOADSTRING - 1);
|
||||
|
||||
// Add a space onto the name so that we get the display right
|
||||
strcat(appName, " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
// /p can only be used with a standard install,
|
||||
// i.e., non-silent install
|
||||
arg = strstr(__argv[i], "/p");
|
||||
if (arg)
|
||||
// move past the /p, default action is install.
|
||||
installDir = arg + 2;
|
||||
else if (!strcmpi(__argv[i], "/u"))
|
||||
action = eUninstall;
|
||||
else if (!strcmpi(__argv[i], "/us"))
|
||||
action = eSilentUninstall;
|
||||
else if (!strcmpi(__argv[i], "/s"))
|
||||
action = eSilentInstall;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Free the command line memory
|
||||
LocalFree(__argv);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case eInstall:
|
||||
ConstructMessage(hInstance, appName, IDS_APP_TITLE_INSTALL, appTitle);
|
||||
ConstructMessage(hInstance, appName, IDS_CONFIRM_INSTALL, msgStr);
|
||||
|
||||
if (MessageBox(NULL, msgStr, appTitle, MB_YESNO | MB_TOPMOST) == IDYES)
|
||||
{
|
||||
res = InstallConduit(hInstance, installDir, appName);
|
||||
if (!res)
|
||||
res = IDS_SUCCESS_INSTALL;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case eSilentInstall:
|
||||
return InstallConduit(hInstance, installDir, appName);
|
||||
|
||||
case eUninstall:
|
||||
ConstructMessage(hInstance, appName, IDS_APP_TITLE_UNINSTALL, appTitle);
|
||||
ConstructMessage(hInstance, appName, IDS_CONFIRM_UNINSTALL, msgStr);
|
||||
|
||||
if (MessageBox(NULL, msgStr, appTitle, MB_YESNO) == IDYES)
|
||||
{
|
||||
res = UninstallConduit();
|
||||
if (!res)
|
||||
res = IDS_SUCCESS_UNINSTALL;
|
||||
break;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
case eSilentUninstall:
|
||||
return UninstallConduit();
|
||||
}
|
||||
|
||||
if (res > IDS_ERR_MAX || res < IDS_ERR_GENERAL)
|
||||
res = IDS_ERR_GENERAL;
|
||||
|
||||
ConstructMessage(hInstance, appName, res, msgStr);
|
||||
MessageBox(NULL, msgStr, appTitle, MB_OK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// this function gets the install dir for installation
|
||||
int GetPalmDesktopInstallDirectory(TCHAR *pPDInstallDirectory, unsigned long *pSize)
|
||||
{
|
||||
HKEY key;
|
||||
// open the key
|
||||
LONG rc = ::RegOpenKey(HKEY_CURRENT_USER, "Software\\U.S. Robotics\\Pilot Desktop\\Core", &key);
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
// get key value
|
||||
rc = ::RegQueryValueEx(key, "Path", NULL, NULL,
|
||||
(LPBYTE)pPDInstallDirectory, pSize);
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
*pSize = _tcslen(pPDInstallDirectory); // windows only
|
||||
rc=0; // 0 is success for us
|
||||
}
|
||||
// close the key
|
||||
::RegCloseKey(key);
|
||||
}
|
||||
|
||||
if(rc) {
|
||||
HKEY key2;
|
||||
// open the key
|
||||
rc = ::RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\palm.exe", &key2);
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
// get the default key value
|
||||
rc = ::RegQueryValueEx(key2, "", NULL, NULL,
|
||||
(LPBYTE)pPDInstallDirectory, pSize);
|
||||
// get only the path (ie, strip out the exe name). note that we don't use string match
|
||||
// for the exe name here since it's possilbe that the exe name in the default setting
|
||||
// is different from the exe name in RegOpenKey() call. For example, the exe name in
|
||||
// the default setting for "Software\\...\\App Paths\\pbrush.exe" is mspaint.exe.
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
TCHAR *end = pPDInstallDirectory + _tcslen(pPDInstallDirectory);
|
||||
while ((*end != '\\') && (end != pPDInstallDirectory))
|
||||
end--;
|
||||
*end = '\0';
|
||||
rc=0; // 0 is success for us
|
||||
}
|
||||
// close the key
|
||||
::RegCloseKey(key2);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
// this function loads the Conduit Manager
|
||||
int LoadConduitManagerDll(HINSTANCE* hCondMgrDll, const TCHAR * szPalmDesktopDirectory)
|
||||
{
|
||||
// Initialize the return value
|
||||
*hCondMgrDll=NULL;
|
||||
|
||||
// Construct the path of the Palm Desktop Conduit Manager
|
||||
TCHAR szPDCondMgrPath[_MAX_PATH];
|
||||
// take care of any possible string overwrites
|
||||
if((strlen(szPalmDesktopDirectory) + strlen(DIRECTORY_SEPARATOR_STR) + strlen(CONDMGR_FILENAME)) >= _MAX_PATH)
|
||||
return IDS_ERR_LOADING_CONDMGR;
|
||||
strcpy(szPDCondMgrPath, szPalmDesktopDirectory);
|
||||
strcat(szPDCondMgrPath, DIRECTORY_SEPARATOR_STR);
|
||||
strcat(szPDCondMgrPath, CONDMGR_FILENAME);
|
||||
// Load the Conduit Manager library from the Palm Desktop directory
|
||||
if( (*hCondMgrDll=LoadLibrary(szPDCondMgrPath)) != NULL )
|
||||
// Successfully loaded CondMgr Library from Palm Desktop Directory
|
||||
return 0;
|
||||
|
||||
return IDS_ERR_LOADING_CONDMGR;
|
||||
}
|
||||
|
||||
// this function loads the Hsapi Dll
|
||||
int LoadHsapiDll(HINSTANCE* hHsapiDLL, const TCHAR * szPalmDesktopDirectory)
|
||||
{
|
||||
// Initialize the return value
|
||||
*hHsapiDLL=NULL;
|
||||
|
||||
TCHAR szHsapiPath[_MAX_PATH];
|
||||
// take care of any possible string overwrites
|
||||
if((strlen(szPalmDesktopDirectory) + strlen(DIRECTORY_SEPARATOR_STR) + strlen(HSAPI_FILENAME)) >= _MAX_PATH)
|
||||
return IDS_ERR_LOADING_CONDMGR;
|
||||
strcpy(szHsapiPath, szPalmDesktopDirectory);
|
||||
strcat(szHsapiPath, DIRECTORY_SEPARATOR_STR);
|
||||
strcat(szHsapiPath, HSAPI_FILENAME);
|
||||
if( (*hHsapiDLL=LoadLibrary(szHsapiPath)) != NULL )
|
||||
// Successfully loaded HSAPI Library from Palm Desktop 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int RegisterMozPalmSyncDll()
|
||||
{
|
||||
HINSTANCE hMozPalmSyncProxyDll = NULL;
|
||||
if( (hMozPalmSyncProxyDll=LoadLibrary(MOZ_PALMSYNC_PROXY)) != NULL ) {
|
||||
mozDllRegisterServerPtr lpfnmozDllRegisterServer;
|
||||
lpfnmozDllRegisterServer = (mozDllRegisterServerPtr) GetProcAddress(hMozPalmSyncProxyDll, "DllRegisterServer");
|
||||
DWORD dwReturnCode = (*lpfnmozDllRegisterServer)();
|
||||
if(dwReturnCode == S_OK)
|
||||
// Successfully registered
|
||||
return 0;
|
||||
}
|
||||
|
||||
return IDS_ERR_REGISTERING_MOZ_DLL;
|
||||
}
|
||||
|
||||
int UnregisterMozPalmSyncDll()
|
||||
{
|
||||
HINSTANCE hMozPalmSyncProxyDll = NULL;
|
||||
if( (hMozPalmSyncProxyDll=LoadLibrary(MOZ_PALMSYNC_PROXY)) != NULL ) {
|
||||
mozDllUnregisterServerPtr lpfnmozDllUnregisterServer;
|
||||
lpfnmozDllUnregisterServer = (mozDllUnregisterServerPtr) GetProcAddress(hMozPalmSyncProxyDll, "DllUnregisterServer");
|
||||
DWORD dwReturnCode = (*lpfnmozDllUnregisterServer)();
|
||||
if(dwReturnCode == S_OK)
|
||||
// Successfully registered
|
||||
return 0;
|
||||
}
|
||||
|
||||
return IDS_ERR_UNREGISTERING_MOZ_DLL;
|
||||
}
|
||||
|
||||
|
||||
char *mystrsep(char **stringp, char delim)
|
||||
{
|
||||
char *endStr = strchr(*stringp, delim);
|
||||
char *retStr;
|
||||
if (endStr)
|
||||
{
|
||||
bool foundDelim = (*endStr == delim);
|
||||
*endStr = '\0';
|
||||
retStr = *stringp;
|
||||
*stringp = endStr + !!foundDelim;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
return retStr;
|
||||
}
|
||||
|
||||
char oldSettingsStr[500];
|
||||
static char gSavedCwd[_MAX_PATH];
|
||||
|
||||
// installs our Conduit
|
||||
int InstallConduit(HINSTANCE hInstance, TCHAR *installDir, TCHAR *appName)
|
||||
{
|
||||
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 (!installDir)
|
||||
{
|
||||
if(!GetModuleFileName(NULL, szConduitPath, _MAX_PATH))
|
||||
return IDS_ERR_CONDUIT_NOT_FOUND;
|
||||
|
||||
// extract the dir path (without the module name)
|
||||
int index = strlen(szConduitPath)-1;
|
||||
while((szConduitPath[index] != DIRECTORY_SEPARATOR) && index)
|
||||
index--;
|
||||
szConduitPath[index] = 0;
|
||||
}
|
||||
else
|
||||
strncpy(szConduitPath, installDir, sizeof(szConduitPath) - 1);
|
||||
|
||||
// take care of any possible string overwrites
|
||||
if((strlen(szConduitPath) + strlen(DIRECTORY_SEPARATOR_STR) + strlen(CONDUIT_FILENAME)) > _MAX_PATH)
|
||||
return IDS_ERR_LOADING_CONDMGR;
|
||||
// might already have conduit filename in szConduitPath if we're
|
||||
// called recursively, also check for .DLL as that is the best option
|
||||
// if we're passed a short patch name with a file in it.
|
||||
if (!strstr(szConduitPath, ".DLL") && !strstr(szConduitPath, CONDUIT_FILENAME))
|
||||
{
|
||||
if (szConduitPath[strlen(szConduitPath) - 1] != DIRECTORY_SEPARATOR)
|
||||
strcat(szConduitPath, DIRECTORY_SEPARATOR_STR);
|
||||
strcat(szConduitPath, CONDUIT_FILENAME);
|
||||
}
|
||||
|
||||
TCHAR shortConduitPath[_MAX_PATH];
|
||||
|
||||
// Try and get the short path name.
|
||||
if (!GetShortPathName(szConduitPath, shortConduitPath, _MAX_PATH))
|
||||
// If failed, so just use the long one
|
||||
strncpy(shortConduitPath, szConduitPath, _MAX_PATH);
|
||||
|
||||
// Make sure the conduit dll exists
|
||||
struct _finddata_t dll_file;
|
||||
long hFile;
|
||||
if( (hFile = _findfirst( shortConduitPath, &dll_file )) == -1L )
|
||||
return IDS_ERR_CONDUIT_NOT_FOUND;
|
||||
|
||||
// now register the Mozilla Palm Sync Support Dll
|
||||
if( (dwReturnCode = RegisterMozPalmSyncDll()) != 0)
|
||||
return dwReturnCode;
|
||||
|
||||
// Get the Palm Desktop Installation directory
|
||||
TCHAR szPalmDesktopDir[_MAX_PATH];
|
||||
unsigned long desktopSize=_MAX_PATH;
|
||||
|
||||
// old conduit settings - MAX_PATH is arbitrarily long...
|
||||
TCHAR szOldCreatorName[_MAX_PATH];
|
||||
TCHAR szOldRemote[_MAX_PATH];
|
||||
TCHAR szOldCreatorTitle[_MAX_PATH];
|
||||
TCHAR szOldCreatorFile[_MAX_PATH];
|
||||
TCHAR szOldCreatorDirectory[_MAX_PATH];
|
||||
DWORD oldPriority;
|
||||
DWORD oldIntegrate;
|
||||
int oldType;
|
||||
|
||||
// Load the Conduit Manager DLL.
|
||||
HINSTANCE hConduitManagerDLL;
|
||||
if( (dwReturnCode=GetPalmDesktopInstallDirectory(szPalmDesktopDir, &desktopSize)) == 0 )
|
||||
{
|
||||
// need to switch current working directory to directory with palm dlls
|
||||
// because of a bug in Palm Desktop 6.01
|
||||
|
||||
GetCurrentDirectory(sizeof(gSavedCwd), gSavedCwd);
|
||||
SetCurrentDirectory(szPalmDesktopDir);
|
||||
|
||||
if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL, szPalmDesktopDir)) != 0 )
|
||||
return dwReturnCode;
|
||||
}
|
||||
else
|
||||
return IDS_ERR_CONDUIT_NOT_FOUND;
|
||||
|
||||
// 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");
|
||||
CmSetCreatorTitlePtr lpfnCmSetCreatorTitle;
|
||||
lpfnCmSetCreatorTitle = (CmSetCreatorTitlePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorTitle");
|
||||
CmSetCreatorPriorityPtr lpfnCmSetCreatorPriority;
|
||||
lpfnCmSetCreatorPriority = (CmSetCreatorPriorityPtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorPriority");
|
||||
CmSetCreatorIntegratePtr lpfnCmSetCreatorIntegrate;
|
||||
lpfnCmSetCreatorIntegrate = (CmSetCreatorIntegratePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorIntegrate");
|
||||
CmRemoveConduitByCreatorIDPtr lpfnCmRemoveConduitByCreatorID;
|
||||
lpfnCmRemoveConduitByCreatorID = (CmRemoveConduitByCreatorIDPtr) GetProcAddress(hConduitManagerDLL, "CmRemoveConduitByCreatorID");
|
||||
CmSetCreatorValueStringPtr lpfnCmSetCreatorValueString = (CmSetCreatorValueStringPtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorValueString");
|
||||
|
||||
CmGetCreatorRemotePtr lpfnCmGetCreatorRemote;
|
||||
lpfnCmGetCreatorRemote = (CmGetCreatorRemotePtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorRemote");
|
||||
CmGetCreatorNamePtr lpfnCmGetCreatorName;
|
||||
lpfnCmGetCreatorName = (CmGetCreatorNamePtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorName");
|
||||
CmGetCreatorTitlePtr lpfnCmGetCreatorTitle;
|
||||
lpfnCmGetCreatorTitle = (CmGetCreatorTitlePtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorTitle");
|
||||
CmGetCreatorPriorityPtr lpfnCmGetCreatorPriority;
|
||||
lpfnCmGetCreatorPriority = (CmGetCreatorPriorityPtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorPriority");
|
||||
CmGetCreatorIntegratePtr lpfnCmGetCreatorIntegrate;
|
||||
lpfnCmGetCreatorIntegrate = (CmGetCreatorIntegratePtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorIntegrate");
|
||||
CmGetCreatorTypePtr lpfnCmGetCreatorType = (CmGetCreatorTypePtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorType");
|
||||
CmGetCreatorFilePtr lpfnCmGetCreatorFile = (CmGetCreatorFilePtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorFile");
|
||||
CmGetCreatorDirectoryPtr lpfnCmGetCreatorDirectory = (CmGetCreatorDirectoryPtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorDirectory");
|
||||
if( (lpfnCmInstallCreator == NULL)
|
||||
|| (lpfnCmSetCreatorRemote == NULL)
|
||||
|| (lpfnCmSetCreatorName == NULL)
|
||||
|| (lpfnCmSetCreatorTitle == NULL)
|
||||
|| (lpfnCmSetCreatorPriority == NULL)
|
||||
|| (lpfnCmSetCreatorIntegrate == NULL)
|
||||
)
|
||||
{
|
||||
// Return error code.
|
||||
return(IDS_ERR_LOADING_CONDMGR);
|
||||
}
|
||||
|
||||
szOldCreatorTitle[0] = '\0';
|
||||
szOldCreatorName[0] = '\0';
|
||||
szOldRemote[0] = '\0';
|
||||
szOldCreatorTitle[0] = '\0';
|
||||
szOldCreatorFile[0] = '\0';
|
||||
szOldCreatorDirectory[0] = '\0';
|
||||
// get settings for old conduit
|
||||
int remoteBufSize = sizeof(szOldRemote);
|
||||
(*lpfnCmGetCreatorRemote) (CREATOR, szOldRemote, &remoteBufSize);
|
||||
int creatorBufSize = sizeof(szOldCreatorName);
|
||||
(*lpfnCmGetCreatorName)(CREATOR, szOldCreatorName, &creatorBufSize);
|
||||
int creatorTitleBufSize = sizeof(szOldCreatorTitle);
|
||||
(*lpfnCmGetCreatorTitle)(CREATOR, szOldCreatorTitle, &creatorTitleBufSize);
|
||||
int creatorFileBufSize = sizeof(szOldCreatorFile);
|
||||
int creatorDirectoryBufSize = sizeof(szOldCreatorDirectory);
|
||||
(*lpfnCmGetCreatorFile)(CREATOR, szOldCreatorFile, &creatorFileBufSize);
|
||||
(*lpfnCmGetCreatorDirectory)(CREATOR, szOldCreatorDirectory, &creatorDirectoryBufSize);
|
||||
(*lpfnCmGetCreatorPriority)(CREATOR, &oldPriority);
|
||||
(*lpfnCmGetCreatorIntegrate)(CREATOR, &oldIntegrate);
|
||||
oldType = (*lpfnCmGetCreatorType) (CREATOR);
|
||||
|
||||
// if not set by previous pass through here
|
||||
if (!oldSettingsStr[0])
|
||||
_snprintf(oldSettingsStr, sizeof(oldSettingsStr), "%s,%s,%s,%s,%s,%d,%d,%d", szOldRemote, szOldCreatorName,
|
||||
szOldCreatorTitle, szOldCreatorFile, szOldCreatorDirectory, oldType, oldPriority, oldIntegrate);
|
||||
|
||||
// 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);
|
||||
// store the flag in temp global so that in the recursive call it is restarted
|
||||
gWasHotSyncRunning = TRUE;
|
||||
}
|
||||
|
||||
// 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(hInstance, shortConduitPath, appName);
|
||||
}
|
||||
}
|
||||
if( dwReturnCode == 0 )
|
||||
{
|
||||
(*lpfnCmSetCreatorValueString) (CREATOR, "oldConduitSettings", oldSettingsStr);
|
||||
dwReturnCode = (*lpfnCmSetCreatorName)(CREATOR, shortConduitPath);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
TCHAR title[MAX_LOADSTRING];
|
||||
// Construct conduit title (the one displayed in HotSync Mgr's Custom...list)..
|
||||
ConstructMessage(hInstance, appName, IDS_CONDUIT_TITLE, title);
|
||||
dwReturnCode = (*lpfnCmSetCreatorTitle)(CREATOR, title);
|
||||
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);
|
||||
(*lpfnCmSetCreatorValueString) (CREATOR, "oldConduitSettings", oldSettingsStr);
|
||||
}
|
||||
|
||||
// Re-start HotSync if it was running before
|
||||
if( gWasHotSyncRunning )
|
||||
StartHotSync(hHsapiDLL);
|
||||
|
||||
// restore cwd, if we changed it.
|
||||
if (gSavedCwd[0])
|
||||
SetCurrentDirectory(gSavedCwd);
|
||||
|
||||
return(dwReturnCode);
|
||||
}
|
||||
|
||||
// uninstalls our conduit
|
||||
int UninstallConduit()
|
||||
{
|
||||
int dwReturnCode;
|
||||
BOOL bHotSyncRunning = FALSE;
|
||||
|
||||
// Get the Palm Desktop Installation directory
|
||||
TCHAR szPalmDesktopDir[_MAX_PATH];
|
||||
unsigned long desktopSize=_MAX_PATH;
|
||||
// Load the Conduit Manager DLL.
|
||||
HINSTANCE hConduitManagerDLL;
|
||||
if( (dwReturnCode=GetPalmDesktopInstallDirectory(szPalmDesktopDir, &desktopSize)) == 0 )
|
||||
{
|
||||
if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL, szPalmDesktopDir)) != 0 )
|
||||
return(dwReturnCode);
|
||||
}
|
||||
// if registery key not load it from local dir if present by any chance
|
||||
else
|
||||
return(dwReturnCode);
|
||||
|
||||
// need to switch current working directory to directory with palm dlls
|
||||
// because of a bug in Palm Desktop 6.01
|
||||
|
||||
GetCurrentDirectory(sizeof(gSavedCwd), gSavedCwd);
|
||||
SetCurrentDirectory(szPalmDesktopDir);
|
||||
|
||||
// Prepare to uninstall the conduit using Conduit Manager functions
|
||||
CmRemoveConduitByCreatorIDPtr lpfnCmRemoveConduitByCreatorID;
|
||||
lpfnCmRemoveConduitByCreatorID = (CmRemoveConduitByCreatorIDPtr) GetProcAddress(hConduitManagerDLL, "CmRemoveConduitByCreatorID");
|
||||
if( (lpfnCmRemoveConduitByCreatorID == NULL) )
|
||||
return(IDS_ERR_LOADING_CONDMGR);
|
||||
CmSetCorePathPtr lpfnCmSetCorePath = (CmSetCorePathPtr) GetProcAddress(hConduitManagerDLL, "CmSetCorePath");
|
||||
CmSetHotSyncExePathPtr lpfnCmSetHotSyncExePath = (CmSetHotSyncExePathPtr) GetProcAddress(hConduitManagerDLL, "CmSetHotSyncExecPath");
|
||||
CmRestoreHotSyncSettingsPtr lpfnCmRestoreHotSyncSettings;
|
||||
lpfnCmRestoreHotSyncSettings = (CmRestoreHotSyncSettingsPtr) GetProcAddress(hConduitManagerDLL, "CmRestoreHotSyncSettings");
|
||||
CmGetCreatorValueStringPtr lpfnCmGetCreatorValueString = (CmGetCreatorValueStringPtr) GetProcAddress(hConduitManagerDLL, "CmGetCreatorValueString");
|
||||
CmInstallCreatorPtr lpfnCmInstallCreator;
|
||||
lpfnCmInstallCreator = (CmInstallCreatorPtr) GetProcAddress(hConduitManagerDLL, "CmInstallCreator");
|
||||
CmSetCreatorRemotePtr lpfnCmSetCreatorRemote;
|
||||
lpfnCmSetCreatorRemote = (CmSetCreatorRemotePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorRemote");
|
||||
CmSetCreatorNamePtr lpfnCmSetCreatorName;
|
||||
lpfnCmSetCreatorName = (CmSetCreatorNamePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorName");
|
||||
CmSetCreatorTitlePtr lpfnCmSetCreatorTitle;
|
||||
lpfnCmSetCreatorTitle = (CmSetCreatorTitlePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorTitle");
|
||||
CmSetCreatorPriorityPtr lpfnCmSetCreatorPriority;
|
||||
lpfnCmSetCreatorPriority = (CmSetCreatorPriorityPtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorPriority");
|
||||
CmSetCreatorIntegratePtr lpfnCmSetCreatorIntegrate;
|
||||
lpfnCmSetCreatorIntegrate = (CmSetCreatorIntegratePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorIntegrate");
|
||||
CmSetCreatorFilePtr lpfnCmSetCreatorFile = (CmSetCreatorFilePtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorFile");
|
||||
CmSetCreatorDirectoryPtr lpfnCmSetCreatorDirectory = (CmSetCreatorDirectoryPtr) GetProcAddress(hConduitManagerDLL, "CmSetCreatorDirectory");
|
||||
if( (lpfnCmRestoreHotSyncSettings == NULL) )
|
||||
return(IDS_ERR_LOADING_CONDMGR);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
TCHAR oldConduitSettings[500];
|
||||
int strSize = sizeof(oldConduitSettings);
|
||||
dwReturnCode = (*lpfnCmGetCreatorValueString)(CREATOR, "oldConduitSettings", oldConduitSettings, &strSize, "");
|
||||
|
||||
// Actually uninstall the conduit
|
||||
dwReturnCode = (*lpfnCmRemoveConduitByCreatorID)(CREATOR);
|
||||
|
||||
if(dwReturnCode >= 0)
|
||||
{
|
||||
// uninstall Mozilla Palm Sync Support Proxy Dll
|
||||
dwReturnCode = UnregisterMozPalmSyncDll();
|
||||
// dwReturnCode = (*lpfnCmRestoreHotSyncSettings)(TRUE);
|
||||
}
|
||||
|
||||
if (dwReturnCode >= 0)
|
||||
{
|
||||
char * szOldCreatorName;
|
||||
char *szOldRemote;
|
||||
char *szOldCreatorTitle;
|
||||
char *szOldCreatorFile;
|
||||
char *szOldCreatorDirectory;
|
||||
char *oldIntStr;
|
||||
DWORD oldPriority;
|
||||
DWORD oldIntegrate;
|
||||
int oldType;
|
||||
|
||||
char *strPtr = oldConduitSettings;
|
||||
szOldRemote = mystrsep(&strPtr, ',');
|
||||
szOldCreatorName = mystrsep(&strPtr, ',');
|
||||
szOldCreatorTitle = mystrsep(&strPtr, ',');
|
||||
szOldCreatorFile = mystrsep(&strPtr, ',');
|
||||
szOldCreatorDirectory = mystrsep(&strPtr, ',');
|
||||
oldIntStr = mystrsep(&strPtr, ',');
|
||||
oldType = (oldIntStr) ? atoi(oldIntStr) : 0;
|
||||
oldIntStr = mystrsep(&strPtr, ',');
|
||||
oldPriority = (oldIntStr) ? atoi(oldIntStr) : 0;
|
||||
oldIntStr = mystrsep(&strPtr, ',');
|
||||
oldIntegrate = (oldIntStr) ? atoi(oldIntStr) : 0;
|
||||
|
||||
dwReturnCode = (*lpfnCmInstallCreator)(CREATOR, oldType);
|
||||
if( dwReturnCode == 0 )
|
||||
{
|
||||
dwReturnCode = (*lpfnCmSetCreatorName)(CREATOR, szOldCreatorName);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
// Construct conduit title (the one displayed in HotSync Mgr's Custom...list)..
|
||||
dwReturnCode = (*lpfnCmSetCreatorTitle)(CREATOR, szOldCreatorTitle);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
dwReturnCode = (*lpfnCmSetCreatorRemote)(CREATOR, szOldRemote);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
dwReturnCode = (*lpfnCmSetCreatorFile)(CREATOR, szOldCreatorFile);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
dwReturnCode = (*lpfnCmSetCreatorDirectory)(CREATOR, szOldCreatorDirectory);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
dwReturnCode = (*lpfnCmSetCreatorPriority)(CREATOR, oldPriority);
|
||||
if( dwReturnCode != 0 ) return dwReturnCode;
|
||||
// Applications should always set Integrate to 0
|
||||
dwReturnCode = (*lpfnCmSetCreatorIntegrate)(CREATOR, oldIntegrate);
|
||||
}
|
||||
}
|
||||
|
||||
// if (lpfnCmSetCorePath)
|
||||
// (*lpfnCmSetCorePath)(szPalmDesktopDir);
|
||||
// if (lpfnCmSetHotSyncExePath)
|
||||
// (*lpfnCmSetHotSyncExePath)(szPalmHotSyncInstallDir);
|
||||
|
||||
// this registry key is set by the RestoreHotSyncSettings to point incorrectly to Mozilla dir
|
||||
// this should point to the Palm directory to enable sync with Palm Desktop.
|
||||
#if 0
|
||||
HKEY key;
|
||||
LONG rc = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\U.S. Robotics\\Pilot Desktop\\Core",
|
||||
0, KEY_ALL_ACCESS, &key);
|
||||
if(rc == ERROR_SUCCESS)
|
||||
::RegSetValueEx(key, "Path", 0, REG_SZ, (const BYTE *) szPalmDesktopDir, desktopSize);
|
||||
|
||||
if(rc == ERROR_SUCCESS)
|
||||
::RegSetValueEx(key, "HotSyncPath", 0, REG_SZ, (const BYTE *) szPalmHotSyncInstallDir, installSize);
|
||||
#endif
|
||||
// Re-start HotSync if it was running before
|
||||
if( bHotSyncRunning )
|
||||
StartHotSync(hHsapiDLL);
|
||||
|
||||
// restore cwd, if we changed it.
|
||||
if (gSavedCwd[0])
|
||||
SetCurrentDirectory(gSavedCwd);
|
||||
|
||||
if( dwReturnCode < 0 )
|
||||
return dwReturnCode;
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/* ***** 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
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
1 ICON DISCARDABLE "install.ico"
|
||||
2 ICON DISCARDABLE "uninstall.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
// Note these strings don't have a space after %s because the code adds that for us
|
||||
// (just in case we've not got a name to dispaly).
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APP_TITLE_INSTALL "%sAddress Book Palm Sync Install"
|
||||
IDS_APP_TITLE_UNINSTALL "%sAddress Book Palm Sync Uninstall"
|
||||
IDS_CONDUIT_TITLE "%sAddress Book"
|
||||
IDC_PALMSYNCINSTALL "PALMSYNCINSTALL"
|
||||
IDS_ERR_GENERAL "Error in (un)installing the %sAddress Book Palm Sync Conduit"
|
||||
IDS_ERR_LOADING_CONDMGR "Error in loading the Conduit Manager while (un)installing the %sAddress Book Palm Sync Conduit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_ERR_HSAPI_NOT_FOUND "Could not find the HSAPI.dll while (un)installing the %sAddress Book Palm Sync Conduit"
|
||||
IDS_ERR_CONDUIT_NOT_FOUND
|
||||
"Could not find the %sAddress 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 %sAddress Book Palm Sync Conduit"
|
||||
IDS_ERR_FINDING_INSTALL_DIR
|
||||
"Could not find the directory to install the %sAddress Book Palm Sync Conduit."
|
||||
IDS_SUCCESS_INSTALL "%sAddress Book Palm Sync was successfully installed. Using your Palm device, perform a HotSync operation to synchronize your Palm device's address book with your %saddress book."
|
||||
IDS_SUCCESS_UNINSTALL "%sAddress Book Palm Sync was successfully uninstalled. Palm Desktop synchronization with your Palm device is now restored."
|
||||
IDS_CONFIRM_INSTALL "You are about to add the %sAddress Book conduit to your Palm Hot Sync installation, which may remove the Palm Desktop conduit. Do you want to continue?"
|
||||
IDS_CONFIRM_UNINSTALL "You are about to uninstall %sAddress Book Palm Sync. This will restore Palm Desktop synchronization. Do you want to continue?"
|
||||
IDS_ERR_REGISTERING_MOZ_DLL
|
||||
"Failed to register the Palm Sync Support Proxy Dll while installing the %sAddress Book Palm Sync Conduit."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
Двоичные данные
mailnews/extensions/palmsync/installer/install.ico
Двоичные данные
mailnews/extensions/palmsync/installer/install.ico
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 1.1 KiB |
|
@ -1,60 +0,0 @@
|
|||
/* ***** 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_INSTALL 103
|
||||
#define IDS_APP_TITLE_UNINSTALL 104
|
||||
#define IDS_CONDUIT_TITLE 105
|
||||
#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_REGISTERING_MOZ_DLL 120
|
||||
#define IDS_ERR_UNREGISTERING_MOZ_DLL 121
|
||||
#define IDS_ERR_MAX 140
|
||||
|
Двоичные данные
mailnews/extensions/palmsync/installer/uninstall.ico
Двоичные данные
mailnews/extensions/palmsync/installer/uninstall.ico
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 1.1 KiB |
|
@ -1,7 +0,0 @@
|
|||
/*
|
||||
Default pref values for the PalmSync Extension
|
||||
*/
|
||||
|
||||
// global pref used to keep track of whether we have run PalmSyncInstall.exe
|
||||
// for the current installation of the extension.
|
||||
pref("extensions.palmsync.conduitRegistered", false);
|
|
@ -1,53 +0,0 @@
|
|||
#
|
||||
# ***** 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = palmsync
|
||||
XPIDL_MODULE = palmsync
|
||||
XPI_NAME = palmsync
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIPalmSyncSupport.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -1,74 +0,0 @@
|
|||
/* ***** 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 "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* This interface provides support for registering Mozilla as a COM component
|
||||
* for enabling Palm-Mozilla Address Book (and also other when implemented) Synchronization
|
||||
*
|
||||
*/
|
||||
|
||||
[noscript, uuid(0071C291-CE82-11d6-B8A6-00B0D06E5F27)]
|
||||
|
||||
interface nsIPalmSyncSupport : nsISupports {
|
||||
|
||||
/** Initiates PalmSync support
|
||||
*/
|
||||
void initializePalmSyncSupport();
|
||||
|
||||
/** Register the PalmSync COM interface for IPC
|
||||
* This is called only once from the installer
|
||||
*/
|
||||
void registerPalmSync();
|
||||
|
||||
/** Unregister the PalmSync COM interface for IPC
|
||||
* This is called only once from the installer
|
||||
*/
|
||||
void unRegisterPalmSync();
|
||||
|
||||
/** Shuts down the PalmSync support
|
||||
*/
|
||||
void shutdownPalmSyncSupport();
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_IPALMSYNCSUPPORT_CONTRACTID "@mozilla.org/palmsyncsupport;1"
|
||||
#define NS_IPALMSYNCSUPPORT_CLASSNAME "Mozilla PalmSync Support"
|
||||
%}
|
||||
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
#
|
||||
# ***** 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = palmsync
|
||||
LIBRARY_NAME = $(MODULE)
|
||||
# Do not set EXPORT_LIBRARY as we do not want palmsync in the static libs list
|
||||
IS_COMPONENT = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
ifndef MOZ_INCOMPLETE_EXTERNAL_LINKAGE
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
endif
|
||||
XPI_NAME = palmsync
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
PalmSyncProxy \
|
||||
embedcomponents \
|
||||
pref \
|
||||
string \
|
||||
rdf \
|
||||
rdfutil \
|
||||
mork \
|
||||
unicharutil \
|
||||
MapiProxy \
|
||||
locale \
|
||||
msgbase \
|
||||
msgbaseutil \
|
||||
necko \
|
||||
addrbook \
|
||||
xulapp \
|
||||
extensions \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsPalmSyncSupport.cpp \
|
||||
PalmSyncFactory.cpp \
|
||||
PalmSyncImp.cpp \
|
||||
Registry.cpp \
|
||||
nsAbIPCCard.cpp \
|
||||
nsAbPalmSync.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsAbIPCCard.h \
|
||||
nsAbPalmSync.h \
|
||||
$(NULL)
|
||||
|
||||
LOBJS = ../build/IPalmSync_i.$(OBJ_SUFFIX)
|
||||
|
||||
ifndef MOZ_STATIC_MAIL_BUILD
|
||||
ifeq ($(USE_SHORT_LIBNAME),1)
|
||||
EXTRA_DSO_LIBS = msgbsutl
|
||||
else
|
||||
EXTRA_DSO_LIBS = msgbaseutil
|
||||
endif
|
||||
|
||||
else
|
||||
SHARED_LIBRARY_LIBS = ../../../base/util/$(LIB_PREFIX)msgbsutl_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
ifdef MOZILLA_INTERNAL_API
|
||||
EXTRA_DSO_LDOPTS= \
|
||||
../../../addrbook/src/$(LIB_PREFIX)addrbook_s.$(LIB_SUFFIX) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(XPCOM_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS= \
|
||||
../../../addrbook/src/$(LIB_PREFIX)addrbook_s.$(LIB_SUFFIX) \
|
||||
$(LIBS_DIR) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
OS_LIBS += ole32.lib shell32.lib
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DUNICODE -D_UNICODE
|
|
@ -1,118 +0,0 @@
|
|||
/* ***** 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
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* 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 ***** */
|
||||
|
||||
// #undef UNICODE
|
||||
// #undef _UNICODE
|
||||
|
||||
#include "PalmSyncImp.h"
|
||||
#include "PalmSyncFactory.h"
|
||||
|
||||
CPalmSyncFactory ::CPalmSyncFactory()
|
||||
: m_cRef(1)
|
||||
{
|
||||
}
|
||||
|
||||
CPalmSyncFactory::~CPalmSyncFactory()
|
||||
{
|
||||
}
|
||||
|
||||
STDMETHODIMP CPalmSyncFactory::QueryInterface(const IID& aIid, void** aPpv)
|
||||
{
|
||||
if ((aIid == IID_IUnknown) || (aIid == IID_IClassFactory))
|
||||
{
|
||||
*aPpv = static_cast<IClassFactory*>(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aPpv = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
reinterpret_cast<IUnknown*>(*aPpv)->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CPalmSyncFactory::AddRef()
|
||||
{
|
||||
return (PR_AtomicIncrement(&m_cRef));
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CPalmSyncFactory::Release()
|
||||
{
|
||||
PRInt32 temp;
|
||||
temp = PR_AtomicDecrement(&m_cRef);
|
||||
if (m_cRef == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPalmSyncFactory::CreateInstance(IUnknown* aUnknownOuter,
|
||||
const IID& aIid,
|
||||
void** aPpv)
|
||||
{
|
||||
// Cannot aggregate.
|
||||
|
||||
if (aUnknownOuter != NULL)
|
||||
{
|
||||
return CLASS_E_NOAGGREGATION ;
|
||||
}
|
||||
|
||||
// Create component.
|
||||
|
||||
CPalmSyncImp* pImp = new CPalmSyncImp();
|
||||
if (pImp == NULL)
|
||||
{
|
||||
return E_OUTOFMEMORY ;
|
||||
}
|
||||
|
||||
// Get the requested interface.
|
||||
HRESULT hr = pImp->QueryInterface(aIid, aPpv);
|
||||
|
||||
// Release the IUnknown pointer.
|
||||
// (If QueryInterface failed, component will delete itself.)
|
||||
|
||||
pImp->Release();
|
||||
return hr;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPalmSyncFactory::LockServer(PRBool aLock)
|
||||
{
|
||||
return S_OK ;
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/* ***** 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
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef MSG_PALMSYNC_FACTORY_H
|
||||
#define MSG_PALMSYNC_FACTORY_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <objbase.h>
|
||||
#include "nspr.h"
|
||||
|
||||
|
||||
class CPalmSyncFactory : public IClassFactory
|
||||
{
|
||||
public :
|
||||
|
||||
// IUnknown
|
||||
|
||||
STDMETHODIMP QueryInterface (REFIID aIid, void** aPpv);
|
||||
STDMETHODIMP_(ULONG) AddRef(void);
|
||||
STDMETHODIMP_(ULONG) Release(void);
|
||||
|
||||
// IClassFactory
|
||||
|
||||
STDMETHODIMP CreateInstance (LPUNKNOWN aUnkOuter, REFIID aIid, void **aPpv);
|
||||
STDMETHODIMP LockServer (BOOL aLock);
|
||||
|
||||
CPalmSyncFactory ();
|
||||
~CPalmSyncFactory ();
|
||||
|
||||
private :
|
||||
|
||||
PRInt32 m_cRef;
|
||||
};
|
||||
|
||||
#endif // MSG_PALMSYNC_FACTORY_H
|
||||
|
|
@ -1,515 +0,0 @@
|
|||
/* ***** 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
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* 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 ***** */
|
||||
|
||||
#ifdef MOZ_LOGGING
|
||||
// sorry, this has to be before the pre-compiled header
|
||||
#define FORCE_PR_LOG /* Allow logging in the release build */
|
||||
#endif
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#include "IPalmSync.h"
|
||||
#include "PalmSyncImp.h"
|
||||
#include "PalmSyncFactory.h"
|
||||
|
||||
#include "nsAbPalmSync.h"
|
||||
#include "nsMsgI18N.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "nsIAbManager.h"
|
||||
#include "nsIAbDirectory.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
||||
#include "nspr.h"
|
||||
PRLogModuleInfo *PALMSYNC;
|
||||
|
||||
#define kPABDirectory 2 // defined in nsDirPrefs.h
|
||||
#define kMAPIDirectory 3
|
||||
|
||||
CPalmSyncImp::CPalmSyncImp()
|
||||
: m_cRef(1),
|
||||
m_PalmHotSync(nsnull)
|
||||
{
|
||||
if (!PALMSYNC)
|
||||
PALMSYNC = PR_NewLogModule("PALMSYNC");
|
||||
|
||||
|
||||
}
|
||||
|
||||
CPalmSyncImp::~CPalmSyncImp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
STDMETHODIMP CPalmSyncImp::QueryInterface(const IID& aIid, void** aPpv)
|
||||
{
|
||||
if (aIid == IID_IUnknown)
|
||||
{
|
||||
*aPpv = static_cast<IPalmSync*>(this);
|
||||
}
|
||||
else if (aIid == IID_IPalmSync)
|
||||
{
|
||||
*aPpv = static_cast<IPalmSync*>(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aPpv = nsnull;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
reinterpret_cast<IUnknown*>(*aPpv)->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CPalmSyncImp::AddRef()
|
||||
{
|
||||
return PR_AtomicIncrement(&m_cRef);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CPalmSyncImp::Release()
|
||||
{
|
||||
PRInt32 temp;
|
||||
temp = PR_AtomicDecrement(&m_cRef);
|
||||
if (m_cRef == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPalmSyncImp::IsValid()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Get the list of Address Books for the currently logged in user profile
|
||||
STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
|
||||
lpnsMozABDesc * aABList, long ** aABCatIndexList, BOOL ** aDirFlagsList)
|
||||
{
|
||||
if (!aABListCount || !aABList || !aABCatIndexList ||!aDirFlagsList)
|
||||
return E_FAIL;
|
||||
*aABListCount = 0;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAbManager> abManager(do_GetService(NS_ABMANAGER_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> subDirectories;
|
||||
if (NS_SUCCEEDED(abManager->GetDirectories(getter_AddRefs(subDirectories))) &&
|
||||
subDirectories)
|
||||
{
|
||||
// Get the total number of addrbook.
|
||||
PRInt16 count=0;
|
||||
nsCOMPtr<nsISupports> item;
|
||||
PRBool hasMore;
|
||||
while (NS_SUCCEEDED(rv = subDirectories->HasMoreElements(&hasMore)) && hasMore)
|
||||
{
|
||||
if (NS_SUCCEEDED(subDirectories->GetNext(getter_AddRefs(item))))
|
||||
{
|
||||
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(item, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCAutoString fileName;
|
||||
rv = directory->GetFileName(fileName);
|
||||
if(NS_FAILED(rv))
|
||||
continue;
|
||||
PRInt32 dirType;
|
||||
rv = directory->GetDirType(&dirType);
|
||||
if(NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
PRBool disableThisAB;
|
||||
rv = directory->GetBoolValue("disablePalmSync",
|
||||
PR_FALSE, &disableThisAB);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
// Skip/Ignore 4.X addrbooks (ie, with ".na2" extension), and non personal AB's
|
||||
if (disableThisAB || ((fileName.Length() > kABFileName_PreviousSuffixLen) &&
|
||||
strcmp(fileName.get() + fileName.Length() - kABFileName_PreviousSuffixLen, kABFileName_PreviousSuffix) == 0) ||
|
||||
(dirType != kPABDirectory && dirType != kMAPIDirectory))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
if (!count)
|
||||
return E_FAIL; // should not happen but just in case.
|
||||
|
||||
lpnsMozABDesc serverDescList = (lpnsMozABDesc) CoTaskMemAlloc(sizeof(nsMozABDesc) * count);
|
||||
BOOL *dirFlagsList = (BOOL *) CoTaskMemAlloc(sizeof(BOOL) * count);
|
||||
long *catIndexList = (long *) CoTaskMemAlloc(sizeof(long) * count);
|
||||
|
||||
*aABListCount = count;
|
||||
*aABList = serverDescList;
|
||||
*aDirFlagsList = dirFlagsList;
|
||||
*aABCatIndexList = catIndexList;
|
||||
|
||||
// reset enumerator
|
||||
if (NS_FAILED(abManager->GetDirectories(getter_AddRefs(subDirectories))))
|
||||
return E_FAIL;
|
||||
|
||||
// For each valid addrbook collect info.
|
||||
while (NS_SUCCEEDED(rv = subDirectories->HasMoreElements(&hasMore)) && hasMore)
|
||||
{
|
||||
if (NS_SUCCEEDED(subDirectories->GetNext(getter_AddRefs(item))))
|
||||
{
|
||||
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(item, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// We don't have to skip mailing list since there's no mailing lists at the top level.
|
||||
nsCAutoString fileName;
|
||||
nsCAutoString uri;
|
||||
nsString description;
|
||||
PRUint32 palmSyncTimeStamp;
|
||||
PRInt32 dirType, palmCategoryIndex;
|
||||
|
||||
rv = directory->GetDescription(description);
|
||||
if(NS_FAILED(rv)) return E_FAIL;
|
||||
rv = directory->GetFileName(fileName);
|
||||
if(NS_FAILED(rv)) return E_FAIL;
|
||||
rv = directory->GetURI(uri);
|
||||
if(NS_FAILED(rv)) return E_FAIL;
|
||||
rv = directory->GetDirType(&dirType);
|
||||
if(NS_FAILED(rv)) return E_FAIL;
|
||||
rv = directory->GetIntValue("PalmCategoryId", -1, &palmCategoryIndex);
|
||||
if (NS_FAILED(rv)) return E_FAIL;
|
||||
rv = directory->GetIntValue("PalmSyncTimeStamp", 0,
|
||||
(PRInt32*)&palmSyncTimeStamp);
|
||||
if (NS_FAILED(rv)) return E_FAIL;
|
||||
|
||||
PRBool disableThisAB;
|
||||
rv = directory->GetBoolValue("disablePalmSync", PR_FALSE, &disableThisAB);
|
||||
if (NS_FAILED(rv)) return E_FAIL;
|
||||
|
||||
// Skip/Ignore 4.X addrbooks (ie, with ".na2" extension), and non personal AB's
|
||||
if (disableThisAB || ((fileName.Length() > kABFileName_PreviousSuffixLen) &&
|
||||
strcmp(fileName.get() + fileName.Length() - kABFileName_PreviousSuffixLen, kABFileName_PreviousSuffix) == 0) ||
|
||||
(dirType != kPABDirectory && dirType != kMAPIDirectory))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(aIsUnicode)
|
||||
{
|
||||
// convert uri to Unicode
|
||||
nsAutoString abUrl;
|
||||
rv = ConvertToUnicode("UTF-8", uri, abUrl);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
// add to the list
|
||||
CopyUnicodeString(&(serverDescList->lpszABName), description);
|
||||
CopyUnicodeString(&(serverDescList->lpszABUrl), abUrl);
|
||||
}
|
||||
else {
|
||||
// we need to convert uri to Unicode and then to ASCII
|
||||
nsAutoString abUUrl;
|
||||
|
||||
rv = ConvertToUnicode("UTF-8", uri, abUUrl);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
CopyCString(&(serverDescList->lpszABName),
|
||||
NS_ConvertUTF16toUTF8(description));
|
||||
CopyCString(&(serverDescList->lpszABUrl),
|
||||
NS_ConvertUTF16toUTF8(abUUrl));
|
||||
}
|
||||
serverDescList++;
|
||||
|
||||
PRUint32 dirFlag = 0;
|
||||
if (palmSyncTimeStamp <= 0)
|
||||
dirFlag |= kFirstTimeSyncDirFlag;
|
||||
// was this the pab?
|
||||
nsCAutoString prefName;
|
||||
rv = directory->GetDirPrefId(prefName);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
if (prefName.Equals("ldap_2.servers.pab"))
|
||||
dirFlag |= kIsPabDirFlag;
|
||||
*dirFlagsList = (BOOL) dirFlag;
|
||||
dirFlagsList++;
|
||||
|
||||
*catIndexList = palmCategoryIndex;
|
||||
catIndexList++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// assign member variables to the beginning of the list
|
||||
serverDescList = *aABList;
|
||||
dirFlagsList = *aDirFlagsList;
|
||||
catIndexList = *aABCatIndexList;
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Synchronize the Address Book represented by the aCategoryIndex and/or corresponding aABName in Mozilla
|
||||
STDMETHODIMP CPalmSyncImp::nsSynchronizeAB(BOOL aIsUnicode, long aCategoryIndex,
|
||||
long aCategoryId, LPTSTR aABName,
|
||||
int aModRemoteRecCount, lpnsABCOMCardStruct aModRemoteRecList,
|
||||
int * aModMozRecCount, lpnsABCOMCardStruct * aModMozRecList)
|
||||
{
|
||||
// let the already continuing sync complete
|
||||
if(m_PalmHotSync)
|
||||
return E_FAIL;
|
||||
|
||||
m_PalmHotSync = (nsAbPalmHotSync *) new nsAbPalmHotSync(aIsUnicode, aABName, (char*)aABName, aCategoryIndex, aCategoryId);
|
||||
if(!m_PalmHotSync)
|
||||
return E_FAIL;
|
||||
|
||||
nsresult rv = ((nsAbPalmHotSync *)m_PalmHotSync)->Initialize();
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = ((nsAbPalmHotSync *)m_PalmHotSync)->DoSyncAndGetUpdatedCards(aModRemoteRecCount, aModRemoteRecList, aModMozRecCount, aModMozRecList);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// All records from a AB represented by aCategoryIndex and aABName into a new Mozilla AB
|
||||
STDMETHODIMP CPalmSyncImp::nsAddAllABRecords(BOOL aIsUnicode, BOOL replaceExisting, long aCategoryIndex, LPTSTR aABName,
|
||||
int aRemoteRecCount, lpnsABCOMCardStruct aRemoteRecList)
|
||||
{
|
||||
// since we are not returning any data we don't need to keep the nsAbPalmHotSync reference
|
||||
// in order to free the returned data in its destructor. Just create a local nsAbPalmHotSync var.
|
||||
nsAbPalmHotSync palmHotSync(aIsUnicode, aABName, (const char*)aABName, aCategoryIndex, -1);
|
||||
|
||||
nsresult rv = palmHotSync.AddAllRecordsToAB(replaceExisting, aRemoteRecCount, aRemoteRecList);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPalmSyncImp::nsGetABDeleted(LPTSTR aABName, BOOL *abDeleted)
|
||||
{
|
||||
nsCAutoString prefName("ldap_2.servers.");
|
||||
prefName.Append((const char *)aABName);
|
||||
prefName.Append(".position");
|
||||
PRInt32 position = GetIntPref(prefName.get(), -1);
|
||||
*abDeleted = (position == 0);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
// Get All records from a Mozilla AB
|
||||
STDMETHODIMP CPalmSyncImp::nsGetAllABCards(BOOL aIsUnicode, long aCategoryIndex, LPTSTR aABName,
|
||||
int * aMozRecCount, lpnsABCOMCardStruct * aMozRecList)
|
||||
{
|
||||
// if sync is already going on wait for AckSyncDone to be called
|
||||
if(m_PalmHotSync)
|
||||
return E_FAIL;
|
||||
|
||||
m_PalmHotSync = (nsAbPalmHotSync *) new nsAbPalmHotSync(aIsUnicode, aABName, (char*)aABName, aCategoryIndex, -1);
|
||||
if(!m_PalmHotSync)
|
||||
return E_FAIL;
|
||||
|
||||
nsresult rv = ((nsAbPalmHotSync *)m_PalmHotSync)->Initialize();
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = ((nsAbPalmHotSync *)m_PalmHotSync)->GetAllCards(aMozRecCount, aMozRecList);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Send an ack for sync done on the remote AB to Mozilla,
|
||||
// now we delete the data returned to the calling app.
|
||||
STDMETHODIMP CPalmSyncImp::nsAckSyncDone(BOOL aIsSuccess, long aCatIndex, int aNewRecCount, unsigned long * aNewPalmRecIDList)
|
||||
{
|
||||
nsAbPalmHotSync * tempPalmHotSync = (nsAbPalmHotSync *) m_PalmHotSync;
|
||||
if(tempPalmHotSync) {
|
||||
if(aNewRecCount && (aCatIndex > -1))
|
||||
tempPalmHotSync->Done(aIsSuccess, aCatIndex, aNewRecCount, aNewPalmRecIDList);
|
||||
delete tempPalmHotSync;
|
||||
}
|
||||
m_PalmHotSync = nsnull;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Update the category id and mod tiem for the Address Book in Mozilla
|
||||
STDMETHODIMP CPalmSyncImp::nsUpdateABSyncInfo(BOOL aIsUnicode, long aCategoryIndex, LPTSTR aABName)
|
||||
{
|
||||
nsresult rv;
|
||||
if(m_PalmHotSync)
|
||||
rv = ((nsAbPalmHotSync *)m_PalmHotSync)->UpdateSyncInfo(aCategoryIndex);
|
||||
else
|
||||
{
|
||||
// Launch another ABpalmHotSync session.
|
||||
nsAbPalmHotSync palmHotSync(aIsUnicode, aABName, (const char*)aABName, aCategoryIndex, -1);
|
||||
rv = palmHotSync.Initialize();
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = palmHotSync.UpdateSyncInfo(aCategoryIndex);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Delete an Address Book in Mozilla
|
||||
STDMETHODIMP CPalmSyncImp::nsDeleteAB(BOOL aIsUnicode, long aCategoryIndex, LPTSTR aABName, LPTSTR aABUrl)
|
||||
{
|
||||
// This is an independent operation so use a local nsAbPalmHotSync var
|
||||
// (ie the callers don't need to call AckSyncdone after this is done).
|
||||
nsAbPalmHotSync palmHotSync(aIsUnicode, aABName, (const char*)aABName, aCategoryIndex, -1);
|
||||
|
||||
nsresult rv = palmHotSync.DeleteAB((const char*)aABUrl);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Rename an Address Book in Mozilla
|
||||
STDMETHODIMP CPalmSyncImp::nsRenameAB(BOOL aIsUnicode, long aCategoryIndex, LPTSTR aABName, LPTSTR aABUrl)
|
||||
{
|
||||
// This is an independent operation so use a local nsAbPalmHotSync var
|
||||
// (ie the callers don't need to call AckSyncdone after this is done).
|
||||
nsAbPalmHotSync palmHotSync(aIsUnicode, aABName, (const char*)aABName, aCategoryIndex, -1);
|
||||
|
||||
nsresult rv = palmHotSync.RenameAB(aCategoryIndex, (const char*)aABUrl);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CPalmSyncImp::CopyUnicodeString(LPTSTR *destStr, const nsString& srcStr)
|
||||
{
|
||||
if (!destStr)
|
||||
return;
|
||||
|
||||
PRInt32 length = srcStr.Length()+1;
|
||||
*destStr = (LPTSTR) CoTaskMemAlloc(sizeof(PRUnichar) * length);
|
||||
wcsncpy(*destStr, srcStr.get(), length-1);
|
||||
(*destStr)[length-1] = '\0';
|
||||
}
|
||||
|
||||
void CPalmSyncImp::CopyCString(LPTSTR *destStr, const nsCString& srcStr)
|
||||
{
|
||||
if (!destStr)
|
||||
return;
|
||||
|
||||
// these strings are defined as wide in the idl, so we need to add up to 3
|
||||
// bytes of 0 byte padding at the end (if the string is an odd number of
|
||||
// bytes long, we need one null byte to pad out the last char to a wide char
|
||||
// and then two more nulls as a wide null terminator.
|
||||
PRInt32 length = sizeof(char) * (srcStr.Length()+3);
|
||||
*destStr = (LPTSTR) CoTaskMemAlloc(length);
|
||||
char *sp = (char *)*destStr;
|
||||
strncpy(sp, srcStr.get(), length-1); // this will null fill the end of destStr
|
||||
sp[length-1] = '\0';
|
||||
}
|
||||
|
||||
|
||||
/* static */PRBool CPalmSyncImp::GetBoolPref(const char *prefName, PRBool defaultVal)
|
||||
{
|
||||
PRBool boolVal = defaultVal;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch)
|
||||
prefBranch->GetBoolPref(prefName, &boolVal);
|
||||
return boolVal;
|
||||
}
|
||||
|
||||
/* static */PRInt32 CPalmSyncImp::GetIntPref(const char *prefName, PRInt32 defaultVal)
|
||||
{
|
||||
PRInt32 intVal = defaultVal;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch)
|
||||
prefBranch->GetIntPref(prefName, &intVal);
|
||||
return intVal;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CPalmSyncImp::nsUseABHomeAddressForPalmAddress(BOOL *aUseHomeAddress)
|
||||
{
|
||||
*aUseHomeAddress = nsUseABHomeAddressForPalmAddress();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPalmSyncImp::nsPreferABHomePhoneForPalmPhone(BOOL *aPreferHomePhone)
|
||||
{
|
||||
*aPreferHomePhone = nsPreferABHomePhoneForPalmPhone();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* static */ PRBool CPalmSyncImp::nsUseABHomeAddressForPalmAddress()
|
||||
{
|
||||
static PRBool gGotAddressPref = PR_FALSE;
|
||||
static PRBool gUseHomeAddress;
|
||||
if (!gGotAddressPref)
|
||||
{
|
||||
gUseHomeAddress = GetBoolPref("mail.palmsync.useHomeAddress", PR_TRUE);
|
||||
gGotAddressPref = PR_TRUE;
|
||||
}
|
||||
return gUseHomeAddress;
|
||||
}
|
||||
|
||||
/* static */ PRBool CPalmSyncImp::nsPreferABHomePhoneForPalmPhone()
|
||||
{
|
||||
static PRBool gGotPhonePref = PR_FALSE;
|
||||
static PRBool gPreferHomePhone;
|
||||
if (!gGotPhonePref)
|
||||
{
|
||||
gPreferHomePhone = GetBoolPref("mail.palmsync.preferHomePhone", PR_TRUE);
|
||||
gGotPhonePref = PR_TRUE;
|
||||
}
|
||||
return gPreferHomePhone;
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
/* ***** 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
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef PALMSYNC_IMP_H
|
||||
#define PALMSYNC_IMP_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "IPalmSync.h"
|
||||
#include "nspr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
const CLSID CLSID_CPalmSyncImp = { 0xb20b4521, 0xccf8, 0x11d6, { 0xb8, 0xa5, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } };
|
||||
|
||||
// this class implements the MS COM interface IPalmSync that provides the methods
|
||||
// called by the Palm Conduit to perform the AB Sync operations.
|
||||
class CPalmSyncImp : public IPalmSync
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
// IUnknown
|
||||
|
||||
STDMETHODIMP QueryInterface(const IID& aIid, void** aPpv);
|
||||
STDMETHODIMP_(ULONG) AddRef();
|
||||
STDMETHODIMP_(ULONG) Release();
|
||||
|
||||
// Interface IPalmSync
|
||||
|
||||
STDMETHODIMP IsValid();
|
||||
|
||||
CPalmSyncImp();
|
||||
~CPalmSyncImp();
|
||||
|
||||
// Get the list of Address Books for the currently logged in user profile
|
||||
STDMETHODIMP nsGetABList(BOOL aIsUnicode, short * aABListCount,
|
||||
lpnsMozABDesc * aABList, long ** aABCatIndexList, BOOL ** aDirFlags);
|
||||
|
||||
// Synchronize the Address Book represented by the aCategoryIndex and/or corresponding aABName in Mozilla
|
||||
STDMETHODIMP nsSynchronizeAB(BOOL aIsUnicode, long aCategoryIndex, long aCategoryId, LPTSTR aABName,
|
||||
int aModRemoteRecCount, lpnsABCOMCardStruct aModRemoteRecList,
|
||||
int * aModMozRecCount, lpnsABCOMCardStruct * aModMozRecList);
|
||||
|
||||
STDMETHODIMP nsAddAllABRecords(BOOL aIsUnicode, BOOL replaceExisting, long aCategoryIndex, LPTSTR aABName,
|
||||
int aRemoteRecCount, lpnsABCOMCardStruct aRemoteRecList);
|
||||
|
||||
|
||||
STDMETHODIMP nsGetAllABCards(BOOL aIsUnicode, long aCategoryIndex, LPTSTR aABName,
|
||||
int * aMozRecCount, lpnsABCOMCardStruct * aMozRecList);
|
||||
|
||||
STDMETHODIMP nsAckSyncDone(BOOL aIsSuccess, long aCatIndex, int aNewRecCount, unsigned long * aNewPalmRecIDList);
|
||||
|
||||
STDMETHODIMP nsUpdateABSyncInfo(BOOL aIsUnicode, long aCategoryIndex, LPTSTR aABName);
|
||||
|
||||
STDMETHODIMP nsDeleteAB(BOOL aIsUnicode, long aCategoryIndex, LPTSTR aABName, LPTSTR aABUrl);
|
||||
|
||||
STDMETHODIMP nsRenameAB(BOOL aIsUnicode, long aCategoryIndex, LPTSTR aABName, LPTSTR aABUrl);
|
||||
|
||||
STDMETHODIMP nsUseABHomeAddressForPalmAddress(BOOL *aUseHomeAddress);
|
||||
|
||||
STDMETHODIMP nsPreferABHomePhoneForPalmPhone(BOOL *aPreferHomePhone);
|
||||
|
||||
STDMETHODIMP nsGetABDeleted(LPTSTR aABName, BOOL *abDeleted);
|
||||
|
||||
static PRBool GetBoolPref(const char *prefName, PRBool defaultVal);
|
||||
static PRInt32 GetIntPref(const char *prefName, PRInt32 defaultVal);
|
||||
static PRBool nsUseABHomeAddressForPalmAddress();
|
||||
static PRBool nsPreferABHomePhoneForPalmPhone();
|
||||
private :
|
||||
PRInt32 m_cRef;
|
||||
void * m_PalmHotSync;
|
||||
void CopyUnicodeString(LPTSTR *destStr, const nsString& srcStr);
|
||||
void CopyCString(LPTSTR *destStr, const nsCString& srcStr);
|
||||
};
|
||||
|
||||
#endif // MSG_MAPI_IMP_H
|
|
@ -1,312 +0,0 @@
|
|||
/* ***** 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
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* 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 ***** */
|
||||
|
||||
#undef _UNICODE
|
||||
#undef UNICODE
|
||||
|
||||
#include <objbase.h>
|
||||
#include "nsString.h"
|
||||
#include "Registry.h"
|
||||
|
||||
#define PALMSYNC_PROXY_DLL_NAME "PalmSyncProxy.dll"
|
||||
#define PALMSYNC_STARTUP_ARG " -PalmSyncStartup"
|
||||
#define MAX_SIZE 2048
|
||||
|
||||
// Size of a CLSID as a string
|
||||
const int CLSID_STRING_SIZE = 39;
|
||||
|
||||
// Proxy/Stub Dll Routines
|
||||
|
||||
typedef HRESULT (__stdcall ProxyServer)();
|
||||
|
||||
|
||||
// Convert a CLSID to a char string.
|
||||
|
||||
BOOL CLSIDtochar(const CLSID& clsid, char* szCLSID,
|
||||
int length)
|
||||
{
|
||||
LPOLESTR wszCLSID = NULL;
|
||||
|
||||
// Get CLSID
|
||||
HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
// Covert from wide characters to non-wide.
|
||||
wcstombs(szCLSID, wszCLSID, length);
|
||||
|
||||
// Free memory.
|
||||
CoTaskMemFree(wszCLSID);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Create a key and set its value.
|
||||
|
||||
BOOL setKeyAndValue(nsCAutoString keyName, const char* subKey,
|
||||
const char* theValue)
|
||||
{
|
||||
HKEY hKey;
|
||||
BOOL retValue = TRUE;
|
||||
|
||||
nsCAutoString theKey(keyName);
|
||||
if (subKey != NULL)
|
||||
{
|
||||
theKey += "\\";
|
||||
theKey += subKey;
|
||||
}
|
||||
|
||||
// Create and open key and subkey.
|
||||
long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, theKey.get(),
|
||||
0, NULL, REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
return FALSE ;
|
||||
|
||||
// Set the Value.
|
||||
if (theValue != NULL)
|
||||
{
|
||||
lResult = RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE *)theValue,
|
||||
strlen(theValue)+1);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
retValue = FALSE;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Delete a key and all of its descendents.
|
||||
|
||||
LONG recursiveDeleteKey(HKEY hKeyParent, // Parent of key to delete
|
||||
const char* lpszKeyChild) // Key to delete
|
||||
{
|
||||
// Open the child.
|
||||
HKEY hKeyChild ;
|
||||
LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
|
||||
KEY_ALL_ACCESS, &hKeyChild) ;
|
||||
if (lRes != ERROR_SUCCESS)
|
||||
{
|
||||
return lRes ;
|
||||
}
|
||||
|
||||
// Enumerate all of the decendents of this child.
|
||||
FILETIME time ;
|
||||
char szBuffer[MAX_SIZE] ;
|
||||
DWORD dwSize = MAX_SIZE ;
|
||||
while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
|
||||
NULL, NULL, &time) == S_OK)
|
||||
{
|
||||
// Delete the decendents of this child.
|
||||
lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
|
||||
if (lRes != ERROR_SUCCESS)
|
||||
{
|
||||
// Cleanup before exiting.
|
||||
RegCloseKey(hKeyChild) ;
|
||||
return lRes;
|
||||
}
|
||||
dwSize = MAX_SIZE;
|
||||
}
|
||||
|
||||
// Close the child.
|
||||
RegCloseKey(hKeyChild) ;
|
||||
|
||||
// Delete this child.
|
||||
return RegDeleteKey(hKeyParent, lpszKeyChild) ;
|
||||
}
|
||||
|
||||
void RegisterProxy()
|
||||
{
|
||||
HINSTANCE h = NULL;
|
||||
ProxyServer *RegisterFunc = NULL;
|
||||
|
||||
char szModule[MAX_SIZE];
|
||||
char *pTemp = NULL;
|
||||
|
||||
HMODULE hModule = GetModuleHandle(NULL);
|
||||
DWORD dwResult = ::GetModuleFileName(hModule, szModule,
|
||||
sizeof(szModule)/sizeof(char));
|
||||
if (dwResult == 0)
|
||||
return;
|
||||
|
||||
pTemp = strrchr(szModule, '\\');
|
||||
if (pTemp == NULL)
|
||||
return;
|
||||
|
||||
*pTemp = '\0';
|
||||
nsCAutoString proxyPath(szModule);
|
||||
|
||||
proxyPath += "\\";
|
||||
proxyPath += PALMSYNC_PROXY_DLL_NAME;
|
||||
|
||||
h = LoadLibrary(proxyPath.get());
|
||||
if (h == NULL)
|
||||
return;
|
||||
|
||||
RegisterFunc = (ProxyServer *) GetProcAddress(h, "DllRegisterServer");
|
||||
if (RegisterFunc)
|
||||
RegisterFunc();
|
||||
|
||||
FreeLibrary(h);
|
||||
}
|
||||
|
||||
void UnRegisterProxy()
|
||||
{
|
||||
HINSTANCE h = NULL;
|
||||
ProxyServer *UnRegisterFunc = NULL;
|
||||
|
||||
char szModule[MAX_SIZE];
|
||||
char *pTemp = NULL;
|
||||
|
||||
HMODULE hModule = GetModuleHandle(NULL);
|
||||
DWORD dwResult = ::GetModuleFileName(hModule, szModule,
|
||||
sizeof(szModule)/sizeof(char));
|
||||
if (dwResult == 0)
|
||||
return;
|
||||
|
||||
pTemp = strrchr(szModule, '\\');
|
||||
if (pTemp == NULL)
|
||||
return;
|
||||
|
||||
*pTemp = '\0';
|
||||
nsCAutoString proxyPath(szModule);
|
||||
|
||||
proxyPath += "\\";
|
||||
proxyPath += PALMSYNC_PROXY_DLL_NAME;
|
||||
|
||||
h = LoadLibrary(proxyPath.get());
|
||||
if (h == NULL)
|
||||
return;
|
||||
|
||||
UnRegisterFunc = (ProxyServer *) GetProcAddress(h, "DllUnregisterServer");
|
||||
if (UnRegisterFunc)
|
||||
UnRegisterFunc();
|
||||
|
||||
FreeLibrary(h);
|
||||
}
|
||||
|
||||
// Register the component in the registry.
|
||||
|
||||
HRESULT RegisterServerForPalmSync(const CLSID& clsid, // Class ID
|
||||
const char* szFriendlyName, // Friendly Name
|
||||
const char* szVerIndProgID, // Programmatic
|
||||
const char* szProgID) // IDs
|
||||
{
|
||||
HMODULE hModule = GetModuleHandle(NULL);
|
||||
char szModuleName[MAX_SIZE];
|
||||
char szCLSID[CLSID_STRING_SIZE];
|
||||
|
||||
nsCAutoString independentProgId(szVerIndProgID);
|
||||
nsCAutoString progId(szProgID);
|
||||
|
||||
DWORD dwResult = ::GetModuleFileName(hModule, szModuleName,
|
||||
sizeof(szModuleName)/sizeof(char));
|
||||
|
||||
if (dwResult == 0)
|
||||
return S_FALSE;
|
||||
|
||||
nsCAutoString moduleName(szModuleName);
|
||||
nsCAutoString registryKey("CLSID\\");
|
||||
|
||||
moduleName += PALMSYNC_STARTUP_ARG;
|
||||
|
||||
// Convert the CLSID into a char.
|
||||
|
||||
if (!CLSIDtochar(clsid, szCLSID, sizeof(szCLSID)))
|
||||
return S_FALSE;
|
||||
registryKey += szCLSID;
|
||||
|
||||
// Add the CLSID to the registry.
|
||||
if((!setKeyAndValue(registryKey, NULL, szFriendlyName))
|
||||
|| (!setKeyAndValue(registryKey, "LocalServer32", moduleName.get()))
|
||||
// Add the ProgID subkey under the CLSID key.
|
||||
|| (!setKeyAndValue(registryKey, "ProgID", szProgID))
|
||||
// Add the version-independent ProgID subkey under CLSID key.
|
||||
|| (!setKeyAndValue(registryKey, "VersionIndependentProgID", szVerIndProgID))
|
||||
// Add the version-independent ProgID subkey under HKEY_CLASSES_ROOT.
|
||||
|| (!setKeyAndValue(independentProgId, NULL, szFriendlyName))
|
||||
|| (!setKeyAndValue(independentProgId, "CLSID", szCLSID))
|
||||
|| (!setKeyAndValue(independentProgId, "CurVer", szProgID))
|
||||
// Add the versioned ProgID subkey under HKEY_CLASSES_ROOT.
|
||||
|| (!setKeyAndValue(progId, NULL, szFriendlyName))
|
||||
|| (!setKeyAndValue(progId, "CLSID", szCLSID))
|
||||
)
|
||||
return S_FALSE;
|
||||
|
||||
RegisterProxy();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
LONG UnregisterServerForPalmSync(const CLSID& clsid, // Class ID
|
||||
const char* szVerIndProgID, // Programmatic
|
||||
const char* szProgID) // IDs
|
||||
{
|
||||
LONG lResult = S_OK;
|
||||
|
||||
// Convert the CLSID into a char.
|
||||
|
||||
char szCLSID[CLSID_STRING_SIZE];
|
||||
if (!CLSIDtochar(clsid, szCLSID, sizeof(szCLSID)))
|
||||
return S_FALSE;
|
||||
|
||||
UnRegisterProxy();
|
||||
|
||||
nsCAutoString registryKey("CLSID\\");
|
||||
registryKey += szCLSID;
|
||||
|
||||
lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, registryKey.get());
|
||||
if (lResult == ERROR_SUCCESS || lResult == ERROR_FILE_NOT_FOUND)
|
||||
return lResult;
|
||||
|
||||
registryKey += "\\LocalServer32";
|
||||
|
||||
// Delete only the path for this server.
|
||||
|
||||
lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, registryKey.get());
|
||||
if (lResult != ERROR_SUCCESS && lResult != ERROR_FILE_NOT_FOUND)
|
||||
return lResult;
|
||||
|
||||
// Delete the version-independent ProgID Key.
|
||||
lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szVerIndProgID);
|
||||
if (lResult != ERROR_SUCCESS && lResult != ERROR_FILE_NOT_FOUND)
|
||||
return lResult;
|
||||
|
||||
lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szProgID);
|
||||
|
||||
return lResult;
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/* ***** 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) 2001
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef _REGISTRY_H_
|
||||
#define _REGISTRY_H_
|
||||
|
||||
#include <objbase.h>
|
||||
|
||||
// This function will register a component in the Registry.
|
||||
|
||||
HRESULT RegisterServerForPalmSync(const CLSID& clsid,
|
||||
const char* szFriendlyName,
|
||||
const char* szVerIndProgID,
|
||||
const char* szProgID) ;
|
||||
|
||||
// This function will unregister a component.
|
||||
|
||||
HRESULT UnregisterServerForPalmSync(const CLSID& clsid,
|
||||
const char* szVerIndProgID,
|
||||
const char* szProgID) ;
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,104 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Created by: Rajiv Dayal <rdayal@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 ***** */
|
||||
|
||||
#ifndef nsAbIPCCard_h__
|
||||
#define nsAbIPCCard_h__
|
||||
|
||||
#include "nsAbCardProperty.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "IPalmSync.h"
|
||||
|
||||
// these are states of Palm record
|
||||
// as defined in the Palm CDK
|
||||
#define ATTR_DELETED 0x0001
|
||||
#define ATTR_ARCHIVED 0x0002
|
||||
#define ATTR_MODIFIED 0x0004
|
||||
#define ATTR_NEW 0x0008
|
||||
#define ATTR_NONE 0x0020
|
||||
#define ATTR_NO_REC 0x0040
|
||||
|
||||
class nsAbIPCCard : public nsAbCardProperty
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// this checks for all card data fields
|
||||
NS_IMETHOD Equals(nsIAbCard *card, PRBool *_retval);
|
||||
PRBool Equals(nsABCOMCardStruct * card, nsStringArray & differingAttrs);
|
||||
PRBool EqualsAfterUnicodeConversion(nsABCOMCardStruct * card, nsStringArray & differingAttrs);
|
||||
|
||||
// this check names attribs: first name + last name + display name + nickname
|
||||
PRBool Same(nsABCOMCardStruct * card, PRBool isUnicode=PR_TRUE);
|
||||
PRBool Same(nsIAbCard *card);
|
||||
|
||||
NS_IMETHOD Copy(nsIAbCard *srcCard);
|
||||
nsresult Copy(nsABCOMCardStruct * srcCard);
|
||||
nsresult ConvertToUnicodeAndCopy(nsABCOMCardStruct * srcCard);
|
||||
|
||||
// this function will allocate new memory for the passed in card struct data members
|
||||
// the caller needs to CoTaskMemFree once it is done using the card struct
|
||||
nsresult GetABCOMCardStruct(PRBool isUnicode, nsABCOMCardStruct * card);
|
||||
|
||||
nsAbIPCCard();
|
||||
nsAbIPCCard(nsIAbCard *card);
|
||||
nsAbIPCCard(nsABCOMCardStruct *card, PRBool isUnicode=PR_TRUE);
|
||||
virtual ~nsAbIPCCard();
|
||||
|
||||
void SetStatus(PRUint32 status) { mStatus = status; }
|
||||
PRUint32 GetStatus() { return mStatus; }
|
||||
void SetRecordId(PRUint32 recID) { mRecordId = recID; }
|
||||
PRUint32 GetRecordId() { return mRecordId; }
|
||||
void SetCategoryId(PRUint32 catID) { mCategoryId = catID; }
|
||||
PRUint32 GetCategoryId() { return mCategoryId; }
|
||||
|
||||
private:
|
||||
PRUint32 mRecordId;
|
||||
PRUint32 mCategoryId;
|
||||
PRUint32 mStatus;
|
||||
|
||||
void CopyValue(PRBool isUnicode, const char *attribute, LPTSTR * result);
|
||||
PRBool CompareValue(PRBool isUnicode, LPTSTR cardValue, const char *attribute);
|
||||
PRBool Compare(nsString &cardValue, const char *attribute);
|
||||
void SplitHomeAndWorkAddresses(nsABCOMCardStruct * card, PRBool isUnicode);
|
||||
void SplitAddresses(PRBool isUnicode, LPTSTR homeAddress, LPTSTR workAddress);
|
||||
void JoinHomeAndWorkAddresses(PRBool isUnicode, nsABCOMCardStruct * card);
|
||||
void JoinAddress(PRBool isUnicode, LPTSTR *ptrAddress, nsString &address1, nsString &address2);
|
||||
};
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,152 +0,0 @@
|
|||
/* ***** 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 of 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 ***** */
|
||||
|
||||
#ifndef nsAbPalmHotSync_h__
|
||||
#define nsAbPalmHotSync_h__
|
||||
|
||||
#include "msgMapi.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAbIPCCard.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIAbDirectory.h"
|
||||
|
||||
class nsAbPalmHotSync
|
||||
{
|
||||
public:
|
||||
|
||||
// this class will do HotSync for a specific AB
|
||||
nsAbPalmHotSync(PRBool aIsUnicode, PRUnichar * aAbDescUnicode, const char * aAbDesc, PRInt32 aPalmCatIndex, PRInt32 aPalmCatId);
|
||||
~nsAbPalmHotSync();
|
||||
|
||||
// initialize the object, info for AB for the object, etc
|
||||
nsresult Initialize();
|
||||
|
||||
// this will take in all updated/new Palm records and start Sync.
|
||||
// Sync process will load updated/new cards and compare with updated/new
|
||||
// Palm records to create final list to be sent to Palm and to update AB.
|
||||
nsresult DoSyncAndGetUpdatedCards(PRInt32 aPalmCount, lpnsABCOMCardStruct aPalmRecords, PRInt32 * aMozCount, lpnsABCOMCardStruct * aMozCards);
|
||||
|
||||
// this will return all cards in an AB
|
||||
nsresult GetAllCards(PRInt32 * aCount, lpnsABCOMCardStruct * aCardList);
|
||||
|
||||
// this will return the final list created by above Sync methods
|
||||
// allocates aCardList as a memory block and populates it with mIPCCardList to be sent to Palm
|
||||
nsresult GetCardsToBeSentToPalm(PRInt32 * aCount, lpnsABCOMCardStruct * aCardList);
|
||||
|
||||
// this will create a new AB and all data into it
|
||||
nsresult AddAllRecordsToAB(PRBool replaceExisting, PRInt32 aCount, lpnsABCOMCardStruct aPalmRecords);
|
||||
|
||||
// this will be called when an AckSyncDone is received from the Conduit
|
||||
nsresult Done(PRBool aSuccess, PRInt32 aPalmCatIndex, PRUint32 aPalmRecIDListCount = 0, unsigned long * aPalmRecordIDList = nsnull);
|
||||
|
||||
// this will upate AB with new category id and mod time.
|
||||
nsresult UpdateSyncInfo(long aCategoryIndex);
|
||||
|
||||
// this will delete an AB
|
||||
nsresult DeleteAB(const char * aABUrl);
|
||||
|
||||
// this will rename an AB
|
||||
nsresult RenameAB(long aCategoryIndex, const char * aABUrl);
|
||||
|
||||
protected:
|
||||
|
||||
PRBool mIsPalmDataUnicode;
|
||||
|
||||
// data members related to AB DB
|
||||
PRUint32 mTotalCardCount;
|
||||
nsCOMPtr<nsIAddrDatabase> mABDB;
|
||||
nsCOMPtr <nsILocalFile> mABFile;
|
||||
PRBool mDBOpen;
|
||||
// pref for the AB DB
|
||||
nsString mAbName;
|
||||
PRInt32 mPalmCategoryId;
|
||||
PRInt32 mPalmCategoryIndex;
|
||||
nsCString mFileName;
|
||||
nsCString mUri;
|
||||
nsString mDescription;
|
||||
PRUint32 mDirType;
|
||||
PRUint32 mPalmSyncTimeStamp;
|
||||
// cards directory for the AB
|
||||
nsCOMPtr<nsIAbDirectory> mDirectory;
|
||||
|
||||
// previous AB, the AB state before the last sync
|
||||
nsCOMPtr <nsILocalFile> mPreviousABFile;
|
||||
|
||||
// Palm records list
|
||||
nsVoidArray mPalmRecords;
|
||||
// CardList to be sent to Palm
|
||||
PRUint32 mCardForPalmCount;
|
||||
lpnsABCOMCardStruct mCardListForPalm;
|
||||
// since cards are already in memory because the db is open,
|
||||
// this doesn't add much to memory overhead
|
||||
PRUint32 mNewCardCount;
|
||||
nsCOMPtr <nsISupportsArray> mNewCardsArray;
|
||||
PRBool mIsNewCardForPalm;
|
||||
|
||||
PRBool mInitialized;
|
||||
protected:
|
||||
// disallow calling of default constructor
|
||||
nsAbPalmHotSync();
|
||||
|
||||
// this will take care of opening, nsIAbDirectroy creation, DB backup, etc
|
||||
nsresult OpenABDBForHotSync(PRBool aCreate);
|
||||
nsresult KeepCurrentStateAsPrevious();
|
||||
nsresult UpdateMozABWithPalmRecords();
|
||||
|
||||
// this will load and create a list of cards since last sync
|
||||
nsresult LoadNewModifiedCardsSinceLastSync();
|
||||
nsresult LoadDeletedCardsSinceLastSync();
|
||||
|
||||
// Checks with the corresponding Palm record for any discrepencies
|
||||
// if any modification needed, this will return the modified card
|
||||
// returns whether card exists (in which case it can be discarded)
|
||||
PRBool CardExistsInPalmList(nsAbIPCCard * aIPCCard);
|
||||
|
||||
// utility function
|
||||
nsresult AddToListForPalm(nsAbIPCCard & ipcCard);
|
||||
void ConvertAssignPalmIDAttrib(PRUint32 id, nsIAbCard * card);
|
||||
nsresult GetABInterface();
|
||||
nsresult UpdateABInfo(PRUint32 modTime, PRInt32 categoryId);
|
||||
nsresult ModifyAB(const char * ABUrl, const nsString &aAbName,
|
||||
const PRUint32 aModTime, const PRInt32 aCategoryId);
|
||||
nsresult NewAB(const nsString& aAbName);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,313 +0,0 @@
|
|||
/* ***** 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
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* 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 "nsCOMPtr.h"
|
||||
#include "objbase.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIAppStartupNotifier.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIExtensionManager.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIXULAppInfo.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "PalmSyncImp.h"
|
||||
#include "nsPalmSyncSupport.h"
|
||||
#include "Registry.h"
|
||||
#include <shellapi.h> // needed for ShellExecute
|
||||
|
||||
#define EXTENSION_ID "p@m" // would ideally be palmsync@mozilla.org, but palm can't handle the long file path
|
||||
#define EXECUTABLE_FILENAME "PalmSyncInstall.exe"
|
||||
#define PREF_CONDUIT_REGISTERED "extensions.palmsync.conduitRegistered"
|
||||
|
||||
|
||||
/** Implementation of the IPalmSyncSupport interface.
|
||||
* Use standard implementation of nsISupports stuff.
|
||||
* This also implements the Observors for App Startup
|
||||
* at which time it will register the MSCOM interface
|
||||
* for PalmSync used for IPC with the Palm Conduits
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsPalmSyncSupport, nsIPalmSyncSupport, nsIObserver)
|
||||
|
||||
static NS_METHOD nsPalmSyncRegistrationProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath, const char *registryLocation, const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> categoryManager(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY, "PalmSync Support",
|
||||
"service," NS_IPALMSYNCSUPPORT_CONTRACTID, PR_TRUE, PR_TRUE, nsnull);
|
||||
return rv ;
|
||||
}
|
||||
|
||||
static NS_METHOD nsPalmSyncUnRegistrationProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> categoryManager(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = categoryManager->DeleteCategoryEntry(APPSTARTUP_CATEGORY, "PalmSync Support", PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPalmSyncSupport::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
// If nsIAppStartupNotifer tells us the app is starting up, then register
|
||||
// our observer topics and return.
|
||||
if (!strcmp(aTopic, "app-startup"))
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = observerService->AddObserver(this,"profile-after-change", PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = observerService->AddObserver(this, "em-action-requested", PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
}
|
||||
// otherwise, take the appropriate action based on the topic
|
||||
else if (!strcmp(aTopic, "profile-after-change"))
|
||||
{
|
||||
// we can't call installPalmSync in app-startup because the extension manager hasn't been initialized yet.
|
||||
// so we need to wait until the profile-after-change notification has fired.
|
||||
rv = LaunchPalmSyncInstallExe();
|
||||
rv |= InitializePalmSyncSupport();
|
||||
}
|
||||
else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
rv = ShutdownPalmSyncSupport();
|
||||
else if (aSubject && !strcmp(aTopic, "em-action-requested") && !NS_strcmp(aData, NS_LITERAL_STRING("item-uninstalled").get()))
|
||||
{
|
||||
// make sure the subject is our extension.
|
||||
nsCOMPtr<nsIUpdateItem> updateItem (do_QueryInterface(aSubject, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString extensionName;
|
||||
updateItem->GetId(extensionName);
|
||||
|
||||
if (extensionName.EqualsLiteral(EXTENSION_ID))
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// clear the conduit pref so we'll re-run PalmSyncInstall.exe the next time the extension is installed.
|
||||
rv = prefBranch->ClearUserPref(PREF_CONDUIT_REGISTERED);
|
||||
|
||||
nsCOMPtr<nsILocalFile> palmSyncInstall;
|
||||
rv = GetPalmSyncInstall(getter_AddRefs(palmSyncInstall));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString nativePath;
|
||||
palmSyncInstall->GetNativePath(nativePath);
|
||||
|
||||
LONG r = (LONG) ::ShellExecuteA( NULL, NULL, nativePath.get(), "/u", NULL, SW_SHOWNORMAL); // silent uninstall
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsPalmSyncSupport::nsPalmSyncSupport()
|
||||
: m_dwRegister(0),
|
||||
m_nsPalmSyncFactory(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsPalmSyncSupport::~nsPalmSyncSupport()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult nsPalmSyncSupport::GetPalmSyncInstall(nsILocalFile ** aLocalFile)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIExtensionManager> em(do_GetService("@mozilla.org/extensions/manager;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIInstallLocation> installLocation;
|
||||
em->GetInstallLocation(NS_LITERAL_STRING(EXTENSION_ID), getter_AddRefs(installLocation));
|
||||
if (!installLocation)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIFile> palmSyncInstallExe;
|
||||
rv = installLocation->GetItemFile(NS_LITERAL_STRING(EXTENSION_ID), NS_LITERAL_STRING(EXECUTABLE_FILENAME), getter_AddRefs(palmSyncInstallExe));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
palmSyncInstallExe->QueryInterface(NS_GET_IID(nsILocalFile), (void **) aLocalFile);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsPalmSyncSupport::LaunchPalmSyncInstallExe()
|
||||
{
|
||||
// we only want to call PalmSyncInstall.exe the first time the app is run after installing the
|
||||
// palm sync extension. We use PREF_CONDUIT_REGISTERED to keep track of that
|
||||
// information.
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRBool conduitIsRegistered = PR_FALSE;
|
||||
rv = prefBranch->GetBoolPref(PREF_CONDUIT_REGISTERED, &conduitIsRegistered);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (!conduitIsRegistered)
|
||||
{
|
||||
rv = prefBranch->SetBoolPref(PREF_CONDUIT_REGISTERED, PR_TRUE);
|
||||
nsCOMPtr<nsILocalFile> palmSyncInstall;
|
||||
rv = GetPalmSyncInstall(getter_AddRefs(palmSyncInstall));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get our app name.
|
||||
nsCOMPtr<nsIXULAppInfo> appInfo =
|
||||
do_GetService("@mozilla.org/xre/app-info;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString appName;
|
||||
rv = appInfo->GetName(appName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString args(NS_LITERAL_CSTRING("/n"));
|
||||
args.Append(appName);
|
||||
|
||||
// nsILocalFile->Launch doesn't accept arguments so we'll have to
|
||||
// do it ourselves
|
||||
nsString path;
|
||||
rv = palmSyncInstall->GetPath(path);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
LONG r = (LONG)::ShellExecuteW(NULL, NULL, path.get(),
|
||||
NS_ConvertUTF8toUTF16(args).get(),
|
||||
NULL, SW_SHOWNORMAL);
|
||||
|
||||
if (r < 32)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPalmSyncSupport::InitializePalmSyncSupport()
|
||||
{
|
||||
::CoInitialize(nsnull) ;
|
||||
|
||||
if (m_nsPalmSyncFactory == nsnull) // No Registering if already done. Sanity Check!!
|
||||
{
|
||||
m_nsPalmSyncFactory = new CPalmSyncFactory();
|
||||
|
||||
if (m_nsPalmSyncFactory != nsnull)
|
||||
{
|
||||
HRESULT hr = ::CoRegisterClassObject(CLSID_CPalmSyncImp, \
|
||||
m_nsPalmSyncFactory, \
|
||||
CLSCTX_LOCAL_SERVER, \
|
||||
REGCLS_MULTIPLEUSE, \
|
||||
&m_dwRegister);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
m_nsPalmSyncFactory->Release() ;
|
||||
m_nsPalmSyncFactory = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RegisterPalmSync();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPalmSyncSupport::ShutdownPalmSyncSupport()
|
||||
{
|
||||
if (m_dwRegister != 0)
|
||||
::CoRevokeClassObject(m_dwRegister);
|
||||
|
||||
if (m_nsPalmSyncFactory != nsnull)
|
||||
{
|
||||
m_nsPalmSyncFactory->Release();
|
||||
m_nsPalmSyncFactory = nsnull;
|
||||
}
|
||||
|
||||
::CoUninitialize();
|
||||
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPalmSyncSupport::RegisterPalmSync()
|
||||
{
|
||||
return RegisterServerForPalmSync(CLSID_CPalmSyncImp, "Mozilla PalmSync", "MozillaPalmSync", "MozillaPalmSync.1");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPalmSyncSupport::UnRegisterPalmSync()
|
||||
{
|
||||
return UnregisterServerForPalmSync(CLSID_CPalmSyncImp, "MozillaPalmSync", "MozillaPalmSync.1");
|
||||
}
|
||||
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPalmSyncSupport)
|
||||
|
||||
// The list of components we register
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
NS_IPALMSYNCSUPPORT_CLASSNAME,
|
||||
NS_IPALMSYNCSUPPORT_CID,
|
||||
NS_IPALMSYNCSUPPORT_CONTRACTID,
|
||||
nsPalmSyncSupportConstructor,
|
||||
nsPalmSyncRegistrationProc,
|
||||
nsnull
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(PalmSyncModule, components)
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
/* ***** 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
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef MSG_PALMSYNC_SUPPORT_H_
|
||||
#define MSG_PALMSYNC_SUPPORT_H_
|
||||
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIPalmSyncSupport.h"
|
||||
#include "PalmSyncFactory.h"
|
||||
|
||||
class nsILocalFile;
|
||||
|
||||
// {44812571-CE84-11d6-B8A6-00B0D06E5F27}
|
||||
#define NS_IPALMSYNCSUPPORT_CID \
|
||||
{ 0x44812571, 0xce84, 0x11d6, \
|
||||
{ 0xb8, 0xa6, 0x0, 0xb0, 0xd0, 0x6e, 0x5f, 0x27 } }
|
||||
|
||||
|
||||
class nsPalmSyncSupport : public nsIPalmSyncSupport,
|
||||
public nsIObserver
|
||||
{
|
||||
public :
|
||||
nsPalmSyncSupport();
|
||||
~nsPalmSyncSupport();
|
||||
|
||||
// Declare all interface methods we must implement.
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIPALMSYNCSUPPORT
|
||||
|
||||
private :
|
||||
|
||||
DWORD m_dwRegister;
|
||||
CPalmSyncFactory *m_nsPalmSyncFactory;
|
||||
|
||||
nsresult LaunchPalmSyncInstallExe();
|
||||
nsresult GetPalmSyncInstall(nsILocalFile ** aLocalFile);
|
||||
};
|
||||
|
||||
#endif // MSG_PALMSYNC_SUPPORT_H_
|
|
@ -4,7 +4,6 @@ user_pref("browser.dom.window.dump.enabled", true);
|
|||
// no slow script dialogs
|
||||
user_pref("dom.max_chrome_script_run_time", 200);
|
||||
user_pref("dom.max_script_run_time", 0);
|
||||
user_pref("extensions.palmsync.conduitRegistered", true);
|
||||
user_pref("mail.account.account1.server", "server1");
|
||||
user_pref("mail.account.account2.identities", "id1");
|
||||
user_pref("mail.account.account2.server", "server2");
|
||||
|
|
Загрузка…
Ссылка в новой задаче