зеркало из https://github.com/mozilla/gecko-dev.git
Fixing migration problems for japanese and european profiles. Used unicode persistent descriptor strings to get and set profile data. Removed all those prefs that had native characters in their values, from the list of profiles to be converted to utf8 format during migration. r=nhotta,alecf,sspitzer,ftang sr=alecf,ftang a=pdt
This commit is contained in:
Родитель
bbbd1ba018
Коммит
49021d8955
|
@ -2066,32 +2066,23 @@ nsPrefMigration::SetPremigratedFilePref(const char *pref_name, nsIFileSpec *path
|
|||
these are the prefs we know we need to convert to utf8.
|
||||
we'll also be converting:
|
||||
|
||||
Please make sure that any pref that contains native characters
|
||||
in it's value is not included in this list as we do not want to
|
||||
convert them into UTF-8 format. Prefs are being get and set in a
|
||||
unicode format (FileXPref) now and there is no need for
|
||||
conversion of those prefs.
|
||||
|
||||
"ldap_2.server.*.description"
|
||||
"intl.font*.fixed_font"
|
||||
"intl.font*.prop_font"
|
||||
*/
|
||||
|
||||
static const char *prefsToConvert[] = {
|
||||
"browser.cache.directory",
|
||||
"custtoolbar.personal_toolbar_folder",
|
||||
"editor.image_editor",
|
||||
"editor.html_editor",
|
||||
"editor.author",
|
||||
"helpers.private_mailcap_file",
|
||||
"helpers.private_mime_types_file",
|
||||
"li.server.ldap.userbase",
|
||||
"mail.default_drafts",
|
||||
"mail.default_fcc",
|
||||
"mail.default_templates",
|
||||
"mail.directory",
|
||||
"mail.identity.organization",
|
||||
"mail.identity.username",
|
||||
"mail.imap.root_dir",
|
||||
"mail.signature_file",
|
||||
"news.default_fcc",
|
||||
"news.directory",
|
||||
"premigration.mail.directory",
|
||||
"premigration.news.directory",
|
||||
nsnull
|
||||
};
|
||||
|
||||
|
|
|
@ -781,10 +781,8 @@ NS_IMETHODIMP nsProfile::GetProfileDir(const PRUnichar *profileName, nsIFile **p
|
|||
rv = NS_NewLocalFile(nsnull, PR_TRUE, getter_AddRefs(aProfileDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString profileLocation;
|
||||
PRBool validDesc;
|
||||
profileLocation.AssignWithConversion(aProfile->profileLocation);
|
||||
rv = aProfileDir->SetPersistentDescriptor(profileLocation.GetBuffer());
|
||||
rv = aProfileDir->InitWithUnicodePath((aProfile->profileLocation).GetUnicode());
|
||||
validDesc = NS_SUCCEEDED(rv);
|
||||
|
||||
// Set this to be a current profile only if it is a 5.0 profile
|
||||
|
@ -846,15 +844,11 @@ NS_IMETHODIMP nsProfile::GetProfileDir(const PRUnichar *profileName, nsIFile **p
|
|||
// Get persistent string for profile directory
|
||||
nsCOMPtr<nsILocalFile> tmpLocalFile(do_QueryInterface(newProfileDir, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString profileDirString;
|
||||
rv = tmpLocalFile->GetPersistentDescriptor(getter_Copies(profileDirString));
|
||||
nsXPIDLString profileDirString;
|
||||
rv = tmpLocalFile->GetUnicodePath(getter_Copies(profileDirString));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Update profile struct entries with new value.
|
||||
nsAutoString profileLoc;
|
||||
profileLoc.AssignWithConversion(profileDirString);
|
||||
|
||||
aProfile->profileLocation = profileLoc;
|
||||
aProfile->profileLocation = profileDirString;
|
||||
gProfileDataAccess->SetValue(aProfile);
|
||||
|
||||
// Return new file spec.
|
||||
|
@ -972,18 +966,16 @@ NS_IMETHODIMP nsProfile::SetProfileDir(const PRUnichar *profileName, nsIFile *pr
|
|||
|
||||
nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(profileDir));
|
||||
NS_ENSURE_TRUE(localFile, NS_ERROR_FAILURE);
|
||||
nsXPIDLCString profileDirString;
|
||||
rv = localFile->GetPersistentDescriptor(getter_Copies(profileDirString));
|
||||
nsXPIDLString profileDirString;
|
||||
rv = localFile->GetUnicodePath(getter_Copies(profileDirString));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
ProfileStruct* aProfile = new ProfileStruct();
|
||||
NS_ENSURE_TRUE(aProfile, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsAutoString profileLocation; profileLocation.AssignWithConversion(profileDirString);
|
||||
|
||||
|
||||
aProfile->profileName = profileName;
|
||||
aProfile->profileLocation = profileLocation;
|
||||
aProfile->profileLocation = profileDirString;
|
||||
aProfile->isMigrated.AssignWithConversion(REGISTRY_YES_STRING);
|
||||
|
||||
|
||||
|
@ -1413,10 +1405,9 @@ NS_IMETHODIMP nsProfile::MigrateProfileInfo()
|
|||
PL_strcpy(oldRegFile, systemDir.GetNativePathCString());
|
||||
PL_strcat(oldRegFile, OLD_REGISTRY_FILE_NAME);
|
||||
#else /* XP_MAC */
|
||||
nsSpecialSystemDirectory regLocation(nsSpecialSystemDirectory::Mac_SystemDirectory);
|
||||
nsSpecialSystemDirectory regLocation(nsSpecialSystemDirectory::Mac_PreferencesDirectory);
|
||||
|
||||
// Append the name of the old registry to the path obtained.
|
||||
regLocation += "Preferences";
|
||||
regLocation += OLD_REGISTRY_FILE_NAME;
|
||||
|
||||
PL_strcpy(oldRegFile, regLocation.GetNativePathCString());
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "nsFileStream.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
#define NS_IMPL_IDS
|
||||
#include "nsICharsetConverterManager.h"
|
||||
|
@ -1248,21 +1249,37 @@ nsProfileAccess::Get4xProfileInfo(const char *registryName)
|
|||
// For example something like %20 would probably be interpreted as a space
|
||||
// There is some problem I guess in sending a space as itself
|
||||
|
||||
#if defined(XP_MAC)
|
||||
// 4.x profiles coming from japanese machine are already in unicode.
|
||||
// So, there is no need to decode into unicode further.
|
||||
|
||||
// Unescape profile name.
|
||||
nsCAutoString temp;
|
||||
temp = (const char*) NS_ConvertUCS2toUTF8(profile);
|
||||
nsCAutoString profileName(nsUnescape( NS_CONST_CAST(char*, temp.GetBuffer())));
|
||||
nsAutoString convertedProfName((const PRUnichar*) NS_ConvertUTF8toUCS2(profileName));
|
||||
|
||||
// Unescape profile location
|
||||
nsCAutoString tempLoc;
|
||||
tempLoc = (const char*) NS_ConvertUCS2toUTF8(profLoc);
|
||||
nsCAutoString profileLocation(nsUnescape( NS_CONST_CAST(char*, tempLoc.GetBuffer())));
|
||||
nsAutoString convertedProfLoc((const PRUnichar*) NS_ConvertUTF8toUCS2(profileLocation));
|
||||
#else
|
||||
nsCAutoString temp; temp.AssignWithConversion(profile);
|
||||
|
||||
nsCAutoString profileName(nsUnescape( NS_CONST_CAST(char*, temp.GetBuffer())));
|
||||
nsAutoString convertedProfName;
|
||||
ConvertStringToUnicode(charSet, profileName.GetBuffer(), convertedProfName);
|
||||
|
||||
profileItem->profileName = convertedProfName;
|
||||
|
||||
// Unescape profile location and convert it to the right format
|
||||
nsCAutoString tempLoc; tempLoc.AssignWithConversion(profLoc);
|
||||
|
||||
nsCAutoString profileLocation(nsUnescape( NS_CONST_CAST(char*, tempLoc.GetBuffer())));
|
||||
nsAutoString convertedProfLoc;
|
||||
ConvertStringToUnicode(charSet, profileLocation.GetBuffer(), convertedProfLoc);
|
||||
#endif
|
||||
|
||||
profileItem->profileName = convertedProfName;
|
||||
profileItem->profileLocation = convertedProfLoc;
|
||||
|
||||
profileItem->isMigrated.AssignWithConversion(REGISTRY_NO_STRING);
|
||||
|
@ -1367,7 +1384,7 @@ nsProfileAccess::UpdateProfileArray()
|
|||
for (PRInt32 idx = 0; idx < m4xCount; idx++)
|
||||
{
|
||||
ProfileStruct* profileItem = (ProfileStruct *) (m4xProfiles->ElementAt(idx));
|
||||
nsFileSpec profileDir(profileItem->profileLocation);
|
||||
|
||||
|
||||
PRBool exists;
|
||||
exists = ProfileExists(profileItem->profileName.GetUnicode());
|
||||
|
@ -1379,16 +1396,17 @@ nsProfileAccess::UpdateProfileArray()
|
|||
continue;
|
||||
}
|
||||
|
||||
nsXPIDLCString profileDirString;
|
||||
nsCOMPtr<nsIFileSpec>spec;
|
||||
rv = NS_NewFileSpecWithSpec(profileDir, getter_AddRefs(spec));
|
||||
nsCOMPtr<nsILocalFile> locProfileDir (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
|
||||
rv = locProfileDir->InitWithUnicodePath((profileItem->profileLocation).GetUnicode());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLString profileDirString;
|
||||
rv = locProfileDir->GetUnicodePath(getter_Copies(profileDirString));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = spec->GetPersistentDescriptorString(getter_Copies(profileDirString));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && profileDirString)
|
||||
{
|
||||
profileItem->profileLocation.AssignWithConversion(profileDirString);
|
||||
profileItem->profileLocation = profileDirString;
|
||||
SetValue(profileItem);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче