From 2d04351e68091024791aea3bb4fcc9d9710ece47 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Tue, 24 Jan 2006 00:35:49 +0000 Subject: [PATCH] Bug #322628 --> Palm Sync Build changes to support palm sync as a proper install.rdf based extension for Thunderbid. This extension code is NPOTB. sr=bienvenu a=mscott for thunderbird 2.0. git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@188070 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mail/installer/removed-files.in | 5 + .../mailnews/extensions/palmsync/Makefile.in | 27 +- .../extensions/palmsync/build/Makefile.in | 4 + .../extensions/palmsync/conduit/Makefile.in | 5 + .../mailnews/extensions/palmsync/install.rdf | 27 + .../mailnews/extensions/palmsync/palm.html | 633 ------------------ .../mailnews/extensions/palmsync/palmsync.js | 7 + .../extensions/palmsync/public/Makefile.in | 4 + .../extensions/palmsync/src/Makefile.in | 13 +- .../palmsync/src/nsPalmSyncSupport.cpp | 145 +++- .../palmsync/src/nsPalmSyncSupport.h | 5 + .../wizard/windows/palmsync/BrandName.rc | 4 + .../wizard/windows/palmsync/Makefile.in | 25 + .../windows/palmsync/PalmSyncInstall.cpp | 27 +- .../windows/palmsync/PalmSyncInstall.rc | 2 +- 15 files changed, 251 insertions(+), 682 deletions(-) create mode 100644 mozilla/mailnews/extensions/palmsync/install.rdf delete mode 100644 mozilla/mailnews/extensions/palmsync/palm.html create mode 100644 mozilla/mailnews/extensions/palmsync/palmsync.js diff --git a/mozilla/mail/installer/removed-files.in b/mozilla/mail/installer/removed-files.in index a4d3cd936e4..0aff55e40bd 100644 --- a/mozilla/mail/installer/removed-files.in +++ b/mozilla/mail/installer/removed-files.in @@ -191,3 +191,8 @@ components/talkback/master.ini components/talkback/talkback components/talkback/talkback.so components/talkback/XTalkback.ad +HSAPI.dll +CondMgr.dll +mozABConduit.dll +components/palmsync.dll +components/palmSync.xpt diff --git a/mozilla/mailnews/extensions/palmsync/Makefile.in b/mozilla/mailnews/extensions/palmsync/Makefile.in index 650582a10ff..409ab78b6b4 100644 --- a/mozilla/mailnews/extensions/palmsync/Makefile.in +++ b/mozilla/mailnews/extensions/palmsync/Makefile.in @@ -44,18 +44,35 @@ README = palm.html include $(DEPTH)/config/autoconf.mk +MODULE = palmsync + DIRS = build public src +ifdef MOZ_XUL_APP +XPI_NAME = palmsync +USE_EXTENSION_MANIFEST = 1 +NO_JAR_AUTO_REG = 1 +INSTALL_EXTENSION_ID = palmsync@mozilla.org +XPI_PKGNAME = palmsync-$(MOZ_APP_VERSION) +endif + +PREF_JS_EXPORTS = palmsync.js +DIST_FILES = install.rdf + +# We should really pull THUNDERBIRD_VERSION from +# mail/config/version.txt but we can't be assured +# that we've even pulled that file. So we hardcode them. + +XULAPP_DEFINES = \ + -DTHUNDERBIRD_VERSION=$(THUNDERBIRD_VERSION) \ + -DEXTENSION_VERSION=$(MOZILLA_VERSION) \ + $(NULL) + ifdef PALM_CDK_DIR DIRS += conduit PACKAGE_FILE = palmsync.pkg -install:: $(README) - $(INSTALL) $< $(DIST)/bin - -GARBAGE += $(DIST)/bin/$(README) - else libs:: @echo " " diff --git a/mozilla/mailnews/extensions/palmsync/build/Makefile.in b/mozilla/mailnews/extensions/palmsync/build/Makefile.in index a01972c1b02..6c7c2b1a32d 100644 --- a/mozilla/mailnews/extensions/palmsync/build/Makefile.in +++ b/mozilla/mailnews/extensions/palmsync/build/Makefile.in @@ -47,6 +47,10 @@ LIBRARY_NAME = $(MODULE) DEFFILE = $(win_srcdir)/PalmSyncProxy.def MOZILLA_INTERNAL_API = 1 +ifdef MOZ_XUL_APP +XPI_NAME = palmsync +endif + EXPORTS = IPalmSync.h CSRCS = \ diff --git a/mozilla/mailnews/extensions/palmsync/conduit/Makefile.in b/mozilla/mailnews/extensions/palmsync/conduit/Makefile.in index 7e3c36e7e07..277ec93702d 100644 --- a/mozilla/mailnews/extensions/palmsync/conduit/Makefile.in +++ b/mozilla/mailnews/extensions/palmsync/conduit/Makefile.in @@ -44,6 +44,7 @@ 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 @@ -52,6 +53,10 @@ EXPORT_LIBRARY = $(MODULE) LIBRARY_NAME = $(MODULE) RESFILE = MozABConduitGenCond.res +ifdef MOZ_XUL_APP +XPI_NAME = palmsync +endif + REQUIRES = PalmSyncProxy \ $(NULL) diff --git a/mozilla/mailnews/extensions/palmsync/install.rdf b/mozilla/mailnews/extensions/palmsync/install.rdf new file mode 100644 index 00000000000..76a5f5118b0 --- /dev/null +++ b/mozilla/mailnews/extensions/palmsync/install.rdf @@ -0,0 +1,27 @@ + + +#filter substitution + + + + + p@m + @EXTENSION_VERSION@ + + + + + {3550f703-e582-4d05-9a08-453d09bdfdc6} + @THUNDERBIRD_VERSION@ + @THUNDERBIRD_VERSION@ + + + + Palm Sync + Palm address book synchronization. + Team Thunderbird + http://www.mozilla.org/projects/thunderbird/palmsync/ + + diff --git a/mozilla/mailnews/extensions/palmsync/palm.html b/mozilla/mailnews/extensions/palmsync/palm.html deleted file mode 100644 index 50d4287535d..00000000000 --- a/mozilla/mailnews/extensions/palmsync/palm.html +++ /dev/null @@ -1,633 +0,0 @@ - - Netscape Address Book Sync for Palm Devices - - -
-
-

