Bug #255043 --> Signature files should be copied from Mozilla profile directories

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2004-11-28 22:03:14 +00:00
parent edfdbfa49a
commit 5523bcf5a1
2 changed files with 54 additions and 0 deletions

View File

@ -486,6 +486,10 @@ nsSeamonkeyProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFil
ReadBranch("ldap_2.servers.", psvc, ldapservers);
ReadBranch("mailnews.labels.", psvc, labelPrefs);
// the signature file prefs may be paths to files in the seamonkey profile path
// so we need to copy them over and fix these paths up before we write them out to the new prefs.js
CopySignatureFiles(identities, psvc);
// certain mail prefs may actually be absolute paths instead of profile relative paths
// we need to fix these paths up before we write them out to the new prefs.js
CopyMailFolders(servers, psvc);
@ -548,6 +552,55 @@ nsresult nsSeamonkeyProfileMigrator::CopyAddressBookDirectories(nsVoidArray* aLd
return NS_OK;
}
nsresult nsSeamonkeyProfileMigrator::CopySignatureFiles(nsVoidArray* aIdentities, nsIPrefService* aPrefService)
{
nsresult rv = NS_OK;
PRUint32 count = aIdentities->Count();
for (PRUint32 i = 0; i < count; ++i)
{
PrefBranchStruct* pref = (PrefBranchStruct*)aIdentities->ElementAt(i);
nsDependentCString prefName (pref->prefName);
// a partial fix for bug #255043
// if the user's signature file from seamonkey lives in the
// seamonkey profile root, we'll copy it over to the new
// thunderbird profile root and thenn set the pref to the new value
// note, this doesn't work for multiple signatures that live
// below the seamonkey profile root
if (StringEndsWith(prefName, nsDependentCString(".sig_file")))
{
// turn the pref into a nsILocalFile
nsCOMPtr<nsILocalFile> srcSigFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
srcSigFile->SetPersistentDescriptor(nsDependentCString(pref->stringValue));
nsCOMPtr<nsIFile> targetSigFile;
rv = mTargetProfile->Clone(getter_AddRefs(targetSigFile));
NS_ENSURE_SUCCESS(rv, rv);
// now make the copy
PRBool exists;
srcSigFile->Exists(&exists);
if (exists)
{
nsAutoString leafName;
srcSigFile->GetLeafName(leafName);
srcSigFile->CopyTo(targetSigFile,leafName); // will fail if we've already copied a sig file here
targetSigFile->Append(leafName);
// now write out the new descriptor
nsCAutoString descriptorString;
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(targetSigFile);
localFile->GetPersistentDescriptor(descriptorString);
nsCRT::free(pref->stringValue);
pref->stringValue = ToNewCString(descriptorString);
}
}
}
return NS_OK;
}
nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers, nsIPrefService* aPrefService)
{
// Each server has a .directory pref which points to the location of the mail data

View File

@ -75,6 +75,7 @@ protected:
nsresult CopyPasswords(PRBool aReplace);
nsresult CopyMailFolders(nsVoidArray* aMailServers, nsIPrefService* aPrefBranch);
nsresult CopyAddressBookDirectories(nsVoidArray* aLdapServers, nsIPrefService* aPrefService);
nsresult CopySignatureFiles(nsVoidArray* aIdentities, nsIPrefService* aPrefBranch);
void ReadBranch(const char * branchName, nsIPrefService* aPrefService, nsVoidArray* aPrefs);
void WriteBranch(const char * branchName, nsIPrefService* aPrefService, nsVoidArray* aPrefs);