NS_IMETHODIMP nsOperaProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile) { nsresult rv = NS_OK; PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE; if (aStartup) { rv = aStartup->DoStartup(); NS_ENSURE_SUCCESS(rv, rv); } if (!mOperaProfile) GetOperaProfile(aProfile, getter_AddRefs(mOperaProfile)); NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull); COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS); COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES); COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY); COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS); NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull); return rv; }
NS_IMETHODIMP nsOperaProfileMigrator::GetMigrateData(const PRUnichar* aProfile, bool aReplace, PRUint16* aResult) { *aResult = 0; if (!mOperaProfile) { GetOperaProfile(aProfile, getter_AddRefs(mOperaProfile)); if (!mOperaProfile) return NS_ERROR_FILE_NOT_FOUND; } MigrationData data[] = { { ToNewUnicode(OPERA_PREFERENCES_FILE_NAME), nsIBrowserProfileMigrator::SETTINGS, PR_FALSE }, { ToNewUnicode(OPERA_COOKIES_FILE_NAME), nsIBrowserProfileMigrator::COOKIES, PR_FALSE }, { ToNewUnicode(OPERA_HISTORY_FILE_NAME), nsIBrowserProfileMigrator::HISTORY, PR_FALSE }, { ToNewUnicode(OPERA_BOOKMARKS_FILE_NAME), nsIBrowserProfileMigrator::BOOKMARKS, PR_FALSE } }; // Frees file name strings allocated above. GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData), aReplace, mOperaProfile, aResult); return NS_OK; }