nsBrowserProfileMigratorUtils.h
Go to the documentation of this file.
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
4  *
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/
9  *
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.
14  *
15  * The Original Code is The Browser Profile Migrator.
16  *
17  * The Initial Developer of the Original Code is Ben Goodger.
18  * Portions created by the Initial Developer are Copyright (C) 2004
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Ben Goodger <ben@bengoodger.com>
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either the GNU General Public License Version 2 or later (the "GPL"), or
26  * 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.
35  *
36  * ***** END LICENSE BLOCK ***** */
37 
38 #ifndef browserprofilemigratorutils___h___
39 #define browserprofilemigratorutils___h___
40 
41 #define MIGRATION_ITEMBEFOREMIGRATE "Migration:ItemBeforeMigrate"
42 #define MIGRATION_ITEMAFTERMIGRATE "Migration:ItemAfterMigrate"
43 #define MIGRATION_STARTED "Migration:Started"
44 #define MIGRATION_ENDED "Migration:Ended"
45 
46 #define NOTIFY_OBSERVERS(message, item) \
47  mObserverService->NotifyObservers(nsnull, message, item)
48 
49 #define COPY_DATA(func, replace, itemIndex) \
50  if (NS_SUCCEEDED(rv) && (aItems & itemIndex || !aItems)) { \
51  nsAutoString index; \
52  index.AppendInt(itemIndex); \
53  NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get()); \
54  rv = func(replace); \
55  NOTIFY_OBSERVERS(MIGRATION_ITEMAFTERMIGRATE, index.get()); \
56  }
57 
58 #define NC_URI(property) \
59  NS_LITERAL_CSTRING("http://home.netscape.com/NC-rdf#"#property)
60 
61 #define BATCH_ACTION_HISTORY 0
62 #define BATCH_ACTION_HISTORY_REPLACE 1
63 #define BATCH_ACTION_BOOKMARKS 2
64 #define BATCH_ACTION_BOOKMARKS_REPLACE 3
65 
66 #include "nsIPrefBranch.h"
67 #include "nsIFile.h"
68 #include "nsStringAPI.h"
69 #include "nsCOMPtr.h"
70 
71 class nsIProfileStartup;
72 
73 
74 void SetUnicharPref(const char* aPref, const nsAString& aValue,
75  nsIPrefBranch* aPrefs);
76 
77 // Proxy utilities shared by the Opera and IE migrators
78 void ParseOverrideServers(const nsAString& aServers, nsIPrefBranch* aBranch);
79 void SetProxyPref(const nsAString& aHostPort, const char* aPref,
80  const char* aPortPref, nsIPrefBranch* aPrefs);
81 
82 struct MigrationData {
83  PRUnichar* fileName;
84  PRUint32 sourceFlag;
85  PRBool replaceOnly;
86 };
87 
88 class nsILocalFile;
89 void GetMigrateDataFromArray(MigrationData* aDataArray,
90  PRInt32 aDataArrayLength,
91  PRBool aReplace,
92  nsIFile* aSourceProfile,
93  PRUint16* aResult);
94 
95 
96 // get the base directory of the *target* profile
97 // this is already cloned, modify it to your heart's content
98 void GetProfilePath(nsIProfileStartup* aStartup, nsCOMPtr<nsIFile>& aProfileDir);
99 
100 // The Netscape Bookmarks Format (bookmarks.html) is fairly standard but
101 // each browser vendor seems to have their own way of identifying the
102 // Personal Toolbar Folder. This function scans for the vendor-specific
103 // name in the source Bookmarks file and then writes out a normalized
104 // variant into the target folder.
105 nsresult AnnotatePersonalToolbarFolder(nsIFile* aSourceBookmarksFile,
106  nsIFile* aTargetBookmarksFile,
107  const char* aToolbarFolderName);
108 
109 // In-place import from aBookmarksFile into a folder in the user's bookmarks.
110 // If the importIntoRoot parameter has a value of true, the bookmarks will be
111 // imported into the bookmarks root folder. Otherwise, they'll be imported into
112 // a new folder with the name "From (STR:aImportSourceNameKey)".
113 // aImportSourceNameKey is a key into migration.properties with the pretty name
114 // of the application.
115 nsresult ImportBookmarksHTML(nsIFile* aBookmarksFile,
116  PRBool aImportIntoRoot,
117  PRBool aOverwriteDefaults,
118  const PRUnichar* aImportSourceNameKey);
119 
120 nsresult InitializeBookmarks(nsIFile* aTargetProfile);
121 
122 #endif
123 
onPageChanged aValue
Definition: FeedWriter.js:1395
void ParseOverrideServers(const nsAString &aServers, nsIPrefBranch *aBranch)
void SetProxyPref(const nsAString &aHostPort, const char *aPref, const char *aPortPref, nsIPrefBranch *aPrefs)
void GetProfilePath(nsIProfileStartup *aStartup, nsCOMPtr< nsIFile > &aProfileDir)
const nsIPrefBranch
nsresult InitializeBookmarks(nsIFile *aTargetProfile)
void SetUnicharPref(const char *aPref, const nsAString &aValue, nsIPrefBranch *aPrefs)
nsresult ImportBookmarksHTML(nsIFile *aBookmarksFile, PRBool aImportIntoRoot, PRBool aOverwriteDefaults, const PRUnichar *aImportSourceNameKey)
nsresult AnnotatePersonalToolbarFolder(nsIFile *aSourceBookmarksFile, nsIFile *aTargetBookmarksFile, const char *aToolbarFolderName)
void GetMigrateDataFromArray(MigrationData *aDataArray, PRInt32 aDataArrayLength, PRBool aReplace, nsIFile *aSourceProfile, PRUint16 *aResult)