Mozilla Address Book Sync for PalmTM -Devices

-
-
-
- Mozilla Address Book Sync for PalmTM devices lets you -transfer data between Mozilla address books and your Palm-compatible -device.
-
-Note: For information on HotSync
® setup, consult -your Palm device's documentation.
-
-
Getting Started
-
Requirements
-Using Mozilla Address Book Palm Sync
-Synchronizing -With Your Palm Device
-Uninstalling Mozilla Address Book Sync
-
-
-Troubleshooting
-
HotSync Problems
-Record -Problems
-
-
-
Field Mapping
-
-
Categories and Address Books
-
-
-
-

-
-

Getting Started

-When you are -ready to begin transferring data between your Mozilla address book and -your Palm device, follow the instructions under Using Mozilla Address Book Palm Sync.
-
-

-

Requirements

- - -

Using Mozilla Address Book Palm Sync

-Before using Mozilla Address -Book Palm Sync, make sure your Palm device contains the latest address -book data. If you have -updated or entered new address book data in your Palm Desktop -software, you should first perform a HotSync to update your Palm -device's address books with the latest data. This will insure that your -latest Palm address book data will be synchronized with your Mozilla -address books.
-
-The Mozilla Address Book Palm Sync installer utility lets your Palm -device synchronize directly with your Mozilla address books by -replacing the Palm Desktop Address Book Sync with Mozilla Address Book -Sync.
-
-To start using Mozilla Address Book Palm Sync:
-
-
    -
  1. Start Mozilla Address -Book Palm Sync:
    -
  2. -
      -
    1. Open the Windows -Start menu.
    2. -
    3. Choose Programs.
    4. -
    5. From the Programs -menu, choose Mozilla.
      -
    6. -
    7. From the Mozilla -menu, choose Palm Tools.
    8. -
    9. From the Palm Tools -menu, choose Address Book Palm Sync Install.
    10. -
    -
