nsresult nsDogbertProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFileName, const nsAString& aTargetPrefFileName) { PrefTransform* transform; PrefTransform* end = gTransforms + sizeof(gTransforms)/sizeof(PrefTransform); // Load the source pref file nsCOMPtr<nsIPrefService> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID)); psvc->ResetPrefs(); nsCOMPtr<nsIFile> sourcePrefsFile; mSourceProfile->Clone(getter_AddRefs(sourcePrefsFile)); sourcePrefsFile->Append(aSourcePrefFileName); psvc->ReadUserPrefs(sourcePrefsFile); nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc)); for (transform = gTransforms; transform < end; ++transform) transform->prefGetterFunc(transform, branch); // Now that we have all the pref data in memory, load the target pref file, // and write it back out psvc->ResetPrefs(); for (transform = gTransforms; transform < end; ++transform) transform->prefSetterFunc(transform, branch); nsCOMPtr<nsIFile> targetPrefsFile; mTargetProfile->Clone(getter_AddRefs(targetPrefsFile)); targetPrefsFile->Append(aTargetPrefFileName); psvc->SavePrefFile(targetPrefsFile); return NS_OK; }
nsresult nsSeamonkeyProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFileName, const nsAString& aTargetPrefFileName) { PrefTransform* transform; PrefTransform* end = gTransforms + sizeof(gTransforms)/sizeof(PrefTransform); // Load the source pref file nsCOMPtr<nsIPrefService> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID)); psvc->ResetPrefs(); nsCOMPtr<nsIFile> sourcePrefsFile; mSourceProfile->Clone(getter_AddRefs(sourcePrefsFile)); sourcePrefsFile->Append(aSourcePrefFileName); psvc->ReadUserPrefs(sourcePrefsFile); nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc)); for (transform = gTransforms; transform < end; ++transform) transform->prefGetterFunc(transform, branch); nsVoidArray* fontPrefs = new nsVoidArray(); if (!fontPrefs) return NS_ERROR_OUT_OF_MEMORY; ReadFontsBranch(psvc, fontPrefs); // Now that we have all the pref data in memory, load the target pref file, // and write it back out psvc->ResetPrefs(); for (transform = gTransforms; transform < end; ++transform) transform->prefSetterFunc(transform, branch); WriteFontsBranch(psvc, fontPrefs); delete fontPrefs; fontPrefs = nsnull; nsCOMPtr<nsIFile> targetPrefsFile; mTargetProfile->Clone(getter_AddRefs(targetPrefsFile)); targetPrefsFile->Append(aTargetPrefFileName); psvc->SavePrefFile(targetPrefsFile); psvc->ResetPrefs(); psvc->ReadUserPrefs(nsnull); return NS_OK; }
nsresult nsThunderbirdProfileMigrator::TransformPreferences( const char* aSourcePrefFileName, const char* aTargetPrefFileName) { PrefTransform* transform; PrefTransform* end = gTransforms + sizeof(gTransforms)/sizeof(PrefTransform); // Load the source pref file nsCOMPtr<nsIPrefService> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID)); psvc->ResetPrefs(); nsCOMPtr<nsIFile> sourcePrefsFile; mSourceProfile->Clone(getter_AddRefs(sourcePrefsFile)); sourcePrefsFile->AppendNative(nsDependentCString(aSourcePrefFileName)); psvc->ReadUserPrefs(sourcePrefsFile); nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc)); for (transform = gTransforms; transform < end; ++transform) transform->prefGetterFunc(transform, branch); // read in the various pref branch trees for accounts, identities, servers, // etc. static const char* branchNames[] = { // Keep the three below first, or change the indexes below "mail.identity.", "mail.server.", "ldap_2.", "accessibility.", "applications.", "bidi.", "dom.", "editor.", "font.", "helpers.", "mail.account.", "mail.addr_book.", "mail.imap.", "mail.mdn.", "mail.smtpserver.", "mail.spam.", "mail.toolbars.", "mailnews.labels.", "mailnews.reply_", "mailnews.tags.", "middlemouse.", "mousewheel.", "network.http.", "print.", "privacy.", "security.OSCP.", "security.crl.", "ui.key.", "wallet." }; PBStructArray branches[MOZ_ARRAY_LENGTH(branchNames)]; uint32_t i; for (i = 0; i < MOZ_ARRAY_LENGTH(branchNames); ++i) ReadBranch(branchNames[i], psvc, branches[i]); // the signature file prefs may be paths to files in the thunderbird 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(branches[0], 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 CopyMailFolderPrefs(branches[1], psvc); CopyAddressBookDirectories(branches[2], psvc); // Now that we have all the pref data in memory, load the target pref file, // and write it back out psvc->ResetPrefs(); nsCOMPtr<nsIFile> targetPrefsFile; mTargetProfile->Clone(getter_AddRefs(targetPrefsFile)); targetPrefsFile->AppendNative(nsDependentCString(aTargetPrefFileName)); // Don't use nullptr here as we're too early in the cycle for the prefs // service to get its default file (because the NS_GetDirectoryService items // aren't fully set up yet). psvc->ReadUserPrefs(targetPrefsFile); for (transform = gTransforms; transform < end; ++transform) transform->prefSetterFunc(transform, branch); for (i = 0; i < MOZ_ARRAY_LENGTH(branchNames); ++i) WriteBranch(branchNames[i], psvc, branches[i]); psvc->SavePrefFile(targetPrefsFile); return NS_OK; }