Bug 439128 Migrate most of the profile migrator code away from nsISupportsArray. r=bienvenu

git-svn-id: svn://10.0.0.236/trunk@252358 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bugzilla%standard8.plus.com
2008-06-15 17:59:25 +00:00
parent 770092074f
commit 059437ce44
14 changed files with 52 additions and 56 deletions

View File

@@ -37,6 +37,7 @@
const kIMig = Components.interfaces.nsIMailProfileMigrator;
const kIPStartup = Components.interfaces.nsIProfileStartup;
const kProfileMigratorContractIDPrefix = "@mozilla.org/profile/migrator;1?app=mail&type=";
const nsISupportsString = Components.interfaces.nsISupportsString;
var MigrationWizard = {
_source: "", // Source Profile Migrator ContractID suffix
@@ -80,8 +81,8 @@ var MigrationWizard = {
else
{
var sourceProfiles = this._migrator.sourceProfiles;
var profileName = sourceProfiles.QueryElementAt(0, Components.interfaces.nsISupportsString);
this._selectedProfile = profileName.data;
this._selectedProfile = sourceProfiles
.queryElementAt(0, nsISupportsString).data;
this._wiz.goTo("migrating");
}
}
@@ -152,10 +153,9 @@ var MigrationWizard = {
else {
this._wiz.currentPage.next = "migrating";
var sourceProfiles = this._migrator.sourceProfiles;
if (sourceProfiles && sourceProfiles.Count() == 1) {
var profileName = sourceProfiles.QueryElementAt(0, Components.interfaces.nsISupportsString);
this._selectedProfile = profileName.data;
}
if (sourceProfiles && sourceProfiles.length == 1)
this._selectedProfile =
sourceProfiles.queryElementAt(0, nsISupportsString).data;
else
this._selectedProfile = "";
}
@@ -174,12 +174,11 @@ var MigrationWizard = {
profiles.removeChild(profiles.firstChild);
var sourceProfiles = this._migrator.sourceProfiles;
var count = sourceProfiles.Count();
var count = sourceProfiles.length;
for (var i = 0; i < count; ++i) {
var item = document.createElement("radio");
var str = sourceProfiles.QueryElementAt(i, Components.interfaces.nsISupportsString);
item.id = str.data;
item.setAttribute("label", str.data);
item.id = sourceProfiles.queryElementAt(i, nsISupportsString).data;
item.setAttribute("label", item.id);
profiles.appendChild(item);
}

View File

@@ -37,10 +37,10 @@
#include "nsISupports.idl"
interface nsISupportsArray;
interface nsIArray;
interface nsIProfileStartup;
[scriptable, uuid(C3CB4343-2E8B-40fd-A639-A65731BED3AE)]
[scriptable, uuid(fca38a7a-c43f-4b28-adbd-61e5cc942508)]
interface nsIMailProfileMigrator : nsISupports
{
/**
@@ -92,6 +92,6 @@ interface nsIMailProfileMigrator : nsISupports
* An enumeration of available profiles. If the import source does
* not support profiles, this attribute is null.
*/
readonly attribute nsISupportsArray sourceProfiles;
readonly attribute nsIArray sourceProfiles;
};

View File

@@ -44,7 +44,6 @@
#include "nsIPrefLocalizedString.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
@@ -344,12 +343,12 @@ nsDogbertProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
NS_IMETHODIMP
nsDogbertProfileMigrator::GetSourceExists(PRBool* aResult)
{
nsCOMPtr<nsISupportsArray> profiles;
nsCOMPtr<nsIArray> profiles;
GetSourceProfiles(getter_AddRefs(profiles));
if (profiles) {
PRUint32 count;
profiles->Count(&count);
profiles->GetLength(&count);
*aResult = count > 0;
}
else
@@ -361,12 +360,12 @@ nsDogbertProfileMigrator::GetSourceExists(PRBool* aResult)
NS_IMETHODIMP
nsDogbertProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
{
nsCOMPtr<nsISupportsArray> profiles;
nsCOMPtr<nsIArray> profiles;
GetSourceProfiles(getter_AddRefs(profiles));
if (profiles) {
PRUint32 count;
profiles->Count(&count);
profiles->GetLength(&count);
*aResult = count > 1;
}
else
@@ -377,12 +376,12 @@ nsDogbertProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MACOSX)
NS_IMETHODIMP
nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
nsDogbertProfileMigrator::GetSourceProfiles(nsIArray** aResult)
{
if (!mProfiles) {
nsresult rv;
rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
mProfiles = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> regFile;
@@ -412,7 +411,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
(do_CreateInstance("@mozilla.org/supports-string;1"));
if (nameString) {
nameString->SetData(NS_ConvertUTF8toUTF16(profileName));
mProfiles->AppendElement(nameString);
mProfiles->AppendElement(nameString, PR_FALSE);
}
}
}
@@ -423,7 +422,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
#else // XP_UNIX
NS_IMETHODIMP
nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
nsDogbertProfileMigrator::GetSourceProfiles(nsIArray** aResult)
{
nsresult rv;
const char* profileDir = PR_GetEnv(PROFILE_HOME_ENVIRONMENT_VARIABLE);
@@ -454,7 +453,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
mSourceProfile = profileFile;
rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
mProfiles = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupportsString> nameString
@@ -462,7 +461,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
if (!nameString) return NS_ERROR_FAILURE;
nameString->SetData(NS_LITERAL_STRING("Netscape 4.x"));
mProfiles->AppendElement(nameString);
mProfiles->AppendElement(nameString, PR_FALSE);
NS_ADDREF(*aResult = mProfiles);
return NS_OK;
}

View File

@@ -41,7 +41,7 @@
#include "nsIMailProfileMigrator.h"
#include "nsILocalFile.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsIMutableArray.h"
#include "nsNetscapeProfileMigratorBase.h"
#include "nsITimer.h"
@@ -95,8 +95,7 @@ protected:
nsresult CopyPreferences();
private:
nsCOMPtr<nsISupportsArray> mProfiles;
nsCOMPtr<nsISupportsArray> mProfileLocations;
nsCOMPtr<nsIMutableArray> mProfiles;
nsCOMPtr<nsIObserverService> mObserverService;
nsCOMPtr<nsITimer> mFileIOTimer;

View File

@@ -42,7 +42,6 @@
#include "nsIPrefLocalizedString.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
@@ -169,7 +168,7 @@ nsEudoraProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
}
NS_IMETHODIMP
nsEudoraProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
nsEudoraProfileMigrator::GetSourceProfiles(nsIArray** aResult)
{
*aResult = nsnull;
return NS_OK;

View File

@@ -41,7 +41,6 @@
#include "nsIMailProfileMigrator.h"
#include "nsILocalFile.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsITimer.h"
#include "nsIImportGeneric.h"

View File

@@ -47,7 +47,7 @@
#include "nsIRDFService.h"
#include "NSReg.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsIMutableArray.h"
#include "nsISupportsPrimitives.h"
#include "nsIURL.h"
#include "nsNetscapeProfileMigratorBase.h"
@@ -89,8 +89,8 @@ regerr2nsresult(REGERR errCode)
nsresult
nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistryFile,
nsISupportsArray* aProfileNames,
nsISupportsArray* aProfileLocations)
nsIMutableArray* aProfileNames,
nsIMutableArray* aProfileLocations)
{
nsresult rv;
REGERR errCode;
@@ -174,7 +174,7 @@ nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistr
dir->Exists(&exists);
if (exists) {
aProfileLocations->AppendElement(dir);
aProfileLocations->AppendElement(dir, PR_FALSE);
// Get the profile name and add it to the names array
nsString profileName;
@@ -184,7 +184,7 @@ nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistr
do_CreateInstance("@mozilla.org/supports-string;1"));
profileNameString->SetData(profileName);
aProfileNames->AppendElement(profileNameString);
aProfileNames->AppendElement(profileNameString, PR_FALSE);
}
}
NR_RegClose(reg);

View File

@@ -46,6 +46,7 @@
class nsIFile;
class nsIPrefBranch;
class nsVoidArray;
class nsIMutableArray;
struct fileTransactionEntry {
nsCOMPtr<nsIFile> srcFile; // the src path including leaf name
@@ -90,8 +91,8 @@ public:
protected:
nsresult GetProfileDataFromRegistry(nsILocalFile* aRegistryFile,
nsISupportsArray* aProfileNames,
nsISupportsArray* aProfileLocations);
nsIMutableArray* aProfileNames,
nsIMutableArray* aProfileLocations);
nsresult CopyFile(const nsAString& aSourceFileName, const nsAString& aTargetFileName);

View File

@@ -39,7 +39,6 @@
#include "nsDirectoryServiceDefs.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsOEProfileMigrator.h"
#include "nsIProfileMigrator.h"
@@ -165,7 +164,7 @@ nsOEProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
}
NS_IMETHODIMP
nsOEProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
nsOEProfileMigrator::GetSourceProfiles(nsIArray** aResult)
{
*aResult = nsnull;
return NS_OK;

View File

@@ -158,7 +158,7 @@ nsOutlookProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
}
NS_IMETHODIMP
nsOutlookProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
nsOutlookProfileMigrator::GetSourceProfiles(nsIArray** aResult)
{
*aResult = nsnull;
return NS_OK;

View File

@@ -43,7 +43,6 @@
#include "nsIPrefLocalizedString.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"

View File

@@ -41,7 +41,6 @@
#include "nsILocalFile.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsITimer.h"
#include "nsIImportGeneric.h"

View File

@@ -43,7 +43,7 @@
#include "nsIPrefLocalizedString.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsArrayUtils.h"
#include "nsISupportsPrimitives.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
@@ -285,12 +285,12 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
NS_IMETHODIMP
nsSeamonkeyProfileMigrator::GetSourceExists(PRBool* aResult)
{
nsCOMPtr<nsISupportsArray> profiles;
nsCOMPtr<nsIArray> profiles;
GetSourceProfiles(getter_AddRefs(profiles));
if (profiles) {
PRUint32 count;
profiles->Count(&count);
profiles->GetLength(&count);
*aResult = count > 0;
}
else
@@ -302,12 +302,12 @@ nsSeamonkeyProfileMigrator::GetSourceExists(PRBool* aResult)
NS_IMETHODIMP
nsSeamonkeyProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
{
nsCOMPtr<nsISupportsArray> profiles;
nsCOMPtr<nsIArray> profiles;
GetSourceProfiles(getter_AddRefs(profiles));
if (profiles) {
PRUint32 count;
profiles->Count(&count);
profiles->GetLength(&count);
*aResult = count > 1;
}
else
@@ -317,14 +317,17 @@ nsSeamonkeyProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
}
NS_IMETHODIMP
nsSeamonkeyProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
nsSeamonkeyProfileMigrator::GetSourceProfiles(nsIArray** aResult)
{
if (!mProfileNames && !mProfileLocations) {
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfileNames));
if (NS_FAILED(rv)) return rv;
nsresult rv;
mProfileNames = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
rv = NS_NewISupportsArray(getter_AddRefs(mProfileLocations));
if (NS_FAILED(rv)) return rv;
mProfileLocations = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
// Fills mProfileNames and mProfileLocations
FillProfileDataFromSeamonkeyRegistry();
@@ -341,7 +344,7 @@ nsresult
nsSeamonkeyProfileMigrator::GetSourceProfile(const PRUnichar* aProfile)
{
PRUint32 count;
mProfileNames->Count(&count);
mProfileNames->GetLength(&count);
for (PRUint32 i = 0; i < count; ++i) {
nsCOMPtr<nsISupportsString> str(do_QueryElementAt(mProfileNames, i));
nsString profileName;

View File

@@ -41,7 +41,7 @@
#include "nsIMailProfileMigrator.h"
#include "nsILocalFile.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsIMutableArray.h"
#include "nsNetscapeProfileMigratorBase.h"
#include "nsITimer.h"
@@ -83,8 +83,8 @@ protected:
void EndCopyFolders();
private:
nsCOMPtr<nsISupportsArray> mProfileNames;
nsCOMPtr<nsISupportsArray> mProfileLocations;
nsCOMPtr<nsIMutableArray> mProfileNames;
nsCOMPtr<nsIMutableArray> mProfileLocations;
nsCOMPtr<nsIObserverService> mObserverService;
nsCOMPtr<nsITimer> mFileIOTimer;