From 2467b181581b0e611c7c748e1a47c81034eb0408 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Wed, 19 Jan 2000 02:18:49 +0000 Subject: [PATCH] fix for #23702. migrate the popstate file on mac and linux. r=mscott --- profile/pref-migrator/src/nsPrefMigration.cpp | 44 +++++++++++++++---- profile/pref-migrator/src/nsPrefMigration.h | 2 + 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/profile/pref-migrator/src/nsPrefMigration.cpp b/profile/pref-migrator/src/nsPrefMigration.cpp index 6e30a5bab49..e4db3a26612 100644 --- a/profile/pref-migrator/src/nsPrefMigration.cpp +++ b/profile/pref-migrator/src/nsPrefMigration.cpp @@ -18,6 +18,8 @@ * Rights Reserved. * * Contributor(s): + * Don Bragg + * Seth Spitzer * Pierre Phaneuf */ @@ -76,6 +78,7 @@ #define BOOKMARKS_FILE_NAME_IN_4x "bookmarks.html" #define HISTORY_FILE_NAME_IN_4x "history.dat" #define NEWSRC_PREFIX_IN_4x ".newsrc-" +#define POPSTATE_FILE_IN_4x "popstate" #elif defined(XP_MAC) #define IMAP_MAIL_FILTER_FILE_NAME_IN_4x " Rules" #define POP_MAIL_FILTER_FILE_NAME_IN_4x "Filter Rules" @@ -83,6 +86,7 @@ #define COOKIES_FILE_NAME_IN_4x "MagicCookie" #define BOOKMARKS_FILE_NAME_IN_4x "Bookmarks.html" #define HISTORY_FILE_NAME_IN_4x "Netscape History" +#define POPSTATE_FILE_IN_4x "Pop State" #else /* XP_PC */ #define IMAP_MAIL_FILTER_FILE_NAME_IN_4x "rules.dat" #define POP_MAIL_FILTER_FILE_NAME_IN_4x "rules.dat" @@ -96,6 +100,7 @@ #define COOKIES_FILE_NAME_IN_5x "cookies.txt" #define IMAP_MAIL_FILTER_FILE_NAME_IN_5x "rules.dat" #define POP_MAIL_FILTER_FILE_NAME_IN_5x "rules.dat" +#define POPSTATE_FILE_IN_5x "popstate.dat" #define BOOKMARKS_FILE_NAME_IN_5x "bookmarks.html" #define HISTORY_FILE_NAME_IN_5x "history.dat" #define RENAMED_OLD_HISTORY_FILE_NAME "old "HISTORY_FILE_NAME_IN_4x @@ -1616,6 +1621,9 @@ nsPrefMigration::DoSpecialUpdates(nsIFileSpec * profilePath) if (serverType == POP_4X_MAIL_TYPE) { rv = RenameAndMove4xPopFilterFile(profilePath); if (NS_FAILED(rv)) return rv; + + rv = RenameAndMove4xPopStateFile(profilePath); + if (NS_FAILED(rv)) return rv; } #ifdef IMAP_MAIL_FILTER_FILE_NAME_FORMAT_IN_4x else if (serverType == IMAP_4X_MAIL_TYPE) { @@ -1640,14 +1648,34 @@ nsPrefMigration::DoSpecialUpdates(nsIFileSpec * profilePath) nsresult nsPrefMigration::RenameAndMove4xPopFilterFile(nsIFileSpec * profilePath) +{ + return RenameAndMove4xPopFile(profilePath, POP_MAIL_FILTER_FILE_NAME_IN_4x, POP_MAIL_FILTER_FILE_NAME_IN_5x); +} + +nsresult +nsPrefMigration::RenameAndMove4xPopStateFile(nsIFileSpec * profilePath) +{ +#ifdef POPSTATE_FILE_IN_4x + return RenameAndMove4xPopFile(profilePath, POPSTATE_FILE_IN_4x, POPSTATE_FILE_IN_5x); +#else + // on windows, popstate.dat was in Users\\MAIL\popstate.dat + // which is the right place, unlike windows and mac. + // so, when we migrate Users\\Mail to Users50\\Mail\ + // it just works + return NS_OK; +#endif /* POPSTATE_FILE_IN_4x */ +} + +nsresult +nsPrefMigration::RenameAndMove4xPopFile(nsIFileSpec * profilePath, const char *fileNameIn4x, const char *fileNameIn5x) { nsresult rv = NS_OK; nsFileSpec file; rv = profilePath->GetFileSpec(&file); if (NS_FAILED(rv)) return rv; - // the 4.x pop filter file lives in /mailrule - file += POP_MAIL_FILTER_FILE_NAME_IN_4x; + // we assume the 4.x pop files live at / + file += fileNameIn4x; // figure out where the 4.x pop mail directory got copied to char *popServerName = nsnull; @@ -1658,16 +1686,16 @@ nsPrefMigration::RenameAndMove4xPopFilterFile(nsIFileSpec * profilePath) migratedPopDirectory += popServerName; PR_FREEIF(popServerName); - // copy the 4.x file from /mailrule to the /Mail//mailrule + // copy the 4.x file from / to the /Mail// file.CopyToDir(migratedPopDirectory); // make migratedPopDirectory point the the copied filter file, - // /Mail//mailrule - migratedPopDirectory += POP_MAIL_FILTER_FILE_NAME_IN_4x; + // /Mail// + migratedPopDirectory += fileNameIn4x; - // rename /Mail//mailrule to /Mail//rules.dat, if necessary - if (PL_strcmp(POP_MAIL_FILTER_FILE_NAME_IN_4x,POP_MAIL_FILTER_FILE_NAME_IN_5x)) { - migratedPopDirectory.Rename(POP_MAIL_FILTER_FILE_NAME_IN_5x); + // rename /Mail//to /Mail//, if necessary + if (PL_strcmp(fileNameIn4x,fileNameIn5x)) { + migratedPopDirectory.Rename(fileNameIn5x); } return rv; diff --git a/profile/pref-migrator/src/nsPrefMigration.h b/profile/pref-migrator/src/nsPrefMigration.h index 47edbb6e43c..2ee692754ae 100644 --- a/profile/pref-migrator/src/nsPrefMigration.h +++ b/profile/pref-migrator/src/nsPrefMigration.h @@ -114,7 +114,9 @@ class nsPrefMigration: public nsIPrefMigration nsresult RenameAndMove4xImapFilterFile(nsIFileSpec *profilePath, const char *hostname); nsresult RenameAndMove4xImapFilterFiles(nsIFileSpec *profilePath); #endif /* IMAP_MAIL_FILTER_FILE_NAME_FORMAT_IN_4x */ + nsresult RenameAndMove4xPopStateFile(nsIFileSpec *profilePath); nsresult RenameAndMove4xPopFilterFile(nsIFileSpec *profilePath); + nsresult RenameAndMove4xPopFile(nsIFileSpec * profilePath, const char *fileNameIn4x, const char *fileNameIn5x); nsresult SetPremigratedFilePref(const char *pref_name, nsIFileSpec *filePath); #ifdef NEED_TO_COPY_AND_RENAME_NEWSRC_FILES