-
Note: If Mozilla is -already running, it uses the address books in the current user profile -for synchronization. If Mozilla is not running, it starts and displays -the Profile Manager (if you have more than one profile) so that you can -choose the profile to use for synchronization.
-
-
    -
  1. Press the -HotSync button on your Palm device to start synchronizing.
  2. -
-Note: To install Mozilla Address Book Palm -Sync from the command line, change to the directory where you installed Mozilla and enter the command PalmSyncInstall.exe.
-
-

Synchronizing With Your Palm Device

-After you synchronize with -your Palm device, your Palm address book will contain all the records in -your Mozilla address books. Each Mozilla address book is listed as a -category in your Palm address book. Your Mozilla address book will -contain a new address book for each category in your Palm address book. -For more information, see Field Mapping.
-
-
Synchronizing With -Another Mozilla User Profile
-To synchronize your Palm -device with a different Mozilla user profile, you must first quit -Mozilla. Start Mozilla again, and choose the user profile you want to -synchronize with.  Press the HotSync button on your Palm device to -synchronize.
-
-Synchronizing With Another Program
-If you want to synchronize with another program, you must first uninstall Mozilla Address Book Palm Sync.
-
-Verifying that Netcape Address Book -Palm Sync Is Installed
-
To verify that you -have established a HotSync connection with Mozilla, right-click the -HotSync Manager icon in the system tray, and choose Custom. The Custom -dialog box should display "Mozilla Address Book" in the Conduit list.
-

Synchronization -Guidelines

-Maximum number of -address books
-
A maximum of 15 -address books can be synchronized.
-
- -Mozilla address -book fields
-Mozilla address book fields, with the exception of the Notes and -Address fields, cannot contain multiple lines. When you synchronize, -field values in your Palm address book will be converted to single line -entries in your Mozilla address book, with each line separated by a -comma.

-
-
-Palm Categories and Mozilla Address -Books
-On your Palm device, address records are stored in categories. In -Mozilla, address records are stored in address books. Mozilla Address -Book Sync matches Palm categories and Mozilla address books. After a -successful synchronization, each Palm device category will have a -corresponding Mozilla address book.
-
Palm category names are limited to 15 characters, so if you have a -Mozilla address book name that is longer than 15 characters, its -corresponding category name will be truncated on the Palm device.
-

-

Uninstalling Mozilla Address Book Palm Sync

-You only need to -uninstall Mozilla Address Book Palm Sync if you want to synchronize -your Palm Device with a different program. If you only plan to -synchronize with Mozilla, you don't need to uninstall Address Book Palm -Sync.
-
-Note: Before -uninstalling Mozilla Address Book Palm Sync, make sure your Palm device -contains the latest address book data. If you have updated or entered new -address book data in your Mozilla address book, you should perform -another HotSync to update your Palm device's address books with the -latest data. This will insure that your Palm address book contains the -latest data from your Mozilla address books before you uninstall Mozilla Address Book Palm Sync.
-
-To uninstall Mozilla Address -Book Palm Sync:
-
-
    -
  1. Start the Mozilla -Address Book Palm Sync uninstaller:
    -
  2. -
      -
    1. Open the Windows -Start menu.
    2. -
    3. Choose Programs.
    4. -
    5. From the Programs -menu, choose Mozilla.
      -
    6. -
    7. From the Mozilla -menu, choose Palm Tools.
    8. -
    9. From the Palm Tools -menu, choose Address Book Palm Sync Uninstall.
    10. -
    -
-Note: To uninstall Mozilla Address Book Palm -Sync from the command line, change to the directory where you installed Mozilla and enter the command PalmSyncInstall.exe -/u.
-
-You have successfully uninstalled Mozilla Address Book Palm Sync. The
Palm Desktop Address Book Sync is -now enabled. You can synchronize your Palm device with your Mozilla -address book again at any time by following the instructions under Installing Mozilla Address Book Palm Sync.
-
-

