39 #include "nsDirectoryServiceDefs.h"
40 #include "nsIObserverService.h"
41 #include "nsIPrefService.h"
42 #include "nsIServiceManager.h"
43 #include "nsISupportsArray.h"
44 #include "nsISupportsPrimitives.h"
46 #include "nsNetUtil.h"
52 #define FILE_NAME_BOOKMARKS NS_LITERAL_STRING("bookmarks.html")
53 #define FILE_NAME_COOKIES NS_LITERAL_STRING("cookies.txt")
54 #define FILE_NAME_SITEPERM_OLD NS_LITERAL_STRING("cookperm.txt")
55 #define FILE_NAME_SITEPERM_NEW NS_LITERAL_STRING("hostperm.1")
56 #define FILE_NAME_CERT8DB NS_LITERAL_STRING("cert8.db")
57 #define FILE_NAME_KEY3DB NS_LITERAL_STRING("key3.db")
58 #define FILE_NAME_SECMODDB NS_LITERAL_STRING("secmod.db")
59 #define FILE_NAME_HISTORY NS_LITERAL_STRING("history.dat")
60 #define FILE_NAME_FORMHISTORY NS_LITERAL_STRING("formhistory.dat")
61 #define FILE_NAME_LOCALSTORE NS_LITERAL_STRING("localstore.rdf")
62 #define FILE_NAME_MIMETYPES NS_LITERAL_STRING("mimeTypes.rdf")
63 #define FILE_NAME_DOWNLOADS NS_LITERAL_STRING("downloads.rdf")
64 #define FILE_NAME_PREFS NS_LITERAL_STRING("prefs.js")
65 #define FILE_NAME_USER_PREFS NS_LITERAL_STRING("user.js")
66 #define FILE_NAME_USERCHROME NS_LITERAL_STRING("userChrome.css")
67 #define FILE_NAME_USERCONTENT NS_LITERAL_STRING("userContent.css")
68 #define DIR_NAME_CHROME NS_LITERAL_STRING("chrome")
74 mObserverService = do_GetService(
"@mozilla.org/observer-service;1");
85 nsPhoenixProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup,
const PRUnichar* aProfile)
92 NS_ASSERTION(aStartup,
"Can't migrate from Phoenix/Firebird/Firefox profiles once Firefox is running!");
94 return NS_ERROR_FAILURE;
127 nsPhoenixProfileMigrator::GetMigrateData(
const PRUnichar* aProfile,
135 return NS_ERROR_FILE_NOT_FOUND;
174 nsCString signonsFileName;
177 if (!signonsFileName.IsEmpty()) {
178 NS_ConvertASCIItoUTF16 fileName(signonsFileName);
179 nsCOMPtr<nsIFile> sourcePasswordsFile;
181 sourcePasswordsFile->Append(fileName);
184 sourcePasswordsFile->Exists(&exists);
193 nsPhoenixProfileMigrator::GetSourceExists(PRBool* aResult)
195 nsCOMPtr<nsISupportsArray> profiles;
196 GetSourceProfiles(getter_AddRefs(profiles));
200 profiles->Count(&count);
201 *aResult = count > 0;
210 nsPhoenixProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
212 nsCOMPtr<nsISupportsArray> profiles;
213 GetSourceProfiles(getter_AddRefs(profiles));
217 profiles->Count(&count);
218 *aResult = count > 1;
227 nsPhoenixProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
229 if (!mProfileNames && !mProfileLocations) {
230 mProfileNames = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
231 mProfileLocations = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
232 NS_ENSURE_TRUE(mProfileNames && mProfileLocations, NS_ERROR_UNEXPECTED);
238 NS_IF_ADDREF(*aResult = mProfileNames);
242 nsPhoenixProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
254 mProfileNames->Count(&count);
255 for (PRUint32
i = 0;
i <
count; ++
i) {
256 nsCOMPtr<nsISupportsString>
str;
258 getter_AddRefs(str));
259 nsString profileName;
260 str->GetData(profileName);
261 if (profileName.Equals(aProfile)) {
262 mProfileLocations->QueryElementAt(
i, NS_GET_IID(nsILocalFile),
275 nsCOMPtr<nsIProperties> fileLocator(do_GetService(
"@mozilla.org/file/directory_service;1"));
276 nsCOMPtr<nsILocalFile> phoenixRegistry;
278 fileLocator->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
280 phoenixRegistry->Append(NS_LITERAL_STRING(
"Phoenix"));
281 phoenixRegistry->Append(NS_LITERAL_STRING(
"registry.dat"));
282 #elif defined(XP_MACOSX)
283 fileLocator->Get(NS_MAC_USER_LIB_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
285 phoenixRegistry->Append(NS_LITERAL_STRING(
"Phoenix"));
286 phoenixRegistry->Append(NS_LITERAL_STRING(
"Application Registry"));
287 #elif defined(XP_UNIX)
288 fileLocator->Get(NS_UNIX_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
290 phoenixRegistry->Append(NS_LITERAL_STRING(
".phoenix"));
291 phoenixRegistry->Append(NS_LITERAL_STRING(
"appreg"));
292 #elif defined(XP_BEOS)
293 fileLocator->Get(NS_BEOS_SETTINGS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
295 phoenixRegistry->Append(NS_LITERAL_STRING(
"Phoenix"));
296 phoenixRegistry->Append(NS_LITERAL_STRING(
"appreg"));
297 #elif defined(XP_OS2)
298 fileLocator->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
300 phoenixRegistry->Append(NS_LITERAL_STRING(
"Phoenix"));
301 phoenixRegistry->Append(NS_LITERAL_STRING(
"registry.dat"));
336 nsCOMPtr<nsIFile> sourceUserContent;
341 PRBool exists = PR_FALSE;
342 sourceUserContent->Exists(&exists);
344 nsCOMPtr<nsIFile> targetUserContent;
347 nsCOMPtr<nsIFile> targetChromeDir;
348 targetUserContent->Clone(getter_AddRefs(targetChromeDir));
351 targetUserContent->Exists(&exists);
353 targetUserContent->Remove(PR_FALSE);
358 nsCOMPtr<nsIFile> sourceUserChrome;
363 sourceUserChrome->Exists(&exists);
365 nsCOMPtr<nsIFile> targetUserChrome;
368 nsCOMPtr<nsIFile> targetChromeDir;
369 targetUserChrome->Clone(getter_AddRefs(targetChromeDir));
372 targetUserChrome->Exists(&exists);
374 targetUserChrome->Remove(PR_FALSE);
399 nsCString signonsFileName;
408 nsCOMPtr<nsIFile> seamonkeyPrefsFile;
411 psvc->ReadUserPrefs(seamonkeyPrefsFile);
413 nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc));
414 rv = branch->GetCharPref(
"signon.SignonFileName", getter_Copies(signonsFileName));
416 if (signonsFileName.IsEmpty())
417 return NS_ERROR_FILE_NOT_FOUND;
419 NS_ConvertASCIItoUTF16 fileName(signonsFileName);
nsresult CopyFile(const nsAString &aSourceFileName, const nsAString &aTargetFileName)
nsresult CopyHistory(PRBool aReplace)
const unsigned short HISTORY
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
#define FILE_NAME_USERCHROME
const NS_PREFSERVICE_CONTRACTID
#define FILE_NAME_DOWNLOADS
nsresult CopyOtherData(PRBool aReplace)
#define FILE_NAME_BOOKMARKS
virtual ~nsPhoenixProfileMigrator()
const unsigned short SETTINGS
#define FILE_NAME_CERT8DB
nsresult GetSourceProfile(const PRUnichar *aProfile)
#define NOTIFY_OBSERVERS(message, item)
#define FILE_NAME_LOCALSTORE
#define FILE_NAME_COOKIES
nsCOMPtr< nsIFile > mTargetProfile
#define FILE_NAME_SITEPERM_OLD
nsresult CopyCookies(PRBool aReplace)
#define MIGRATION_STARTED
nsresult GetProfileDataFromRegistry(nsILocalFile *aRegistryFile, nsISupportsArray *aProfileNames, nsISupportsArray *aProfileLocations)
#define COPY_DATA(func, replace, itemIndex)
nsresult CopyPasswords(PRBool aReplace)
nsresult CopyPreferences(PRBool aReplace)
#define FILE_NAME_SECMODDB
nsresult CopyBookmarks(PRBool aReplace)
#define FILE_NAME_HISTORY
const unsigned short COOKIES
#define FILE_NAME_USER_PREFS
#define FILE_NAME_USERCONTENT
const unsigned short BOOKMARKS
void GetProfilePath(nsIProfileStartup *aStartup, nsCOMPtr< nsIFile > &aProfileDir)
nsresult CopyUserStyleSheets()
const unsigned short PASSWORDS
const unsigned short OTHERDATA
_getSelectedPageStyle s i
#define FILE_NAME_SITEPERM_NEW
#define FILE_NAME_FORMHISTORY
nsCOMPtr< nsILocalFile > mSourceProfile
#define FILE_NAME_MIMETYPES
void GetMigrateDataFromArray(MigrationData *aDataArray, PRInt32 aDataArrayLength, PRBool aReplace, nsIFile *aSourceProfile, PRUint16 *aResult)
nsresult GetSignonFileName(PRBool aReplace, char **aFileName)
nsresult FillProfileDataFromPhoenixRegistry()