Bug 333874 - cannot build ffox against xulrunner due to xpcom_obsolete dependency, patch by Pawl Chmielowski <prefiks@aviary.pl>, r=me
git-svn-id: svn://10.0.0.236/trunk@194683 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
59e55aa87f
commit
6f5ddb059c
@ -92,14 +92,13 @@ EXTRA_DSO_LDOPTS += \
|
||||
$(LIBS_DIR) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(DEPTH)/modules/libreg/src/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \
|
||||
$(MOZ_XPCOM_OBSOLETE_LIBS) \
|
||||
$(LIBXUL_DIST)/../modules/libreg/src/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PLACES
|
||||
EXTRA_DSO_LDOPTS += $(DEPTH)/db/morkreader/$(LIB_PREFIX)morkreader_s.$(LIB_SUFFIX)
|
||||
EXTRA_DSO_LDOPTS += $(LIBXUL_DIST)/../db/morkreader/$(LIB_PREFIX)morkreader_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
# Mac: Need to link with CoreFoundation for Mac Migrators (PList reading code)
|
||||
|
||||
@ -46,8 +46,7 @@ LIBRARY_NAME = migration_s
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
xpcom_obsolete \
|
||||
xpcom \
|
||||
string \
|
||||
necko \
|
||||
history \
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "NSReg.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIURL.h"
|
||||
@ -70,12 +70,28 @@ nsNetscapeProfileMigratorBase::nsNetscapeProfileMigratorBase()
|
||||
{
|
||||
}
|
||||
|
||||
static nsresult
|
||||
regerr2nsresult(REGERR errCode)
|
||||
{
|
||||
switch (errCode) {
|
||||
case REGERR_PARAM:
|
||||
case REGERR_BADTYPE:
|
||||
case REGERR_BADNAME:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
case REGERR_MEMORY:
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistryFile,
|
||||
nsISupportsArray* aProfileNames,
|
||||
nsISupportsArray* aProfileLocations)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsresult rv;
|
||||
REGERR errCode;
|
||||
|
||||
// Ensure aRegistryFile exists before open it
|
||||
PRBool regFileExists = PR_FALSE;
|
||||
@ -85,67 +101,93 @@ nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistr
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
|
||||
// Open It
|
||||
nsCOMPtr<nsIRegistry> reg(do_CreateInstance("@mozilla.org/registry;1"));
|
||||
reg->Open(aRegistryFile);
|
||||
nsCAutoString regPath;
|
||||
rv = aRegistryFile->GetNativePath(regPath);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRegistryKey profilesTree;
|
||||
rv = reg->GetKey(nsIRegistry::Common, NS_LITERAL_STRING("Profiles").get(), &profilesTree);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if ((errCode = NR_StartupRegistry()))
|
||||
return regerr2nsresult(errCode);
|
||||
|
||||
nsCOMPtr<nsIEnumerator> keys;
|
||||
reg->EnumerateSubtrees(profilesTree, getter_AddRefs(keys));
|
||||
HREG reg;
|
||||
if ((errCode = NR_RegOpen(regPath.get(), ®))) {
|
||||
NR_ShutdownRegistry();
|
||||
|
||||
keys->First();
|
||||
while (keys->IsDone() != NS_OK) {
|
||||
nsCOMPtr<nsISupports> key;
|
||||
keys->CurrentItem(getter_AddRefs(key));
|
||||
return regerr2nsresult(errCode);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRegistryNode> node(do_QueryInterface(key));
|
||||
RKEY profilesTree;
|
||||
if ((errCode = NR_RegGetKey(reg, ROOTKEY_COMMON, "Profiles", &profilesTree))) {
|
||||
NR_RegClose(reg);
|
||||
NR_ShutdownRegistry();
|
||||
|
||||
nsRegistryKey profile;
|
||||
node->GetKey(&profile);
|
||||
return regerr2nsresult(errCode);
|
||||
}
|
||||
|
||||
char profileStr[MAXREGPATHLEN];
|
||||
REGENUM enumState = nsnull;
|
||||
|
||||
while (!NR_RegEnumSubkeys(reg, profilesTree, &enumState, profileStr,
|
||||
sizeof(profileStr), REGENUM_CHILDREN))
|
||||
{
|
||||
RKEY profileKey;
|
||||
if (NR_RegGetKey(reg, profilesTree, profileStr, &profileKey))
|
||||
continue;
|
||||
|
||||
// "migrated" is "yes" for all valid Seamonkey profiles. It is only "no"
|
||||
// for 4.x profiles.
|
||||
nsXPIDLString isMigrated;
|
||||
reg->GetString(profile, NS_LITERAL_STRING("migrated").get(), getter_Copies(isMigrated));
|
||||
|
||||
if (isMigrated.Equals(NS_LITERAL_STRING("no"))) {
|
||||
keys->Next();
|
||||
char migratedStr[3];
|
||||
errCode = NR_RegGetEntryString(reg, profileKey, "migrated",
|
||||
migratedStr, sizeof(migratedStr));
|
||||
if ((errCode != REGERR_OK && errCode != REGERR_BUFTOOSMALL) ||
|
||||
strcmp(migratedStr, "no") == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the profile name and add it to the names array
|
||||
nsXPIDLString profileName;
|
||||
node->GetName(getter_Copies(profileName));
|
||||
|
||||
// Get the profile location and add it to the locations array
|
||||
nsXPIDLString directory;
|
||||
reg->GetString(profile, NS_LITERAL_STRING("directory").get(), getter_Copies(directory));
|
||||
REGINFO regInfo;
|
||||
regInfo.size = sizeof(REGINFO);
|
||||
|
||||
if (NR_RegGetEntryInfo(reg, profileKey, "directory", ®Info))
|
||||
continue;
|
||||
|
||||
nsCAutoString dirStr;
|
||||
dirStr.SetLength(regInfo.entryLength);
|
||||
|
||||
errCode = NR_RegGetEntryString(reg, profileKey, "directory",
|
||||
dirStr.BeginWriting(), regInfo.entryLength);
|
||||
// Remove trailing \0
|
||||
dirStr.SetLength(regInfo.entryLength-1);
|
||||
|
||||
nsCOMPtr<nsILocalFile> dir;
|
||||
#ifdef XP_MACOSX
|
||||
rv = NS_NewNativeLocalFile(EmptyCString(), PR_TRUE, getter_AddRefs(dir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
dir->SetPersistentDescriptor(NS_LossyConvertUTF16toASCII(directory));
|
||||
if (NS_FAILED(rv)) break;
|
||||
dir->SetPersistentDescriptor(dirStr);
|
||||
#else
|
||||
rv = NS_NewLocalFile(directory, PR_TRUE, getter_AddRefs(dir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(dirStr), PR_TRUE,
|
||||
getter_AddRefs(dir));
|
||||
if (NS_FAILED(rv)) break;
|
||||
#endif
|
||||
|
||||
PRBool exists;
|
||||
dir->Exists(&exists);
|
||||
|
||||
if (exists) {
|
||||
nsCOMPtr<nsISupportsString> profileNameString(do_CreateInstance("@mozilla.org/supports-string;1"));
|
||||
aProfileLocations->AppendElement(dir);
|
||||
|
||||
// Get the profile name and add it to the names array
|
||||
nsXPIDLString profileName;
|
||||
CopyUTF8toUTF16(profileStr, profileName);
|
||||
|
||||
nsCOMPtr<nsISupportsString> profileNameString(
|
||||
do_CreateInstance("@mozilla.org/supports-string;1"));
|
||||
|
||||
profileNameString->SetData(profileName);
|
||||
aProfileNames->AppendElement(profileNameString);
|
||||
|
||||
aProfileLocations->AppendElement(dir);
|
||||
}
|
||||
|
||||
keys->Next();
|
||||
}
|
||||
NR_RegClose(reg);
|
||||
NR_ShutdownRegistry();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user