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
15 * The Original Code is The Browser Profile Migrator.
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.
22 * Ben Goodger <ben@bengoodger.com>
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.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef browserprofilemigratorutils___h___
39 #define browserprofilemigratorutils___h___
41 #define MIGRATION_ITEMBEFOREMIGRATE "Migration:ItemBeforeMigrate"
42 #define MIGRATION_ITEMAFTERMIGRATE "Migration:ItemAfterMigrate"
43 #define MIGRATION_STARTED "Migration:Started"
44 #define MIGRATION_ENDED "Migration:Ended"
46 #define NOTIFY_OBSERVERS(message, item) \
47 mObserverService->NotifyObservers(nsnull, message, item)
49 #define COPY_DATA(func, replace, itemIndex) \
50 if (NS_SUCCEEDED(rv) && (aItems & itemIndex || !aItems)) { \
52 index.AppendInt(itemIndex); \
53 NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get()); \
55 NOTIFY_OBSERVERS(MIGRATION_ITEMAFTERMIGRATE, index.get()); \
58 #define NC_URI(property) \
59 NS_LITERAL_CSTRING("http://home.netscape.com/NC-rdf#"#property)
61 #include "nsIPrefBranch.h"
63 #include "nsStringAPI.h"
66 class nsIProfileStartup
;
69 void SetUnicharPref(const char* aPref
, const nsAString
& aValue
,
70 nsIPrefBranch
* aPrefs
);
72 // Proxy utilities shared by the Opera and IE migrators
73 void ParseOverrideServers(const nsAString
& aServers
, nsIPrefBranch
* aBranch
);
74 void SetProxyPref(const nsAString
& aHostPort
, const char* aPref
,
75 const char* aPortPref
, nsIPrefBranch
* aPrefs
);
77 struct MigrationData
{
84 void GetMigrateDataFromArray(MigrationData
* aDataArray
,
85 PRInt32 aDataArrayLength
,
87 nsIFile
* aSourceProfile
,
91 // get the base directory of the *target* profile
92 // this is already cloned, modify it to your heart's content
93 void GetProfilePath(nsIProfileStartup
* aStartup
, nsCOMPtr
<nsIFile
>& aProfileDir
);
95 // The Netscape Bookmarks Format (bookmarks.html) is fairly standard but
96 // each browser vendor seems to have their own way of identifying the
97 // Personal Toolbar Folder. This function scans for the vendor-specific
98 // name in the source Bookmarks file and then writes out a normalized
99 // variant into the target folder.
100 nsresult
AnnotatePersonalToolbarFolder(nsIFile
* aSourceBookmarksFile
,
101 nsIFile
* aTargetBookmarksFile
,
102 const char* aToolbarFolderName
);
104 // In-place import from aBookmarksFile into a folder in the user's bookmarks.
105 // If the importIntoRoot parameter has a value of true, the bookmarks will be
106 // imported into the bookmarks root folder. Otherwise, they'll be imported into
107 // a new folder with the name "From (STR:aImportSourceNameKey)".
108 // aImportSourceNameKey is a key into migration.properties with the pretty name
109 // of the application.
110 nsresult
ImportBookmarksHTML(nsIFile
* aBookmarksFile
,
111 PRBool aImportIntoRoot
,
112 PRBool aOverwriteDefaults
,
113 const PRUnichar
* aImportSourceNameKey
);
115 nsresult
InitializeBookmarks(nsIFile
* aTargetProfile
);