-
-

Troubleshooting

-

-

HotSync -Problems

-Problem:I cannot get my Palm -organizer to HotSync with my Mozilla address book.
-

-Possible Solutions:
-
- -Problem: The HotSync Manager -keeps timing out.
-
-Possible -Solution:
- -Problem: The HotSync process -takes a long time.
-
-Possible -Solutions: You can reduce the -time it takes to synchronize by doing the following:
- -

Record -Problems

-Problem: Some Mozilla records -do not appear in the Palm device after synchronizing.
-
-
Possible -Solution:
-
- -Problem: Some records appear -duplicated.
-
-
Possible -Solution:
-
- -Problem: Changes I made to a -record on my Palm device were not transferred to my Mozilla address -book.
-
-Possible -Solution:
-
- -Problem: Some Palm device -fields appear in a different order after synchronizing.
-
-Possible -Solution:
-
-On the Palm device, there are five phone fields. When you synchronize, -the order of these fields is reset according to the current field -mapping.
-
-
Problem: Fields that contain -multiple lines get changed when I synchronize.
-
-
Possible -Solution:
-
- -
-
-

-
-

Field -Mapping

-
This -section describes the conversions that occur when transferring data -between Mozilla address book(s) and your Palm device's address book. -Apart from the special conversion rules that apply to specific fields, -some general rules apply:
- -
Categories and Address Books
-
-
-
The -following table describes what happens to categories and address books -during synchronization.
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
Mozilla Address Book action
-
-
Palm category action
-
-
Synchronization
-
-
New address book created
-
-
n/a
-
-
New Palm category created if there is an -available category.  The Palm device can only contain 15 -categories.  If the maximum has been reached then this address book -will not be synchronized.
-
-
Address book deleted
-
-
Category not changed, or 
-category deleted
-
-
All of the records from this address book -will be deleted and if the category still exists it will be deleted as -well.
-
Address book renamed
-
n/a
-
All -of the records from this address book remain in the same category. The -category is not renamed on the Palm device. However, after syncing, the -Mozilla address book will be renamed to match the category name on the -Palm device. Therefore, to rename a Mozilla address book, rename it on -the Palm device and then sync.
-
-
n/a
-
-
New category created
-
-
A new address book with the same name as -the category will be created in Mozilla.  All new records filed in -the category will be created in the new address book.
-
-
n/a
-
-
Category deleted
-
-
Records go to the Unfiled Mozilla address -book.
-
n/aCategory renamedThe category will be renamed to -match the address book it corresponds to. To rename a Mozilla address book, rename it on the Palm device and then sync.
-
n/a
-
Records in "Unfiled" category
-
Records appear in the Unfiled Mozilla address book.
-
-

Fields

-
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
Mozilla field
-
-
Palm field
-
-
Notes
-
-
First name
-
-
First name
-
-
 
-
-
Last name
-
-
Last name
-
-
 
-
-
Display name
-
-
 
-
-
There is no Palm field for Display -name.  The Palm can be configured to list records by Last name, -First name or Company, Last name 
-
-
Email Address
-
-
E-mail
-
-
 
-
-
Nickname
-
-
 
-
-
Not synchronized
-
-
Title
-
-
Title
-
-
 
-
-
Organization
-
-
Company
-
-
 
