bug 250255 : use nsIWindowsRegKey for Windows registry handling (MSIE profile migrator patch) : r=biesi, sr=darin

This commit is contained in:
jshin@mailaps.org
2005-10-02 02:01:10 +00:00
parent 1a117a9240
commit e58d7df7d7
4 changed files with 180 additions and 158 deletions

View File

@@ -46,6 +46,7 @@
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nsISupportsPrimitives.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsIRDFService.h"
@@ -55,10 +56,21 @@
#include "nsCRT.h"
#define MIGRATION_BUNDLE "chrome://browser/locale/migration/migration.properties"
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
void SetProxyPref(const nsACString& aHostPort, const char* aPref,
void SetUnicharPref(const char* aPref, const nsAString& aValue,
nsIPrefBranch* aPrefs)
{
nsCOMPtr<nsISupportsString> supportsString =
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
if (supportsString) {
supportsString->SetData(aValue);
aPrefs->SetComplexValue(aPref, NS_GET_IID(nsISupportsString),
supportsString);
}
}
void SetProxyPref(const nsAString& aHostPort, const char* aPref,
const char* aPortPref, nsIPrefBranch* aPrefs)
{
nsCOMPtr<nsIURI> uri;
@@ -70,47 +82,44 @@ void SetProxyPref(const nsACString& aHostPort, const char* aPref,
&& NS_SUCCEEDED(uri->GetHost(host))
&& !host.IsEmpty()
&& NS_SUCCEEDED(uri->GetPort(&portValue))) {
aPrefs->SetCharPref(aPref, host.get());
SetUnicharPref(aPref, NS_ConvertUTF8toUTF16(host), aPrefs);
aPrefs->SetIntPref(aPortPref, portValue);
}
else {
nsCAutoString hostPort(aHostPort);
nsAutoString hostPort(aHostPort);
PRInt32 portDelimOffset = hostPort.RFindChar(':');
if (portDelimOffset > 0) {
host = Substring(hostPort, 0, portDelimOffset);
nsCAutoString port(Substring(hostPort, portDelimOffset + 1,
hostPort.Length() - (portDelimOffset + 1)));
aPrefs->SetCharPref(aPref, host.get());
SetUnicharPref(aPref, Substring(hostPort, 0, portDelimOffset), aPrefs);
nsAutoString port(Substring(hostPort, portDelimOffset + 1));
PRInt32 stringErr;
portValue = port.ToInteger(&stringErr);
aPrefs->SetIntPref(aPortPref, portValue);
}
else
aPrefs->SetCharPref(aPref, hostPort.get());
SetUnicharPref(aPref, hostPort, aPrefs);
}
}
void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch)
void ParseOverrideServers(const nsAString& 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);
nsAutoString 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"));
const nsAString& host = Substring(override, left,
(right < 0 ? override.Length() : right) - left);
if (host.EqualsLiteral("<local>"))
override.Replace(left, 7, NS_LITERAL_STRING("localhost,127.0.0.1"));
if (right < 0)
break;
left = right + 1;
override.Replace(right, 1, NS_LITERAL_CSTRING(","));
override.Replace(right, 1, NS_LITERAL_STRING(","));
}
aBranch->SetCharPref("network.proxy.no_proxies_on", override.get());
SetUnicharPref("network.proxy.no_proxies_on", override, aBranch);
}
void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength,