Bug 463982 - Drop configure support for cairo-mac widget toolkit, r=ted
[wine-gecko.git] / profile / pref-migrator / src / nsPrefMigration.h
blob0d9c4fd6becedf4c83fb0e12ecd1e716b28eceb4
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Communicator client code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsPrefMigration_h___
39 #define nsPrefMigration_h___
42 #include "nscore.h"
43 #include "nsIFactory.h"
44 #include "nsISupports.h"
45 #include "nsFileSpec.h"
46 #include "nsIPrefBranch.h"
47 #include "nsIServiceManager.h"
48 #include "nsCOMPtr.h"
49 #include "nsIDOMWindowInternal.h"
50 #include "nsIFileSpec.h"
51 #include "nsPrefMigrationCIDs.h"
52 #include "nsIPrefMigration.h"
53 #include "nsVoidArray.h"
54 #include "nsILocalFile.h"
56 #define MIGRATION_SUCCESS 0
57 #define MIGRATION_RETRY 1
58 #define MIGRATION_CANCEL 2
59 #define MIGRATION_CREATE_NEW 3
61 #define MAX_DRIVES 4
63 //Interfaces Needed
65 #if defined(XP_MACOSX)
66 #define IMAP_MAIL_FILTER_FILE_NAME_FORMAT_IN_4x "%s Rules"
67 #endif
69 #if defined(XP_UNIX) && !defined(XP_MACOSX)
70 #define NEED_TO_COPY_AND_RENAME_NEWSRC_FILES
71 #endif
73 class nsPrefConverter: public nsIPrefConverter
75 public:
76 NS_DEFINE_STATIC_CID_ACCESSOR(NS_PREFCONVERTER_CID)
78 nsPrefConverter();
79 virtual ~nsPrefConverter();
81 NS_DECL_ISUPPORTS
82 NS_DECL_NSIPREFCONVERTER
84 nsresult GetPlatformCharset(nsCString& aCharset);
87 class nsPrefMigration: public nsIPrefMigration
89 public:
90 NS_DEFINE_STATIC_CID_ACCESSOR(NS_PREFMIGRATION_CID)
92 static nsPrefMigration *GetInstance();
94 nsPrefMigration();
95 virtual ~nsPrefMigration();
97 NS_DECL_ISUPPORTS
99 NS_DECL_NSIPREFMIGRATION
101 // todo try to move this to private. We need this because we need to call this
102 // from a thread.
104 nsVoidArray mProfilesToMigrate;
105 nsresult ProcessPrefsCallback(const char* oldProfilePathStr, const char * newProfilePathStr);
106 void WaitForThread();
108 nsresult mErrorCode;
110 private:
112 static nsPrefMigration* mInstance;
114 nsresult ConvertPersistentStringToFileSpec(const char *str, nsIFileSpec *path);
115 nsresult CreateNewUser5Tree(nsIFileSpec* oldProfilePath,
116 nsIFileSpec* newProfilePath);
118 nsresult GetDirFromPref(nsIFileSpec* oldProfilePath,
119 nsIFileSpec* newProfilePath,
120 const char* newDirName,
121 const char* pref,
122 nsIFileSpec* newPath,
123 nsIFileSpec* oldPath);
125 nsresult GetSizes(nsFileSpec inputPath,
126 PRBool readSubdirs,
127 PRUint32* sizeTotal);
129 nsresult ComputeSpaceRequirements(PRInt64 DriveArray[],
130 PRUint32 SpaceReqArray[],
131 PRInt64 Drive,
132 PRUint32 SpaceNeeded);
134 nsresult DoTheCopy(nsIFileSpec *oldPath,
135 nsIFileSpec *newPath,
136 PRBool readSubdirs);
137 nsresult DoTheCopy(nsIFileSpec *oldPath,
138 nsIFileSpec *newPath,
139 const char *fileOrDirName,
140 PRBool isDirectory = PR_FALSE);
142 nsresult DoTheCopyAndRename(nsIFileSpec *oldPath,
143 nsIFileSpec *newPath,
144 PRBool readSubdirs,
145 PRBool needToRenameFiles,
146 const char *oldName,
147 const char *newName);
148 nsresult DoTheCopyAndRename(nsIFileSpec *aPath,
149 PRBool aReadSubdirs,
150 const char *aOldName,
151 const char *aNewName);
152 nsresult CopyFilesByPattern(nsIFileSpec * oldPathSpec,
153 nsIFileSpec * newPathSpec,
154 const char *pattern);
157 #ifdef NEED_TO_COPY_AND_RENAME_NEWSRC_FILES
158 nsresult CopyAndRenameNewsrcFiles(nsIFileSpec *newPath);
159 #endif /* NEED_TO_COPY_AND_RENAME_NEWSRC_FILES */
161 nsresult DoSpecialUpdates(nsIFileSpec * profilePath);
162 nsresult Rename4xFileAfterMigration(nsIFileSpec *profilePath, const char *oldFileName, const char *newFileName);
163 #ifdef IMAP_MAIL_FILTER_FILE_NAME_FORMAT_IN_4x
164 nsresult RenameAndMove4xImapFilterFile(nsIFileSpec *profilePath, const char *hostname);
165 nsresult RenameAndMove4xImapFilterFiles(nsIFileSpec *profilePath);
166 #endif /* IMAP_MAIL_FILTER_FILE_NAME_FORMAT_IN_4x */
167 nsresult RenameAndMove4xPopStateFile(nsIFileSpec *profilePath);
168 nsresult RenameAndMove4xPopFilterFile(nsIFileSpec *profilePath);
169 nsresult RenameAndMove4xPopFile(nsIFileSpec * profilePath, const char *fileNameIn4x, const char *fileNameIn5x);
171 nsresult DetermineOldPath(nsIFileSpec *profilePath, const char *oldPathName, const char *oldPathEntityName, nsIFileSpec *oldPath);
172 nsresult SetPremigratedFilePref(const char *pref_name, nsIFileSpec *filePath);
173 #ifdef NEED_TO_COPY_AND_RENAME_NEWSRC_FILES
174 nsresult GetPremigratedFilePref(const char *pref_name, nsIFileSpec **filePath);
175 #endif /* NEED_TO_COPY_AND_RENAME_NEWSRC_FILES */
177 nsresult getPrefService();
179 nsCOMPtr<nsIPrefBranch> m_prefBranch;
180 nsCOMPtr<nsILocalFile> m_prefsFile;
181 nsCOMPtr<nsIDOMWindowInternal> m_parentWindow;
182 nsCOMPtr<nsIDOMWindow> mPMProgressWindow;
185 #endif /* nsPrefMigration_h___ */