зеркало из https://github.com/mozilla/pjs.git
237190 - fix some leaks in migration. r=brendan
This commit is contained in:
Родитель
ecceb2c22d
Коммит
e9b3a4d1aa
|
@ -67,6 +67,7 @@ REQUIRES = \
|
|||
$(NULL)
|
||||
|
||||
CPPSRCS = nsProfileMigrator.cpp \
|
||||
nsBrowserProfileMigratorUtils.cpp \
|
||||
nsNetscapeProfileMigratorBase.cpp \
|
||||
nsDogbertProfileMigrator.cpp \
|
||||
nsSeamonkeyProfileMigrator.cpp \
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
void SetProxyPref(const nsACString& aHostPort, const char* aPref,
|
||||
const char* aPortPref, nsIPrefBranch* aPrefs)
|
||||
{
|
||||
nsCAutoString hostPort(aHostPort);
|
||||
PRInt32 portDelimOffset = hostPort.RFindChar(':');
|
||||
if (portDelimOffset) {
|
||||
nsDependentCString host(Substring(hostPort, 0, portDelimOffset));
|
||||
nsDependentCString port(Substring(hostPort, portDelimOffset + 1,
|
||||
hostPort.Length() - (portDelimOffset + 1)));
|
||||
|
||||
aPrefs->SetCharPref(aPref, host.get());
|
||||
PRInt32 stringErr;
|
||||
PRInt32 portValue = port.ToInteger(&stringErr);
|
||||
aPrefs->SetIntPref(aPortPref, portValue);
|
||||
}
|
||||
else
|
||||
aPrefs->SetCharPref(aPref, hostPort.get());
|
||||
}
|
||||
|
||||
void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch)
|
||||
{
|
||||
// Windows (and Opera) formats its proxy override list in the form:
|
||||
// server;server;server where server is a server name or ip address,
|
||||
// or "<local>". Mozilla's format is server,server,server, and <local>
|
||||
// must be translated to "localhost,127.0.0.1"
|
||||
nsCAutoString override(aServers);
|
||||
PRInt32 left = 0, right = 0;
|
||||
for (;;) {
|
||||
right = override.FindChar(';', right);
|
||||
const nsACString& host = Substring(override, left,
|
||||
(right < 0 ? override.Length() : right) - left);
|
||||
if (host.Equals("<local>"))
|
||||
override.Replace(left, 7, NS_LITERAL_CSTRING("localhost,127.0.0.1"));
|
||||
if (right < 0)
|
||||
break;
|
||||
left = right + 1;
|
||||
override.Replace(right, 1, NS_LITERAL_CSTRING(","));
|
||||
}
|
||||
aBranch->SetCharPref("network.proxy.no_proxies_on", override.get());
|
||||
}
|
||||
|
||||
void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength,
|
||||
PRBool aReplace, nsILocalFile* aSourceProfile,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
PRBool exists;
|
||||
MigrationData* cursor;
|
||||
MigrationData* end = aDataArray + aDataArrayLength;
|
||||
for (cursor = aDataArray; cursor < end && cursor->fileName; ++cursor) {
|
||||
// When in replace mode, all items can be imported.
|
||||
// When in non-replace mode, only items that do not require file replacement
|
||||
// can be imported.
|
||||
if (aReplace || !cursor->replaceOnly) {
|
||||
aSourceProfile->Clone(getter_AddRefs(sourceFile));
|
||||
sourceFile->Append(nsDependentString(cursor->fileName));
|
||||
sourceFile->Exists(&exists);
|
||||
if (exists)
|
||||
*aResult |= cursor->sourceFlag;
|
||||
}
|
||||
nsCRT::free(cursor->fileName);
|
||||
cursor->fileName = nsnull;
|
||||
}
|
||||
}
|
|
@ -63,11 +63,18 @@ void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch);
|
|||
void SetProxyPref(const nsACString& aHostPort, const char* aPref,
|
||||
const char* aPortPref, nsIPrefBranch* aPrefs);
|
||||
|
||||
typedef struct {
|
||||
struct MigrationData {
|
||||
PRUnichar* fileName;
|
||||
PRUint32 sourceFlag;
|
||||
PRBool replaceOnly;
|
||||
} MIGRATIONDATA;
|
||||
};
|
||||
|
||||
class nsILocalFile;
|
||||
void GetMigrateDataFromArray(MigrationData* aDataArray,
|
||||
PRInt32 aDataArrayLength,
|
||||
PRBool aReplace,
|
||||
nsILocalFile* aSourceProfile,
|
||||
PRUint16* aResult);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -145,31 +145,19 @@ nsDogbertProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
GetSourceProfile(aProfile);
|
||||
|
||||
PRBool exists;
|
||||
const MIGRATIONDATA data[] = { { ToNewUnicode(PREF_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(COOKIES_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(BOOKMARKS_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_FALSE } };
|
||||
MigrationData data[] = { { ToNewUnicode(PREF_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(COOKIES_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(BOOKMARKS_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_FALSE } };
|
||||
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
for (PRInt32 i = 0; i < 3; ++i) {
|
||||
// Don't list items that can only be imported in replace-mode when
|
||||
// we aren't being run in replace-mode.
|
||||
if (!aReplace && data[i].replaceOnly)
|
||||
continue;
|
||||
|
||||
mSourceProfile->Clone(getter_AddRefs(sourceFile));
|
||||
sourceFile->Append(nsDependentString(data[i].fileName));
|
||||
sourceFile->Exists(&exists);
|
||||
if (exists)
|
||||
*aResult |= data[i].sourceFlag;
|
||||
|
||||
nsCRT::free(data[i].fileName);
|
||||
}
|
||||
// Frees file name strings allocated above.
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
aReplace, mSourceProfile, aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -242,7 +230,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
|||
#define F(a) nsDogbertProfileMigrator::a
|
||||
|
||||
static
|
||||
nsDogbertProfileMigrator::PREFTRANSFORM gTransforms[] = {
|
||||
nsDogbertProfileMigrator::PrefTransform gTransforms[] = {
|
||||
// Simple Copy Prefs
|
||||
{ "browser.anchor_color", 0, F(GetString), F(SetString), PR_FALSE, -1 },
|
||||
{ "browser.visited_color", 0, F(GetString), F(SetString), PR_FALSE, -1 },
|
||||
|
@ -280,8 +268,8 @@ nsresult
|
|||
nsDogbertProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFileName,
|
||||
const nsAString& aTargetPrefFileName)
|
||||
{
|
||||
PREFTRANSFORM* transform;
|
||||
PREFTRANSFORM* end = gTransforms + sizeof(gTransforms)/sizeof(PREFTRANSFORM);
|
||||
PrefTransform* transform;
|
||||
PrefTransform* end = gTransforms + sizeof(gTransforms)/sizeof(PrefTransform);
|
||||
|
||||
// Load the source pref file
|
||||
nsCOMPtr<nsIPrefService> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
|
@ -332,7 +320,7 @@ nsDogbertProfileMigrator::CopyPreferences(PRBool aReplace)
|
|||
nsresult
|
||||
nsDogbertProfileMigrator::GetHomepage(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
PRInt32 val;
|
||||
nsresult rv = aBranch->GetIntPref(xform->sourcePrefName, &val);
|
||||
if (NS_SUCCEEDED(rv) && val == 0) {
|
||||
|
@ -345,7 +333,7 @@ nsDogbertProfileMigrator::GetHomepage(void* aTransform, nsIPrefBranch* aBranch)
|
|||
nsresult
|
||||
nsDogbertProfileMigrator::GetImagePref(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
PRBool loadImages;
|
||||
nsresult rv = aBranch->GetBoolPref(xform->sourcePrefName, &loadImages);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
@ -670,11 +670,11 @@ nsIEProfileMigrator::CopyHistory(PRBool aReplace)
|
|||
|
||||
typedef HRESULT (WINAPI *PStoreCreateInstancePtr)(IPStore**, DWORD, DWORD, DWORD);
|
||||
|
||||
typedef struct {
|
||||
struct SignonData {
|
||||
PRUnichar* user;
|
||||
PRUnichar* pass;
|
||||
char* realm;
|
||||
} SIGNONDATA;
|
||||
};
|
||||
|
||||
// The IEPStore GUID is the registry key under which IE Protected Store data lives.
|
||||
// {e161255a-37c3-11d2-bcaa-00c04fd929db}
|
||||
|
@ -792,10 +792,10 @@ nsIEProfileMigrator::GetSignonsListFromPStore(IPStore* aPStore, nsVoidArray* aSi
|
|||
// method, and we own that buffer. We don't free it here, since we're going to be using
|
||||
// it after the password harvesting stage to locate the username field. Only after the second
|
||||
// phase is complete do we free the buffer.
|
||||
SIGNONDATA* d = new SIGNONDATA;
|
||||
SignonData* d = new SignonData;
|
||||
d->user = (PRUnichar*)username;
|
||||
d->pass = (PRUnichar*)pass;
|
||||
d->realm = realm;
|
||||
d->realm = realm; // freed in ResolveAndMigrateSignons
|
||||
aSignonsFound->AppendElement(d);
|
||||
}
|
||||
}
|
||||
|
@ -859,8 +859,8 @@ nsIEProfileMigrator::ResolveAndMigrateSignons(IPStore* aPStore, nsVoidArray* aSi
|
|||
|
||||
// Assume all keys that are valid URIs are signons, not saved form data, and that
|
||||
// all keys that aren't valid URIs are form field names (containing form data).
|
||||
char* realm = nsnull;
|
||||
if (!KeyIsURI(key, &realm)) {
|
||||
nsXPIDLCString realm;
|
||||
if (!KeyIsURI(key, getter_Copies(realm))) {
|
||||
// Search the data for a username that matches one of the found signons.
|
||||
EnumerateUsernames(key, (PRUnichar*)data, (count/sizeof(PRUnichar)), aSignonsFound);
|
||||
}
|
||||
|
@ -870,11 +870,11 @@ nsIEProfileMigrator::ResolveAndMigrateSignons(IPStore* aPStore, nsVoidArray* aSi
|
|||
}
|
||||
}
|
||||
// Now that we've done resolving signons, we need to walk the signons list, freeing the data buffers
|
||||
// for each SIGNONDATA entry, since these buffers were allocated by the system back in |GetSignonListFromPStore|
|
||||
// for each SignonData entry, since these buffers were allocated by the system back in |GetSignonListFromPStore|
|
||||
// but never freed.
|
||||
PRInt32 signonCount = aSignonsFound->Count();
|
||||
for (PRInt32 i = 0; i < signonCount; ++i) {
|
||||
SIGNONDATA* sd = (SIGNONDATA*)aSignonsFound->ElementAt(i);
|
||||
SignonData* sd = (SignonData*)aSignonsFound->ElementAt(i);
|
||||
::CoTaskMemFree(sd->user); // |sd->user| is a pointer to the start of a buffer that also contains sd->pass
|
||||
nsCRT::free(sd->realm);
|
||||
delete sd;
|
||||
|
@ -899,7 +899,7 @@ nsIEProfileMigrator::EnumerateUsernames(const nsAString& aKey, PRUnichar* aData,
|
|||
|
||||
// Compare the value at the current cursor position with the collected list of signons
|
||||
for (PRInt32 i = 0; i < signonCount; ++i) {
|
||||
SIGNONDATA* sd = (SIGNONDATA*)aSignonsFound->ElementAt(i);
|
||||
SignonData* sd = (SignonData*)aSignonsFound->ElementAt(i);
|
||||
if (curr.Equals(sd->user)) {
|
||||
// Bingo! Found a username in the saved data for this item. Now, add a Signon.
|
||||
nsDependentString usernameStr(sd->user), passStr(sd->pass);
|
||||
|
@ -982,8 +982,8 @@ nsIEProfileMigrator::CopyFormData(PRBool aReplace)
|
|||
if (suffix.EqualsIgnoreCase(":StringData")) {
|
||||
// :StringData contains the saved data
|
||||
const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11);
|
||||
char* realm = nsnull;
|
||||
if (!KeyIsURI(key, &realm))
|
||||
nsXPIDLCString realm;
|
||||
if (!KeyIsURI(key, getter_Copies(realm)))
|
||||
AddDataToFormHistory(key, (PRUnichar*)data, (count/sizeof(PRUnichar)));
|
||||
}
|
||||
}
|
||||
|
@ -1763,7 +1763,8 @@ nsIEProfileMigrator::CopySecurityPrefs(nsIPrefBranch* aPrefs)
|
|||
if (::RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
|
||||
0, KEY_READ, &key) == ERROR_SUCCESS) {
|
||||
DWORD length, value, type;
|
||||
DWORD value, type;
|
||||
DWORD length = sizeof DWORD;
|
||||
if (::RegQueryValueEx(key, "SecureProtocols", 0, &type, (LPBYTE)&value, &length) == ERROR_SUCCESS) {
|
||||
aPrefs->SetBoolPref("security.enable_ssl2", value & 0x08);
|
||||
aPrefs->SetBoolPref("security.enable_ssl3", value & 0x20);
|
||||
|
@ -1774,13 +1775,13 @@ nsIEProfileMigrator::CopySecurityPrefs(nsIPrefBranch* aPrefs)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
struct ProxyData {
|
||||
char* prefix;
|
||||
PRInt32 prefixLength;
|
||||
PRBool proxyConfigured;
|
||||
char* hostPref;
|
||||
char* portPref;
|
||||
} PROXYDATA;
|
||||
};
|
||||
|
||||
nsresult
|
||||
nsIEProfileMigrator::CopyProxyPreferences(nsIPrefBranch* aPrefs)
|
||||
|
@ -1816,7 +1817,7 @@ nsIEProfileMigrator::CopyProxyPreferences(nsIPrefBranch* aPrefs)
|
|||
if (r == ERROR_SUCCESS) {
|
||||
nsCAutoString bufStr; bufStr = (char*)buf;
|
||||
|
||||
PROXYDATA data[] = {
|
||||
ProxyData data[] = {
|
||||
{ "ftp=", 4, PR_FALSE, "network.proxy.ftp", "network.proxy.ftp_port" },
|
||||
{ "gopher=", 7, PR_FALSE, "network.proxy.gopher", "network.proxy.gopher_port" },
|
||||
{ "http=", 5, PR_FALSE, "network.proxy.http", "network.proxy.http_port" },
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
|
||||
#include "nsINIParser.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
nsINIParser::nsINIParser(const char *aFilename)
|
||||
{
|
||||
|
@ -84,6 +85,10 @@ bail:
|
|||
|
||||
nsINIParser::~nsINIParser()
|
||||
{
|
||||
if (mFileBuf) {
|
||||
nsCRT::free(mFileBuf);
|
||||
mFileBuf = nsnull;
|
||||
}
|
||||
DUMP("~nsINIParser");
|
||||
}
|
||||
|
||||
|
|
|
@ -235,21 +235,21 @@ nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistr
|
|||
nsresult
|
||||
nsNetscapeProfileMigratorBase::GetString(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
GETPREF(xform, GetCharPref, &xform->stringValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNetscapeProfileMigratorBase::SetString(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
SETPREF(xform, SetCharPref, xform->stringValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNetscapeProfileMigratorBase::GetWString(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
nsCOMPtr<nsIPrefLocalizedString> prefValue;
|
||||
nsresult rv = aBranch->GetComplexValue(xform->sourcePrefName,
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
|
@ -268,7 +268,7 @@ nsNetscapeProfileMigratorBase::GetWString(void* aTransform, nsIPrefBranch* aBran
|
|||
nsresult
|
||||
nsNetscapeProfileMigratorBase::SetWStringFromASCII(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
if (xform->prefHasValue) {
|
||||
nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1"));
|
||||
nsAutoString data; data.AssignWithConversion(xform->stringValue);
|
||||
|
@ -281,7 +281,7 @@ nsNetscapeProfileMigratorBase::SetWStringFromASCII(void* aTransform, nsIPrefBran
|
|||
nsresult
|
||||
nsNetscapeProfileMigratorBase::SetWString(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
if (xform->prefHasValue) {
|
||||
nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1"));
|
||||
nsAutoString data = NS_ConvertUTF8toUCS2(xform->stringValue);
|
||||
|
@ -295,28 +295,28 @@ nsNetscapeProfileMigratorBase::SetWString(void* aTransform, nsIPrefBranch* aBran
|
|||
nsresult
|
||||
nsNetscapeProfileMigratorBase::GetBool(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
GETPREF(xform, GetBoolPref, &xform->boolValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNetscapeProfileMigratorBase::SetBool(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
SETPREF(xform, SetBoolPref, xform->boolValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNetscapeProfileMigratorBase::GetInt(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
GETPREF(xform, GetIntPref, &xform->intValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNetscapeProfileMigratorBase::SetInt(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
SETPREF(xform, SetIntPref, xform->intValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
public:
|
||||
typedef nsresult(*prefConverter)(void*, nsIPrefBranch*);
|
||||
|
||||
typedef struct {
|
||||
struct PrefTransform {
|
||||
char* sourcePrefName;
|
||||
char* targetPrefName;
|
||||
prefConverter prefGetterFunc;
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
PRBool boolValue;
|
||||
char* stringValue;
|
||||
};
|
||||
} PREFTRANSFORM;
|
||||
};
|
||||
|
||||
static nsresult GetString(void* aTransform, nsIPrefBranch* aBranch);
|
||||
static nsresult SetString(void* aTransform, nsIPrefBranch* aBranch);
|
||||
|
|
|
@ -131,35 +131,22 @@ nsOperaProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
if (!mOperaProfile)
|
||||
GetOperaProfile(aProfile, getter_AddRefs(mOperaProfile));
|
||||
|
||||
const MIGRATIONDATA data[] = { { ToNewUnicode(OPERA_PREFERENCES_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(OPERA_COOKIES_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(OPERA_HISTORY_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::HISTORY,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(OPERA_BOOKMARKS_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_FALSE } };
|
||||
MigrationData data[] = { { ToNewUnicode(OPERA_PREFERENCES_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(OPERA_COOKIES_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(OPERA_HISTORY_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::HISTORY,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(OPERA_BOOKMARKS_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_FALSE } };
|
||||
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
PRBool exists;
|
||||
for (PRInt32 i = 0; i < 4; ++i) {
|
||||
// Don't list items that can only be imported in replace-mode when
|
||||
// we aren't being run in replace-mode.
|
||||
if (!aReplace && data[i].replaceOnly)
|
||||
continue;
|
||||
|
||||
mOperaProfile->Clone(getter_AddRefs(sourceFile));
|
||||
sourceFile->Append(nsDependentString(data[i].fileName));
|
||||
sourceFile->Exists(&exists);
|
||||
if (exists)
|
||||
*aResult |= data[i].sourceFlag;
|
||||
|
||||
nsCRT::free(data[i].fileName);
|
||||
}
|
||||
// Frees file name strings allocated above.
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
aReplace, mOperaProfile, aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -274,7 +261,7 @@ nsOperaProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
|||
#define _OPM(type) nsOperaProfileMigrator::type
|
||||
|
||||
static
|
||||
nsOperaProfileMigrator::PREFTRANSFORM gTransforms[] = {
|
||||
nsOperaProfileMigrator::PrefTransform gTransforms[] = {
|
||||
{ "User Prefs", "Download Directory", _OPM(STRING), "browser.download.defaultFolder", _OPM(SetFile), PR_FALSE, -1 },
|
||||
{ nsnull, "Enable Cookies", _OPM(INT), "network.cookie.cookieBehavior", _OPM(SetCookieBehavior), PR_FALSE, -1 },
|
||||
{ nsnull, "Accept Cookies Session Only", _OPM(BOOL), "network.cookie.enableForCurrentSessionOnly", _OPM(SetBool), PR_FALSE, -1 },
|
||||
|
@ -301,7 +288,7 @@ nsOperaProfileMigrator::PREFTRANSFORM gTransforms[] = {
|
|||
nsresult
|
||||
nsOperaProfileMigrator::SetFile(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
nsCOMPtr<nsILocalFile> lf(do_CreateInstance("@mozilla.org/file/local;1"));
|
||||
lf->InitWithNativePath(nsDependentCString(xform->stringValue));
|
||||
return aBranch->SetComplexValue(xform->targetPrefName, NS_GET_IID(nsILocalFile), lf);
|
||||
|
@ -310,7 +297,7 @@ nsOperaProfileMigrator::SetFile(void* aTransform, nsIPrefBranch* aBranch)
|
|||
nsresult
|
||||
nsOperaProfileMigrator::SetCookieBehavior(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
PRInt32 val = (xform->intValue == 3) ? 0 : (xform->intValue == 0) ? 2 : 1;
|
||||
return aBranch->SetIntPref(xform->targetPrefName, val);
|
||||
}
|
||||
|
@ -318,21 +305,21 @@ nsOperaProfileMigrator::SetCookieBehavior(void* aTransform, nsIPrefBranch* aBran
|
|||
nsresult
|
||||
nsOperaProfileMigrator::SetImageBehavior(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
return aBranch->SetIntPref(xform->targetPrefName, xform->boolValue ? 0 : 2);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsOperaProfileMigrator::SetBool(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
return aBranch->SetBoolPref(xform->targetPrefName, xform->boolValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsOperaProfileMigrator::SetWString(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1"));
|
||||
nsAutoString data; data.AssignWithConversion(xform->stringValue);
|
||||
pls->SetData(data.get());
|
||||
|
@ -342,14 +329,14 @@ nsOperaProfileMigrator::SetWString(void* aTransform, nsIPrefBranch* aBranch)
|
|||
nsresult
|
||||
nsOperaProfileMigrator::SetInt(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
return aBranch->SetIntPref(xform->targetPrefName, xform->intValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsOperaProfileMigrator::SetString(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
return aBranch->SetCharPref(xform->targetPrefName, xform->stringValue);
|
||||
}
|
||||
|
||||
|
@ -369,8 +356,8 @@ nsOperaProfileMigrator::CopyPreferences(PRBool aReplace)
|
|||
nsCOMPtr<nsIPrefBranch> branch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
|
||||
// Traverse the standard transforms
|
||||
PREFTRANSFORM* transform;
|
||||
PREFTRANSFORM* end = gTransforms + sizeof(gTransforms)/sizeof(PREFTRANSFORM);
|
||||
PrefTransform* transform;
|
||||
PrefTransform* end = gTransforms + sizeof(gTransforms)/sizeof(PrefTransform);
|
||||
|
||||
PRInt32 length;
|
||||
char* lastSectionName = nsnull;
|
||||
|
@ -1343,46 +1330,3 @@ nsOperaProfileMigrator::GetOperaProfile(const PRUnichar* aProfile, nsILocalFile*
|
|||
NS_ADDREF(*aFile);
|
||||
}
|
||||
|
||||
void SetProxyPref(const nsACString& aHostPort, const char* aPref,
|
||||
const char* aPortPref, nsIPrefBranch* aPrefs)
|
||||
{
|
||||
nsCAutoString hostPort(aHostPort);
|
||||
PRInt32 portDelimOffset = hostPort.RFindChar(':');
|
||||
if (portDelimOffset) {
|
||||
nsCAutoString host(Substring(hostPort, 0, portDelimOffset));
|
||||
nsCAutoString port(Substring(hostPort, portDelimOffset + 1, hostPort.Length() - portDelimOffset + 1));
|
||||
|
||||
aPrefs->SetCharPref(aPref, host.get());
|
||||
PRInt32 stringErr;
|
||||
PRInt32 portValue = port.ToInteger(&stringErr);
|
||||
aPrefs->SetIntPref(aPortPref, portValue);
|
||||
}
|
||||
else {
|
||||
aPrefs->SetCharPref(aPref, hostPort.get());
|
||||
}
|
||||
}
|
||||
|
||||
void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch)
|
||||
{
|
||||
// First check to see if the value is "<local>", if so, set the field to
|
||||
// "localhost,127.0.0.1"
|
||||
nsCAutoString override; override = aServers;
|
||||
if (override.Equals("<local>")) {
|
||||
aBranch->SetCharPref("network.proxy.no_proxies_on", "localhost,127.0.0.1");
|
||||
}
|
||||
else {
|
||||
// If it's not, then replace every ";" character with ","
|
||||
PRInt32 offset = 0, temp = 0;
|
||||
while (offset != -1) {
|
||||
offset = override.FindChar(';', offset);
|
||||
const nsACString& host = Substring(override, temp, offset < 0 ? override.Length() - temp : offset - temp);
|
||||
if (host.Equals("<local>"))
|
||||
override.Replace(temp, 7, NS_LITERAL_CSTRING("localhost,127.0.0.1"));
|
||||
temp = offset + 1;
|
||||
if (offset != -1)
|
||||
override.Replace(offset, 1, NS_LITERAL_CSTRING(","));
|
||||
}
|
||||
aBranch->SetCharPref("network.proxy.no_proxies_on", override.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
typedef nsresult(*prefConverter)(void*, nsIPrefBranch*);
|
||||
|
||||
typedef struct {
|
||||
struct PrefTransform {
|
||||
char* sectionName;
|
||||
char* keyName;
|
||||
PrefType type;
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
PRBool boolValue;
|
||||
char* stringValue;
|
||||
};
|
||||
} PREFTRANSFORM;
|
||||
};
|
||||
|
||||
static nsresult SetFile(void* aTransform, nsIPrefBranch* aBranch);
|
||||
static nsresult SetCookieBehavior(void* aTransform, nsIPrefBranch* aBranch);
|
||||
|
@ -177,19 +177,19 @@ private:
|
|||
nsVoidArray mDomainStack;
|
||||
nsVoidArray mPathStack;
|
||||
|
||||
typedef struct {
|
||||
struct Cookie {
|
||||
nsCString id;
|
||||
nsCString data;
|
||||
PRInt32 expiryTime;
|
||||
PRBool isSecure;
|
||||
} COOKIE;
|
||||
};
|
||||
|
||||
PRUint32 mAppVersion;
|
||||
PRUint32 mFileVersion;
|
||||
PRUint16 mTagTypeLength;
|
||||
PRUint16 mPayloadTypeLength;
|
||||
PRBool mCookieOpen;
|
||||
COOKIE mCurrCookie;
|
||||
Cookie mCurrCookie;
|
||||
PRUint8 mCurrHandlingInfo;
|
||||
|
||||
};
|
||||
|
|
|
@ -130,47 +130,34 @@ nsPhoenixProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
if (!mSourceProfile)
|
||||
GetSourceProfile(aProfile);
|
||||
|
||||
const MIGRATIONDATA data[] = { { ToNewUnicode(FILE_NAME_PREFS),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_COOKIES),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_HISTORY),
|
||||
nsIBrowserProfileMigrator::HISTORY,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_BOOKMARKS),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_DOWNLOADS),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_MIMETYPES),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_USERCHROME),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_USERCONTENT),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE } };
|
||||
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
PRBool exists;
|
||||
for (PRInt32 i = 0; i < 8; ++i) {
|
||||
// Don't list items that can only be imported in replace-mode when
|
||||
// we aren't being run in replace-mode.
|
||||
if (!aReplace && data[i].replaceOnly)
|
||||
continue;
|
||||
MigrationData data[] = { { ToNewUnicode(FILE_NAME_PREFS),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_COOKIES),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_HISTORY),
|
||||
nsIBrowserProfileMigrator::HISTORY,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_BOOKMARKS),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_DOWNLOADS),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_MIMETYPES),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_USERCHROME),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_USERCONTENT),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE } };
|
||||
|
||||
mSourceProfile->Clone(getter_AddRefs(sourceFile));
|
||||
sourceFile->Append(nsDependentString(data[i].fileName));
|
||||
sourceFile->Exists(&exists);
|
||||
if (exists)
|
||||
*aResult |= data[i].sourceFlag;
|
||||
|
||||
nsCRT::free(data[i].fileName);
|
||||
}
|
||||
// Frees file name strings allocated above.
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
aReplace, mSourceProfile, aResult);
|
||||
|
||||
// Now locate passwords
|
||||
nsXPIDLCString signonsFileName;
|
||||
|
@ -181,7 +168,8 @@ nsPhoenixProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
nsCOMPtr<nsIFile> sourcePasswordsFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile));
|
||||
sourcePasswordsFile->Append(fileName);
|
||||
|
||||
|
||||
PRBool exists;
|
||||
sourcePasswordsFile->Exists(&exists);
|
||||
if (exists)
|
||||
*aResult |= nsIBrowserProfileMigrator::PASSWORDS;
|
||||
|
|
|
@ -167,7 +167,7 @@ GetPListFromFile(nsILocalFile* aPListFile, CFPropertyListRef* aResult)
|
|||
#define _SPM(type) nsSafariProfileMigrator::type
|
||||
|
||||
static
|
||||
nsSafariProfileMigrator::PREFTRANSFORM gTransforms[] = {
|
||||
nsSafariProfileMigrator::PrefTransform gTransforms[] = {
|
||||
{ CFSTR("AlwaysShowTabBar"), _SPM(BOOL), "browser.tabs.autoHide", _SPM(SetBoolInverted), PR_FALSE, -1 },
|
||||
{ CFSTR("AutoFillPasswords"), _SPM(BOOL), "signon.rememberSignons", _SPM(SetBool), PR_FALSE, -1 },
|
||||
{ CFSTR("OpenNewTabsInFront"), _SPM(BOOL), "browser.tabs.loadInBackground", _SPM(SetBoolInverted), PR_FALSE, -1 },
|
||||
|
@ -195,35 +195,35 @@ WebKitUserStyleSheetLocationPreferenceKey - STRING
|
|||
nsresult
|
||||
nsSafariProfileMigrator::SetBool(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
return aBranch->SetBoolPref(xform->targetPrefName, xform->boolValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSafariProfileMigrator::SetBoolInverted(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
return aBranch->SetBoolPref(xform->targetPrefName, !xform->boolValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSafariProfileMigrator::SetString(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
return aBranch->SetCharPref(xform->targetPrefName, xform->stringValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSafariProfileMigrator::SetInt(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
return aBranch->SetIntPref(xform->targetPrefName, !xform->intValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSafariProfileMigrator::SetDefaultEncoding(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
|
||||
nsCAutoString encodingSuffix;
|
||||
nsDependentCString encoding(xform->stringValue);
|
||||
|
@ -282,7 +282,7 @@ nsSafariProfileMigrator::SetDefaultEncoding(void* aTransform, nsIPrefBranch* aBr
|
|||
nsresult
|
||||
nsSafariProfileMigrator::SetDownloadFolder(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
|
||||
nsCOMPtr<nsILocalFile> downloadFolder(do_CreateInstance("@mozilla.org/file/local;1"));
|
||||
downloadFolder->InitWithNativePath(nsDependentCString(xform->stringValue));
|
||||
|
@ -305,7 +305,7 @@ nsSafariProfileMigrator::SetDownloadFolder(void* aTransform, nsIPrefBranch* aBra
|
|||
nsresult
|
||||
nsSafariProfileMigrator::SetDownloadHandlers(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
if (!xform->boolValue) {
|
||||
// If we're not set to auto-open safe downloads, we need to clear out the mime types
|
||||
// list which contains default handlers.
|
||||
|
@ -423,8 +423,8 @@ nsSafariProfileMigrator::CopyPreferences(PRBool aReplace)
|
|||
return NS_OK;
|
||||
|
||||
// Traverse the standard transforms
|
||||
PREFTRANSFORM* transform;
|
||||
PREFTRANSFORM* end = gTransforms + sizeof(gTransforms)/sizeof(PREFTRANSFORM);
|
||||
PrefTransform* transform;
|
||||
PrefTransform* end = gTransforms + sizeof(gTransforms)/sizeof(PrefTransform);
|
||||
|
||||
for (transform = gTransforms; transform < end; ++transform) {
|
||||
Boolean hasValue = ::CFDictionaryContainsKey(safariPrefs, transform->keyName);
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
typedef nsresult(*prefConverter)(void*, nsIPrefBranch*);
|
||||
|
||||
typedef struct {
|
||||
struct PrefTransform {
|
||||
CFStringRef keyName;
|
||||
PrefType type;
|
||||
char* targetPrefName;
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
PRBool boolValue;
|
||||
char* stringValue;
|
||||
};
|
||||
} PREFTRANSFORM;
|
||||
};
|
||||
|
||||
static nsresult SetBool(void* aTransform, nsIPrefBranch* aBranch);
|
||||
static nsresult SetBoolInverted(void* aTransform, nsIPrefBranch* aBranch);
|
||||
|
|
|
@ -125,41 +125,28 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
if (!mSourceProfile)
|
||||
GetSourceProfile(aProfile);
|
||||
|
||||
const MIGRATIONDATA data[] = { { ToNewUnicode(FILE_NAME_PREFS),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_COOKIES),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(FILE_NAME_HISTORY),
|
||||
nsIBrowserProfileMigrator::HISTORY,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_BOOKMARKS),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(FILE_NAME_DOWNLOADS),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_MIMETYPES),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE } };
|
||||
MigrationData data[] = { { ToNewUnicode(FILE_NAME_PREFS),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_COOKIES),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(FILE_NAME_HISTORY),
|
||||
nsIBrowserProfileMigrator::HISTORY,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_BOOKMARKS),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(FILE_NAME_DOWNLOADS),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_MIMETYPES),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE } };
|
||||
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
PRBool exists;
|
||||
for (PRInt32 i = 0; i < 6; ++i) {
|
||||
// Don't list items that can only be imported in replace-mode when
|
||||
// we aren't being run in replace-mode.
|
||||
if (!aReplace && data[i].replaceOnly)
|
||||
continue;
|
||||
|
||||
mSourceProfile->Clone(getter_AddRefs(sourceFile));
|
||||
sourceFile->Append(nsDependentString(data[i].fileName));
|
||||
sourceFile->Exists(&exists);
|
||||
if (exists)
|
||||
*aResult |= data[i].sourceFlag;
|
||||
|
||||
nsCRT::free(data[i].fileName);
|
||||
}
|
||||
// Frees file name strings allocated above.
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
aReplace, mSourceProfile, aResult);
|
||||
|
||||
// Now locate passwords
|
||||
nsXPIDLCString signonsFileName;
|
||||
|
@ -171,6 +158,7 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile));
|
||||
sourcePasswordsFile->Append(fileName);
|
||||
|
||||
PRBool exists;
|
||||
sourcePasswordsFile->Exists(&exists);
|
||||
if (exists)
|
||||
*aResult |= nsIBrowserProfileMigrator::PASSWORDS;
|
||||
|
@ -288,7 +276,7 @@ nsSeamonkeyProfileMigrator::FillProfileDataFromSeamonkeyRegistry()
|
|||
|
||||
|
||||
static
|
||||
nsSeamonkeyProfileMigrator::PREFTRANSFORM gTransforms[] = {
|
||||
nsSeamonkeyProfileMigrator::PrefTransform gTransforms[] = {
|
||||
MAKESAMETYPEPREFTRANSFORM("signon.SignonFileName", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("browser.startup.homepage", WString),
|
||||
MAKESAMETYPEPREFTRANSFORM("browser.history_expire_days", Int),
|
||||
|
@ -354,7 +342,7 @@ nsSeamonkeyProfileMigrator::PREFTRANSFORM gTransforms[] = {
|
|||
nsresult
|
||||
nsSeamonkeyProfileMigrator::SetImage(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (xform->prefHasValue)
|
||||
|
@ -366,7 +354,7 @@ nsSeamonkeyProfileMigrator::SetImage(void* aTransform, nsIPrefBranch* aBranch)
|
|||
nsresult
|
||||
nsSeamonkeyProfileMigrator::SetCookie(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (xform->prefHasValue)
|
||||
|
@ -378,7 +366,7 @@ nsSeamonkeyProfileMigrator::SetCookie(void* aTransform, nsIPrefBranch* aBranch)
|
|||
nsresult
|
||||
nsSeamonkeyProfileMigrator::SetDownloadManager(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PREFTRANSFORM* xform = (PREFTRANSFORM*)aTransform;
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (xform->prefHasValue) {
|
||||
|
@ -402,8 +390,8 @@ nsresult
|
|||
nsSeamonkeyProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFileName,
|
||||
const nsAString& aTargetPrefFileName)
|
||||
{
|
||||
PREFTRANSFORM* transform;
|
||||
PREFTRANSFORM* end = gTransforms + sizeof(gTransforms)/sizeof(PREFTRANSFORM);
|
||||
PrefTransform* transform;
|
||||
PrefTransform* end = gTransforms + sizeof(gTransforms)/sizeof(PrefTransform);
|
||||
|
||||
// Load the source pref file
|
||||
nsCOMPtr<nsIPrefService> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
|
@ -441,7 +429,7 @@ nsSeamonkeyProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFil
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
struct FontPref {
|
||||
char* prefName;
|
||||
PRInt32 type;
|
||||
union {
|
||||
|
@ -450,7 +438,7 @@ typedef struct {
|
|||
PRBool boolValue;
|
||||
PRUnichar* wstringValue;
|
||||
};
|
||||
} FontPref;
|
||||
};
|
||||
|
||||
void
|
||||
nsSeamonkeyProfileMigrator::ReadFontsBranch(nsIPrefService* aPrefService,
|
||||
|
|
Загрузка…
Ссылка в новой задаче