(215094) Update string uses, replace history contract id with cid

git-svn-id: svn://10.0.0.236/trunk@153155 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ben%bengoodger.com 2004-02-24 10:38:24 +00:00
parent 04969eba01
commit 8deae0f7d3
6 changed files with 62 additions and 44 deletions

View File

@ -1,4 +1,5 @@
const kIMig = Components.interfaces.nsIBrowserProfileMigrator;
const kProfileMigratorContractIDPrefix = "@mozilla.org/profile/migrator;1?app=browser&type=";
var MigrationWizard = {
_source: "", // Source Profile Migrator ContractID suffix
@ -20,7 +21,7 @@ var MigrationWizard = {
if ("arguments" in window) {
this._source = window.arguments[0];
this._migrator = window.arguments[1].QueryInterface(nsIBPM);
this._migrator = window.arguments[1].QueryInterface(kIMig);
this._autoMigrate = true;
// Advance past the first page
@ -46,10 +47,10 @@ var MigrationWizard = {
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);
var contractID = kProfileMigratorContractIDPrefix + suffix;
var migrator = Components.classes[contractID].createInstance(kIMig);
if (!migrator.sourceExists)
group.childNodes[i].setAttribute("hidden", "true");
group.childNodes[i].setAttribute("disabled", "true");
}
group.selectedItem = this._source == "" ? group.firstChild : document.getElementById(this._source);
@ -57,16 +58,19 @@ var MigrationWizard = {
onImportSourcePageAdvanced: function ()
{
if (!this._autoMigrate)
this._source = document.getElementById("importSourceGroup").selectedItem.id;
// Create the migrator for the selected source.
if (!this._migrator) {
var contractID = "@mozilla.org/profile/migrator;1?app=browser&type=" + this._source;
dump("*** contractID = " + contractID + "\n");
this._migrator = Components.classes[contractID].createInstance(nsIBPM);
}
var newSource = document.getElementById("importSourceGroup").selectedItem.id;
if (!this._migrator || newSource != this._source) {
// Create the migrator for the selected source.
var contractID = kProfileMigratorContractIDPrefix + newSource;
this._migrator = Components.classes[contractID].createInstance(kIMig);
this._itemsFlags = kIMig.ALL;
this._selectedProfile = null;
}
if (!this._autoMigrate)
this._source = newSource;
// check for more than one source profile
this._wiz.currentPage.next = this._migrator.sourceHasMultipleProfiles ? "selectProfile" : "importItems";
},
@ -121,13 +125,15 @@ var MigrationWizard = {
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 = itemID;
checkbox.setAttribute("label", bundle.getString(itemID + "_" + this._source));
dataSources.appendChild(checkbox);
if (!this._itemsFlags || this._itemsFlags & itemID)
checkbox.checked = true;
var itemID = (items >> i) & 0x1 ? Math.pow(2, i) : 0;
if (itemID > 0) {
var checkbox = document.createElement("checkbox");
checkbox.id = itemID;
checkbox.setAttribute("label", bundle.getString(itemID + "_" + this._source));
dataSources.appendChild(checkbox);
if (!this._itemsFlags || this._itemsFlags & itemID)
checkbox.checked = true;
}
}
},
@ -177,12 +183,15 @@ var MigrationWizard = {
items.removeChild(items.firstChild);
var bundle = document.getElementById("bundle");
var itemID;
for (var i = 0; i < 32; ++i) {
var itemID = Math.pow(2, (this._itemsFlags >> i) & 0x1);
var label = document.createElement("label");
label.id = itemID + "_migrated";
label.setAttribute("value", bundle.getString(itemID + "_" + this._source));
items.appendChild(label);
var itemID = (this._itemsFlags >> i) & 0x1 ? Math.pow(2, i) : 0;
if (itemID > 0) {
var label = document.createElement("label");
label.id = itemID + "_migrated";
label.setAttribute("value", bundle.getString(itemID + "_" + this._source));
items.appendChild(label);
}
}
},

View File

@ -51,6 +51,7 @@ REQUIRES = \
necko \
history \
browsercomps \
toolkitcomps \
profile \
pref \
rdf \

View File

@ -146,16 +146,16 @@ nsDogbertProfileMigrator::GetMigrateData(const PRUnichar* aProfile, PRUint32* aR
GetSourceProfile(aProfile);
PRBool exists;
const nsAString fileNames[] = { PREF_FILE_NAME_IN_4x,
COOKIES_FILE_NAME_IN_4x,
BOOKMARKS_FILE_NAME_IN_4x };
const PRUnichar* fileNames[] = { PREF_FILE_NAME_IN_4x.get(),
COOKIES_FILE_NAME_IN_4x.get(),
BOOKMARKS_FILE_NAME_IN_4x.get() };
const PRUint32 sourceFlags[] = { nsIBrowserProfileMigrator::SETTINGS,
nsIBrowserProfileMigrator::COOKIES,
nsIBrowserProfileMigrator::BOOKMARKS };
nsCOMPtr<nsIFile> sourceFile;
for (PRInt32 i = 0; i < 3; ++i) {
mSourceProfile->Clone(getter_AddRefs(sourceFile));
sourceFile->Append(fileNames[i]);
sourceFile->Append(nsDependentString(fileNames[i]));
sourceFile->Exists(&exists);
if (exists)
*aResult |= sourceFlags[i];

View File

@ -86,9 +86,11 @@
#include "nsIStringBundle.h"
#include "nsCRT.h"
#include "nsNetUtil.h"
#include "nsToolkitCompsCID.h"
#include "nsUnicharUtils.h"
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_CID(kGlobalHistoryCID, NS_GLOBALHISTORY_CID);
#define TRIDENTPROFILE_BUNDLE "chrome://browser/locale/migration/migration.properties"
#define LARGE_BUFFER 1024
@ -495,7 +497,7 @@ nsIEProfileMigrator::~nsIEProfileMigrator() {
nsresult
nsIEProfileMigrator::CopyHistory(PRBool aReplace)
{
nsCOMPtr<nsIBrowserHistory> hist(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
nsCOMPtr<nsIBrowserHistory> hist(do_GetService(kGlobalHistoryCID));
// First, Migrate standard IE History entries...
::CoInitialize(NULL);
@ -557,8 +559,14 @@ nsIEProfileMigrator::CopyHistory(PRBool aReplace)
}
// 4 - Now add the page
if (validScheme)
hist->AddPageWithDetails((char*)url, tempTitle, lastVisited);
if (validScheme) {
if (tempTitle)
hist->AddPageWithDetails((char*)url, tempTitle, lastVisited);
else {
nsAutoString urlTitle; urlTitle.AssignWithConversion(url);
hist->AddPageWithDetails((char*)url, urlTitle.get(), lastVisited);
}
}
}
}
nsCOMPtr<nsIRDFRemoteDataSource> ds(do_QueryInterface(hist));

View File

@ -126,10 +126,10 @@ nsOperaProfileMigrator::GetMigrateData(const PRUnichar* aProfile, PRUint32* aRes
GetOperaProfile(aProfile, getter_AddRefs(mOperaProfile));
PRBool exists;
const nsAString fileNames[] = { OPERA_PREFERENCES_FILE_NAME,
OPERA_COOKIES_FILE_NAME,
OPERA_HISTORY_FILE_NAME,
OPERA_BOOKMARKS_FILE_NAME };
const PRUnichar* fileNames[] = { OPERA_PREFERENCES_FILE_NAME.get(),
OPERA_COOKIES_FILE_NAME.get(),
OPERA_HISTORY_FILE_NAME.get(),
OPERA_BOOKMARKS_FILE_NAME.get() };
const PRUint32 sourceFlags[] = { nsIBrowserProfileMigrator::SETTINGS,
nsIBrowserProfileMigrator::COOKIES,
nsIBrowserProfileMigrator::HISTORY,
@ -137,7 +137,7 @@ nsOperaProfileMigrator::GetMigrateData(const PRUnichar* aProfile, PRUint32* aRes
nsCOMPtr<nsIFile> sourceFile;
for (PRInt32 i = 0; i < 4; ++i) {
mOperaProfile->Clone(getter_AddRefs(sourceFile));
sourceFile->Append(fileNames[i]);
sourceFile->Append(nsDependentString(fileNames[i]));
sourceFile->Exists(&exists);
if (exists)
*aResult |= sourceFlags[i];

View File

@ -119,12 +119,12 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile, PRUint32*
GetSourceProfile(aProfile);
PRBool exists;
const nsAString fileNames[] = { FILE_NAME_PREFS,
FILE_NAME_COOKIES,
FILE_NAME_HISTORY,
FILE_NAME_BOOKMARKS,
FILE_NAME_DOWNLOADS,
FILE_NAME_MIMETYPES };
const PRUnichar* fileNames[] = { FILE_NAME_PREFS.get(),
FILE_NAME_COOKIES.get(),
FILE_NAME_HISTORY.get(),
FILE_NAME_BOOKMARKS.get(),
FILE_NAME_DOWNLOADS.get(),
FILE_NAME_MIMETYPES.get() };
const PRUint32 sourceFlags[] = { nsIBrowserProfileMigrator::SETTINGS,
nsIBrowserProfileMigrator::COOKIES,
nsIBrowserProfileMigrator::HISTORY,
@ -134,7 +134,7 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile, PRUint32*
nsCOMPtr<nsIFile> sourceFile;
for (PRInt32 i = 0; i < 6; ++i) {
mSourceProfile->Clone(getter_AddRefs(sourceFile));
sourceFile->Append(fileNames[i]);
sourceFile->Append(nsDependentString(fileNames[i]));
sourceFile->Exists(&exists);
if (exists)
*aResult |= sourceFlags[i];