mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bugzilla Bug 335692 Remove nsIPref from profile/pref-migrator.
Patch by alfred.peng@sun.com. roc: review+ roc: superreview+
This commit is contained in:
parent
138429f364
commit
3f649fb148
@ -55,7 +55,7 @@
|
||||
#include "prio.h"
|
||||
#include "prerror.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "plstr.h"
|
||||
#include "prprf.h"
|
||||
#include "nsXPIDLString.h"
|
||||
@ -284,12 +284,12 @@ nsPrefMigration::getPrefService()
|
||||
// get the prefs service
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPref> pIMyService(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
nsCOMPtr<nsIPrefBranch> pIMyService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIPref),
|
||||
return NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIPrefBranch),
|
||||
pIMyService, NS_PROXY_SYNC,
|
||||
getter_AddRefs(m_prefs));
|
||||
getter_AddRefs(m_prefBranch));
|
||||
|
||||
}
|
||||
|
||||
@ -635,11 +635,13 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
rv = m_prefsFile->AppendNative(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIPrefService> psvc(do_QueryInterface(m_prefBranch));
|
||||
|
||||
//Clear the prefs in case a previous set was read in.
|
||||
m_prefs->ResetPrefs();
|
||||
psvc->ResetPrefs();
|
||||
|
||||
//Now read the prefs from the prefs file in the system directory
|
||||
m_prefs->ReadUserPrefs(m_prefsFile);
|
||||
psvc->ReadUserPrefs(m_prefsFile);
|
||||
|
||||
//
|
||||
// Start computing the sizes required for migration
|
||||
@ -647,11 +649,12 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
rv = GetSizes(oldProfileSpec, PR_FALSE, &totalProfileSize);
|
||||
profileDrive = newProfileSpec.GetDiskSpaceAvailable();
|
||||
|
||||
rv = m_prefs->GetIntPref(PREF_MAIL_SERVER_TYPE, &serverType);
|
||||
rv = m_prefBranch->GetIntPref(PREF_MAIL_SERVER_TYPE, &serverType);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// get the migration mode for mail
|
||||
rv = m_prefs->GetBoolPref(PREF_MIGRATION_MODE_FOR_MAIL, ©MailFileInMigration);
|
||||
rv = m_prefBranch->GetBoolPref(PREF_MIGRATION_MODE_FOR_MAIL,
|
||||
©MailFileInMigration);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -871,11 +874,13 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
NS_FileSpecToIFile(&newPOPMailPathSpec,
|
||||
getter_AddRefs(newPOPMailPathFile));
|
||||
|
||||
rv = m_prefs->SetFileXPref(PREF_MAIL_DIRECTORY, newPOPMailPathFile);
|
||||
rv = m_prefBranch->SetComplexValue(PREF_MAIL_DIRECTORY,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
newPOPMailPathFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
m_prefs->CopyCharPref(PREF_NETWORK_HOSTS_POP_SERVER, &popServerName);
|
||||
m_prefBranch->GetCharPref(PREF_NETWORK_HOSTS_POP_SERVER, &popServerName);
|
||||
|
||||
nsCAutoString popServerNamewithoutPort(popServerName);
|
||||
PRInt32 colonPos = popServerNamewithoutPort.FindChar(':');
|
||||
@ -926,7 +931,9 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
NS_FileSpecToIFile(&newIMAPLocalMailPathSpec,
|
||||
getter_AddRefs(newIMAPLocalMailPathFile));
|
||||
|
||||
rv = m_prefs->SetFileXPref(PREF_MAIL_DIRECTORY, newIMAPLocalMailPathFile);
|
||||
rv = m_prefBranch->SetComplexValue(PREF_MAIL_DIRECTORY,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
newIMAPLocalMailPathFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
@ -966,7 +973,9 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
NS_FileSpecToIFile(&newIMAPMailPathSpec,
|
||||
getter_AddRefs(newIMAPMailPathFile));
|
||||
|
||||
rv = m_prefs->SetFileXPref(PREF_MAIL_IMAP_ROOT_DIR, newIMAPMailPathFile);
|
||||
rv = m_prefBranch->SetComplexValue(PREF_MAIL_IMAP_ROOT_DIR,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
newIMAPMailPathFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
@ -981,7 +990,9 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
NS_FileSpecToIFile(&oldIMAPLocalMailPathSpec,
|
||||
getter_AddRefs(oldIMAPLocalMailPathFile));
|
||||
|
||||
rv = m_prefs->SetFileXPref(PREF_MAIL_DIRECTORY, oldIMAPLocalMailPathFile);
|
||||
rv = m_prefBranch->SetComplexValue(PREF_MAIL_DIRECTORY,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
oldIMAPLocalMailPathFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
{
|
||||
@ -993,7 +1004,9 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
NS_FileSpecToIFile(&oldIMAPMailPathSpec,
|
||||
getter_AddRefs(oldIMAPMailPathFile));
|
||||
|
||||
rv = m_prefs->SetFileXPref(PREF_MAIL_IMAP_ROOT_DIR, oldIMAPMailPathFile);
|
||||
rv = m_prefBranch->SetComplexValue(PREF_MAIL_IMAP_ROOT_DIR,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
oldIMAPMailPathFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
@ -1028,7 +1041,9 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
NS_FileSpecToIFile(&newMOVEMAILPathSpec,
|
||||
getter_AddRefs(newMOVEMAILPathFile));
|
||||
|
||||
rv = m_prefs->SetFileXPref(PREF_MAIL_DIRECTORY, newMOVEMAILPathFile);
|
||||
rv = m_prefBranch->SetComplexValue(PREF_MAIL_DIRECTORY,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
newMOVEMAILPathFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
@ -1079,7 +1094,9 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
NS_FileSpecToIFile(&newNewsPathSpec,
|
||||
getter_AddRefs(newNewsPathFile));
|
||||
|
||||
rv = m_prefs->SetFileXPref(PREF_NEWS_DIRECTORY, newNewsPathFile);
|
||||
rv = m_prefBranch->SetComplexValue(PREF_NEWS_DIRECTORY,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
newNewsPathFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
@ -1192,7 +1209,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
|
||||
// Don't inherit the 4.x cache file location for mozilla!
|
||||
// The cache pref later gets set with a default in nsAppRunner::InitCachePrefs().
|
||||
m_prefs->ClearUserPref(PREF_BROWSER_CACHE_DIRECTORY);
|
||||
m_prefBranch->ClearUserPref(PREF_BROWSER_CACHE_DIRECTORY);
|
||||
|
||||
rv = DoSpecialUpdates(newProfilePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -1206,9 +1223,9 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
|
||||
rv = newPrefsFile->AppendNative(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_5x));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv=m_prefs->SavePrefFile(newPrefsFile);
|
||||
rv=psvc->SavePrefFile(newPrefsFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv=m_prefs->ResetPrefs();
|
||||
rv=psvc->ResetPrefs();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRBool flagExists = PR_FALSE;
|
||||
@ -1316,7 +1333,7 @@ nsPrefMigration::GetDirFromPref(nsIFileSpec * oldProfilePath, nsIFileSpec * newP
|
||||
|
||||
nsCOMPtr <nsIFileSpec> oldPrefPath;
|
||||
nsXPIDLCString oldPrefPathStr;
|
||||
rv = m_prefs->CopyCharPref(pref,getter_Copies(oldPrefPathStr));
|
||||
rv = m_prefBranch->GetCharPref(pref, getter_Copies(oldPrefPathStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// the default on the mac was "". doing GetFileXPref on that would return
|
||||
@ -1327,7 +1344,8 @@ nsPrefMigration::GetDirFromPref(nsIFileSpec * oldProfilePath, nsIFileSpec * newP
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr <nsILocalFile> oldPrefPathFile;
|
||||
rv = m_prefs->GetFileXPref(pref, getter_AddRefs(oldPrefPathFile));
|
||||
rv = m_prefBranch->GetComplexValue(pref, NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(oldPrefPathFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// convert nsILocalFile to nsIFileSpec
|
||||
@ -1966,7 +1984,7 @@ nsPrefMigration::DoSpecialUpdates(nsIFileSpec * profilePath)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
/* Create the new mail directory from the setting in prefs.js or a default */
|
||||
rv = m_prefs->GetIntPref(PREF_MAIL_SERVER_TYPE, &serverType);
|
||||
rv = m_prefBranch->GetIntPref(PREF_MAIL_SERVER_TYPE, &serverType);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (serverType == POP_4X_MAIL_TYPE) {
|
||||
rv = RenameAndMove4xPopFilterFile(profilePath);
|
||||
@ -2020,7 +2038,7 @@ nsPrefMigration::RenameAndMove4xPopFile(nsIFileSpec * profilePath, const char *f
|
||||
nsFileSpec migratedPopDirectory;
|
||||
rv = profilePath->GetFileSpec(&migratedPopDirectory);
|
||||
migratedPopDirectory += NEW_MAIL_DIR_NAME;
|
||||
m_prefs->CopyCharPref(PREF_NETWORK_HOSTS_POP_SERVER, &popServerName);
|
||||
m_prefBranch->GetCharPref(PREF_NETWORK_HOSTS_POP_SERVER, &popServerName);
|
||||
migratedPopDirectory += popServerName;
|
||||
PR_FREEIF(popServerName);
|
||||
|
||||
@ -2089,7 +2107,7 @@ nsPrefMigration::RenameAndMove4xImapFilterFiles(nsIFileSpec * profilePath)
|
||||
nsresult rv;
|
||||
char *hostList=nsnull;
|
||||
|
||||
rv = m_prefs->CopyCharPref(PREF_4X_NETWORK_HOSTS_IMAP_SERVER, &hostList);
|
||||
rv = m_prefBranch->GetCharPref(PREF_4X_NETWORK_HOSTS_IMAP_SERVER, &hostList);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!hostList || !*hostList) return NS_OK;
|
||||
@ -2154,7 +2172,9 @@ nsPrefMigration::GetPremigratedFilePref(const char *pref_name, nsIFileSpec **pat
|
||||
#ifdef DEBUG_seth
|
||||
printf("getting %s (into a nsFileSpec)\n", premigration_pref);
|
||||
#endif
|
||||
rv = m_prefs->GetFilePref((const char *)premigration_pref, path);
|
||||
rv = m_prefBranch->GetComplexValue((const char *)premigration_pref,
|
||||
NS_GET_IID(nsIFileSpec),
|
||||
(void **)path);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -2192,7 +2212,8 @@ nsPrefMigration::SetPremigratedFilePref(const char *pref_name, nsIFileSpec *path
|
||||
NS_ASSERTION(exists, "the path does not exist. see bug #55444");
|
||||
if (!exists) return NS_OK;
|
||||
|
||||
rv = m_prefs->SetFileXPref((const char *)premigration_pref, pathFile);
|
||||
rv = m_prefBranch->SetComplexValue((const char *)premigration_pref,
|
||||
NS_GET_IID(nsILocalFile), pathFile);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -2334,7 +2355,7 @@ ConvertStringToUTF8(const char* aCharset, const char* inString, char** outString
|
||||
}
|
||||
|
||||
nsresult
|
||||
ConvertPrefToUTF8(const char *prefname, nsIPref *prefs, const char* charSet)
|
||||
ConvertPrefToUTF8(const char *prefname, nsIPrefBranch *prefs, const char* charSet)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -2345,7 +2366,7 @@ ConvertPrefToUTF8(const char *prefname, nsIPref *prefs, const char* charSet)
|
||||
|
||||
nsXPIDLCString prefval;
|
||||
|
||||
rv = prefs->CopyCharPref(prefname, getter_Copies(prefval));
|
||||
rv = prefs->GetCharPref(prefname, getter_Copies(prefval));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (prefval.IsEmpty()) {
|
||||
@ -2384,10 +2405,8 @@ static PRBool charEndsWith(const char *str, const char *endStr)
|
||||
}
|
||||
|
||||
static
|
||||
void fontPrefEnumerationFunction(const char *name, void *data)
|
||||
void fontPrefEnumerationFunction(const char *name, nsCStringArray *arr)
|
||||
{
|
||||
nsCStringArray *arr;
|
||||
arr = (nsCStringArray *)data;
|
||||
#ifdef DEBUG_UTF8_CONVERSION
|
||||
printf("fontPrefEnumerationFunction: %s\n", name);
|
||||
#endif
|
||||
@ -2399,10 +2418,8 @@ void fontPrefEnumerationFunction(const char *name, void *data)
|
||||
}
|
||||
|
||||
static
|
||||
void ldapPrefEnumerationFunction(const char *name, void *data)
|
||||
void ldapPrefEnumerationFunction(const char *name, nsCStringArray *arr)
|
||||
{
|
||||
nsCStringArray *arr;
|
||||
arr = (nsCStringArray *)data;
|
||||
#ifdef DEBUG_UTF8_CONVERSION
|
||||
printf("ldapPrefEnumerationFunction: %s\n", name);
|
||||
#endif
|
||||
@ -2415,10 +2432,8 @@ void ldapPrefEnumerationFunction(const char *name, void *data)
|
||||
}
|
||||
|
||||
static
|
||||
void vCardPrefEnumerationFunction(const char *name, void *data)
|
||||
void vCardPrefEnumerationFunction(const char *name, nsCStringArray *arr)
|
||||
{
|
||||
nsCStringArray *arr;
|
||||
arr = (nsCStringArray *)data;
|
||||
#ifdef DEBUG_UTF8_CONVERSION
|
||||
printf("vCardPrefEnumerationFunction: %s\n", name);
|
||||
#endif
|
||||
@ -2430,7 +2445,7 @@ void vCardPrefEnumerationFunction(const char *name, void *data)
|
||||
|
||||
|
||||
typedef struct {
|
||||
nsIPref *prefs;
|
||||
nsIPrefBranch *prefs;
|
||||
const char* charSet;
|
||||
} PrefEnumerationClosure;
|
||||
|
||||
@ -2451,7 +2466,7 @@ nsPrefConverter::ConvertPrefsToUTF8()
|
||||
|
||||
nsCStringArray prefsToMigrate;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
if (!prefs) return NS_ERROR_FAILURE;
|
||||
|
||||
@ -2465,9 +2480,29 @@ nsPrefConverter::ConvertPrefsToUTF8()
|
||||
prefsToMigrate.AppendCString(prefnameStr);
|
||||
}
|
||||
|
||||
prefs->EnumerateChildren("intl.font",fontPrefEnumerationFunction,(void *)(&prefsToMigrate));
|
||||
prefs->EnumerateChildren("ldap_2.servers",ldapPrefEnumerationFunction,(void *)(&prefsToMigrate));
|
||||
prefs->EnumerateChildren("mail.identity.vcard",vCardPrefEnumerationFunction,(void *)(&prefsToMigrate));
|
||||
PRUint32 count, i;
|
||||
char **childArray;
|
||||
|
||||
if (NS_SUCCEEDED(prefs->GetChildList("intl.font.", &count, &childArray))) {
|
||||
for (i = 0; i < count; i++)
|
||||
fontPrefEnumerationFunction(childArray[i], &prefsToMigrate);
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, childArray);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(prefs->GetChildList("ldap_2.servers.", &count, &childArray))) {
|
||||
for (i = 0; i < count; i++)
|
||||
ldapPrefEnumerationFunction(childArray[i], &prefsToMigrate);
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, childArray);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(prefs->GetChildList("mail.identity.vcard.", &count, &childArray))) {
|
||||
for (i = 0; i < count; i++)
|
||||
vCardPrefEnumerationFunction(childArray[i], &prefsToMigrate);
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, childArray);
|
||||
}
|
||||
|
||||
PrefEnumerationClosure closure;
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
@ -176,7 +176,7 @@ class nsPrefMigration: public nsIPrefMigration
|
||||
|
||||
nsresult getPrefService();
|
||||
|
||||
nsCOMPtr<nsIPref> m_prefs;
|
||||
nsCOMPtr<nsIPrefBranch> m_prefBranch;
|
||||
nsCOMPtr<nsILocalFile> m_prefsFile;
|
||||
nsCOMPtr<nsIDOMWindowInternal> m_parentWindow;
|
||||
nsCOMPtr<nsIDOMWindow> mPMProgressWindow;
|
||||
|
Loading…
Reference in New Issue
Block a user