зеркало из https://github.com/mozilla/gecko-dev.git
Bug 656205 - Remove unused browser migration code. r=mak77
This commit is contained in:
Родитель
669eb04ac7
Коммит
38b464ee6e
|
@ -46,33 +46,14 @@
|
|||
#ifdef XP_MACOSX
|
||||
#define NS_SAFARIPROFILEMIGRATOR_CID \
|
||||
{ 0x29e3b139, 0xad19, 0x44f3, { 0xb2, 0xc2, 0xe9, 0xf1, 0x3b, 0xa2, 0xbb, 0xc6 } }
|
||||
|
||||
#define NS_MACIEPROFILEMIGRATOR_CID \
|
||||
{ 0xf1a4e549, 0x5c4b, 0x41ff, { 0xb5, 0xe3, 0xeb, 0x87, 0xae, 0x31, 0x41, 0x9b } }
|
||||
|
||||
#define NS_OMNIWEBPROFILEMIGRATOR_CID \
|
||||
{ 0xb80ae6d8, 0x766c, 0x43da, { 0x9c, 0x7a, 0xd, 0x82, 0x44, 0x52, 0x61, 0x6a } }
|
||||
|
||||
#define NS_CAMINOPROFILEMIGRATOR_CID \
|
||||
{ 0x01d88ea9, 0x0feb, 0x495e, { 0x8c, 0x9b, 0x41, 0x65, 0x99, 0x55, 0x52, 0x65 } }
|
||||
|
||||
#define NS_ICABPROFILEMIGRATOR_CID \
|
||||
{ 0xf394a036, 0xc5e1, 0x46d8, { 0x99, 0x39, 0x6b, 0x35, 0xe1, 0x13, 0x0a, 0x27 } }
|
||||
|
||||
#endif
|
||||
|
||||
#define NS_OPERAPROFILEMIGRATOR_CID \
|
||||
{ 0xf34ff792, 0x722e, 0x4490, { 0xb1, 0x95, 0x47, 0xd2, 0x42, 0xed, 0xca, 0x1c } }
|
||||
|
||||
#define NS_DOGBERTPROFILEMIGRATOR_CID \
|
||||
{ 0x24f92fae, 0xf793, 0x473b, { 0x80, 0x61, 0x71, 0x34, 0x8, 0xbd, 0x11, 0xd5 } }
|
||||
|
||||
#define NS_SEAMONKEYPROFILEMIGRATOR_CID \
|
||||
{ 0x9a28ffa7, 0xe6ef, 0x4b52, { 0xa1, 0x27, 0x6a, 0xd9, 0x51, 0xde, 0x8e, 0x9b } }
|
||||
|
||||
#define NS_PHOENIXPROFILEMIGRATOR_CID \
|
||||
{ 0x78481e4a, 0x50e4, 0x4489, { 0xb6, 0x8a, 0xef, 0x82, 0x67, 0xe, 0xd6, 0x3f } }
|
||||
|
||||
#define NS_SHELLSERVICE_CID \
|
||||
{ 0x63c7b9f4, 0xcc8, 0x43f8, { 0xb6, 0x66, 0xa, 0x66, 0x16, 0x55, 0xcb, 0x73 } }
|
||||
|
||||
|
|
|
@ -50,20 +50,14 @@
|
|||
#endif
|
||||
|
||||
#include "nsProfileMigrator.h"
|
||||
#include "nsDogbertProfileMigrator.h"
|
||||
#if !defined(XP_OS2)
|
||||
#include "nsOperaProfileMigrator.h"
|
||||
#endif
|
||||
#include "nsPhoenixProfileMigrator.h"
|
||||
#include "nsSeamonkeyProfileMigrator.h"
|
||||
#if defined(XP_WIN) && !defined(__MINGW32__)
|
||||
#include "nsIEProfileMigrator.h"
|
||||
#elif defined(XP_MACOSX)
|
||||
#include "nsSafariProfileMigrator.h"
|
||||
#include "nsOmniWebProfileMigrator.h"
|
||||
#include "nsMacIEProfileMigrator.h"
|
||||
#include "nsCaminoProfileMigrator.h"
|
||||
#include "nsICabProfileMigrator.h"
|
||||
#endif
|
||||
|
||||
#include "rdf.h"
|
||||
|
@ -87,21 +81,15 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacShellService)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGNOMEShellService, Init)
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDogbertProfileMigrator)
|
||||
#if !defined(XP_OS2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOperaProfileMigrator)
|
||||
#endif
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPhoenixProfileMigrator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsProfileMigrator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSeamonkeyProfileMigrator)
|
||||
#if defined(XP_WIN) && !defined(__MINGW32__)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEProfileMigrator)
|
||||
#elif defined(XP_MACOSX)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafariProfileMigrator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOmniWebProfileMigrator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacIEProfileMigrator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCaminoProfileMigrator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsICabProfileMigrator)
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFeedSniffer)
|
||||
|
@ -122,16 +110,10 @@ NS_DEFINE_NAMED_CID(NS_WINIEPROFILEMIGRATOR_CID);
|
|||
#elif defined(XP_MACOSX)
|
||||
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_SAFARIPROFILEMIGRATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_MACIEPROFILEMIGRATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_OMNIWEBPROFILEMIGRATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_CAMINOPROFILEMIGRATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_ICABPROFILEMIGRATOR_CID);
|
||||
#endif
|
||||
#if !defined(XP_OS2)
|
||||
NS_DEFINE_NAMED_CID(NS_OPERAPROFILEMIGRATOR_CID);
|
||||
#endif
|
||||
NS_DEFINE_NAMED_CID(NS_DOGBERTPROFILEMIGRATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PHOENIXPROFILEMIGRATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_SEAMONKEYPROFILEMIGRATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID);
|
||||
|
||||
|
@ -150,16 +132,10 @@ static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
|
|||
#elif defined(XP_MACOSX)
|
||||
{ &kNS_SHELLSERVICE_CID, false, NULL, nsMacShellServiceConstructor },
|
||||
{ &kNS_SAFARIPROFILEMIGRATOR_CID, false, NULL, nsSafariProfileMigratorConstructor },
|
||||
{ &kNS_MACIEPROFILEMIGRATOR_CID, false, NULL, nsMacIEProfileMigratorConstructor },
|
||||
{ &kNS_OMNIWEBPROFILEMIGRATOR_CID, false, NULL, nsOmniWebProfileMigratorConstructor },
|
||||
{ &kNS_CAMINOPROFILEMIGRATOR_CID, false, NULL, nsCaminoProfileMigratorConstructor },
|
||||
{ &kNS_ICABPROFILEMIGRATOR_CID, false, NULL, nsICabProfileMigratorConstructor },
|
||||
#endif
|
||||
#if !defined(XP_OS2)
|
||||
{ &kNS_OPERAPROFILEMIGRATOR_CID, false, NULL, nsOperaProfileMigratorConstructor },
|
||||
#endif
|
||||
{ &kNS_DOGBERTPROFILEMIGRATOR_CID, false, NULL, nsDogbertProfileMigratorConstructor },
|
||||
{ &kNS_PHOENIXPROFILEMIGRATOR_CID, false, NULL, nsPhoenixProfileMigratorConstructor },
|
||||
{ &kNS_SEAMONKEYPROFILEMIGRATOR_CID, false, NULL, nsSeamonkeyProfileMigratorConstructor },
|
||||
{ &kNS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID, false, NULL, nsPrivateBrowsingServiceWrapperConstructor },
|
||||
{ NULL }
|
||||
|
@ -192,16 +168,10 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
|
|||
#elif defined(XP_MACOSX)
|
||||
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "safari", &kNS_SAFARIPROFILEMIGRATOR_CID },
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "macie", &kNS_MACIEPROFILEMIGRATOR_CID },
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "omniweb", &kNS_OMNIWEBPROFILEMIGRATOR_CID },
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "camino", &kNS_CAMINOPROFILEMIGRATOR_CID },
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "icab", &kNS_ICABPROFILEMIGRATOR_CID },
|
||||
#endif
|
||||
#if !defined(XP_OS2)
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "opera", &kNS_OPERAPROFILEMIGRATOR_CID },
|
||||
#endif
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "dogbert", &kNS_DOGBERTPROFILEMIGRATOR_CID },
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix", &kNS_PHOENIXPROFILEMIGRATOR_CID },
|
||||
{ NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey", &kNS_SEAMONKEYPROFILEMIGRATOR_CID },
|
||||
{ NS_PRIVATE_BROWSING_SERVICE_CONTRACTID, &kNS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID },
|
||||
{ NULL }
|
||||
|
|
|
@ -128,8 +128,7 @@ var MigrationWizard = {
|
|||
return;
|
||||
}
|
||||
|
||||
if (migrator.sourceExists &&
|
||||
!(suffix == "phoenix" && !this._autoMigrate)) {
|
||||
if (migrator.sourceExists) {
|
||||
// Save this as the first selectable item, if we don't already have
|
||||
// one, or if it is the migrator that was passed to us.
|
||||
if (!selectedMigrator || this._source == suffix)
|
||||
|
@ -333,15 +332,11 @@ var MigrationWizard = {
|
|||
var source = null;
|
||||
switch (this._source) {
|
||||
case "ie":
|
||||
case "macie":
|
||||
source = "sourceNameIE";
|
||||
break;
|
||||
case "opera":
|
||||
source = "sourceNameOpera";
|
||||
break;
|
||||
case "dogbert":
|
||||
source = "sourceNameDogbert";
|
||||
break;
|
||||
case "safari":
|
||||
source = "sourceNameSafari";
|
||||
break;
|
||||
|
|
|
@ -68,43 +68,21 @@
|
|||
<!-- If you are adding a migrator, please add the appropriate
|
||||
hooks to GetDefaultBrowserMigratorKey in
|
||||
browser/components/migration/src/nsProfileMigrator.cpp -->
|
||||
<radio id="phoenix" label="&importFromPhoenix.label;" accesskey="&importFromPhoenix.accesskey;"/>
|
||||
#ifdef XP_UNIX
|
||||
#ifdef XP_MACOSX
|
||||
<radio id="safari" label="&importFromSafari.label;" accesskey="&importFromSafari.accesskey;"/>
|
||||
<radio id="macie" label="&importFromIE.label;" accesskey="&importFromIE.accesskey;"/>
|
||||
<!-- XXXben - uncomment these as we write migrators for them
|
||||
<radio id="camino" label="&importFromCamino.label;" accesskey="&importFromCamino.accesskey;"/>
|
||||
<radio id="omniweb" label="&importFromOmniWeb.label;" accesskey="&importFromOmniWeb.accesskey;"/>
|
||||
<radio id="icab" label="&importFromICab.label;" accesskey="&importFromICab.accesskey;"/>
|
||||
-->
|
||||
<radio id="seamonkey" label="&importFromSeamonkey.label;" accesskey="&importFromSeamonkey.accesskey;"/>
|
||||
<radio id="dogbert" label="&importFromNetscape4.label;" accesskey="&importFromNetscape4.accesskey;"/>
|
||||
<radio id="opera" label="&importFromOpera.label;" accesskey="&importFromOpera.accesskey;"/>
|
||||
#else
|
||||
#elifdef XP_UNIX
|
||||
<radio id="seamonkey" label="&importFromSeamonkey.label;" accesskey="&importFromSeamonkey.accesskey;"/>
|
||||
<radio id="dogbert" label="&importFromNetscape4.label;" accesskey="&importFromNetscape4.accesskey;"/>
|
||||
<radio id="opera" label="&importFromOpera.label;" accesskey="&importFromOpera.accesskey;"/>
|
||||
<!-- XXXben - uncomment these as we write migrators for them
|
||||
<radio id="konqueror" label="&importFromKonqueror.label;" accesskey="&importFromKonqueror.accesskey;"/>
|
||||
<radio id="epiphany" label="&importFromEpiphany.label;" accesskey="&importFromEpiphany.accesskey;"/>
|
||||
<radio id="galeon" label="&importFromGaleon.label;" accesskey="&importFromGaleon.accesskey;"/>
|
||||
-->
|
||||
#endif
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
#elifdef XP_WIN
|
||||
#ifndef NO_IE_MIGRATOR
|
||||
<radio id="ie" label="&importFromIE.label;" accesskey="&importFromIE.accesskey;"/>
|
||||
#endif
|
||||
<radio id="seamonkey" label="&importFromSeamonkey.label;" accesskey="&importFromSeamonkey.accesskey;"/>
|
||||
<radio id="dogbert" label="&importFromNetscape4.label;" accesskey="&importFromNetscape4.accesskey;"/>
|
||||
<radio id="opera" label="&importFromOpera.label;" accesskey="&importFromOpera.accesskey;"/>
|
||||
#endif
|
||||
#ifndef XP_UNIX
|
||||
#ifndef XP_WIN
|
||||
#else
|
||||
<radio id="seamonkey" label="&importFromSeamonkey.label;" accesskey="&importFromSeamonkey.accesskey;"/>
|
||||
<radio id="dogbert" label="&importFromNetscape4.label;" accesskey="&importFromNetscape4.accesskey;"/>
|
||||
#endif
|
||||
#endif
|
||||
<radio id="fromfile" label="&importFromHTMLFile.label;" accesskey="&importFromHTMLFile.accesskey;" hidden="true"/>
|
||||
<radio id="nothing" label="&importFromNothing.label;" accesskey="&importFromNothing.accesskey;" hidden="true"/>
|
||||
|
|
|
@ -54,8 +54,6 @@ CPPSRCS = nsProfileMigrator.cpp \
|
|||
nsBrowserProfileMigratorUtils.cpp \
|
||||
nsNetscapeProfileMigratorBase.cpp \
|
||||
nsSeamonkeyProfileMigrator.cpp \
|
||||
nsPhoenixProfileMigrator.cpp \
|
||||
nsDogbertProfileMigrator.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(OS_ARCH),OS2)
|
||||
|
@ -69,10 +67,6 @@ endif
|
|||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += nsSafariProfileMigrator.cpp \
|
||||
nsMacIEProfileMigrator.cpp \
|
||||
nsOmniWebProfileMigrator.cpp \
|
||||
nsCaminoProfileMigrator.cpp \
|
||||
nsICabProfileMigrator.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsCaminoProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsCaminoProfileMigrator
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCaminoProfileMigrator, nsIBrowserProfileMigrator)
|
||||
|
||||
nsCaminoProfileMigrator::nsCaminoProfileMigrator()
|
||||
{
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
}
|
||||
|
||||
nsCaminoProfileMigrator::~nsCaminoProfileMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCaminoProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCaminoProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
||||
PRBool aReplace,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
*aResult = 0; // XXXben implement me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCaminoProfileMigrator::GetSourceExists(PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_FALSE; // XXXben implement me
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCaminoProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCaminoProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCaminoProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsCaminoProfileMigrator
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef caminoprofilemigrator___h___
|
||||
#define caminoprofilemigrator___h___
|
||||
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
class nsCaminoProfileMigrator : public nsIBrowserProfileMigrator
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIBROWSERPROFILEMIGRATOR
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsCaminoProfileMigrator();
|
||||
virtual ~nsCaminoProfileMigrator();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,672 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsDogbertProfileMigrator.h"
|
||||
#include "nsICookieManager2.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsILineInputStream.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "prprf.h"
|
||||
#include "prenv.h"
|
||||
#include "NSReg.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#ifdef PATH_MAX
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#elif defined(_MAX_PATH)
|
||||
#define MAXPATHLEN _MAX_PATH
|
||||
#elif defined(CCHMAXPATH)
|
||||
#define MAXPATHLEN CCHMAXPATH
|
||||
#else
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define PREF_FILE_HEADER_STRING "# Mozilla User Preferences "
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#define OLDREG_NAME "Netscape Registry"
|
||||
#define OLDREG_DIR NS_MAC_PREFS_DIR
|
||||
#define PREF_FILE_NAME_IN_4x NS_LITERAL_STRING("Netscape Preferences")
|
||||
#define COOKIES_FILE_NAME_IN_4x NS_LITERAL_STRING("MagicCookie")
|
||||
#define BOOKMARKS_FILE_NAME_IN_4x NS_LITERAL_STRING("Bookmarks.html")
|
||||
#define SECURITY_PATH "Security"
|
||||
#define PSM_CERT7_DB NS_LITERAL_STRING("Certificates7")
|
||||
#define PSM_KEY3_DB NS_LITERAL_STRING("Key Database3")
|
||||
#define PSM_SECMODULE_DB NS_LITERAL_STRING("Security Modules")
|
||||
|
||||
#elif defined(XP_WIN) || defined(XP_OS2)
|
||||
#define OLDREG_NAME "nsreg.dat"
|
||||
#ifdef XP_WIN
|
||||
#define OLDREG_DIR NS_WIN_WINDOWS_DIR
|
||||
#else
|
||||
#define OLDREG_DIR NS_OS2_DIR
|
||||
#endif
|
||||
#define PREF_FILE_NAME_IN_4x NS_LITERAL_STRING("prefs.js")
|
||||
#define COOKIES_FILE_NAME_IN_4x NS_LITERAL_STRING("cookies.txt")
|
||||
#define BOOKMARKS_FILE_NAME_IN_4x NS_LITERAL_STRING("bookmark.htm")
|
||||
#define PSM_CERT7_DB NS_LITERAL_STRING("cert7.db")
|
||||
#define PSM_KEY3_DB NS_LITERAL_STRING("key3.db")
|
||||
#define PSM_SECMODULE_DB NS_LITERAL_STRING("secmod.db")
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
#define PREF_FILE_NAME_IN_4x NS_LITERAL_STRING("preferences.js")
|
||||
#define COOKIES_FILE_NAME_IN_4x NS_LITERAL_STRING("cookies")
|
||||
#define BOOKMARKS_FILE_NAME_IN_4x NS_LITERAL_STRING("bookmarks.html")
|
||||
#define PSM_CERT7_DB NS_LITERAL_STRING("cert7.db")
|
||||
#define PSM_KEY3_DB NS_LITERAL_STRING("key3.db")
|
||||
#define PSM_SECMODULE_DB NS_LITERAL_STRING("secmodule.db")
|
||||
#define HOME_ENVIRONMENT_VARIABLE "HOME"
|
||||
#define PROFILE_HOME_ENVIRONMENT_VARIABLE "PROFILE_HOME"
|
||||
#define DEFAULT_UNIX_PROFILE_NAME "default"
|
||||
#else
|
||||
#error No netscape4.x profile-migrator on this platform.
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#define COOKIES_FILE_NAME_IN_5x NS_LITERAL_STRING("cookies.txt")
|
||||
#define BOOKMARKS_FILE_NAME_IN_5x NS_LITERAL_STRING("bookmarks.html")
|
||||
#define PREF_FILE_NAME_IN_5x NS_LITERAL_STRING("prefs.js")
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsDogbertProfileMigrator
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDogbertProfileMigrator, nsIBrowserProfileMigrator)
|
||||
|
||||
nsDogbertProfileMigrator::nsDogbertProfileMigrator()
|
||||
{
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
}
|
||||
|
||||
nsDogbertProfileMigrator::~nsDogbertProfileMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup,
|
||||
const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE;
|
||||
|
||||
if (!mTargetProfile) {
|
||||
GetProfilePath(aStartup, mTargetProfile);
|
||||
if (!mTargetProfile) return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!mSourceProfile) {
|
||||
GetSourceProfile(aProfile);
|
||||
if (!mSourceProfile)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS);
|
||||
COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES);
|
||||
COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS);
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// on win/mac/os2, NS4x uses a registry to determine profile locations
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_OS2)
|
||||
void
|
||||
nsDogbertProfileMigrator::GetSourceProfile(const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFile> regFile;
|
||||
rv = NS_GetSpecialDirectory(OLDREG_DIR, getter_AddRefs(regFile));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
regFile->AppendNative(NS_LITERAL_CSTRING(OLDREG_NAME));
|
||||
|
||||
nsCAutoString path;
|
||||
rv = regFile->GetNativePath(path);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
if (NR_StartupRegistry())
|
||||
return;
|
||||
|
||||
HREG reg = nsnull;
|
||||
RKEY profile = nsnull;
|
||||
|
||||
if (NR_RegOpen(path.get(), ®))
|
||||
goto cleanup;
|
||||
|
||||
{
|
||||
// on macos, registry entries are UTF8 encoded
|
||||
NS_ConvertUTF16toUTF8 profileName(aProfile);
|
||||
|
||||
if (NR_RegGetKey(reg, ROOTKEY_USERS, profileName.get(), &profile))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
char profilePath[MAXPATHLEN];
|
||||
if (NR_RegGetEntryString(reg, profile, "ProfileLocation", profilePath, MAXPATHLEN))
|
||||
goto cleanup;
|
||||
|
||||
mSourceProfile = do_CreateInstance("@mozilla.org/file/local;1");
|
||||
if (!mSourceProfile) goto cleanup;
|
||||
|
||||
{
|
||||
// the string is UTF8 encoded, which forces us to do some strange string-do
|
||||
rv = mSourceProfile->InitWithPath(NS_ConvertUTF8toUTF16(profilePath));
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
mSourceProfile = nsnull;
|
||||
|
||||
cleanup:
|
||||
if (reg)
|
||||
NR_RegClose(reg);
|
||||
NR_ShutdownRegistry();
|
||||
}
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
||||
PRBool aReplace,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
*aResult = 0;
|
||||
if (!mSourceProfile) {
|
||||
GetSourceProfile(aProfile);
|
||||
if (!mSourceProfile)
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
MigrationData data[] = { { ToNewUnicode(PREF_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(COOKIES_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_FALSE },
|
||||
{ ToNewUnicode(BOOKMARKS_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_FALSE } };
|
||||
|
||||
// Frees file name strings allocated above.
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
aReplace, mSourceProfile, aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::GetSourceExists(PRBool* aResult)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> profiles;
|
||||
GetSourceProfiles(getter_AddRefs(profiles));
|
||||
|
||||
if (profiles) {
|
||||
PRUint32 count;
|
||||
profiles->Count(&count);
|
||||
*aResult = count > 0;
|
||||
}
|
||||
else
|
||||
*aResult = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> profiles;
|
||||
GetSourceProfiles(getter_AddRefs(profiles));
|
||||
|
||||
if (profiles) {
|
||||
PRUint32 count;
|
||||
profiles->Count(&count);
|
||||
*aResult = count > 1;
|
||||
}
|
||||
else
|
||||
*aResult = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MACOSX)
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
||||
{
|
||||
if (!mProfiles) {
|
||||
nsresult rv;
|
||||
|
||||
mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIFile> regFile;
|
||||
rv = NS_GetSpecialDirectory(OLDREG_DIR, getter_AddRefs(regFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
regFile->AppendNative(NS_LITERAL_CSTRING(OLDREG_NAME));
|
||||
|
||||
nsCAutoString path;
|
||||
rv = regFile->GetNativePath(path);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (NR_StartupRegistry())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
HREG reg = nsnull;
|
||||
REGENUM enumstate = 0;
|
||||
|
||||
if (NR_RegOpen(path.get(), ®)) {
|
||||
NR_ShutdownRegistry();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
char profileName[MAXREGNAMELEN];
|
||||
while (!NR_RegEnumSubkeys(reg, ROOTKEY_USERS, &enumstate,
|
||||
profileName, MAXREGNAMELEN, REGENUM_CHILDREN)) {
|
||||
nsCOMPtr<nsISupportsString> nameString
|
||||
(do_CreateInstance("@mozilla.org/supports-string;1"));
|
||||
if (nameString) {
|
||||
nameString->SetData(NS_ConvertUTF8toUTF16(profileName));
|
||||
mProfiles->AppendElement(nameString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aResult = mProfiles);
|
||||
return NS_OK;
|
||||
}
|
||||
#else // XP_UNIX
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
const char* profileDir = PR_GetEnv(PROFILE_HOME_ENVIRONMENT_VARIABLE);
|
||||
|
||||
if (!profileDir) {
|
||||
profileDir = PR_GetEnv(HOME_ENVIRONMENT_VARIABLE);
|
||||
}
|
||||
if (!profileDir) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString profilePath(profileDir);
|
||||
profilePath += "/.netscape";
|
||||
|
||||
nsCOMPtr<nsILocalFile> profileFile;
|
||||
rv = NS_NewNativeLocalFile(profilePath, PR_TRUE, getter_AddRefs(profileFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIFile> prefFile;
|
||||
rv = profileFile->Clone(getter_AddRefs(prefFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
prefFile->AppendNative(NS_LITERAL_CSTRING("preferences.js"));
|
||||
|
||||
PRBool exists;
|
||||
rv = prefFile->Exists(&exists);
|
||||
if (NS_FAILED(rv) || !exists) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mSourceProfile = profileFile;
|
||||
|
||||
mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupportsString> nameString
|
||||
(do_CreateInstance("@mozilla.org/supports-string;1"));
|
||||
if (!nameString) return NS_ERROR_FAILURE;
|
||||
|
||||
nameString->SetData(NS_LITERAL_STRING("Netscape 4.x"));
|
||||
mProfiles->AppendElement(nameString);
|
||||
NS_ADDREF(*aResult = mProfiles);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDogbertProfileMigrator::GetSourceProfile(const PRUnichar* aProfile)
|
||||
{
|
||||
// if GetSourceProfiles didn't do its magic, we're screwed
|
||||
}
|
||||
#endif // GetSourceProfiles
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsDogbertProfileMigrator
|
||||
#define F(a) nsDogbertProfileMigrator::a
|
||||
|
||||
static
|
||||
nsDogbertProfileMigrator::PrefTransform gTransforms[] = {
|
||||
// Simple Copy Prefs
|
||||
{ "browser.anchor_color", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "browser.visited_color", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "browser.startup.homepage", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "network.cookie.cookieBehavior", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||
{ "network.cookie.warnAboutCookies",0, F(GetBool), F(SetBool), PR_FALSE, { -1 } },
|
||||
{ "javascript.enabled", 0, F(GetBool), F(SetBool), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.type", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.no_proxies_on", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.autoconfig_url", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.ftp", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.ftp_port", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.http", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.http_port", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.ssl", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "network.proxy.ssl_port", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||
|
||||
// Prefs with Different Names
|
||||
{ "network.hosts.socks_server", "network.proxy.socks", F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "network.hosts.socks_serverport", "network.proxy.socks_port", F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||
{ "browser.background_color", "browser.display.background_color", F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "browser.foreground_color", "browser.display.foreground_color", F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||
{ "browser.wfe.use_windows_colors", "browser.display.use_system_colors", F(GetBool), F(SetBool), PR_FALSE, { -1 } },
|
||||
{ "browser.use_document_colors", "browser.display.use_document_colors",F(GetBool), F(SetBool), PR_FALSE, { -1 } },
|
||||
{ "browser.use_document.fonts", "browser.display.use_document_fonts", F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||
{ "browser.startup.page", "browser.startup.homepage", F(GetHomepage), F(SetWStringFromASCII), PR_FALSE, { -1 } },
|
||||
{ "general.always_load_images", "permissions.default.image", F(GetImagePref),F(SetInt), PR_FALSE, { -1 } },
|
||||
};
|
||||
|
||||
nsresult
|
||||
nsDogbertProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFileName,
|
||||
const nsAString& aTargetPrefFileName)
|
||||
{
|
||||
PrefTransform* transform;
|
||||
PrefTransform* end = gTransforms + sizeof(gTransforms)/sizeof(PrefTransform);
|
||||
|
||||
// Load the source pref file
|
||||
nsCOMPtr<nsIPrefService> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
psvc->ResetPrefs();
|
||||
|
||||
nsCOMPtr<nsIFile> sourcePrefsFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(sourcePrefsFile));
|
||||
sourcePrefsFile->Append(aSourcePrefFileName);
|
||||
psvc->ReadUserPrefs(sourcePrefsFile);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc));
|
||||
for (transform = gTransforms; transform < end; ++transform)
|
||||
transform->prefGetterFunc(transform, branch);
|
||||
|
||||
// Now that we have all the pref data in memory, load the target pref file,
|
||||
// and write it back out
|
||||
psvc->ResetPrefs();
|
||||
for (transform = gTransforms; transform < end; ++transform)
|
||||
transform->prefSetterFunc(transform, branch);
|
||||
|
||||
nsCOMPtr<nsIFile> targetPrefsFile;
|
||||
mTargetProfile->Clone(getter_AddRefs(targetPrefsFile));
|
||||
targetPrefsFile->Append(aTargetPrefFileName);
|
||||
psvc->SavePrefFile(targetPrefsFile);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDogbertProfileMigrator::CopyPreferences(PRBool aReplace)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!aReplace)
|
||||
return rv;
|
||||
|
||||
// 1) Copy Preferences
|
||||
TransformPreferences(PREF_FILE_NAME_IN_4x, PREF_FILE_NAME_IN_5x);
|
||||
|
||||
// 2) Copy Certficates
|
||||
rv |= CopyFile(PSM_CERT7_DB, PSM_CERT7_DB);
|
||||
rv |= CopyFile(PSM_KEY3_DB, PSM_KEY3_DB);
|
||||
rv |= CopyFile(PSM_SECMODULE_DB, PSM_SECMODULE_DB);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDogbertProfileMigrator::GetHomepage(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
PRInt32 val;
|
||||
nsresult rv = aBranch->GetIntPref(xform->sourcePrefName, &val);
|
||||
if (NS_SUCCEEDED(rv) && val == 0) {
|
||||
xform->stringValue = ToNewCString(NS_LITERAL_CSTRING("about:blank"));
|
||||
if (!xform->stringValue)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
xform->prefHasValue = PR_TRUE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDogbertProfileMigrator::GetImagePref(void* aTransform, nsIPrefBranch* aBranch)
|
||||
{
|
||||
PrefTransform* xform = (PrefTransform*)aTransform;
|
||||
PRBool loadImages;
|
||||
nsresult rv = aBranch->GetBoolPref(xform->sourcePrefName, &loadImages);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
xform->intValue = loadImages ? 1 : 2;
|
||||
xform->prefHasValue = PR_TRUE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDogbertProfileMigrator::CopyCookies(PRBool aReplace)
|
||||
{
|
||||
nsresult rv;
|
||||
if (aReplace) {
|
||||
#ifdef NEED_TO_FIX_4X_COOKIES
|
||||
rv = CopyFile(COOKIES_FILE_NAME_IN_4x, COOKIES_FILE_NAME_IN_5x);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = FixDogbertCookies();
|
||||
#else
|
||||
rv = CopyFile(COOKIES_FILE_NAME_IN_4x, COOKIES_FILE_NAME_IN_5x);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsICookieManager2> cookieManager(do_GetService(NS_COOKIEMANAGER_CONTRACTID));
|
||||
if (!cookieManager)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsIFile> dogbertCookiesFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(dogbertCookiesFile));
|
||||
dogbertCookiesFile->Append(COOKIES_FILE_NAME_IN_4x);
|
||||
|
||||
rv = ImportNetscapeCookies(dogbertCookiesFile);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if NEED_TO_FIX_4X_COOKIES
|
||||
nsresult
|
||||
nsDogbertProfileMigrator::FixDogbertCookies()
|
||||
{
|
||||
nsCOMPtr<nsIFile> dogbertCookiesFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(dogbertCookiesFile));
|
||||
dogbertCookiesFile->Append(COOKIES_FILE_NAME_IN_4x);
|
||||
|
||||
nsCOMPtr<nsIInputStream> fileInputStream;
|
||||
NS_NewLocalFileInputStream(getter_AddRefs(fileInputStream), dogbertCookiesFile);
|
||||
if (!fileInputStream) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsIFile> firebirdCookiesFile;
|
||||
mTargetProfile->Clone(getter_AddRefs(firebirdCookiesFile));
|
||||
firebirdCookiesFile->Append(COOKIES_FILE_NAME_IN_5x);
|
||||
|
||||
nsCOMPtr<nsIOutputStream> fileOutputStream;
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(fileOutputStream), firebirdCookiesFile);
|
||||
if (!fileOutputStream) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsILineInputStream> lineInputStream(do_QueryInterface(fileInputStream));
|
||||
nsCAutoString buffer, outBuffer;
|
||||
PRBool moreData = PR_FALSE;
|
||||
PRUint32 written = 0;
|
||||
do {
|
||||
nsresult rv = lineInputStream->ReadLine(buffer, &moreData);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!moreData)
|
||||
break;
|
||||
|
||||
// skip line if it is a comment or null line
|
||||
if (buffer.IsEmpty() || buffer.CharAt(0) == '#' ||
|
||||
buffer.CharAt(0) == '\r' || buffer.CharAt(0) == '\n') {
|
||||
fileOutputStream->Write(buffer.get(), buffer.Length(), &written);
|
||||
continue;
|
||||
}
|
||||
|
||||
// locate expire field, skip line if it does not contain all its fields
|
||||
int hostIndex, isDomainIndex, pathIndex, xxxIndex, expiresIndex, nameIndex, cookieIndex;
|
||||
hostIndex = 0;
|
||||
if ((isDomainIndex = buffer.FindChar('\t', hostIndex)+1) == 0 ||
|
||||
(pathIndex = buffer.FindChar('\t', isDomainIndex)+1) == 0 ||
|
||||
(xxxIndex = buffer.FindChar('\t', pathIndex)+1) == 0 ||
|
||||
(expiresIndex = buffer.FindChar('\t', xxxIndex)+1) == 0 ||
|
||||
(nameIndex = buffer.FindChar('\t', expiresIndex)+1) == 0 ||
|
||||
(cookieIndex = buffer.FindChar('\t', nameIndex)+1) == 0 )
|
||||
continue;
|
||||
|
||||
// separate the expires field from the rest of the cookie line
|
||||
const nsDependentCSubstring prefix =
|
||||
Substring(buffer, hostIndex, expiresIndex-hostIndex-1);
|
||||
const nsDependentCSubstring expiresString =
|
||||
Substring(buffer, expiresIndex, nameIndex-expiresIndex-1);
|
||||
const nsDependentCSubstring suffix =
|
||||
Substring(buffer, nameIndex, buffer.Length()-nameIndex);
|
||||
|
||||
// correct the expires field
|
||||
char* expiresCString = ToNewCString(expiresString);
|
||||
unsigned long expires = strtoul(expiresCString, nsnull, 10);
|
||||
NS_Free(expiresCString);
|
||||
|
||||
// if the cookie is supposed to expire at the end of the session
|
||||
// expires == 0. don't adjust those cookies.
|
||||
if (expires)
|
||||
expires -= SECONDS_BETWEEN_1900_AND_1970;
|
||||
char dateString[36];
|
||||
PR_snprintf(dateString, sizeof(dateString), "%lu", expires);
|
||||
|
||||
// generate the output buffer and write it to file
|
||||
outBuffer = prefix;
|
||||
outBuffer.Append('\t');
|
||||
outBuffer.Append(dateString);
|
||||
outBuffer.Append('\t');
|
||||
outBuffer.Append(suffix);
|
||||
|
||||
fileOutputStream->Write(outBuffer.get(), outBuffer.Length(), &written);
|
||||
}
|
||||
while (1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif // NEED_TO_FIX_4X_COOKIES
|
||||
|
||||
|
||||
nsresult
|
||||
nsDogbertProfileMigrator::CopyBookmarks(PRBool aReplace)
|
||||
{
|
||||
// If we're blowing away existing content, just copy the file, don't do fancy importing.
|
||||
if (aReplace) {
|
||||
nsresult rv = InitializeBookmarks(mTargetProfile);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return MigrateDogbertBookmarks();
|
||||
}
|
||||
|
||||
return ImportNetscapeBookmarks(BOOKMARKS_FILE_NAME_IN_4x,
|
||||
NS_LITERAL_STRING("sourceNameDogbert").get());
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDogbertProfileMigrator::MigrateDogbertBookmarks()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Find out what the personal toolbar folder was called, this is stored in a pref
|
||||
// in 4.x
|
||||
nsCOMPtr<nsIPrefService> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
psvc->ResetPrefs();
|
||||
|
||||
nsCOMPtr<nsIFile> dogbertPrefsFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(dogbertPrefsFile));
|
||||
dogbertPrefsFile->Append(PREF_FILE_NAME_IN_4x);
|
||||
psvc->ReadUserPrefs(dogbertPrefsFile);
|
||||
|
||||
nsCString toolbarName;
|
||||
nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc));
|
||||
rv = branch->GetCharPref("custtoolbar.personal_toolbar_folder", getter_Copies(toolbarName));
|
||||
// If the pref wasn't set in the user's 4.x preferences, there's no way we can "Fix" the
|
||||
// file when importing it to set the personal toolbar folder correctly, so don't bother
|
||||
// with the more involved file correction procedure and just copy the file over.
|
||||
if (NS_FAILED(rv))
|
||||
return CopyFile(BOOKMARKS_FILE_NAME_IN_4x, BOOKMARKS_FILE_NAME_IN_5x);
|
||||
|
||||
// Now read the 4.x bookmarks file, correcting the Personal Toolbar Folder line
|
||||
// and writing to the new location.
|
||||
nsCOMPtr<nsIFile> sourceBookmarksFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(sourceBookmarksFile));
|
||||
sourceBookmarksFile->Append(BOOKMARKS_FILE_NAME_IN_4x);
|
||||
|
||||
nsCOMPtr<nsIFile> targetBookmarksFile;
|
||||
mTargetProfile->Clone(getter_AddRefs(targetBookmarksFile));
|
||||
targetBookmarksFile->Append(BOOKMARKS_FILE_NAME_IN_5x);
|
||||
|
||||
return AnnotatePersonalToolbarFolder(sourceBookmarksFile,
|
||||
targetBookmarksFile, toolbarName.get());
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef dogbertprofilemigrator___h___
|
||||
#define dogbertprofilemigrator___h___
|
||||
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsNetscapeProfileMigratorBase.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#define NEED_TO_FIX_4X_COOKIES 1
|
||||
#define SECONDS_BETWEEN_1900_AND_1970 2208988800UL
|
||||
#endif /* XP_MACOSX */
|
||||
|
||||
class nsIFile;
|
||||
|
||||
class nsDogbertProfileMigrator : public nsNetscapeProfileMigratorBase,
|
||||
public nsIBrowserProfileMigrator
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIBROWSERPROFILEMIGRATOR
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsDogbertProfileMigrator();
|
||||
virtual ~nsDogbertProfileMigrator();
|
||||
|
||||
public:
|
||||
static nsresult GetHomepage(void* aTransform, nsIPrefBranch* aBranch);
|
||||
static nsresult GetImagePref(void* aTransform, nsIPrefBranch* aBranch);
|
||||
|
||||
protected:
|
||||
nsresult CopyPreferences(PRBool aReplace);
|
||||
nsresult TransformPreferences(const nsAString& aSourcePrefFileName,
|
||||
const nsAString& aTargetPrefFileName);
|
||||
|
||||
nsresult CopyCookies(PRBool aReplace);
|
||||
#ifdef NEED_TO_FIX_4X_COOKIES
|
||||
nsresult FixDogbertCookies();
|
||||
#endif
|
||||
|
||||
nsresult CopyBookmarks(PRBool aReplace);
|
||||
nsresult MigrateDogbertBookmarks();
|
||||
|
||||
void GetSourceProfile(const PRUnichar* aProfile);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupportsArray> mProfiles;
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,116 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsICabProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsICabProfileMigrator
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsICabProfileMigrator, nsIBrowserProfileMigrator)
|
||||
|
||||
nsICabProfileMigrator::nsICabProfileMigrator()
|
||||
{
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
}
|
||||
|
||||
nsICabProfileMigrator::~nsICabProfileMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsICabProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsICabProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
||||
PRBool aReplace,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
*aResult = 0; // XXXben implement me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsICabProfileMigrator::GetSourceExists(PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_FALSE; // XXXben implement me
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsICabProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsICabProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsICabProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsICabProfileMigrator
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef icabprofilemigrator___h___
|
||||
#define icabprofilemigrator___h___
|
||||
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
class nsICabProfileMigrator : public nsIBrowserProfileMigrator
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIBROWSERPROFILEMIGRATOR
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsICabProfileMigrator();
|
||||
virtual ~nsICabProfileMigrator();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,259 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsMacIEProfileMigrator.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIProperties.h"
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#define MACIE_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("Favorites.html")
|
||||
#define MACIE_PREFERENCES_FOLDER_NAME NS_LITERAL_STRING("Explorer")
|
||||
#define MACIE_DEFAULT_HOMEPAGE_PREF "\p4D534945¥WWWHomePage"
|
||||
#define TEMP_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("bookmarks_tmp.html")
|
||||
|
||||
#define MIGRATION_BUNDLE "chrome://browser/locale/migration/migration.properties"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsMacIEProfileMigrator
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMacIEProfileMigrator, nsIBrowserProfileMigrator)
|
||||
|
||||
nsMacIEProfileMigrator::nsMacIEProfileMigrator()
|
||||
{
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
}
|
||||
|
||||
nsMacIEProfileMigrator::~nsMacIEProfileMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacIEProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRBool replace = aStartup ? PR_TRUE : PR_FALSE;
|
||||
|
||||
if (!mTargetProfile) {
|
||||
GetProfilePath(aStartup, mTargetProfile);
|
||||
if (!mTargetProfile) return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!mSourceProfile) {
|
||||
nsCOMPtr<nsIProperties> fileLocator =
|
||||
do_GetService("@mozilla.org/file/directory_service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
fileLocator->Get(NS_OSX_USER_PREFERENCES_DIR,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(mSourceProfile));
|
||||
mSourceProfile->Append(MACIE_PREFERENCES_FOLDER_NAME);
|
||||
}
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
COPY_DATA(CopyBookmarks, replace, nsIBrowserProfileMigrator::BOOKMARKS);
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacIEProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
||||
PRBool aReplace,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
*aResult = 0;
|
||||
|
||||
if (!mSourceProfile) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIProperties> fileLocator =
|
||||
do_GetService("@mozilla.org/file/directory_service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
fileLocator->Get(NS_OSX_USER_PREFERENCES_DIR,
|
||||
NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(mSourceProfile));
|
||||
mSourceProfile->Append(MACIE_PREFERENCES_FOLDER_NAME);
|
||||
}
|
||||
|
||||
MigrationData data[] = { { ToNewUnicode(MACIE_BOOKMARKS_FILE_NAME),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_FALSE } };
|
||||
|
||||
// Frees file name strings allocated above.
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
aReplace, mSourceProfile, aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacIEProfileMigrator::GetSourceExists(PRBool* aResult)
|
||||
{
|
||||
// Since the IE bookmarks file can sometimes be created by programs
|
||||
// other than Internet Explorer, thus misleading, we must first
|
||||
// check whether IE is even installed on this Mac. We accomplish this by
|
||||
// checking one of IEs stored preferences in the apple.internetconfig file.
|
||||
PRBool prefExists = PR_FALSE;
|
||||
OSErr err;
|
||||
ICInstance icInstance;
|
||||
|
||||
err = ::ICStart(&icInstance, 'FRFX');
|
||||
if (err == noErr) {
|
||||
ICAttr attrs;
|
||||
Str255 IEhomePageValue;
|
||||
long size = kICFileSpecHeaderSize;
|
||||
err = ::ICGetPref(icInstance, MACIE_DEFAULT_HOMEPAGE_PREF, &attrs,
|
||||
IEhomePageValue, &size);
|
||||
if (err == noErr)
|
||||
prefExists = PR_TRUE;
|
||||
|
||||
::ICStop(icInstance);
|
||||
}
|
||||
|
||||
if (!prefExists) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint16 data;
|
||||
GetMigrateData(nsnull, PR_FALSE, &data);
|
||||
|
||||
*aResult = data != 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacIEProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacIEProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacIEProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsMacIEProfileMigrator
|
||||
|
||||
nsresult
|
||||
nsMacIEProfileMigrator::CopyBookmarks(PRBool aReplace)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(sourceFile));
|
||||
|
||||
sourceFile->Append(MACIE_BOOKMARKS_FILE_NAME);
|
||||
PRBool exists = PR_FALSE;
|
||||
sourceFile->Exists(&exists);
|
||||
if (!exists)
|
||||
return NS_OK;
|
||||
|
||||
// it's an import
|
||||
if (!aReplace)
|
||||
return ImportBookmarksHTML(sourceFile,
|
||||
PR_FALSE,
|
||||
PR_FALSE,
|
||||
NS_LITERAL_STRING("sourceNameIE").get());
|
||||
|
||||
// Initialize the default bookmarks
|
||||
rv = InitializeBookmarks(mTargetProfile);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// If we're blowing away existing content, annotate the Personal Toolbar and
|
||||
// then import the file.
|
||||
nsCOMPtr<nsIFile> tempFile;
|
||||
mTargetProfile->Clone(getter_AddRefs(tempFile));
|
||||
tempFile->Append(TEMP_BOOKMARKS_FILE_NAME);
|
||||
|
||||
// Look for the localized name of the IE Favorites Bar
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsString toolbarFolderNameMacIE;
|
||||
rv = bundle->GetStringFromName(NS_LITERAL_STRING("toolbarFolderNameMacIE").get(),
|
||||
getter_Copies(toolbarFolderNameMacIE));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Now read the 4.x bookmarks file, correcting the Personal Toolbar Folder
|
||||
// line and writing to the temporary file.
|
||||
rv = AnnotatePersonalToolbarFolder(sourceFile,
|
||||
tempFile,
|
||||
NS_ConvertUTF16toUTF8(toolbarFolderNameMacIE).get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// import the temp file
|
||||
rv = ImportBookmarksHTML(tempFile,
|
||||
PR_TRUE,
|
||||
PR_FALSE,
|
||||
EmptyString().get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// remove the temp file
|
||||
return tempFile->Remove(PR_FALSE);
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef macieprofilemigrator___h___
|
||||
#define macieprofilemigrator___h___
|
||||
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
class nsMacIEProfileMigrator : public nsIBrowserProfileMigrator
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIBROWSERPROFILEMIGRATOR
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsMacIEProfileMigrator();
|
||||
virtual ~nsMacIEProfileMigrator();
|
||||
|
||||
protected:
|
||||
nsresult CopyBookmarks(PRBool aReplace);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsILocalFile> mSourceProfile;
|
||||
nsCOMPtr<nsIFile> mTargetProfile;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,116 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsOmniWebProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsOmniWebProfileMigrator
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsOmniWebProfileMigrator, nsIBrowserProfileMigrator)
|
||||
|
||||
nsOmniWebProfileMigrator::nsOmniWebProfileMigrator()
|
||||
{
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
}
|
||||
|
||||
nsOmniWebProfileMigrator::~nsOmniWebProfileMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOmniWebProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOmniWebProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
||||
PRBool aReplace,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
*aResult = 0; // XXXben implement me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOmniWebProfileMigrator::GetSourceExists(PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_FALSE; // XXXben implement me
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOmniWebProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOmniWebProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOmniWebProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsOmniWebProfileMigrator
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef omniwebprofilemigrator___h___
|
||||
#define omniwebprofilemigrator___h___
|
||||
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
class nsOmniWebProfileMigrator : public nsIBrowserProfileMigrator
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIBROWSERPROFILEMIGRATOR
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsOmniWebProfileMigrator();
|
||||
virtual ~nsOmniWebProfileMigrator();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -46,6 +46,7 @@
|
|||
#include "nsStringAPI.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsINavHistoryService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
class nsICookieManager2;
|
||||
class nsILineInputStream;
|
||||
|
|
|
@ -1,438 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPhoenixProfileMigrator.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsPhoenixProfileMigrator
|
||||
|
||||
#define FILE_NAME_BOOKMARKS NS_LITERAL_STRING("bookmarks.html")
|
||||
#define FILE_NAME_COOKIES NS_LITERAL_STRING("cookies.txt")
|
||||
#define FILE_NAME_SITEPERM_OLD NS_LITERAL_STRING("cookperm.txt")
|
||||
#define FILE_NAME_SITEPERM_NEW NS_LITERAL_STRING("hostperm.1")
|
||||
#define FILE_NAME_CERT8DB NS_LITERAL_STRING("cert8.db")
|
||||
#define FILE_NAME_KEY3DB NS_LITERAL_STRING("key3.db")
|
||||
#define FILE_NAME_SECMODDB NS_LITERAL_STRING("secmod.db")
|
||||
#define FILE_NAME_HISTORY NS_LITERAL_STRING("history.dat")
|
||||
#define FILE_NAME_FORMHISTORY NS_LITERAL_STRING("formhistory.dat")
|
||||
#define FILE_NAME_LOCALSTORE NS_LITERAL_STRING("localstore.rdf")
|
||||
#define FILE_NAME_MIMETYPES NS_LITERAL_STRING("mimeTypes.rdf")
|
||||
#define FILE_NAME_DOWNLOADS NS_LITERAL_STRING("downloads.rdf")
|
||||
#define FILE_NAME_PREFS NS_LITERAL_STRING("prefs.js")
|
||||
#define FILE_NAME_USER_PREFS NS_LITERAL_STRING("user.js")
|
||||
#define FILE_NAME_USERCHROME NS_LITERAL_STRING("userChrome.css")
|
||||
#define FILE_NAME_USERCONTENT NS_LITERAL_STRING("userContent.css")
|
||||
#define DIR_NAME_CHROME NS_LITERAL_STRING("chrome")
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPhoenixProfileMigrator, nsIBrowserProfileMigrator)
|
||||
|
||||
nsPhoenixProfileMigrator::nsPhoenixProfileMigrator()
|
||||
{
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
}
|
||||
|
||||
nsPhoenixProfileMigrator::~nsPhoenixProfileMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPhoenixProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// At this time the only reason for this migrator is to get data across from the
|
||||
// Phoenix profile directory on initial run, so we don't need to support after-the-fact
|
||||
// importing.
|
||||
NS_ASSERTION(aStartup, "Can't migrate from Phoenix/Firebird/Firefox profiles once Firefox is running!");
|
||||
if (!aStartup)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!mTargetProfile) {
|
||||
GetProfilePath(aStartup, mTargetProfile);
|
||||
if (!mTargetProfile) return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!mSourceProfile)
|
||||
GetSourceProfile(aProfile);
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
COPY_DATA(CopyPreferences, PR_TRUE, nsIBrowserProfileMigrator::SETTINGS);
|
||||
COPY_DATA(CopyCookies, PR_TRUE, nsIBrowserProfileMigrator::COOKIES);
|
||||
COPY_DATA(CopyHistory, PR_TRUE, nsIBrowserProfileMigrator::HISTORY);
|
||||
COPY_DATA(CopyPasswords, PR_TRUE, nsIBrowserProfileMigrator::PASSWORDS);
|
||||
COPY_DATA(CopyOtherData, PR_TRUE, nsIBrowserProfileMigrator::OTHERDATA);
|
||||
COPY_DATA(CopyBookmarks, PR_TRUE, nsIBrowserProfileMigrator::BOOKMARKS);
|
||||
|
||||
if (aItems & nsIBrowserProfileMigrator::SETTINGS ||
|
||||
aItems & nsIBrowserProfileMigrator::COOKIES ||
|
||||
aItems & nsIBrowserProfileMigrator::PASSWORDS ||
|
||||
!aItems) {
|
||||
// Permissions (Images, Cookies, Popups)
|
||||
rv |= CopyFile(FILE_NAME_SITEPERM_NEW, FILE_NAME_SITEPERM_NEW);
|
||||
rv |= CopyFile(FILE_NAME_SITEPERM_OLD, FILE_NAME_SITEPERM_OLD);
|
||||
}
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPhoenixProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
||||
PRBool aReplace,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
*aResult = 0;
|
||||
if (!mSourceProfile) {
|
||||
GetSourceProfile(aProfile);
|
||||
if (!mSourceProfile)
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
MigrationData data[] = { { ToNewUnicode(FILE_NAME_PREFS),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_USER_PREFS),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_COOKIES),
|
||||
nsIBrowserProfileMigrator::COOKIES,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_HISTORY),
|
||||
nsIBrowserProfileMigrator::HISTORY,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_BOOKMARKS),
|
||||
nsIBrowserProfileMigrator::BOOKMARKS,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_DOWNLOADS),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_MIMETYPES),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_USERCHROME),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_USERCONTENT),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE },
|
||||
{ ToNewUnicode(FILE_NAME_FORMHISTORY),
|
||||
nsIBrowserProfileMigrator::OTHERDATA,
|
||||
PR_TRUE } };
|
||||
|
||||
// Frees file name strings allocated above.
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
aReplace, mSourceProfile, aResult);
|
||||
|
||||
// Now locate passwords
|
||||
nsCString signonsFileName;
|
||||
GetSignonFileName(aReplace, getter_Copies(signonsFileName));
|
||||
|
||||
if (!signonsFileName.IsEmpty()) {
|
||||
NS_ConvertASCIItoUTF16 fileName(signonsFileName);
|
||||
nsCOMPtr<nsIFile> sourcePasswordsFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile));
|
||||
sourcePasswordsFile->Append(fileName);
|
||||
|
||||
PRBool exists;
|
||||
sourcePasswordsFile->Exists(&exists);
|
||||
if (exists)
|
||||
*aResult |= nsIBrowserProfileMigrator::PASSWORDS;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPhoenixProfileMigrator::GetSourceExists(PRBool* aResult)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> profiles;
|
||||
GetSourceProfiles(getter_AddRefs(profiles));
|
||||
|
||||
if (profiles) {
|
||||
PRUint32 count;
|
||||
profiles->Count(&count);
|
||||
*aResult = count > 0;
|
||||
}
|
||||
else
|
||||
*aResult = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPhoenixProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> profiles;
|
||||
GetSourceProfiles(getter_AddRefs(profiles));
|
||||
|
||||
if (profiles) {
|
||||
PRUint32 count;
|
||||
profiles->Count(&count);
|
||||
*aResult = count > 1;
|
||||
}
|
||||
else
|
||||
*aResult = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPhoenixProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
||||
{
|
||||
if (!mProfileNames && !mProfileLocations) {
|
||||
mProfileNames = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
|
||||
mProfileLocations = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mProfileNames && mProfileLocations, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// Fills mProfileNames and mProfileLocations
|
||||
FillProfileDataFromPhoenixRegistry();
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aResult = mProfileNames);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsPhoenixProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsPhoenixProfileMigrator
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::GetSourceProfile(const PRUnichar* aProfile)
|
||||
{
|
||||
PRUint32 count;
|
||||
mProfileNames->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsISupportsString> str;
|
||||
mProfileNames->QueryElementAt(i, NS_GET_IID(nsISupportsString),
|
||||
getter_AddRefs(str));
|
||||
nsString profileName;
|
||||
str->GetData(profileName);
|
||||
if (profileName.Equals(aProfile)) {
|
||||
mProfileLocations->QueryElementAt(i, NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(mSourceProfile));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::FillProfileDataFromPhoenixRegistry()
|
||||
{
|
||||
// Find the Phoenix Registry
|
||||
nsCOMPtr<nsIProperties> fileLocator(do_GetService("@mozilla.org/file/directory_service;1"));
|
||||
nsCOMPtr<nsILocalFile> phoenixRegistry;
|
||||
#ifdef XP_WIN
|
||||
fileLocator->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
|
||||
|
||||
phoenixRegistry->Append(NS_LITERAL_STRING("Phoenix"));
|
||||
phoenixRegistry->Append(NS_LITERAL_STRING("registry.dat"));
|
||||
#elif defined(XP_MACOSX)
|
||||
fileLocator->Get(NS_MAC_USER_LIB_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
|
||||
|
||||
phoenixRegistry->Append(NS_LITERAL_STRING("Phoenix"));
|
||||
phoenixRegistry->Append(NS_LITERAL_STRING("Application Registry"));
|
||||
#elif defined(XP_UNIX)
|
||||
fileLocator->Get(NS_UNIX_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
|
||||
|
||||
phoenixRegistry->Append(NS_LITERAL_STRING(".phoenix"));
|
||||
phoenixRegistry->Append(NS_LITERAL_STRING("appreg"));
|
||||
#elif defined(XP_OS2)
|
||||
fileLocator->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(phoenixRegistry));
|
||||
|
||||
phoenixRegistry->Append(NS_LITERAL_STRING("Phoenix"));
|
||||
phoenixRegistry->Append(NS_LITERAL_STRING("registry.dat"));
|
||||
#endif
|
||||
|
||||
|
||||
return GetProfileDataFromRegistry(phoenixRegistry, mProfileNames, mProfileLocations);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::CopyPreferences(PRBool aReplace)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!aReplace)
|
||||
return rv;
|
||||
|
||||
// Prefs files
|
||||
rv |= CopyFile(FILE_NAME_PREFS, FILE_NAME_PREFS);
|
||||
rv |= CopyFile(FILE_NAME_USER_PREFS, FILE_NAME_USER_PREFS);
|
||||
|
||||
// Security Stuff
|
||||
rv |= CopyFile(FILE_NAME_CERT8DB, FILE_NAME_CERT8DB);
|
||||
rv |= CopyFile(FILE_NAME_KEY3DB, FILE_NAME_KEY3DB);
|
||||
rv |= CopyFile(FILE_NAME_SECMODDB, FILE_NAME_SECMODDB);
|
||||
|
||||
// User MIME Type overrides
|
||||
rv |= CopyFile(FILE_NAME_MIMETYPES, FILE_NAME_MIMETYPES);
|
||||
|
||||
rv |= CopyUserStyleSheets();
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::CopyUserStyleSheets()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIFile> sourceUserContent;
|
||||
mSourceProfile->Clone(getter_AddRefs(sourceUserContent));
|
||||
sourceUserContent->Append(DIR_NAME_CHROME);
|
||||
sourceUserContent->Append(FILE_NAME_USERCONTENT);
|
||||
|
||||
PRBool exists = PR_FALSE;
|
||||
sourceUserContent->Exists(&exists);
|
||||
if (exists) {
|
||||
nsCOMPtr<nsIFile> targetUserContent;
|
||||
mTargetProfile->Clone(getter_AddRefs(targetUserContent));
|
||||
targetUserContent->Append(DIR_NAME_CHROME);
|
||||
nsCOMPtr<nsIFile> targetChromeDir;
|
||||
targetUserContent->Clone(getter_AddRefs(targetChromeDir));
|
||||
targetUserContent->Append(FILE_NAME_USERCONTENT);
|
||||
|
||||
targetUserContent->Exists(&exists);
|
||||
if (exists)
|
||||
targetUserContent->Remove(PR_FALSE);
|
||||
|
||||
rv |= sourceUserContent->CopyTo(targetChromeDir, FILE_NAME_USERCONTENT);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> sourceUserChrome;
|
||||
mSourceProfile->Clone(getter_AddRefs(sourceUserChrome));
|
||||
sourceUserChrome->Append(DIR_NAME_CHROME);
|
||||
sourceUserChrome->Append(FILE_NAME_USERCHROME);
|
||||
|
||||
sourceUserChrome->Exists(&exists);
|
||||
if (exists) {
|
||||
nsCOMPtr<nsIFile> targetUserChrome;
|
||||
mTargetProfile->Clone(getter_AddRefs(targetUserChrome));
|
||||
targetUserChrome->Append(DIR_NAME_CHROME);
|
||||
nsCOMPtr<nsIFile> targetChromeDir;
|
||||
targetUserChrome->Clone(getter_AddRefs(targetChromeDir));
|
||||
targetUserChrome->Append(FILE_NAME_USERCHROME);
|
||||
|
||||
targetUserChrome->Exists(&exists);
|
||||
if (exists)
|
||||
targetUserChrome->Remove(PR_FALSE);
|
||||
|
||||
rv |= sourceUserChrome->CopyTo(targetChromeDir, FILE_NAME_USERCHROME);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::CopyCookies(PRBool aReplace)
|
||||
{
|
||||
return aReplace ? CopyFile(FILE_NAME_COOKIES, FILE_NAME_COOKIES) : NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::CopyHistory(PRBool aReplace)
|
||||
{
|
||||
return aReplace ? CopyFile(FILE_NAME_HISTORY, FILE_NAME_HISTORY) : NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::CopyPasswords(PRBool aReplace)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCString signonsFileName;
|
||||
if (!aReplace)
|
||||
return NS_OK;
|
||||
|
||||
// Find out what the signons file was called, this is stored in a pref
|
||||
// in Seamonkey.
|
||||
nsCOMPtr<nsIPrefService> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
psvc->ResetPrefs();
|
||||
|
||||
nsCOMPtr<nsIFile> seamonkeyPrefsFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(seamonkeyPrefsFile));
|
||||
seamonkeyPrefsFile->Append(FILE_NAME_PREFS);
|
||||
psvc->ReadUserPrefs(seamonkeyPrefsFile);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc));
|
||||
rv = branch->GetCharPref("signon.SignonFileName", getter_Copies(signonsFileName));
|
||||
|
||||
if (signonsFileName.IsEmpty())
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
|
||||
NS_ConvertASCIItoUTF16 fileName(signonsFileName);
|
||||
return aReplace ? CopyFile(fileName, fileName) : NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::CopyBookmarks(PRBool aReplace)
|
||||
{
|
||||
// This overwrites the defaults. This might be ok in this instance.
|
||||
return aReplace ? CopyFile(FILE_NAME_BOOKMARKS, FILE_NAME_BOOKMARKS) : NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPhoenixProfileMigrator::CopyOtherData(PRBool aReplace)
|
||||
{
|
||||
if (!aReplace)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
rv |= CopyFile(FILE_NAME_DOWNLOADS, FILE_NAME_DOWNLOADS);
|
||||
rv |= CopyFile(FILE_NAME_LOCALSTORE, FILE_NAME_LOCALSTORE);
|
||||
rv |= CopyFile(FILE_NAME_FORMHISTORY, FILE_NAME_FORMHISTORY);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef phoenixprofilemigrator___h___
|
||||
#define phoenixprofilemigrator___h___
|
||||
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsNetscapeProfileMigratorBase.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
class nsIFile;
|
||||
class nsIPrefBranch;
|
||||
class nsIPrefService;
|
||||
|
||||
class nsPhoenixProfileMigrator : public nsNetscapeProfileMigratorBase,
|
||||
public nsIBrowserProfileMigrator
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIBROWSERPROFILEMIGRATOR
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsPhoenixProfileMigrator();
|
||||
virtual ~nsPhoenixProfileMigrator();
|
||||
|
||||
public:
|
||||
static nsresult SetImage(void* aTransform, nsIPrefBranch* aBranch);
|
||||
static nsresult SetCookie(void* aTransform, nsIPrefBranch* aBranch);
|
||||
static nsresult SetDownloadManager(void* aTransform, nsIPrefBranch* aBranch);
|
||||
|
||||
protected:
|
||||
nsresult FillProfileDataFromPhoenixRegistry();
|
||||
nsresult GetSourceProfile(const PRUnichar* aProfile);
|
||||
|
||||
nsresult CopyPreferences(PRBool aReplace);
|
||||
nsresult CopyUserStyleSheets();
|
||||
|
||||
nsresult CopyCookies(PRBool aReplace);
|
||||
nsresult CopyHistory(PRBool aReplace);
|
||||
nsresult CopyPasswords(PRBool aReplace);
|
||||
nsresult CopyBookmarks(PRBool aReplace);
|
||||
nsresult CopyOtherData(PRBool aReplace);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupportsArray> mProfileNames;
|
||||
nsCOMPtr<nsISupportsArray> mProfileLocations;
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -160,13 +160,9 @@ NS_IMPL_ISUPPORTS1(nsProfileMigrator, nsIProfileMigrator)
|
|||
|
||||
#ifdef XP_WIN
|
||||
|
||||
#define INTERNAL_NAME_FIREBIRD "firebird"
|
||||
#define INTERNAL_NAME_FIREFOX "firefox"
|
||||
#define INTERNAL_NAME_PHOENIX "phoenix"
|
||||
#define INTERNAL_NAME_IEXPLORE "iexplore"
|
||||
#define INTERNAL_NAME_MOZILLA_SUITE "apprunner"
|
||||
#define INTERNAL_NAME_SEAMONKEY "seamonkey"
|
||||
#define INTERNAL_NAME_DOGBERT "netscape"
|
||||
#define INTERNAL_NAME_OPERA "opera"
|
||||
#endif
|
||||
|
||||
|
@ -252,22 +248,11 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsACString& aKey,
|
|||
aKey = "seamonkey";
|
||||
return NS_OK;
|
||||
}
|
||||
if (internalName.LowerCaseEqualsLiteral(INTERNAL_NAME_DOGBERT)) {
|
||||
aKey = "dogbert";
|
||||
return NS_OK;
|
||||
}
|
||||
if (internalName.LowerCaseEqualsLiteral(INTERNAL_NAME_OPERA)) {
|
||||
aKey = "opera";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Migrate data from any existing Application Data\Phoenix\* installations.
|
||||
if (internalName.LowerCaseEqualsLiteral(INTERNAL_NAME_FIREBIRD) ||
|
||||
internalName.LowerCaseEqualsLiteral(INTERNAL_NAME_FIREFOX) ||
|
||||
internalName.LowerCaseEqualsLiteral(INTERNAL_NAME_PHOENIX)) {
|
||||
aKey = "phoenix";
|
||||
return NS_OK;
|
||||
}
|
||||
#else
|
||||
PRBool exists = PR_FALSE;
|
||||
#define CHECK_MIGRATOR(browser) do {\
|
||||
|
@ -281,9 +266,7 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsACString& aKey,
|
|||
|
||||
#if defined(XP_MACOSX)
|
||||
CHECK_MIGRATOR("safari");
|
||||
CHECK_MIGRATOR("macie");
|
||||
#endif
|
||||
CHECK_MIGRATOR("phoenix");
|
||||
CHECK_MIGRATOR("seamonkey");
|
||||
CHECK_MIGRATOR("opera");
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ protected:
|
|||
nsCOMPtr<nsIBrowserProfileMigrator>& bpm);
|
||||
|
||||
/**
|
||||
* Import profiles from ~/.firefox/ or ~/.phoenix/
|
||||
* Import profiles from ~/.firefox/
|
||||
* @return PR_TRUE if any profiles imported.
|
||||
*/
|
||||
PRBool ImportRegistryProfiles(const nsACString& aAppName);
|
||||
|
|
|
@ -7,30 +7,14 @@
|
|||
|
||||
<!ENTITY importFromIE.label "Microsoft Internet Explorer">
|
||||
<!ENTITY importFromIE.accesskey "M">
|
||||
<!ENTITY importFromPhoenix.label "Firefox 0.8, Firebird or Phoenix">
|
||||
<!ENTITY importFromPhoenix.accesskey "P">
|
||||
<!ENTITY importFromNothing.label "Don't import anything">
|
||||
<!ENTITY importFromNothing.accesskey "D">
|
||||
<!ENTITY importFromSeamonkey.label "Netscape 6, 7 or Mozilla 1.x">
|
||||
<!ENTITY importFromSeamonkey.accesskey "N">
|
||||
<!ENTITY importFromNetscape4.label "Netscape 4.x">
|
||||
<!ENTITY importFromNetscape4.accesskey "4">
|
||||
<!ENTITY importFromOpera.label "Opera">
|
||||
<!ENTITY importFromOpera.accesskey "O">
|
||||
<!ENTITY importFromCamino.label "Camino">
|
||||
<!ENTITY importFromCamino.accesskey "C">
|
||||
<!ENTITY importFromSafari.label "Safari">
|
||||
<!ENTITY importFromSafari.accesskey "S">
|
||||
<!ENTITY importFromOmniWeb.label "OmniWeb">
|
||||
<!ENTITY importFromOmniWeb.accesskey "W">
|
||||
<!ENTITY importFromICab.label "iCab">
|
||||
<!ENTITY importFromICab.accesskey "i">
|
||||
<!ENTITY importFromKonqueror.label "Konqueror">
|
||||
<!ENTITY importFromKonqueror.accesskey "K">
|
||||
<!ENTITY importFromEpiphany.label "Epiphany">
|
||||
<!ENTITY importFromEpiphany.accesskey "E">
|
||||
<!ENTITY importFromGaleon.label "Galeon">
|
||||
<!ENTITY importFromGaleon.accesskey "G">
|
||||
<!ENTITY importFromHTMLFile.label "From an HTML File">
|
||||
<!ENTITY importFromHTMLFile.accesskey "F">
|
||||
|
||||
|
|
|
@ -3,22 +3,14 @@ profileName_format=%S %S
|
|||
# Browser Specific
|
||||
sourceNameIE=Internet Explorer
|
||||
sourceNameSeamonkey=Netscape 6/7/Mozilla
|
||||
sourceNameDogbert=Netscape 4
|
||||
sourceNameOpera=Opera
|
||||
sourceNameSafari=Safari
|
||||
sourceNameOmniWeb=OmniWeb
|
||||
sourceNameCamino=Camino
|
||||
sourceNameICab=iCab
|
||||
sourceNameKonqueror=Konqueror
|
||||
sourceNameEpiphany=Epiphany
|
||||
sourceNameGaleon=Galeon
|
||||
|
||||
importedBookmarksFolder=From %S
|
||||
importedSearchURLsFolder=Keyword Searches (From %S)
|
||||
importedSearchURLsTitle=Search on %S
|
||||
importedSearchUrlDesc=Type "%S <search query>" in the Location Bar to perform a search on %S.
|
||||
|
||||
importedDogbertBookmarksTitle=From Netscape 4
|
||||
importedSeamonkeyBookmarksTitle=From Netscape 6/7/Mozilla
|
||||
importedSafariBookmarks=From Safari
|
||||
importedOperaHotlistTitle=From Opera
|
||||
|
@ -27,57 +19,36 @@ importedOperaSearchUrls=Keyword Searches (From Opera)
|
|||
# Import Sources
|
||||
1_ie=Internet Options
|
||||
1_opera=Preferences
|
||||
1_dogbert=Preferences
|
||||
1_seamonkey=Preferences
|
||||
1_phoenix=Preferences
|
||||
1_safari=Preferences
|
||||
1_macie=Preferences
|
||||
|
||||
2_ie=Cookies
|
||||
2_opera=Cookies
|
||||
2_dogbert=Cookies
|
||||
2_seamonkey=Cookies
|
||||
2_phoenix=Cookies
|
||||
2_safari=Cookies
|
||||
2_macie=Cookies
|
||||
|
||||
4_ie=Browsing History
|
||||
4_opera=Browsing History
|
||||
4_dogbert=Browsing History
|
||||
4_seamonkey=Browsing History
|
||||
4_phoenix=Browsing History
|
||||
4_safari=Browsing History
|
||||
4_macie=Browsing History
|
||||
|
||||
8_ie=Saved Form History
|
||||
8_opera=Saved Form History
|
||||
8_dogbert=Saved Form History
|
||||
8_seamonkey=Saved Form History
|
||||
8_phoenix=Saved Form History
|
||||
8_safari=Saved Form History
|
||||
8_macie=Saved Form History
|
||||
|
||||
16_ie=Saved Passwords
|
||||
16_opera=Saved Passwords
|
||||
16_dogbert=Saved Passwords
|
||||
16_seamonkey=Saved Passwords
|
||||
16_phoenix=Saved Passwords
|
||||
16_safari=Saved Passwords
|
||||
16_macie=Saved Passwords
|
||||
|
||||
32_ie=Favorites
|
||||
32_opera=Bookmarks
|
||||
32_dogbert=Bookmarks
|
||||
32_seamonkey=Bookmarks
|
||||
32_phoenix=Bookmarks
|
||||
32_safari=Bookmarks
|
||||
32_macie=Favorites
|
||||
|
||||
64_ie=Other Data
|
||||
64_opera=Other Data
|
||||
64_dogbert=Other Data
|
||||
64_seamonkey=Other Data
|
||||
64_phoenix=Other Data
|
||||
64_safari=Other Data
|
||||
64_macie=Other Data
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче