Bug 239929 - Porting semi-single-profile from the aviary1.0 branch to the trunk. This is using the argv-restart method right now (a child process). This will be changing to an xpcom-restart process soon. Code by me, Ben Goodger, Darin, Scott M., M. Kaply, and others. xpfe/appshell code r=danm sr=brendan (bug 244106).
|
@ -67,7 +67,7 @@ ifdef BUILD_STATIC_LIBS
|
|||
STATIC_COMPONENTS_LINKER_PATH = -L$(DIST)/lib/components
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
TK_LIBS := -framework Cocoa $(TK_LIBS)
|
||||
endif
|
||||
|
||||
|
@ -98,6 +98,8 @@ MOZ_WINCONSOLE = 0
|
|||
endif
|
||||
endif
|
||||
|
||||
NSDISTMODE = copy
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
ifndef BUILD_STATIC_LIBS
|
||||
|
||||
|
@ -163,6 +165,9 @@ endif
|
|||
APP_VERSION = $(shell cat $(srcdir)/../config/version.txt)
|
||||
DEFINES += -DAPP_VERSION=\"$(APP_VERSION)\"
|
||||
|
||||
BUILD_ID = $(shell cat $(DEPTH)/config/build_number)
|
||||
DEFINES += -DBUILD_ID=\"$(BUILD_ID)\"
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
LIBS += -framework QuickTime -framework IOKit
|
||||
|
|
|
@ -39,22 +39,25 @@
|
|||
#include "nsXULAppAPI.h"
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include "nsBuildID.h"
|
||||
|
||||
static const nsXREAppData kAppData = {
|
||||
"Mozilla",
|
||||
"Firefox",
|
||||
APP_VERSION,
|
||||
BUILD_ID,
|
||||
"Copyright (c) 2004 mozilla.org",
|
||||
PR_FALSE
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
nsXREAppData appData;
|
||||
appData.SetSplashEnabled(PR_FALSE);
|
||||
appData.SetProductName(NS_LITERAL_CSTRING("Firefox"));
|
||||
appData.SetUseStartupPrefs(PR_FALSE);
|
||||
|
||||
return xre_main(argc, argv, appData);
|
||||
return xre_main(argc, argv, &kAppData);
|
||||
}
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
|
||||
char* splash_xpm[] = {0};
|
||||
#endif
|
||||
|
||||
#if defined( XP_WIN ) && defined( WIN32 ) && !defined(__GNUC__)
|
||||
// We need WinMain in order to not be a console app. This function is
|
||||
// unused if we are a console application.
|
||||
|
|
|
@ -9,7 +9,13 @@
|
|||
|
||||
<!-- Target Application this extension can install into,
|
||||
with minimum and maximum supported versions. -->
|
||||
<em:targetApplication>{ec8030f7-c20a-464f-9b0e-13a3a9e97384},0.7,1.2</em:targetApplication>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>0.8</em:minVersion>
|
||||
<em:maxVersion>0.9</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>DOM Inspector</em:name>
|
||||
|
|
|
@ -26,9 +26,8 @@ FILES := \
|
|||
install.rdf \
|
||||
$(NULL)
|
||||
|
||||
FILES := $(addprefix $(srcdir)/, $(FILES))
|
||||
|
||||
libs::
|
||||
$(PERL) $(MOZILLA_DIR)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) $(srcdir)/install.rdf.in > install.rdf
|
||||
$(INSTALL) $(FILES) $(DIST)/bin/defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
|
||||
|
||||
install::
|
||||
|
|
|
@ -9,7 +9,13 @@
|
|||
|
||||
<!-- Target Application this theme can install into,
|
||||
with minimum and maximum supported versions. -->
|
||||
<em:targetApplication>{ec8030f7-c20a-464f-9b0e-13a3a9e97384},0.8+,0.9</em:targetApplication>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>0.8</em:minVersion>
|
||||
<em:maxVersion>0.9</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Firefox (default)</em:name>
|
||||
|
@ -19,7 +25,7 @@
|
|||
|
||||
<!-- Front End Integration Hooks (used by Theme Manager)-->
|
||||
<!-- XXXben - preprocess this file to use different info for mac version -->
|
||||
<em:creator>Arvid Axelsson</em:creator>
|
||||
<em:creator>Gerich and Horlander</em:creator>
|
||||
<em:contributor>Mozilla Contributors</em:contributor>
|
||||
|
||||
<em:internalName>classic/1.0</em:internalName>
|
|
@ -54,9 +54,13 @@ pref("app.id", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}");
|
|||
pref("app.version",
|
||||
#expand __APP_VERSION__
|
||||
);
|
||||
pref("app.build_id",
|
||||
#expand __BUILD_ID__
|
||||
);
|
||||
|
||||
pref("update.app.enabled", true);
|
||||
pref("update.app.url", "chrome://mozapps/locale/update/update.properties");
|
||||
pref("update.app.updatesAvailable", false);
|
||||
pref("update.app.updateVersion", "");
|
||||
pref("update.app.updateDescription", "");
|
||||
pref("update.app.updateURL", "");
|
||||
|
|
|
@ -17,8 +17,6 @@ REQUIRES = \
|
|||
string \
|
||||
autocomplete \
|
||||
mork \
|
||||
profile \
|
||||
profilemanager \
|
||||
pref \
|
||||
rdf \
|
||||
intl \
|
||||
|
@ -30,6 +28,7 @@ REQUIRES = \
|
|||
bookmarks \
|
||||
migration \
|
||||
shellservice \
|
||||
xulapp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = nsBrowserCompsCID.h
|
||||
|
|
|
@ -125,7 +125,7 @@ static const nsModuleComponentInfo components[] =
|
|||
nsBookmarksServiceConstructor },
|
||||
|
||||
{ "Profile Migrator",
|
||||
NS_PROFILEMIGRATOR_CID,
|
||||
NS_FIREFOX_PROFILEMIGRATOR_CID,
|
||||
NS_PROFILEMIGRATOR_CONTRACTID,
|
||||
nsProfileMigratorConstructor },
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const kIMig = Components.interfaces.nsIBrowserProfileMigrator;
|
||||
const kIPStartup = Components.interfaces.nsIProfileStartup;
|
||||
const kProfileMigratorContractIDPrefix = "@mozilla.org/profile/migrator;1?app=browser&type=";
|
||||
|
||||
var MigrationWizard = {
|
||||
|
@ -7,7 +8,7 @@ var MigrationWizard = {
|
|||
_selectedProfile: null, // Selected Profile name to import from
|
||||
_wiz: null,
|
||||
_migrator: null,
|
||||
_autoMigrate: false,
|
||||
_autoMigrate: null,
|
||||
|
||||
init: function ()
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ var MigrationWizard = {
|
|||
if ("arguments" in window) {
|
||||
this._source = window.arguments[0];
|
||||
this._migrator = window.arguments[1].QueryInterface(kIMig);
|
||||
this._autoMigrate = true;
|
||||
this._autoMigrate = window.arguments[2].QueryInterface(kIPStartup);
|
||||
|
||||
// Show the "nothing" option in the automigrate case to provide an
|
||||
// easily identifiable way to avoid migration and create a new profile.
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISupportsArray;
|
||||
interface nsIProfileStartup;
|
||||
|
||||
[scriptable, uuid(6c64bc4a-881f-4fd8-8f19-3b4125dcee50)]
|
||||
interface nsIBrowserProfileMigrator : nsISupports
|
||||
|
@ -59,18 +60,17 @@ interface nsIBrowserProfileMigrator : nsISupports
|
|||
* @param aReplace replace or append current data where applicable.
|
||||
* @param aProfile profile to migrate from, if there is more than one.
|
||||
*/
|
||||
void migrate(in unsigned short aItems, in boolean aReplace, in wstring aProfile);
|
||||
void migrate(in unsigned short aItems, in nsIProfileStartup aStartup, in wstring aProfile);
|
||||
|
||||
/**
|
||||
* A bit field containing profile items that this migrator
|
||||
* offers for import.
|
||||
* @param aProfile the profile that we are looking for available data
|
||||
* to import
|
||||
* @param aReplace whether or not the profile is being run replace-current
|
||||
* data mode (automigration, before profile has started)
|
||||
* @param aStarting "true" if the profile is not currently being used.
|
||||
* @returns bit field containing profile items (see above)
|
||||
*/
|
||||
unsigned short getMigrateData(in wstring aProfile, in boolean aReplace);
|
||||
unsigned short getMigrateData(in wstring aProfile, in boolean aDoingStartup);
|
||||
|
||||
/**
|
||||
* Whether or not there is any data that can be imported from this
|
||||
|
|
|
@ -50,10 +50,9 @@ REQUIRES = \
|
|||
string \
|
||||
necko \
|
||||
history \
|
||||
libreg \
|
||||
browsercomps \
|
||||
toolkitcomps \
|
||||
profile \
|
||||
profilemanager \
|
||||
pref \
|
||||
rdf \
|
||||
satchel \
|
||||
|
@ -64,17 +63,21 @@ REQUIRES = \
|
|||
dom \
|
||||
docshell \
|
||||
cookie \
|
||||
xulapp \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = nsProfileMigrator.cpp \
|
||||
nsBrowserProfileMigratorUtils.cpp \
|
||||
nsNetscapeProfileMigratorBase.cpp \
|
||||
nsDogbertProfileMigrator.cpp \
|
||||
nsSeamonkeyProfileMigrator.cpp \
|
||||
nsPhoenixProfileMigrator.cpp \
|
||||
nsINIParser.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(OS_ARCH),BeOS)
|
||||
CPPSRCS += nsDogbertProfileMigrator.cpp
|
||||
endif
|
||||
|
||||
ifneq ($(OS_ARCH),OS2)
|
||||
CPPSRCS += nsOperaProfileMigrator.cpp
|
||||
endif
|
||||
|
@ -85,7 +88,7 @@ DEFINES += -DPSTOREC_DLL=\"$(subst \,\\,$(WINDIR))\\system32\\pstorec.dll\"
|
|||
CPPSRCS += nsIEProfileMigrator.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS += nsSafariProfileMigrator.cpp \
|
||||
nsMacIEProfileMigrator.cpp \
|
||||
|
|
|
@ -36,7 +36,13 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsXPCOMCID.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
void SetProxyPref(const nsACString& aHostPort, const char* aPref,
|
||||
|
@ -81,7 +87,7 @@ void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch)
|
|||
}
|
||||
|
||||
void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength,
|
||||
PRBool aReplace, nsILocalFile* aSourceProfile,
|
||||
PRBool aReplace, nsIFile* aSourceProfile,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
|
@ -103,3 +109,19 @@ void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength
|
|||
cursor->fileName = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GetProfilePath(nsIProfileStartup* aStartup, nsCOMPtr<nsIFile>& aProfileDir)
|
||||
{
|
||||
if (aStartup) {
|
||||
aStartup->GetDirectory(getter_AddRefs(aProfileDir));
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIProperties> dirSvc
|
||||
(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
|
||||
if (dirSvc) {
|
||||
dirSvc->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile),
|
||||
(void**) getter_AddRefs(aProfileDir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,9 @@
|
|||
}
|
||||
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsString.h"
|
||||
class nsIProfileStartup;
|
||||
|
||||
// Proxy utilities shared by the Opera and IE migrators
|
||||
void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch);
|
||||
|
@ -73,8 +75,13 @@ class nsILocalFile;
|
|||
void GetMigrateDataFromArray(MigrationData* aDataArray,
|
||||
PRInt32 aDataArrayLength,
|
||||
PRBool aReplace,
|
||||
nsILocalFile* aSourceProfile,
|
||||
nsIFile* aSourceProfile,
|
||||
PRUint16* aResult);
|
||||
|
||||
|
||||
// get the base directory of the *target* profile
|
||||
// this is already cloned, modify it to your heart's content
|
||||
void GetProfilePath(nsIProfileStartup* aStartup, nsCOMPtr<nsIFile>& aProfileDir);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsCaminoProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -62,7 +61,7 @@ nsCaminoProfileMigrator::~nsCaminoProfileMigrator()
|
|||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCaminoProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsCaminoProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
|
|
@ -48,8 +48,6 @@
|
|||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -57,17 +55,26 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "prprf.h"
|
||||
#include "prenv.h"
|
||||
#include "nsEscape.h"
|
||||
#include "NSReg.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#ifdef _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_UNIX) && !defined(XP_MACOSX)
|
||||
#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")
|
||||
#elif defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#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")
|
||||
|
@ -75,13 +82,33 @@
|
|||
#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")
|
||||
#else /* XP_WIN || XP_OS2 */
|
||||
|
||||
#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")
|
||||
|
@ -106,14 +133,22 @@ nsDogbertProfileMigrator::~nsDogbertProfileMigrator()
|
|||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsDogbertProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup,
|
||||
const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE;
|
||||
|
||||
if (!mTargetProfile)
|
||||
GetTargetProfile(aProfile, aReplace);
|
||||
if (!mSourceProfile)
|
||||
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);
|
||||
|
||||
|
@ -126,15 +161,63 @@ nsDogbertProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnic
|
|||
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)
|
||||
{
|
||||
// XXXben I would actually prefer we do this by reading the 4.x registry, rather than
|
||||
// relying on the 5.x registry knowing about 4.x profiles, in case we remove profile
|
||||
// manager support from Firefox.
|
||||
nsCOMPtr<nsIProfileInternal> pmi(do_GetService("@mozilla.org/profile/manager;1"));
|
||||
pmi->GetOriginalProfileDir(aProfile, getter_AddRefs(mSourceProfile));
|
||||
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,
|
||||
|
@ -144,11 +227,10 @@ nsDogbertProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
*aResult = 0;
|
||||
if (!mSourceProfile) {
|
||||
GetSourceProfile(aProfile);
|
||||
if (!mSourceProfile)
|
||||
if (!mSourceProfile)
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
PRBool exists;
|
||||
MigrationData data[] = { { ToNewUnicode(PREF_FILE_NAME_IN_4x),
|
||||
nsIBrowserProfileMigrator::SETTINGS,
|
||||
PR_TRUE },
|
||||
|
@ -200,34 +282,104 @@ nsDogbertProfileMigrator::GetSourceHasMultipleProfiles(PRBool* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MACOSX)
|
||||
NS_IMETHODIMP
|
||||
nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
||||
{
|
||||
if (!mProfiles) {
|
||||
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsresult rv;
|
||||
|
||||
// XXXben - this is a little risky.. let's make this actually go and use the
|
||||
// 4.x registry instead...
|
||||
// Our profile manager stores information about the set of Dogbert Profiles we have.
|
||||
nsCOMPtr<nsIProfileInternal> pmi(do_CreateInstance("@mozilla.org/profile/manager;1"));
|
||||
PRUnichar** profileNames = nsnull;
|
||||
PRUint32 profileCount = 0;
|
||||
// Lordy, this API sucketh.
|
||||
rv = pmi->GetProfileListX(nsIProfileInternal::LIST_FOR_IMPORT, &profileCount, &profileNames);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (PRUint32 i = 0; i < profileCount; ++i) {
|
||||
nsCOMPtr<nsISupportsString> string(do_CreateInstance("@mozilla.org/supports-string;1"));
|
||||
string->SetData(nsDependentString(profileNames[i]));
|
||||
mProfiles->AppendElement(string);
|
||||
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_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(profileCount, profileNames);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
|
||||
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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsDogbertProfileMigrator
|
||||
|
@ -396,7 +548,7 @@ nsDogbertProfileMigrator::FixDogbertCookies()
|
|||
if (!fileOutputStream) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsILineInputStream> lineInputStream(do_QueryInterface(fileInputStream));
|
||||
nsCAutoString buffer, outBuffer;
|
||||
nsAutoString buffer, outBuffer;
|
||||
PRBool moreData = PR_FALSE;
|
||||
PRUint32 written = 0;
|
||||
do {
|
||||
|
@ -409,7 +561,8 @@ nsDogbertProfileMigrator::FixDogbertCookies()
|
|||
// skip line if it is a comment or null line
|
||||
if (buffer.IsEmpty() || buffer.CharAt(0) == '#' ||
|
||||
buffer.CharAt(0) == nsCRT::CR || buffer.CharAt(0) == nsCRT::LF) {
|
||||
fileOutputStream->Write(buffer.get(), buffer.Length(), &written);
|
||||
fileOutputStream->Write((const char*)buffer.get(), buffer.Length(), &written);
|
||||
// XXX this is wrong! you need buffer.Length() * sizeof(PRUnichar)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -425,7 +578,7 @@ nsDogbertProfileMigrator::FixDogbertCookies()
|
|||
continue;
|
||||
|
||||
// separate the expires field from the rest of the cookie line
|
||||
nsCAutoString prefix, expiresString, suffix;
|
||||
nsAutoString prefix, expiresString, suffix;
|
||||
buffer.Mid(prefix, hostIndex, expiresIndex-hostIndex-1);
|
||||
buffer.Mid(expiresString, expiresIndex, nameIndex-expiresIndex-1);
|
||||
buffer.Mid(suffix, nameIndex, buffer.Length()-nameIndex);
|
||||
|
@ -444,12 +597,14 @@ nsDogbertProfileMigrator::FixDogbertCookies()
|
|||
|
||||
// generate the output buffer and write it to file
|
||||
outBuffer = prefix;
|
||||
outBuffer.Append('\t');
|
||||
outBuffer.Append(dateString);
|
||||
outBuffer.Append('\t');
|
||||
outBuffer.Append(PRUnichar('\t'));
|
||||
outBuffer.AppendWithConversion(dateString);
|
||||
outBuffer.Append(PRUnichar('\t'));
|
||||
outBuffer.Append(suffix);
|
||||
|
||||
fileOutputStream->Write(outBuffer.get(), outBuffer.Length(), &written);
|
||||
nsCAutoString convertedBuffer;
|
||||
convertedBuffer.Assign(NS_ConvertUCS2toUTF8(outBuffer));
|
||||
fileOutputStream->Write(convertedBuffer.get(), convertedBuffer.Length(), &written);
|
||||
}
|
||||
while (1);
|
||||
|
||||
|
@ -514,7 +669,6 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks()
|
|||
|
||||
nsCOMPtr<nsILineInputStream> lineInputStream(do_QueryInterface(fileInputStream));
|
||||
nsCAutoString sourceBuffer;
|
||||
nsCAutoString targetBuffer;
|
||||
PRBool moreData = PR_FALSE;
|
||||
PRUint32 bytesWritten = 0;
|
||||
do {
|
||||
|
@ -534,9 +688,8 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks()
|
|||
folderPrefixOffset + folderPrefix.Length());
|
||||
}
|
||||
|
||||
targetBuffer.Assign(sourceBuffer);
|
||||
targetBuffer.Append("\r\n");
|
||||
outputStream->Write(targetBuffer.get(), targetBuffer.Length(), &bytesWritten);
|
||||
sourceBuffer.Append("\r\n");
|
||||
outputStream->Write(sourceBuffer.get(), sourceBuffer.Length(), &bytesWritten);
|
||||
}
|
||||
while (1);
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsICabProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -62,7 +61,7 @@ nsICabProfileMigrator::~nsICabProfileMigrator()
|
|||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsICabProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsICabProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "nsIServiceManagerUtils.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
|
@ -427,10 +428,18 @@ user_pref("font.size.variable.x-western", 15);
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIBrowserProfileMigrator
|
||||
NS_IMETHODIMP
|
||||
nsIEProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsIEProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRBool aReplace = PR_FALSE;
|
||||
|
||||
if (aStartup) {
|
||||
aReplace = PR_TRUE;
|
||||
rv = aStartup->DoStartup();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS);
|
||||
|
@ -1031,6 +1040,10 @@ nsIEProfileMigrator::CopyFavorites(PRBool aReplace) {
|
|||
rdf->GetResource(NS_LITERAL_CSTRING("NC:BookmarksRoot"), getter_AddRefs(root));
|
||||
|
||||
nsCOMPtr<nsIBookmarksService> bms(do_GetService("@mozilla.org/browser/bookmarks-service;1"));
|
||||
NS_ENSURE_TRUE(bms, NS_ERROR_FAILURE);
|
||||
PRBool dummy;
|
||||
bms->ReadBookmarks(&dummy);
|
||||
|
||||
nsAutoString personalToolbarFolderName;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> folder;
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsMacIEProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -62,7 +61,7 @@ nsMacIEProfileMigrator::~nsMacIEProfileMigrator()
|
|||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacIEProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsMacIEProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@
|
|||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -80,75 +78,6 @@ nsNetscapeProfileMigratorBase::nsNetscapeProfileMigratorBase()
|
|||
bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(mBundle));
|
||||
}
|
||||
|
||||
void
|
||||
nsNetscapeProfileMigratorBase::GetTargetProfile(const PRUnichar* aSuggestedName, PRBool aReplace)
|
||||
{
|
||||
if (aReplace)
|
||||
CreateTemplateProfile(aSuggestedName);
|
||||
else {
|
||||
nsCOMPtr<nsIProfileInternal> pmi(do_GetService("@mozilla.org/profile/manager;1"));
|
||||
nsXPIDLString currProfile;
|
||||
pmi->GetCurrentProfile(getter_Copies(currProfile));
|
||||
nsCOMPtr<nsIFile> dir;
|
||||
pmi->GetProfileDir(currProfile.get(), getter_AddRefs(dir));
|
||||
mTargetProfile = do_QueryInterface(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsNetscapeProfileMigratorBase::CreateTemplateProfile(const PRUnichar* aSuggestedName)
|
||||
{
|
||||
nsCOMPtr<nsIFile> profilesDir;
|
||||
NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(profilesDir));
|
||||
|
||||
nsXPIDLString profileName;
|
||||
GetUniqueProfileName(profilesDir, aSuggestedName, getter_Copies(profileName));
|
||||
|
||||
nsAutoString profilesDirPath;
|
||||
profilesDir->GetPath(profilesDirPath);
|
||||
|
||||
nsCOMPtr<nsIProfile> pm(do_GetService("@mozilla.org/profile/manager;1"));
|
||||
pm->CreateNewProfile(profileName.get(), profilesDirPath.get(), nsnull, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIProfileInternal> pmi(do_QueryInterface(pm));
|
||||
nsCOMPtr<nsIFile> target;
|
||||
pmi->GetProfileDir(profileName.get(), getter_AddRefs(target));
|
||||
mTargetProfile = do_QueryInterface(target);
|
||||
}
|
||||
|
||||
void
|
||||
nsNetscapeProfileMigratorBase::GetUniqueProfileName(nsIFile* aProfilesDir,
|
||||
const PRUnichar* aSuggestedName,
|
||||
PRUnichar** aUniqueName)
|
||||
{
|
||||
PRBool exists = PR_FALSE;
|
||||
PRUint32 count = 1;
|
||||
nsXPIDLString profileName;
|
||||
nsAutoString profileNameStr(aSuggestedName);
|
||||
|
||||
nsCOMPtr<nsIFile> newProfileDir;
|
||||
aProfilesDir->Clone(getter_AddRefs(newProfileDir));
|
||||
newProfileDir->Append(profileNameStr);
|
||||
newProfileDir->Exists(&exists);
|
||||
|
||||
while (exists) {
|
||||
nsAutoString countString;
|
||||
countString.AppendInt(count);
|
||||
const PRUnichar* strings[2] = { aSuggestedName, countString.get() };
|
||||
mBundle->FormatStringFromName(NS_LITERAL_STRING("profileName_format").get(), strings, 2, getter_Copies(profileName));
|
||||
|
||||
nsCOMPtr<nsIFile> newProfileDir;
|
||||
aProfilesDir->Clone(getter_AddRefs(newProfileDir));
|
||||
newProfileDir->Append(profileName);
|
||||
newProfileDir->Exists(&exists);
|
||||
|
||||
profileNameStr = profileName.get();
|
||||
++count;
|
||||
}
|
||||
|
||||
*aUniqueName = ToNewUnicode(profileNameStr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistryFile,
|
||||
nsISupportsArray* aProfileNames,
|
||||
|
|
|
@ -81,9 +81,6 @@ protected:
|
|||
nsresult GetProfileDataFromRegistry(nsILocalFile* aRegistryFile,
|
||||
nsISupportsArray* aProfileNames,
|
||||
nsISupportsArray* aProfileLocations);
|
||||
void GetTargetProfile(const PRUnichar* aSuggestedName, PRBool aReplace);
|
||||
void CreateTemplateProfile(const PRUnichar* aSuggestedName);
|
||||
void GetUniqueProfileName(nsIFile* aProfilesDir, const PRUnichar* aSuggestedName, PRUnichar** aUniqueName);
|
||||
|
||||
nsresult CopyFile(const nsAString& aSourceFileName, const nsAString& aTargetFileName);
|
||||
|
||||
|
@ -97,7 +94,7 @@ protected:
|
|||
|
||||
protected:
|
||||
nsCOMPtr<nsILocalFile> mSourceProfile;
|
||||
nsCOMPtr<nsILocalFile> mTargetProfile;
|
||||
nsCOMPtr<nsIFile> mTargetProfile;
|
||||
|
||||
nsCOMPtr<nsIStringBundle> mBundle;
|
||||
};
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsOmniWebProfileMigrator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -62,7 +61,7 @@ nsOmniWebProfileMigrator::~nsOmniWebProfileMigrator()
|
|||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOmniWebProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsOmniWebProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "nsIPermissionManager.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsIRDFService.h"
|
||||
|
@ -115,9 +116,15 @@ nsOperaProfileMigrator::~nsOperaProfileMigrator()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOperaProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsOperaProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE;
|
||||
|
||||
if (aStartup) {
|
||||
rv = aStartup->DoStartup();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!mOperaProfile)
|
||||
GetOperaProfile(aProfile, getter_AddRefs(mOperaProfile));
|
||||
|
@ -932,7 +939,8 @@ nsOperaProfileMigrator::CopyHistory(PRBool aReplace)
|
|||
|
||||
nsCOMPtr<nsILineInputStream> lineStream = do_QueryInterface(fileStream);
|
||||
|
||||
nsCAutoString buffer, title, url;
|
||||
nsCAutoString buffer, url;
|
||||
nsAutoString title;
|
||||
PRTime lastVisitDate;
|
||||
PRBool moreData = PR_FALSE;
|
||||
|
||||
|
@ -946,7 +954,7 @@ nsOperaProfileMigrator::CopyHistory(PRBool aReplace)
|
|||
|
||||
switch (state) {
|
||||
case TITLE:
|
||||
title = buffer;
|
||||
CopyUTF8toUTF16(buffer, title);
|
||||
state = URL;
|
||||
break;
|
||||
case URL:
|
||||
|
@ -963,8 +971,7 @@ nsOperaProfileMigrator::CopyHistory(PRBool aReplace)
|
|||
LL_I2L(million, PR_USEC_PER_SEC);
|
||||
LL_MUL(lastVisitDate, temp, million);
|
||||
|
||||
nsAutoString titleStr; titleStr.AssignWithConversion(title);
|
||||
hist->AddPageWithDetails(url.get(), titleStr.get(), lastVisitDate);
|
||||
hist->AddPageWithDetails(url.get(), title.get(), lastVisitDate);
|
||||
|
||||
state = TITLE;
|
||||
break;
|
||||
|
@ -990,6 +997,10 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace)
|
|||
nsCOMPtr<nsILineInputStream> lineInputStream(do_QueryInterface(fileInputStream));
|
||||
|
||||
nsCOMPtr<nsIBookmarksService> bms(do_GetService("@mozilla.org/browser/bookmarks-service;1"));
|
||||
NS_ENSURE_TRUE(bms, NS_ERROR_FAILURE);
|
||||
PRBool dummy;
|
||||
bms->ReadBookmarks(&dummy);
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(kStringBundleServiceCID));
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle));
|
||||
|
@ -1182,37 +1193,32 @@ typedef enum { LineType_FOLDER,
|
|||
LineType_NL,
|
||||
LineType_OTHER } LineType;
|
||||
|
||||
static LineType GetLineType(nsAString& aBuffer, PRUnichar** aData)
|
||||
static LineType GetLineType(nsACString& aBuffer, nsACString& aResult)
|
||||
{
|
||||
if (Substring(aBuffer, 0, 7).Equals(NS_LITERAL_STRING("#FOLDER")))
|
||||
if (Substring(aBuffer, 0, 7).EqualsLiteral("#FOLDER"))
|
||||
return LineType_FOLDER;
|
||||
if (Substring(aBuffer, 0, 4).Equals(NS_LITERAL_STRING("#URL")))
|
||||
if (Substring(aBuffer, 0, 4).EqualsLiteral("#URL"))
|
||||
return LineType_BOOKMARK;
|
||||
if (Substring(aBuffer, 0, 1).Equals(NS_LITERAL_STRING("-")))
|
||||
if (Substring(aBuffer, 0, 1).EqualsLiteral("-"))
|
||||
return LineType_SEPARATOR;
|
||||
if (Substring(aBuffer, 1, 5).Equals(NS_LITERAL_STRING("NAME="))) {
|
||||
const nsAString& data = Substring(aBuffer, 6, aBuffer.Length() - 6);
|
||||
*aData = ToNewUnicode(data);
|
||||
if (Substring(aBuffer, 1, 5).EqualsLiteral("NAME=")) {
|
||||
aResult.Assign(Substring(aBuffer, 6, aBuffer.Length() - 6));
|
||||
return LineType_NAME;
|
||||
}
|
||||
if (Substring(aBuffer, 1, 4).Equals(NS_LITERAL_STRING("URL="))) {
|
||||
const nsAString& data = Substring(aBuffer, 5, aBuffer.Length() - 5);
|
||||
*aData = ToNewUnicode(data);
|
||||
if (Substring(aBuffer, 1, 4).EqualsLiteral("URL=")) {
|
||||
aResult.Assign(Substring(aBuffer, 5, aBuffer.Length() - 5));
|
||||
return LineType_URL;
|
||||
}
|
||||
if (Substring(aBuffer, 1, 12).Equals(NS_LITERAL_STRING("DESCRIPTION="))) {
|
||||
const nsAString& data = Substring(aBuffer, 13, aBuffer.Length() - 13);
|
||||
*aData = ToNewUnicode(data);
|
||||
if (Substring(aBuffer, 1, 12).EqualsLiteral("DESCRIPTION=")) {
|
||||
aResult.Assign(Substring(aBuffer, 13, aBuffer.Length() - 13));
|
||||
return LineType_DESCRIPTION;
|
||||
}
|
||||
if (Substring(aBuffer, 1, 11).Equals(NS_LITERAL_STRING("SHORT NAME="))) {
|
||||
const nsAString& data = Substring(aBuffer, 12, aBuffer.Length() - 12);
|
||||
*aData = ToNewUnicode(data);
|
||||
if (Substring(aBuffer, 1, 11).EqualsLiteral("SHORT NAME=")) {
|
||||
aResult.Assign(Substring(aBuffer, 12, aBuffer.Length() - 12));
|
||||
return LineType_KEYWORD;
|
||||
}
|
||||
if (Substring(aBuffer, 1, 15).Equals(NS_LITERAL_STRING("ON PERSONALBAR="))) {
|
||||
const nsAString& data = Substring(aBuffer, 16, aBuffer.Length() - 16);
|
||||
*aData = ToNewUnicode(data);
|
||||
if (Substring(aBuffer, 1, 15).EqualsLiteral("ON PERSONALBAR=")) {
|
||||
aResult.Assign(Substring(aBuffer, 16, aBuffer.Length() - 16));
|
||||
return LineType_ONTOOLBAR;
|
||||
}
|
||||
if (aBuffer.IsEmpty())
|
||||
|
@ -1230,22 +1236,17 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
|
|||
{
|
||||
nsresult rv;
|
||||
PRBool moreData = PR_FALSE;
|
||||
nsAutoString buffer;
|
||||
nsCAutoString buffer, result;
|
||||
EntryType entryType = EntryType_BOOKMARK;
|
||||
nsAutoString name, keyword, description;
|
||||
nsCAutoString url;
|
||||
nsAutoString name, keyword, description, url;
|
||||
PRBool onToolbar = PR_FALSE;
|
||||
NS_NAMED_LITERAL_STRING(empty, "");
|
||||
do {
|
||||
nsCAutoString cBuffer;
|
||||
rv = aStream->ReadLine(cBuffer, &moreData);
|
||||
rv = aStream->ReadLine(buffer, &moreData);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!moreData) break;
|
||||
|
||||
CopyASCIItoUTF16(cBuffer, buffer);
|
||||
nsXPIDLString data;
|
||||
LineType type = GetLineType(buffer, getter_Copies(data));
|
||||
LineType type = GetLineType(buffer, result);
|
||||
switch(type) {
|
||||
case LineType_FOLDER:
|
||||
entryType = EntryType_FOLDER;
|
||||
|
@ -1260,19 +1261,19 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
|
|||
// folder, or CopyBookmarks (which means we're done parsing all bookmarks).
|
||||
goto done;
|
||||
case LineType_NAME:
|
||||
name = data;
|
||||
CopyUTF8toUTF16(result, name);
|
||||
break;
|
||||
case LineType_URL:
|
||||
url.Assign(NS_ConvertUCS2toUTF8(data));
|
||||
CopyUTF8toUTF16(result, url);
|
||||
break;
|
||||
case LineType_KEYWORD:
|
||||
keyword = data;
|
||||
CopyUTF8toUTF16(result, keyword);
|
||||
break;
|
||||
case LineType_DESCRIPTION:
|
||||
description = data;
|
||||
CopyUTF8toUTF16(result, description);
|
||||
break;
|
||||
case LineType_ONTOOLBAR:
|
||||
if (NS_LITERAL_STRING("YES").Equals(data))
|
||||
if (result.EqualsLiteral("YES"))
|
||||
onToolbar = PR_TRUE;
|
||||
break;
|
||||
case LineType_NL: {
|
||||
|
@ -1284,7 +1285,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
|
|||
if (entryType == EntryType_BOOKMARK) {
|
||||
if (!name.IsEmpty() && !url.IsEmpty()) {
|
||||
rv = aBMS->CreateBookmarkInContainer(name.get(),
|
||||
NS_ConvertUTF8toUTF16(url).get(),
|
||||
url.get(),
|
||||
keyword.get(),
|
||||
description.get(),
|
||||
nsnull,
|
||||
|
@ -1292,10 +1293,10 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
|
|||
onToolbar ? aToolbar : aParent,
|
||||
-1,
|
||||
getter_AddRefs(itemRes));
|
||||
name = empty;
|
||||
url.AssignWithConversion(empty);
|
||||
keyword = empty;
|
||||
description = empty;
|
||||
name.Truncate();
|
||||
url.Truncate();
|
||||
keyword.Truncate();
|
||||
description.Truncate();
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
}
|
||||
|
@ -1306,7 +1307,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
|
|||
onToolbar ? aToolbar : aParent,
|
||||
-1,
|
||||
getter_AddRefs(itemRes));
|
||||
name = empty;
|
||||
name.Truncate();
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
rv = ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS);
|
||||
|
|
|
@ -85,30 +85,32 @@ nsPhoenixProfileMigrator::~nsPhoenixProfileMigrator()
|
|||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPhoenixProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
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(aReplace, "Can't migrate from Phoenix/Firebird/Firefox profiles once Firefox is running!");
|
||||
if (!aReplace)
|
||||
NS_ASSERTION(aStartup, "Can't migrate from Phoenix/Firebird/Firefox profiles once Firefox is running!");
|
||||
if (!aStartup)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!mTargetProfile)
|
||||
GetTargetProfile(aProfile, aReplace);
|
||||
if (!mTargetProfile) {
|
||||
GetProfilePath(aStartup, mTargetProfile);
|
||||
if (!mTargetProfile) return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!mSourceProfile)
|
||||
GetSourceProfile(aProfile);
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS);
|
||||
COPY_DATA(CopyCookies, aReplace, nsIBrowserProfileMigrator::COOKIES);
|
||||
COPY_DATA(CopyHistory, aReplace, nsIBrowserProfileMigrator::HISTORY);
|
||||
COPY_DATA(CopyPasswords, aReplace, nsIBrowserProfileMigrator::PASSWORDS);
|
||||
COPY_DATA(CopyOtherData, aReplace, nsIBrowserProfileMigrator::OTHERDATA);
|
||||
COPY_DATA(CopyBookmarks, aReplace, nsIBrowserProfileMigrator::BOOKMARKS);
|
||||
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 ||
|
||||
|
@ -284,6 +286,11 @@ nsPhoenixProfileMigrator::FillProfileDataFromPhoenixRegistry()
|
|||
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -35,24 +35,43 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsBrowserCompsCID.h"
|
||||
#include "nsProfileMigrator.h"
|
||||
|
||||
#include "nsIBookmarksService.h"
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIToolkitProfile.h"
|
||||
#include "nsIToolkitProfileService.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsProfileMigrator.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsBrowserCompsCID.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "NSReg.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#ifdef _MAX_PATH
|
||||
#define MAXPATHLEN _MAX_PATH
|
||||
#elif defined(CCHMAXPATH)
|
||||
#define MAXPATHLEN CCHMAXPATH
|
||||
#else
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProfileMigrator
|
||||
|
||||
|
@ -60,82 +79,67 @@
|
|||
#define MIGRATION_WIZARD_FE_FEATURES "chrome,dialog,modal,centerscreen"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProfileMigrator::Migrate()
|
||||
nsProfileMigrator::Migrate(nsIProfileStartup* aStartup)
|
||||
{
|
||||
PRBool needsActiveProfile = PR_TRUE;
|
||||
GetDefaultBrowserMigratorKey(getter_AddRefs(mMigrator),
|
||||
getter_AddRefs(mSourceKey),
|
||||
&needsActiveProfile);
|
||||
nsresult rv;
|
||||
|
||||
nsresult rv = NS_ERROR_FILE_NOT_FOUND; // No migrator, or data could be
|
||||
// found for the migrator
|
||||
if (mMigrator && mSourceKey) {
|
||||
PRBool sourceExists;
|
||||
mMigrator->GetSourceExists(&sourceExists);
|
||||
nsCAutoString key;
|
||||
nsCOMPtr<nsIBrowserProfileMigrator> bpm;
|
||||
|
||||
if (sourceExists) {
|
||||
if (!needsActiveProfile)
|
||||
rv = OpenMigrationWizard();
|
||||
else {
|
||||
nsCOMPtr<nsIObserverService> obs(do_GetService("@mozilla.org/observer-service;1"));
|
||||
rv = obs->AddObserver(this, "browser-window-before-show", PR_FALSE);
|
||||
}
|
||||
}
|
||||
rv = GetDefaultBrowserMigratorKey(key, bpm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!bpm) {
|
||||
nsCAutoString contractID =
|
||||
NS_LITERAL_CSTRING(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX) + key;
|
||||
|
||||
bpm = do_CreateInstance(contractID.get());
|
||||
if (!bpm) return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
PRBool sourceExists;
|
||||
rv = bpm->GetSourceExists(&sourceExists);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!sourceExists) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISupportsCString> cstr
|
||||
(do_CreateInstance("@mozilla.org/supports-cstring;1"));
|
||||
if (!cstr) return NS_ERROR_OUT_OF_MEMORY;
|
||||
cstr->SetData(key);
|
||||
|
||||
// By opening the Migration FE with a supplied bpm, it will automatically
|
||||
// migrate from it.
|
||||
nsCOMPtr<nsIWindowWatcher> ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsArray> params;
|
||||
NS_NewISupportsArray(getter_AddRefs(params));
|
||||
if (!ww || !params) return NS_ERROR_FAILURE;
|
||||
|
||||
params->AppendElement(cstr);
|
||||
params->AppendElement(bpm);
|
||||
params->AppendElement(aStartup);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> migrateWizard;
|
||||
return ww->OpenWindow(nsnull,
|
||||
MIGRATION_WIZARD_FE_URL,
|
||||
"_blank",
|
||||
MIGRATION_WIZARD_FE_FEATURES,
|
||||
params,
|
||||
getter_AddRefs(migrateWizard));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIObserver
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProfileMigrator::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData)
|
||||
nsProfileMigrator::Import()
|
||||
{
|
||||
if (nsCRT::strcmp(aTopic, "browser-window-before-show") == 0) {
|
||||
// Remove ourselves so we only run the migration wizard once.
|
||||
nsCOMPtr<nsIObserverService> obs(do_GetService("@mozilla.org/observer-service;1"));
|
||||
obs->RemoveObserver(this, "browser-window-before-show");
|
||||
if (ImportRegistryProfiles(NS_LITERAL_CSTRING("Firefox")))
|
||||
return NS_OK;
|
||||
|
||||
// Spin up Bookmarks
|
||||
nsCOMPtr<nsIBookmarksService> bms(do_GetService("@mozilla.org/browser/bookmarks-service;1"));
|
||||
if (bms) {
|
||||
PRBool loaded;
|
||||
bms->ReadBookmarks(&loaded);
|
||||
}
|
||||
|
||||
return OpenMigrationWizard();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsProfileMigrator
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsProfileMigrator, nsIProfileMigrator, nsIObserver)
|
||||
|
||||
nsresult
|
||||
nsProfileMigrator::OpenMigrationWizard()
|
||||
{
|
||||
if (mSourceKey && mMigrator) {
|
||||
// By opening the Migration FE with a supplied bpm, it will automatically
|
||||
// migrate from it.
|
||||
nsCOMPtr<nsIWindowWatcher> ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsArray> params;
|
||||
NS_NewISupportsArray(getter_AddRefs(params));
|
||||
params->AppendElement(mSourceKey);
|
||||
params->AppendElement(mMigrator);
|
||||
nsCOMPtr<nsIDOMWindow> migrateWizard;
|
||||
return ww->OpenWindow(nsnull,
|
||||
MIGRATION_WIZARD_FE_URL,
|
||||
"_blank",
|
||||
MIGRATION_WIZARD_FE_FEATURES,
|
||||
params,
|
||||
getter_AddRefs(migrateWizard));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMPL_ISUPPORTS1(nsProfileMigrator, nsIProfileMigrator)
|
||||
|
||||
#ifdef XP_WIN
|
||||
typedef struct {
|
||||
|
@ -153,13 +157,9 @@ typedef struct {
|
|||
#endif
|
||||
|
||||
nsresult
|
||||
nsProfileMigrator::GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMigrator,
|
||||
nsISupportsString** aKey,
|
||||
PRBool* aNeedsActiveProfile)
|
||||
nsProfileMigrator::GetDefaultBrowserMigratorKey(nsACString& aKey,
|
||||
nsCOMPtr<nsIBrowserProfileMigrator>& bpm)
|
||||
{
|
||||
*aMigrator = nsnull;
|
||||
*aKey = nsnull;
|
||||
|
||||
#if XP_WIN
|
||||
HKEY hkey;
|
||||
|
||||
|
@ -221,39 +221,29 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMig
|
|||
UINT size;
|
||||
::VerQueryValue(ver, subBlock, (void**)&internalName, &size);
|
||||
|
||||
nsCOMPtr<nsISupportsString> key(do_CreateInstance("@mozilla.org/supports-string;1"));
|
||||
nsCOMPtr<nsIBrowserProfileMigrator> bpm;
|
||||
if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_IEXPLORE)) {
|
||||
*aNeedsActiveProfile = PR_TRUE;
|
||||
key->SetData(NS_LITERAL_STRING("ie"));
|
||||
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "ie");
|
||||
aKey = "ie";
|
||||
return NS_OK;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_SEAMONKEY)) {
|
||||
*aNeedsActiveProfile = PR_FALSE;
|
||||
key->SetData(NS_LITERAL_STRING("seamonkey"));
|
||||
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey");
|
||||
if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_SEAMONKEY)) {
|
||||
aKey = "seamonkey";
|
||||
return NS_OK;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_DOGBERT)) {
|
||||
*aNeedsActiveProfile = PR_FALSE;
|
||||
key->SetData(NS_LITERAL_STRING("dogbert"));
|
||||
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "dogbert");
|
||||
if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_DOGBERT)) {
|
||||
aKey = "dogbert";
|
||||
return NS_OK;
|
||||
}
|
||||
else if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_OPERA)) {
|
||||
*aNeedsActiveProfile = PR_TRUE;
|
||||
key->SetData(NS_LITERAL_STRING("opera"));
|
||||
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "opera");
|
||||
if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_OPERA)) {
|
||||
aKey = "opera";
|
||||
return NS_OK;
|
||||
}
|
||||
// Migrate data from any existing Application Data\Phoenix\* installations.
|
||||
else if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_FIREBIRD) ||
|
||||
!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_FIREFOX) ||
|
||||
!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_PHOENIX)) {
|
||||
*aNeedsActiveProfile = PR_FALSE;
|
||||
key->SetData(NS_LITERAL_STRING("phoenix"));
|
||||
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix");
|
||||
if (!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_FIREBIRD) ||
|
||||
!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_FIREFOX) ||
|
||||
!nsCRT::strcasecmp((char*)internalName, INTERNAL_NAME_PHOENIX)) {
|
||||
aKey = "phoenix";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aKey = key);
|
||||
NS_IF_ADDREF(*aMigrator = bpm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,28 +251,125 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMig
|
|||
}
|
||||
#else
|
||||
// XXXben - until we figure out what to do here with default browsers on MacOS and
|
||||
// GNOME, simply copy data from a previous Phoenix or Seamonkey install.
|
||||
*aNeedsActiveProfile = PR_FALSE;
|
||||
nsCOMPtr<nsISupportsString> key(do_CreateInstance("@mozilla.org/supports-string;1"));
|
||||
key->SetData(NS_LITERAL_STRING("phoenix"));
|
||||
nsCOMPtr<nsIBrowserProfileMigrator> bpm(do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix"));
|
||||
PRBool exists;
|
||||
bpm->GetSourceExists(&exists);
|
||||
if (!exists) {
|
||||
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey");
|
||||
key->SetData(NS_LITERAL_STRING("seamonkey"));
|
||||
// GNOME, simply copy data from a previous Seamonkey install.
|
||||
PRBool exists = PR_FALSE;
|
||||
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "phoenix");
|
||||
if (bpm)
|
||||
bpm->GetSourceExists(&exists);
|
||||
if (!exists) {
|
||||
bpm = nsnull;
|
||||
key = nsnull;
|
||||
}
|
||||
if (exists) {
|
||||
aKey = "phoenix";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bpm = do_CreateInstance(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey");
|
||||
if (bpm)
|
||||
bpm->GetSourceExists(&exists);
|
||||
if (exists) {
|
||||
aKey = "seamonkey";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aKey = key);
|
||||
NS_IF_ADDREF(*aMigrator = bpm);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsProfileMigrator::ImportRegistryProfiles(const nsACString& aAppName)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIToolkitProfileService> profileSvc
|
||||
(do_GetService(NS_PROFILESERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(profileSvc, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIProperties> dirService
|
||||
(do_GetService("@mozilla.org/file/directory_service;1"));
|
||||
NS_ENSURE_TRUE(dirService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsILocalFile> regFile;
|
||||
#ifdef XP_WIN
|
||||
rv = dirService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(regFile));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
regFile->AppendNative(aAppName);
|
||||
regFile->AppendNative(NS_LITERAL_CSTRING("registry.dat"));
|
||||
#elif defined(XP_MACOSX)
|
||||
rv = dirService->Get(NS_MAC_USER_LIB_DIR, NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(regFile));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
regFile->AppendNative(aAppName);
|
||||
regFile->AppendNative(NS_LITERAL_CSTRING("Application Registry"));
|
||||
#elif defined(XP_OS2)
|
||||
rv = dirService->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(regFile));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
regFile->AppendNative(aAppName);
|
||||
regFile->AppendNative(NS_LITERAL_CSTRING("registry.dat"));
|
||||
#else
|
||||
rv = dirService->Get(NS_UNIX_HOME_DIR, NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(regFile));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
nsCAutoString dotAppName;
|
||||
ToLowerCase(aAppName, dotAppName);
|
||||
dotAppName.Insert('.', 0);
|
||||
|
||||
regFile->AppendNative(dotAppName);
|
||||
regFile->AppendNative(NS_LITERAL_CSTRING("appreg"));
|
||||
#endif
|
||||
|
||||
nsCAutoString path;
|
||||
rv = regFile->GetNativePath(path);
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
if (NR_StartupRegistry())
|
||||
return PR_FALSE;
|
||||
|
||||
PRBool migrated = PR_FALSE;
|
||||
HREG reg = nsnull;
|
||||
RKEY profiles = 0;
|
||||
REGENUM enumstate = 0;
|
||||
char profileName[MAXREGNAMELEN];
|
||||
|
||||
if (NR_RegOpen(path.get(), ®))
|
||||
goto cleanup;
|
||||
|
||||
if (NR_RegGetKey(reg, ROOTKEY_COMMON, "Profiles", &profiles))
|
||||
goto cleanup;
|
||||
|
||||
while (!NR_RegEnumSubkeys(reg, profiles, &enumstate,
|
||||
profileName, MAXREGNAMELEN, REGENUM_CHILDREN)) {
|
||||
#ifdef DEBUG_bsmedberg
|
||||
printf("Found profile %s.\n", profileName);
|
||||
#endif
|
||||
|
||||
RKEY profile = 0;
|
||||
if (NR_RegGetKey(reg, profiles, profileName, &profile)) {
|
||||
NS_ERROR("Could not get the key that was enumerated.");
|
||||
continue;
|
||||
}
|
||||
|
||||
char profilePath[MAXPATHLEN];
|
||||
if (NR_RegGetEntryString(reg, profile, "directory",
|
||||
profilePath, MAXPATHLEN))
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsILocalFile> profileFile
|
||||
(do_CreateInstance("@mozilla.org/file/local;1"));
|
||||
if (!profileFile)
|
||||
continue;
|
||||
|
||||
rv = profileFile->InitWithNativePath(nsDependentCString(profilePath));
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
nsCOMPtr<nsIToolkitProfile> tprofile;
|
||||
profileSvc->CreateProfile(profileFile, nsDependentCString(profileName),
|
||||
getter_AddRefs(tprofile));
|
||||
migrated = PR_TRUE;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (reg)
|
||||
NR_RegClose(reg);
|
||||
NR_ShutdownRegistry();
|
||||
return migrated;
|
||||
}
|
||||
|
|
|
@ -39,30 +39,31 @@
|
|||
#define profilemigrator___h___
|
||||
|
||||
#include "nsIBrowserProfileMigrator.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsProfileMigrator : public nsIProfileMigrator,
|
||||
public nsIObserver
|
||||
#define NS_FIREFOX_PROFILEMIGRATOR_CID \
|
||||
{ 0x4ca3c946, 0x5408, 0x49f0, { 0x9e, 0xca, 0x3a, 0x97, 0xd5, 0xc6, 0x77, 0x50 } }
|
||||
|
||||
class nsProfileMigrator : public nsIProfileMigrator
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIPROFILEMIGRATOR
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsProfileMigrator() { };
|
||||
virtual ~nsProfileMigrator() { };
|
||||
|
||||
protected:
|
||||
nsresult OpenMigrationWizard();
|
||||
nsresult GetDefaultBrowserMigratorKey(nsIBrowserProfileMigrator** aMigrator,
|
||||
nsISupportsString** aKey,
|
||||
PRBool* aNeedsActiveProfile);
|
||||
~nsProfileMigrator() { };
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIBrowserProfileMigrator> mMigrator;
|
||||
nsCOMPtr<nsISupportsString> mSourceKey;
|
||||
nsresult GetDefaultBrowserMigratorKey(nsACString& key,
|
||||
nsCOMPtr<nsIBrowserProfileMigrator>& bpm);
|
||||
|
||||
/**
|
||||
* Import profiles from ~/.firefox/ or ~/.phoenix/
|
||||
* @return PR_TRUE if any profiles imported.
|
||||
*/
|
||||
PRBool ImportRegistryProfiles(const nsACString& aAppName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,8 +43,7 @@
|
|||
#include "nsILocalFileMac.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
|
@ -77,10 +76,18 @@ nsSafariProfileMigrator::~nsSafariProfileMigrator()
|
|||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSafariProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsSafariProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRBool aReplace = PR_FALSE;
|
||||
|
||||
if (aStartup) {
|
||||
aReplace = PR_TRUE;
|
||||
rv = aStartup->DoStartup();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_STARTED, nsnull);
|
||||
|
||||
COPY_DATA(CopyPreferences, aReplace, nsIBrowserProfileMigrator::SETTINGS);
|
||||
|
|
|
@ -85,12 +85,15 @@ nsSeamonkeyProfileMigrator::~nsSeamonkeyProfileMigrator()
|
|||
// nsIBrowserProfileMigrator
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSeamonkeyProfileMigrator::Migrate(PRUint16 aItems, PRBool aReplace, const PRUnichar* aProfile)
|
||||
nsSeamonkeyProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup, const PRUnichar* aProfile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool aReplace = aStartup ? PR_TRUE : PR_FALSE;
|
||||
|
||||
if (!mTargetProfile)
|
||||
GetTargetProfile(aProfile, aReplace);
|
||||
if (!mTargetProfile) {
|
||||
GetProfilePath(aStartup, mTargetProfile);
|
||||
if (!mTargetProfile) return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!mSourceProfile)
|
||||
GetSourceProfile(aProfile);
|
||||
|
||||
|
@ -270,6 +273,11 @@ nsSeamonkeyProfileMigrator::FillProfileDataFromSeamonkeyRegistry()
|
|||
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING(".mozilla"));
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING("appreg"));
|
||||
#elif defined(XP_OS2)
|
||||
fileLocator->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(seamonkeyRegistry));
|
||||
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING("Mozilla"));
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING("registry.dat"));
|
||||
#endif
|
||||
|
||||
return GetProfileDataFromRegistry(seamonkeyRegistry, mProfileNames, mProfileLocations);
|
||||
|
|
|
@ -11,4 +11,5 @@ ac_add_options --disable-mailnews
|
|||
ac_add_options --enable-extensions=cookie,xml-rpc,xmlextras,pref,transformiix,universalchardet,typeaheadfind,webservices,inspector,gnomevfs,negotiateauth
|
||||
ac_add_options --enable-crypto
|
||||
ac_add_options --disable-composer
|
||||
ac_add_options --enable-single-profile
|
||||
ac_add_options --disable-profilesharing
|
||||
|
|
|
@ -149,6 +149,9 @@ endif
|
|||
APP_VERSION = $(shell cat $(srcdir)/../config/version.txt)
|
||||
DEFINES += -DAPP_VERSION=\"$(APP_VERSION)\"
|
||||
|
||||
BUILD_ID = $(shell cat $(DEPTH)/config/build_number)
|
||||
DEFINES += -DBUILD_ID=\"$(BUILD_ID)\"
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
LIBS += -framework QuickTime -framework IOKit
|
||||
|
|
|
@ -37,24 +37,27 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsISoftwareUpdate.h"
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include "nsBuildID.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
static const nsXREAppData kAppData = {
|
||||
0,
|
||||
"Thunderbird",
|
||||
APP_VERSION,
|
||||
BUILD_ID,
|
||||
"Copyright (c) 2004 mozilla.org",
|
||||
PR_FALSE
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
nsXREAppData appData;
|
||||
appData.SetSplashEnabled(PR_FALSE);
|
||||
appData.SetProductName(NS_LITERAL_CSTRING("Thunderbird"));
|
||||
appData.SetUseStartupPrefs(PR_TRUE);
|
||||
return xre_main(argc, argv, appData);
|
||||
return xre_main(argc, argv, &kAppData);
|
||||
}
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
|
||||
char* splash_xpm[] = {0};
|
||||
#endif
|
||||
|
||||
#if defined( XP_WIN ) && defined( WIN32 ) && !defined(__GNUC__)
|
||||
// We need WinMain in order to not be a console app. This function is
|
||||
// unused if we are a console application.
|
||||
|
|
|
@ -40,6 +40,47 @@ pref("general.useragent.vendorSub",
|
|||
#expand __APP_VERSION__
|
||||
);
|
||||
|
||||
// This is this application's unique identifier used by the Extension System to identify
|
||||
// this application as an extension target, and by the SmartUpdate system to identify
|
||||
// this application to the Update server.
|
||||
pref("app.id", "{3550f703-e582-4d05-9a08-453d09bdfdc6}");
|
||||
pref("app.version",
|
||||
#expand __APP_VERSION__
|
||||
);
|
||||
pref("app.build_id",
|
||||
#expand __BUILD_ID__
|
||||
);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
pref("mail.biff.animate_dock_icon", false);
|
||||
#endif
|
||||
|
||||
pref("update.app.enabled", true);
|
||||
pref("update.app.url", "chrome://mozapps/locale/update/update.properties");
|
||||
pref("update.app.updatesAvailable", false);
|
||||
pref("update.app.updateVersion", "");
|
||||
pref("update.app.updateDescription", "");
|
||||
pref("update.app.updateURL", "");
|
||||
pref("update.extensions.enabled", true);
|
||||
pref("update.extensions.wsdl", "chrome://mozapps/locale/extensions/extensions.properties");
|
||||
pref("extensions.getMoreExtensionsURL", "chrome://mozapps/locale/extensions/extensions.properties");
|
||||
pref("extensions.getMoreThemesURL", "chrome://mozapps/locale/extensions/extensions.properties");
|
||||
// Automatically download and install updates to themes and extensions.
|
||||
pref("update.extensions.autoUpdate", false);
|
||||
|
||||
pref("update.interval", 604800000); // every 7 days
|
||||
pref("update.lastUpdateDate", 0); // UTC offset when last update was performed.
|
||||
|
||||
// These prefs relate to the number and severity of updates available. This is a
|
||||
// cache that the browser notification mechanism uses to determine if it should show
|
||||
// status bar UI if updates are detected and the app is shut down before installing
|
||||
// them.
|
||||
// 0 = low (extension/theme updates), 1 = medium (app minor version), 2 = high (major version)
|
||||
pref("update.severity", 0);
|
||||
// The number of extension/theme/etc updates available
|
||||
pref("update.extensions.count", 0);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Overrides of the seamonkey suite mailnews.js prefs
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
@ -130,8 +171,10 @@ pref("network.hosts.pop_server", "mail");
|
|||
pref("general.config.obscure_value", 0); // for MCD .cfg files
|
||||
|
||||
pref("xpinstall.dialog.confirm", "chrome://communicator/content/xpinstall/institems.xul");
|
||||
pref("xpinstall.dialog.progress", "chrome://communicator/content/xpinstall/xpistatus.xul");
|
||||
pref("xpinstall.dialog.progress.type", "");
|
||||
pref("xpinstall.dialog.progress.skin", "chrome://mozapps/content/extensions/extensions.xul?type=themes");
|
||||
pref("xpinstall.dialog.progress.chrome", "chrome://mozapps/content/extensions/extensions.xul?type=extensions");
|
||||
pref("xpinstall.dialog.progress.type.skin", "Extension:Manager-themes");
|
||||
pref("xpinstall.dialog.progress.type.chrome", "Extension:Manager-extensions");
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// End seamonkey suite all.js pref overrides
|
||||
|
|
|
@ -834,8 +834,10 @@ function setFromBuddyIcon(email)
|
|||
gIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
||||
gFileHandler = gIOService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
|
||||
|
||||
var profile = Components.classes["@mozilla.org/profile/manager;1"].getService(Components.interfaces.nsIProfileInternal);
|
||||
gProfileDirURL = gIOService.newFileURI(profile.getProfileDir(profile.currentProfile));
|
||||
var dirService = Components.classes["@mozilla.org/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
var profileDir = dirService.get("ProfD", Components.interfaces.nsIFile);
|
||||
gProfileDirURL = gIOService.newFileURI(profileDir);
|
||||
}
|
||||
|
||||
// if we did have a buddy icon on disk for this screenname, this would be the file url spec for it
|
||||
|
|
|
@ -26,7 +26,7 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = compose prefwindow addrbook
|
||||
DIRS = compose prefwindow addrbook migration
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -337,8 +337,10 @@ function setBuddyIcon(card, buddyIcon)
|
|||
if (myScreenName && card.primaryEmail) {
|
||||
if (!gProfileDirURL) {
|
||||
// lazily create these file urls, and keep them around
|
||||
var profile = Components.classes["@mozilla.org/profile/manager;1"].getService(Components.interfaces.nsIProfileInternal);
|
||||
gProfileDirURL = gIOService.newFileURI(profile.getProfileDir(profile.currentProfile));
|
||||
var dirService = Components.classes["@mozilla.org/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
var profileDir = dirService.get("ProfD", Components.interfaces.nsIFile);
|
||||
gProfileDirURL = gIOService.newFileURI(profileDir);
|
||||
}
|
||||
|
||||
// if we did have a buddy icon on disk for this screenname, this would be the file url spec for it
|
||||
|
|
|
@ -13,6 +13,7 @@ ac_add_options --disable-activex-scripting
|
|||
ac_add_options --disable-tests
|
||||
ac_add_options --disable-oji
|
||||
ac_add_options --disable-necko-disk-cache
|
||||
ac_add_options --enable-single-profile
|
||||
ac_add_options --disable-profilesharing
|
||||
ac_add_options --enable-extensions=wallet,spellcheck,xmlextras
|
||||
ac_add_options --enable-necko-protocols=http,file,jar,viewsource,res,data
|
||||
|
|
|
@ -43,7 +43,15 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = content locale obsolete xre components mozapps
|
||||
DIRS = \
|
||||
content \
|
||||
locale \
|
||||
obsolete \
|
||||
profile \
|
||||
xre \
|
||||
components \
|
||||
mozapps \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
# Use Pinstripe on MacOS X
|
||||
|
|
|
@ -59,7 +59,6 @@ DIRS = \
|
|||
history \
|
||||
passwordmgr \
|
||||
printing \
|
||||
profile \
|
||||
satchel \
|
||||
viewconfig \
|
||||
viewsource \
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = profilemanager
|
||||
|
||||
XPIDLSRCS = nsIProfileMigrator.idl
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -64,8 +64,7 @@ function goQuitApplication()
|
|||
return false;
|
||||
domWindow.close();
|
||||
};
|
||||
if (!nativeAppSupport || !nativeAppSupport.isServerMode)
|
||||
appShell.quit(Components.interfaces.nsIAppShellService.eAttemptQuit);
|
||||
appShell.quit(Components.interfaces.nsIAppShellService.eAttemptQuit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ const kObserverServiceProgID = "@mozilla.org/observer-service;1";
|
|||
const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
|
||||
|
||||
var gExtensionManager = null;
|
||||
var gExtensionssView = null;
|
||||
var gExtensionsView = null;
|
||||
var gWindowState = "";
|
||||
var gURIPrefix = ""; // extension or theme prefix
|
||||
var gDSRoot = ""; // extension or theme root
|
||||
|
@ -17,6 +17,7 @@ var gObserverIndex = -1;
|
|||
const PREF_APP_ID = "app.id";
|
||||
const PREF_EXTENSIONS_GETMORETHEMESURL = "extensions.getMoreThemesURL";
|
||||
const PREF_EXTENSIONS_GETMOREEXTENSIONSURL = "extensions.getMoreExtensionsURL";
|
||||
const PREF_EM_LAST_SELECTED_SKIN = "extensions.lastSelectedSkin";
|
||||
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -36,8 +37,7 @@ function openURL(aURL)
|
|||
|
||||
var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
|
||||
.getService(Components.interfaces.nsIExternalProtocolService);
|
||||
if (protocolSvc.isExposedProtocol(uri.scheme))
|
||||
protocolSvc.loadUrl(uri);
|
||||
protocolSvc.loadUrl(uri);
|
||||
# If we're a browser, open a new browser window instead.
|
||||
#else
|
||||
openDialog("chrome://browser/content/browser.xul", "_blank", "chrome,all,dialog=no", aURL, null, null);
|
||||
|
@ -93,10 +93,9 @@ function Startup()
|
|||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
if (!isExtensions) {
|
||||
gExtensionsView.addEventListener("richview-select", onThemeSelect, false);
|
||||
try {
|
||||
gCurrentTheme = pref.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN);
|
||||
}
|
||||
catch (e) { gCurrentTheme = "classic/1.0"; }
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
gCurrentTheme = cr.getSelectedSkin("global");
|
||||
|
||||
var useThemeButton = document.getElementById("useThemeButton");
|
||||
useThemeButton.hidden = false;
|
||||
|
@ -247,7 +246,6 @@ XPInstallDownloadManager.prototype = {
|
|||
{
|
||||
const nsIXPIProgressDialog = Components.interfaces.nsIXPIProgressDialog;
|
||||
var element = document.getElementById(aURL);
|
||||
dump("*** aURL = " + aURL + "\n");
|
||||
if (!element) return;
|
||||
switch (aState) {
|
||||
case nsIXPIProgressDialog.DOWNLOAD_START:
|
||||
|
@ -261,6 +259,7 @@ XPInstallDownloadManager.prototype = {
|
|||
element.setAttribute("state", "installing");
|
||||
break;
|
||||
case nsIXPIProgressDialog.INSTALL_DONE:
|
||||
dump("*** state change = " + aURL + ", state = " + aState + ", value = " + aValue + "\n");
|
||||
element.setAttribute("state", "done");
|
||||
var msg;
|
||||
if (aValue != 0) {
|
||||
|
@ -570,6 +569,10 @@ var gExtensionsViewController = {
|
|||
case "cmd_movedn":
|
||||
var children = gExtensionsView.children;
|
||||
return (children[children.length-1] != selectedItem);
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
case "cmd_install":
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
@ -601,17 +604,24 @@ var gExtensionsViewController = {
|
|||
cmd_useTheme: function ()
|
||||
{
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
gCurrentTheme = gExtensionsView.selected.getAttribute("internalName");
|
||||
var inUse = cr.isSkinSelected(gCurrentTheme , true);
|
||||
if (inUse == Components.interfaces.nsIChromeRegistry.FULL)
|
||||
return;
|
||||
|
||||
pref.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, gCurrentTheme);
|
||||
|
||||
// Set this pref so the user can reset the theme in safe mode
|
||||
pref.setCharPref(PREF_EM_LAST_SELECTED_SKIN, gCurrentTheme);
|
||||
cr.selectSkin(gCurrentTheme, true);
|
||||
cr.refreshSkins();
|
||||
|
||||
|
||||
// disable the useThemeButton
|
||||
gExtensionsViewController.onCommandUpdate();
|
||||
},
|
||||
|
||||
cmd_options: function ()
|
||||
|
@ -640,65 +650,22 @@ var gExtensionsViewController = {
|
|||
|
||||
cmd_movetop: function ()
|
||||
{
|
||||
var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
|
||||
var extensions = rdfs.GetResource("urn:mozilla:extension:root");
|
||||
var container = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer);
|
||||
container.Init(gExtensionManager.datasource, extensions);
|
||||
|
||||
var movingID = gExtensionsView.selected.id;
|
||||
var extension = rdfs.GetResource(movingID);
|
||||
var index = container.IndexOf(extension);
|
||||
if (index > 1) {
|
||||
container.RemoveElement(extension, false);
|
||||
container.InsertElementAt(extension, 1, true);
|
||||
}
|
||||
|
||||
flushDataSource();
|
||||
|
||||
gExtensionManager.moveTop(stripPrefix(movingID));
|
||||
gExtensionsView.selected = document.getElementById(movingID);
|
||||
},
|
||||
|
||||
cmd_moveup: function ()
|
||||
{
|
||||
var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
|
||||
var extensions = rdfs.GetResource("urn:mozilla:extension:root");
|
||||
var container = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer);
|
||||
container.Init(gExtensionManager.datasource, extensions);
|
||||
|
||||
var movingID = gExtensionsView.selected.id;
|
||||
var extension = rdfs.GetResource(movingID);
|
||||
var index = container.IndexOf(extension);
|
||||
if (index > 1) {
|
||||
container.RemoveElement(extension, false);
|
||||
container.InsertElementAt(extension, index - 1, true);
|
||||
}
|
||||
|
||||
flushDataSource();
|
||||
|
||||
gExtensionManager.moveUp(stripPrefix(movingID));
|
||||
gExtensionsView.selected = document.getElementById(movingID);
|
||||
},
|
||||
|
||||
cmd_movedn: function ()
|
||||
{
|
||||
var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
|
||||
var extensions = rdfs.GetResource("urn:mozilla:extension:root");
|
||||
var container = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer);
|
||||
container.Init(gExtensionManager.datasource, extensions);
|
||||
|
||||
var movingID = gExtensionsView.selected.id;
|
||||
var extension = rdfs.GetResource(movingID);
|
||||
var index = container.IndexOf(extension);
|
||||
var count = container.GetCount();
|
||||
if (index < count) {
|
||||
container.RemoveElement(extension, true);
|
||||
container.InsertElementAt(extension, index + 1, true);
|
||||
}
|
||||
|
||||
flushDataSource();
|
||||
|
||||
gExtensionManager.moveDown(stripPrefix(movingID));
|
||||
gExtensionsView.selected = document.getElementById(movingID);
|
||||
},
|
||||
|
||||
|
@ -757,9 +724,74 @@ var gExtensionsViewController = {
|
|||
{
|
||||
gExtensionManager.enableExtension(stripPrefix(gExtensionsView.selected.id));
|
||||
},
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
cmd_install: function()
|
||||
{
|
||||
if (gWindowState == "extensions")
|
||||
installExtension();
|
||||
else
|
||||
installSkin();
|
||||
},
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
///////////////////////////////////////////////////////////////
|
||||
// functions to support installing of themes in thunderbird
|
||||
///////////////////////////////////////////////////////////////
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
const nsIIOService = Components.interfaces.nsIIOService;
|
||||
const nsIFileProtocolHandler = Components.interfaces.nsIFileProtocolHandler;
|
||||
const nsIURL = Components.interfaces.nsIURL;
|
||||
|
||||
function installSkin()
|
||||
{
|
||||
// 1) Prompt the user for the location of the theme to install.
|
||||
var extensionsStrings = document.getElementById("extensionsStrings");
|
||||
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
fp.init(window, extensionsStrings.getString("installThemePickerTitle"), nsIFilePicker.modeOpen);
|
||||
|
||||
|
||||
fp.appendFilter(extensionsStrings.getString("themesFilter"), "*.jar");
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
|
||||
var ret = fp.show();
|
||||
if (ret == nsIFilePicker.returnOK)
|
||||
{
|
||||
var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(nsIIOService);
|
||||
var fileProtocolHandler =
|
||||
ioService.getProtocolHandler("file").QueryInterface(nsIFileProtocolHandler);
|
||||
var url = fileProtocolHandler.newFileURI(fp.file).QueryInterface(nsIURL);
|
||||
InstallTrigger.installChrome(InstallTrigger.SKIN, url.spec, decodeURIComponent(url.fileBaseName));
|
||||
}
|
||||
}
|
||||
|
||||
function installExtension()
|
||||
{
|
||||
var extensionsStrings = document.getElementById("extensionsStrings");
|
||||
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
fp.init(window, extensionsStrings.getString("installExtensionPickerTitle"), nsIFilePicker.modeOpen);
|
||||
|
||||
fp.appendFilter(extensionsStrings.getString("extensionFilter"), "*.xpi");
|
||||
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
|
||||
var ret = fp.show();
|
||||
if (ret == nsIFilePicker.returnOK)
|
||||
{
|
||||
var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(nsIIOService);
|
||||
var fileProtocolHandler =
|
||||
ioService.getProtocolHandler("file").QueryInterface(nsIFileProtocolHandler);
|
||||
var url = fileProtocolHandler.newFileURI(fp.file).QueryInterface(nsIURL);
|
||||
var xpi = {};
|
||||
xpi[decodeURIComponent(url.fileBaseName)] = url.spec;
|
||||
InstallTrigger.install(xpi);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
|
|
@ -74,14 +74,13 @@
|
|||
#else
|
||||
tooltiptext="&optionsUnix.tooltip;"
|
||||
#endif
|
||||
tooltiptext="&options.tooltip;"
|
||||
onclick="this.parentNode.parentNode.parentNode.fireEvent('options');"/>
|
||||
onclick="gExtensionsViewController.doCommand('cmd_options');"/>
|
||||
<xul:image class="extension-button" anonid="about-button"
|
||||
tooltiptext="&about.tooltip;"
|
||||
onclick="this.parentNode.parentNode.parentNode.fireEvent('about');"/>
|
||||
onclick="gExtensionsViewController.doCommand('cmd_about');"/>
|
||||
<xul:image class="extension-button" anonid="homepage-button"
|
||||
tooltiptext="&homepage.tooltip;"
|
||||
onclick="this.parentNode.parentNode.parentNode.fireEvent('homepage');"/>
|
||||
onclick="gExtensionsViewController.doCommand('cmd_homepage');"/>
|
||||
</xul:vbox>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
<command id="cmd_options"/>
|
||||
<command id="cmd_about"/>
|
||||
<command id="cmd_homepage"/>
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
<command id="cmd_install"/>
|
||||
#endif
|
||||
<command id="cmd_uninstall"/>
|
||||
<command id="cmd_update"/>
|
||||
<command id="cmd_enable"/>
|
||||
|
@ -246,6 +249,11 @@
|
|||
<hbox>
|
||||
<hbox id="commandBar" flex="1" align="center">
|
||||
<hbox>
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
<button id="installButton"
|
||||
label="&cmd.install.label;" accesskey="&cmd.install.accesskey;" tooltiptext="&cmd.install.tooltip;"
|
||||
command="cmd_install"/>
|
||||
#endif
|
||||
<button id="uninstallButton"
|
||||
label="&cmd.uninstall.label;" accesskey="&cmd.uninstall.accesskey;" tooltiptext="&cmd.uninstall.tooltip;"
|
||||
command="cmd_uninstall"/>
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
<!ENTITY cmd.useTheme.label " Use Theme">
|
||||
<!ENTITY cmd.useTheme.accesskey "U">
|
||||
<!ENTITY cmd.useTheme.tooltip "Changes &brandShortName;'s theme.">
|
||||
<!-- the following command bar items are used by thunderbird only -->
|
||||
<!ENTITY cmd.install.label "Install">
|
||||
<!ENTITY cmd.install.tooltip "Install an extension">
|
||||
<!ENTITY cmd.install.accesskey "n">
|
||||
|
||||
<!-- Context Menu Options: Extension -->
|
||||
<!ENTITY cmd.options.label "Options">
|
||||
|
|
|
@ -12,9 +12,9 @@ queryUninstallExtensionMessage=If you uninstall %S, the functionality it offers
|
|||
queryUninstallThemeMessage=Do you want to uninstall %S?
|
||||
queryUninstallTitle=Uninstall %S
|
||||
|
||||
update.extensions.wsdl=http://localhost:8080/axis/services/VersionCheck?wsdl
|
||||
extensions.getMoreExtensionsURL=http://update.mozilla.org/extensions.php?app=%APPID%
|
||||
extensions.getMoreThemesURL=http://update.mozilla.org/themes.php?app=%APPID%
|
||||
update.extensions.wsdl=http://update.mozilla.org:8080/axis/services/VersionCheck?wsdl
|
||||
extensions.getMoreExtensionsURL=http://update.mozilla.org/extensions/?application=%APPID%
|
||||
extensions.getMoreThemesURL=http://update.mozilla.org/themes/?application=%APPID%
|
||||
|
||||
themesTitle=Themes
|
||||
extensionsTitle=Extensions
|
||||
|
@ -29,3 +29,24 @@ installSuccess=Installed Successfully
|
|||
statusFormatKBKB=#1 of #2 KB
|
||||
statusFormatKBMB=#1 KB of #2 MB
|
||||
statusFormatMBMB=#1 of #2 MB
|
||||
|
||||
disabledObsoleteTitle=Old Extensions
|
||||
disabledObsoleteMessage=Any old extensions that you have installed have been disabled.
|
||||
|
||||
incompatibleTitle=Incompatible Extension
|
||||
incompatibleMessage=%S %S could not be installed because it is not compatible with this version of %S. (%S %S will only work with %S versions from %S to %S)
|
||||
incompatibleMessageSingleAppVersion=%S %S could not be installed because it is not compatible with this version of %S. (%S %S will only work with %S %S)
|
||||
|
||||
malformedMessage=%S could not install this item because "%S" (provided by the item) is malformed. Please contact the author about this problem.
|
||||
malformedTitle=Malformed File
|
||||
|
||||
invalidVersionMessage=%S could not install "%S" because its version information ("%S") is invalid. Please contact the author about this problem.
|
||||
invalidVersionTitle=Invalid Version
|
||||
|
||||
# The following are used by Thunderbird only in order to provide a way to load
|
||||
# extension and JAR files.
|
||||
|
||||
extensionFilter=Extensions (*.xpi)
|
||||
themesFilter=Themes (*.jar)
|
||||
installThemePickerTitle=Select a theme to install
|
||||
installExtensionPickerTitle=Select an extension to install
|
||||
|
|
|
@ -53,6 +53,17 @@ interface nsIExtensionDownloadProgressListener : nsISupports
|
|||
[scriptable, uuid(c3515b0f-99f4-453b-805e-1fdf5724d6d9)]
|
||||
interface nsIExtensionManager : nsISupports
|
||||
{
|
||||
// Apprunner hooks
|
||||
boolean start(in boolean aIsDirty);
|
||||
|
||||
/**
|
||||
* Returns true if mismatches were found and the app needs to restart.
|
||||
*/
|
||||
boolean checkForMismatches();
|
||||
|
||||
void handleCommandLineArgs();
|
||||
|
||||
// Installing Extensions
|
||||
const unsigned long FLAG_INSTALL_PROFILE = 0x01;
|
||||
const unsigned long FLAG_INSTALL_GLOBAL = 0x02;
|
||||
|
||||
|
@ -61,30 +72,33 @@ interface nsIExtensionManager : nsISupports
|
|||
void enableExtension(in string aExtensionID);
|
||||
void disableExtension(in string aExtensionID);
|
||||
|
||||
// Installing Themes
|
||||
void installTheme(in nsIFile aJARFile, in unsigned long aFlags);
|
||||
void uninstallTheme(in string aThemeID);
|
||||
|
||||
// Downloads
|
||||
void addDownloads([array, size_is(aItemCount)] in nsIUpdateItem aItems,
|
||||
in unsigned long aItemCount);
|
||||
void removeDownload(in wstring aURL, in unsigned short aType);
|
||||
long addDownloadObserver(in nsIExtensionDownloadProgressListener aObserver);
|
||||
void removeDownloadObserverAt(in long aIndex);
|
||||
|
||||
void installTheme(in nsIFile aJARFile, in unsigned long aFlags);
|
||||
void uninstallTheme(in string aThemeID);
|
||||
|
||||
/**
|
||||
* Returns true if mismatches were found and the app needs to restart.
|
||||
*/
|
||||
boolean checkForMismatches();
|
||||
|
||||
readonly attribute boolean inSafeMode;
|
||||
|
||||
// Updates
|
||||
void update([array, size_is(aItemCount)] in nsIUpdateItem aItems,
|
||||
in unsigned long aItemCount);
|
||||
|
||||
// Management
|
||||
void getItemList(in string aItemID,
|
||||
in unsigned short aType,
|
||||
out unsigned long aItemCount,
|
||||
[retval, array, size_is(aItemCount)] out nsIUpdateItem aItems);
|
||||
|
||||
void moveUp(in string aItemID);
|
||||
void moveDown(in string aItemID);
|
||||
void moveTop(in string aItemID);
|
||||
|
||||
readonly attribute nsIRDFDataSource datasource;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,10 +55,6 @@
|
|||
margin: 0px 5px 0px 0px !important;
|
||||
}
|
||||
|
||||
#uninstallButton[disabled="true"] {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/placeholder.gif");
|
||||
}
|
||||
|
||||
.commandBarSeparator {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
#clientBox {
|
||||
background-color: #FFFFFF;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#extensionName {
|
||||
font-size: large;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#extensionVersion {
|
||||
font-weight: bold;
|
||||
color: #909090;
|
||||
}
|
||||
|
||||
#extensionHomepage {
|
||||
color: #0000FF;
|
||||
text-decoration: underline !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#genericAbout {
|
||||
padding: 0px 0px 10px 0px;
|
||||
min-height: 200px;
|
||||
width: 30em;
|
||||
}
|
||||
|
||||
#groove {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
#clientBox {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#extensionDescription {
|
||||
color: #404040;
|
||||
}
|
||||
|
||||
#extensionDescription, #extensionContributors, #creatorBox, #contributorsBox {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
#extensionCreator, .contributor {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#extensionCreatorLabel, #extensionContributors {
|
||||
border-top: 2px solid #C0C0C0;
|
||||
padding: 2px 0px 3px 0px;
|
||||
margin-top: 3px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
После Ширина: | Высота: | Размер: 3.3 KiB |
После Ширина: | Высота: | Размер: 430 B |
После Ширина: | Высота: | Размер: 385 B |
После Ширина: | Высота: | Размер: 2.1 KiB |
После Ширина: | Высота: | Размер: 499 B |
|
@ -0,0 +1,191 @@
|
|||
#extensionManager {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
view {
|
||||
-moz-appearance: none !important;
|
||||
-moz-user-focus: normal;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#extensionsView[state="themes"] {
|
||||
margin: 8px 8px 3px 8px;
|
||||
border: 1px solid #bebebe;
|
||||
}
|
||||
|
||||
#extensionsView[state="extensions"] {
|
||||
margin-bottom: 1px;
|
||||
border-bottom: 1px solid #bebebe;
|
||||
}
|
||||
|
||||
/* Extension Manager Command Bar */
|
||||
#commandBar {
|
||||
padding: 5px 8px 6px 8px;
|
||||
}
|
||||
|
||||
#uninstallButton {
|
||||
margin: 0px;
|
||||
-moz-user-focus: ignore;
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(0px, 32px, 26px, 0px) !important;
|
||||
}
|
||||
|
||||
#uninstallButton:hover:active {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(26px, 32px, 52px, 0px);
|
||||
}
|
||||
|
||||
#uninstallButton[disabled="true"] {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(52px, 32px, 78px, 0px) !important;
|
||||
}
|
||||
|
||||
#updateButton {
|
||||
margin: 0px;
|
||||
-moz-user-focus: ignore;
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(0px, 64px, 26px, 32px);
|
||||
-moz-appearance: none;
|
||||
}
|
||||
|
||||
#updateButton:hover:active {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(26px, 64px, 52px, 32px);
|
||||
}
|
||||
|
||||
#updateButton[disabled="true"] {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(52px, 64px, 78px, 32px) !important;
|
||||
}
|
||||
|
||||
#useThemeButton {
|
||||
margin: 0px;
|
||||
-moz-user-focus: ignore;
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(0px, 96px, 26px, 64px) !important;
|
||||
}
|
||||
|
||||
#useThemeButton:hover:active {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(26px, 96px, 52px, 64px);
|
||||
}
|
||||
|
||||
#useThemeButton[disabled="true"] {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/actionbuttons.png");
|
||||
-moz-image-region: rect(52px, 96px, 78px, 64px) !important;
|
||||
}
|
||||
|
||||
#uninstallButton, #updateButton, #useThemeButton {
|
||||
-moz-appearance: none !important;
|
||||
width: 32px !important;
|
||||
max-width: 32px !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.button-text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.commandBarSeparator {
|
||||
width: 3px;
|
||||
}
|
||||
|
||||
#getMore {
|
||||
color: #0000FF;
|
||||
text-decoration: underline !important;
|
||||
cursor: pointer;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Extension Buttons (Iconic buttons in each extension item) */
|
||||
.extension-button {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
.extension-button[anonid="options-button"] {
|
||||
background-image: url("chrome://mozapps/skin/extensions/extensionOptions.png");
|
||||
}
|
||||
|
||||
.extension-button[anonid="about-button"] {
|
||||
background-image: url("chrome://mozapps/skin/extensions/extensionAbout.png");
|
||||
}
|
||||
|
||||
.extension-button[anonid="homepage-button"] {
|
||||
background-image: url("chrome://mozapps/skin/extensions/extensionHome.png");
|
||||
}
|
||||
|
||||
/* Extension List Items */
|
||||
extension[selected="true"] {
|
||||
background-color: Highlight;
|
||||
}
|
||||
|
||||
extension {
|
||||
padding: 10px;
|
||||
min-height: 25px;
|
||||
border-bottom: 1px dashed #C0C0C0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
extension[odd] {
|
||||
background-color: #F3F3F3;
|
||||
}
|
||||
|
||||
.extension-icon {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/extensionItem.png");
|
||||
}
|
||||
|
||||
extension[disabled="true"] {
|
||||
color: GrayText;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
extension[disabled="true"][selected="true"] {
|
||||
background-image: url("chrome://mozapps/skin/shared/itemSelected.png");
|
||||
}
|
||||
|
||||
extension[disabled="true"] .extension-icon {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.extension-item-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.extension-item-description, .extension-item-creator {
|
||||
color: #505050;
|
||||
}
|
||||
.extension-icon {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.previewText {
|
||||
font-size: larger;
|
||||
font-weight: bold;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
extension[itemType="theme"] {
|
||||
padding: 7px 5px 7px 6px;
|
||||
}
|
||||
|
||||
extension[itemType="theme"] .extension-icon {
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
.themePreviewArea {
|
||||
margin: 8px 8px 3px 0px !important;
|
||||
padding: 5px 5px 0px 5px;
|
||||
border: 3px solid transparent;
|
||||
-moz-border-top-colors: #9b9b9b #c8c8c8 #e1e1e1 ;
|
||||
-moz-border-right-colors: #c4c4c4 #e1e1e1 #e4e4e4;
|
||||
-moz-border-bottom-colors: #d6d6d6 #e2e2e2 #e4e4e4;
|
||||
-moz-border-left-colors: #c4c4c4 #e1e1e1 #e4e4e4;
|
||||
background: url("chrome://global/skin/10pct_transparent_grey.png") repeat !important;
|
||||
-moz-border-radius: 3px;
|
||||
}
|
||||
|
После Ширина: | Высота: | Размер: 2.1 KiB |
После Ширина: | Высота: | Размер: 2.1 KiB |
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@mozilla.org>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __MacLaunchHelper_h__
|
||||
#define __MacLaunchHelper_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void LaunchChildMac(int aArgc, char** aArgv);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@mozilla.org>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "MacLaunchHelper.h"
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
void LaunchChildMac(int aArgc, char** aArgv)
|
||||
{
|
||||
int i;
|
||||
NSTask* child = [[NSTask alloc] init];
|
||||
NSMutableArray* args = [[NSMutableArray alloc] init];
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
for (i = 1; i < aArgc; ++i)
|
||||
[args addObject: [NSString stringWithCString: aArgv[i]]];
|
||||
|
||||
[child setCurrentDirectoryPath:[[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent]];
|
||||
[child setLaunchPath:[[NSBundle mainBundle] executablePath]];
|
||||
[child setArguments:args];
|
||||
[child launch];
|
||||
[pool release];
|
||||
}
|
||||
|
|
@ -54,8 +54,10 @@ REQUIRES = \
|
|||
dom \
|
||||
embed_base \
|
||||
embedcomponents \
|
||||
extensions \
|
||||
gfx \
|
||||
intl \
|
||||
js \
|
||||
locale \
|
||||
necko \
|
||||
pref \
|
||||
|
@ -68,6 +70,7 @@ REQUIRES = \
|
|||
widget \
|
||||
windowwatcher \
|
||||
winhooks \
|
||||
xulapp \
|
||||
xpcom \
|
||||
xpconnect \
|
||||
xpinstall \
|
||||
|
@ -87,47 +90,31 @@ FORCE_STATIC_LIB = 1
|
|||
EXPORTS = nsXULAppAPI.h
|
||||
|
||||
SHAREDCPPSRCS = \
|
||||
nsNativeAppSupportBase.cpp \
|
||||
nsWindowCreator.cpp \
|
||||
showOSAlert.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter gtk gtk2,$(MOZ_WIDGET_TOOLKIT)))
|
||||
SHAREDCPPSRCS += nsNativeAppSupportGtk.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
SHAREDCPPSRCS += nsNativeAppSupportOS2.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
|
||||
SHAREDCPPSRCS += nsNativeAppSupportBeOS.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),mac)
|
||||
SHAREDCPPSRCS += nsNativeAppSupportMac.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
SHAREDCMMSRCS += nsNativeAppSupportForCocoa.mm
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),photon)
|
||||
SHAREDCPPSRCS += nsNativeAppSupportPh.cpp
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
$(SHAREDCPPSRCS) \
|
||||
nsAppRunner.cpp \
|
||||
nsXREDirProvider.cpp \
|
||||
nsNativeAppSupportBase.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
CPPSRCS += nsNativeAppSupportWin.cpp
|
||||
DEFINES += -DWIN32_LEAN_AND_MEAN
|
||||
else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),mac)
|
||||
CPPSRCS += nsNativeAppSupportMac.cpp
|
||||
else
|
||||
CPPSRCS += nsNativeAppSupportDefault.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
CMMSRCS = $(SHAREDCMMSRCS)
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),mac)
|
||||
CMSRCS = MacLaunchHelper.m
|
||||
endif
|
||||
|
||||
ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
|
||||
STACKWALK_SRC_LCSRCS = \
|
||||
|
@ -148,9 +135,11 @@ ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
|
|||
GARBAGE += $(STACKWALK_SRC_LCSRCS)
|
||||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS += ../profile/src/$(LIB_PREFIX)profile_s.$(LIB_SUFFIX)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/xpfe/bootstrap -I.
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/xpfe/bootstrap -I$(srcdir)/../profile/src
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsAppRunner_h__
|
||||
#define nsAppRunner_h__
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#ifdef _MAX_PATH
|
||||
#define MAXPATHLEN _MAX_PATH
|
||||
#elif defined(CCHMAXPATH)
|
||||
#define MAXPATHLEN CCHMAXPATH
|
||||
#else
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
class nsACString;
|
||||
struct nsXREAppData;
|
||||
|
||||
class nsINativeAppSupport;
|
||||
class nsICmdLineService;
|
||||
class nsXREDirProvider;
|
||||
class nsIToolkitProfileService;
|
||||
class nsILocalFile;
|
||||
class nsIProfileLock;
|
||||
|
||||
extern nsXREDirProvider* gDirServiceProvider;
|
||||
extern const nsXREAppData* gAppData;
|
||||
|
||||
extern int gArgc;
|
||||
extern char **gArgv;
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
extern char gBinaryPath[MAXPATHLEN];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create the nativeappsupport implementation.
|
||||
*
|
||||
* @note XPCOMInit has not happened yet.
|
||||
*/
|
||||
nsresult NS_CreateNativeAppSupport(nsINativeAppSupport* *aResult);
|
||||
|
||||
// This function is implemented in nsAppRunner.cpp and called from there and
|
||||
// from nsNativeAppSupportWin.cpp.
|
||||
nsresult DoCommandLines(nsICmdLineService* cmdLine, PRBool heedGeneralStartupPrefs, PRBool *windowOpened);
|
||||
|
||||
NS_HIDDEN_(nsresult)
|
||||
NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult);
|
||||
|
||||
NS_HIDDEN_(nsresult)
|
||||
NS_GetFileFromPath(const char *aPath, nsILocalFile* *aResult);
|
||||
|
||||
NS_HIDDEN_(nsresult)
|
||||
NS_LockProfilePath(nsILocalFile* aPath, nsIProfileLock* *aResult);
|
||||
|
||||
#endif // nsAppRunner_h__
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bill Law law@netscape.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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsNativeAppSupportBase_h__
|
||||
#define nsNativeAppSupportBase_h__
|
||||
|
||||
#include "nsAppRunner.h"
|
||||
#include "nsINativeAppSupport.h"
|
||||
|
||||
// nsNativeAppSupportBase
|
||||
//
|
||||
// This is a default implementation of the nsINativeAppSupport interface
|
||||
// declared in mozilla/xpfe/appshell/public/nsINativeAppSupport.h.
|
||||
|
||||
class nsNativeAppSupportBase : public nsINativeAppSupport {
|
||||
public:
|
||||
nsNativeAppSupportBase();
|
||||
virtual ~nsNativeAppSupportBase();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSINATIVEAPPSUPPORT
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,4 +1,3 @@
|
|||
/* -*- 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
|
||||
*
|
||||
|
@ -12,14 +11,14 @@
|
|||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
* The Original Code is the Mozilla XUL toolkit.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
* 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
|
||||
|
@ -35,22 +34,16 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsNativeAppSupportBase.h"
|
||||
|
||||
[scriptable, uuid(5d9c7f6a-4af4-4a3d-be48-da1e70600b9c)]
|
||||
interface nsIProfileMigrator : nsISupports
|
||||
nsresult
|
||||
NS_CreateNativeAppSupport( nsINativeAppSupport **aResult )
|
||||
{
|
||||
/**
|
||||
* Copy user profile information to the current active profile.
|
||||
*/
|
||||
void migrate();
|
||||
};
|
||||
nsNativeAppSupportBase* native = new nsNativeAppSupportBase();
|
||||
if (!native) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
%{C++
|
||||
|
||||
#define NS_PROFILEMIGRATOR_CONTRACTID "@mozilla.org/profile/migrator;1"
|
||||
*aResult = native;
|
||||
NS_ADDREF( *aResult );
|
||||
|
||||
#define NS_PROFILEMIGRATOR_CID \
|
||||
{ 0xc0f8241e, 0x3340, 0x431e, { 0xbe, 0xba, 0x7b, 0x82, 0xf8, 0x7d, 0xd1, 0x41 } }
|
||||
|
||||
%}
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,315 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsNativeAppSupport.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include <Gestalt.h>
|
||||
#include <Dialogs.h>
|
||||
#include <Resources.h>
|
||||
#include <TextUtils.h>
|
||||
#include <ControlDefinitions.h>
|
||||
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsNativeAppSupportBase.h"
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
||||
static Boolean VersGreaterThan4(const FSSpec *fSpec);
|
||||
|
||||
const OSType kNSCreator = 'MOSS';
|
||||
const OSType kMozCreator = 'MOZZ';
|
||||
const SInt16 kNSCanRunStrArrayID = 1000;
|
||||
const SInt16 kAnotherVersionStrIndex = 1;
|
||||
|
||||
nsresult
|
||||
GetNativeWindowPointerFromDOMWindow(nsIDOMWindowInternal *window, WindowRef *nativeWindow);
|
||||
|
||||
const SInt16 kNSOSVersErrsStrArrayID = 1001;
|
||||
|
||||
enum {
|
||||
eOSXVersTooOldErrIndex = 1,
|
||||
eOSXVersTooOldExplanationIndex,
|
||||
eContinueButtonTextIndex,
|
||||
eQuitButtonTextIndex,
|
||||
eCarbonLibVersTooOldIndex,
|
||||
eCarbonLibVersTooOldExplanationIndex
|
||||
};
|
||||
|
||||
class nsNativeAppSupportMac : public nsNativeAppSupportBase
|
||||
{
|
||||
public:
|
||||
nsNativeAppSupportMac() :
|
||||
mCanShowUI(PR_FALSE) { }
|
||||
|
||||
NS_IMETHOD Start(PRBool* aRetVal);
|
||||
NS_IMETHOD ReOpen();
|
||||
NS_IMETHOD SetShouldShowUI(PRBool aValue);
|
||||
|
||||
private:
|
||||
PRBool mCanShowUI;
|
||||
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportMac::SetShouldShowUI(PRBool aValue)
|
||||
{
|
||||
NS_ASSERTION(aValue, "True is the only allowed value!");
|
||||
mCanShowUI = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean start (); */
|
||||
NS_IMETHODIMP nsNativeAppSupportMac::Start(PRBool *_retval)
|
||||
{
|
||||
Str255 str1;
|
||||
Str255 str2;
|
||||
SInt16 outItemHit;
|
||||
long response = 0;
|
||||
OSErr err = ::Gestalt (gestaltSystemVersion, &response);
|
||||
// check for at least MacOS 8.5
|
||||
if ( err || response < 0x850)
|
||||
{
|
||||
::StopAlert (5000, NULL);
|
||||
*_retval = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#if TARGET_CARBON
|
||||
// If we're running under Mac OS X check for at least Mac OS X 10.1
|
||||
// If that fails display a StandardAlert giving the user the option
|
||||
// to continue running the app or quitting
|
||||
if (response >= 0x00001000 && response < 0x00001010)
|
||||
{
|
||||
// put up error dialog
|
||||
Str255 continueButtonLabel;
|
||||
Str255 quitButtonLabel;
|
||||
::GetIndString(str1, kNSOSVersErrsStrArrayID, eOSXVersTooOldErrIndex);
|
||||
::GetIndString(str2, kNSOSVersErrsStrArrayID, eOSXVersTooOldExplanationIndex);
|
||||
::GetIndString(continueButtonLabel, kNSOSVersErrsStrArrayID, eContinueButtonTextIndex);
|
||||
::GetIndString(quitButtonLabel, kNSOSVersErrsStrArrayID, eQuitButtonTextIndex);
|
||||
if (StrLength(str1) && StrLength(str1) && StrLength(continueButtonLabel) && StrLength(quitButtonLabel))
|
||||
{
|
||||
AlertStdAlertParamRec pRec;
|
||||
|
||||
pRec.movable = nil;
|
||||
pRec.filterProc = nil;
|
||||
pRec.defaultText = continueButtonLabel;
|
||||
pRec.cancelText = quitButtonLabel;
|
||||
pRec.otherText = nil;
|
||||
pRec.helpButton = nil;
|
||||
pRec.defaultButton = kAlertStdAlertOKButton;
|
||||
pRec.cancelButton = kAlertStdAlertCancelButton;
|
||||
pRec.position = 0;
|
||||
|
||||
::StandardAlert(kAlertNoteAlert, str1, str2, &pRec, &outItemHit);
|
||||
if (outItemHit == kAlertStdAlertCancelButton)
|
||||
return PR_FALSE;
|
||||
}
|
||||
else
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// We also check for CarbonLib version >= 1.4 if OS vers < 10.0
|
||||
// which is always cause for the app to quit
|
||||
if (response < 0x00001000)
|
||||
{
|
||||
err = ::Gestalt (gestaltCarbonVersion, &response);
|
||||
if (err || response < 0x00000140)
|
||||
{
|
||||
// put up error dialog
|
||||
::GetIndString(str1, kNSOSVersErrsStrArrayID, eCarbonLibVersTooOldIndex);
|
||||
::GetIndString(str2, kNSOSVersErrsStrArrayID, eCarbonLibVersTooOldExplanationIndex);
|
||||
if (StrLength(str1) && StrLength(str1))
|
||||
{
|
||||
::StandardAlert(kAlertStopAlert, str1, str2, nil, &outItemHit);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportMac::ReOpen()
|
||||
{
|
||||
if (!mCanShowUI)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool haveUncollapsed = PR_FALSE;
|
||||
PRBool haveOpenWindows = PR_FALSE;
|
||||
PRBool done = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIWindowMediator>
|
||||
wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
|
||||
if (!wm)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> windowList;
|
||||
wm->GetXULWindowEnumerator(nsnull, getter_AddRefs(windowList));
|
||||
PRBool more;
|
||||
windowList->HasMoreElements(&more);
|
||||
while (more)
|
||||
{
|
||||
nsCOMPtr<nsISupports> nextWindow = nsnull;
|
||||
windowList->GetNext(getter_AddRefs(nextWindow));
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(nextWindow));
|
||||
if (!baseWindow)
|
||||
{
|
||||
windowList->HasMoreElements(&more);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
haveOpenWindows = PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWidget> widget = nsnull;
|
||||
baseWindow->GetMainWidget(getter_AddRefs(widget));
|
||||
if (!widget)
|
||||
{
|
||||
windowList->HasMoreElements(&more);
|
||||
continue;
|
||||
}
|
||||
WindowRef windowRef = (WindowRef)widget->GetNativeData(NS_NATIVE_DISPLAY);
|
||||
if (!::IsWindowCollapsed(windowRef))
|
||||
{
|
||||
haveUncollapsed = PR_TRUE;
|
||||
break; //have un-minimized windows, nothing to do
|
||||
}
|
||||
windowList->HasMoreElements(&more);
|
||||
} // end while
|
||||
|
||||
if (!haveUncollapsed)
|
||||
{
|
||||
//uncollapse the most recenty used window
|
||||
nsCOMPtr<nsIDOMWindowInternal> mru = nsnull;
|
||||
wm->GetMostRecentWindow(nsnull, getter_AddRefs(mru));
|
||||
|
||||
if (mru)
|
||||
{
|
||||
WindowRef mruRef = nil;
|
||||
GetNativeWindowPointerFromDOMWindow(mru, &mruRef);
|
||||
if (mruRef)
|
||||
{
|
||||
::CollapseWindow(mruRef, FALSE);
|
||||
::SelectWindow(mruRef);
|
||||
done = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
} // end if have uncollapsed
|
||||
|
||||
if (!haveOpenWindows && !done)
|
||||
{
|
||||
|
||||
NS_WARNING("trying to open new window");
|
||||
//use the bootstrap helpers to make the right kind(s) of window open
|
||||
nsresult rv = PR_FALSE;
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID, &rv));
|
||||
if (!rv)
|
||||
{
|
||||
PRBool openedAWindow = PR_FALSE;
|
||||
appShell->CreateStartupState(nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT,
|
||||
&openedAWindow);
|
||||
}
|
||||
}
|
||||
|
||||
} // got window mediator
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetNativeWindowPointerFromDOMWindow(nsIDOMWindowInternal *a_window, WindowRef *a_nativeWindow)
|
||||
{
|
||||
*a_nativeWindow = nil;
|
||||
if (!a_window) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> mruWebNav(do_GetInterface(a_window));
|
||||
if (mruWebNav)
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> mruTreeItem(do_QueryInterface(mruWebNav));
|
||||
nsCOMPtr<nsIDocShellTreeOwner> mruTreeOwner = nsnull;
|
||||
mruTreeItem->GetTreeOwner(getter_AddRefs(mruTreeOwner));
|
||||
if(mruTreeOwner)
|
||||
{
|
||||
nsCOMPtr<nsIBaseWindow> mruBaseWindow(do_QueryInterface(mruTreeOwner));
|
||||
if (mruBaseWindow)
|
||||
{
|
||||
nsCOMPtr<nsIWidget> mruWidget = nsnull;
|
||||
mruBaseWindow->GetMainWidget(getter_AddRefs(mruWidget));
|
||||
if (mruWidget)
|
||||
{
|
||||
*a_nativeWindow = (WindowRef)mruWidget->GetNativeData(NS_NATIVE_DISPLAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// Create and return an instance of class nsNativeAppSupportMac.
|
||||
nsresult NS_CreateNativeAppSupport(nsINativeAppSupport**aResult)
|
||||
{
|
||||
*aResult = new nsNativeAppSupportMac;
|
||||
if (!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF( *aResult );
|
||||
return NS_OK;
|
||||
}
|
|
@ -82,6 +82,8 @@
|
|||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define kMailtoUrlScheme "mailto:"
|
||||
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
#define MAPI_STARTUP_ARG "/MAPIStartUp"
|
||||
#endif
|
||||
|
@ -126,60 +128,6 @@ activateWindow( nsIDOMWindowInternal *win ) {
|
|||
#define MOZ_DEBUG_DDE 1
|
||||
#endif
|
||||
|
||||
class nsSplashScreenWin : public nsISplashScreen {
|
||||
public:
|
||||
nsSplashScreenWin();
|
||||
~nsSplashScreenWin();
|
||||
|
||||
NS_IMETHOD Show();
|
||||
NS_IMETHOD Hide();
|
||||
|
||||
// nsISupports methods
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() {
|
||||
mRefCnt++;
|
||||
return mRefCnt;
|
||||
}
|
||||
NS_IMETHOD_(nsrefcnt) Release() {
|
||||
--mRefCnt;
|
||||
if ( !mRefCnt ) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
NS_IMETHOD QueryInterface( const nsIID &iid, void**p ) {
|
||||
nsresult rv = NS_OK;
|
||||
if ( p ) {
|
||||
*p = 0;
|
||||
if ( iid.Equals( NS_GET_IID( nsISplashScreen ) ) ) {
|
||||
nsISplashScreen *result = this;
|
||||
*p = result;
|
||||
NS_ADDREF( result );
|
||||
} else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
|
||||
nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
|
||||
*p = result;
|
||||
NS_ADDREF( result );
|
||||
} else {
|
||||
rv = NS_NOINTERFACE;
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void SetDialog( HWND dlg );
|
||||
void LoadBitmap();
|
||||
static nsSplashScreenWin* GetPointer( HWND dlg );
|
||||
|
||||
static BOOL CALLBACK DialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp );
|
||||
static DWORD WINAPI ThreadProc( LPVOID );
|
||||
|
||||
HWND mDlg;
|
||||
HBITMAP mBitmap;
|
||||
nsrefcnt mRefCnt;
|
||||
}; // class nsSplashScreenWin
|
||||
|
||||
// Simple Win32 mutex wrapper.
|
||||
struct Mutex {
|
||||
Mutex( const char *name )
|
||||
|
@ -320,7 +268,7 @@ public:
|
|||
NS_IMETHOD Start( PRBool *aResult );
|
||||
NS_IMETHOD Stop( PRBool *aResult );
|
||||
NS_IMETHOD Quit();
|
||||
NS_IMETHOD EnsureProfile(nsICmdLineService* args);
|
||||
NS_IMETHOD SetShouldShowUI(PRBool aValue);
|
||||
|
||||
// The "old" Start method (renamed).
|
||||
NS_IMETHOD StartDDE();
|
||||
|
@ -371,175 +319,12 @@ private:
|
|||
static HSZ mApplication, mTopics[ topicCount ];
|
||||
static DWORD mInstance;
|
||||
static char *mAppName;
|
||||
static PRBool mInitialWindowActive;
|
||||
static PRBool mForceProfileStartup;
|
||||
static PRBool mCanHandleRequests;
|
||||
static PRBool mSupportingDDEExec;
|
||||
static char mMutexName[];
|
||||
friend struct MessageWindow;
|
||||
}; // nsNativeAppSupportWin
|
||||
|
||||
nsSplashScreenWin::nsSplashScreenWin()
|
||||
: mDlg( 0 ), mBitmap( 0 ), mRefCnt( 0 ) {
|
||||
}
|
||||
|
||||
nsSplashScreenWin::~nsSplashScreenWin() {
|
||||
#if MOZ_DEBUG_DDE
|
||||
printf( "splash screen dtor called\n" );
|
||||
#endif
|
||||
// Make sure dialog is gone.
|
||||
Hide();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSplashScreenWin::Show() {
|
||||
// Spawn new thread to display real splash screen.
|
||||
DWORD threadID = 0;
|
||||
HANDLE handle = CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID );
|
||||
CloseHandle(handle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSplashScreenWin::Hide() {
|
||||
if ( mDlg ) {
|
||||
// Fix for bugs:
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=26581
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=65974
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=29172
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=45805
|
||||
// As the splash-screen is in a separate thread, Windows considers
|
||||
// this the "foreground" thread. When our main windows on the main
|
||||
// thread are activated, they are treated like windows from a different
|
||||
// application, so Windows 2000 and 98 both leave the window in the background.
|
||||
// Therefore, we post a message to the splash-screen thread that includes
|
||||
// the hwnd of the window we want moved to the foreground. This thread
|
||||
// can then successfully bring the top-level window to the foreground.
|
||||
nsCOMPtr<nsIDOMWindowInternal> topLevel;
|
||||
GetMostRecentWindow(nsnull, getter_AddRefs( topLevel ) );
|
||||
HWND hWndTopLevel = topLevel ? hwndForDOMWindow(topLevel) : 0;
|
||||
// Dismiss the dialog.
|
||||
::PostMessage(mDlg, WM_CLOSE, (WPARAM)mBitmap, (LPARAM)hWndTopLevel);
|
||||
mBitmap = 0;
|
||||
mDlg = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsSplashScreenWin::LoadBitmap() {
|
||||
// Check for '<program-name>.bmp" in same directory as executable.
|
||||
char fileName[ _MAX_PATH ];
|
||||
int fileNameLen = ::GetModuleFileName( NULL, fileName, sizeof fileName );
|
||||
if ( fileNameLen >= 3 ) {
|
||||
fileName[ fileNameLen - 3 ] = 0;
|
||||
strcat( fileName, "bmp" );
|
||||
// Try to load bitmap from that file.
|
||||
HBITMAP bitmap = (HBITMAP)::LoadImage( NULL,
|
||||
fileName,
|
||||
IMAGE_BITMAP,
|
||||
0,
|
||||
0,
|
||||
LR_LOADFROMFILE );
|
||||
if ( bitmap ) {
|
||||
HWND bitmapControl = GetDlgItem( mDlg, IDB_SPLASH );
|
||||
if ( bitmapControl ) {
|
||||
HBITMAP old = (HBITMAP)SendMessage( bitmapControl,
|
||||
STM_SETIMAGE,
|
||||
IMAGE_BITMAP,
|
||||
(LPARAM)bitmap );
|
||||
// Remember bitmap so we can delete it later.
|
||||
mBitmap = bitmap;
|
||||
// Delete old bitmap.
|
||||
if ( old ) {
|
||||
BOOL ok = DeleteObject( old );
|
||||
}
|
||||
} else {
|
||||
// Delete bitmap since it isn't going to be used.
|
||||
DeleteObject( bitmap );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CALLBACK
|
||||
nsSplashScreenWin::DialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ) {
|
||||
if ( msg == WM_INITDIALOG ) {
|
||||
// Store dialog handle.
|
||||
nsSplashScreenWin *splashScreen = (nsSplashScreenWin*)lp;
|
||||
if ( lp ) {
|
||||
splashScreen->SetDialog( dlg );
|
||||
|
||||
// Try to load customized bitmap.
|
||||
splashScreen->LoadBitmap();
|
||||
}
|
||||
|
||||
/* Size and center the splash screen correctly. The flags in the
|
||||
* dialog template do not do the right thing if the user's
|
||||
* machine is using large fonts.
|
||||
*/
|
||||
HWND bitmapControl = GetDlgItem( dlg, IDB_SPLASH );
|
||||
if ( bitmapControl ) {
|
||||
HBITMAP hbitmap = (HBITMAP)SendMessage( bitmapControl,
|
||||
STM_GETIMAGE,
|
||||
IMAGE_BITMAP,
|
||||
0 );
|
||||
if ( hbitmap ) {
|
||||
BITMAP bitmap;
|
||||
if ( GetObject( hbitmap, sizeof bitmap, &bitmap ) ) {
|
||||
SetWindowPos( dlg,
|
||||
NULL,
|
||||
GetSystemMetrics(SM_CXSCREEN)/2 - bitmap.bmWidth/2,
|
||||
GetSystemMetrics(SM_CYSCREEN)/2 - bitmap.bmHeight/2,
|
||||
bitmap.bmWidth,
|
||||
bitmap.bmHeight,
|
||||
SWP_NOZORDER );
|
||||
ShowWindow( dlg, SW_SHOW );
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} else if (msg == WM_CLOSE) {
|
||||
// Before killing ourself, set the top-level current.
|
||||
// See comments in nsSplashScreenWin::Hide() above.
|
||||
HWND topLevel = (HWND)lp;
|
||||
if (topLevel)
|
||||
::SetForegroundWindow(topLevel);
|
||||
// Destroy the dialog
|
||||
::EndDialog(dlg, 0);
|
||||
// Release custom bitmap (if there is one).
|
||||
HBITMAP bitmap = (HBITMAP)wp;
|
||||
if ( bitmap ) {
|
||||
::DeleteObject( bitmap );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nsSplashScreenWin::SetDialog( HWND dlg ) {
|
||||
// Save dialog handle.
|
||||
mDlg = dlg;
|
||||
// Store this pointer in the dialog.
|
||||
SetWindowLong( mDlg, DWL_USER, (LONG)(void*)this );
|
||||
}
|
||||
|
||||
nsSplashScreenWin *nsSplashScreenWin::GetPointer( HWND dlg ) {
|
||||
// Get result from dialog user data.
|
||||
LONG data = GetWindowLong( dlg, DWL_USER );
|
||||
return (nsSplashScreenWin*)(void*)data;
|
||||
}
|
||||
|
||||
DWORD WINAPI nsSplashScreenWin::ThreadProc( LPVOID splashScreen ) {
|
||||
DialogBoxParam( GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_SPLASH ),
|
||||
HWND_DESKTOP,
|
||||
(DLGPROC)DialogProc,
|
||||
(LPARAM)splashScreen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRBool gAbortServer = PR_FALSE;
|
||||
|
||||
void
|
||||
nsNativeAppSupportWin::CheckConsole() {
|
||||
for ( int i = 1; i < __argc; i++ ) {
|
||||
|
@ -602,45 +387,14 @@ nsNativeAppSupportWin::CheckConsole() {
|
|||
// Create and return an instance of class nsNativeAppSupportWin.
|
||||
nsresult
|
||||
NS_CreateNativeAppSupport( nsINativeAppSupport **aResult ) {
|
||||
if ( aResult ) {
|
||||
nsNativeAppSupportWin *pNative = new nsNativeAppSupportWin;
|
||||
if ( pNative ) {
|
||||
*aResult = pNative;
|
||||
NS_ADDREF( *aResult );
|
||||
// Check for dynamic console creation request.
|
||||
pNative->CheckConsole();
|
||||
} else {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsNativeAppSupportWin *pNative = new nsNativeAppSupportWin;
|
||||
if (!pNative) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
// Check for dynamic console creation request.
|
||||
pNative->CheckConsole();
|
||||
|
||||
// Create instance of Windows splash screen object.
|
||||
nsresult
|
||||
NS_CreateSplashScreen( nsISplashScreen **aResult ) {
|
||||
if ( aResult ) {
|
||||
*aResult = 0;
|
||||
for ( int i = 1; i < __argc; i++ ) {
|
||||
if ( strcmp( "-quiet", __argv[i] ) == 0
|
||||
||
|
||||
strcmp( "/quiet", __argv[i] ) == 0 ) {
|
||||
// No splash screen, please.
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
*aResult = new nsSplashScreenWin;
|
||||
if ( *aResult ) {
|
||||
NS_ADDREF( *aResult );
|
||||
} else {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = pNative;
|
||||
NS_ADDREF( *aResult );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -666,8 +420,7 @@ int nsNativeAppSupportWin::mConversations = 0;
|
|||
HSZ nsNativeAppSupportWin::mApplication = 0;
|
||||
HSZ nsNativeAppSupportWin::mTopics[nsNativeAppSupportWin::topicCount] = { 0 };
|
||||
DWORD nsNativeAppSupportWin::mInstance = 0;
|
||||
PRBool nsNativeAppSupportWin::mInitialWindowActive = PR_FALSE;
|
||||
PRBool nsNativeAppSupportWin::mForceProfileStartup = PR_FALSE;
|
||||
PRBool nsNativeAppSupportWin::mCanHandleRequests = PR_FALSE;
|
||||
PRBool nsNativeAppSupportWin::mSupportingDDEExec = PR_FALSE;
|
||||
|
||||
char nsNativeAppSupportWin::mMutexName[ 128 ] = { 0 };
|
||||
|
@ -767,6 +520,9 @@ struct MessageWindow {
|
|||
// Window proc.
|
||||
static long CALLBACK WindowProc( HWND msgWindow, UINT msg, WPARAM wp, LPARAM lp ) {
|
||||
if ( msg == WM_COPYDATA ) {
|
||||
if (!nsNativeAppSupportWin::mCanHandleRequests)
|
||||
return 0;
|
||||
|
||||
// This is an incoming request.
|
||||
COPYDATASTRUCT *cds = (COPYDATASTRUCT*)lp;
|
||||
#if MOZ_DEBUG_DDE
|
||||
|
@ -779,6 +535,8 @@ struct MessageWindow {
|
|||
GetMostRecentWindow( 0, getter_AddRefs( win ) );
|
||||
return win ? (long)hwndForDOMWindow( win ) : 0;
|
||||
} else if ( msg == WM_QUERYENDSESSION ) {
|
||||
if (!nsNativeAppSupportWin::mCanHandleRequests)
|
||||
return 0;
|
||||
// Invoke "-killAll" cmd line handler. That will close all open windows,
|
||||
// and display dialog asking whether to save/don't save/cancel. If the
|
||||
// user says cancel, then we pass that indicator along to the system
|
||||
|
@ -861,14 +619,12 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) {
|
|||
rv = msgWindow.SendRequest( cmd );
|
||||
} else {
|
||||
// We will be server.
|
||||
if (!gAbortServer) {
|
||||
rv = msgWindow.Create();
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
// Start up DDE server.
|
||||
this->StartDDE();
|
||||
// Tell caller to spin message loop.
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
rv = msgWindow.Create();
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
// Start up DDE server.
|
||||
this->StartDDE();
|
||||
// Tell caller to spin message loop.
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1066,9 +822,12 @@ nsNativeAppSupportWin::Quit() {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool NS_CanRun()
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportWin::SetShouldShowUI(PRBool aValue)
|
||||
{
|
||||
return PR_TRUE;
|
||||
NS_ASSERTION(aValue, "True is the only allowed value!");
|
||||
mCanHandleRequests = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if MOZ_DEBUG_DDE
|
||||
|
@ -1153,6 +912,10 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
|
|||
ULONG dwData1, // transaction-specific data
|
||||
ULONG dwData2 ) { // transaction-specific data
|
||||
|
||||
if (!mCanHandleRequests)
|
||||
return 0;
|
||||
|
||||
|
||||
#if MOZ_DEBUG_DDE
|
||||
printf( "DDE: uType =%s\n", uTypeDesc( uType ).get() );
|
||||
printf( " uFmt =%u\n", (unsigned)uFmt );
|
||||
|
@ -1503,13 +1266,6 @@ HDDEDATA nsNativeAppSupportWin::CreateDDEData( LPBYTE value, DWORD len ) {
|
|||
void
|
||||
nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
|
||||
|
||||
// if initial hidden window is still being displayed, we need to ignore requests
|
||||
// because such requests might not function properly. See bug 147223 for details
|
||||
|
||||
if (mInitialWindowActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse command line.
|
||||
|
||||
nsCOMPtr<nsICmdLineService> args;
|
||||
|
@ -1518,13 +1274,6 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
|
|||
rv = GetCmdLineArgs( request, getter_AddRefs( args ) );
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService("@mozilla.org/appshell/appShellService;1", &rv));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
rv = appShell->GetNativeAppSupport(getter_AddRefs( nativeApp ));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
// first see if there is a url
|
||||
nsXPIDLCString arg;
|
||||
rv = args->GetURLToLoad(getter_Copies(arg));
|
||||
|
@ -1533,8 +1282,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
|
|||
#if MOZ_DEBUG_DDE
|
||||
printf( "Launching browser on url [%s]...\n", (const char*)arg );
|
||||
#endif
|
||||
if (NS_SUCCEEDED(nativeApp->EnsureProfile(args)))
|
||||
(void)OpenBrowserWindow( arg, newWindow );
|
||||
(void)OpenBrowserWindow( arg, newWindow );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1546,39 +1294,21 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
|
|||
#if MOZ_DEBUG_DDE
|
||||
printf( "Launching chrome url [%s]...\n", (const char*)arg );
|
||||
#endif
|
||||
if (NS_SUCCEEDED(nativeApp->EnsureProfile(args)))
|
||||
(void)OpenWindow( arg, "" );
|
||||
(void)OpenWindow( arg, "" );
|
||||
return;
|
||||
}
|
||||
|
||||
// try for the "-profilemanager" argument, in which case we want the
|
||||
// profile manager to appear, but only if there are no windows open
|
||||
|
||||
rv = args->GetCmdLineValue( "-profilemanager", getter_Copies(arg));
|
||||
if ( NS_SUCCEEDED(rv) && (const char*)arg ) { // -profilemanager on command line
|
||||
nsCOMPtr<nsIDOMWindowInternal> window;
|
||||
GetMostRecentWindow(0, getter_AddRefs(window));
|
||||
if (!window) { // there are no open windows
|
||||
mForceProfileStartup = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
// check wheather it is a MAPI request. If yes, don't open any new
|
||||
// windows and just return.
|
||||
rv = args->GetCmdLineValue(MAPI_STARTUP_ARG, getter_Copies(arg));
|
||||
if (NS_SUCCEEDED(rv) && (const char*)arg) {
|
||||
nativeApp->EnsureProfile(args);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Try standard startup's command-line handling logic from nsAppRunner.cpp...
|
||||
|
||||
// Need profile before opening windows.
|
||||
rv = nativeApp->EnsureProfile(args);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
// This will tell us whether the command line processing opened a window.
|
||||
PRBool windowOpened = PR_FALSE;
|
||||
|
||||
|
@ -1653,6 +1383,8 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
|
|||
int argc;
|
||||
char *p;
|
||||
nsCAutoString arg;
|
||||
nsDependentCString mailtoUrlScheme (kMailtoUrlScheme);
|
||||
|
||||
// We loop if we've not finished the second pass through.
|
||||
while ( 1 ) {
|
||||
// Initialize if required.
|
||||
|
@ -1690,7 +1422,9 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
|
|||
} else {
|
||||
// We are processing the contents of an argument.
|
||||
// Check for whitespace or end.
|
||||
if ( *p == 0 || ( !quoted && isspace( *p ) ) ) {
|
||||
// if the argument we are parsing is a mailto url then all of the remaining command line data
|
||||
// needs to be part of the mailto url even if it has spaces. See Bug #231032
|
||||
if ( *p == 0 || ( !quoted && isspace( *p ) && !StringBeginsWith(arg, mailtoUrlScheme, nsCaseInsensitiveCStringComparator()) ) ) {
|
||||
// Process pending backslashes (interpret them
|
||||
// literally since they're not followed by a ").
|
||||
while( bSlashCount ) {
|
||||
|
@ -1798,88 +1532,6 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Check to see if we have a profile. We will not have a profile
|
||||
// at this point if we were launched invisibly in -turbo mode, and
|
||||
// the profile mgr needed to show UI (to pick from multiple profiles).
|
||||
// At this point, we can show UI, so call DoProfileStartUp().
|
||||
nsresult
|
||||
nsNativeAppSupportWin::EnsureProfile(nsICmdLineService* args)
|
||||
{
|
||||
static PRBool firstTime = PR_TRUE;
|
||||
if ( firstTime ) {
|
||||
firstTime = PR_FALSE;
|
||||
// Check pref for whether to set ddeexec subkey entries.
|
||||
nsCOMPtr<nsIPref> prefService( do_GetService( NS_PREF_CONTRACTID ) );
|
||||
PRBool supportDDEExec = PR_FALSE;
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref( "advanced.system.supportDDEExec", &supportDDEExec );
|
||||
}
|
||||
if ( supportDDEExec && isDefaultBrowser() ) {
|
||||
#if MOZ_DEBUG_DDE
|
||||
printf( "Setting ddexec subkey entries\n" );
|
||||
#endif
|
||||
// Set ddeexec default value.
|
||||
const char ddeexec[] = "\"%1\",,-1,0,,,,";
|
||||
::RegSetValue( HKEY_CLASSES_ROOT,
|
||||
"http\\shell\\open\\ddeexec",
|
||||
REG_SZ,
|
||||
ddeexec,
|
||||
sizeof ddeexec );
|
||||
|
||||
// Set application/topic (while we're running), reset at exit.
|
||||
::RegSetValue( HKEY_CLASSES_ROOT,
|
||||
"http\\shell\\open\\ddeexec\\application",
|
||||
REG_SZ,
|
||||
mAppName,
|
||||
::strlen( mAppName ) );
|
||||
|
||||
const char topic[] = "WWW_OpenURL";
|
||||
::RegSetValue( HKEY_CLASSES_ROOT,
|
||||
"http\\shell\\open\\ddeexec\\topic",
|
||||
REG_SZ,
|
||||
topic,
|
||||
sizeof topic );
|
||||
|
||||
// Remember we need to undo this.
|
||||
mSupportingDDEExec = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIProfileInternal> profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService("@mozilla.org/appshell/appShellService;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// If we have a profile, everything is fine -
|
||||
// unless mForceProfileStartup is TRUE. This flag is set when the
|
||||
// last window is closed in -turbo mode. When TRUE, it forces the
|
||||
// profile UI to come up at the beginning of the next -turbo session
|
||||
// even if we currently have a profile.
|
||||
PRBool haveProfile;
|
||||
rv = profileMgr->IsCurrentProfileAvailable(&haveProfile);
|
||||
if (!mForceProfileStartup && NS_SUCCEEDED(rv) && haveProfile)
|
||||
return NS_OK;
|
||||
|
||||
// If the profile selection is happening, fail.
|
||||
PRBool doingProfileStartup;
|
||||
rv = profileMgr->GetIsStartingUp(&doingProfileStartup);
|
||||
if (NS_FAILED(rv) || doingProfileStartup) return NS_ERROR_FAILURE;
|
||||
|
||||
// See if profile manager is being suppressed via -silent flag.
|
||||
PRBool canInteract = PR_TRUE;
|
||||
nsXPIDLCString arg;
|
||||
if (NS_SUCCEEDED(args->GetCmdLineValue("-silent", getter_Copies(arg))) && (const char*)arg) {
|
||||
canInteract = PR_FALSE;
|
||||
}
|
||||
rv = appShell->DoProfileStartup(args, canInteract);
|
||||
|
||||
mForceProfileStartup = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNativeAppSupportWin::OpenWindow( const char*urlstr, const char *args ) {
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
* Ben Goodger <ben@mozilla.org>
|
||||
*
|
||||
* 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
|
||||
|
@ -36,139 +38,622 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAppRunner.h"
|
||||
#include "nsXREDirProvider.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfileChangeStatus.h"
|
||||
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsXREDirProvider.h"
|
||||
#ifdef XP_UNIX
|
||||
#include "prenv.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
#include "nsINIParser.h"
|
||||
#include "nsDependentString.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsArrayEnumerator.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
#ifdef XP_MACOSX
|
||||
#include "nsILocalFileMac.h"
|
||||
#endif
|
||||
#ifdef XP_BEOS
|
||||
#include <StorageDefs.h>
|
||||
#include <be/kernel/image.h>
|
||||
#include <FindDirectory.h>
|
||||
#endif
|
||||
|
||||
// WARNING: These hard coded names need to go away. They need to
|
||||
// come from localizable resources
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("Application Registry")
|
||||
#elif defined(XP_WIN) || defined(XP_OS2)
|
||||
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("registry.dat")
|
||||
#else
|
||||
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("appreg")
|
||||
#ifdef XP_UNIX
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#ifdef XP_OS2
|
||||
#define INCL_DOS
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
nsXREDirProvider::nsXREDirProvider(const nsACString& aProductName)
|
||||
nsXREDirProvider* gDirServiceProvider = nsnull;
|
||||
|
||||
nsXREDirProvider::nsXREDirProvider() :
|
||||
mProfileNotified(PR_FALSE),
|
||||
mRegisterExtraComponents(PR_TRUE)
|
||||
{
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
mProductDir.Assign(NS_LITERAL_CSTRING(".") + aProductName);
|
||||
ToLowerCase(mProductDir);
|
||||
#else
|
||||
mProductDir.Assign(aProductName);
|
||||
#endif
|
||||
gDirServiceProvider = this;
|
||||
}
|
||||
|
||||
nsXREDirProvider::~nsXREDirProvider()
|
||||
{
|
||||
gDirServiceProvider = nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsXREDirProvider, nsIDirectoryServiceProvider)
|
||||
nsresult
|
||||
nsXREDirProvider::Initialize()
|
||||
{
|
||||
// We need to use platform-specific hackery to find the
|
||||
// path of this executable. This is copied, with some modifications, from
|
||||
// nsGREDirServiceProvider.cpp
|
||||
#ifdef XP_WIN
|
||||
char exePath[MAXPATHLEN];
|
||||
if ( ! ::GetModuleFileName(0, exePath, MAXPATHLEN) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// chop off the executable name by finding the rightmost backslash
|
||||
char* lastSlash = strrchr(exePath, '\\');
|
||||
if (!lastSlash) return NS_ERROR_FAILURE;
|
||||
|
||||
*(lastSlash) = '\0';
|
||||
return NS_NewNativeLocalFile(nsDependentCString(exePath), PR_TRUE,
|
||||
getter_AddRefs(mAppDir));
|
||||
|
||||
#elif defined(XP_MACOSX)
|
||||
// Works even if we're not bundled.
|
||||
CFBundleRef appBundle = CFBundleGetMainBundle();
|
||||
if (!appBundle) return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
CFURLRef bundleURL = CFBundleCopyExecutableURL(appBundle);
|
||||
if (bundleURL) {
|
||||
CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, bundleURL);
|
||||
if (parentURL) {
|
||||
rv = NS_NewNativeLocalFile(EmptyCString(), PR_TRUE,
|
||||
getter_AddRefs(mAppDir));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILocalFileMac> appDirMac (do_QueryInterface(mAppDir, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = appDirMac->InitWithCFURL(parentURL);
|
||||
}
|
||||
}
|
||||
|
||||
CFRelease(parentURL);
|
||||
}
|
||||
CFRelease(bundleURL);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
// Because we do have access to argv[0], we can get the application
|
||||
// path with certitude, instead of using MOZILLA_FIVE_HOME or
|
||||
// guessing from the CWD like nsGREDirServiceProvider does.
|
||||
char* lastSlash = strrchr(gBinaryPath, '/');
|
||||
if (!lastSlash) return NS_ERROR_FAILURE;
|
||||
|
||||
nsDependentCSubstring appDir(gBinaryPath, lastSlash);
|
||||
return NS_NewNativeLocalFile(appDir, PR_TRUE, getter_AddRefs(mAppDir));
|
||||
|
||||
#elif defined(XP_OS2)
|
||||
PPIB ppib;
|
||||
PTIB ptib;
|
||||
char appDir[MAXPATHLEN];
|
||||
char* p;
|
||||
DosGetInfoBlocks( &ptib, &ppib);
|
||||
DosQueryModuleName( ppib->pib_hmte, MAXPATHLEN, appDir);
|
||||
p = strrchr( appDir, '\\'); // XXX DBCS misery
|
||||
if (!p) return NS_ERROR_FAILURE;
|
||||
|
||||
*p = '\0';
|
||||
return NS_NewNativeLocalFile(nsDependentCString(appDir), PR_TRUE, getter_AddRefs(mAppDir));
|
||||
|
||||
#elif defined(XP_BEOS)
|
||||
int32 cookie = 0;
|
||||
image_info info;
|
||||
char *p;
|
||||
|
||||
if(get_next_image_info(0, &cookie, &info) != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
p = strrchr(info.name, '/');
|
||||
if (!p) return NS_ERROR_FAILURE;
|
||||
|
||||
*p = 0;
|
||||
return NS_NewNativeLocalFile(nsDependentCString(info.name), PR_TRUE, getter_AddRefs(mAppDir));
|
||||
#elif
|
||||
#error Oops, you need platform-specific code here
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXREDirProvider::SetProfileDir(nsIFile* aDir)
|
||||
{
|
||||
NS_ASSERTION(aDir, "We don't support no-profile apps yet!");
|
||||
|
||||
#ifdef DEBUG_bsmedberg
|
||||
nsCAutoString path;
|
||||
aDir->GetNativePath(path);
|
||||
printf("nsXREDirProvider::SetProfileDir('%s')\n", path.get());
|
||||
#endif
|
||||
|
||||
mProfileDir = aDir;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE3(nsXREDirProvider,
|
||||
nsIDirectoryServiceProvider,
|
||||
nsIDirectoryServiceProvider2,
|
||||
nsIProfileStartup)
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsXREDirProvider::AddRef()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsXREDirProvider::Release()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
|
||||
nsIFile** aFile)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
*aPersistent = PR_TRUE;
|
||||
nsCOMPtr<nsIFile> file;
|
||||
|
||||
if (!strcmp(aProperty, NS_APP_APPLICATION_REGISTRY_DIR))
|
||||
rv = GetProductDirectory(getter_AddRefs(localFile));
|
||||
else if (!strcmp(aProperty, NS_APP_APPLICATION_REGISTRY_FILE)) {
|
||||
rv = GetProductDirectory(getter_AddRefs(localFile));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = localFile->AppendNative(APP_REGISTRY_NAME);
|
||||
if (!strcmp(aProperty, NS_OS_CURRENT_PROCESS_DIR) ||
|
||||
!strcmp(aProperty, NS_APP_INSTALL_CLEANUP_DIR)) {
|
||||
// NOTE: this is *different* than NS_XPCOM_CURRENT_PROCESS_DIR. This points
|
||||
// to the application dir. NS_XPCOM_CURRENT_PROCESS_DIR points to the toolkit.
|
||||
return mAppDir->Clone(aFile);
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PROFILE_DEFAULTS_50_DIR) ||
|
||||
!strcmp(aProperty, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR)) {
|
||||
return GetProfileDefaultsDir(aFile);
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PREF_DEFAULTS_50_DIR))
|
||||
{
|
||||
rv = mAppDir->Clone(getter_AddRefs(file));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = file->AppendNative(nsDependentCString("defaults"));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = file->AppendNative(nsDependentCString("pref"));
|
||||
}
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_USER_PROFILES_ROOT_DIR)) {
|
||||
rv = GetProductDirectory(getter_AddRefs(localFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = GetUserAppDataDirectory((nsILocalFile**)(nsIFile**) getter_AddRefs(file));
|
||||
|
||||
#if !defined(XP_UNIX) || defined(XP_MACOSX)
|
||||
rv = localFile->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv |= file->AppendNative(nsDependentCString("Profiles"));
|
||||
#endif
|
||||
|
||||
// We must create the profile directory here if it does not exist.
|
||||
rv = EnsureDirectoryExists(localFile);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv |= EnsureDirectoryExists(file);
|
||||
}
|
||||
else if (mProfileDir) {
|
||||
if (!strcmp(aProperty, NS_XPCOM_COMPONENT_REGISTRY_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("compreg.dat"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_XPCOM_XPTI_REGISTRY_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("xpti.dat"));
|
||||
}
|
||||
if (mProfileNotified) {
|
||||
if (!strcmp(aProperty, NS_APP_USER_PROFILE_50_DIR) ||
|
||||
!strcmp(aProperty, NS_APP_PREFS_50_DIR)) {
|
||||
return mProfileDir->Clone(aFile);
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PREFS_50_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("prefs.js"));
|
||||
}
|
||||
// XXXbsmedberg this needs rethinking... many of these are app-specific,
|
||||
// and apps are going to add new stuff. I don't have a good solution,
|
||||
// yet.
|
||||
else if (!strcmp(aProperty, NS_APP_USER_CHROME_DIR)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("chrome"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_LOCALSTORE_50_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("localstore.rdf"));
|
||||
EnsureProfileFileExists(file);
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_HISTORY_50_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("history.dat"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_USER_PANELS_50_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("panels.rdf"));
|
||||
EnsureProfileFileExists(file);
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_USER_MIMETYPES_50_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("mimeTypes.rdf"));
|
||||
EnsureProfileFileExists(file);
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_BOOKMARKS_50_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("bookmarks.html"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_DOWNLOADS_50_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("downloads.rdf"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_SEARCH_50_FILE)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("search.rdf"));
|
||||
EnsureProfileFileExists(file);
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_MAIL_50_DIR)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("Mail"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_IMAP_MAIL_50_DIR)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("ImapMail"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_NEWS_50_DIR)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("News"));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_MESSENGER_FOLDER_CACHE_50_DIR)) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
rv |= file->AppendNative(nsDependentCString("panacea.dat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
if (!file) return NS_ERROR_FAILURE;
|
||||
|
||||
if (localFile)
|
||||
return CallQueryInterface(localFile, aFile);
|
||||
NS_ADDREF(*aFile = file);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXREDirProvider::RegisterExtraComponents()
|
||||
{
|
||||
mRegisterExtraComponents = PR_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
LoadDirsIntoArray(nsIFile* aComponentsList, nsCOMArray<nsIFile>& aDirectories)
|
||||
{
|
||||
nsINIParser parser;
|
||||
nsCOMPtr<nsILocalFile> lf(do_QueryInterface(aComponentsList));
|
||||
parser.Init(lf);
|
||||
|
||||
char parserBuf[MAXPATHLEN];
|
||||
nsresult rv = parser.GetString("Extra Files", "Count", parserBuf, MAXPATHLEN);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 count = atoi(parserBuf);
|
||||
char buf[10];
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
aComponentsList->GetParent(getter_AddRefs(parent));
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
sprintf(buf, "File%d", i);
|
||||
|
||||
rv = parser.GetString("Extra Files", buf, parserBuf, MAXPATHLEN);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILocalFile> lfParent(do_QueryInterface(parent));
|
||||
nsCOMPtr<nsILocalFile> dir(do_CreateInstance("@mozilla.org/file/local;1"));
|
||||
dir->SetRelativeDescriptor(lfParent, nsDependentCString(parserBuf));
|
||||
nsCOMPtr<nsIFile> dirAsFile(do_QueryInterface(dir));
|
||||
aDirectories.AppendObject(dirAsFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
*aResult = nsnull;
|
||||
|
||||
if (!strcmp(aProperty, NS_XPCOM_COMPONENT_DIR_LIST)) {
|
||||
if (mRegisterExtraComponents) {
|
||||
nsCOMArray<nsIFile> directories;
|
||||
|
||||
nsCOMPtr<nsIFile> appFile;
|
||||
mAppDir->Clone(getter_AddRefs(appFile));
|
||||
appFile->AppendNative(nsDependentCString("components.ini"));
|
||||
LoadDirsIntoArray(appFile, directories);
|
||||
|
||||
nsCOMPtr<nsIFile> profileFile;
|
||||
if (mProfileDir) {
|
||||
mProfileDir->Clone(getter_AddRefs(profileFile));
|
||||
profileFile->AppendNative(nsDependentCString("components.ini"));
|
||||
LoadDirsIntoArray(profileFile, directories);
|
||||
}
|
||||
|
||||
rv = NS_NewArrayEnumerator(aResult, directories);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PREFS_DEFAULTS_DIR_LIST)) {
|
||||
nsCOMArray<nsIFile> directories;
|
||||
|
||||
nsCOMPtr<nsIFile> appFile;
|
||||
mAppDir->Clone(getter_AddRefs(appFile));
|
||||
appFile->AppendNative(nsDependentCString("defaults.ini"));
|
||||
LoadDirsIntoArray(appFile, directories);
|
||||
|
||||
nsCOMPtr<nsIFile> profileFile;
|
||||
if (mProfileDir) {
|
||||
mProfileDir->Clone(getter_AddRefs(profileFile));
|
||||
profileFile->AppendNative(nsDependentCString("defaults.ini"));
|
||||
LoadDirsIntoArray(profileFile, directories);
|
||||
}
|
||||
|
||||
rv = NS_NewArrayEnumerator(aResult, directories);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXREDirProvider::GetDirectory(nsIFile* *aResult)
|
||||
{
|
||||
NS_ENSURE_TRUE(mProfileDir, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
return mProfileDir->Clone(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXREDirProvider::DoStartup()
|
||||
{
|
||||
if (!mProfileNotified) {
|
||||
nsCOMPtr<nsIObserverService> obsSvc
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
if (!obsSvc) return NS_ERROR_FAILURE;
|
||||
|
||||
mProfileNotified = PR_TRUE;
|
||||
|
||||
static const PRUnichar kStartup[] = {'s','t','a','r','t','u','p','\0'};
|
||||
obsSvc->NotifyObservers(nsnull, "profile-do-change", kStartup);
|
||||
obsSvc->NotifyObservers(nsnull, "profile-after-change", kStartup);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class ProfileChangeStatusImpl : public nsIProfileChangeStatus
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROFILECHANGESTATUS
|
||||
ProfileChangeStatusImpl() { }
|
||||
private:
|
||||
~ProfileChangeStatusImpl() { }
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(ProfileChangeStatusImpl, nsIProfileChangeStatus)
|
||||
|
||||
NS_IMETHODIMP
|
||||
ProfileChangeStatusImpl::VetoChange()
|
||||
{
|
||||
NS_ERROR("Can't veto change!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXREDirProvider::GetProductDirectory(nsILocalFile** aFile)
|
||||
NS_IMETHODIMP
|
||||
ProfileChangeStatusImpl::ChangeFailed()
|
||||
{
|
||||
NS_ERROR("Profile change cancellation.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
nsXREDirProvider::DoShutdown()
|
||||
{
|
||||
if (mProfileNotified) {
|
||||
nsCOMPtr<nsIObserverService> obssvc
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
NS_ASSERTION(obssvc, "No observer service?");
|
||||
if (obssvc) {
|
||||
nsCOMPtr<nsIProfileChangeStatus> cs = new ProfileChangeStatusImpl();
|
||||
static const PRUnichar kShutdownPersist[] =
|
||||
{'s','h','u','t','d','o','w','n','-','p','e','r','s','i','s','t','\0'};
|
||||
obssvc->NotifyObservers(cs, "profile-change-net-teardown", kShutdownPersist);
|
||||
obssvc->NotifyObservers(cs, "profile-change-teardown", kShutdownPersist);
|
||||
|
||||
// Phase 2c: Now that things are torn down, force JS GC so that things which depend on
|
||||
// resources which are about to go away in "profile-before-change" are destroyed first.
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack
|
||||
(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
||||
if (stack)
|
||||
{
|
||||
JSContext *cx = nsnull;
|
||||
stack->GetSafeJSContext(&cx);
|
||||
if (cx)
|
||||
::JS_GC(cx);
|
||||
}
|
||||
|
||||
// Phase 3: Notify observers of a profile change
|
||||
obssvc->NotifyObservers(cs, "profile-before-change", kShutdownPersist);
|
||||
}
|
||||
mProfileNotified = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
GetProfileFolderName(char* aProfileFolderName, const char* aSource)
|
||||
{
|
||||
const char* reading = aSource;
|
||||
|
||||
while (*reading) {
|
||||
*aProfileFolderName = tolower(*reading);
|
||||
++aProfileFolderName; ++reading;
|
||||
}
|
||||
*aProfileFolderName = '\0';
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXREDirProvider::GetUserAppDataDirectory(nsILocalFile** aFile)
|
||||
{
|
||||
NS_ASSERTION(gAppData, "gAppData not initialized!");
|
||||
|
||||
// Copied from nsAppFileLocationProvider (more or less)
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> localDir;
|
||||
|
||||
nsCOMPtr<nsIProperties> directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
#if defined(XP_MACOSX)
|
||||
FSRef fsRef;
|
||||
OSErr err = ::FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &fsRef);
|
||||
if (err) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = NS_NewNativeLocalFile(EmptyCString(), PR_TRUE, getter_AddRefs(localDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#if defined(XP_MAC)
|
||||
OSErr err;
|
||||
long response;
|
||||
err = ::Gestalt(gestaltSystemVersion, &response);
|
||||
const char *prop = (!err && response >= 0x00001000) ? NS_MAC_USER_LIB_DIR : NS_MAC_DOCUMENTS_DIR;
|
||||
rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
#elif defined(XP_MACOSX)
|
||||
FSRef fsRef;
|
||||
OSErr err = ::FSFindFolder(kUserDomain, kDomainLibraryFolderType, kCreateFolder, &fsRef);
|
||||
if (err) return NS_ERROR_FAILURE;
|
||||
NS_NewLocalFile(nsString(), PR_TRUE, getter_AddRefs(localDir));
|
||||
if (!localDir) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
|
||||
rv = localDirMac->InitWithFSRef(&fsRef);
|
||||
#elif defined(XP_OS2)
|
||||
rv = directoryService->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
nsCOMPtr<nsILocalFileMac> dirFileMac = do_QueryInterface(localDir);
|
||||
NS_ENSURE_TRUE(dirFileMac, NS_ERROR_UNEXPECTED);
|
||||
|
||||
rv = dirFileMac->InitWithFSRef(&fsRef);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Note that MacOS ignores the vendor when creating the profile hierarchy - all
|
||||
// application preferences directories live alongside one another in
|
||||
// ~/Library/Application Support/
|
||||
rv = dirFileMac->AppendNative(nsDependentCString(gAppData->appName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#elif defined(XP_WIN)
|
||||
PRBool exists;
|
||||
rv = directoryService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = localDir->Exists(&exists);
|
||||
if (NS_FAILED(rv) || !exists) {
|
||||
// On some Win95 machines, NS_WIN_APPDATA_DIR does not exist - revert to NS_WIN_WINDOWS_DIR
|
||||
localDir = 0;
|
||||
rv = directoryService->Get(NS_WIN_WINDOWS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
LPMALLOC pMalloc;
|
||||
LPITEMIDLIST pItemIDList = NULL;
|
||||
|
||||
if (!SUCCEEDED(SHGetMalloc(&pMalloc)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
char appDataPath[MAXPATHLEN];
|
||||
|
||||
if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pItemIDList)) &&
|
||||
SUCCEEDED(SHGetPathFromIDList(pItemIDList, appDataPath))) {
|
||||
} else {
|
||||
if (!GetWindowsDirectory(appDataPath, MAXPATHLEN)) {
|
||||
NS_WARNING("Aaah, no windows directory!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
#elif defined(XP_UNIX)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), PR_TRUE, getter_AddRefs(localDir));
|
||||
|
||||
if (pItemIDList) pMalloc->Free(pItemIDList);
|
||||
pMalloc->Release();
|
||||
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(appDataPath),
|
||||
PR_TRUE, getter_AddRefs(localDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (gAppData->appVendor) {
|
||||
rv = localDir->AppendNative(nsDependentCString(gAppData->appVendor));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = localDir->AppendNative(nsDependentCString(gAppData->appName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#elif defined(XP_OS2)
|
||||
#if 0 /* For OS/2 we want to always use MOZILLA_HOME */
|
||||
// we want an environment variable of the form
|
||||
// FIREFOX_HOME, etc
|
||||
nsDependentCString envVar(nsDependentCString(gAppData->appName));
|
||||
envVar.Append("_HOME");
|
||||
char *pHome = getenv(envVar.get());
|
||||
#endif
|
||||
char *pHome = getenv("MOZILLA_HOME");
|
||||
if (pHome && *pHome) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(pHome), PR_TRUE,
|
||||
getter_AddRefs(localDir));
|
||||
} else {
|
||||
PPIB ppib;
|
||||
PTIB ptib;
|
||||
char appDir[CCHMAXPATH];
|
||||
|
||||
DosGetInfoBlocks(&ptib, &ppib);
|
||||
DosQueryModuleName(ppib->pib_hmte, CCHMAXPATH, appDir);
|
||||
*strrchr(appDir, '\\') = '\0';
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(appDir), PR_TRUE, getter_AddRefs(localDir));
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (gAppData->appVendor) {
|
||||
rv = localDir->AppendNative(nsDependentCString(gAppData->appVendor));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = localDir->AppendNative(nsDependentCString(gAppData->appName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#elif defined(XP_BEOS)
|
||||
char path[MAXPATHLEN];
|
||||
find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, path, MAXPATHLEN);
|
||||
// Need enough space to add the trailing backslash
|
||||
int len = strlen(path);
|
||||
if (len > MAXPATHLEN - 2)
|
||||
char appDir[MAXPATHLEN];
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, NULL, true, appDir, MAXPATHLEN))
|
||||
return NS_ERROR_FAILURE;
|
||||
path[len] = '/';
|
||||
path[len+1] = '\0';
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localDir));
|
||||
|
||||
int len = strlen(appDir);
|
||||
appDir[len] = '/';
|
||||
appDir[len+1] = '\0';
|
||||
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(appDir), PR_TRUE,
|
||||
getter_AddRefs(localDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (gAppData->appVendor) {
|
||||
rv = localDir->AppendNative(nsDependentCString(gAppData->appVendor));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = localDir->AppendNative(nsDependentCString(gAppData->appName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
const char* homeDir = getenv("HOME");
|
||||
if (!homeDir || !*homeDir)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), PR_TRUE,
|
||||
getter_AddRefs(localDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
char* appNameFolder = nsnull;
|
||||
char profileFolderName[MAXPATHLEN] = ".";
|
||||
|
||||
// Offset 1 for the outermost folder to make it hidden (i.e. using the ".")
|
||||
char* writing = profileFolderName + 1;
|
||||
if (gAppData->appVendor) {
|
||||
GetProfileFolderName(writing, gAppData->appVendor);
|
||||
|
||||
rv = localDir->AppendNative(nsDependentCString(profileFolderName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
char temp[MAXPATHLEN];
|
||||
GetProfileFolderName(temp, gAppData->appName);
|
||||
appNameFolder = temp;
|
||||
}
|
||||
else {
|
||||
GetProfileFolderName(writing, gAppData->appName);
|
||||
appNameFolder = profileFolderName;
|
||||
}
|
||||
rv = localDir->AppendNative(nsDependentCString(appNameFolder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#else
|
||||
#error dont_know_how_to_get_product_dir_on_your_platform
|
||||
#endif
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = localDir->AppendRelativeNativePath(mProductDir);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = EnsureDirectoryExists(localDir);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -178,7 +663,7 @@ nsXREDirProvider::GetProductDirectory(nsILocalFile** aFile)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXREDirProvider::EnsureDirectoryExists(nsILocalFile* aDirectory)
|
||||
nsXREDirProvider::EnsureDirectoryExists(nsIFile* aDirectory)
|
||||
{
|
||||
PRBool exists;
|
||||
nsresult rv = aDirectory->Exists(&exists);
|
||||
|
@ -188,3 +673,47 @@ nsXREDirProvider::EnsureDirectoryExists(nsILocalFile* aDirectory)
|
|||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsXREDirProvider::EnsureProfileFileExists(nsIFile *aFile)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool exists;
|
||||
|
||||
rv = aFile->Exists(&exists);
|
||||
if (NS_FAILED(rv) || exists) return;
|
||||
|
||||
nsCAutoString leafName;
|
||||
rv = aFile->GetNativeLeafName(leafName);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsCOMPtr<nsIFile> defaultsFile;
|
||||
rv = GetProfileDefaultsDir(getter_AddRefs(defaultsFile));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
rv = defaultsFile->AppendNative(leafName);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
defaultsFile->CopyToNative(mProfileDir, EmptyCString());
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXREDirProvider::GetProfileDefaultsDir(nsIFile* *aResult)
|
||||
{
|
||||
NS_ASSERTION(mAppDir, "nsXREDirProvider not initialized.");
|
||||
NS_PRECONDITION(aResult, "Null out-param");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFile> defaultsDir;
|
||||
|
||||
rv = mAppDir->Clone(getter_AddRefs(defaultsDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = defaultsDir->AppendNative(nsDependentCString("defaults"));
|
||||
rv |= defaultsDir->AppendNative(nsDependentCString("profile"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ADDREF(*aResult = defaultsDir);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,24 +40,55 @@
|
|||
#define _nsXREDirProvider_h__
|
||||
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIProfileMigrator.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
class nsILocalFile;
|
||||
|
||||
class nsXREDirProvider : public nsIDirectoryServiceProvider
|
||||
class nsXREDirProvider : public nsIDirectoryServiceProvider2,
|
||||
public nsIProfileStartup
|
||||
{
|
||||
public:
|
||||
nsXREDirProvider(const nsACString& aProductName);
|
||||
virtual ~nsXREDirProvider();
|
||||
// we use a custom isupports implementation (no refcount)
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
|
||||
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
|
||||
NS_DECL_NSIPROFILESTARTUP
|
||||
|
||||
private:
|
||||
nsresult GetProductDirectory(nsILocalFile** aFile);
|
||||
nsresult EnsureDirectoryExists(nsILocalFile* aDirectory);
|
||||
nsXREDirProvider();
|
||||
nsresult Initialize();
|
||||
~nsXREDirProvider();
|
||||
|
||||
nsCString mProductDir;
|
||||
// We only set the profile dir, we don't ensure that it exists;
|
||||
// that is the responsibility of the toolkit profile service.
|
||||
// We also don't fire profile-changed notifications... that is
|
||||
// the responsibility of the apprunner.
|
||||
nsresult SetProfileDir(nsIFile* aProfileDir);
|
||||
|
||||
// Causes any attempts to retrieve an enumeration of directories for the
|
||||
// "ComsDL" property to return a list of directories specified in the
|
||||
// "components.ini" manifest in the profile/application directories.
|
||||
// This results in component registration at those locations during
|
||||
// XPCOM startup.
|
||||
void RegisterExtraComponents();
|
||||
|
||||
void DoShutdown();
|
||||
|
||||
nsresult GetProfileDefaultsDir(nsIFile* *aResult);
|
||||
static nsresult GetUserAppDataDirectory(nsILocalFile* *aFile);
|
||||
|
||||
/* make sure you clone it, if you need to do stuff to it */
|
||||
nsIFile* GetAppDir() { return mAppDir; }
|
||||
|
||||
protected:
|
||||
static nsresult EnsureDirectoryExists(nsIFile* aDirectory);
|
||||
void EnsureProfileFileExists(nsIFile* aFile);
|
||||
|
||||
nsCOMPtr<nsILocalFile> mAppDir;
|
||||
nsCOMPtr<nsIFile> mProfileDir;
|
||||
PRBool mProfileNotified;
|
||||
PRBool mRegisterExtraComponents;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
*
|
||||
* 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
|
||||
|
@ -40,47 +41,60 @@
|
|||
#define _nsXULAppAPI_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsString.h"
|
||||
class nsILocalFile;
|
||||
|
||||
// This class holds application-specific information used to
|
||||
// initialize the XUL environment.
|
||||
/**
|
||||
* Application-specific data needed to start the apprunner.
|
||||
*/
|
||||
|
||||
class nsXREAppData {
|
||||
public:
|
||||
nsXREAppData()
|
||||
: mUseSplash(PR_FALSE), mUseStartupPrefs(PR_FALSE) { }
|
||||
struct nsXREAppData
|
||||
{
|
||||
/**
|
||||
* The name of the application vendor. This must be ASCII, and is normally
|
||||
* mixed-case, e.g. "Mozilla".
|
||||
*/
|
||||
const char *appVendor;
|
||||
|
||||
// Set whether the application should use a splash screen.
|
||||
// If set to true, the splash screen must be linked to the application as follows:
|
||||
// Windows: via an IDB_SPLASH bitmap resource
|
||||
// Unix: via an xpm named splash_xpm
|
||||
void SetSplashEnabled(PRBool aEnabled) { mUseSplash = aEnabled; }
|
||||
PRBool GetSplashEnabled() const { return mUseSplash; }
|
||||
/**
|
||||
* The name of the application. This must be ASCII, and is normally
|
||||
* mixed-case, e.g. "Firefox".
|
||||
*/
|
||||
const char *appName;
|
||||
|
||||
// Set the product name for this application.
|
||||
// The product name is used for determining the profile location.
|
||||
// On Windows, profiles will be in Documents and Settings\<user>\<ProductName>
|
||||
// On Unix, profiles will be in ~/.<ProductName>
|
||||
void SetProductName(const nsACString& aName) { mProductName.Assign(aName); }
|
||||
const nsACString& GetProductName() const { return mProductName; }
|
||||
/**
|
||||
* The major version, e.g. "0.8.0+"
|
||||
*/
|
||||
const char *appVersion;
|
||||
|
||||
// Set whether the "general.startup.*" prefs are processed if no
|
||||
// command line arguments are given.
|
||||
void SetUseStartupPrefs(PRBool aUsePrefs) { mUseStartupPrefs = aUsePrefs; }
|
||||
PRBool GetUseStartupPrefs() const { return mUseStartupPrefs; }
|
||||
/**
|
||||
* The application's build identifier, e.g. "2004051604"
|
||||
*/
|
||||
const char *appBuildID;
|
||||
|
||||
private:
|
||||
PRPackedBool mUseSplash;
|
||||
PRPackedBool mUseStartupPrefs;
|
||||
nsCString mProductName;
|
||||
/**
|
||||
* The copyright information to print for the -h commandline flag,
|
||||
* e.g. "Copyright (c) 2003 mozilla.org".
|
||||
*/
|
||||
const char *copyright;
|
||||
|
||||
PRBool useStartupPrefs; // XXXbsmedberg this is going away
|
||||
};
|
||||
|
||||
// Call this function to begin execution of the XUL application.
|
||||
// This function does not return until the user exits the application.
|
||||
// The return code is a native result code suitable for returning from
|
||||
// your main() function.
|
||||
/**
|
||||
* Begin an XUL application. Does not return until the user exits the
|
||||
* application.
|
||||
* @param aAppData Information about the application being run.
|
||||
* @return A native result code suitable for returning from main().
|
||||
*
|
||||
* @note If the binary is linked against the standalone XPCOM glue,
|
||||
* XPCOMGlueStartup() should be called before this method.
|
||||
*
|
||||
* @note XXXbsmedberg Nobody uses the glue yet, but there is a
|
||||
* potentital problem: on windows, the glue calls
|
||||
* SetCurrentDirectory, and relative paths on the command line
|
||||
* won't be correct.
|
||||
*/
|
||||
|
||||
int xre_main(int argc, char* argv[], const nsXREAppData& aAppData);
|
||||
int xre_main(int argc, char* argv[], const nsXREAppData* aAppData);
|
||||
|
||||
#endif // _nsXULAppAPI_h__
|
||||
|
|
|
@ -85,9 +85,6 @@ static PRBool OnMacOSX();
|
|||
|
||||
#include "nsAppShellService.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#ifdef MOZ_PHOENIX
|
||||
#include "nsIProfileMigrator.h"
|
||||
#endif
|
||||
#include "nsIProfileChangeStatus.h"
|
||||
#include "nsICloseAllWindows.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -122,17 +119,6 @@ nsAppShellService::nsAppShellService() :
|
|||
|
||||
nsAppShellService::~nsAppShellService()
|
||||
{
|
||||
mDeleteCalled = PR_TRUE;
|
||||
nsCOMPtr<nsIWebShellWindow> hiddenWin(do_QueryInterface(mHiddenWindow));
|
||||
if(hiddenWin) {
|
||||
ClearXPConnectSafeContext();
|
||||
hiddenWin->Close();
|
||||
}
|
||||
/* Note we don't unregister with the observer service
|
||||
(RegisterObserver(PR_FALSE)) because, being refcounted, we can't have
|
||||
reached our own destructor until after the ObserverService has shut down
|
||||
and released us. This means we leak until the end of the application, but
|
||||
so what; this is the appshell service. */
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,9 +148,11 @@ nsAppShellService::Initialize( nsICmdLineService *aCmdLineService,
|
|||
// Remember where the native app support lives.
|
||||
mNativeAppSupport = do_QueryInterface(aNativeAppSupportOrSplashScreen);
|
||||
|
||||
#ifndef MOZ_XUL_APP
|
||||
// Or, remember the splash screen (for backward compatibility).
|
||||
if (!mNativeAppSupport)
|
||||
mSplashScreen = do_QueryInterface(aNativeAppSupportOrSplashScreen);
|
||||
#endif
|
||||
|
||||
NS_TIMELINE_ENTER("nsComponentManager::CreateInstance.");
|
||||
// Create widget application shell
|
||||
|
@ -217,8 +205,10 @@ nsresult nsAppShellService::ClearXPConnectSafeContext()
|
|||
|
||||
nsCOMPtr<nsIThreadJSContextStack> cxstack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("XPConnect ContextStack gone before XPCOM shutdown?");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> junk;
|
||||
JSContext *cx;
|
||||
|
@ -260,6 +250,14 @@ nsAppShellService::AttemptingQuit(PRBool aAttempt)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef MOZ_XUL_APP
|
||||
NS_IMETHODIMP
|
||||
nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool canInteract)
|
||||
{
|
||||
NS_NOTREACHED("Don't call me, I'm dead!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#else
|
||||
NS_IMETHODIMP
|
||||
nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool canInteract)
|
||||
{
|
||||
|
@ -270,38 +268,6 @@ nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool c
|
|||
|
||||
EnterLastWindowClosingSurvivalArea();
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
// This will eventually change to MOZ_XULAPP
|
||||
|
||||
// Profile Manager has a number of command line arguments... most of which relate to
|
||||
// management UI or options for starting a specific profile. The migration code we're
|
||||
// about to execute occurs ONLY in the situation when there are NO profiles.
|
||||
//
|
||||
// In this case there are only TWO profile manager flags that are of concern to us -
|
||||
// -CreateProfile (used by various automation processes) and -ProfileWizard - these
|
||||
// are the only two commands valid in the no-profile case - users of these commands
|
||||
// do NOT want the automigration UI to appear, so we explicitly check for these flags
|
||||
// before invoking anything.
|
||||
nsXPIDLCString isCreateProfile, isCreateProfileWizard;
|
||||
aCmdLineService->GetCmdLineValue("-CreateProfile", getter_Copies(isCreateProfile));
|
||||
aCmdLineService->GetCmdLineValue("-ProfileWizard", getter_Copies(isCreateProfileWizard));
|
||||
|
||||
if (isCreateProfile.IsEmpty() && isCreateProfileWizard.IsEmpty()) {
|
||||
PRInt32 numProfiles = 0;
|
||||
profileMgr->GetProfileCount(&numProfiles);
|
||||
|
||||
if (numProfiles == 0) {
|
||||
nsCOMPtr<nsIProfileMigrator> pm(do_CreateInstance("@mozilla.org/profile/migrator;1", &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = pm->Migrate();
|
||||
if (NS_FAILED(rv)) {
|
||||
// Migration failed for some reason, or there was no profile migrator.
|
||||
// Create a generic default profile.
|
||||
rv = profileMgr->CreateDefaultProfile();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// If we are being launched in turbo mode, profile mgr cannot show UI
|
||||
rv = profileMgr->StartupWithArgs(aCmdLineService, canInteract);
|
||||
|
@ -310,13 +276,11 @@ nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool c
|
|||
rv = NS_OK;
|
||||
}
|
||||
|
||||
#ifndef MOZ_PHOENIX
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CheckAndRemigrateDefunctProfile();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to check and remigrate profile");
|
||||
rv = NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
ExitLastWindowClosingSurvivalArea();
|
||||
|
||||
|
@ -325,8 +289,9 @@ nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool c
|
|||
return NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MOZ_PHOENIX
|
||||
#ifndef MOZ_XUL_APP
|
||||
nsresult
|
||||
nsAppShellService::CheckAndRemigrateDefunctProfile()
|
||||
{
|
||||
|
@ -560,6 +525,7 @@ nsAppShellService::Quit(PRUint32 aFerocity)
|
|||
if (!windowsRemain) {
|
||||
aFerocity = eAttemptQuit;
|
||||
|
||||
#ifndef MOZ_XUL_APP
|
||||
// Check to see if we should quit in this case.
|
||||
if (mNativeAppSupport) {
|
||||
PRBool serverMode = PR_FALSE;
|
||||
|
@ -571,6 +537,7 @@ nsAppShellService::Quit(PRUint32 aFerocity)
|
|||
return NS_OK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1231,6 +1198,7 @@ nsAppShellService::OpenWindow(const nsAFlatCString& aChromeURL,
|
|||
if (!wwatch || !sarg)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifndef MOZ_XUL_APP
|
||||
// Make sure a profile is selected.
|
||||
|
||||
// We need the native app support object. If this fails, we still proceed.
|
||||
|
@ -1254,6 +1222,7 @@ nsAppShellService::OpenWindow(const nsAFlatCString& aChromeURL,
|
|||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
sarg->SetData(aAppArgs);
|
||||
|
||||
|
@ -1278,6 +1247,7 @@ nsAppShellService::Ensure1Window(nsICmdLineService *aCmdLineService)
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
#ifndef MOZ_XUL_APP
|
||||
// If starting up in server mode, then we do things differently.
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
rv = GetNativeAppSupport(getter_AddRefs(nativeApp));
|
||||
|
@ -1293,6 +1263,7 @@ nsAppShellService::Ensure1Window(nsICmdLineService *aCmdLineService)
|
|||
return NS_OK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -1431,11 +1402,13 @@ NS_IMETHODIMP nsAppShellService::Observe(nsISupports *aSubject,
|
|||
if (isNative)
|
||||
mAppShell->ListenToEventQueue(eq, PR_FALSE);
|
||||
}
|
||||
#ifndef MOZ_XUL_APP
|
||||
} else if (!strcmp(aTopic, gSkinSelectedTopic) ||
|
||||
!strcmp(aTopic, gLocaleSelectedTopic) ||
|
||||
!strcmp(aTopic, gInstallRestartTopic)) {
|
||||
if (mNativeAppSupport)
|
||||
mNativeAppSupport->SetIsServerMode(PR_FALSE);
|
||||
#endif
|
||||
} else if (!strcmp(aTopic, gProfileChangeTeardownTopic)) {
|
||||
nsresult rv;
|
||||
EnterLastWindowClosingSurvivalArea();
|
||||
|
@ -1460,6 +1433,13 @@ NS_IMETHODIMP nsAppShellService::Observe(nsISupports *aSubject,
|
|||
CreateStartupState(SIZE_TO_CONTENT, SIZE_TO_CONTENT, &openedWindow);
|
||||
if (!openedWindow)
|
||||
OpenBrowserWindow(SIZE_TO_CONTENT, SIZE_TO_CONTENT);
|
||||
} else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
||||
mDeleteCalled = PR_TRUE;
|
||||
nsCOMPtr<nsIWebShellWindow> hiddenWin(do_QueryInterface(mHiddenWindow));
|
||||
if(hiddenWin) {
|
||||
ClearXPConnectSafeContext();
|
||||
hiddenWin->Close();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1487,6 +1467,7 @@ void nsAppShellService::RegisterObserver(PRBool aRegister)
|
|||
os->AddObserver(weObserve, gInstallRestartTopic, PR_TRUE);
|
||||
os->AddObserver(weObserve, gProfileChangeTeardownTopic, PR_TRUE);
|
||||
os->AddObserver(weObserve, gProfileInitialStateTopic, PR_TRUE);
|
||||
os->AddObserver(weObserve, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
} else {
|
||||
os->RemoveObserver(weObserve, gEQActivatedNotification);
|
||||
os->RemoveObserver(weObserve, gEQDestroyedNotification);
|
||||
|
@ -1495,6 +1476,7 @@ void nsAppShellService::RegisterObserver(PRBool aRegister)
|
|||
os->RemoveObserver(weObserve, gInstallRestartTopic);
|
||||
os->RemoveObserver(weObserve, gProfileChangeTeardownTopic);
|
||||
os->RemoveObserver(weObserve, gProfileInitialStateTopic);
|
||||
os->RemoveObserver(weObserve, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
}
|
||||
NS_RELEASE(glop);
|
||||
}
|
||||
|
@ -1502,12 +1484,15 @@ void nsAppShellService::RegisterObserver(PRBool aRegister)
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsAppShellService::HideSplashScreen() {
|
||||
#ifndef MOZ_XUL_APP
|
||||
// Hide the splash screen.
|
||||
if ( mNativeAppSupport ) {
|
||||
mNativeAppSupport->HideSplashScreen();
|
||||
} else if ( mSplashScreen ) {
|
||||
}
|
||||
else if ( mSplashScreen ) {
|
||||
mSplashScreen->Hide();
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,9 @@ protected:
|
|||
nsCOMPtr<nsPIWindowWatcher> mWindowWatcher;
|
||||
nsCOMPtr<nsIXULWindow> mHiddenWindow;
|
||||
PRBool mDeleteCalled;
|
||||
#ifndef MOZ_XUL_APP
|
||||
nsCOMPtr<nsISplashScreen> mSplashScreen;
|
||||
#endif
|
||||
nsCOMPtr<nsINativeAppSupport> mNativeAppSupport;
|
||||
|
||||
PRUint16 mModalWindowCount;
|
||||
|
@ -95,7 +97,7 @@ protected:
|
|||
PR_STATIC_CALLBACK(void) DestroyExitEvent(PLEvent* aEvent);
|
||||
|
||||
private:
|
||||
#ifndef MOZ_PHOENIX
|
||||
#ifndef MOZ_XUL_APP
|
||||
nsresult CheckAndRemigrateDefunctProfile();
|
||||
#endif
|
||||
|
||||
|
|