mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Make migration wizard more generic and less complex
This commit is contained in:
parent
dd2c8174a4
commit
ed2afb145b
@ -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();
|
||||
}
|
||||
|
@ -58,13 +58,31 @@
|
||||
<description>&importFrom.label;</description>
|
||||
|
||||
<radiogroup id="importSourceGroup">
|
||||
#ifdef XP_UNIX
|
||||
#ifdef XP_MACOSX
|
||||
<radio id="safari" label="&importFromSafari.label;" accesskey="&importFromSafari.accesskey;"/>
|
||||
<radio id="macie" label="&importFromIE.label;" accesskey="&importFromIE.accesskey;"/>
|
||||
<radio id="camino" label="&importFromCamino.label;" accesskey="&importFromCamino.accesskey;"/>
|
||||
<radio id="omniweb" label="&importFromOmniWeb.label;" accesskey="&importFromOmniweb.accesskey;"/>
|
||||
<radio id="icab" label="&importFromICab.label;" accesskey="&importFromICab.accesskey;"/>
|
||||
<radio id="seamonkey" label="&importFromSeamonkey.label;" accesskey="&importFromSeamonkey.accesskey;"/>
|
||||
<radio id="dogbert" label="&importFromNetscape4.label;" accesskey="&importFromNetscape4.accesskey;"/>
|
||||
<radio id="opera" label="&importFromOpera.label;" accesskey="&importFromOpera.accesskey;"/>
|
||||
#else
|
||||
<radio id="seamonkey" label="&importFromSeamonkey.label;" accesskey="&importFromSeamonkey.accesskey;"/>
|
||||
<radio id="dogbert" label="&importFromNetscape4.label;" accesskey="&importFromNetscape4.accesskey;"/>
|
||||
<radio id="opera" label="&importFromOpera.label;" accesskey="&importFromOpera.accesskey;"/>
|
||||
<radio id="konqueror" label="&importFromKonqueror.label;" accesskey="&importFromKonqueror.accesskey;"/>
|
||||
<radio id="epiphany" label="&importFromEpiphany.label;" accesskey="&importFromEpiphany.accesskey;"/>
|
||||
<radio id="galeon" label="&importFromGaleon.label;" accesskey="&importFromGaleon.accesskey;"/>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
<radio id="ie" label="&importFromIE.label;" accesskey="&importFromIE.accesskey;"/>
|
||||
<radio id="seamonkey" label="&importFromSeamonkey.label;" accesskey="&importFromSeamonkey.accesskey;"/>
|
||||
<radio id="dogbert" label="&importFromNetscape4.label;" accesskey="&importFromNetscape4.accesskey;"/>
|
||||
<radio id="opera" label="&importFromOpera.label;" accesskey="&importFromOpera.accesskey;"/>
|
||||
#endif
|
||||
</radiogroup>
|
||||
</wizardpage>
|
||||
|
||||
|
@ -11,8 +11,20 @@
|
||||
<!ENTITY importFromNetscape4.accesskey "4">
|
||||
<!ENTITY importFromOpera.label "Opera">
|
||||
<!ENTITY importFromOpera.accesskey "O">
|
||||
<!ENTITY importFromCamino.label "Camino">
|
||||
<!ENTITY importFromCamino.label "Camino">
|
||||
<!ENTITY importFromSafari.label "Safari">
|
||||
<!ENTITY importFromSafari.accesskey "s">
|
||||
<!ENTITY importFromSafari.label "Safari">
|
||||
<!ENTITY importFromOmniWeb.label "OmniWeb">
|
||||
<!ENTITY importFromOmniWeb.accesskey "W">
|
||||
<!ENTITY importFromICab.label "iCab">
|
||||
<!ENTITY importFromICab.accesskey "i">
|
||||
<!ENTITY importFromKonquerror.label "Konqueror">
|
||||
<!ENTITY importFromKonquerror.accesskey "K">
|
||||
<!ENTITY importFromEpiphany.label "Epiphany">
|
||||
<!ENTITY importFromEpiphany.accesskey "E">
|
||||
<!ENTITY importFromGaleon.label "Galeon">
|
||||
<!ENTITY importFromGaleon.accesskey "G">
|
||||
|
||||
<!ENTITY importSource.title "Import Settings and Data From">
|
||||
<!ENTITY importItems.title "Items to Import">
|
||||
|
@ -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 <search query>" 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 <search query>" 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
|
||||
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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<nsIStringBundle> 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);
|
||||
|
@ -264,7 +264,7 @@ nsNetscapeProfileMigratorBase::CopyFile(const nsAString& aSourceFileName, const
|
||||
|
||||
nsresult
|
||||
nsNetscapeProfileMigratorBase::ImportNetscapeBookmarks(const nsAString& aBookmarksFileName,
|
||||
const PRUnichar* aImportFolderTitleKey)
|
||||
const PRUnichar* aImportSourceNameKey)
|
||||
{
|
||||
nsCOMPtr<nsIFile> bookmarksFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(bookmarksFile));
|
||||
@ -293,11 +293,17 @@ nsNetscapeProfileMigratorBase::ImportNetscapeBookmarks(const nsAString& aBookmar
|
||||
nsCOMPtr<nsIRDFResource> 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<nsIRDFResource> folder;
|
||||
bms->CreateFolderInContainer(importedDogbertBookmarksTitle.get(), root, -1, getter_AddRefs(folder));
|
||||
bms->CreateFolderInContainer(importedBookmarksTitle.get(), root, -1, getter_AddRefs(folder));
|
||||
|
||||
nsCOMPtr<nsIRDFResource> folderProp;
|
||||
rdfs->GetResource(NS_LITERAL_CSTRING("http://home.netscape.com/NC-rdf#Folder"),
|
||||
|
@ -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<nsILocalFile> mSourceProfile;
|
||||
|
@ -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<nsIRDFResource> 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<nsIRDFResource> keywordsFolder;
|
||||
aBMS->CreateFolderInContainer(importedSearchUrlsTitle.get(),
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user