-
Department
-
There is no corresponding Palm field for Department. 
NotesNoteMultiple lines are allowed in this field.
AddressAddressMultiple lines are allowed in this field.
CityCity
-
StateState
-
ZipZip Code
-
CountryCountry
-
Work phoneWork
-
Home phoneHome
-
FaxFax
-
Pager
-
Only 5 phone fields are available on the Palm.  Work, -Home, Fax, Email, and Mobile are synchronized.
CellularMobile
-
Prefers to receive rich text (HTML) mail
-
Not synchronized.
-
-
-
12 May 2003
-
-Copyright©  1994-2003 The Mozilla Organization.
-
-
-
-
- \ No newline at end of file diff --git a/mozilla/mailnews/extensions/palmsync/palmsync.js b/mozilla/mailnews/extensions/palmsync/palmsync.js new file mode 100644 index 00000000000..4c5366c3e5e --- /dev/null +++ b/mozilla/mailnews/extensions/palmsync/palmsync.js @@ -0,0 +1,7 @@ +/* + 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); diff --git a/mozilla/mailnews/extensions/palmsync/public/Makefile.in b/mozilla/mailnews/extensions/palmsync/public/Makefile.in index 3541ce62430..89190010596 100644 --- a/mozilla/mailnews/extensions/palmsync/public/Makefile.in +++ b/mozilla/mailnews/extensions/palmsync/public/Makefile.in @@ -45,6 +45,10 @@ include $(DEPTH)/config/autoconf.mk MODULE = palmSync XPIDL_MODULE = palmSync +ifdef MOZ_XUL_APP +XPI_NAME = palmsync +endif + XPIDLSRCS = \ nsIPalmSyncSupport.idl \ $(NULL) diff --git a/mozilla/mailnews/extensions/palmsync/src/Makefile.in b/mozilla/mailnews/extensions/palmsync/src/Makefile.in index 54de88e7315..ef91a5dfac6 100644 --- a/mozilla/mailnews/extensions/palmsync/src/Makefile.in +++ b/mozilla/mailnews/extensions/palmsync/src/Makefile.in @@ -44,12 +44,16 @@ include $(DEPTH)/config/autoconf.mk MODULE = palmsync LIBRARY_NAME = $(MODULE) -EXPORT_LIBRARY = 1 +# Do not set EXPORT_LIBRARY as we do not want palmsync in the static libs list IS_COMPONENT = 1 -MODULE_NAME = PalmSyncModule -META_COMPONENT = mail +FORCE_SHARED_LIB = 1 + MOZILLA_INTERNAL_API = 1 +ifdef MOZ_XUL_APP +XPI_NAME = palmsync +endif + REQUIRES = xpcom \ xpcom_obsolete \ PalmSyncProxy \ @@ -67,6 +71,7 @@ REQUIRES = xpcom \ msgbaseutil \ necko \ addrbook \ + extensions \ $(NULL) CPPSRCS = \ @@ -106,7 +111,7 @@ EXTRA_DSO_LDOPTS= \ $(NSPR_LIBS) \ $(NULL) -OS_LIBS += ole32.lib +OS_LIBS += ole32.lib shell32.lib include $(topsrcdir)/config/rules.mk diff --git a/mozilla/mailnews/extensions/palmsync/src/nsPalmSyncSupport.cpp b/mozilla/mailnews/extensions/palmsync/src/nsPalmSyncSupport.cpp index 95a324be525..ebcf8744967 100644 --- a/mozilla/mailnews/extensions/palmsync/src/nsPalmSyncSupport.cpp +++ b/mozilla/mailnews/extensions/palmsync/src/nsPalmSyncSupport.cpp @@ -45,10 +45,21 @@ #include "nsIComponentManager.h" #include "nsICategoryManager.h" #include "nsCRT.h" +#include "nsIExtensionManager.h" +#include "nsIFile.h" +#include "nsILocalFile.h" +#include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "PalmSyncImp.h" #include "nsPalmSyncSupport.h" #include "Registry.h" +#include // 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. @@ -63,17 +74,24 @@ 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; +{ + nsresult rv; + nsCOMPtr 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 ; +} - nsCOMPtr 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); +static NS_METHOD nsPalmSyncUnRegistrationProc(nsIComponentManager *aCompMgr, + nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info) +{ + nsresult rv; + nsCOMPtr categoryManager(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); + if (NS_SUCCEEDED(rv)) + rv = categoryManager->DeleteCategoryEntry(APPSTARTUP_CATEGORY, "PalmSync Support", PR_TRUE); - return rv ; - + return rv; } NS_IMETHODIMP @@ -81,22 +99,62 @@ nsPalmSyncSupport::Observe(nsISupports *aSubject, const char *aTopic, const PRUn { nsresult rv = NS_OK ; - if (!strcmp(aTopic, "profile-after-change")) - return InitializePalmSyncSupport(); - - if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) - return ShutdownPalmSyncSupport(); - - nsCOMPtr observerService(do_GetService("@mozilla.org/observer-service;1", &rv)); - if (NS_FAILED(rv)) return rv; + // If nsIAppStartupNotifer tells us the app is starting up, then register + // our observer topics and return. + if (!strcmp(aTopic, "app-startup")) + { + nsCOMPtr observerService(do_GetService("@mozilla.org/observer-service;1", &rv)); + NS_ENSURE_SUCCESS(rv, rv); - rv = observerService->AddObserver(this,"profile-after-change", PR_FALSE); - if (NS_FAILED(rv)) return rv; + rv = observerService->AddObserver(this,"profile-after-change", PR_FALSE); + NS_ENSURE_SUCCESS(rv, rv); - return observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); + 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") && !nsCRT::strcmp(aData, NS_LITERAL_STRING("item-uninstalled").get())) + { + // make sure the subject is our extension. + nsCOMPtr updateItem (do_QueryInterface(aSubject, &rv)); + NS_ENSURE_SUCCESS(rv, rv); + + nsAutoString extensionName; + updateItem->GetId(extensionName); + + if (extensionName.EqualsLiteral(EXTENSION_ID)) + { + nsCOMPtr 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 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) @@ -107,6 +165,51 @@ nsPalmSyncSupport::~nsPalmSyncSupport() { } +nsresult nsPalmSyncSupport::GetPalmSyncInstall(nsILocalFile ** aLocalFile) +{ + nsresult rv; + nsCOMPtr em(do_GetService("@mozilla.org/extensions/manager;1")); + NS_ENSURE_TRUE(em, NS_ERROR_FAILURE); + + nsCOMPtr installLocation; + rv = em->GetInstallLocation(NS_LITERAL_STRING(EXTENSION_ID), getter_AddRefs(installLocation)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr 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 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 palmSyncInstall; + rv = GetPalmSyncInstall(getter_AddRefs(palmSyncInstall)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = palmSyncInstall->Launch(); + } + + return rv; +} + NS_IMETHODIMP nsPalmSyncSupport::InitializePalmSyncSupport() { diff --git a/mozilla/mailnews/extensions/palmsync/src/nsPalmSyncSupport.h b/mozilla/mailnews/extensions/palmsync/src/nsPalmSyncSupport.h index fc6f995e758..f22af4f6341 100644 --- a/mozilla/mailnews/extensions/palmsync/src/nsPalmSyncSupport.h +++ b/mozilla/mailnews/extensions/palmsync/src/nsPalmSyncSupport.h @@ -42,6 +42,8 @@ #include "nsIPalmSyncSupport.h" #include "PalmSyncFactory.h" +class nsILocalFile; + // {44812571-CE84-11d6-B8A6-00B0D06E5F27} #define NS_IPALMSYNCSUPPORT_CID \ { 0x44812571, 0xce84, 0x11d6, \ @@ -64,6 +66,9 @@ class nsPalmSyncSupport : public nsIPalmSyncSupport, DWORD m_dwRegister; CPalmSyncFactory *m_nsPalmSyncFactory; + + nsresult LaunchPalmSyncInstallExe(); + nsresult GetPalmSyncInstall(nsILocalFile ** aLocalFile); }; #endif // MSG_PALMSYNC_SUPPORT_H_ diff --git a/mozilla/xpinstall/wizard/windows/palmsync/BrandName.rc b/mozilla/xpinstall/wizard/windows/palmsync/BrandName.rc index 99e2aed214c..a75e217ad14 100644 --- a/mozilla/xpinstall/wizard/windows/palmsync/BrandName.rc +++ b/mozilla/xpinstall/wizard/windows/palmsync/BrandName.rc @@ -1,4 +1,8 @@ STRINGTABLE DISCARDABLE BEGIN +#ifdef MOZ_THUNDERBIRD + IDS_BRAND_NAME "Thunderbird" +#else IDS_BRAND_NAME "Mozilla" +#endif END diff --git a/mozilla/xpinstall/wizard/windows/palmsync/Makefile.in b/mozilla/xpinstall/wizard/windows/palmsync/Makefile.in index aa6e4eaae82..bf0c1ca72ef 100644 --- a/mozilla/xpinstall/wizard/windows/palmsync/Makefile.in +++ b/mozilla/xpinstall/wizard/windows/palmsync/Makefile.in @@ -53,10 +53,34 @@ LOCAL_INCLUDES += -I$(PALM_CDK_INC) \ CPPSRCS = PalmSyncInstall.cpp +ifdef MOZ_XUL_APP +XPI_NAME = palmsync +USE_EXTENSION_MANIFEST = 1 +NO_JAR_AUTO_REG = 1 +INSTALL_EXTENSION_ID = palmsync@mozilla.org +XPI_PKGNAME = palmsync-$(MOZ_APP_VERSION) + +# We should really pull THUNDERBIRD_VERSION from +# mail/config/version.txt but we can't be assured +# that we've even pulled that file. So we hardcode them. + +XULAPP_DEFINES = \ + -DTHUNDERBIRD_VERSION=$(THUNDERBIRD_VERSION) \ + -DEXTENSION_VERSION=$(MOZILLA_VERSION) \ + $(NULL) + +#ifdef MOZ_THUNDERBIRD +RCFLAGS += -DMOZ_THUNDERBIRD +#endif + +endif + + include $(topsrcdir)/config/rules.mk LDFLAGS += /SUBSYSTEM:WINDOWS /MACHINE:i386 +ifndef MOZ_XUL_APP libs:: $(PROGRAM) $(INSTALL) $(PROGRAM) $(DIST)/install @@ -65,3 +89,4 @@ install:: $(PROGRAM) clean clobber clobber_all realclean:: $(RM) $(DIST)/install/$(PROGRAM) +endif diff --git a/mozilla/xpinstall/wizard/windows/palmsync/PalmSyncInstall.cpp b/mozilla/xpinstall/wizard/windows/palmsync/PalmSyncInstall.cpp index 0edddf7f190..5a4c2e1ce8c 100644 --- a/mozilla/xpinstall/wizard/windows/palmsync/PalmSyncInstall.cpp +++ b/mozilla/xpinstall/wizard/windows/palmsync/PalmSyncInstall.cpp @@ -253,7 +253,7 @@ int LoadConduitManagerDll(HINSTANCE* hCondMgrDll, const TCHAR * szPalmDesktopDir // 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 0; return IDS_ERR_LOADING_CONDMGR; } @@ -486,7 +486,7 @@ int InstallConduit(HINSTANCE hInstance, TCHAR *installDir) // Load the Conduit Manager DLL. HINSTANCE hConduitManagerDLL; - if( (dwReturnCode=GetPalmDesktopInstallDirectory(szPalmDesktopDir, &desktopSize)) == 0 ) + 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 @@ -495,13 +495,10 @@ int InstallConduit(HINSTANCE hInstance, TCHAR *installDir) SetCurrentDirectory(szPalmDesktopDir); if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL, szPalmDesktopDir)) != 0 ) - // load it from local dir if present by any chance - if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL, ".")) != 0 ) - return(dwReturnCode); + return dwReturnCode; } - else // if registery key not load it from local dir if present by any chance - if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL, ".")) != 0 ) - return(dwReturnCode); + else + return IDS_ERR_CONDUIT_NOT_FOUND; // Prepare to install the conduit using Conduit Manager functions CmInstallCreatorPtr lpfnCmInstallCreator; @@ -574,9 +571,7 @@ int InstallConduit(HINSTANCE hInstance, TCHAR *installDir) // Load the HSAPI DLL. HINSTANCE hHsapiDLL; if( (dwReturnCode = LoadHsapiDll(&hHsapiDLL, szPalmDesktopDir)) != 0 ) - // load it from local dir if present by any chance - if( (dwReturnCode = LoadHsapiDll(&hHsapiDLL, ".")) != 0 ) - return(dwReturnCode); + return dwReturnCode; // Shutdown the HotSync Process if it is running if( (bHotSyncRunning=IsHotSyncRunning(hHsapiDLL)) ) @@ -645,13 +640,11 @@ int UninstallConduit() if( (dwReturnCode=GetPalmDesktopInstallDirectory(szPalmDesktopDir, &desktopSize)) == 0 ) { if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL, szPalmDesktopDir)) != 0 ) - // load it from local dir if present by any chance - if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL, ".")) != 0 ) return(dwReturnCode); } // if registery key not load it from local dir if present by any chance - else if( (dwReturnCode = LoadConduitManagerDll(&hConduitManagerDLL, ".")) != 0 ) - return(dwReturnCode); + else + return(dwReturnCode); // need to switch current working directory to directory with palm dlls // because of a bug in Palm Desktop 6.01 @@ -664,7 +657,7 @@ int UninstallConduit() lpfnCmRemoveConduitByCreatorID = (CmRemoveConduitByCreatorIDPtr) GetProcAddress(hConduitManagerDLL, "CmRemoveConduitByCreatorID"); if( (lpfnCmRemoveConduitByCreatorID == NULL) ) return(IDS_ERR_LOADING_CONDMGR); - CmSetCorePathPtr lpfnCmSetCorePath = (CmSetCorePathPtr) GetProcAddress(hConduitManagerDLL, "CmSetCorePath"); + CmSetCorePathPtr lpfnCmSetCorePath = (CmSetCorePathPtr) GetProcAddress(hConduitManagerDLL, "CmSetCorePath"); CmSetHotSyncExePathPtr lpfnCmSetHotSyncExePath = (CmSetHotSyncExePathPtr) GetProcAddress(hConduitManagerDLL, "CmSetHotSyncExecPath"); CmRestoreHotSyncSettingsPtr lpfnCmRestoreHotSyncSettings; lpfnCmRestoreHotSyncSettings = (CmRestoreHotSyncSettingsPtr) GetProcAddress(hConduitManagerDLL, "CmRestoreHotSyncSettings"); @@ -689,8 +682,6 @@ int UninstallConduit() // Load the HSAPI DLL. HINSTANCE hHsapiDLL; if( (dwReturnCode = LoadHsapiDll(&hHsapiDLL, szPalmDesktopDir)) != 0 ) - // load it from local dir if present by any chance - if( (dwReturnCode = LoadHsapiDll(&hHsapiDLL, ".")) != 0 ) return(dwReturnCode); // Shutdown the HotSync Process if it is running diff --git a/mozilla/xpinstall/wizard/windows/palmsync/PalmSyncInstall.rc b/mozilla/xpinstall/wizard/windows/palmsync/PalmSyncInstall.rc index c3c4d3b2e67..4e0cfe23375 100644 --- a/mozilla/xpinstall/wizard/windows/palmsync/PalmSyncInstall.rc +++ b/mozilla/xpinstall/wizard/windows/palmsync/PalmSyncInstall.rc @@ -94,7 +94,7 @@ BEGIN "Could not find the directory to install the %s Address Book Palm Sync Conduit." IDS_SUCCESS_INSTALL "%s Address Book Palm Sync was successfully installed. Using your Palm device, perform a HotSync operation to synchronize your Palm device's address book with your %s address book." IDS_SUCCESS_UNINSTALL "%s Address Book Palm Sync was successfully uninstalled. Palm Desktop synchronization with your Palm device is now restored." - IDS_CONFIRM_INSTALL "You are about to synchronize your %s address book with your Palm device's address book. This will replace Palm Desktop synchronization with %s address book synchronization. Do you want to continue?" + IDS_CONFIRM_INSTALL "You are about to add the %s Address 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 %s Address Book Palm Sync. This will restore Palm Desktop synchronization. Do you want to continue?" IDS_ERR_REGISTERING_MOZ_DLL "Failed to register the %s's Palm Sync Support Proxy Dll while installing the %s Address Book Palm Sync Conduit."