fix for #55449. we over-localized some of the international 4.x release,

and localized the folder names "Mail" and "News" when we weren't supposed to.
this fix makes it so we do this when we migrate

1)  try the pref first
2)  if the pref is not set, try "4.x profile dir"/"Mail"
3)  if "4.x profile dir"/"Mail" doesn't exist, try "4.x profile dir"/"Localize-Word-For-Mail"
This commit is contained in:
sspitzer%netscape.com 2000-10-11 23:52:48 +00:00
Родитель 6ff6c4d6b4
Коммит 88073867eb
3 изменённых файлов: 88 добавлений и 59 удалений

Просмотреть файл

@ -45,7 +45,7 @@
#include "nsXPIDLString.h"
#include "nsIFileLocator.h"
#include "nsFileLocations.h"
#include "nsIStringBundle.h"
#include "nsProxiedService.h"
#include "nsNetUtil.h"
@ -75,6 +75,7 @@
#undef NS_IMPL_IDS
#define CHROME_STYLE nsIWebBrowserChrome::CHROME_ALL | nsIWebBrowserChrome::CHROME_CENTER_SCREEN
#define MIGRATION_PROPERTIES_URL "chrome://communicator/locale/profile/migration.properties"
/* Network */
@ -235,6 +236,7 @@ static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
nsPrefMigration* nsPrefMigration::mInstance = nsnull;
@ -712,11 +714,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
rv = GetDirFromPref(oldProfilePath,newProfilePath,NEW_MAIL_DIR_NAME, PREF_MAIL_DIRECTORY, newPOPMailPath, oldPOPMailPath);
if (NS_FAILED(rv)) {
/* use the default locations */
rv = oldPOPMailPath->FromFileSpec(oldProfilePath);
if (NS_FAILED(rv)) return rv;
rv = oldPOPMailPath->AppendRelativeUnixPath(OLD_MAIL_DIR_NAME);
rv = DetermineOldPath(oldProfilePath, OLD_MAIL_DIR_NAME, "mailDirName", oldPOPMailPath);
if (NS_FAILED(rv)) return rv;
rv = SetPremigratedFilePref(PREF_MAIL_DIRECTORY, oldPOPMailPath);
@ -741,16 +739,12 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
/* First get the actual 4.x "Local Mail" files location */
rv = GetDirFromPref(oldProfilePath,newProfilePath, NEW_MAIL_DIR_NAME, PREF_MAIL_DIRECTORY, newIMAPLocalMailPath, oldIMAPLocalMailPath);
if (NS_FAILED(rv)) {
/* default paths */
rv = oldIMAPLocalMailPath->FromFileSpec(oldProfilePath);
rv = DetermineOldPath(oldProfilePath, OLD_MAIL_DIR_NAME, "mailDirName", oldIMAPLocalMailPath);
if (NS_FAILED(rv)) return rv;
rv = oldIMAPLocalMailPath->AppendRelativeUnixPath(OLD_MAIL_DIR_NAME);
if (NS_FAILED(rv)) return rv;
rv = SetPremigratedFilePref(PREF_MAIL_DIRECTORY, oldIMAPLocalMailPath);
if (NS_FAILED(rv)) return rv;
rv = newIMAPLocalMailPath->FromFileSpec(newProfilePath);
if (NS_FAILED(rv)) return rv;
@ -770,10 +764,10 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
rv = GetDirFromPref(oldProfilePath,newProfilePath, NEW_IMAPMAIL_DIR_NAME, PREF_MAIL_IMAP_ROOT_DIR,newIMAPMailPath,oldIMAPMailPath);
if (NS_FAILED(rv)) {
/* default paths */
rv = oldIMAPMailPath->FromFileSpec(oldProfilePath);
if (NS_FAILED(rv)) return rv;
/* we didn't over localize "ImapMail" in 4.x, so this is all we have to do */
rv = oldIMAPMailPath->AppendRelativeUnixPath(OLD_IMAPMAIL_DIR_NAME);
if (NS_FAILED(rv)) return rv;
@ -806,10 +800,10 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
rv = GetDirFromPref(oldProfilePath,newProfilePath,NEW_MAIL_DIR_NAME, PREF_MAIL_DIRECTORY, newMOVEMAILMailPath, oldMOVEMAILMailPath);
if (NS_FAILED(rv)) {
/* use the default locations */
rv = oldMOVEMAILMailPath->FromFileSpec(oldProfilePath);
if (NS_FAILED(rv)) return rv;
/* we didn't over localize this in 4.x, so this is all we have to do */
rv = oldMOVEMAILMailPath->AppendRelativeUnixPath(OLD_MAIL_DIR_NAME);
if (NS_FAILED(rv)) return rv;
@ -840,18 +834,15 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
rv = GetDirFromPref(oldProfilePath,newProfilePath, NEW_NEWS_DIR_NAME, PREF_NEWS_DIRECTORY, newNewsPath,oldNewsPath);
if (NS_FAILED(rv)) {
/* default paths */
rv = oldNewsPath->FromFileSpec(oldProfilePath);
if (NS_FAILED(rv)) return rv;
rv = oldNewsPath->AppendRelativeUnixPath(OLD_NEWS_DIR_NAME);
if (NS_FAILED(rv)) return rv;
rv = newNewsPath->FromFileSpec(newProfilePath);
rv = DetermineOldPath(oldProfilePath, OLD_NEWS_DIR_NAME, "newsDirName", oldNewsPath);
if (NS_FAILED(rv)) return rv;
rv = SetPremigratedFilePref(PREF_NEWS_DIRECTORY, oldNewsPath);
if (NS_FAILED(rv)) return rv;
rv = newNewsPath->FromFileSpec(newProfilePath);
if (NS_FAILED(rv)) return rv;
newsDriveDefault = PR_TRUE;
}
oldNewsPath->GetFileSpec(&newsSpec);
@ -1446,42 +1437,6 @@ nsPrefMigration::GetSizes(nsFileSpec inputPath, PRBool readSubdirs, PRUint32 *si
return NS_OK;
}
/*--------------------------------------------------------------------------
* GetStringFromSpec gets the drive letter (on Windows) or the volume name (on Mac)
*
* INPUT: an nsFileSpec path
*
* OUTPUT: the drive letter or volume name
*
* RETURNS: NS_OK if found
* NS_ERROR_FAILURE if some error occurs while iterating through the
* parent nodes.
*
*--------------------------------------------------------------------------*/
static
nsresult GetStringFromSpec(nsFileSpec inSpec, char **string)
{
nsresult rv;
nsCOMPtr<nsIFileSpec> spec;
rv = NS_NewFileSpecWithSpec(inSpec, getter_AddRefs(spec));
if (NS_SUCCEEDED(rv)) {
rv = spec->GetPersistentDescriptorString(string);
if (NS_SUCCEEDED(rv)) {
return NS_OK;
}
else {
PR_FREEIF(*string);
return rv;
}
}
else {
*string = nsnull;
return rv;
}
}
/*---------------------------------------------------------------------------*
* ComputeSpaceRequirments
*
@ -2067,6 +2022,71 @@ nsPrefMigration::SetPremigratedFilePref(const char *pref_name, nsIFileSpec *path
return rv;
}
nsresult
nsPrefMigration::DetermineOldPath(nsIFileSpec *profilePath, const char *oldPathName, const char *oldPathEntityName, nsIFileSpec *oldPath)
{
nsresult rv;
PRBool exists = PR_FALSE;
/* use the default locations */
rv = oldPath->FromFileSpec(profilePath);
if (NS_FAILED(rv)) return rv;
/* first check if the directory with the appropriate ascii name exists */
rv = oldPath->AppendRelativeUnixPath(oldPathName);
if (NS_FAILED(rv)) return rv;
rv = oldPath->Exists(&exists);
if (exists) {
/* at this point, the folder with the english name exists. use it */
return NS_OK;
}
/* set oldLocalFile to profilePath. need to convert nsIFileSpec->nsILocalFile */
nsCOMPtr<nsILocalFile> oldLocalFile;
nsFileSpec pathSpec;
profilePath->GetFileSpec(&pathSpec);
rv = NS_FileSpecToIFile(&pathSpec, getter_AddRefs(oldLocalFile));
if (NS_FAILED(rv)) return rv;
/* get the string bundle, and get the appropriate localized string out of it */
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(kStringBundleServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle(MIGRATION_PROPERTIES_URL, nsnull, getter_AddRefs(bundle));
if (NS_FAILED(rv)) return rv;
nsXPIDLString localizedDirName;
nsAutoString entityName;
entityName.AssignWithConversion(oldPathEntityName);
rv = bundle->GetStringFromName(entityName.GetUnicode(), getter_Copies(localizedDirName));
if (NS_FAILED(rv)) return rv;
rv = oldLocalFile->AppendRelativeUnicodePath((const PRUnichar *)localizedDirName);
if (NS_FAILED(rv)) return rv;
exists = PR_FALSE;
rv = oldLocalFile->Exists(&exists);
if (!exists) {
/* at this point, neither the folder with the localized name or the english name
* exist. oldPath is set to the english name. just use that.
*/
return NS_OK;
}
/* at this point, the folder with the english name doesn't exist, but the
* folder with the localized name does. use the localized one
*/
nsXPIDLCString persistentDescriptor;
rv = oldLocalFile->GetPersistentDescriptor(getter_Copies(persistentDescriptor));
if (NS_FAILED(rv)) return rv;
rv = oldPath->SetPersistentDescriptorString((const char *)persistentDescriptor);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsPrefConverter
////////////////////////////////////////////////////////////////////////
@ -2300,3 +2320,4 @@ nsPrefConverter::GetPlatformCharset(nsAutoString& aCharset)
return rv;
}

Просмотреть файл

@ -37,6 +37,7 @@
#include "nsPrefMigrationCIDs.h"
#include "nsIPrefMigration.h"
#include "nsVoidArray.h"
#include "nsILocalFile.h"
#define SUCCESS 0
#define RETRY 1
@ -142,6 +143,7 @@ class nsPrefMigration: public nsIPrefMigration
nsresult RenameAndMove4xPopFilterFile(nsIFileSpec *profilePath);
nsresult RenameAndMove4xPopFile(nsIFileSpec * profilePath, const char *fileNameIn4x, const char *fileNameIn5x);
nsresult DetermineOldPath(nsIFileSpec *profilePath, const char *oldPathName, const char *oldPathEntityName, nsIFileSpec *oldPath);
nsresult SetPremigratedFilePref(const char *pref_name, nsIFileSpec *filePath);
#ifdef NEED_TO_COPY_AND_RENAME_NEWSRC_FILES
nsresult GetPremigratedFilePref(const char *pref_name, nsIFileSpec **filePath);

Просмотреть файл

@ -1,2 +1,8 @@
migrate=Convert Profile
newprofile=Manage Profiles...
newprofile=Manage Profiles...
# mailDirName needs to be set to the same value as in 4.x
# see bug #55449
mailDirName=Mail
# newsDirName needs to be set to the same value as in 4.x
# see bug #55449
newsDirName=News