diff --git a/mozilla/browser/app/Makefile.in b/mozilla/browser/app/Makefile.in index ab85e26e265..60d1cd30387 100644 --- a/mozilla/browser/app/Makefile.in +++ b/mozilla/browser/app/Makefile.in @@ -67,7 +67,7 @@ ifdef BUILD_STATIC_LIBS STATIC_COMPONENTS_LINKER_PATH = -L$(DIST)/lib/components endif -ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) +ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) TK_LIBS := -framework Cocoa $(TK_LIBS) endif @@ -98,6 +98,8 @@ MOZ_WINCONSOLE = 0 endif endif +NSDISTMODE = copy + include $(topsrcdir)/config/config.mk ifndef BUILD_STATIC_LIBS @@ -163,6 +165,9 @@ endif APP_VERSION = $(shell cat $(srcdir)/../config/version.txt) DEFINES += -DAPP_VERSION=\"$(APP_VERSION)\" +BUILD_ID = $(shell cat $(DEPTH)/config/build_number) +DEFINES += -DBUILD_ID=\"$(BUILD_ID)\" + ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) ifdef BUILD_STATIC_LIBS LIBS += -framework QuickTime -framework IOKit diff --git a/mozilla/browser/app/nsBrowserApp.cpp b/mozilla/browser/app/nsBrowserApp.cpp index 1ca00f09012..d6b1b3c5fa6 100644 --- a/mozilla/browser/app/nsBrowserApp.cpp +++ b/mozilla/browser/app/nsBrowserApp.cpp @@ -39,22 +39,25 @@ #include "nsXULAppAPI.h" #ifdef XP_WIN #include +#include #endif +#include "nsBuildID.h" + +static const nsXREAppData kAppData = { + "Mozilla", + "Firefox", + APP_VERSION, + BUILD_ID, + "Copyright (c) 2004 mozilla.org", + PR_FALSE +}; + int main(int argc, char* argv[]) { - nsXREAppData appData; - appData.SetSplashEnabled(PR_FALSE); - appData.SetProductName(NS_LITERAL_CSTRING("Firefox")); - appData.SetUseStartupPrefs(PR_FALSE); - - return xre_main(argc, argv, appData); + return xre_main(argc, argv, &kAppData); } -#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2) -char* splash_xpm[] = {0}; -#endif - #if defined( XP_WIN ) && defined( WIN32 ) && !defined(__GNUC__) // We need WinMain in order to not be a console app. This function is // unused if we are a console application. diff --git a/mozilla/browser/app/profile/extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/install.rdf b/mozilla/browser/app/profile/extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/install.rdf index e39982d7c68..bbd368e7d2f 100644 --- a/mozilla/browser/app/profile/extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/install.rdf +++ b/mozilla/browser/app/profile/extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/install.rdf @@ -9,7 +9,13 @@ - {ec8030f7-c20a-464f-9b0e-13a3a9e97384},0.7,1.2 + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 0.8 + 0.9 + + DOM Inspector diff --git a/mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/Makefile.in b/mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/Makefile.in index d740333a1d0..c6b2bba5697 100644 --- a/mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/Makefile.in +++ b/mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/Makefile.in @@ -26,9 +26,8 @@ FILES := \ install.rdf \ $(NULL) -FILES := $(addprefix $(srcdir)/, $(FILES)) - libs:: + $(PERL) $(MOZILLA_DIR)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) $(srcdir)/install.rdf.in > install.rdf $(INSTALL) $(FILES) $(DIST)/bin/defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd} install:: diff --git a/mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf b/mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf.in similarity index 74% rename from mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf rename to mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf.in index 406e5364ed9..4019e89fef5 100644 --- a/mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf +++ b/mozilla/browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf.in @@ -9,7 +9,13 @@ - {ec8030f7-c20a-464f-9b0e-13a3a9e97384},0.8+,0.9 + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 0.8 + 0.9 + + Firefox (default) @@ -19,7 +25,7 @@ - Arvid Axelsson + Gerich and Horlander Mozilla Contributors classic/1.0 diff --git a/mozilla/browser/app/profile/firefox.js b/mozilla/browser/app/profile/firefox.js index cf2d62565b8..e099ba36301 100644 --- a/mozilla/browser/app/profile/firefox.js +++ b/mozilla/browser/app/profile/firefox.js @@ -54,9 +54,13 @@ pref("app.id", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"); pref("app.version", #expand __APP_VERSION__ ); +pref("app.build_id", +#expand __BUILD_ID__ +); pref("update.app.enabled", true); pref("update.app.url", "chrome://mozapps/locale/update/update.properties"); +pref("update.app.updatesAvailable", false); pref("update.app.updateVersion", ""); pref("update.app.updateDescription", ""); pref("update.app.updateURL", ""); diff --git a/mozilla/browser/components/build/Makefile.in b/mozilla/browser/components/build/Makefile.in index a9e7a11ff62..f32d1546594 100644 --- a/mozilla/browser/components/build/Makefile.in +++ b/mozilla/browser/components/build/Makefile.in @@ -17,8 +17,6 @@ REQUIRES = \ string \ autocomplete \ mork \ - profile \ - profilemanager \ pref \ rdf \ intl \ @@ -30,6 +28,7 @@ REQUIRES = \ bookmarks \ migration \ shellservice \ + xulapp \ $(NULL) EXPORTS = nsBrowserCompsCID.h diff --git a/mozilla/browser/components/build/nsModule.cpp b/mozilla/browser/components/build/nsModule.cpp index 8bb052c22e1..400d59cfed4 100644 --- a/mozilla/browser/components/build/nsModule.cpp +++ b/mozilla/browser/components/build/nsModule.cpp @@ -125,7 +125,7 @@ static const nsModuleComponentInfo components[] = nsBookmarksServiceConstructor }, { "Profile Migrator", - NS_PROFILEMIGRATOR_CID, + NS_FIREFOX_PROFILEMIGRATOR_CID, NS_PROFILEMIGRATOR_CONTRACTID, nsProfileMigratorConstructor }, diff --git a/mozilla/browser/components/migration/content/migration.js b/mozilla/browser/components/migration/content/migration.js index 72e7a25ee37..17960bb610f 100644 --- a/mozilla/browser/components/migration/content/migration.js +++ b/mozilla/browser/components/migration/content/migration.js @@ -1,4 +1,5 @@ const kIMig = Components.interfaces.nsIBrowserProfileMigrator; +const kIPStartup = Components.interfaces.nsIProfileStartup; const kProfileMigratorContractIDPrefix = "@mozilla.org/profile/migrator;1?app=browser&type="; var MigrationWizard = { @@ -7,7 +8,7 @@ var MigrationWizard = { _selectedProfile: null, // Selected Profile name to import from _wiz: null, _migrator: null, - _autoMigrate: false, + _autoMigrate: null, init: function () { @@ -22,7 +23,7 @@ var MigrationWizard = { if ("arguments" in window) { this._source = window.arguments[0]; this._migrator = window.arguments[1].QueryInterface(kIMig); - this._autoMigrate = true; + this._autoMigrate = window.arguments[2].QueryInterface(kIPStartup); // Show the "nothing" option in the automigrate case to provide an // easily identifiable way to avoid migration and create a new profile. diff --git a/mozilla/browser/components/migration/public/nsIBrowserProfileMigrator.idl b/mozilla/browser/components/migration/public/nsIBrowserProfileMigrator.idl index c00c46fcd5d..578ead9c058 100644 --- a/mozilla/browser/components/migration/public/nsIBrowserProfileMigrator.idl +++ b/mozilla/browser/components/migration/public/nsIBrowserProfileMigrator.idl @@ -37,6 +37,7 @@ #include "nsISupports.idl" interface nsISupportsArray; +interface nsIProfileStartup; [scriptable, uuid(6c64bc4a-881f-4fd8-8f19-3b4125dcee50)] interface nsIBrowserProfileMigrator : nsISupports @@ -59,18 +60,17 @@ interface nsIBrowserProfileMigrator : nsISupports * @param aReplace replace or append current data where applicable. * @param aProfile profile to migrate from, if there is more than one. */ - void migrate(in unsigned short aItems, in boolean aReplace, in wstring aProfile); + void migrate(in unsigned short aItems, in nsIProfileStartup aStartup, in wstring aProfile); /** * A bit field containing profile items that this migrator * offers for import. * @param aProfile the profile that we are looking for available data * to import - * @param aReplace whether or not the profile is being run replace-current - * data mode (automigration, before profile has started) + * @param aStarting "true" if the profile is not currently being used. * @returns bit field containing profile items (see above) */ - unsigned short getMigrateData(in wstring aProfile, in boolean aReplace); + unsigned short getMigrateData(in wstring aProfile, in boolean aDoingStartup); /** * Whether or not there is any data that can be imported from this diff --git a/mozilla/browser/components/migration/src/Makefile.in b/mozilla/browser/components/migration/src/Makefile.in index 29b0e2367bf..dec8044357b 100644 --- a/mozilla/browser/components/migration/src/Makefile.in +++ b/mozilla/browser/components/migration/src/Makefile.in @@ -50,10 +50,9 @@ REQUIRES = \ string \ necko \ history \ + libreg \ browsercomps \ toolkitcomps \ - profile \ - profilemanager \ pref \ rdf \ satchel \ @@ -64,17 +63,21 @@ REQUIRES = \ dom \ docshell \ cookie \ + xulapp \ $(NULL) CPPSRCS = nsProfileMigrator.cpp \ nsBrowserProfileMigratorUtils.cpp \ nsNetscapeProfileMigratorBase.cpp \ - nsDogbertProfileMigrator.cpp \ nsSeamonkeyProfileMigrator.cpp \ nsPhoenixProfileMigrator.cpp \ nsINIParser.cpp \ $(NULL) +ifneq ($(OS_ARCH),BeOS) +CPPSRCS += nsDogbertProfileMigrator.cpp +endif + ifneq ($(OS_ARCH),OS2) CPPSRCS += nsOperaProfileMigrator.cpp endif @@ -85,7 +88,7 @@ DEFINES += -DPSTOREC_DLL=\"$(subst \,\\,$(WINDIR))\\system32\\pstorec.dll\" CPPSRCS += nsIEProfileMigrator.cpp \ $(NULL) endif - + ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) CPPSRCS += nsSafariProfileMigrator.cpp \ nsMacIEProfileMigrator.cpp \ diff --git a/mozilla/browser/components/migration/src/nsBrowserProfileMigratorUtils.cpp b/mozilla/browser/components/migration/src/nsBrowserProfileMigratorUtils.cpp index 81e3d3d12fa..42232e291c6 100644 --- a/mozilla/browser/components/migration/src/nsBrowserProfileMigratorUtils.cpp +++ b/mozilla/browser/components/migration/src/nsBrowserProfileMigratorUtils.cpp @@ -36,7 +36,13 @@ * ***** END LICENSE BLOCK ***** */ #include "nsBrowserProfileMigratorUtils.h" -#include "nsILocalFile.h" +#include "nsIFile.h" +#include "nsIProperties.h" +#include "nsIProfileMigrator.h" + +#include "nsIServiceManagerUtils.h" +#include "nsAppDirectoryServiceDefs.h" +#include "nsXPCOMCID.h" #include "nsCRT.h" void SetProxyPref(const nsACString& aHostPort, const char* aPref, @@ -81,7 +87,7 @@ void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch) } void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength, - PRBool aReplace, nsILocalFile* aSourceProfile, + PRBool aReplace, nsIFile* aSourceProfile, PRUint16* aResult) { nsCOMPtr sourceFile; @@ -103,3 +109,19 @@ void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength cursor->fileName = nsnull; } } + +void +GetProfilePath(nsIProfileStartup* aStartup, nsCOMPtr& aProfileDir) +{ + if (aStartup) { + aStartup->GetDirectory(getter_AddRefs(aProfileDir)); + } + else { + nsCOMPtr dirSvc + (do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID)); + if (dirSvc) { + dirSvc->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), + (void**) getter_AddRefs(aProfileDir)); + } + } +} diff --git a/mozilla/browser/components/migration/src/nsBrowserProfileMigratorUtils.h b/mozilla/browser/components/migration/src/nsBrowserProfileMigratorUtils.h index fa14929d64c..b87a657e64d 100644 --- a/mozilla/browser/components/migration/src/nsBrowserProfileMigratorUtils.h +++ b/mozilla/browser/components/migration/src/nsBrowserProfileMigratorUtils.h @@ -56,7 +56,9 @@ } #include "nsIPrefBranch.h" +#include "nsIFile.h" #include "nsString.h" +class nsIProfileStartup; // Proxy utilities shared by the Opera and IE migrators void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch); @@ -73,8 +75,13 @@ class nsILocalFile; void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength, PRBool aReplace, - nsILocalFile* aSourceProfile, + nsIFile* aSourceProfile, PRUint16* aResult); + +// get the base directory of the *target* profile +// this is already cloned, modify it to your heart's content +void GetProfilePath(nsIProfileStartup* aStartup, nsCOMPtr& aProfileDir); + #endif diff --git a/mozilla/browser/components/migration/src/nsCaminoProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsCaminoProfileMigrator.cpp index 711f43cf337..775f184656e 100644 --- a/mozilla/browser/components/migration/src/nsCaminoProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsCaminoProfileMigrator.cpp @@ -38,8 +38,7 @@ #include "nsBrowserProfileMigratorUtils.h" #include "nsCaminoProfileMigrator.h" #include "nsIObserverService.h" -#include "nsIProfile.h" -#include "nsIProfileInternal.h" +#include "nsIProfileMigrator.h" #include "nsIServiceManager.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" @@ -62,7 +61,7 @@ nsCaminoProfileMigrator::~nsCaminoProfileMigrator() // nsIBrowserProfileMigrator NS_IMETHODIMP -nsCaminoProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsCaminoProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; diff --git a/mozilla/browser/components/migration/src/nsDogbertProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsDogbertProfileMigrator.cpp index 752dd0eefe5..e5d222f8d00 100644 --- a/mozilla/browser/components/migration/src/nsDogbertProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsDogbertProfileMigrator.cpp @@ -48,8 +48,6 @@ #include "nsIPrefBranch.h" #include "nsIPrefLocalizedString.h" #include "nsIPrefService.h" -#include "nsIProfile.h" -#include "nsIProfileInternal.h" #include "nsIServiceManager.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" @@ -57,17 +55,26 @@ #include "nsNetUtil.h" #include "nsReadableUtils.h" #include "prprf.h" +#include "prenv.h" +#include "nsEscape.h" +#include "NSReg.h" +#include "nsDirectoryServiceDefs.h" + +#ifndef MAXPATHLEN +#ifdef _MAX_PATH +#define MAXPATHLEN _MAX_PATH +#elif defined(CCHMAXPATH) +#define MAXPATHLEN CCHMAXPATH +#else +#define MAXPATHLEN 1024 +#endif +#endif #define PREF_FILE_HEADER_STRING "# Mozilla User Preferences " -#if defined(XP_UNIX) && !defined(XP_MACOSX) -#define PREF_FILE_NAME_IN_4x NS_LITERAL_STRING("preferences.js") -#define COOKIES_FILE_NAME_IN_4x NS_LITERAL_STRING("cookies") -#define BOOKMARKS_FILE_NAME_IN_4x NS_LITERAL_STRING("bookmarks.html") -#define PSM_CERT7_DB NS_LITERAL_STRING("cert7.db") -#define PSM_KEY3_DB NS_LITERAL_STRING("key3.db") -#define PSM_SECMODULE_DB NS_LITERAL_STRING("secmodule.db") -#elif defined(XP_MAC) || defined(XP_MACOSX) +#if defined(XP_MACOSX) +#define OLDREG_NAME "Netscape Registry" +#define OLDREG_DIR NS_MAC_PREFS_DIR #define PREF_FILE_NAME_IN_4x NS_LITERAL_STRING("Netscape Preferences") #define COOKIES_FILE_NAME_IN_4x NS_LITERAL_STRING("MagicCookie") #define BOOKMARKS_FILE_NAME_IN_4x NS_LITERAL_STRING("Bookmarks.html") @@ -75,13 +82,33 @@ #define PSM_CERT7_DB NS_LITERAL_STRING("Certificates7") #define PSM_KEY3_DB NS_LITERAL_STRING("Key Database3") #define PSM_SECMODULE_DB NS_LITERAL_STRING("Security Modules") -#else /* XP_WIN || XP_OS2 */ + +#elif defined(XP_WIN) || defined(XP_OS2) +#define OLDREG_NAME "nsreg.dat" +#ifdef XP_WIN +#define OLDREG_DIR NS_WIN_WINDOWS_DIR +#else +#define OLDREG_DIR NS_OS2_DIR +#endif #define PREF_FILE_NAME_IN_4x NS_LITERAL_STRING("prefs.js") #define COOKIES_FILE_NAME_IN_4x NS_LITERAL_STRING("cookies.txt") #define BOOKMARKS_FILE_NAME_IN_4x NS_LITERAL_STRING("bookmark.htm") #define PSM_CERT7_DB NS_LITERAL_STRING("cert7.db") #define PSM_KEY3_DB NS_LITERAL_STRING("key3.db") #define PSM_SECMODULE_DB NS_LITERAL_STRING("secmod.db") + +#elif defined(XP_UNIX) +#define PREF_FILE_NAME_IN_4x NS_LITERAL_STRING("preferences.js") +#define COOKIES_FILE_NAME_IN_4x NS_LITERAL_STRING("cookies") +#define BOOKMARKS_FILE_NAME_IN_4x NS_LITERAL_STRING("bookmarks.html") +#define PSM_CERT7_DB NS_LITERAL_STRING("cert7.db") +#define PSM_KEY3_DB NS_LITERAL_STRING("key3.db") +#define PSM_SECMODULE_DB NS_LITERAL_STRING("secmodule.db") +#define HOME_ENVIRONMENT_VARIABLE "HOME" +#define PROFILE_HOME_ENVIRONMENT_VARIABLE "PROFILE_HOME" +#define DEFAULT_UNIX_PROFILE_NAME "default" +#else +#error No netscape4.x profile-migrator on this platform. #endif /* XP_UNIX */ #define COOKIES_FILE_NAME_IN_5x NS_LITERAL_STRING("cookies.txt") @@ -106,14 +133,22 @@ nsDogbertProfileMigrator::~nsDogbertProfileMigrator() // nsIBrowserProfileMigrator NS_IMETHODIMP -nsDogbertProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsDogbertProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, + const PRUnichar* aProfile) { nsresult rv = NS_OK; + PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE; - if (!mTargetProfile) - GetTargetProfile(aProfile, aReplace); - if (!mSourceProfile) + if (!mTargetProfile) { + GetProfilePath(aStartup, mTargetProfile); + if (!mTargetProfile) return NS_ERROR_FAILURE; + } + + if (!mSourceProfile) { GetSourceProfile(aProfile); + if (!mSourceProfile) + return NS_ERROR_FAILURE; + } NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull); @@ -126,15 +161,63 @@ nsDogbertProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnic return rv; } +// on win/mac/os2, NS4x uses a registry to determine profile locations +#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_OS2) void nsDogbertProfileMigrator::GetSourceProfile(const PRUnichar* aProfile) { - // XXXben I would actually prefer we do this by reading the 4.x registry, rather than - // relying on the 5.x registry knowing about 4.x profiles, in case we remove profile - // manager support from Firefox. - nsCOMPtr pmi(do_GetService("@mozilla.org/profile/manager;1")); - pmi->GetOriginalProfileDir(aProfile, getter_AddRefs(mSourceProfile)); + nsresult rv; + + nsCOMPtr regFile; + rv = NS_GetSpecialDirectory(OLDREG_DIR, getter_AddRefs(regFile)); + if (NS_FAILED(rv)) return; + + regFile->AppendNative(NS_LITERAL_CSTRING(OLDREG_NAME)); + + nsCAutoString path; + rv = regFile->GetNativePath(path); + if (NS_FAILED(rv)) return; + + if (NR_StartupRegistry()) + return; + + HREG reg = nsnull; + RKEY profile = nsnull; + + if (NR_RegOpen(path.get(), ®)) + goto cleanup; + + { + // on macos, registry entries are UTF8 encoded + NS_ConvertUTF16toUTF8 profileName(aProfile); + + if (NR_RegGetKey(reg, ROOTKEY_USERS, profileName.get(), &profile)) + goto cleanup; + } + + char profilePath[MAXPATHLEN]; + if (NR_RegGetEntryString(reg, profile, "ProfileLocation", profilePath, MAXPATHLEN)) + goto cleanup; + + mSourceProfile = do_CreateInstance("@mozilla.org/file/local;1"); + if (!mSourceProfile) goto cleanup; + + { + // the string is UTF8 encoded, which forces us to do some strange string-do + rv = mSourceProfile->InitWithPath(NS_ConvertUTF8toUTF16(profilePath)); + } + + if (NS_FAILED(rv)) + mSourceProfile = nsnull; + +cleanup: + if (reg) + NR_RegClose(reg); + NR_ShutdownRegistry(); } +#else + +#endif NS_IMETHODIMP nsDogbertProfileMigrator::GetMigrateData(const PRUnichar* aProfile, @@ -144,11 +227,10 @@ nsDogbertProfileMigrator::GetMigrateData(const PRUnichar* aProfile, *aResult = 0; if (!mSourceProfile) { GetSourceProfile(aProfile); - if (!mSourceProfile) + if (!mSourceProfile) return NS_ERROR_FILE_NOT_FOUND; } - PRBool exists; MigrationData data[] = { { ToNewUnicode(PREF_FILE_NAME_IN_4x), nsIBrowserProfileMigrator::SETTINGS, PR_TRUE }, @@ -200,34 +282,104 @@ nsDogbertProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult) return NS_OK; } +#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MACOSX) NS_IMETHODIMP nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) { if (!mProfiles) { - nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); - if (NS_FAILED(rv)) return rv; + nsresult rv; - // XXXben - this is a little risky.. let's make this actually go and use the - // 4.x registry instead... - // Our profile manager stores information about the set of Dogbert Profiles we have. - nsCOMPtr pmi(do_CreateInstance("@mozilla.org/profile/manager;1")); - PRUnichar** profileNames = nsnull; - PRUint32 profileCount = 0; - // Lordy, this API sucketh. - rv = pmi->GetProfileListX(nsIProfileInternal::LIST_FOR_IMPORT, &profileCount, &profileNames); - if (NS_FAILED(rv)) return rv; + rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); + NS_ENSURE_SUCCESS(rv, rv); - for (PRUint32 i = 0; i < profileCount; ++i) { - nsCOMPtr string(do_CreateInstance("@mozilla.org/supports-string;1")); - string->SetData(nsDependentString(profileNames[i])); - mProfiles->AppendElement(string); + nsCOMPtr regFile; + rv = NS_GetSpecialDirectory(OLDREG_DIR, getter_AddRefs(regFile)); + NS_ENSURE_SUCCESS(rv, rv); + regFile->AppendNative(NS_LITERAL_CSTRING(OLDREG_NAME)); + + nsCAutoString path; + rv = regFile->GetNativePath(path); + NS_ENSURE_SUCCESS(rv, rv); + + if (NR_StartupRegistry()) + return NS_ERROR_FAILURE; + + HREG reg = nsnull; + REGENUM enumstate = 0; + + if (NR_RegOpen(path.get(), ®)) { + NR_ShutdownRegistry(); + return NS_ERROR_FAILURE; + } + + char profileName[MAXREGNAMELEN]; + while (!NR_RegEnumSubkeys(reg, ROOTKEY_USERS, &enumstate, + profileName, MAXREGNAMELEN, REGENUM_CHILDREN)) { + nsCOMPtr nameString + (do_CreateInstance("@mozilla.org/supports-string;1")); + if (nameString) { + nameString->SetData(NS_ConvertUTF8toUTF16(profileName)); + mProfiles->AppendElement(nameString); + } } - NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(profileCount, profileNames); } NS_IF_ADDREF(*aResult = mProfiles); return NS_OK; } +#else // XP_UNIX + +NS_IMETHODIMP +nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) +{ + nsresult rv; + const char* profileDir = PR_GetEnv(PROFILE_HOME_ENVIRONMENT_VARIABLE); + + if (!profileDir) { + profileDir = PR_GetEnv(HOME_ENVIRONMENT_VARIABLE); + } + if (!profileDir) return NS_ERROR_FAILURE; + + nsCAutoString profilePath(profileDir); + profilePath += "/.netscape"; + + nsCOMPtr profileFile; + rv = NS_NewNativeLocalFile(profilePath, PR_TRUE, getter_AddRefs(profileFile)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr prefFile; + rv = profileFile->Clone(getter_AddRefs(prefFile)); + NS_ENSURE_SUCCESS(rv, rv); + + prefFile->AppendNative(NS_LITERAL_CSTRING("preferences.js")); + + PRBool exists; + rv = prefFile->Exists(&exists); + if (NS_FAILED(rv) || !exists) { + return NS_ERROR_FAILURE; + } + + mSourceProfile = profileFile; + + rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr nameString + (do_CreateInstance("@mozilla.org/supports-string;1")); + if (!nameString) return NS_ERROR_FAILURE; + + nameString->SetData(NS_LITERAL_STRING("Netscape 4.x")); + mProfiles->AppendElement(nameString); + NS_ADDREF(*aResult = mProfiles); + return NS_OK; +} + +void +nsDogbertProfileMigrator::GetSourceProfile(const PRUnichar* aProfile) +{ + // if GetSourceProfiles didn't do its magic, we're screwed +} +#endif // GetSourceProfiles /////////////////////////////////////////////////////////////////////////////// // nsDogbertProfileMigrator @@ -396,7 +548,7 @@ nsDogbertProfileMigrator::FixDogbertCookies() if (!fileOutputStream) return NS_ERROR_OUT_OF_MEMORY; nsCOMPtr lineInputStream(do_QueryInterface(fileInputStream)); - nsCAutoString buffer, outBuffer; + nsAutoString buffer, outBuffer; PRBool moreData = PR_FALSE; PRUint32 written = 0; do { @@ -409,7 +561,8 @@ nsDogbertProfileMigrator::FixDogbertCookies() // skip line if it is a comment or null line if (buffer.IsEmpty() || buffer.CharAt(0) == '#' || buffer.CharAt(0) == nsCRT::CR || buffer.CharAt(0) == nsCRT::LF) { - fileOutputStream->Write(buffer.get(), buffer.Length(), &written); + fileOutputStream->Write((const char*)buffer.get(), buffer.Length(), &written); + // XXX this is wrong! you need buffer.Length() * sizeof(PRUnichar) continue; } @@ -425,7 +578,7 @@ nsDogbertProfileMigrator::FixDogbertCookies() continue; // separate the expires field from the rest of the cookie line - nsCAutoString prefix, expiresString, suffix; + nsAutoString prefix, expiresString, suffix; buffer.Mid(prefix, hostIndex, expiresIndex-hostIndex-1); buffer.Mid(expiresString, expiresIndex, nameIndex-expiresIndex-1); buffer.Mid(suffix, nameIndex, buffer.Length()-nameIndex); @@ -444,12 +597,14 @@ nsDogbertProfileMigrator::FixDogbertCookies() // generate the output buffer and write it to file outBuffer = prefix; - outBuffer.Append('\t'); - outBuffer.Append(dateString); - outBuffer.Append('\t'); + outBuffer.Append(PRUnichar('\t')); + outBuffer.AppendWithConversion(dateString); + outBuffer.Append(PRUnichar('\t')); outBuffer.Append(suffix); - fileOutputStream->Write(outBuffer.get(), outBuffer.Length(), &written); + nsCAutoString convertedBuffer; + convertedBuffer.Assign(NS_ConvertUCS2toUTF8(outBuffer)); + fileOutputStream->Write(convertedBuffer.get(), convertedBuffer.Length(), &written); } while (1); @@ -514,7 +669,6 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks() nsCOMPtr lineInputStream(do_QueryInterface(fileInputStream)); nsCAutoString sourceBuffer; - nsCAutoString targetBuffer; PRBool moreData = PR_FALSE; PRUint32 bytesWritten = 0; do { @@ -534,9 +688,8 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks() folderPrefixOffset + folderPrefix.Length()); } - targetBuffer.Assign(sourceBuffer); - targetBuffer.Append("\r\n"); - outputStream->Write(targetBuffer.get(), targetBuffer.Length(), &bytesWritten); + sourceBuffer.Append("\r\n"); + outputStream->Write(sourceBuffer.get(), sourceBuffer.Length(), &bytesWritten); } while (1); diff --git a/mozilla/browser/components/migration/src/nsICabProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsICabProfileMigrator.cpp index ba3695bae16..250bd7f5d42 100644 --- a/mozilla/browser/components/migration/src/nsICabProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsICabProfileMigrator.cpp @@ -38,8 +38,7 @@ #include "nsBrowserProfileMigratorUtils.h" #include "nsICabProfileMigrator.h" #include "nsIObserverService.h" -#include "nsIProfile.h" -#include "nsIProfileInternal.h" +#include "nsIProfileMigrator.h" #include "nsIServiceManager.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" @@ -62,7 +61,7 @@ nsICabProfileMigrator::~nsICabProfileMigrator() // nsIBrowserProfileMigrator NS_IMETHODIMP -nsICabProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsICabProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; diff --git a/mozilla/browser/components/migration/src/nsIEProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsIEProfileMigrator.cpp index 80afe7578a3..685c8d04eaa 100644 --- a/mozilla/browser/components/migration/src/nsIEProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsIEProfileMigrator.cpp @@ -63,6 +63,7 @@ #include "nsIServiceManagerUtils.h" #include "nsISimpleEnumerator.h" #include "nsISupportsArray.h" +#include "nsIProfileMigrator.h" #include "nsIBrowserProfileMigrator.h" #include "nsIObserverService.h" @@ -427,10 +428,18 @@ user_pref("font.size.variable.x-western", 15); /////////////////////////////////////////////////////////////////////////////// // nsIBrowserProfileMigrator NS_IMETHODIMP -nsIEProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsIEProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; + PRBool aReplace = PR_FALSE; + + if (aStartup) { + aReplace = PR_TRUE; + rv = aStartup->DoStartup(); + NS_ENSURE_SUCCESS(rv, rv); + } + NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull); COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS); @@ -1031,6 +1040,10 @@ nsIEProfileMigrator::CopyFavorites(PRBool aReplace) { rdf->GetResource(NS_LITERAL_CSTRING("NC:BookmarksRoot"), getter_AddRefs(root)); nsCOMPtr bms(do_GetService("@mozilla.org/browser/bookmarks-service;1")); + NS_ENSURE_TRUE(bms, NS_ERROR_FAILURE); + PRBool dummy; + bms->ReadBookmarks(&dummy); + nsAutoString personalToolbarFolderName; nsCOMPtr folder; diff --git a/mozilla/browser/components/migration/src/nsMacIEProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsMacIEProfileMigrator.cpp index fc8c16ec70a..a54b2600d69 100644 --- a/mozilla/browser/components/migration/src/nsMacIEProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsMacIEProfileMigrator.cpp @@ -38,8 +38,7 @@ #include "nsBrowserProfileMigratorUtils.h" #include "nsMacIEProfileMigrator.h" #include "nsIObserverService.h" -#include "nsIProfile.h" -#include "nsIProfileInternal.h" +#include "nsIProfileMigrator.h" #include "nsIServiceManager.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" @@ -62,7 +61,7 @@ nsMacIEProfileMigrator::~nsMacIEProfileMigrator() // nsIBrowserProfileMigrator NS_IMETHODIMP -nsMacIEProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsMacIEProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; diff --git a/mozilla/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp b/mozilla/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp index b2c1f22f6f0..0c915f4d97f 100644 --- a/mozilla/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp +++ b/mozilla/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp @@ -46,8 +46,6 @@ #include "nsIPrefBranch.h" #include "nsIPrefLocalizedString.h" #include "nsIPrefService.h" -#include "nsIProfile.h" -#include "nsIProfileInternal.h" #include "nsIRDFService.h" #include "nsIRegistry.h" #include "nsIServiceManager.h" @@ -80,75 +78,6 @@ nsNetscapeProfileMigratorBase::nsNetscapeProfileMigratorBase() bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(mBundle)); } -void -nsNetscapeProfileMigratorBase::GetTargetProfile(const PRUnichar* aSuggestedName, PRBool aReplace) -{ - if (aReplace) - CreateTemplateProfile(aSuggestedName); - else { - nsCOMPtr pmi(do_GetService("@mozilla.org/profile/manager;1")); - nsXPIDLString currProfile; - pmi->GetCurrentProfile(getter_Copies(currProfile)); - nsCOMPtr dir; - pmi->GetProfileDir(currProfile.get(), getter_AddRefs(dir)); - mTargetProfile = do_QueryInterface(dir); - } -} - -void -nsNetscapeProfileMigratorBase::CreateTemplateProfile(const PRUnichar* aSuggestedName) -{ - nsCOMPtr profilesDir; - NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(profilesDir)); - - nsXPIDLString profileName; - GetUniqueProfileName(profilesDir, aSuggestedName, getter_Copies(profileName)); - - nsAutoString profilesDirPath; - profilesDir->GetPath(profilesDirPath); - - nsCOMPtr pm(do_GetService("@mozilla.org/profile/manager;1")); - pm->CreateNewProfile(profileName.get(), profilesDirPath.get(), nsnull, PR_TRUE); - - nsCOMPtr pmi(do_QueryInterface(pm)); - nsCOMPtr target; - pmi->GetProfileDir(profileName.get(), getter_AddRefs(target)); - mTargetProfile = do_QueryInterface(target); -} - -void -nsNetscapeProfileMigratorBase::GetUniqueProfileName(nsIFile* aProfilesDir, - const PRUnichar* aSuggestedName, - PRUnichar** aUniqueName) -{ - PRBool exists = PR_FALSE; - PRUint32 count = 1; - nsXPIDLString profileName; - nsAutoString profileNameStr(aSuggestedName); - - nsCOMPtr newProfileDir; - aProfilesDir->Clone(getter_AddRefs(newProfileDir)); - newProfileDir->Append(profileNameStr); - newProfileDir->Exists(&exists); - - while (exists) { - nsAutoString countString; - countString.AppendInt(count); - const PRUnichar* strings[2] = { aSuggestedName, countString.get() }; - mBundle->FormatStringFromName(NS_LITERAL_STRING("profileName_format").get(), strings, 2, getter_Copies(profileName)); - - nsCOMPtr newProfileDir; - aProfilesDir->Clone(getter_AddRefs(newProfileDir)); - newProfileDir->Append(profileName); - newProfileDir->Exists(&exists); - - profileNameStr = profileName.get(); - ++count; - } - - *aUniqueName = ToNewUnicode(profileNameStr); -} - nsresult nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistryFile, nsISupportsArray* aProfileNames, diff --git a/mozilla/browser/components/migration/src/nsNetscapeProfileMigratorBase.h b/mozilla/browser/components/migration/src/nsNetscapeProfileMigratorBase.h index a8179804b9b..dd396710a93 100644 --- a/mozilla/browser/components/migration/src/nsNetscapeProfileMigratorBase.h +++ b/mozilla/browser/components/migration/src/nsNetscapeProfileMigratorBase.h @@ -81,9 +81,6 @@ protected: nsresult GetProfileDataFromRegistry(nsILocalFile* aRegistryFile, nsISupportsArray* aProfileNames, nsISupportsArray* aProfileLocations); - void GetTargetProfile(const PRUnichar* aSuggestedName, PRBool aReplace); - void CreateTemplateProfile(const PRUnichar* aSuggestedName); - void GetUniqueProfileName(nsIFile* aProfilesDir, const PRUnichar* aSuggestedName, PRUnichar** aUniqueName); nsresult CopyFile(const nsAString& aSourceFileName, const nsAString& aTargetFileName); @@ -97,7 +94,7 @@ protected: protected: nsCOMPtr mSourceProfile; - nsCOMPtr mTargetProfile; + nsCOMPtr mTargetProfile; nsCOMPtr mBundle; }; diff --git a/mozilla/browser/components/migration/src/nsOmniWebProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsOmniWebProfileMigrator.cpp index 04e9bc1cd47..29ba4540613 100644 --- a/mozilla/browser/components/migration/src/nsOmniWebProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsOmniWebProfileMigrator.cpp @@ -38,8 +38,7 @@ #include "nsBrowserProfileMigratorUtils.h" #include "nsOmniWebProfileMigrator.h" #include "nsIObserverService.h" -#include "nsIProfile.h" -#include "nsIProfileInternal.h" +#include "nsIProfileMigrator.h" #include "nsIServiceManager.h" #include "nsISupportsArray.h" #include "nsISupportsPrimitives.h" @@ -62,7 +61,7 @@ nsOmniWebProfileMigrator::~nsOmniWebProfileMigrator() // nsIBrowserProfileMigrator NS_IMETHODIMP -nsOmniWebProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsOmniWebProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; diff --git a/mozilla/browser/components/migration/src/nsOperaProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsOperaProfileMigrator.cpp index c10ff1e209b..5734a446393 100644 --- a/mozilla/browser/components/migration/src/nsOperaProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsOperaProfileMigrator.cpp @@ -52,6 +52,7 @@ #include "nsIPermissionManager.h" #include "nsIPrefLocalizedString.h" #include "nsIPrefService.h" +#include "nsIProfileMigrator.h" #include "nsIProperties.h" #include "nsIRDFContainer.h" #include "nsIRDFService.h" @@ -115,9 +116,15 @@ nsOperaProfileMigrator::~nsOperaProfileMigrator() } NS_IMETHODIMP -nsOperaProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsOperaProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; + PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE; + + if (aStartup) { + rv = aStartup->DoStartup(); + NS_ENSURE_SUCCESS(rv, rv); + } if (!mOperaProfile) GetOperaProfile(aProfile, getter_AddRefs(mOperaProfile)); @@ -932,7 +939,8 @@ nsOperaProfileMigrator::CopyHistory(PRBool aReplace) nsCOMPtr lineStream = do_QueryInterface(fileStream); - nsCAutoString buffer, title, url; + nsCAutoString buffer, url; + nsAutoString title; PRTime lastVisitDate; PRBool moreData = PR_FALSE; @@ -946,7 +954,7 @@ nsOperaProfileMigrator::CopyHistory(PRBool aReplace) switch (state) { case TITLE: - title = buffer; + CopyUTF8toUTF16(buffer, title); state = URL; break; case URL: @@ -963,8 +971,7 @@ nsOperaProfileMigrator::CopyHistory(PRBool aReplace) LL_I2L(million, PR_USEC_PER_SEC); LL_MUL(lastVisitDate, temp, million); - nsAutoString titleStr; titleStr.AssignWithConversion(title); - hist->AddPageWithDetails(url.get(), titleStr.get(), lastVisitDate); + hist->AddPageWithDetails(url.get(), title.get(), lastVisitDate); state = TITLE; break; @@ -990,6 +997,10 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace) nsCOMPtr lineInputStream(do_QueryInterface(fileInputStream)); nsCOMPtr bms(do_GetService("@mozilla.org/browser/bookmarks-service;1")); + NS_ENSURE_TRUE(bms, NS_ERROR_FAILURE); + PRBool dummy; + bms->ReadBookmarks(&dummy); + nsCOMPtr bundleService(do_GetService(kStringBundleServiceCID)); nsCOMPtr bundle; bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); @@ -1182,37 +1193,32 @@ typedef enum { LineType_FOLDER, LineType_NL, LineType_OTHER } LineType; -static LineType GetLineType(nsAString& aBuffer, PRUnichar** aData) +static LineType GetLineType(nsACString& aBuffer, nsACString& aResult) { - if (Substring(aBuffer, 0, 7).Equals(NS_LITERAL_STRING("#FOLDER"))) + if (Substring(aBuffer, 0, 7).EqualsLiteral("#FOLDER")) return LineType_FOLDER; - if (Substring(aBuffer, 0, 4).Equals(NS_LITERAL_STRING("#URL"))) + if (Substring(aBuffer, 0, 4).EqualsLiteral("#URL")) return LineType_BOOKMARK; - if (Substring(aBuffer, 0, 1).Equals(NS_LITERAL_STRING("-"))) + if (Substring(aBuffer, 0, 1).EqualsLiteral("-")) return LineType_SEPARATOR; - if (Substring(aBuffer, 1, 5).Equals(NS_LITERAL_STRING("NAME="))) { - const nsAString& data = Substring(aBuffer, 6, aBuffer.Length() - 6); - *aData = ToNewUnicode(data); + if (Substring(aBuffer, 1, 5).EqualsLiteral("NAME=")) { + aResult.Assign(Substring(aBuffer, 6, aBuffer.Length() - 6)); return LineType_NAME; } - if (Substring(aBuffer, 1, 4).Equals(NS_LITERAL_STRING("URL="))) { - const nsAString& data = Substring(aBuffer, 5, aBuffer.Length() - 5); - *aData = ToNewUnicode(data); + if (Substring(aBuffer, 1, 4).EqualsLiteral("URL=")) { + aResult.Assign(Substring(aBuffer, 5, aBuffer.Length() - 5)); return LineType_URL; } - if (Substring(aBuffer, 1, 12).Equals(NS_LITERAL_STRING("DESCRIPTION="))) { - const nsAString& data = Substring(aBuffer, 13, aBuffer.Length() - 13); - *aData = ToNewUnicode(data); + if (Substring(aBuffer, 1, 12).EqualsLiteral("DESCRIPTION=")) { + aResult.Assign(Substring(aBuffer, 13, aBuffer.Length() - 13)); return LineType_DESCRIPTION; } - if (Substring(aBuffer, 1, 11).Equals(NS_LITERAL_STRING("SHORT NAME="))) { - const nsAString& data = Substring(aBuffer, 12, aBuffer.Length() - 12); - *aData = ToNewUnicode(data); + if (Substring(aBuffer, 1, 11).EqualsLiteral("SHORT NAME=")) { + aResult.Assign(Substring(aBuffer, 12, aBuffer.Length() - 12)); return LineType_KEYWORD; } - if (Substring(aBuffer, 1, 15).Equals(NS_LITERAL_STRING("ON PERSONALBAR="))) { - const nsAString& data = Substring(aBuffer, 16, aBuffer.Length() - 16); - *aData = ToNewUnicode(data); + if (Substring(aBuffer, 1, 15).EqualsLiteral("ON PERSONALBAR=")) { + aResult.Assign(Substring(aBuffer, 16, aBuffer.Length() - 16)); return LineType_ONTOOLBAR; } if (aBuffer.IsEmpty()) @@ -1230,22 +1236,17 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, { nsresult rv; PRBool moreData = PR_FALSE; - nsAutoString buffer; + nsCAutoString buffer, result; EntryType entryType = EntryType_BOOKMARK; - nsAutoString name, keyword, description; - nsCAutoString url; + nsAutoString name, keyword, description, url; PRBool onToolbar = PR_FALSE; - NS_NAMED_LITERAL_STRING(empty, ""); do { - nsCAutoString cBuffer; - rv = aStream->ReadLine(cBuffer, &moreData); + rv = aStream->ReadLine(buffer, &moreData); if (NS_FAILED(rv)) return rv; if (!moreData) break; - CopyASCIItoUTF16(cBuffer, buffer); - nsXPIDLString data; - LineType type = GetLineType(buffer, getter_Copies(data)); + LineType type = GetLineType(buffer, result); switch(type) { case LineType_FOLDER: entryType = EntryType_FOLDER; @@ -1260,19 +1261,19 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, // folder, or CopyBookmarks (which means we're done parsing all bookmarks). goto done; case LineType_NAME: - name = data; + CopyUTF8toUTF16(result, name); break; case LineType_URL: - url.Assign(NS_ConvertUCS2toUTF8(data)); + CopyUTF8toUTF16(result, url); break; case LineType_KEYWORD: - keyword = data; + CopyUTF8toUTF16(result, keyword); break; case LineType_DESCRIPTION: - description = data; + CopyUTF8toUTF16(result, description); break; case LineType_ONTOOLBAR: - if (NS_LITERAL_STRING("YES").Equals(data)) + if (result.EqualsLiteral("YES")) onToolbar = PR_TRUE; break; case LineType_NL: { @@ -1284,7 +1285,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, if (entryType == EntryType_BOOKMARK) { if (!name.IsEmpty() && !url.IsEmpty()) { rv = aBMS->CreateBookmarkInContainer(name.get(), - NS_ConvertUTF8toUTF16(url).get(), + url.get(), keyword.get(), description.get(), nsnull, @@ -1292,10 +1293,10 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, onToolbar ? aToolbar : aParent, -1, getter_AddRefs(itemRes)); - name = empty; - url.AssignWithConversion(empty); - keyword = empty; - description = empty; + name.Truncate(); + url.Truncate(); + keyword.Truncate(); + description.Truncate(); if (NS_FAILED(rv)) continue; } @@ -1306,7 +1307,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, onToolbar ? aToolbar : aParent, -1, getter_AddRefs(itemRes)); - name = empty; + name.Truncate(); if (NS_FAILED(rv)) continue; rv = ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS); diff --git a/mozilla/browser/components/migration/src/nsPhoenixProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsPhoenixProfileMigrator.cpp index 063ccdbc835..f33e9b88722 100644 --- a/mozilla/browser/components/migration/src/nsPhoenixProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsPhoenixProfileMigrator.cpp @@ -85,30 +85,32 @@ nsPhoenixProfileMigrator::~nsPhoenixProfileMigrator() // nsIBrowserProfileMigrator NS_IMETHODIMP -nsPhoenixProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsPhoenixProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; // At this time the only reason for this migrator is to get data across from the // Phoenix profile directory on initial run, so we don't need to support after-the-fact // importing. - NS_ASSERTION(aReplace, "Can't migrate from Phoenix/Firebird/Firefox profiles once Firefox is running!"); - if (!aReplace) + NS_ASSERTION(aStartup, "Can't migrate from Phoenix/Firebird/Firefox profiles once Firefox is running!"); + if (!aStartup) return NS_ERROR_FAILURE; - if (!mTargetProfile) - GetTargetProfile(aProfile, aReplace); + if (!mTargetProfile) { + GetProfilePath(aStartup, mTargetProfile); + if (!mTargetProfile) return NS_ERROR_FAILURE; + } if (!mSourceProfile) GetSourceProfile(aProfile); NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull); - COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS); - COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES); - COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY); - COPY_DATA(CopyPasswords, aReplace, nsIBrowserProfileMigrator::PASSWORDS); - COPY_DATA(CopyOtherData, aReplace, nsIBrowserProfileMigrator::OTHERDATA); - COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS); + COPY_DATA(CopyPreferences, PR_TRUE, nsIBrowserProfileMigrator::SETTINGS); + COPY_DATA(CopyCookies, PR_TRUE, nsIBrowserProfileMigrator::COOKIES); + COPY_DATA(CopyHistory, PR_TRUE, nsIBrowserProfileMigrator::HISTORY); + COPY_DATA(CopyPasswords, PR_TRUE, nsIBrowserProfileMigrator::PASSWORDS); + COPY_DATA(CopyOtherData, PR_TRUE, nsIBrowserProfileMigrator::OTHERDATA); + COPY_DATA(CopyBookmarks, PR_TRUE, nsIBrowserProfileMigrator::BOOKMARKS); if (aItems & nsIBrowserProfileMigrator::SETTINGS || aItems & nsIBrowserProfileMigrator::COOKIES || @@ -284,6 +286,11 @@ nsPhoenixProfileMigrator::FillProfileDataFromPhoenixRegistry() phoenixRegistry->Append(NS_LITERAL_STRING(".phoenix")); phoenixRegistry->Append(NS_LITERAL_STRING("appreg")); +#elif defined(XP_OS2) + fileLocator->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry)); + + phoenixRegistry->Append(NS_LITERAL_STRING("Phoenix")); + phoenixRegistry->Append(NS_LITERAL_STRING("registry.dat")); #endif diff --git a/mozilla/browser/components/migration/src/nsProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsProfileMigrator.cpp index 10e045c2cc5..a63afb6e2d5 100644 --- a/mozilla/browser/components/migration/src/nsProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsProfileMigrator.cpp @@ -35,24 +35,43 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsCOMPtr.h" -#include "nsCRT.h" -#include "nsBrowserCompsCID.h" +#include "nsProfileMigrator.h" + #include "nsIBookmarksService.h" #include "nsIBrowserProfileMigrator.h" #include "nsIComponentManager.h" #include "nsIDOMWindowInternal.h" +#include "nsILocalFile.h" #include "nsIObserverService.h" #include "nsIServiceManager.h" +#include "nsISupportsPrimitives.h" #include "nsISupportsArray.h" +#include "nsIToolkitProfile.h" +#include "nsIToolkitProfileService.h" #include "nsIWindowWatcher.h" -#include "nsProfileMigrator.h" + +#include "nsCOMPtr.h" +#include "nsBrowserCompsCID.h" +#include "nsDirectoryServiceDefs.h" + +#include "nsCRT.h" +#include "NSReg.h" #include "nsReadableUtils.h" #include "nsString.h" #ifdef XP_WIN #include #endif +#ifndef MAXPATHLEN +#ifdef _MAX_PATH +#define MAXPATHLEN _MAX_PATH +#elif defined(CCHMAXPATH) +#define MAXPATHLEN CCHMAXPATH +#else +#define MAXPATHLEN 1024 +#endif +#endif + /////////////////////////////////////////////////////////////////////////////// // nsIProfileMigrator @@ -60,82 +79,67 @@ #define MIGRATION_WIZARD_FE_FEATURES "chrome,dialog,modal,centerscreen" NS_IMETHODIMP -nsProfileMigrator::Migrate() +nsProfileMigrator::Migrate(nsIProfileStartup* aStartup) { - PRBool needsActiveProfile = PR_TRUE; - GetDefaultBrowserMigratorKey(getter_AddRefs(mMigrator), - getter_AddRefs(mSourceKey), - &needsActiveProfile); + nsresult rv; - nsresult rv = NS_ERROR_FILE_NOT_FOUND; // No migrator, or data could be - // found for the migrator - if (mMigrator && mSourceKey) { - PRBool sourceExists; - mMigrator->GetSourceExists(&sourceExists); + nsCAutoString key; + nsCOMPtr bpm; - if (sourceExists) { - if (!needsActiveProfile) - rv = OpenMigrationWizard(); - else { - nsCOMPtr obs(do_GetService("@mozilla.org/observer-service;1")); - rv = obs->AddObserver(this, "browser-window-before-show", PR_FALSE); - } - } + rv = GetDefaultBrowserMigratorKey(key, bpm); + if (NS_FAILED(rv)) return rv; + + if (!bpm) { + nsCAutoString contractID = + NS_LITERAL_CSTRING(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX) + key; + + bpm = do_CreateInstance(contractID.get()); + if (!bpm) return NS_ERROR_FAILURE; } - return rv; + PRBool sourceExists; + rv = bpm->GetSourceExists(&sourceExists); + NS_ENSURE_SUCCESS(rv, rv); + if (!sourceExists) return NS_ERROR_FAILURE; + + nsCOMPtr cstr + (do_CreateInstance("@mozilla.org/supports-cstring;1")); + if (!cstr) return NS_ERROR_OUT_OF_MEMORY; + cstr->SetData(key); + + // By opening the Migration FE with a supplied bpm, it will automatically + // migrate from it. + nsCOMPtr ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); + nsCOMPtr params; + NS_NewISupportsArray(getter_AddRefs(params)); + if (!ww || !params) return NS_ERROR_FAILURE; + + params->AppendElement(cstr); + params->AppendElement(bpm); + params->AppendElement(aStartup); + + nsCOMPtr migrateWizard; + return ww->OpenWindow(nsnull, + MIGRATION_WIZARD_FE_URL, + "_blank", + MIGRATION_WIZARD_FE_FEATURES, + params, + getter_AddRefs(migrateWizard)); } -/////////////////////////////////////////////////////////////////////////////// -// nsIObserver - NS_IMETHODIMP -nsProfileMigrator::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData) +nsProfileMigrator::Import() { - if (nsCRT::strcmp(aTopic, "browser-window-before-show") == 0) { - // Remove ourselves so we only run the migration wizard once. - nsCOMPtr obs(do_GetService("@mozilla.org/observer-service;1")); - obs->RemoveObserver(this, "browser-window-before-show"); + if (ImportRegistryProfiles(NS_LITERAL_CSTRING("Firefox"))) + return NS_OK; - // Spin up Bookmarks - nsCOMPtr bms(do_GetService("@mozilla.org/browser/bookmarks-service;1")); - if (bms) { - PRBool loaded; - bms->ReadBookmarks(&loaded); - } - - return OpenMigrationWizard(); - } - - return NS_OK; + return NS_ERROR_FAILURE; } /////////////////////////////////////////////////////////////////////////////// // nsProfileMigrator -NS_IMPL_ISUPPORTS2(nsProfileMigrator, nsIProfileMigrator, nsIObserver) - -nsresult -nsProfileMigrator::OpenMigrationWizard() -{ - if (mSourceKey && mMigrator) { - // By opening the Migration FE with a supplied bpm, it will automatically - // migrate from it. - nsCOMPtr ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); - nsCOMPtr params; - NS_NewISupportsArray(getter_AddRefs(params)); - params->AppendElement(mSourceKey); - params->AppendElement(mMigrator); - nsCOMPtr migrateWizard; - return ww->OpenWindow(nsnull, - MIGRATION_WIZARD_FE_URL, - "_blank", - MIGRATION_WIZARD_FE_FEATURES, - params, - getter_AddRefs(migrateWizard)); - } - return NS_OK; -} +NS_IMPL_ISUPPORTS1(nsProfileMigrator, nsIProfileMigrator) #ifdef XP_WIN typedef struct { @@ -153,13 +157,9 @@ typedef struct { #endif nsresult -nsProfileMigrator::GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMigrator, - nsISupportsString** aKey, - PRBool* aNeedsActiveProfile) +nsProfileMigrator::GetDefaultBrowserMigratorKey(nsACString& aKey, + nsCOMPtr& bpm) { - *aMigrator = nsnull; - *aKey = nsnull; - #if XP_WIN HKEY hkey; @@ -221,39 +221,29 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMig UINT size; ::VerQueryValue(ver, subBlock, (void**)&internalName, &size); - nsCOMPtr key(do_CreateInstance("@mozilla.org/supports-string;1")); - nsCOMPtr bpm; if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_IEXPLORE)) { - *aNeedsActiveProfile = PR_TRUE; - key->SetData(NS_LITERAL_STRING("ie")); - bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "ie"); + aKey = "ie"; + return NS_OK; } - else if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_SEAMONKEY)) { - *aNeedsActiveProfile = PR_FALSE; - key->SetData(NS_LITERAL_STRING("seamonkey")); - bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey"); + if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_SEAMONKEY)) { + aKey = "seamonkey"; + return NS_OK; } - else if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_DOGBERT)) { - *aNeedsActiveProfile = PR_FALSE; - key->SetData(NS_LITERAL_STRING("dogbert")); - bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "dogbert"); + if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_DOGBERT)) { + aKey = "dogbert"; + return NS_OK; } - else if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_OPERA)) { - *aNeedsActiveProfile = PR_TRUE; - key->SetData(NS_LITERAL_STRING("opera")); - bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "opera"); + if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_OPERA)) { + aKey = "opera"; + return NS_OK; } // Migrate data from any existing Application Data\Phoenix\* installations. - else if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_FIREBIRD) || - !nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_FIREFOX) || - !nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_PHOENIX)) { - *aNeedsActiveProfile = PR_FALSE; - key->SetData(NS_LITERAL_STRING("phoenix")); - bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix"); + if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_FIREBIRD) || + !nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_FIREFOX) || + !nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_PHOENIX)) { + aKey = "phoenix"; + return NS_OK; } - - NS_IF_ADDREF(*aKey = key); - NS_IF_ADDREF(*aMigrator = bpm); } } } @@ -261,28 +251,125 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMig } #else // XXXben - until we figure out what to do here with default browsers on MacOS and - // GNOME, simply copy data from a previous Phoenix or Seamonkey install. - *aNeedsActiveProfile = PR_FALSE; - nsCOMPtr key(do_CreateInstance("@mozilla.org/supports-string;1")); - key->SetData(NS_LITERAL_STRING("phoenix")); - nsCOMPtr bpm(do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix")); - PRBool exists; - bpm->GetSourceExists(&exists); - if (!exists) { - bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey"); - key->SetData(NS_LITERAL_STRING("seamonkey")); + // GNOME, simply copy data from a previous Seamonkey install. + PRBool exists = PR_FALSE; + bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix"); + if (bpm) bpm->GetSourceExists(&exists); - if (!exists) { - bpm = nsnull; - key = nsnull; - } + if (exists) { + aKey = "phoenix"; + return NS_OK; + } + + bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey"); + if (bpm) + bpm->GetSourceExists(&exists); + if (exists) { + aKey = "seamonkey"; + return NS_OK; } - - NS_IF_ADDREF(*aKey = key); - NS_IF_ADDREF(*aMigrator = bpm); #endif - return NS_OK; + return NS_ERROR_FAILURE; } +PRBool +nsProfileMigrator::ImportRegistryProfiles(const nsACString& aAppName) +{ + nsresult rv; + nsCOMPtr profileSvc + (do_GetService(NS_PROFILESERVICE_CONTRACTID)); + NS_ENSURE_TRUE(profileSvc, NS_ERROR_FAILURE); + + nsCOMPtr dirService + (do_GetService("@mozilla.org/file/directory_service;1")); + NS_ENSURE_TRUE(dirService, NS_ERROR_FAILURE); + + nsCOMPtr regFile; +#ifdef XP_WIN + rv = dirService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), + getter_AddRefs(regFile)); + NS_ENSURE_SUCCESS(rv, PR_FALSE); + regFile->AppendNative(aAppName); + regFile->AppendNative(NS_LITERAL_CSTRING("registry.dat")); +#elif defined(XP_MACOSX) + rv = dirService->Get(NS_MAC_USER_LIB_DIR, NS_GET_IID(nsILocalFile), + getter_AddRefs(regFile)); + NS_ENSURE_SUCCESS(rv, PR_FALSE); + regFile->AppendNative(aAppName); + regFile->AppendNative(NS_LITERAL_CSTRING("Application Registry")); +#elif defined(XP_OS2) + rv = dirService->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), + getter_AddRefs(regFile)); + NS_ENSURE_SUCCESS(rv, PR_FALSE); + regFile->AppendNative(aAppName); + regFile->AppendNative(NS_LITERAL_CSTRING("registry.dat")); +#else + rv = dirService->Get(NS_UNIX_HOME_DIR, NS_GET_IID(nsILocalFile), + getter_AddRefs(regFile)); + NS_ENSURE_SUCCESS(rv, PR_FALSE); + nsCAutoString dotAppName; + ToLowerCase(aAppName, dotAppName); + dotAppName.Insert('.', 0); + + regFile->AppendNative(dotAppName); + regFile->AppendNative(NS_LITERAL_CSTRING("appreg")); +#endif + + nsCAutoString path; + rv = regFile->GetNativePath(path); + NS_ENSURE_SUCCESS(rv, PR_FALSE); + + if (NR_StartupRegistry()) + return PR_FALSE; + + PRBool migrated = PR_FALSE; + HREG reg = nsnull; + RKEY profiles = 0; + REGENUM enumstate = 0; + char profileName[MAXREGNAMELEN]; + + if (NR_RegOpen(path.get(), ®)) + goto cleanup; + + if (NR_RegGetKey(reg, ROOTKEY_COMMON, "Profiles", &profiles)) + goto cleanup; + + while (!NR_RegEnumSubkeys(reg, profiles, &enumstate, + profileName, MAXREGNAMELEN, REGENUM_CHILDREN)) { +#ifdef DEBUG_bsmedberg + printf("Found profile %s.\n", profileName); +#endif + + RKEY profile = 0; + if (NR_RegGetKey(reg, profiles, profileName, &profile)) { + NS_ERROR("Could not get the key that was enumerated."); + continue; + } + + char profilePath[MAXPATHLEN]; + if (NR_RegGetEntryString(reg, profile, "directory", + profilePath, MAXPATHLEN)) + continue; + + nsCOMPtr profileFile + (do_CreateInstance("@mozilla.org/file/local;1")); + if (!profileFile) + continue; + + rv = profileFile->InitWithNativePath(nsDependentCString(profilePath)); + if (NS_FAILED(rv)) continue; + + nsCOMPtr tprofile; + profileSvc->CreateProfile(profileFile, nsDependentCString(profileName), + getter_AddRefs(tprofile)); + migrated = PR_TRUE; + } + +cleanup: + if (reg) + NR_RegClose(reg); + NR_ShutdownRegistry(); + return migrated; +} diff --git a/mozilla/browser/components/migration/src/nsProfileMigrator.h b/mozilla/browser/components/migration/src/nsProfileMigrator.h index 976b5322327..486c1d34af9 100644 --- a/mozilla/browser/components/migration/src/nsProfileMigrator.h +++ b/mozilla/browser/components/migration/src/nsProfileMigrator.h @@ -39,30 +39,31 @@ #define profilemigrator___h___ #include "nsIBrowserProfileMigrator.h" -#include "nsIObserver.h" #include "nsIProfileMigrator.h" -#include "nsISupportsPrimitives.h" +#include "nsCOMPtr.h" -class nsProfileMigrator : public nsIProfileMigrator, - public nsIObserver +#define NS_FIREFOX_PROFILEMIGRATOR_CID \ +{ 0x4ca3c946, 0x5408, 0x49f0, { 0x9e, 0xca, 0x3a, 0x97, 0xd5, 0xc6, 0x77, 0x50 } } + +class nsProfileMigrator : public nsIProfileMigrator { public: - NS_DECL_NSIOBSERVER NS_DECL_NSIPROFILEMIGRATOR NS_DECL_ISUPPORTS nsProfileMigrator() { }; - virtual ~nsProfileMigrator() { }; protected: - nsresult OpenMigrationWizard(); - nsresult GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMigrator, - nsISupportsString** aKey, - PRBool* aNeedsActiveProfile); + ~nsProfileMigrator() { }; -private: - nsCOMPtr mMigrator; - nsCOMPtr mSourceKey; + nsresult GetDefaultBrowserMigratorKey(nsACString& key, + nsCOMPtr& bpm); + + /** + * Import profiles from ~/.firefox/ or ~/.phoenix/ + * @return PR_TRUE if any profiles imported. + */ + PRBool ImportRegistryProfiles(const nsACString& aAppName); }; #endif diff --git a/mozilla/browser/components/migration/src/nsSafariProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsSafariProfileMigrator.cpp index b08f5af3cbc..76392e08595 100644 --- a/mozilla/browser/components/migration/src/nsSafariProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsSafariProfileMigrator.cpp @@ -43,8 +43,7 @@ #include "nsILocalFileMac.h" #include "nsIObserverService.h" #include "nsIPrefService.h" -#include "nsIProfile.h" -#include "nsIProfileInternal.h" +#include "nsIProfileMigrator.h" #include "nsIProtocolHandler.h" #include "nsIRDFContainer.h" #include "nsIRDFDataSource.h" @@ -77,10 +76,18 @@ nsSafariProfileMigrator::~nsSafariProfileMigrator() // nsIBrowserProfileMigrator NS_IMETHODIMP -nsSafariProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsSafariProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; + PRBool aReplace = PR_FALSE; + + if (aStartup) { + aReplace = PR_TRUE; + rv = aStartup->DoStartup(); + NS_ENSURE_SUCCESS(rv, rv); + } + NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull); COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS); diff --git a/mozilla/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp index f640ef9d4e9..f657b06bec5 100644 --- a/mozilla/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp @@ -85,12 +85,15 @@ nsSeamonkeyProfileMigrator::~nsSeamonkeyProfileMigrator() // nsIBrowserProfileMigrator NS_IMETHODIMP -nsSeamonkeyProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile) +nsSeamonkeyProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; + PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE; - if (!mTargetProfile) - GetTargetProfile(aProfile, aReplace); + if (!mTargetProfile) { + GetProfilePath(aStartup, mTargetProfile); + if (!mTargetProfile) return NS_ERROR_FAILURE; + } if (!mSourceProfile) GetSourceProfile(aProfile); @@ -270,6 +273,11 @@ nsSeamonkeyProfileMigrator::FillProfileDataFromSeamonkeyRegistry() seamonkeyRegistry->Append(NS_LITERAL_STRING(".mozilla")); seamonkeyRegistry->Append(NS_LITERAL_STRING("appreg")); +#elif defined(XP_OS2) + fileLocator->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(seamonkeyRegistry)); + + seamonkeyRegistry->Append(NS_LITERAL_STRING("Mozilla")); + seamonkeyRegistry->Append(NS_LITERAL_STRING("registry.dat")); #endif return GetProfileDataFromRegistry(seamonkeyRegistry, mProfileNames, mProfileLocations); diff --git a/mozilla/browser/config/mozconfig b/mozilla/browser/config/mozconfig index fbdc570cef5..4c08f1c0a05 100644 --- a/mozilla/browser/config/mozconfig +++ b/mozilla/browser/config/mozconfig @@ -11,4 +11,5 @@ ac_add_options --disable-mailnews ac_add_options --enable-extensions=cookie,xml-rpc,xmlextras,pref,transformiix,universalchardet,typeaheadfind,webservices,inspector,gnomevfs,negotiateauth ac_add_options --enable-crypto ac_add_options --disable-composer +ac_add_options --enable-single-profile ac_add_options --disable-profilesharing diff --git a/mozilla/mail/app/Makefile.in b/mozilla/mail/app/Makefile.in index 748843f5b54..b609bb9be30 100644 --- a/mozilla/mail/app/Makefile.in +++ b/mozilla/mail/app/Makefile.in @@ -149,6 +149,9 @@ endif APP_VERSION = $(shell cat $(srcdir)/../config/version.txt) DEFINES += -DAPP_VERSION=\"$(APP_VERSION)\" +BUILD_ID = $(shell cat $(DEPTH)/config/build_number) +DEFINES += -DBUILD_ID=\"$(BUILD_ID)\" + ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) ifdef BUILD_STATIC_LIBS LIBS += -framework QuickTime -framework IOKit diff --git a/mozilla/mail/app/nsMailApp.cpp b/mozilla/mail/app/nsMailApp.cpp index 32efbd81eda..788e6884de3 100644 --- a/mozilla/mail/app/nsMailApp.cpp +++ b/mozilla/mail/app/nsMailApp.cpp @@ -37,24 +37,27 @@ * ***** END LICENSE BLOCK ***** */ #include "nsXULAppAPI.h" -#include "nsISoftwareUpdate.h" #ifdef XP_WIN #include +#include #endif +#include "nsBuildID.h" +#include "prtypes.h" + +static const nsXREAppData kAppData = { + 0, + "Thunderbird", + APP_VERSION, + BUILD_ID, + "Copyright (c) 2004 mozilla.org", + PR_FALSE +}; int main(int argc, char* argv[]) { - nsXREAppData appData; - appData.SetSplashEnabled(PR_FALSE); - appData.SetProductName(NS_LITERAL_CSTRING("Thunderbird")); - appData.SetUseStartupPrefs(PR_TRUE); - return xre_main(argc, argv, appData); + return xre_main(argc, argv, &kAppData); } -#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2) -char* splash_xpm[] = {0}; -#endif - #if defined( XP_WIN ) && defined( WIN32 ) && !defined(__GNUC__) // We need WinMain in order to not be a console app. This function is // unused if we are a console application. diff --git a/mozilla/mail/app/profile/thunderbird.js b/mozilla/mail/app/profile/thunderbird.js index b34bcfe8fd0..bd813aa6092 100644 --- a/mozilla/mail/app/profile/thunderbird.js +++ b/mozilla/mail/app/profile/thunderbird.js @@ -40,6 +40,47 @@ pref("general.useragent.vendorSub", #expand __APP_VERSION__ ); +// This is this application's unique identifier used by the Extension System to identify +// this application as an extension target, and by the SmartUpdate system to identify +// this application to the Update server. +pref("app.id", "{3550f703-e582-4d05-9a08-453d09bdfdc6}"); +pref("app.version", +#expand __APP_VERSION__ +); +pref("app.build_id", +#expand __BUILD_ID__ +); + +#ifdef XP_MACOSX +pref("mail.biff.animate_dock_icon", false); +#endif + +pref("update.app.enabled", true); +pref("update.app.url", "chrome://mozapps/locale/update/update.properties"); +pref("update.app.updatesAvailable", false); +pref("update.app.updateVersion", ""); +pref("update.app.updateDescription", ""); +pref("update.app.updateURL", ""); +pref("update.extensions.enabled", true); +pref("update.extensions.wsdl", "chrome://mozapps/locale/extensions/extensions.properties"); +pref("extensions.getMoreExtensionsURL", "chrome://mozapps/locale/extensions/extensions.properties"); +pref("extensions.getMoreThemesURL", "chrome://mozapps/locale/extensions/extensions.properties"); +// Automatically download and install updates to themes and extensions. +pref("update.extensions.autoUpdate", false); + +pref("update.interval", 604800000); // every 7 days +pref("update.lastUpdateDate", 0); // UTC offset when last update was performed. + +// These prefs relate to the number and severity of updates available. This is a +// cache that the browser notification mechanism uses to determine if it should show +// status bar UI if updates are detected and the app is shut down before installing +// them. +// 0 = low (extension/theme updates), 1 = medium (app minor version), 2 = high (major version) +pref("update.severity", 0); +// The number of extension/theme/etc updates available +pref("update.extensions.count", 0); + + ///////////////////////////////////////////////////////////////// // Overrides of the seamonkey suite mailnews.js prefs ///////////////////////////////////////////////////////////////// @@ -130,8 +171,10 @@ pref("network.hosts.pop_server", "mail"); pref("general.config.obscure_value", 0); // for MCD .cfg files pref("xpinstall.dialog.confirm", "chrome://communicator/content/xpinstall/institems.xul"); -pref("xpinstall.dialog.progress", "chrome://communicator/content/xpinstall/xpistatus.xul"); -pref("xpinstall.dialog.progress.type", ""); +pref("xpinstall.dialog.progress.skin", "chrome://mozapps/content/extensions/extensions.xul?type=themes"); +pref("xpinstall.dialog.progress.chrome", "chrome://mozapps/content/extensions/extensions.xul?type=extensions"); +pref("xpinstall.dialog.progress.type.skin", "Extension:Manager-themes"); +pref("xpinstall.dialog.progress.type.chrome", "Extension:Manager-extensions"); ///////////////////////////////////////////////////////////////// // End seamonkey suite all.js pref overrides diff --git a/mozilla/mail/base/content/msgHdrViewOverlay.js b/mozilla/mail/base/content/msgHdrViewOverlay.js index 99829a0bbd5..f2226b2f52f 100644 --- a/mozilla/mail/base/content/msgHdrViewOverlay.js +++ b/mozilla/mail/base/content/msgHdrViewOverlay.js @@ -834,8 +834,10 @@ function setFromBuddyIcon(email) gIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); gFileHandler = gIOService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler); - var profile = Components.classes["@mozilla.org/profile/manager;1"].getService(Components.interfaces.nsIProfileInternal); - gProfileDirURL = gIOService.newFileURI(profile.getProfileDir(profile.currentProfile)); + var dirService = Components.classes["@mozilla.org/directory_service;1"] + .getService(Components.interfaces.nsIProperties); + var profileDir = dirService.get("ProfD", Components.interfaces.nsIFile); + gProfileDirURL = gIOService.newFileURI(profileDir); } // if we did have a buddy icon on disk for this screenname, this would be the file url spec for it diff --git a/mozilla/mail/components/Makefile.in b/mozilla/mail/components/Makefile.in index 71527b9bf40..d2c5ce02fab 100644 --- a/mozilla/mail/components/Makefile.in +++ b/mozilla/mail/components/Makefile.in @@ -26,7 +26,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = compose prefwindow addrbook +DIRS = compose prefwindow addrbook migration include $(topsrcdir)/config/rules.mk diff --git a/mozilla/mail/components/addrbook/content/abCardViewOverlay.js b/mozilla/mail/components/addrbook/content/abCardViewOverlay.js index e138ef4dc0c..913597c22e5 100644 --- a/mozilla/mail/components/addrbook/content/abCardViewOverlay.js +++ b/mozilla/mail/components/addrbook/content/abCardViewOverlay.js @@ -337,8 +337,10 @@ function setBuddyIcon(card, buddyIcon) if (myScreenName && card.primaryEmail) { if (!gProfileDirURL) { // lazily create these file urls, and keep them around - var profile = Components.classes["@mozilla.org/profile/manager;1"].getService(Components.interfaces.nsIProfileInternal); - gProfileDirURL = gIOService.newFileURI(profile.getProfileDir(profile.currentProfile)); + var dirService = Components.classes["@mozilla.org/directory_service;1"] + .getService(Components.interfaces.nsIProperties); + var profileDir = dirService.get("ProfD", Components.interfaces.nsIFile); + gProfileDirURL = gIOService.newFileURI(profileDir); } // if we did have a buddy icon on disk for this screenname, this would be the file url spec for it diff --git a/mozilla/mail/config/mozconfig b/mozilla/mail/config/mozconfig index c02b5f5df52..192096f6378 100644 --- a/mozilla/mail/config/mozconfig +++ b/mozilla/mail/config/mozconfig @@ -13,6 +13,7 @@ ac_add_options --disable-activex-scripting ac_add_options --disable-tests ac_add_options --disable-oji ac_add_options --disable-necko-disk-cache +ac_add_options --enable-single-profile ac_add_options --disable-profilesharing ac_add_options --enable-extensions=wallet,spellcheck,xmlextras ac_add_options --enable-necko-protocols=http,file,jar,viewsource,res,data diff --git a/mozilla/toolkit/Makefile.in b/mozilla/toolkit/Makefile.in index c2987ffc794..b87ee6e0f56 100644 --- a/mozilla/toolkit/Makefile.in +++ b/mozilla/toolkit/Makefile.in @@ -43,7 +43,15 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = content locale obsolete xre components mozapps +DIRS = \ + content \ + locale \ + obsolete \ + profile \ + xre \ + components \ + mozapps \ + $(NULL) ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) # Use Pinstripe on MacOS X diff --git a/mozilla/toolkit/components/Makefile.in b/mozilla/toolkit/components/Makefile.in index 7767577f353..5883ff6fb77 100644 --- a/mozilla/toolkit/components/Makefile.in +++ b/mozilla/toolkit/components/Makefile.in @@ -59,7 +59,6 @@ DIRS = \ history \ passwordmgr \ printing \ - profile \ satchel \ viewconfig \ viewsource \ diff --git a/mozilla/toolkit/components/profile/Makefile.in b/mozilla/toolkit/components/profile/Makefile.in deleted file mode 100644 index 21385d99772..00000000000 --- a/mozilla/toolkit/components/profile/Makefile.in +++ /dev/null @@ -1,32 +0,0 @@ -# -# The contents of this file are subject to the Netscape 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/NPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DIRS = public - -include $(topsrcdir)/config/rules.mk - diff --git a/mozilla/toolkit/components/profile/public/Makefile.in b/mozilla/toolkit/components/profile/public/Makefile.in deleted file mode 100644 index f1b5befc2ad..00000000000 --- a/mozilla/toolkit/components/profile/public/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# -# The contents of this file are subject to the Netscape 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/NPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = profilemanager - -XPIDLSRCS = nsIProfileMigrator.idl - -include $(topsrcdir)/config/rules.mk - diff --git a/mozilla/toolkit/content/globalOverlay.js b/mozilla/toolkit/content/globalOverlay.js index 9a6298bc1f6..d4742d42adf 100644 --- a/mozilla/toolkit/content/globalOverlay.js +++ b/mozilla/toolkit/content/globalOverlay.js @@ -64,8 +64,7 @@ function goQuitApplication() return false; domWindow.close(); }; - if (!nativeAppSupport || !nativeAppSupport.isServerMode) - appShell.quit(Components.interfaces.nsIAppShellService.eAttemptQuit); + appShell.quit(Components.interfaces.nsIAppShellService.eAttemptQuit); return true; } diff --git a/mozilla/toolkit/mozapps/extensions/content/extensions.js b/mozilla/toolkit/mozapps/extensions/content/extensions.js index 1d98434417a..5e261de3ce8 100644 --- a/mozilla/toolkit/mozapps/extensions/content/extensions.js +++ b/mozilla/toolkit/mozapps/extensions/content/extensions.js @@ -5,7 +5,7 @@ const kObserverServiceProgID = "@mozilla.org/observer-service;1"; const nsIUpdateItem = Components.interfaces.nsIUpdateItem; var gExtensionManager = null; -var gExtensionssView = null; +var gExtensionsView = null; var gWindowState = ""; var gURIPrefix = ""; // extension or theme prefix var gDSRoot = ""; // extension or theme root @@ -17,6 +17,7 @@ var gObserverIndex = -1; const PREF_APP_ID = "app.id"; const PREF_EXTENSIONS_GETMORETHEMESURL = "extensions.getMoreThemesURL"; const PREF_EXTENSIONS_GETMOREEXTENSIONSURL = "extensions.getMoreExtensionsURL"; +const PREF_EM_LAST_SELECTED_SKIN = "extensions.lastSelectedSkin"; const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin"; /////////////////////////////////////////////////////////////////////////////// @@ -36,8 +37,7 @@ function openURL(aURL) var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"] .getService(Components.interfaces.nsIExternalProtocolService); - if (protocolSvc.isExposedProtocol(uri.scheme)) - protocolSvc.loadUrl(uri); + protocolSvc.loadUrl(uri); # If we're a browser, open a new browser window instead. #else openDialog("chrome://browser/content/browser.xul", "_blank", "chrome,all,dialog=no", aURL, null, null); @@ -93,10 +93,9 @@ function Startup() .getService(Components.interfaces.nsIPrefBranch); if (!isExtensions) { gExtensionsView.addEventListener("richview-select", onThemeSelect, false); - try { - gCurrentTheme = pref.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN); - } - catch (e) { gCurrentTheme = "classic/1.0"; } + var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"] + .getService(Components.interfaces.nsIXULChromeRegistry); + gCurrentTheme = cr.getSelectedSkin("global"); var useThemeButton = document.getElementById("useThemeButton"); useThemeButton.hidden = false; @@ -247,7 +246,6 @@ XPInstallDownloadManager.prototype = { { const nsIXPIProgressDialog = Components.interfaces.nsIXPIProgressDialog; var element = document.getElementById(aURL); - dump("*** aURL = " + aURL + "\n"); if (!element) return; switch (aState) { case nsIXPIProgressDialog.DOWNLOAD_START: @@ -261,6 +259,7 @@ XPInstallDownloadManager.prototype = { element.setAttribute("state", "installing"); break; case nsIXPIProgressDialog.INSTALL_DONE: + dump("*** state change = " + aURL + ", state = " + aState + ", value = " + aValue + "\n"); element.setAttribute("state", "done"); var msg; if (aValue != 0) { @@ -570,6 +569,10 @@ var gExtensionsViewController = { case "cmd_movedn": var children = gExtensionsView.children; return (children[children.length-1] != selectedItem); +#ifdef MOZ_THUNDERBIRD + case "cmd_install": + return true; +#endif } return false; }, @@ -601,17 +604,24 @@ var gExtensionsViewController = { cmd_useTheme: function () { var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"] - .getService(Components.interfaces.nsIXULChromeRegistry); + .getService(Components.interfaces.nsIXULChromeRegistry); var pref = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); + .getService(Components.interfaces.nsIPrefBranch); gCurrentTheme = gExtensionsView.selected.getAttribute("internalName"); var inUse = cr.isSkinSelected(gCurrentTheme , true); if (inUse == Components.interfaces.nsIChromeRegistry.FULL) return; pref.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, gCurrentTheme); + + // Set this pref so the user can reset the theme in safe mode + pref.setCharPref(PREF_EM_LAST_SELECTED_SKIN, gCurrentTheme); cr.selectSkin(gCurrentTheme, true); cr.refreshSkins(); + + + // disable the useThemeButton + gExtensionsViewController.onCommandUpdate(); }, cmd_options: function () @@ -640,65 +650,22 @@ var gExtensionsViewController = { cmd_movetop: function () { - var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); - - var extensions = rdfs.GetResource("urn:mozilla:extension:root"); - var container = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer); - container.Init(gExtensionManager.datasource, extensions); - var movingID = gExtensionsView.selected.id; - var extension = rdfs.GetResource(movingID); - var index = container.IndexOf(extension); - if (index > 1) { - container.RemoveElement(extension, false); - container.InsertElementAt(extension, 1, true); - } - - flushDataSource(); - + gExtensionManager.moveTop(stripPrefix(movingID)); gExtensionsView.selected = document.getElementById(movingID); }, cmd_moveup: function () { - var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); - - var extensions = rdfs.GetResource("urn:mozilla:extension:root"); - var container = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer); - container.Init(gExtensionManager.datasource, extensions); - var movingID = gExtensionsView.selected.id; - var extension = rdfs.GetResource(movingID); - var index = container.IndexOf(extension); - if (index > 1) { - container.RemoveElement(extension, false); - container.InsertElementAt(extension, index - 1, true); - } - - flushDataSource(); - + gExtensionManager.moveUp(stripPrefix(movingID)); gExtensionsView.selected = document.getElementById(movingID); }, cmd_movedn: function () { - var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); - - var extensions = rdfs.GetResource("urn:mozilla:extension:root"); - var container = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer); - container.Init(gExtensionManager.datasource, extensions); - var movingID = gExtensionsView.selected.id; - var extension = rdfs.GetResource(movingID); - var index = container.IndexOf(extension); - var count = container.GetCount(); - if (index < count) { - container.RemoveElement(extension, true); - container.InsertElementAt(extension, index + 1, true); - } - - flushDataSource(); - + gExtensionManager.moveDown(stripPrefix(movingID)); gExtensionsView.selected = document.getElementById(movingID); }, @@ -757,9 +724,74 @@ var gExtensionsViewController = { { gExtensionManager.enableExtension(stripPrefix(gExtensionsView.selected.id)); }, +#ifdef MOZ_THUNDERBIRD + cmd_install: function() + { + if (gWindowState == "extensions") + installExtension(); + else + installSkin(); + }, +#endif } }; +#ifdef MOZ_THUNDERBIRD +/////////////////////////////////////////////////////////////// +// functions to support installing of themes in thunderbird +/////////////////////////////////////////////////////////////// +const nsIFilePicker = Components.interfaces.nsIFilePicker; +const nsIIOService = Components.interfaces.nsIIOService; +const nsIFileProtocolHandler = Components.interfaces.nsIFileProtocolHandler; +const nsIURL = Components.interfaces.nsIURL; + +function installSkin() +{ + // 1) Prompt the user for the location of the theme to install. + var extensionsStrings = document.getElementById("extensionsStrings"); + + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + fp.init(window, extensionsStrings.getString("installThemePickerTitle"), nsIFilePicker.modeOpen); + + + fp.appendFilter(extensionsStrings.getString("themesFilter"), "*.jar"); + fp.appendFilters(nsIFilePicker.filterAll); + + var ret = fp.show(); + if (ret == nsIFilePicker.returnOK) + { + var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(nsIIOService); + var fileProtocolHandler = + ioService.getProtocolHandler("file").QueryInterface(nsIFileProtocolHandler); + var url = fileProtocolHandler.newFileURI(fp.file).QueryInterface(nsIURL); + InstallTrigger.installChrome(InstallTrigger.SKIN, url.spec, decodeURIComponent(url.fileBaseName)); + } +} + +function installExtension() +{ + var extensionsStrings = document.getElementById("extensionsStrings"); + + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + fp.init(window, extensionsStrings.getString("installExtensionPickerTitle"), nsIFilePicker.modeOpen); + + fp.appendFilter(extensionsStrings.getString("extensionFilter"), "*.xpi"); + + fp.appendFilters(nsIFilePicker.filterAll); + + var ret = fp.show(); + if (ret == nsIFilePicker.returnOK) + { + var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(nsIIOService); + var fileProtocolHandler = + ioService.getProtocolHandler("file").QueryInterface(nsIFileProtocolHandler); + var url = fileProtocolHandler.newFileURI(fp.file).QueryInterface(nsIURL); + var xpi = {}; + xpi[decodeURIComponent(url.fileBaseName)] = url.spec; + InstallTrigger.install(xpi); + } +} +#endif # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # Version: MPL 1.1/GPL 2.0/LGPL 2.1 diff --git a/mozilla/toolkit/mozapps/extensions/content/extensions.xml b/mozilla/toolkit/mozapps/extensions/content/extensions.xml index fbdae125519..a786c3feed8 100644 --- a/mozilla/toolkit/mozapps/extensions/content/extensions.xml +++ b/mozilla/toolkit/mozapps/extensions/content/extensions.xml @@ -74,14 +74,13 @@ #else tooltiptext="&optionsUnix.tooltip;" #endif - tooltiptext="&options.tooltip;" - onclick="this.parentNode.parentNode.parentNode.fireEvent('options');"/> + onclick="gExtensionsViewController.doCommand('cmd_options');"/> + onclick="gExtensionsViewController.doCommand('cmd_about');"/> + onclick="gExtensionsViewController.doCommand('cmd_homepage');"/> diff --git a/mozilla/toolkit/mozapps/extensions/content/extensions.xul b/mozilla/toolkit/mozapps/extensions/content/extensions.xul index 7b6f21b5dbb..4f4ae90509c 100644 --- a/mozilla/toolkit/mozapps/extensions/content/extensions.xul +++ b/mozilla/toolkit/mozapps/extensions/content/extensions.xul @@ -85,6 +85,9 @@ +#ifdef MOZ_THUNDERBIRD + +#endif @@ -246,6 +249,11 @@ +#ifdef MOZ_THUNDERBIRD +