From ed2afb145b9f057858d5c31d155cc46b75b21c62 Mon Sep 17 00:00:00 2001 From: "ben%bengoodger.com" Date: Tue, 24 Feb 2004 05:35:32 +0000 Subject: [PATCH] Make migration wizard more generic and less complex --- .../components/migration/content/migration.js | 136 +++++------------- .../migration/content/migration.xul | 18 +++ .../components/migration/locale/migration.dtd | 14 +- .../migration/locale/migration.properties | 93 +++++++----- .../src/nsBrowserProfileMigratorUtils.h | 8 +- .../src/nsDogbertProfileMigrator.cpp | 8 +- .../migration/src/nsIEProfileMigrator.cpp | 34 +++-- .../src/nsNetscapeProfileMigratorBase.cpp | 14 +- .../src/nsNetscapeProfileMigratorBase.h | 2 +- .../migration/src/nsOperaProfileMigrator.cpp | 28 ++-- .../migration/src/nsSafariProfileMigrator.cpp | 8 +- .../src/nsSeamonkeyProfileMigrator.cpp | 14 +- 12 files changed, 200 insertions(+), 177 deletions(-) diff --git a/browser/components/migration/content/migration.js b/browser/components/migration/content/migration.js index 51e0025a6183..81c3c90d02d3 100644 --- a/browser/components/migration/content/migration.js +++ b/browser/components/migration/content/migration.js @@ -1,44 +1,9 @@ -const nsIBPM = Components.interfaces.nsIBrowserProfileMigrator; - -function MigrationItem(aID, aKey) -{ - this._id = aID; - this._key = aKey; -} +const kIMig = Components.interfaces.nsIBrowserProfileMigrator; var MigrationWizard = { - _items: [new MigrationItem(nsIBPM.SETTINGS, "settings"), - new MigrationItem(nsIBPM.COOKIES, "cookies"), - new MigrationItem(nsIBPM.HISTORY, "history"), - new MigrationItem(nsIBPM.FORMDATA, "formdata"), - new MigrationItem(nsIBPM.PASSWORDS, "passwords"), - new MigrationItem(nsIBPM.BOOKMARKS, "bookmarks"), - new MigrationItem(nsIBPM.OTHERDATA, "otherdata")], - _dataSources: { -#ifdef XP_WIN - "ie": { _migrate: [nsIBPM.SETTINGS, nsIBPM.COOKIES, nsIBPM.HISTORY, nsIBPM.FORMDATA, nsIBPM.PASSWORDS, nsIBPM.BOOKMARKS], - _import: [0, 1, 2, 3, 4, 5] }, -#endif -#ifdef XP_MACOSX - "safari": { _migrate: [nsIBPM.SETTINGS, nsIBPM.COOKIES, nsIBPM.HISTORY, nsIBPM.BOOKMARKS], - _import: [0, 1, 2, 5] }, - "omniweb": { _migrate: [], - _import: [] }, - "macie": { _migrate: [], - _import: [] }, -#endif - "opera": { _migrate: [nsIBPM.SETTINGS, nsIBPM.COOKIES, nsIBPM.HISTORY, nsIBPM.BOOKMARKS, nsIBPM.OTHERDATA], - _import: [0, 1, 2, 5, 6] }, - "dogbert": { _migrate: [nsIBPM.SETTINGS, nsIBPM.COOKIES, nsIBPM.BOOKMARKS], - _import: [1, 5] }, - "seamonkey":{ _migrate: [nsIBPM.SETTINGS, nsIBPM.COOKIES, nsIBPM.HISTORY, nsIBPM.PASSWORDS, nsIBPM.BOOKMARKS, nsIBPM.OTHERDATA], - _import: [1, 4, 5] }, - }, - - _source: "", - _itemsFlags: 0, - _selectedIndices: [], - _selectedProfile: null, + _source: "", // Source Profile Migrator ContractID suffix + _itemsFlags: kIMig.ALL, // Selected Import Data Sources (32-bit bitfield) + _selectedProfile: null, // Selected Profile name to import from _wiz: null, _migrator: null, _autoMigrate: false, @@ -56,7 +21,7 @@ var MigrationWizard = { if ("arguments" in window) { this._source = window.arguments[0]; this._migrator = window.arguments[1].QueryInterface(nsIBPM); - this._automigrate = true; + this._autoMigrate = true; // Advance past the first page this._wiz.advance(); @@ -76,14 +41,23 @@ var MigrationWizard = { onImportSourcePageShow: function () { document.documentElement.getButton("back").disabled = true; + + // Figure out what source apps are are available to import from: + var group = document.getElementById("importSourceGroup"); + for (var i = 0; i < group.childNodes.length; ++i) { + var suffix = group.childNodes[i].id; + var contractID = "@mozilla.org/profile/migrator;1?app=browser&type=" + suffix; + var migrator = Components.classes[contractID].createInstance(nsIBPM); + if (!migrator.sourceExists) + group.childNodes[i].setAttribute("hidden", "true"); + } - var importSourceGroup = document.getElementById("importSourceGroup"); - importSourceGroup.selectedItem = document.getElementById(this._source == "" ? "ie" : this._source); + group.selectedItem = this._source == "" ? group.firstChild : document.getElementById(this._source); }, onImportSourcePageAdvanced: function () { - if (!this._automigrate) + if (!this._autoMigrate) this._source = document.getElementById("importSourceGroup").selectedItem.id; // Create the migrator for the selected source. @@ -93,30 +67,14 @@ var MigrationWizard = { this._migrator = Components.classes[contractID].createInstance(nsIBPM); } - dump("*** source = " + this._source + "\n"); - - switch (this._source) { -# Opera only supports profiles on Windows. -#ifdef XP_WIN - case "opera": -#endif - case "dogbert": - case "seamonkey": - // check for more than one Opera profile - this._wiz.currentPage.next = this._migrator.sourceHasMultipleProfiles ? "selectProfile" : "importItems"; - break; - default: - // Don't show the Select Profile page for sources that don't support - // multiple profiles - this._wiz.currentPage.next = "importItems"; - break; - } + // check for more than one source profile + this._wiz.currentPage.next = this._migrator.sourceHasMultipleProfiles ? "selectProfile" : "importItems"; }, // 2 - [Profile Selection] onSelectProfilePageShow: function () { - if (this._automigrate) + if (this._autoMigrate) document.documentElement.getButton("back").disabled = true; var profiles = document.getElementById("profiles"); @@ -148,11 +106,8 @@ var MigrationWizard = { this._selectedProfile = profiles.selectedItem.id; // If we're automigrating, don't show the item selection page, just grab everything. - if (this._automigrate) { - this._itemsFlags = nsIBPM.ALL; - this._selectedIndices = this._dataSources[this._source]._migrate; + if (this._autoMigrate) this._wiz.currentPage.next = "migrating"; - } }, // 3 - ImportItems @@ -164,14 +119,14 @@ var MigrationWizard = { var bundle = document.getElementById("bundle"); - var ds = this._dataSources[this._source]._import; - for (var i = 0; i < ds.length; ++i) { - var item = this._items[ds[i]]; + var items = this._migrator.getMigrateData(this._selectedProfile); + for (var i = 0; i < 32; ++i) { + var itemID = Math.pow(2, (items >> i) & 0x1); var checkbox = document.createElement("checkbox"); - checkbox.id = item._id; - checkbox.setAttribute("label", bundle.getString(item._key + "_" + this._source)); + checkbox.id = itemID; + checkbox.setAttribute("label", bundle.getString(itemID + "_" + this._source)); dataSources.appendChild(checkbox); - if (!this._itemsFlags || this._itemsFlags & item._id) + if (!this._itemsFlags || this._itemsFlags & itemID) checkbox.checked = true; } }, @@ -179,18 +134,12 @@ var MigrationWizard = { onImportItemsPageAdvanced: function () { var dataSources = document.getElementById("dataSources"); - var params = 0; - this._selectedIndices = []; + this._itemsFlags = 0; for (var i = 0; i < dataSources.childNodes.length; ++i) { var checkbox = dataSources.childNodes[i]; - if (checkbox.localName == "checkbox") { - if (checkbox.checked) { - params |= parseInt(checkbox.id); - this._selectedIndices.push(parseInt(checkbox.id)); - } - } + if (checkbox.localName == "checkbox" && checkbox.checked) + this._itemsFlags |= parseInt(checkbox.id); } - this._itemsFlags = params; }, onImportItemCommand: function (aEvent) @@ -218,7 +167,7 @@ var MigrationWizard = { onMigratingMigrate: function (aOuter) { - aOuter._migrator.migrate(aOuter._itemsFlags, aOuter._automigrate, aOuter._selectedProfile); + aOuter._migrator.migrate(aOuter._itemsFlags, aOuter._autoMigrate, aOuter._selectedProfile); }, _listItems: function (aID) @@ -227,44 +176,37 @@ var MigrationWizard = { while (items.hasChildNodes()) items.removeChild(items.firstChild); - var idToIndex = { "1": 0, "2": 1, "4": 2, "8": 3, "16": 4, "32": 5, "64": 6 }; var bundle = document.getElementById("bundle"); - for (var i = 0; i < this._selectedIndices.length; ++i) { - var index = this._selectedIndices[i]; + for (var i = 0; i < 32; ++i) { + var itemID = Math.pow(2, (this._itemsFlags >> i) & 0x1); var label = document.createElement("label"); - var item = this._items[idToIndex[index.toString()]]; - label.id = item._key; - label.setAttribute("value", bundle.getString(item._key + "_" + this._source)); + label.id = itemID + "_migrated"; + label.setAttribute("value", bundle.getString(itemID + "_" + this._source)); items.appendChild(label); - } + } }, observe: function (aSubject, aTopic, aData) { - var itemToIndex = { "settings": 0, "cookies": 1, "history": 2, "formdata": 3, "passwords": 4, "bookmarks": 5, "otherdata": 6 }; switch (aTopic) { case "Migration:Started": dump("*** started\n"); break; case "Migration:ItemBeforeMigrate": dump("*** before " + aData + "\n"); - var index = itemToIndex[aData]; - var item = this._items[index]; - var label = document.getElementById(item._key); + var label = document.getElementById(aData + "_migrated"); if (label) label.setAttribute("style", "font-weight: bold"); break; case "Migration:ItemAfterMigrate": dump("*** after " + aData + "\n"); - var index = itemToIndex[aData]; - var item = this._items[index]; - var label = document.getElementById(item._key); + var label = document.getElementById(aData + "_migrated"); if (label) label.removeAttribute("style"); break; case "Migration:Ended": dump("*** done\n"); - if (this._automigrate) { + if (this._autoMigrate) { // We're done now. window.close(); } diff --git a/browser/components/migration/content/migration.xul b/browser/components/migration/content/migration.xul index 29141a10eca8..fc91d3f0f120 100644 --- a/browser/components/migration/content/migration.xul +++ b/browser/components/migration/content/migration.xul @@ -58,13 +58,31 @@ &importFrom.label; +#ifdef XP_UNIX #ifdef XP_MACOSX + + + + + + + +#else + + + + + + #endif +#endif +#ifdef XP_WIN +#endif diff --git a/browser/components/migration/locale/migration.dtd b/browser/components/migration/locale/migration.dtd index ed80d68e0658..af810e2bcb85 100644 --- a/browser/components/migration/locale/migration.dtd +++ b/browser/components/migration/locale/migration.dtd @@ -11,8 +11,20 @@ + + - + + + + + + + + + + + diff --git a/browser/components/migration/locale/migration.properties b/browser/components/migration/locale/migration.properties index 78952f84d36c..c130d7aa7b49 100644 --- a/browser/components/migration/locale/migration.properties +++ b/browser/components/migration/locale/migration.properties @@ -1,45 +1,64 @@ -settings_ie=Internet Options -settings_opera=Preferences -settings_dogbert=Preferences -settings_seamonkey=Preferences -settings_safari=Preferences -cookies_ie=Cookies -cookies_opera=Cookies -cookies_dogbert=Cookies -cookies_seamonkey=Cookies -cookies_safari=Cookies -history_ie=Browsing History -history_opera=Browsing History -history_dogbert=Browsing History -history_seamonkey=Browsing History -history_safari=Browsing History -formdata_ie=Saved Form History -formdata_opera=Saved Form History -formdata_dogbert=Saved Form History -formdata_seamonkey=Saved Form History -passwords_ie=Saved Passwords -passwords_opera=Saved Passwords -passwords_dogbert=Saved Passwords -passwords_seamonkey=Saved Passwords -bookmarks_ie=Favorites -bookmarks_opera=Bookmarks -bookmarks_dogbert=Bookmarks -bookmarks_seamonkey=Bookmarks -bookmarks_safari=Bookmarks -otherdata_ie=Other Data -otherdata_opera=Other Data -otherdata_dogbert=Other Data -otherdata_seamonkey=Other Data - profileName_format=%S %S -importedIEFavsTitle=From Internet Explorer -importedIESearchUrls=Keyword Searches (From Internet Explorer) -importedIESearchUrlTitle=Search on %S +# Browser Specific +sourceNameIE=Internet Explorer +sourceNameSeamonkey=Netscape 6/7/Mozilla +sourceNameDogbert=Netscape 4 +sourceNameOpera=Opera +sourceNameSafari=Safari +sourceNameOmniWeb=OmniWeb +sourceNameCamino=Camino +sourceNameICab=iCab +sourceNameKonqueror=Konqueror +sourceNameEpiphany=Epiphany +sourceNameGaleon=Galeon + +importedBookmarksFolder=From %S +importedSearchURLsFolder=Keyword Searches (From %S) +importedSearchURLsTitle=Search on %S +importedSearchUrlDesc=Type "%S " in the Location Bar to perform a search on %S. + importedDogbertBookmarksTitle=From Netscape 4 importedSeamonkeyBookmarksTitle=From Netscape 6/7/Mozilla importedSafariBookmarks=From Safari importedOperaHotlistTitle=From Opera importedOperaSearchUrls=Keyword Searches (From Opera) -importedSearchUrlDesc=Type "%S " in the Location Bar to perform a search on %S. + +# Import Sources +1_ie=Internet Options +1_opera=Preferences +1_dogbert=Preferences +1_seamonkey=Preferences + +2_ie=Cookies +2_opera=Cookies +2_dogbert=Cookies +2_seamonkey=Cookies + +4_ie=Browsing History +4_opera=Browsing History +4_dogbert=Browsing History +4_seamonkey=Browsing History + +8_ie=Saved Form History +8_opera=Saved Form History +8_dogbert=Saved Form History +8_seamonkey=Saved Form History + +16_ie=Saved Passwords +16_opera=Saved Passwords +16_dogbert=Saved Passwords +16_seamonkey=Saved Passwords + +32_ie=Favorites +32_opera=Bookmarks +32_dogbert=Bookmarks +32_seamonkey=Bookmarks + +64_ie=Other Data +64_opera=Other Data +64_dogbert=Other Data +64_seamonkey=Other Data + + diff --git a/browser/components/migration/src/nsBrowserProfileMigratorUtils.h b/browser/components/migration/src/nsBrowserProfileMigratorUtils.h index 719d603107b7..38a23fad6f8d 100644 --- a/browser/components/migration/src/nsBrowserProfileMigratorUtils.h +++ b/browser/components/migration/src/nsBrowserProfileMigratorUtils.h @@ -47,11 +47,13 @@ if (sObserverService) \ sObserverService->NotifyObservers(nsnull, message, item) -#define COPY_DATA(func, replace, itemIndex, itemString) \ +#define COPY_DATA(func, replace, itemIndex) \ if (NS_SUCCEEDED(rv) && (aItems & itemIndex || !aItems)) { \ - NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, itemString); \ + nsAutoString index; \ + index.AppendInt(itemIndex); \ + NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get()); \ rv = func(replace); \ - NOTIFY_OBSERVERS(MIGRATION_ITEMAFTERMIGRATE, itemString); \ + NOTIFY_OBSERVERS(MIGRATION_ITEMAFTERMIGRATE, index.get()); \ } #include "nsIPrefBranch.h" diff --git a/browser/components/migration/src/nsDogbertProfileMigrator.cpp b/browser/components/migration/src/nsDogbertProfileMigrator.cpp index c2b1c5b0ad48..a63cfe4ecda5 100644 --- a/browser/components/migration/src/nsDogbertProfileMigrator.cpp +++ b/browser/components/migration/src/nsDogbertProfileMigrator.cpp @@ -120,9 +120,9 @@ nsDogbertProfileMigrator::Migrate(PRUint32 aItems, PRBool aReplace, const PRUnic if (!mSourceProfile) GetSourceProfile(aProfile); - COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS, NS_LITERAL_STRING("settings").get()); - COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES, NS_LITERAL_STRING("cookies").get()); - COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS, NS_LITERAL_STRING("bookmarks").get()); + COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS); + COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES); + COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS); NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull); @@ -464,7 +464,7 @@ nsDogbertProfileMigrator::CopyBookmarks(PRBool aReplace) return MigrateDogbertBookmarks(); return ImportNetscapeBookmarks(BOOKMARKS_FILE_NAME_IN_4x, - NS_LITERAL_STRING("importedDogbertBookmarksTitle").get()); + NS_LITERAL_STRING("sourceNameSeamonkey").get()); } nsresult diff --git a/browser/components/migration/src/nsIEProfileMigrator.cpp b/browser/components/migration/src/nsIEProfileMigrator.cpp index dd44a64f690d..a2da591969d0 100644 --- a/browser/components/migration/src/nsIEProfileMigrator.cpp +++ b/browser/components/migration/src/nsIEProfileMigrator.cpp @@ -433,12 +433,12 @@ nsIEProfileMigrator::Migrate(PRUint32 aItems, PRBool aReplace, const PRUnichar* NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull); - COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS, NS_LITERAL_STRING("settings").get()); - COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES, NS_LITERAL_STRING("cookies").get()); - COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY, NS_LITERAL_STRING("history").get()); - COPY_DATA(CopyFormData, aReplace, nsIBrowserProfileMigrator::FORMDATA, NS_LITERAL_STRING("formdata").get()); - COPY_DATA(CopyPasswords, aReplace, nsIBrowserProfileMigrator::PASSWORDS, NS_LITERAL_STRING("passwords").get()); - COPY_DATA(CopyFavorites, aReplace, nsIBrowserProfileMigrator::BOOKMARKS, NS_LITERAL_STRING("bookmarks").get()); + COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS); + COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES); + COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY); + COPY_DATA(CopyFormData, aReplace, nsIBrowserProfileMigrator::FORMDATA); + COPY_DATA(CopyPasswords, aReplace, nsIBrowserProfileMigrator::PASSWORDS); + COPY_DATA(CopyFavorites, aReplace, nsIBrowserProfileMigrator::BOOKMARKS); NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull); @@ -1033,8 +1033,14 @@ nsIEProfileMigrator::CopyFavorites(PRBool aReplace) { nsCOMPtr bundle; bundleService->CreateBundle(TRIDENTPROFILE_BUNDLE, getter_AddRefs(bundle)); + nsXPIDLString sourceNameIE; + bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameIE").get(), + getter_Copies(sourceNameIE)); + + const PRUnichar* sourceNameStrings[] = { sourceNameIE.get() }; nsXPIDLString importedIEFavsTitle; - bundle->GetStringFromName(NS_LITERAL_STRING("importedIEFavsTitle").get(), getter_Copies(importedIEFavsTitle)); + bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), + sourceNameStrings, 1, getter_Copies(importedIEFavsTitle)); bms->CreateFolderInContainer(importedIEFavsTitle.get(), root, -1, getter_AddRefs(folder)); } @@ -1098,10 +1104,16 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder) break; if (!keywordsFolder) { - nsXPIDLString importedIESearchUrlsTitle; - bundle->GetStringFromName(NS_LITERAL_STRING("importedIESearchUrls").get(), getter_Copies(importedIESearchUrlsTitle)); + nsXPIDLString sourceNameIE; + bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameIE").get(), + getter_Copies(sourceNameIE)); - bms->CreateFolderInContainer(importedIESearchUrlsTitle.get(), aParentFolder, -1, getter_AddRefs(keywordsFolder)); + const PRUnichar* sourceNameStrings[] = { sourceNameIE.get() }; + nsXPIDLString importedIESearchUrlsTitle; + bundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(), + sourceNameStrings, 1, getter_Copies(importedIESearchUrlsTitle)); + bms->CreateFolderInContainer(importedIESearchUrlsTitle.get(), aParentFolder, -1, + getter_AddRefs(keywordsFolder)); } nsCAutoString keyNameStr(keyName); @@ -1121,7 +1133,7 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder) const PRUnichar* nameStrings[] = { host.get() }; nsXPIDLString keywordName; - rv = bundle->FormatStringFromName(NS_LITERAL_STRING("importedIESearchUrlTitle").get(), + rv = bundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsTitle").get(), nameStrings, 1, getter_Copies(keywordName)); nsAutoString keyword; keyword.AssignWithConversion(keyName); diff --git a/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp b/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp index 3547be14b13e..ee40ed699523 100644 --- a/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp +++ b/browser/components/migration/src/nsNetscapeProfileMigratorBase.cpp @@ -264,7 +264,7 @@ nsNetscapeProfileMigratorBase::CopyFile(const nsAString& aSourceFileName, const nsresult nsNetscapeProfileMigratorBase::ImportNetscapeBookmarks(const nsAString& aBookmarksFileName, - const PRUnichar* aImportFolderTitleKey) + const PRUnichar* aImportSourceNameKey) { nsCOMPtr bookmarksFile; mSourceProfile->Clone(getter_AddRefs(bookmarksFile)); @@ -293,11 +293,17 @@ nsNetscapeProfileMigratorBase::ImportNetscapeBookmarks(const nsAString& aBookmar nsCOMPtr root; rdfs->GetResource(NS_LITERAL_CSTRING("NC:BookmarksRoot"), getter_AddRefs(root)); - nsXPIDLString importedDogbertBookmarksTitle; - mBundle->GetStringFromName(aImportFolderTitleKey, getter_Copies(importedDogbertBookmarksTitle)); + nsXPIDLString sourceName; + mBundle->GetStringFromName(aImportSourceNameKey, getter_Copies(sourceName)); + + const PRUnichar* sourceNameStrings[] = { sourceName.get() }; + nsXPIDLString importedBookmarksTitle; + mBundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), + sourceNameStrings, 1, + getter_Copies(importedBookmarksTitle)); nsCOMPtr folder; - bms->CreateFolderInContainer(importedDogbertBookmarksTitle.get(), root, -1, getter_AddRefs(folder)); + bms->CreateFolderInContainer(importedBookmarksTitle.get(), root, -1, getter_AddRefs(folder)); nsCOMPtr folderProp; rdfs->GetResource(NS_LITERAL_CSTRING("http://home.netscape.com/NC-rdf#Folder"), diff --git a/browser/components/migration/src/nsNetscapeProfileMigratorBase.h b/browser/components/migration/src/nsNetscapeProfileMigratorBase.h index 17e9edecd9b4..b4faad95f3f0 100644 --- a/browser/components/migration/src/nsNetscapeProfileMigratorBase.h +++ b/browser/components/migration/src/nsNetscapeProfileMigratorBase.h @@ -85,7 +85,7 @@ protected: nsresult CopyFile(const nsAString& aSourceFileName, const nsAString& aTargetFileName); nsresult ImportNetscapeBookmarks(const nsAString& aBookmarksFileName, - const PRUnichar* aImportFolderTitleKey); + const PRUnichar* aImportSourceNameKey); protected: nsCOMPtr mSourceProfile; diff --git a/browser/components/migration/src/nsOperaProfileMigrator.cpp b/browser/components/migration/src/nsOperaProfileMigrator.cpp index c04c7779dc18..18332d49bf27 100644 --- a/browser/components/migration/src/nsOperaProfileMigrator.cpp +++ b/browser/components/migration/src/nsOperaProfileMigrator.cpp @@ -109,10 +109,10 @@ nsOperaProfileMigrator::Migrate(PRUint32 aItems, PRBool aReplace, const PRUnicha NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull); - COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS, NS_LITERAL_STRING("settings").get()); - COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES, NS_LITERAL_STRING("cookies").get()); - COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY, NS_LITERAL_STRING("history").get()); - COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS, NS_LITERAL_STRING("bookmarks").get()); + COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS); + COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES); + COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY); + COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS); NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull); @@ -909,9 +909,15 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace) getter_AddRefs(root)); nsCOMPtr parentFolder; if (!aReplace) { + nsXPIDLString sourceNameOpera; + bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(), + getter_Copies(sourceNameOpera)); + + const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() }; nsXPIDLString importedOperaHotlistTitle; - bundle->GetStringFromName(NS_LITERAL_STRING("importedOperaHotlistTitle").get(), - getter_Copies(importedOperaHotlistTitle)); + bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), + sourceNameStrings, 1, + getter_Copies(importedOperaHotlistTitle)); bms->CreateFolderInContainer(importedOperaHotlistTitle.get(), root, -1, getter_AddRefs(parentFolder)); @@ -954,9 +960,15 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS, if (!parser) return NS_ERROR_OUT_OF_MEMORY; + nsXPIDLString sourceNameOpera; + aBundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(), + getter_Copies(sourceNameOpera)); + + const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() }; nsXPIDLString importedSearchUrlsTitle; - aBundle->GetStringFromName(NS_LITERAL_STRING("importedOperaSearchUrls").get(), - getter_Copies(importedSearchUrlsTitle)); + aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(), + sourceNameStrings, 1, + getter_Copies(importedSearchUrlsTitle)); nsCOMPtr keywordsFolder; aBMS->CreateFolderInContainer(importedSearchUrlsTitle.get(), diff --git a/browser/components/migration/src/nsSafariProfileMigrator.cpp b/browser/components/migration/src/nsSafariProfileMigrator.cpp index 1a9a7afa6d2d..d4d8371ce20c 100644 --- a/browser/components/migration/src/nsSafariProfileMigrator.cpp +++ b/browser/components/migration/src/nsSafariProfileMigrator.cpp @@ -90,10 +90,10 @@ nsSafariProfileMigrator::Migrate(PRUint32 aItems, PRBool aReplace, const PRUnich NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull); - COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS, NS_LITERAL_STRING("settings").get()); - COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES, NS_LITERAL_STRING("cookies").get()); - COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY, NS_LITERAL_STRING("history").get()); - COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS, NS_LITERAL_STRING("bookmarks").get()); + COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS); + COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES); + COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY); + COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS); NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull); diff --git a/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp b/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp index e9a5349167ec..07f5f0619e60 100644 --- a/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp +++ b/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp @@ -100,12 +100,12 @@ nsSeamonkeyProfileMigrator::Migrate(PRUint32 aItems, PRBool aReplace, const PRUn if (!mSourceProfile) GetSourceProfile(aProfile); - COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS, NS_LITERAL_STRING("settings").get()); - COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES, NS_LITERAL_STRING("cookies").get()); - COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY, NS_LITERAL_STRING("history").get()); - COPY_DATA(CopyPasswords, aReplace, nsIBrowserProfileMigrator::PASSWORDS, NS_LITERAL_STRING("passwords").get()); - COPY_DATA(CopyOtherData, aReplace, nsIBrowserProfileMigrator::OTHERDATA, NS_LITERAL_STRING("otherdata").get()); - COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS, NS_LITERAL_STRING("bookmarks").get()); + 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); NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull); @@ -723,7 +723,7 @@ nsSeamonkeyProfileMigrator::CopyBookmarks(PRBool aReplace) if (aReplace) return CopyFile(FILE_NAME_BOOKMARKS, FILE_NAME_BOOKMARKS); return ImportNetscapeBookmarks(FILE_NAME_BOOKMARKS, - NS_LITERAL_STRING("importedSeamonkeyBookmarksTitle").get()); + NS_LITERAL_STRING("sourceNameSeamonkey").get()); } nsresult