зеркало из https://github.com/mozilla/gecko-dev.git
Bug 237745 (app-startup) - split off the pieces of appshellservice that have to do with the startup sequence into a new (forked, temporarily) app-startup service r+sr=darin+biesi+Neil
This commit is contained in:
Родитель
a73f965a59
Коммит
e08012b8b7
57
Makefile.in
57
Makefile.in
|
@ -206,10 +206,6 @@ tier_9_dirs += \
|
|||
editor \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
tier_9_dirs += xpfe/bootstrap/appleevents
|
||||
endif
|
||||
|
||||
ifdef MOZ_THUNDERBIRD
|
||||
ifdef MOZ_USE_OFFICIAL_BRANDING
|
||||
tier_9_dirs += other-licenses/branding/thunderbird
|
||||
|
@ -222,23 +218,8 @@ tier_9_dirs += other-licenses/branding/firefox
|
|||
endif
|
||||
endif
|
||||
|
||||
# profile and chrome should be in tier 50, but are required by xpfe/appshell
|
||||
# This is a temporary hack until the app-startup patch lands.
|
||||
|
||||
ifdef MOZ_XUL
|
||||
ifdef MOZ_XUL_APP
|
||||
tier_9_dirs += chrome
|
||||
else
|
||||
tier_9_dirs += rdf/chrome
|
||||
endif
|
||||
endif
|
||||
|
||||
tier_9_dirs += profile
|
||||
|
||||
tier_9_dirs += \
|
||||
xpfe/appshell \
|
||||
xpfe/browser/public \
|
||||
xpfe/components/sidebar/public \
|
||||
xpfe/components/xremote/public \
|
||||
$(NULL)
|
||||
|
||||
|
@ -250,10 +231,6 @@ ifdef MOZ_LDAP_XPCOM
|
|||
tier_9_dirs += directory/xpcom
|
||||
endif
|
||||
|
||||
ifndef MOZ_XUL
|
||||
tier_9_dirs += embedding/minimo/chromelite
|
||||
endif
|
||||
|
||||
ifdef MOZ_XUL_APP
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
tier_9_dirs += toolkit/components/gnome
|
||||
|
@ -264,6 +241,18 @@ endif
|
|||
# tier 50 - xpfe & toolkit
|
||||
#
|
||||
|
||||
ifdef MOZ_XUL
|
||||
ifdef MOZ_XUL_APP
|
||||
tier_50_dirs += chrome
|
||||
else
|
||||
tier_50_dirs += rdf/chrome
|
||||
endif
|
||||
else
|
||||
tier_50_dirs += embedding/minimo/chromelite
|
||||
endif
|
||||
|
||||
tier_50_dirs += profile
|
||||
|
||||
ifdef MOZ_PSM
|
||||
tier_50_dirs += security/manager
|
||||
endif
|
||||
|
@ -273,10 +262,8 @@ ifdef MOZ_JPROF
|
|||
tier_50_dirs += tools/jprof
|
||||
endif
|
||||
|
||||
ifdef MOZ_XUL_APP
|
||||
tier_50_dirs += toolkit/components/history/public
|
||||
else
|
||||
tier_50_dirs += xpfe/components/history/public
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
tier_50_dirs += xpfe/bootstrap/appleevents
|
||||
endif
|
||||
|
||||
tier_50_dirs += xpfe themes
|
||||
|
@ -289,10 +276,6 @@ ifdef MOZ_MAPINFO
|
|||
tier_50_dirs += tools/codesighs
|
||||
endif
|
||||
|
||||
ifneq (,$(MOZ_L10N_LANG)$(MOZ_L10N_TOOLS))
|
||||
tier_50_dirs += l10n
|
||||
endif
|
||||
|
||||
ifdef MOZ_XUL_APP
|
||||
tier_50_dirs += toolkit
|
||||
endif
|
||||
|
@ -358,6 +341,10 @@ tier_99_dirs += other-licenses/branding/thunderbird/content
|
|||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_COMPOSER
|
||||
tier_99_dirs += editor/ui
|
||||
endif
|
||||
|
||||
ifdef MOZ_STANDALONE_COMPOSER
|
||||
tier_99_dirs += composer
|
||||
endif
|
||||
|
@ -385,11 +372,17 @@ ifneq (,$(ENABLE_TESTS))
|
|||
tier_99_dirs += webshell/tests
|
||||
endif
|
||||
|
||||
# winembed, mfcembed
|
||||
# winembed, mfcembed, axcontrol
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
ifneq (,$(ENABLE_TESTS)$(MOZILLA_OFFICIAL))
|
||||
tier_99_dirs += embedding/tests
|
||||
endif
|
||||
ifndef MOZ_NO_ACTIVEX_SUPPORT
|
||||
tier_99_dirs += \
|
||||
embedding/browser/activex/src/control \
|
||||
embedding/browser/activex/src/control_kicker \
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
|
||||
# os2embed
|
||||
|
|
|
@ -700,6 +700,9 @@ xpfe/components/search/src/Makefile
|
|||
xpfe/components/sidebar/Makefile
|
||||
xpfe/components/sidebar/public/Makefile
|
||||
xpfe/components/sidebar/src/Makefile
|
||||
xpfe/components/startup/Makefile
|
||||
xpfe/components/startup/public/Makefile
|
||||
xpfe/components/startup/src/Makefile
|
||||
xpfe/components/autocomplete/Makefile
|
||||
xpfe/components/autocomplete/public/Makefile
|
||||
xpfe/components/autocomplete/src/Makefile
|
||||
|
@ -945,6 +948,9 @@ toolkit/components/printing/Makefile
|
|||
toolkit/components/satchel/Makefile
|
||||
toolkit/components/satchel/public/Makefile
|
||||
toolkit/components/satchel/src/Makefile
|
||||
toolkit/components/startup/Makefile
|
||||
toolkit/components/startup/public/Makefile
|
||||
toolkit/components/startup/src/Makefile
|
||||
toolkit/components/viewconfig/Makefile
|
||||
toolkit/components/viewsource/Makefile
|
||||
toolkit/mozapps/Makefile
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include <windows.h>
|
||||
#include "nsINativeAppSupportWin.h"
|
||||
#include "nsNativeAppSupportWin.h"
|
||||
|
||||
1 24 "firefox.exe.manifest"
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ REQUIRES = xpcom \
|
|||
string \
|
||||
rdf \
|
||||
appshell \
|
||||
appcomps \
|
||||
widget \
|
||||
necko \
|
||||
nkcache \
|
||||
|
|
|
@ -35,6 +35,7 @@ REQUIRES = \
|
|||
windowwatcher \
|
||||
intl \
|
||||
appshell \
|
||||
appcomps \
|
||||
necko \
|
||||
layout \
|
||||
content \
|
||||
|
|
|
@ -49,6 +49,7 @@ REQUIRES = xpcom \
|
|||
widget \
|
||||
js \
|
||||
appshell \
|
||||
appcomps \
|
||||
caps \
|
||||
pref \
|
||||
docshell \
|
||||
|
|
|
@ -45,10 +45,5 @@ include $(DEPTH)/config/autoconf.mk
|
|||
MODULE = editor
|
||||
DIRS = public idl txtsvc libeditor txmgr composer
|
||||
|
||||
# We need to export headers from composer/ even if we're not building composer.
|
||||
ifdef MOZ_COMPOSER
|
||||
DIRS += ui
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -82,7 +82,6 @@ CPPSRCS = \
|
|||
nsComposerRegistration.cpp \
|
||||
nsEditingSession.cpp \
|
||||
nsComposerCommandsUpdater.cpp \
|
||||
nsEditorService.cpp \
|
||||
nsEditorSpellCheck.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -42,12 +42,13 @@
|
|||
#include "nsEditingSession.h" // for the CID
|
||||
#include "nsComposerController.h" // for the CID
|
||||
#include "nsEditorSpellCheck.h" // for the CID
|
||||
#include "nsEditorService.h"
|
||||
#include "nsComposeTxtSrvFilter.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsIControllerContext.h"
|
||||
#include "nsIControllerCommandTable.h"
|
||||
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
|
||||
#define NS_HTMLEDITOR_COMMANDTABLE_CID \
|
||||
{ 0x7a727843, 0x6ae1, 0x11d7, { 0xa5eb, 0x00, 0x03, 0x93, 0x63, 0x65, 0x92 } }
|
||||
|
||||
|
@ -66,7 +67,6 @@ static NS_DEFINE_CID(kHTMLEditorDocStateCommandTableCID, NS_HTMLEDITOR_DOCSTATE_
|
|||
//
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditingSession)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditorService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditorSpellCheck)
|
||||
|
||||
// There are no macros that enable us to have 2 constructors
|
||||
|
@ -236,23 +236,10 @@ static const nsModuleComponentInfo components[] = {
|
|||
{ "Editing Session", NS_EDITINGSESSION_CID,
|
||||
"@mozilla.org/editor/editingsession;1", nsEditingSessionConstructor, },
|
||||
|
||||
{ "Editor Service", NS_EDITORSERVICE_CID,
|
||||
"@mozilla.org/editor/editorservice;1", nsEditorServiceConstructor,},
|
||||
|
||||
{ "Editor Spell Checker", NS_EDITORSPELLCHECK_CID,
|
||||
"@mozilla.org/editor/editorspellchecker;1",
|
||||
nsEditorSpellCheckConstructor,},
|
||||
|
||||
{ "Editor Startup Handler", NS_EDITORSERVICE_CID,
|
||||
"@mozilla.org/commandlinehandler/general-startup;1?type=editor",
|
||||
nsEditorServiceConstructor,
|
||||
nsEditorService::RegisterProc,
|
||||
nsEditorService::UnregisterProc, },
|
||||
|
||||
{ "Edit Startup Handler", NS_EDITORSERVICE_CID,
|
||||
"@mozilla.org/commandlinehandler/general-startup;1?type=edit",
|
||||
nsEditorServiceConstructor, },
|
||||
|
||||
{ "TxtSrv Filter", NS_COMPOSERTXTSRVFILTER_CID,
|
||||
COMPOSER_TXTSRVFILTER_CONTRACTID,
|
||||
nsComposeTxtSrvFilterConstructorForComposer, },
|
||||
|
|
|
@ -44,6 +44,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
ifndef MOZ_STANDALONE_COMPOSER
|
||||
PREF_JS_EXPORTS = $(srcdir)/composer.js
|
||||
EXTRA_COMPONENTS = nsComposerCmdLineHandler.js
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,186 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Seamonkey Composer.
|
||||
*
|
||||
* 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):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const nsICmdLineHandler = Components.interfaces.nsICmdLineHandler;
|
||||
const nsIFactory = Components.interfaces.nsIFactory;
|
||||
const nsISupports = Components.interfaces.nsISupports;
|
||||
const nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar;
|
||||
const nsICategoryManager = Components.interfaces.nsICategoryManager;
|
||||
|
||||
const NS_ERROR_FAILURE = Components.results.NS_ERROR_FAILURE;
|
||||
const NS_ERROR_NO_AGGREGATION = Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
const NS_ERROR_NO_INTERFACE = Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
function nsComposerCmdLineHandler() {
|
||||
}
|
||||
|
||||
nsComposerCmdLineHandler.prototype = {
|
||||
/* nsISupports */
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (!iid.equals(nsICmdLineHandler) &&
|
||||
!iid.equals(nsISupports)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/* nsICmdLineHandler */
|
||||
|
||||
get commandLineArgument() {
|
||||
return "-edit";
|
||||
},
|
||||
|
||||
get prefNameForStartup() {
|
||||
return "general.startup.editor";
|
||||
},
|
||||
|
||||
get chromeUrlForTask() {
|
||||
return "chrome://editor/content/editor.xul";
|
||||
},
|
||||
|
||||
get helpText() {
|
||||
return "Start with editor."
|
||||
},
|
||||
|
||||
get handlesArgs() {
|
||||
return true;
|
||||
},
|
||||
|
||||
get defaultArgs() {
|
||||
return "about:blank";
|
||||
},
|
||||
|
||||
get openWindowWithArgs() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
function nsComposerCmdLineHandlerFactory() {
|
||||
}
|
||||
|
||||
nsComposerCmdLineHandlerFactory.prototype = {
|
||||
/* nsISupports */
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (!iid.equals(nsIFactory) &&
|
||||
!iid.equals(nsISupports)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/* nsIFactory */
|
||||
|
||||
createInstance: function(outer, iid) {
|
||||
if (outer != null) {
|
||||
throw NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
|
||||
return new nsComposerCmdLineHandler().QueryInterface(iid);
|
||||
},
|
||||
|
||||
lockFactory: function(lock) {
|
||||
}
|
||||
};
|
||||
|
||||
const nsComposerCmdLineHandler_CID =
|
||||
Components.ID("{f7d8db95-ab5d-4393-a796-9112fe758cfa}");
|
||||
|
||||
const ContractIDPrefix =
|
||||
"@mozilla.org/commandlinehandler/general-startup;1?type=";
|
||||
|
||||
var thisModule = {
|
||||
/* nsISupports */
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (!iid.equals(nsIModule) &&
|
||||
!iid.equals(nsISupports)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/* nsIModule */
|
||||
|
||||
getClassObject: function (compMgr, cid, iid) {
|
||||
if (!cid.equals(nsComposerCmdLineHandler_CID)) {
|
||||
throw NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!iid.equals(nsIFactory)) {
|
||||
throw NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
return new nsComposerCmdLineHandlerFactory();
|
||||
},
|
||||
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
var compReg = compMgr.QueryInterface(nsIComponentRegistrar);
|
||||
compReg.registerFactoryLocation(nsComposerCmdLineHandler_CID,
|
||||
"nsComposerCmdLineHandler",
|
||||
ContractIDPrefix + "edit",
|
||||
fileSpec, location, type);
|
||||
compReg.registerFactoryLocation(nsComposerCmdLineHandler_CID,
|
||||
"nsComposerCmdLineHandler",
|
||||
ContractIDPrefix + "editor",
|
||||
fileSpec, location, type);
|
||||
|
||||
var catMan = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager);
|
||||
catMan.addCategoryEntry("command-line-argument-handlers",
|
||||
"nsComposerCmdLineHandler",
|
||||
ContractIDPrefix + "edit",
|
||||
true, true);
|
||||
},
|
||||
|
||||
unregisterSelf: function (compMgr, location, type) {
|
||||
var compReg = compMgr.QueryInterface(nsIComponentRegistrar);
|
||||
compReg.unregisterFactoryLocation(nsComposerCmdLineHandler_CID,
|
||||
location);
|
||||
|
||||
var catMan = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager);
|
||||
catMan.deleteCategoryEntry("command-line-argument-handlers",
|
||||
"nsComposerCmdLineHandler", true);
|
||||
},
|
||||
|
||||
canUnload: function (compMgr) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return thisModule;
|
||||
}
|
|
@ -50,12 +50,11 @@ DIRS = $(NULL)
|
|||
# Common
|
||||
DIRS += common
|
||||
|
||||
# ActiveX control
|
||||
DIRS += control control_kicker
|
||||
|
||||
# ActiveX plugin
|
||||
ifdef MOZ_ACTIVEX_SCRIPTING_SUPPORT
|
||||
DIRS += plugin
|
||||
endif
|
||||
|
||||
# The ActiveX control is now built in tier 99 from mozilla/Makefile.in
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -51,7 +51,18 @@ MODULE_NAME = nsAutoConfigModule
|
|||
|
||||
PACKAGE_FILE = autoconfig.pkg
|
||||
|
||||
REQUIRES = xpcom string intl js xpconnect necko profile pref appshell embedcomponents windowwatcher
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
intl \
|
||||
js \
|
||||
xpconnect \
|
||||
necko \
|
||||
profile \
|
||||
pref \
|
||||
appcomps \
|
||||
embedcomponents \
|
||||
windowwatcher \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#endif
|
||||
#include "nsReadConfig.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIAutoConfig.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
@ -54,6 +54,7 @@
|
|||
#include "nsIPromptService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "prmem.h"
|
||||
|
@ -141,10 +142,10 @@ NS_IMETHODIMP nsReadConfig::Observe(nsISupports *aSubject, const char *aTopic, c
|
|||
if (NS_FAILED(rv)) {
|
||||
DisplayError();
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService =
|
||||
do_GetService("@mozilla.org/appshell/appShellService;1");
|
||||
if (appShellService)
|
||||
appShellService->Quit(nsIAppShellService::eAttemptQuit);
|
||||
nsCOMPtr<nsIAppStartup> appStartup =
|
||||
do_GetService(NS_APPSTARTUP_CONTRACTID);
|
||||
if (appStartup)
|
||||
appStartup->Quit(nsIAppStartup::eAttemptQuit);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
|
|
@ -105,7 +105,8 @@ nsSystemPref::Init(void)
|
|||
|
||||
if (!gSysPrefLog) {
|
||||
gSysPrefLog = PR_NewLogModule("Syspref");
|
||||
PR_ASSERT(gSysPrefLog);
|
||||
if (!gSysPrefLog)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include <windows.h>
|
||||
#include "nsINativeAppSupportWin.h"
|
||||
#include "nsNativeAppSupportWin.h"
|
||||
|
||||
1 24 "thunderbird.exe.manifest"
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ REQUIRES = xpcom \
|
|||
rdfutil \
|
||||
docshell \
|
||||
appshell \
|
||||
appcomps \
|
||||
dom \
|
||||
widget \
|
||||
locale \
|
||||
|
|
|
@ -51,6 +51,7 @@ REQUIRES = xpcom \
|
|||
rdf \
|
||||
rdfutil \
|
||||
appshell \
|
||||
appcomps \
|
||||
dom \
|
||||
layout \
|
||||
widget \
|
||||
|
|
|
@ -60,8 +60,6 @@
|
|||
#include "nsRDFResource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
|
|
@ -77,6 +77,7 @@ REQUIRES = xpcom \
|
|||
msgbaseutil \
|
||||
msgdb \
|
||||
appshell \
|
||||
appcomps \
|
||||
msgnews \
|
||||
msgimap \
|
||||
gfx \
|
||||
|
|
|
@ -51,6 +51,7 @@ REQUIRES = xpcom \
|
|||
necko \
|
||||
dom \
|
||||
appshell \
|
||||
appcomps \
|
||||
uconv \
|
||||
intl \
|
||||
htmlparser \
|
||||
|
|
|
@ -411,24 +411,24 @@ nsMessengerWinIntegration::Init()
|
|||
rv = profilePath->GetPath(mProfilePath);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#else
|
||||
// get current profile name to fill in commandliner.
|
||||
// get current profile name to fill in commandliner.
|
||||
nsCOMPtr<nsIProfile> profileService = do_GetService(NS_PROFILE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
profileService->GetCurrentProfile(getter_Copies(mProfileName));
|
||||
profileService->GetCurrentProfile(getter_Copies(mProfileName));
|
||||
#endif
|
||||
|
||||
// get application path
|
||||
char appPath[_MAX_PATH] = {0};
|
||||
GetModuleFileName(nsnull, appPath, sizeof(appPath));
|
||||
WCHAR wideFormatAppPath[_MAX_PATH*2] = {0};
|
||||
MultiByteToWideChar(CP_ACP, 0, appPath, strlen(appPath), wideFormatAppPath, _MAX_PATH*2);
|
||||
mAppName.Assign((PRUnichar *)wideFormatAppPath);
|
||||
// get application path
|
||||
char appPath[_MAX_PATH] = {0};
|
||||
GetModuleFileName(nsnull, appPath, sizeof(appPath));
|
||||
WCHAR wideFormatAppPath[_MAX_PATH*2] = {0};
|
||||
MultiByteToWideChar(CP_ACP, 0, appPath, strlen(appPath), wideFormatAppPath, _MAX_PATH*2);
|
||||
mAppName.Assign((PRUnichar *)wideFormatAppPath);
|
||||
|
||||
rv = ResetCurrent();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = ResetCurrent();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = SetupUnreadCountUpdateTimer();
|
||||
rv = SetupUnreadCountUpdateTimer();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -73,6 +73,7 @@ REQUIRES = xpcom \
|
|||
widget \
|
||||
msgdb \
|
||||
appshell \
|
||||
appcomps \
|
||||
nkcache \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ REQUIRES = xpcom \
|
|||
msgdb \
|
||||
rdf \
|
||||
appshell \
|
||||
appcomps \
|
||||
msgimap \
|
||||
msgnews \
|
||||
docshell \
|
||||
|
|
|
@ -88,7 +88,6 @@
|
|||
#include "nsTextFormatter.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsMailHeaders.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
|
|
@ -54,6 +54,7 @@ REQUIRES = xpcom \
|
|||
string \
|
||||
MapiProxy \
|
||||
appshell \
|
||||
appcomps \
|
||||
windowwatcher \
|
||||
dom \
|
||||
profile \
|
||||
|
|
|
@ -54,12 +54,11 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsINativeAppSupport.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIMsgAccountManager.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -74,6 +73,7 @@
|
|||
#include "nsIMsgComposeParams.h"
|
||||
#include "nsIMsgCompose.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
#include "nsIMsgSend.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsIMsgComposeService.h"
|
||||
|
@ -90,8 +90,6 @@
|
|||
extern PRLogModuleInfo *MAPI;
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
|
||||
class nsMAPISendListener : public nsIMsgSendListener
|
||||
{
|
||||
public:
|
||||
|
@ -160,20 +158,23 @@ PRBool nsMapiHook::isMapiService = PR_FALSE;
|
|||
|
||||
PRBool nsMapiHook::Initialize()
|
||||
{
|
||||
#ifndef MOZ_THUNDERBIRD
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINativeAppSupport> native;
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs(do_GetService(kCmdLineServiceCID, &rv));
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs (
|
||||
do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell (do_GetService( "@mozilla.org/appshell/appShellService;1", &rv));
|
||||
nsCOMPtr<nsIAppStartup> appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
rv = appShell->GetNativeAppSupport( getter_AddRefs( native ));
|
||||
rv = appStartup->GetNativeAppSupport(getter_AddRefs(native));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
rv = native->EnsureProfile(cmdLineArgs);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
#endif
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -190,9 +191,6 @@ PRBool nsMapiHook::DisplayLoginDialog(PRBool aLogin, PRUnichar **aUsername,
|
|||
nsresult rv;
|
||||
PRBool btnResult = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService( "@mozilla.org/appshell/appShellService;1", &rv));
|
||||
if (NS_FAILED(rv) || !appShell) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPromptService> dlgService(do_GetService("@mozilla.org/embedcomp/prompt-service;1", &rv));
|
||||
if (NS_SUCCEEDED(rv) && dlgService)
|
||||
{
|
||||
|
|
|
@ -59,6 +59,7 @@ REQUIRES = xpcom \
|
|||
msgbaseutil \
|
||||
msgdb \
|
||||
appshell \
|
||||
appcomps \
|
||||
mime \
|
||||
necko \
|
||||
rdf \
|
||||
|
|
|
@ -62,6 +62,7 @@ REQUIRES = xpcom \
|
|||
pref \
|
||||
uriloader \
|
||||
appshell \
|
||||
appcomps \
|
||||
mime \
|
||||
intl \
|
||||
webshell \
|
||||
|
|
|
@ -46,7 +46,6 @@ LIBRARY_NAME = profile
|
|||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsProfileModule
|
||||
GRE_MODULE = 1
|
||||
|
||||
PACKAGE_FILE = profile.pkg
|
||||
|
||||
|
@ -55,6 +54,7 @@ REQUIRES = xpcom \
|
|||
string \
|
||||
uriloader \
|
||||
appshell \
|
||||
appcomps \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -43,7 +43,6 @@ VPATH = @srcdir@
|
|||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = profile
|
||||
GRE_MODULE = 1
|
||||
|
||||
SDK_XPIDLSRCS = \
|
||||
nsIProfile.idl \
|
||||
|
|
|
@ -265,9 +265,9 @@ function onStart()
|
|||
|
||||
if (fatalError)
|
||||
{
|
||||
var appShellService = Components.classes["@mozilla.org/appshell/appShellService;1"]
|
||||
.getService(Components.interfaces.nsIAppShellService);
|
||||
appShellService.quit(Components.interfaces.nsIAppShellService.eForceQuit);
|
||||
var appStartup = Components.classes["@mozilla.org/seamonkey/app-startup;1"]
|
||||
.getService(Components.interfaces.nsIAppStartup);
|
||||
appStartup.quit(Components.interfaces.nsIAppStartup.eForceQuit);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -60,6 +60,7 @@ REQUIRES = xpcom \
|
|||
pref \
|
||||
prefmigr \
|
||||
appshell \
|
||||
appcomps \
|
||||
chrome \
|
||||
uconv \
|
||||
windowwatcher \
|
||||
|
|
|
@ -52,6 +52,7 @@ ifdef MOZ_SUNBIRD
|
|||
DIRS = autocomplete console filepicker help printing passwordmgr
|
||||
else
|
||||
DIRS = \
|
||||
startup \
|
||||
autocomplete \
|
||||
console \
|
||||
filepicker \
|
||||
|
|
|
@ -36,6 +36,7 @@ MODULE_NAME = nsToolkitCompsModule
|
|||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
widget \
|
||||
layout \
|
||||
dom \
|
||||
mork \
|
||||
|
@ -44,6 +45,7 @@ REQUIRES = \
|
|||
intl \
|
||||
docshell \
|
||||
autocomplete \
|
||||
appcomps \
|
||||
downloads \
|
||||
mimetype \
|
||||
webbrowserpersist \
|
||||
|
@ -54,6 +56,8 @@ REQUIRES = \
|
|||
windowwatcher \
|
||||
uriloader \
|
||||
xpinstall \
|
||||
xulapp \
|
||||
embed_base \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
|
@ -70,6 +74,7 @@ LOCAL_INCLUDES = \
|
|||
-I$(srcdir)/../history/src \
|
||||
-I$(srcdir)/../satchel/src \
|
||||
-I$(srcdir)/../passwordmgr/base \
|
||||
-I$(srcdir)/../startup/src \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
|
@ -77,6 +82,11 @@ LOCAL_INCLUDES += -I$(srcdir)/../alerts/src
|
|||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
../startup/src/$(LIB_PREFIX)appstartup_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PHOENIX
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
$(DIST)/lib/$(LIB_PREFIX)autocomplete_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)download_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)history_s.$(LIB_SUFFIX) \
|
||||
|
@ -89,6 +99,7 @@ SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)alerts_s.$(LIB_SUFFIX)
|
|||
endif
|
||||
|
||||
EXTRA_DSO_LIBS = gkgfx
|
||||
endif # MOZ_PHOENIX
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(LIBS_DIR) \
|
||||
|
@ -98,4 +109,9 @@ EXTRA_DSO_LDOPTS += \
|
|||
$(MOZ_JS_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)appleevents_s.$(LIB_SUFFIX)
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -36,7 +36,12 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsAppStartup.h"
|
||||
#include "nsUserInfo.h"
|
||||
#include "nsCommandLineService.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
#ifdef XP_WIN
|
||||
#include "nsAlertsService.h"
|
||||
#endif
|
||||
|
@ -51,9 +56,15 @@
|
|||
#include "nsGlobalHistory.h"
|
||||
#include "nsPasswordManager.h"
|
||||
#include "nsSingleSignonPrompt.h"
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAppStartup, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUserInfo)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCmdLineService)
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
#ifdef XP_WIN
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAlertsService)
|
||||
#endif
|
||||
|
@ -66,20 +77,39 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsFormFillController)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGlobalHistory, Init)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPasswordManager, nsPasswordManager::GetInstance)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSingleSignonPrompt)
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//// Module Destructor
|
||||
|
||||
static void PR_CALLBACK nsToolkitCompModuleDtor(nsIModule* self)
|
||||
{
|
||||
#ifdef MOZ_PHOENIX
|
||||
nsFormHistory::ReleaseInstance();
|
||||
nsPasswordManager::Shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "App Startup Service",
|
||||
NS_TOOLKIT_APPSTARTUP_CID,
|
||||
NS_APPSTARTUP_CONTRACTID,
|
||||
nsAppStartupConstructor },
|
||||
|
||||
{ "User Info Service",
|
||||
NS_USERINFO_CID,
|
||||
NS_USERINFO_CONTRACTID,
|
||||
nsUserInfoConstructor },
|
||||
|
||||
{ "Command Line Service",
|
||||
NS_COMMANDLINESERVICE_CID,
|
||||
NS_COMMANDLINESERVICE_CONTRACTID,
|
||||
nsCmdLineServiceConstructor },
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
#ifdef XP_WIN
|
||||
{ "Alerts Service",
|
||||
NS_ALERTSSERVICE_CID,
|
||||
|
@ -147,6 +177,7 @@ static const nsModuleComponentInfo components[] =
|
|||
NS_SINGLE_SIGNON_PROMPT_CID,
|
||||
"@mozilla.org/wallet/single-sign-on-prompt;1",
|
||||
nsSingleSignonPromptConstructor },
|
||||
#endif
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_DTOR(nsToolkitCompsModule, components, nsToolkitCompModuleDtor)
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla Seamonkey bootstrap code.
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,57 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla Seamonkey bootstrap code.
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
# note: everything depends on appcomps, so to avoid confusion these IDL files are
|
||||
# exported there, not toolkitcomps, which would be more logical
|
||||
MODULE = appcomps
|
||||
XPIDL_MODULE = appstartup
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIAppStartup.idl \
|
||||
nsICloseAllWindows.idl \
|
||||
nsICmdLineHandler.idl \
|
||||
nsICmdLineService.idl \
|
||||
nsIUserInfo.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,95 @@
|
|||
/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, copied from
|
||||
* xpfe/appshell/public/nsIAppShellService.idl
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* 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 MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsICmdLineService;
|
||||
|
||||
[scriptable, uuid(7877c9eb-ec6c-4214-9b59-48ee78f09eb9)]
|
||||
interface nsIAppStartup : nsISupports
|
||||
{
|
||||
/**
|
||||
* Create the hidden window.
|
||||
*/
|
||||
void createHiddenWindow();
|
||||
|
||||
/**
|
||||
* Runs an application event loop: normally the main event pump which
|
||||
* defines the lifetime of the application.
|
||||
*/
|
||||
void run();
|
||||
|
||||
/**
|
||||
* During application startup (and at other times!) we may temporarily
|
||||
* encounter a situation where all application windows will be closed
|
||||
* but we don't want to take this as a signal to quit the app. Bracket
|
||||
* the code where the last window could close with these.
|
||||
* (And at application startup, on platforms that don't normally quit
|
||||
* when the last window has closed, call Enter once, but not Exit)
|
||||
*/
|
||||
void enterLastWindowClosingSurvivalArea();
|
||||
void exitLastWindowClosingSurvivalArea();
|
||||
|
||||
const PRUint32 eConsiderQuit = 1; // attempt to quit if all windows are closed
|
||||
const PRUint32 eAttemptQuit = 2; // try to close all windows, then quit if successful
|
||||
const PRUint32 eForceQuit = 3; // quit, damnit
|
||||
|
||||
/**
|
||||
* Exit the event loop, shut down the app
|
||||
*/
|
||||
void quit(in PRUint32 aFerocity);
|
||||
|
||||
/**
|
||||
* Creates the initial state of the application by launching tasks
|
||||
* specfied by "general.startup.*" prefs.
|
||||
* @param aWindowWidth the width to make the initial window(s) opened
|
||||
* @param aWindowHeight the height to make the initial window(s) opened
|
||||
* @note SIZE_TO_CONTENT may be used for width or height.
|
||||
* @return TRUE if a window was opened
|
||||
*/
|
||||
boolean createStartupState(in long aWindowWidth, in long aWindowHeight);
|
||||
|
||||
/**
|
||||
* Ensures that at least one window exists after creating the startup state.
|
||||
* If one has not been made, this will create a browser window.
|
||||
*
|
||||
* @param aCmdLineService the command line from which startup args
|
||||
* can be read.
|
||||
*/
|
||||
void ensure1Window(in nsICmdLineService aCmdLineService);
|
||||
};
|
|
@ -20,10 +20,11 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Conrad Carlen <ccarlen@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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"),
|
||||
* 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
|
||||
|
@ -35,22 +36,15 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsWindowCreator_h_
|
||||
#define __nsWindowCreator_h_
|
||||
#include "nsISupports.idl"
|
||||
|
||||
#include "nsIWindowCreator2.h"
|
||||
|
||||
class nsWindowCreator :
|
||||
public nsIWindowCreator2
|
||||
[scriptable, uuid(2f977d49-5485-11d4-87e2-0010a4e75ef2)]
|
||||
interface nsICloseAllWindows : nsISupports
|
||||
{
|
||||
public:
|
||||
nsWindowCreator();
|
||||
virtual ~nsWindowCreator();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWCREATOR
|
||||
NS_DECL_NSIWINDOWCREATOR2
|
||||
/**
|
||||
* Closes all open windows, optionally asking to confirm changes if any.
|
||||
* @return TRUE if the user does not cancel from any confirmation dialog.
|
||||
*/
|
||||
boolean closeAll(in boolean askSave);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
/* -*- 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):
|
||||
* Seth Spitzer <sspitzer@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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
%{C++
|
||||
|
||||
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
|
||||
#define PREF_STARTUP_PREFIX "general.startup."
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
struct nsModuleComponentInfo; // forward declaration
|
||||
|
||||
#define CMDLINEHANDLER_REGISTERPROC_DECLS \
|
||||
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info); \
|
||||
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info);
|
||||
|
||||
#define CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args)\
|
||||
NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \
|
||||
{ \
|
||||
if (!aDefaultArgs) return NS_ERROR_FAILURE; \
|
||||
*aDefaultArgs = ToNewUnicode(nsDependentCString(macro_default_args)); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define CMDLINEHANDLER_GETCHROMEURL_IMPL(macro_class,macro_chrome_url)\
|
||||
NS_IMETHODIMP macro_class::GetChromeUrlForTask(char **aChromeUrlForTask) \
|
||||
{ \
|
||||
if (!aChromeUrlForTask) return NS_ERROR_FAILURE; \
|
||||
*aChromeUrlForTask = PL_strdup(macro_chrome_url); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_help_text, macro_handles_args, macro_open_window_with_args)\
|
||||
NS_IMETHODIMP macro_class::GetCommandLineArgument(char **aCommandLineArgument) \
|
||||
{ \
|
||||
if (!aCommandLineArgument) return NS_ERROR_FAILURE; \
|
||||
*aCommandLineArgument = PL_strdup(macro_cmd_line_arg); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP macro_class::GetPrefNameForStartup(char **aPrefNameForStartup) \
|
||||
{ \
|
||||
if (!aPrefNameForStartup) return NS_ERROR_FAILURE; \
|
||||
*aPrefNameForStartup = PL_strdup(macro_pref_name); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP macro_class::GetHelpText(char **aHelpText) \
|
||||
{ \
|
||||
if (!aHelpText) return NS_ERROR_FAILURE; \
|
||||
*aHelpText = PL_strdup(macro_help_text); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP macro_class::GetHandlesArgs(PRBool *aHandlesArgs) \
|
||||
{ \
|
||||
if (!aHandlesArgs) return NS_ERROR_FAILURE; \
|
||||
*aHandlesArgs = macro_handles_args; \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP macro_class::GetOpenWindowWithArgs(PRBool *aOpenWindowWithArgs) \
|
||||
{ \
|
||||
if (!aOpenWindowWithArgs) return NS_ERROR_FAILURE; \
|
||||
*aOpenWindowWithArgs = macro_open_window_with_args; \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define CMDLINEHANDLER_REGISTERPROC_IMPL(macro_class, \
|
||||
macro_pretty_name, \
|
||||
macro_contractid) \
|
||||
NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info) \
|
||||
{ \
|
||||
nsresult rv; \
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("@mozilla.org/categorymanager;1", &rv); \
|
||||
if (NS_FAILED(rv)) return rv; \
|
||||
nsXPIDLCString prevEntry; \
|
||||
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_pretty_name, macro_contractid, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info) \
|
||||
{ \
|
||||
nsresult rv; \
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("@mozilla.org/categorymanager;1", &rv); \
|
||||
if (NS_FAILED(rv)) return rv; \
|
||||
rv = catman->DeleteCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_contractid, PR_TRUE); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
// basic definition
|
||||
#define CMDLINEHANDLER1_IMPL(macro_class, \
|
||||
macro_cmd_line_arg, \
|
||||
macro_pref_name, \
|
||||
macro_help_text, \
|
||||
macro_handles_args, \
|
||||
macro_default_args, \
|
||||
macro_open_window_with_args)\
|
||||
CMDLINEHANDLER_OTHERS_IMPL(macro_class, macro_cmd_line_arg,macro_pref_name,\
|
||||
macro_help_text, macro_handles_args, \
|
||||
macro_open_window_with_args)
|
||||
|
||||
// provides everything above, plus GetChromeUrl and regproc stuff
|
||||
#define CMDLINEHANDLER2_IMPL(macro_class, \
|
||||
macro_cmd_line_arg, \
|
||||
macro_pref_name, \
|
||||
macro_chrome_url, \
|
||||
macro_help_text, \
|
||||
macro_contractid, \
|
||||
macro_pretty_name, \
|
||||
macro_handles_args, \
|
||||
macro_open_window_with_args) \
|
||||
CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,\
|
||||
macro_help_text, macro_handles_args, \
|
||||
macro_open_window_with_args) \
|
||||
CMDLINEHANDLER_REGISTERPROC_IMPL(macro_class, macro_pretty_name, \
|
||||
macro_contractid) \
|
||||
CMDLINEHANDLER_GETCHROMEURL_IMPL(macro_class,macro_chrome_url)
|
||||
|
||||
// deprecated: includes everything above, plus getdefaultargs
|
||||
#define CMDLINEHANDLER_IMPL(macro_class, \
|
||||
macro_cmd_line_arg,\
|
||||
macro_pref_name, \
|
||||
macro_chrome_url,\
|
||||
macro_help_text, \
|
||||
macro_contractid, \
|
||||
macro_pretty_name, \
|
||||
macro_handles_args, \
|
||||
macro_default_args, \
|
||||
macro_open_window_with_args) \
|
||||
CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args) \
|
||||
CMDLINEHANDLER2_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name, \
|
||||
macro_chrome_url,macro_help_text, macro_contractid, \
|
||||
macro_pretty_name, macro_handles_args, \
|
||||
macro_open_window_with_args)
|
||||
|
||||
//Creates a version without the GetChromeUrlForTaskFunction
|
||||
#define CMDLINEHANDLER3_IMPL(macro_class, \
|
||||
macro_cmd_line_arg, \
|
||||
macro_pref_name, \
|
||||
macro_help_text, \
|
||||
macro_contractid, \
|
||||
macro_pretty_name, \
|
||||
macro_handles_args, \
|
||||
macro_default_args, \
|
||||
macro_open_window_with_args)\
|
||||
CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args)\
|
||||
CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,\
|
||||
macro_help_text, macro_handles_args, \
|
||||
macro_open_window_with_args) \
|
||||
CMDLINEHANDLER_REGISTERPROC_IMPL(macro_class, macro_pretty_name, \
|
||||
macro_contractid)
|
||||
|
||||
%}
|
||||
|
||||
[scriptable, uuid(54e1a910-c064-4756-b1d3-82c6b2e0be24)]
|
||||
interface nsICmdLineHandler : nsISupports
|
||||
{
|
||||
readonly attribute string commandLineArgument;
|
||||
readonly attribute string prefNameForStartup;
|
||||
readonly attribute string chromeUrlForTask;
|
||||
readonly attribute string helpText;
|
||||
|
||||
readonly attribute boolean handlesArgs;
|
||||
readonly attribute wstring defaultArgs;
|
||||
readonly attribute boolean openWindowWithArgs;
|
||||
};
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** 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 "nsISupports.idl"
|
||||
#include "nsIFactory.idl"
|
||||
#include "nsICmdLineHandler.idl"
|
||||
|
||||
[ptr] native charArray(char*);
|
||||
[scriptable, uuid(e34783f4-ac08-11d2-8d19-00805fc2500c)]
|
||||
interface nsICmdLineService : nsISupports
|
||||
{
|
||||
/**
|
||||
* initialize
|
||||
* Used to pass the original argv/argc from main()
|
||||
* Warning: This will hold a reference to the original argv
|
||||
* passed into Initialze();
|
||||
*/
|
||||
[noscript] void initialize(in long argc, out string argv);
|
||||
|
||||
/**
|
||||
* getCmdLineValue
|
||||
* returns the 2nd parameter, if any, to the parameter passed in
|
||||
* For example, getCmdLineValue "-edit" will return any url that
|
||||
* came after the -edit parameter
|
||||
*/
|
||||
string getCmdLineValue(in string argv);
|
||||
|
||||
/**
|
||||
* URLToLoad
|
||||
* The URL to load as passed to the command line
|
||||
*/
|
||||
readonly attribute string URLToLoad;
|
||||
|
||||
/**
|
||||
* programName
|
||||
*
|
||||
*/
|
||||
readonly attribute string programName;
|
||||
|
||||
/**
|
||||
* argc
|
||||
* The number of parameters passed in on the command line
|
||||
*/
|
||||
readonly attribute long argc;
|
||||
|
||||
/**
|
||||
* argv
|
||||
* returns a direct reference to the parameter array passed in
|
||||
* to initialize() - do NOT dereference this array!
|
||||
*/
|
||||
[noscript] readonly attribute charArray argv;
|
||||
|
||||
/**
|
||||
* Get the command line handler for the given parameter
|
||||
* @param param - can be any parameter, with or without leading
|
||||
* "-" such as "-mail" or "edit" - Pass in a null
|
||||
* string if you want the "default" handler
|
||||
*/
|
||||
nsICmdLineHandler getHandlerForParam(in string param);
|
||||
};
|
|
@ -0,0 +1,65 @@
|
|||
/* -*- 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):
|
||||
* Seth Spitzer <sspitzer@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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(6c1034f0-1dd2-11b2-aa14-e6657ed7bb0b)]
|
||||
interface nsIUserInfo : nsISupports
|
||||
{
|
||||
/* these are things the system may know about the current user */
|
||||
|
||||
readonly attribute wstring fullname;
|
||||
|
||||
readonly attribute string emailAddress;
|
||||
|
||||
/* should this be a wstring? */
|
||||
readonly attribute string username;
|
||||
|
||||
readonly attribute string domain;
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
// 14c13684-1dd2-11b2-9463-bb10ba742554
|
||||
#define NS_USERINFO_CID \
|
||||
{ 0x14c13684, 0x1dd2, 0x11b2, \
|
||||
{0x94, 0x63, 0xbb, 0x10, 0xba, 0x74, 0x25, 0x54}}
|
||||
|
||||
#define NS_USERINFO_CONTRACTID "@mozilla.org/userinfo;1"
|
||||
|
||||
%}
|
|
@ -0,0 +1,98 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla Seamonkey bootstrap code.
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = toolkitcomps
|
||||
LIBRARY_NAME = appstartup_s
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
js \
|
||||
widget \
|
||||
appshell \
|
||||
appcomps \
|
||||
docshell \
|
||||
exthandler \
|
||||
webshell \
|
||||
dom \
|
||||
necko \
|
||||
pref \
|
||||
profile \
|
||||
embed_base \
|
||||
webbrwsr \
|
||||
windowwatcher \
|
||||
intl \
|
||||
util \
|
||||
uconv \
|
||||
xulapp \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsAppStartup.cpp \
|
||||
nsCommandLineService.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq (os2,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += nsUserInfoOS2.cpp
|
||||
else
|
||||
ifeq (WINNT,$(OS_ARCH))
|
||||
CPPSRCS += nsUserInfoWin.cpp
|
||||
else
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS += \
|
||||
nsUserInfoMac.cpp \
|
||||
nsCommandLineServiceMac.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/xpfe/bootstrap/appleevents
|
||||
OS_CXXFLAGS += -fexceptions
|
||||
else
|
||||
CPPSRCS += nsUserInfoUnix.cpp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_COMPONENTS = nsCloseAllWindows.js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,828 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code. This file was split
|
||||
* from xpfe/appshell/src/nsAppShellService.cpp
|
||||
*
|
||||
* 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):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Robert O'Callahan <roc+moz@cs.cmu.edu>
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAppStartup.h"
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICloseAllWindows.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIProfileChangeStatus.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIXULWindow.h"
|
||||
|
||||
#include "prprf.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsAppShellCID.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
// Static Function Prototypes
|
||||
static nsresult ConvertToUnicode(nsCString& aCharset, const char* inString, nsAString& outString);
|
||||
|
||||
//
|
||||
// nsAppStartup
|
||||
//
|
||||
|
||||
nsAppStartup::nsAppStartup() :
|
||||
mConsiderQuitStopper(0),
|
||||
mShuttingDown(PR_FALSE),
|
||||
mAttemptingQuit(PR_FALSE)
|
||||
{ }
|
||||
|
||||
|
||||
nsresult
|
||||
nsAppStartup::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Create widget application shell
|
||||
mAppShell = do_CreateInstance(kAppShellCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineService
|
||||
(do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 argc = 0;
|
||||
char** argv = nsnull;
|
||||
cmdLineService->GetArgc(&argc);
|
||||
cmdLineService->GetArgv(&argv);
|
||||
|
||||
rv = mAppShell->Create(&argc, argv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// listen to EventQueues' comings and goings. do this after the appshell
|
||||
// has been created, but after the event queue has been created. that
|
||||
// latter bit is unfortunate, but we deal with it.
|
||||
nsCOMPtr<nsIObserverService> os
|
||||
(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
os->AddObserver(this, "nsIEventQueueActivated", PR_TRUE);
|
||||
os->AddObserver(this, "nsIEventQueueDestroyed", PR_TRUE);
|
||||
os->AddObserver(this, "profile-change-teardown", PR_TRUE);
|
||||
os->AddObserver(this, "profile-initial-state", PR_TRUE);
|
||||
os->AddObserver(this, "xul-window-registered", PR_TRUE);
|
||||
os->AddObserver(this, "xul-window-destroyed", PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsAppStartup->nsISupports
|
||||
//
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS5(nsAppStartup,
|
||||
nsIAppStartup,
|
||||
nsIWindowCreator,
|
||||
nsIWindowCreator2,
|
||||
nsIObserver,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
|
||||
//
|
||||
// nsAppStartup->nsIAppStartup
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::CreateHiddenWindow()
|
||||
{
|
||||
nsCOMPtr<nsIAppShellService> appShellService
|
||||
(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(appShellService, NS_ERROR_FAILURE);
|
||||
|
||||
return appShellService->CreateHiddenWindow(mAppShell);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::Run(void)
|
||||
{
|
||||
return mAppShell->Run();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::Quit(PRUint32 aFerocity)
|
||||
{
|
||||
// Quit the application. We will asynchronously call the appshell's
|
||||
// Exit() method via the ExitCallback() to allow one last pass
|
||||
// through any events in the queue. This guarantees a tidy cleanup.
|
||||
nsresult rv = NS_OK;
|
||||
PRBool postedExitEvent = PR_FALSE;
|
||||
|
||||
if (mShuttingDown)
|
||||
return NS_OK;
|
||||
|
||||
/* eForceQuit doesn't actually work; it can cause a subtle crash if
|
||||
there are windows open which have unload handlers which open
|
||||
new windows. Use eAttemptQuit for now. */
|
||||
if (aFerocity == eForceQuit) {
|
||||
NS_WARNING("attempted to force quit");
|
||||
// it will be treated the same as eAttemptQuit, below
|
||||
}
|
||||
|
||||
mShuttingDown = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIWindowMediator> mediator
|
||||
(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
|
||||
|
||||
if (aFerocity == eConsiderQuit && mConsiderQuitStopper == 0) {
|
||||
// attempt quit if the last window has been unregistered/closed
|
||||
|
||||
PRBool windowsRemain = PR_TRUE;
|
||||
|
||||
if (mediator) {
|
||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||
mediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator));
|
||||
if (windowEnumerator)
|
||||
windowEnumerator->HasMoreElements(&windowsRemain);
|
||||
}
|
||||
if (!windowsRemain) {
|
||||
aFerocity = eAttemptQuit;
|
||||
}
|
||||
}
|
||||
|
||||
/* Currently aFerocity can never have the value of eForceQuit here.
|
||||
That's temporary (in an unscheduled kind of way) and logically
|
||||
this code is part of the eForceQuit case, so I'm checking against
|
||||
that value anyway. Reviewers made me add this comment. */
|
||||
if (aFerocity == eAttemptQuit || aFerocity == eForceQuit) {
|
||||
|
||||
AttemptingQuit(PR_TRUE);
|
||||
|
||||
/* Enumerate through each open window and close it. It's important to do
|
||||
this before we forcequit because this can control whether we really quit
|
||||
at all. e.g. if one of these windows has an unload handler that
|
||||
opens a new window. Ugh. I know. */
|
||||
if (mediator) {
|
||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||
|
||||
mediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator));
|
||||
|
||||
if (windowEnumerator) {
|
||||
|
||||
while (1) {
|
||||
PRBool more;
|
||||
if (NS_FAILED(rv = windowEnumerator->HasMoreElements(&more)) || !more)
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsISupports> isupports;
|
||||
rv = windowEnumerator->GetNext(getter_AddRefs(isupports));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(isupports);
|
||||
NS_ASSERTION(window, "not an nsIDOMWindowInternal");
|
||||
if (!window)
|
||||
continue;
|
||||
|
||||
window->Close();
|
||||
}
|
||||
}
|
||||
|
||||
if (aFerocity == eAttemptQuit) {
|
||||
|
||||
aFerocity = eForceQuit; // assume success
|
||||
|
||||
/* Were we able to immediately close all windows? if not, eAttemptQuit
|
||||
failed. This could happen for a variety of reasons; in fact it's
|
||||
very likely. Perhaps we're being called from JS and the window->Close
|
||||
method hasn't had a chance to wrap itself up yet. So give up.
|
||||
We'll return (with eConsiderQuit) as the remaining windows are
|
||||
closed. */
|
||||
mediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator));
|
||||
if (windowEnumerator) {
|
||||
PRBool more;
|
||||
while (windowEnumerator->HasMoreElements(&more), more) {
|
||||
/* we can't quit immediately. we'll try again as the last window
|
||||
finally closes. */
|
||||
aFerocity = eAttemptQuit;
|
||||
nsCOMPtr<nsISupports> window;
|
||||
windowEnumerator->GetNext(getter_AddRefs(window));
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWindow(do_QueryInterface(window));
|
||||
if (domWindow) {
|
||||
PRBool closed = PR_FALSE;
|
||||
domWindow->GetClosed(&closed);
|
||||
if (!closed) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aFerocity == eForceQuit) {
|
||||
// do it!
|
||||
|
||||
// No chance of the shutdown being cancelled from here on; tell people
|
||||
// we're shutting down for sure while all services are still available.
|
||||
nsCOMPtr<nsIObserverService> obsService
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
if (obsService)
|
||||
obsService->NotifyObservers(nsnull, "quit-application", nsnull);
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService
|
||||
(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
NS_ASSERTION(appShellService, "We're gonna leak something.");
|
||||
if (appShellService)
|
||||
appShellService->DestroyHiddenWindow();
|
||||
|
||||
// no matter what, make sure we send the exit event. If
|
||||
// worst comes to worst, we'll do a leaky shutdown but we WILL
|
||||
// shut down. Well, assuming that all *this* stuff works ;-).
|
||||
nsCOMPtr<nsIEventQueueService> svc = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
nsCOMPtr<nsIEventQueue> queue;
|
||||
rv = svc->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
PLEvent* event = new PLEvent;
|
||||
if (event) {
|
||||
NS_ADDREF_THIS();
|
||||
PL_InitEvent(event,
|
||||
this,
|
||||
HandleExitEvent,
|
||||
DestroyExitEvent);
|
||||
|
||||
rv = queue->PostEvent(event);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
postedExitEvent = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
PL_DestroyEvent(event);
|
||||
}
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// turn off the reentrancy check flag, but not if we have
|
||||
// more asynchronous work to do still.
|
||||
if (!postedExitEvent)
|
||||
mShuttingDown = PR_FALSE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/* We know we're trying to quit the app, but may not be able to do so
|
||||
immediately. Enter a state where we're more ready to quit.
|
||||
(Does useful work only on the Mac.) */
|
||||
void
|
||||
nsAppStartup::AttemptingQuit(PRBool aAttempt)
|
||||
{
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
if (aAttempt) {
|
||||
// now even the Mac wants to quit when the last window is closed
|
||||
if (!mAttemptingQuit)
|
||||
ExitLastWindowClosingSurvivalArea();
|
||||
mAttemptingQuit = PR_TRUE;
|
||||
} else {
|
||||
// changed our mind. back to normal.
|
||||
if (mAttemptingQuit)
|
||||
EnterLastWindowClosingSurvivalArea();
|
||||
mAttemptingQuit = PR_FALSE;
|
||||
}
|
||||
#else
|
||||
mAttemptingQuit = aAttempt;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::EnterLastWindowClosingSurvivalArea(void)
|
||||
{
|
||||
++mConsiderQuitStopper;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::ExitLastWindowClosingSurvivalArea(void)
|
||||
{
|
||||
NS_ASSERTION(mConsiderQuitStopper > 0, "consider quit stopper out of bounds");
|
||||
--mConsiderQuitStopper;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::CreateStartupState(PRInt32 aWindowWidth, PRInt32 aWindowHeight,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
nsresult rv;
|
||||
|
||||
#ifndef MOZ_THUNDERBIRD // xxxbsmedberg: more ifdef badness!
|
||||
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (!prefService)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPrefBranch> startupBranch;
|
||||
prefService->GetBranch(PREF_STARTUP_PREFIX, getter_AddRefs(startupBranch));
|
||||
if (!startupBranch)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 childCount;
|
||||
char **childArray = nsnull;
|
||||
rv = startupBranch->GetChildList("", &childCount, &childArray);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
PRBool prefValue;
|
||||
startupBranch->GetBoolPref(childArray[i], &prefValue);
|
||||
if (prefValue) {
|
||||
PRBool windowOpened;
|
||||
rv = LaunchTask(childArray[i], aWindowHeight, aWindowWidth, &windowOpened);
|
||||
if (NS_SUCCEEDED(rv) && windowOpened)
|
||||
*_retval = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(childCount, childArray);
|
||||
#else
|
||||
PRBool windowOpened;
|
||||
rv = LaunchTask("mail", aWindowHeight, aWindowWidth, &windowOpened);
|
||||
if (NS_SUCCEEDED(rv) && windowOpened)
|
||||
*_retval = PR_TRUE;
|
||||
else
|
||||
*_retval = PR_FALSE;
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::Ensure1Window(nsICmdLineService *aCmdLineService)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator
|
||||
(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator))))
|
||||
{
|
||||
PRBool more;
|
||||
windowEnumerator->HasMoreElements(&more);
|
||||
if (!more)
|
||||
{
|
||||
// No window exists so lets create a browser one
|
||||
PRInt32 height = nsIAppShellService::SIZE_TO_CONTENT;
|
||||
PRInt32 width = nsIAppShellService::SIZE_TO_CONTENT;
|
||||
|
||||
// Get the value of -width option
|
||||
nsXPIDLCString tempString;
|
||||
rv = aCmdLineService->GetCmdLineValue("-width", getter_Copies(tempString));
|
||||
if (NS_SUCCEEDED(rv) && !tempString.IsEmpty())
|
||||
PR_sscanf(tempString.get(), "%d", &width);
|
||||
|
||||
|
||||
// Get the value of -height option
|
||||
rv = aCmdLineService->GetCmdLineValue("-height", getter_Copies(tempString));
|
||||
if (NS_SUCCEEDED(rv) && !tempString.IsEmpty())
|
||||
PR_sscanf(tempString.get(), "%d", &height);
|
||||
|
||||
#ifdef MOZ_THUNDERBIRD // XXXbsmedberg more badness, needs NVU thought
|
||||
PRBool windowOpened = PR_FALSE;
|
||||
|
||||
rv = LaunchTask(NULL, height, width, &windowOpened);
|
||||
|
||||
if (NS_FAILED(rv) || !windowOpened)
|
||||
rv = LaunchTask("mail", height, width, &windowOpened);
|
||||
#else
|
||||
rv = OpenBrowserWindow(height, width);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
void* PR_CALLBACK
|
||||
nsAppStartup::HandleExitEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsAppStartup *service =
|
||||
NS_REINTERPRET_CAST(nsAppStartup*, aEvent->owner);
|
||||
|
||||
// Tell the appshell to exit
|
||||
service->mAppShell->Exit();
|
||||
|
||||
// We're done "shutting down".
|
||||
service->mShuttingDown = PR_FALSE;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void PR_CALLBACK
|
||||
nsAppStartup::DestroyExitEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsAppStartup *service =
|
||||
NS_REINTERPRET_CAST(nsAppStartup*, aEvent->owner);
|
||||
NS_RELEASE(service);
|
||||
delete aEvent;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsAppStartup::LaunchTask(const char *aParam, PRInt32 height, PRInt32 width, PRBool *windowOpened)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr <nsICmdLineService> cmdLine =
|
||||
do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr <nsICmdLineHandler> handler;
|
||||
rv = cmdLine->GetHandlerForParam(aParam, getter_AddRefs(handler));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString chromeUrlForTask;
|
||||
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRBool handlesArgs = PR_FALSE;
|
||||
rv = handler->GetHandlesArgs(&handlesArgs);
|
||||
if (handlesArgs) {
|
||||
#ifndef MOZ_THUNDERBIRD //XXXbsmedberg bad toolkit->app dependency!
|
||||
nsXPIDLString defaultArgs;
|
||||
rv = handler->GetDefaultArgs(getter_Copies(defaultArgs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = OpenWindow(chromeUrlForTask, defaultArgs,
|
||||
nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT);
|
||||
#else
|
||||
// XXX horibble thunderbird hack. Don't pass in the default args if the
|
||||
// cmd line service says we have real arguments! Use those instead.
|
||||
nsXPIDLCString args;
|
||||
nsXPIDLCString cmdLineArgument; // -mail, -compose, etc.
|
||||
rv = handler->GetCommandLineArgument(getter_Copies(cmdLineArgument));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = cmdLine->GetCmdLineValue(cmdLineArgument, getter_Copies(args));
|
||||
if (NS_SUCCEEDED(rv) && args.get() && strcmp(args.get(), "1")) {
|
||||
nsAutoString cmdArgs; cmdArgs.AssignWithConversion(args);
|
||||
rv = OpenWindow(chromeUrlForTask, cmdArgs, height, width);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// any failure case, do what we used to do:
|
||||
if (NS_FAILED(rv)) {
|
||||
nsXPIDLString defaultArgs;
|
||||
rv = handler->GetDefaultArgs(getter_Copies(defaultArgs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = OpenWindow(chromeUrlForTask, defaultArgs,
|
||||
nsIAppShellService::SIZE_TO_CONTENT, nsIAppShellService::SIZE_TO_CONTENT);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
rv = OpenWindow(chromeUrlForTask, nsString(), width, height);
|
||||
}
|
||||
|
||||
// If we get here without an error, then a window was opened OK.
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*windowOpened = PR_TRUE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAppStartup::OpenWindow(const nsAFlatCString& aChromeURL,
|
||||
const nsAFlatString& aAppArgs,
|
||||
PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsString> sarg(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
|
||||
if (!wwatch || !sarg)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
sarg->SetData(aAppArgs);
|
||||
|
||||
nsCAutoString features("chrome,dialog=no,all");
|
||||
if (aHeight != nsIAppShellService::SIZE_TO_CONTENT) {
|
||||
features.Append(",height=");
|
||||
features.AppendInt(aHeight);
|
||||
}
|
||||
if (aWidth != nsIAppShellService::SIZE_TO_CONTENT) {
|
||||
features.Append(",width=");
|
||||
features.AppendInt(aWidth);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
return wwatch->OpenWindow(0, aChromeURL.get(), "_blank",
|
||||
features.get(), sarg,
|
||||
getter_AddRefs(newWindow));
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsAppStartup::OpenBrowserWindow(PRInt32 height, PRInt32 width)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICmdLineHandler> handler(do_GetService("@mozilla.org/commandlinehandler/general-startup;1?type=browser", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString chromeUrlForTask;
|
||||
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr <nsICmdLineService> cmdLine = do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString urlToLoad;
|
||||
rv = cmdLine->GetURLToLoad(getter_Copies(urlToLoad));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!urlToLoad.IsEmpty()) {
|
||||
|
||||
#ifdef DEBUG_CMD_LINE
|
||||
printf("url to load: %s\n", urlToLoad.get());
|
||||
#endif /* DEBUG_CMD_LINE */
|
||||
|
||||
nsAutoString url;
|
||||
if (nsCRT::IsAscii(urlToLoad)) {
|
||||
url.AssignWithConversion(urlToLoad);
|
||||
}
|
||||
else {
|
||||
// get a platform charset
|
||||
nsCAutoString charSet;
|
||||
nsCOMPtr <nsIPlatformCharset> platformCharset(do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(0, "Failed to get a platform charset");
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, charSet);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(0, "Failed to get a charset");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// convert the cmdLine URL to Unicode
|
||||
rv = ConvertToUnicode(charSet, urlToLoad, url);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(0, "Failed to convert commandline url to unicode");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
rv = OpenWindow(chromeUrlForTask, url, width, height);
|
||||
|
||||
} else {
|
||||
|
||||
nsXPIDLString defaultArgs;
|
||||
rv = handler->GetDefaultArgs(getter_Copies(defaultArgs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef DEBUG_CMD_LINE
|
||||
printf("default args: %s\n", NS_ConvertUCS2toUTF8(defaultArgs).get());
|
||||
#endif /* DEBUG_CMD_LINE */
|
||||
|
||||
rv = OpenWindow(chromeUrlForTask, defaultArgs, width, height);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsAppStartup->nsIWindowCreator
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
PRBool cancel;
|
||||
return CreateChromeWindow2(aParent, aChromeFlags, 0, 0, &cancel, _retval);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsAppStartup->nsIWindowCreator2
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::CreateChromeWindow2(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
PRUint32 aContextFlags,
|
||||
nsIURI *aURI,
|
||||
PRBool *aCancel,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCancel);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*aCancel = PR_FALSE;
|
||||
*_retval = 0;
|
||||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
|
||||
if (aParent) {
|
||||
nsCOMPtr<nsIXULWindow> xulParent(do_GetInterface(aParent));
|
||||
NS_ASSERTION(xulParent, "window created using non-XUL parent. that's unexpected, but may work.");
|
||||
|
||||
if (xulParent)
|
||||
xulParent->CreateNewWindow(aChromeFlags, mAppShell, getter_AddRefs(newWindow));
|
||||
// And if it fails, don't try again without a parent. It could fail
|
||||
// intentionally (bug 115969).
|
||||
} else { // try using basic methods:
|
||||
/* You really shouldn't be making dependent windows without a parent.
|
||||
But unparented modal (and therefore dependent) windows happen
|
||||
in our codebase, so we allow it after some bellyaching: */
|
||||
if (aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT)
|
||||
NS_WARNING("dependent window created without a parent");
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
if (!appShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
appShell->CreateTopLevelWindow(0, 0, PR_FALSE, PR_FALSE,
|
||||
aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT, mAppShell, getter_AddRefs(newWindow));
|
||||
}
|
||||
|
||||
// if anybody gave us anything to work with, use it
|
||||
if (newWindow) {
|
||||
newWindow->SetContextFlags(aContextFlags);
|
||||
nsCOMPtr<nsIInterfaceRequestor> thing(do_QueryInterface(newWindow));
|
||||
if (thing)
|
||||
CallGetInterface(thing.get(), _retval);
|
||||
}
|
||||
|
||||
return *_retval ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsAppStartup->nsIObserver
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::Observe(nsISupports *aSubject,
|
||||
const char *aTopic, const PRUnichar *aData)
|
||||
{
|
||||
NS_ASSERTION(mAppShell, "appshell service notified before appshell built");
|
||||
if (!strcmp(aTopic, "nsIEventQueueActivated")) {
|
||||
nsCOMPtr<nsIEventQueue> eq(do_QueryInterface(aSubject));
|
||||
if (eq) {
|
||||
PRBool isNative = PR_TRUE;
|
||||
// we only add native event queues to the appshell
|
||||
eq->IsQueueNative(&isNative);
|
||||
if (isNative)
|
||||
mAppShell->ListenToEventQueue(eq, PR_TRUE);
|
||||
}
|
||||
} else if (!strcmp(aTopic, "nsIEventQueueDestroyed")) {
|
||||
nsCOMPtr<nsIEventQueue> eq(do_QueryInterface(aSubject));
|
||||
if (eq) {
|
||||
PRBool isNative = PR_TRUE;
|
||||
// we only remove native event queues from the appshell
|
||||
eq->IsQueueNative(&isNative);
|
||||
if (isNative)
|
||||
mAppShell->ListenToEventQueue(eq, PR_FALSE);
|
||||
}
|
||||
} else if (!strcmp(aTopic, "profile-change-teardown")) {
|
||||
nsresult rv;
|
||||
EnterLastWindowClosingSurvivalArea();
|
||||
// NOTE: No early error exits because we need to execute the
|
||||
// balancing ExitLastWindowClosingSurvivalArea().
|
||||
nsCOMPtr<nsICloseAllWindows> closer =
|
||||
do_CreateInstance("@mozilla.org/appshell/closeallwindows;1", &rv);
|
||||
NS_ASSERTION(closer, "Failed to create nsICloseAllWindows impl.");
|
||||
PRBool proceedWithSwitch = PR_FALSE;
|
||||
if (closer)
|
||||
rv = closer->CloseAll(PR_TRUE, &proceedWithSwitch);
|
||||
|
||||
if (NS_FAILED(rv) || !proceedWithSwitch) {
|
||||
nsCOMPtr<nsIProfileChangeStatus> changeStatus(do_QueryInterface(aSubject));
|
||||
if (changeStatus)
|
||||
changeStatus->VetoChange();
|
||||
}
|
||||
ExitLastWindowClosingSurvivalArea();
|
||||
} else if (!strcmp(aTopic, "profile-initial-state")) {
|
||||
if (nsDependentString(aData).Equals(NS_LITERAL_STRING("switch"))) {
|
||||
// Now, establish the startup state according to the new prefs.
|
||||
PRBool openedWindow;
|
||||
CreateStartupState(nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT, &openedWindow);
|
||||
if (!openedWindow)
|
||||
OpenBrowserWindow(nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT);
|
||||
}
|
||||
} else if (!strcmp(aTopic, "xul-window-registered")) {
|
||||
AttemptingQuit(PR_FALSE);
|
||||
} else if (!strcmp(aTopic, "xul-window-destroyed")) {
|
||||
Quit(eConsiderQuit);
|
||||
} else {
|
||||
NS_ERROR("Unexpected observer topic.");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
ConvertToUnicode(nsCString& aCharset, const char* inString, nsAString& outString)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// convert result to unicode
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm(do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID , &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr <nsIUnicodeDecoder> decoder;
|
||||
rv = ccm->GetUnicodeDecoderRaw(aCharset.get(), getter_AddRefs(decoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRInt32 uniLength = 0;
|
||||
PRInt32 srcLength = strlen(inString);
|
||||
rv = decoder->GetMaxLength(inString, srcLength, &uniLength);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRUnichar *unichars = new PRUnichar [uniLength];
|
||||
if (nsnull != unichars) {
|
||||
// convert to unicode
|
||||
rv = decoder->Convert(inString, &srcLength, unichars, &uniLength);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Pass back the unicode string
|
||||
outString.Assign(unichars, uniLength);
|
||||
}
|
||||
delete [] unichars;
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code. This file was split
|
||||
* from xpfe/appshell/src/nsAppShellService.h
|
||||
*
|
||||
* 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):
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsAppStartup_h__
|
||||
#define nsAppStartup_h__
|
||||
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIWindowCreator2.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsINativeAppSupport.h"
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
struct PLEvent;
|
||||
|
||||
// {7DD4D320-C84B-4624-8D45-7BB9B2356977}
|
||||
#define NS_TOOLKIT_APPSTARTUP_CID \
|
||||
{ 0x7dd4d320, 0xc84b, 0x4624, { 0x8d, 0x45, 0x7b, 0xb9, 0xb2, 0x35, 0x69, 0x77 } }
|
||||
|
||||
|
||||
class nsAppStartup : public nsIAppStartup,
|
||||
public nsIWindowCreator2,
|
||||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAPPSTARTUP
|
||||
NS_DECL_NSIWINDOWCREATOR
|
||||
NS_DECL_NSIWINDOWCREATOR2
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
nsAppStartup();
|
||||
nsresult Init();
|
||||
|
||||
private:
|
||||
~nsAppStartup() { }
|
||||
|
||||
void AttemptingQuit(PRBool aAttempt);
|
||||
|
||||
// A "last event" that is used to flush the appshell's event queue.
|
||||
PR_STATIC_CALLBACK(void*) HandleExitEvent(PLEvent* aEvent);
|
||||
PR_STATIC_CALLBACK(void) DestroyExitEvent(PLEvent* aEvent);
|
||||
|
||||
nsresult LaunchTask(const char* aParam,
|
||||
PRInt32 height, PRInt32 width,
|
||||
PRBool *windowOpened);
|
||||
nsresult OpenWindow(const nsAFlatCString& aChromeURL,
|
||||
const nsAFlatString& aAppArgs,
|
||||
PRInt32 aWidth, PRInt32 aHeight);
|
||||
nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width);
|
||||
|
||||
nsCOMPtr<nsIAppShell> mAppShell;
|
||||
|
||||
PRInt32 mConsiderQuitStopper; // if > 0, Quit(eConsiderQuit) fails
|
||||
PRPackedBool mShuttingDown; // Quit method reentrancy check
|
||||
PRPackedBool mAttemptingQuit; // Quit(eAttemptQuit) still trying
|
||||
};
|
||||
|
||||
#endif // nsAppStartup_h__
|
|
@ -0,0 +1,143 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Conrad Carlen <ccarlen@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 MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
/* This file implements the nsCloseAllWindows component which implements
|
||||
* the nsICloseAllWindows interface. Use this component when all
|
||||
* windows need to be closed and confirmation to save changes is required.
|
||||
*/
|
||||
|
||||
|
||||
/* ctor
|
||||
*/
|
||||
function nsCloseAllWindows() {
|
||||
}
|
||||
|
||||
nsCloseAllWindows.prototype = {
|
||||
|
||||
// This "class" supports nsICloseAllWindows, and nsISupports.
|
||||
QueryInterface: function (iid) {
|
||||
if (!iid.equals(Components.interfaces.nsICloseAllWindows) &&
|
||||
!iid.equals(Components.interfaces.nsISupports)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// ---------- nsICloseAllWindows methods ----------
|
||||
|
||||
// closeAll: Close all open windows
|
||||
closeAll: function(aAskToSave) {
|
||||
|
||||
var windowMediator = Components.classes['@mozilla.org/appshell/window-mediator;1'].
|
||||
getService(Components.interfaces.nsIWindowMediator);
|
||||
var enumerator = windowMediator.getEnumerator(null);
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
var domWindow = enumerator.getNext();
|
||||
if (aAskToSave && ("tryToClose" in domWindow)) {
|
||||
if (!domWindow.tryToClose())
|
||||
return false;
|
||||
}
|
||||
domWindow.close();
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// This Component's module implementation. All the code below is used to get this
|
||||
// component registered and accessible via XPCOM.
|
||||
var module = {
|
||||
firstTime: true,
|
||||
|
||||
// registerSelf: Register this component.
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
if (this.firstTime) {
|
||||
this.firstTime = false;
|
||||
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
||||
}
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
compMgr.registerFactoryLocation( this.cid,
|
||||
"Close All Windows",
|
||||
this.contractId,
|
||||
fileSpec,
|
||||
location,
|
||||
type );
|
||||
},
|
||||
|
||||
// getClassObject: Return this component's factory object.
|
||||
getClassObject: function (compMgr, cid, iid) {
|
||||
if (!cid.equals(this.cid)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsIFactory)) {
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return this.factory;
|
||||
},
|
||||
|
||||
/* CID for this class */
|
||||
cid: Components.ID("{2f977d48-5485-11d4-87e2-0010a4e75ef2}"),
|
||||
|
||||
/* Contract ID for this class */
|
||||
contractId: "@mozilla.org/appshell/closeallwindows;1",
|
||||
|
||||
/* factory object */
|
||||
factory: {
|
||||
// createInstance: Return a new nsCloseAllWindows object.
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return (new nsCloseAllWindows()).QueryInterface(iid);
|
||||
}
|
||||
},
|
||||
|
||||
// canUnload: n/a (returns true)
|
||||
canUnload: function(compMgr) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// NSGetModule: Return the nsIModule object.
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return module;
|
||||
}
|
|
@ -0,0 +1,397 @@
|
|||
/* -*- 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 "nsICmdLineService.h"
|
||||
#include "nsCommandLineService.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsString.h"
|
||||
#include "plstr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsNetUtil.h"
|
||||
#ifdef XP_MACOSX
|
||||
#include "nsCommandLineServiceMac.h"
|
||||
#endif
|
||||
|
||||
nsCmdLineService::nsCmdLineService()
|
||||
: mArgCount(0), mArgc(0), mArgv(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement the nsISupports methods...
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS1(nsCmdLineService, nsICmdLineService)
|
||||
|
||||
static void* ProcessURLArg(char* str)
|
||||
{
|
||||
// Problem: since the arg parsing code doesn't know which flags
|
||||
// take arguments, it always calls this method for the last
|
||||
// non-flag argument. But sometimes that argument is actually
|
||||
// the arg for the last switch, e.g. -width 500 or -Profile default.
|
||||
// nsLocalFile will only work on absolute pathnames, so return
|
||||
// if str doesn't start with '/' or '\'.
|
||||
if (str && (*str == '\\' || *str == '/'))
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), str);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> file(do_CreateInstance("@mozilla.org/file/local;1"));
|
||||
if (file)
|
||||
{
|
||||
rv = file->InitWithNativePath(nsDependentCString(str));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCAutoString fileurl;
|
||||
rv = NS_GetURLSpecFromFile(file, fileurl);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return NS_REINTERPRET_CAST(void*, ToNewCString(fileurl));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_REINTERPRET_CAST(void*, nsCRT::strdup(str));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::Initialize(int aArgc, char ** aArgv)
|
||||
{
|
||||
|
||||
|
||||
PRInt32 i=0;
|
||||
nsresult rv = nsnull;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
rv = InitializeMacCommandLine(aArgc, aArgv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Initializing AppleEvents failed");
|
||||
#endif
|
||||
|
||||
// Save aArgc and argv
|
||||
mArgc = aArgc;
|
||||
mArgv = new char*[ aArgc ];
|
||||
for(i=0; i<aArgc; i++) {
|
||||
mArgv[i] = nsCRT::strdup( aArgv[i] ? aArgv[i] : "" );
|
||||
}
|
||||
//Insert the program name
|
||||
if (aArgc > 0 && aArgv[0])
|
||||
{
|
||||
mArgList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("-progname")));
|
||||
mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup(aArgv[0])));
|
||||
mArgCount++;
|
||||
i++;
|
||||
}
|
||||
|
||||
for(i=1; i<aArgc; i++) {
|
||||
|
||||
if ((aArgv[i][0] == '-')
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
|| (aArgv[i][0] == '/')
|
||||
#endif
|
||||
) {
|
||||
/* An option that starts with -. May or may not
|
||||
* have a value after it.
|
||||
*/
|
||||
mArgList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup(aArgv[i])));
|
||||
//Increment the index to look ahead at the next option.
|
||||
i++;
|
||||
|
||||
|
||||
//Look ahead if this option has a value like -w 60
|
||||
|
||||
if (i == aArgc) {
|
||||
/* All args have been parsed. Append a PR_TRUE for the
|
||||
* previous option in the mArgValueList
|
||||
*/
|
||||
mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("1")));
|
||||
mArgCount++;
|
||||
break;
|
||||
}
|
||||
if ((aArgv[i][0] == '-')
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
|| (aArgv[i][0] == '/')
|
||||
#endif
|
||||
) {
|
||||
/* An other option. The previous one didn't have a value.
|
||||
* So, store the previous one's value as PR_TRUE in the
|
||||
* mArgValue array and retract the index so that this option
|
||||
* will get stored in the next iteration
|
||||
*/
|
||||
mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("1")));
|
||||
mArgCount++;
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* The next argument does not start with '-'. This
|
||||
* could be value to the previous option
|
||||
*/
|
||||
if (i == (aArgc-1)) {
|
||||
/* This is the last argument and a URL
|
||||
* Append a PR_TRUE for the previous option in the value array
|
||||
*/
|
||||
mArgValueList.AppendElement(ProcessURLArg(aArgv[i]));
|
||||
mArgCount++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* This is a value to the previous option.
|
||||
* Store it in the mArgValue array
|
||||
*/
|
||||
mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup(aArgv[i])));
|
||||
mArgCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (i == (aArgc-1)) {
|
||||
/* This must be the URL at the end
|
||||
* Append the url to the arrays
|
||||
*/
|
||||
mArgList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("-url")));
|
||||
mArgValueList.AppendElement(ProcessURLArg(aArgv[i]));
|
||||
mArgCount++;
|
||||
}
|
||||
else {
|
||||
/* A bunch of unrecognized arguments */
|
||||
rv = NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
} // for
|
||||
|
||||
#if 0
|
||||
for (i=0; i<mArgCount; i++)
|
||||
{
|
||||
printf("Argument: %s, ****** Value: %s\n", (char *)mArgList.ElementAt(i), (char *) mArgValueList.ElementAt(i));
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetURLToLoad(char ** aResult)
|
||||
{
|
||||
|
||||
return GetCmdLineValue("-url", aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetProgramName(char ** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
*aResult = (char *)mArgValueList.SafeElementAt(0);
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
PRBool nsCmdLineService::ArgsMatch(const char *lookingFor, const char *userGave)
|
||||
{
|
||||
if (!lookingFor || !userGave) return PR_FALSE;
|
||||
|
||||
if (!PL_strcasecmp(lookingFor,userGave)) return PR_TRUE;
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
/* on unix and beos, we'll allow --mail for -mail */
|
||||
if (lookingFor && userGave && (lookingFor[0] != '\0') && (userGave[0] != '\0') && (userGave[1] != '\0')) {
|
||||
if (!PL_strcasecmp(lookingFor+1,userGave+2) && (lookingFor[0] == '-') && (userGave[0] == '-') && (userGave[1] == '-')) return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
/* on windows /mail is the same as -mail */
|
||||
if (lookingFor && userGave && (lookingFor[0] != '\0') && (userGave[0] != '\0')) {
|
||||
if (!PL_strcasecmp(lookingFor+1,userGave+1) && (lookingFor[0] == '-') && (userGave[0] == '/')) return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetCmdLineValue(const char * aArg, char ** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (nsnull == aArg || nsnull == aResult ) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
for (int i = 0; i<mArgCount; i++)
|
||||
{
|
||||
if (ArgsMatch(aArg,(char *) mArgList.ElementAt(i))) {
|
||||
*aResult = nsCRT::strdup((char *)mArgValueList.ElementAt(i));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
*aResult = nsnull;
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetArgc(PRInt32 * aResult)
|
||||
{
|
||||
|
||||
if (nsnull == aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// if we are null, we were never initialized.
|
||||
if (mArgc == 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aResult = mArgc;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetArgv(char *** aResult)
|
||||
{
|
||||
if (nsnull == aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// if we are 0, we were never set.
|
||||
if (!mArgv)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aResult = mArgv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCmdLineService::~nsCmdLineService()
|
||||
{
|
||||
PRInt32 curr = mArgList.Count();
|
||||
while ( curr ) {
|
||||
char* str = NS_REINTERPRET_CAST(char*, mArgList[curr-1]);
|
||||
if ( str )
|
||||
nsMemory::Free(str);
|
||||
--curr;
|
||||
}
|
||||
|
||||
curr = mArgValueList.Count();
|
||||
while ( curr ) {
|
||||
char* str = NS_REINTERPRET_CAST(char*, mArgValueList[curr-1]);
|
||||
if ( str )
|
||||
nsMemory::Free(str);
|
||||
--curr;
|
||||
}
|
||||
|
||||
curr = mArgc;
|
||||
while ( curr ) {
|
||||
char *str = mArgv ? mArgv[curr-1] : 0;
|
||||
if ( str )
|
||||
nsMemory::Free( mArgv[curr-1] );
|
||||
--curr;
|
||||
}
|
||||
delete [] mArgv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetHandlerForParam(const char *aParam,
|
||||
nsICmdLineHandler** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// allocate temp on the stack
|
||||
nsAutoVoidArray oneParameter;
|
||||
|
||||
nsVoidArray *paramList;
|
||||
|
||||
// if user passed in "null", then we want to go through each one
|
||||
if (!aParam)
|
||||
paramList = &mArgList;
|
||||
else {
|
||||
oneParameter.AppendElement((void *)aParam);
|
||||
paramList = &oneParameter;
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
for (i=0; i < (PRUint32)paramList->Count(); i++) {
|
||||
const char *param = (const char*)paramList->ElementAt(i);
|
||||
|
||||
// skip past leading / and -
|
||||
if (*param == '-' || *param == '/') {
|
||||
++param;
|
||||
if (*param == *(param-1)) // skip "--" or "//"
|
||||
++param;
|
||||
}
|
||||
|
||||
nsCAutoString
|
||||
contractID("@mozilla.org/commandlinehandler/general-startup;1?type=");
|
||||
|
||||
contractID += param;
|
||||
|
||||
nsCOMPtr<nsICmdLineHandler> handler =
|
||||
do_GetService(contractID.get(), &rv);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
*aResult = handler;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// went through all the parameters, didn't find one
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::PrintCmdArgs()
|
||||
{
|
||||
|
||||
if (mArgCount == 0) {
|
||||
printf("No command line options provided\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0; i<mArgCount; i++)
|
||||
{
|
||||
printf("Argument: %s, ****** Value: %s\n", mArgList.ElementAt(i), mArgValueList.ElementAt(i));
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/* -*- 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 __nsCommandLineService_h
|
||||
#define __nsCommandLineService_h
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsCmdLineService : public nsICmdLineService
|
||||
{
|
||||
public:
|
||||
nsCmdLineService(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICMDLINESERVICE
|
||||
|
||||
protected:
|
||||
virtual ~nsCmdLineService();
|
||||
|
||||
nsVoidArray mArgList; // The arguments
|
||||
nsVoidArray mArgValueList; // The argument values
|
||||
PRInt32 mArgCount; // This is not argc. This is # of argument pairs
|
||||
// in the arglist and argvaluelist arrays. This
|
||||
// normally is argc/2.
|
||||
PRInt32 mArgc; // This is argc;
|
||||
char ** mArgv; // This is argv;
|
||||
|
||||
PRBool ArgsMatch(const char *lookingFor, const char *userGave);
|
||||
};
|
||||
|
||||
// e34783f5-ac08-11d2-8d19-00805fc2500c
|
||||
#define NS_COMMANDLINESERVICE_CID \
|
||||
{ 0xe34783f5, 0xac08, 0x11d2, \
|
||||
{0x8d, 0x19, 0x00, 0x80, 0x5f, 0xc2, 0x50,0xc} }
|
||||
|
||||
#endif
|
|
@ -0,0 +1,427 @@
|
|||
/* -*- Mode: C++; tab-width: 4; 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):
|
||||
* Simon Fraser <sfraser@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.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 ***** */
|
||||
|
||||
// Special stuff for the Macintosh implementation of command-line service.
|
||||
|
||||
#include "nsCommandLineServiceMac.h"
|
||||
|
||||
// Mozilla
|
||||
#include "nsDebug.h"
|
||||
#include "nsILocalFileMac.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsICloseAllWindows.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsAEEventHandling.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
// NSPR
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "prenv.h"
|
||||
#ifdef XP_MAC
|
||||
#include "pprio.h" // PR_Init_Log
|
||||
#endif
|
||||
|
||||
// the static instance
|
||||
nsMacCommandLine nsMacCommandLine::sMacCommandLine;
|
||||
|
||||
/*
|
||||
* ReadLine --
|
||||
*
|
||||
* Read in a line of text, terminated by CR or LF, from inStream into buf.
|
||||
* The terminating CR or LF is not included. The text in buf is terminated
|
||||
* by a null byte.
|
||||
* Returns the number of bytes in buf. If EOF and zero bytes were read, returns -1.
|
||||
*/
|
||||
|
||||
static PRInt32 ReadLine(FILE* inStream, char* buf, PRInt32 bufSize)
|
||||
{
|
||||
PRInt32 charsRead = 0;
|
||||
int c;
|
||||
|
||||
if (bufSize < 2)
|
||||
return -1;
|
||||
|
||||
while (charsRead < (bufSize-1)) {
|
||||
c = getc(inStream);
|
||||
if (c == EOF || c == '\n' || c == '\r')
|
||||
break;
|
||||
buf[charsRead++] = c;
|
||||
}
|
||||
buf[charsRead] = '\0';
|
||||
|
||||
return (c == EOF && !charsRead) ? -1 : charsRead;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsMacCommandLine::nsMacCommandLine()
|
||||
: mArgs(NULL)
|
||||
, mArgsAllocated(0)
|
||||
, mArgsUsed(0)
|
||||
, mStartedUp(PR_FALSE)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsMacCommandLine::~nsMacCommandLine()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
ShutdownAEHandlerClasses();
|
||||
if (mArgs) {
|
||||
for (PRUint32 i = 0; i < mArgsUsed; i++)
|
||||
free(mArgs[i]);
|
||||
free(mArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::Initialize(int& argc, char**& argv)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mArgs = static_cast<char **>(malloc(kArgsGrowSize * sizeof(char *)));
|
||||
if (!mArgs)
|
||||
return NS_ERROR_FAILURE;
|
||||
mArgs[0] = nsnull;
|
||||
mArgsAllocated = kArgsGrowSize;
|
||||
mArgsUsed = 0;
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
// Here, we may actually get useful args.
|
||||
// Copy them first to mArgv.
|
||||
for (int arg = 0; arg < argc; arg++)
|
||||
AddToCommandLine(argv[arg]);
|
||||
#else
|
||||
// init the args buffer with the program name
|
||||
AddToCommandLine("mozilla");
|
||||
#endif
|
||||
|
||||
// Set up AppleEvent handling.
|
||||
OSErr err = CreateAEHandlerClasses(false);
|
||||
if (err != noErr) return NS_ERROR_FAILURE;
|
||||
|
||||
// Snarf all the odoc and pdoc apple-events.
|
||||
//
|
||||
// 1. If they are odoc for 'CMDL' documents, read them into the buffer ready for
|
||||
// parsing (concatenating multiple files).
|
||||
//
|
||||
// 2. If they are any other kind of document, convert them into -url command-line
|
||||
// parameters or -print parameters, with file URLs.
|
||||
|
||||
EventRecord anEvent;
|
||||
for (short i = 1; i < 5; i++)
|
||||
::WaitNextEvent(0, &anEvent, 0, nsnull);
|
||||
|
||||
while (::EventAvail(highLevelEventMask, &anEvent))
|
||||
{
|
||||
::WaitNextEvent(highLevelEventMask, &anEvent, 0, nsnull);
|
||||
if (anEvent.what == kHighLevelEvent)
|
||||
{
|
||||
// here we process startup odoc/pdoc events, which can
|
||||
// add items to the command line.
|
||||
err = ::AEProcessAppleEvent(&anEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetCurrentKeyModifiers() & optionKey)
|
||||
AddToCommandLine("-p");
|
||||
|
||||
// we've started up now
|
||||
mStartedUp = PR_TRUE;
|
||||
|
||||
argc = mArgsUsed;
|
||||
argv = mArgs;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::AddToCommandLine(const char* inArgText)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mArgsUsed >= mArgsAllocated) {
|
||||
// realloc does not free the given pointer if allocation fails.
|
||||
char **temp = static_cast<char **>(realloc(mArgs, (mArgsAllocated + kArgsGrowSize) * sizeof(char *)));
|
||||
if (!temp)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mArgs = temp;
|
||||
mArgsAllocated += kArgsGrowSize;
|
||||
}
|
||||
char *temp2 = strdup(inArgText);
|
||||
if (!temp2)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mArgs[mArgsUsed++] = temp2;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::AddToCommandLine(const char* inOptionString, const FSSpec& inFileSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Convert the filespec to a URL
|
||||
FSSpec nonConstSpec = inFileSpec;
|
||||
nsCOMPtr<nsILocalFileMac> inFile;
|
||||
nsresult rv = NS_NewLocalFileWithFSSpec(&nonConstSpec, PR_TRUE, getter_AddRefs(inFile));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCAutoString specBuf;
|
||||
rv = NS_GetURLSpecFromFile(inFile, specBuf);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
AddToCommandLine(inOptionString);
|
||||
AddToCommandLine(specBuf.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::AddToEnvironmentVars(const char* inArgText)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
(void)PR_SetEnv(inArgText);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsCOMPtr<nsILocalFileMac> inFile;
|
||||
nsresult rv = NS_NewLocalFileWithFSSpec(&inFileSpec, PR_TRUE, getter_AddRefs(inFile));
|
||||
if (NS_FAILED(rv))
|
||||
return errAEEventNotHandled;
|
||||
|
||||
if (!mStartedUp)
|
||||
{
|
||||
// Is it the right type to be a command-line file?
|
||||
if (inFileType == 'TEXT' || inFileType == 'CMDL')
|
||||
{
|
||||
// Can we open the file?
|
||||
FILE *fp = 0;
|
||||
rv = inFile->OpenANSIFileDesc("r", &fp);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
Boolean foundArgs = false;
|
||||
Boolean foundEnv = false;
|
||||
char chars[1024];
|
||||
static const char kCommandLinePrefix[] = "ARGS:";
|
||||
static const char kEnvVarLinePrefix[] = "ENV:";
|
||||
|
||||
while (ReadLine(fp, chars, sizeof(chars)) != -1)
|
||||
{ // See if there are any command line or environment var settings
|
||||
if (PL_strstr(chars, kCommandLinePrefix) == chars)
|
||||
{
|
||||
(void)AddToCommandLine(chars + sizeof(kCommandLinePrefix) - 1);
|
||||
foundArgs = true;
|
||||
}
|
||||
else if (PL_strstr(chars, kEnvVarLinePrefix) == chars)
|
||||
{
|
||||
(void)AddToEnvironmentVars(chars + sizeof(kEnvVarLinePrefix) - 1);
|
||||
foundEnv = true;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
#ifndef XP_MACOSX
|
||||
// If we found any environment vars we need to re-init NSPR's logging
|
||||
// so that it knows what the new vars are
|
||||
if (foundEnv)
|
||||
PR_Init_Log();
|
||||
#endif
|
||||
// If we found a command line or environment vars we want to return now
|
||||
// raather than trying to open the file as a URL
|
||||
if (foundArgs || foundEnv)
|
||||
return noErr;
|
||||
}
|
||||
}
|
||||
// If it's not a command-line argument, and we are starting up the application,
|
||||
// add a command-line "-url" argument to the global list. This means that if
|
||||
// the app is opened with documents on the mac, they'll be handled the same
|
||||
// way as if they had been typed on the command line in Unix or DOS.
|
||||
return AddToCommandLine("-url", inFileSpec);
|
||||
}
|
||||
|
||||
// Final case: we're not just starting up. How do we handle this?
|
||||
nsCAutoString specBuf;
|
||||
rv = NS_GetURLSpecFromFile(inFile, specBuf);
|
||||
if (NS_FAILED(rv))
|
||||
return errAEEventNotHandled;
|
||||
|
||||
return OpenURL(specBuf.get());
|
||||
}
|
||||
|
||||
OSErr nsMacCommandLine::OpenURL(const char* aURL)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
|
||||
nsXPIDLCString browserURL;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = prefBranch->GetCharPref("browser.chromeURL", getter_Copies(browserURL));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("browser.chromeURL not supplied! How is the app supposed to know what the main window is?");
|
||||
browserURL.Assign("chrome://navigator/content/navigator.xul");
|
||||
}
|
||||
|
||||
rv = OpenWindow(browserURL.get(), NS_ConvertASCIItoUCS2(aURL).get());
|
||||
if (NS_FAILED(rv))
|
||||
return errAEEventNotHandled;
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsMacCommandLine::HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// If we are starting up the application,
|
||||
// add a command-line "-print" argument to the global list. This means that if
|
||||
// the app is opened with documents on the mac, they'll be handled the same
|
||||
// way as if they had been typed on the command line in Unix or DOS.
|
||||
if (!mStartedUp)
|
||||
return AddToCommandLine("-print", inFileSpec);
|
||||
|
||||
// Final case: we're not just starting up. How do we handle this?
|
||||
NS_NOTYETIMPLEMENTED("Write Me");
|
||||
return errAEEventNotHandled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::OpenWindow(const char *chrome, const PRUnichar *url)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsString> urlWrapper(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
|
||||
if (!wwatch || !urlWrapper)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
urlWrapper->SetData(nsDependentString(url));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
nsresult rv;
|
||||
rv = wwatch->OpenWindow(0, chrome, "_blank",
|
||||
"chrome,dialog=no,all", urlWrapper,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsMacCommandLine::DispatchURLToNewBrowser(const char* url)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
OSErr err = errAEEventNotHandled;
|
||||
if (mStartedUp)
|
||||
return OpenURL(url);
|
||||
else {
|
||||
err = AddToCommandLine("-url");
|
||||
if (err == noErr)
|
||||
err = AddToCommandLine(url);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsMacCommandLine::Quit(TAskSave askSave)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICloseAllWindows> closer =
|
||||
do_CreateInstance("@mozilla.org/appshell/closeallwindows;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return errAEEventNotHandled;
|
||||
|
||||
PRBool doQuit;
|
||||
rv = closer->CloseAll(askSave != eSaveNo, &doQuit);
|
||||
if (NS_FAILED(rv) || !doQuit)
|
||||
return errAEEventNotHandled;
|
||||
|
||||
nsCOMPtr<nsIAppStartup> appStartup =
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return errAEEventNotHandled;
|
||||
|
||||
(void)appStartup->Quit(nsIAppStartup::eAttemptQuit);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================================
|
||||
// InitializeMacCommandLine
|
||||
// The only external entry point to this file.
|
||||
//========================================================================================
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult InitializeMacCommandLine(int& argc, char**& argv)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
|
||||
return cmdLine.Initialize(argc, argv);
|
||||
} // InitializeMac
|
|
@ -0,0 +1,115 @@
|
|||
/* -*- 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 ***** */
|
||||
|
||||
// Special stuff for the Macintosh implementation of command-line service.
|
||||
|
||||
#ifndef nsCommandLineServiceMac_h_
|
||||
#define nsCommandLineServiceMac_h_
|
||||
|
||||
#include <Files.h>
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsError.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsAEDefs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class nsMacCommandLine
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
kArgsGrowSize = 20
|
||||
};
|
||||
|
||||
nsMacCommandLine();
|
||||
~nsMacCommandLine();
|
||||
|
||||
nsresult Initialize(int& argc, char**& argv);
|
||||
|
||||
nsresult AddToCommandLine(const char* inArgText);
|
||||
nsresult AddToCommandLine(const char* inOptionString, const FSSpec& inFileSpec);
|
||||
nsresult AddToEnvironmentVars(const char* inArgText);
|
||||
|
||||
OSErr HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType);
|
||||
OSErr HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType);
|
||||
|
||||
OSErr DispatchURLToNewBrowser(const char* url);
|
||||
|
||||
OSErr Quit(TAskSave askSave);
|
||||
|
||||
protected:
|
||||
|
||||
OSErr OpenURL(const char* aURL);
|
||||
|
||||
nsresult OpenWindow(const char *chrome, const PRUnichar *url);
|
||||
|
||||
char** mArgs; // array of arg pointers (augmented argv)
|
||||
PRUint32 mArgsAllocated; // number of slots available in mArgs
|
||||
PRUint32 mArgsUsed; // number of slots used in mArgs
|
||||
|
||||
PRBool mStartedUp;
|
||||
|
||||
public:
|
||||
|
||||
static nsMacCommandLine& GetMacCommandLine() { return sMacCommandLine; }
|
||||
|
||||
private:
|
||||
|
||||
static nsMacCommandLine sMacCommandLine;
|
||||
|
||||
};
|
||||
|
||||
#endif //__cplusplus
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
nsresult InitializeMacCommandLine(int& argc, char**& argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // nsCommandLineServiceMac_h_
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- 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):
|
||||
* Seth Spitzer <sspitzer@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 __nsUserInfo_h
|
||||
#define __nsUserInfo_h
|
||||
|
||||
#include "nsIUserInfo.h"
|
||||
|
||||
class nsUserInfo: public nsIUserInfo
|
||||
|
||||
{
|
||||
public:
|
||||
nsUserInfo(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUSERINFO
|
||||
|
||||
virtual ~nsUserInfo();
|
||||
};
|
||||
|
||||
#endif /* __nsUserInfo_h */
|
|
@ -0,0 +1,142 @@
|
|||
/* -*- 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 "nsUserInfo.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIInternetConfigService.h"
|
||||
|
||||
nsUserInfo::nsUserInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsUserInfo::~nsUserInfo()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetFullname(PRUnichar **aFullname)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
|
||||
if (icService)
|
||||
{
|
||||
nsCAutoString cName;
|
||||
result = icService->GetString(nsIInternetConfigService::eICString_RealName, cName);
|
||||
if ( NS_SUCCEEDED ( result ) )
|
||||
{
|
||||
nsString fullName;
|
||||
*aFullname = ToNewUnicode(cName);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
|
||||
if (icService)
|
||||
{
|
||||
nsCAutoString tempString;
|
||||
result = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
|
||||
if (NS_SUCCEEDED(result))
|
||||
*aEmailAddress = ToNewCString(tempString);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetUsername(char * *aUsername)
|
||||
{
|
||||
*aUsername = nsnull;
|
||||
|
||||
nsCAutoString tempString;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
|
||||
if (icService)
|
||||
rv = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
|
||||
|
||||
if ( NS_FAILED( rv ) ) return rv;
|
||||
|
||||
const char* atString = "@";
|
||||
PRInt32 atOffset = tempString.Find(atString);
|
||||
if (atOffset != kNotFound)
|
||||
tempString.Truncate(atOffset);
|
||||
|
||||
*aUsername = ToNewCString(tempString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetDomain(char * *aDomain)
|
||||
{
|
||||
*aDomain = nsnull;
|
||||
nsCAutoString tempString;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
|
||||
if (icService)
|
||||
rv = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
|
||||
if ( NS_FAILED( rv ) ) return rv;
|
||||
const char* atString = "@";
|
||||
PRInt32 atOffset = tempString.Find(atString);
|
||||
if (atOffset != kNotFound)
|
||||
{
|
||||
nsCAutoString domainString;
|
||||
tempString.Right(domainString, tempString.Length() - (atOffset + 1));
|
||||
*aDomain = ToNewCString(domainString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// no domain in the pref
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
/* -*- 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
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
* 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
|
||||
|
@ -14,51 +14,58 @@
|
|||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* 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):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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"),
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* 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 MPL, the GPL or the LGPL.
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef __nsUserInfoMac_h
|
||||
#define __nsUserInfoMac_h
|
||||
|
||||
#include "nsICmdLineHandler.h"
|
||||
#include "nsIUserInfo.h"
|
||||
|
||||
#define NS_PRELOADER_CID \
|
||||
{ /* 5ad506ee-393e-45d9-8d6f-53066fa8dc3a */ \
|
||||
0x5ad506ee, \
|
||||
0x393e, \
|
||||
0x45d9, \
|
||||
{0x8d, 0x6f, 0x53, 0x06, 0x6f, 0xa8, 0xdc, 0x3a} \
|
||||
} \
|
||||
|
||||
#define NS_PRELOADER_CONTRACTID \
|
||||
"@mozilla.org/commandlinehandler/general-startup;1?type=preloader"
|
||||
#include <InternetConfig.h>
|
||||
|
||||
class nsUserInfo: public nsIUserInfo
|
||||
|
||||
class nsPreloader : public nsICmdLineHandler
|
||||
{
|
||||
public:
|
||||
nsPreloader();
|
||||
virtual ~nsPreloader();
|
||||
public:
|
||||
nsUserInfo(void);
|
||||
virtual ~nsUserInfo();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICMDLINEHANDLER
|
||||
CMDLINEHANDLER_REGISTERPROC_DECLS
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUSERINFO
|
||||
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
|
||||
nsresult EnsureInitted();
|
||||
|
||||
static OSType GetAppCreatorCode();
|
||||
static PRUnichar* PStringToNewUCS2(ConstStr255Param str);
|
||||
|
||||
protected:
|
||||
|
||||
ICInstance mInstance;
|
||||
PRBool mInitted;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __nsUserInfo_h */
|
|
@ -0,0 +1,70 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
||||
* described herein are Copyright (c) International Business Machines Corporation, 2000.
|
||||
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
|
||||
*
|
||||
* Date Modified by Description of modification
|
||||
* 05/11/2000 IBM Corp. Created for OS/2 VisualAge build.
|
||||
*/
|
||||
|
||||
#include "nsUserInfo.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
nsUserInfo::nsUserInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsUserInfo::~nsUserInfo()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetUsername(char **aUsername)
|
||||
{
|
||||
*aUsername = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetFullname(PRUnichar **aFullname)
|
||||
{
|
||||
*aFullname = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetDomain(char * *aDomain)
|
||||
{
|
||||
*aDomain = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
|
||||
{
|
||||
*aEmailAddress = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
/* -*- 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):
|
||||
* Seth Spitzer <sspitzer@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 ***** */
|
||||
|
||||
#include "nsUserInfo.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include <pwd.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
/* Some UNIXy platforms don't have pw_gecos. In this case we use pw_name */
|
||||
#if defined(NO_PW_GECOS)
|
||||
#define PW_GECOS pw_name
|
||||
#else
|
||||
#define PW_GECOS pw_gecos
|
||||
#endif
|
||||
|
||||
nsUserInfo::nsUserInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsUserInfo::~nsUserInfo()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetFullname(PRUnichar **aFullname)
|
||||
{
|
||||
struct passwd *pw = nsnull;
|
||||
|
||||
pw = getpwuid (geteuid());
|
||||
|
||||
if (!pw || !pw->PW_GECOS) return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("fullname = %s\n", pw->PW_GECOS);
|
||||
#endif
|
||||
|
||||
nsCAutoString fullname(pw->PW_GECOS);
|
||||
|
||||
// now try to parse the GECOS information, which will be in the form
|
||||
// Full Name, <other stuff> - eliminate the ", <other stuff>
|
||||
// also, sometimes GECOS uses "&" to mean "the user name" so do
|
||||
// the appropriate substitution
|
||||
|
||||
// truncate at first comma (field delimiter)
|
||||
PRInt32 index;
|
||||
if ((index = fullname.Find(",")) != kNotFound)
|
||||
fullname.Truncate(index);
|
||||
|
||||
// replace ampersand with username
|
||||
if (pw->pw_name) {
|
||||
nsCAutoString username(pw->pw_name);
|
||||
if (!username.IsEmpty() && nsCRT::IsLower(username.CharAt(0)))
|
||||
username.SetCharAt(nsCRT::ToUpper(username.CharAt(0)), 0);
|
||||
|
||||
fullname.ReplaceSubstring("&", username.get());
|
||||
}
|
||||
|
||||
*aFullname = ToNewUnicode(fullname);
|
||||
|
||||
if (*aFullname)
|
||||
return NS_OK;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetUsername(char * *aUsername)
|
||||
{
|
||||
struct passwd *pw = nsnull;
|
||||
|
||||
// is this portable? those are POSIX compliant calls, but I need to check
|
||||
pw = getpwuid(geteuid());
|
||||
|
||||
if (!pw || !pw->pw_name) return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("username = %s\n", pw->pw_name);
|
||||
#endif
|
||||
|
||||
*aUsername = nsCRT::strdup(pw->pw_name);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetDomain(char * *aDomain)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
struct utsname buf;
|
||||
char *domainname = nsnull;
|
||||
|
||||
// is this portable? that is a POSIX compliant call, but I need to check
|
||||
if (uname(&buf)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if defined(HAVE_UNAME_DOMAINNAME_FIELD)
|
||||
domainname = buf.domainname;
|
||||
#elif defined(HAVE_UNAME_US_DOMAINNAME_FIELD)
|
||||
domainname = buf.__domainname;
|
||||
#endif
|
||||
|
||||
if (domainname && domainname[0]) {
|
||||
*aDomain = nsCRT::strdup(domainname);
|
||||
rv = NS_OK;
|
||||
}
|
||||
else {
|
||||
// try to get the hostname from the nodename
|
||||
// on machines that use DHCP, domainname may not be set
|
||||
// but the nodename might.
|
||||
if (buf.nodename && buf.nodename[0]) {
|
||||
// if the nodename is foo.bar.org, use bar.org as the domain
|
||||
char *pos = strchr(buf.nodename,'.');
|
||||
if (pos) {
|
||||
*aDomain = nsCRT::strdup(pos+1);
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
|
||||
{
|
||||
// use username + "@" + domain for the email address
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCAutoString emailAddress;
|
||||
nsXPIDLCString username;
|
||||
nsXPIDLCString domain;
|
||||
|
||||
rv = GetUsername(getter_Copies(username));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = GetDomain(getter_Copies(domain));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!username.IsEmpty() && !domain.IsEmpty()) {
|
||||
emailAddress = (const char *)username;
|
||||
emailAddress += "@";
|
||||
emailAddress += (const char *)domain;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aEmailAddress = ToNewCString(emailAddress);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -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):
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
* Seth Spitzer <sspitzer@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 ***** */
|
||||
|
||||
#include "nsUserInfo.h"
|
||||
#include "nsString.h"
|
||||
#include "windows.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
nsUserInfo::nsUserInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsUserInfo::~nsUserInfo()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetUsername(char **aUsername)
|
||||
{
|
||||
*aUsername = nsnull;
|
||||
|
||||
TCHAR username[256];
|
||||
DWORD size = 256;
|
||||
|
||||
if (!GetUserName(username, &size))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aUsername = nsCRT::strdup(username);
|
||||
|
||||
if (*aUsername) return NS_OK;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetFullname(PRUnichar **aFullname)
|
||||
{
|
||||
*aFullname = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetDomain(char * *aDomain)
|
||||
{
|
||||
*aDomain = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
|
||||
{
|
||||
*aEmailAddress = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
|
@ -47,15 +47,8 @@ function goQuitApplication()
|
|||
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
|
||||
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
|
||||
var enumerator = windowManagerInterface.getEnumerator( null );
|
||||
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
|
||||
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService );
|
||||
|
||||
var nativeAppSupport = null;
|
||||
try {
|
||||
nativeAppSupport = appShell.nativeAppSupport;
|
||||
}
|
||||
catch ( ex ) {
|
||||
}
|
||||
var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'].
|
||||
getService(Components.interfaces.nsIAppStartup);
|
||||
|
||||
while ( enumerator.hasMoreElements() )
|
||||
{
|
||||
|
@ -64,7 +57,7 @@ function goQuitApplication()
|
|||
return false;
|
||||
domWindow.close();
|
||||
};
|
||||
appShell.quit(Components.interfaces.nsIAppShellService.eAttemptQuit);
|
||||
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1544,7 +1544,7 @@ nsExtensionManager.prototype = {
|
|||
// time now.
|
||||
this._cleanDirs();
|
||||
|
||||
var cmdLineSvc = Components.classes["@mozilla.org/appshell/commandLineService;1"]
|
||||
var cmdLineSvc = Components.classes["@mozilla.org/app-startup/commandLineService;1"]
|
||||
.getService(Components.interfaces.nsICmdLineService);
|
||||
var safeMode = cmdLineSvc.getCmdLineValue("-safe-mode") != null;
|
||||
if (!safeMode) {
|
||||
|
@ -1647,7 +1647,7 @@ nsExtensionManager.prototype = {
|
|||
|
||||
handleCommandLineArgs: function nsExtensionManager_handleCommandLineArgs ()
|
||||
{
|
||||
var cmdLineSvc = Components.classes["@mozilla.org/appshell/commandLineService;1"]
|
||||
var cmdLineSvc = Components.classes["@mozilla.org/app-startup/commandLineService;1"]
|
||||
.getService(Components.interfaces.nsICmdLineService);
|
||||
var globalExtension = cmdLineSvc.getCmdLineValue("-install-global-extension");
|
||||
if (globalExtension)
|
||||
|
|
|
@ -87,10 +87,11 @@ endif
|
|||
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
XPIDLSRCS = nsINativeAppSupport.idl
|
||||
|
||||
EXPORTS = nsXULAppAPI.h
|
||||
|
||||
SHAREDCPPSRCS = \
|
||||
nsWindowCreator.cpp \
|
||||
showOSAlert.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "prenv.h"
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIAppStartupNotifier.h"
|
||||
#include "nsIArray.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
@ -89,11 +90,11 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsXREDirProvider.h"
|
||||
#include "nsWindowCreator.h"
|
||||
|
||||
#include "nsINIParser.h"
|
||||
|
||||
|
@ -593,7 +594,7 @@ LaunchApplicationWithArgs(const char *commandLineArg,
|
|||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLine =
|
||||
do_GetService("@mozilla.org/appshell/commandLineService;1",&rv);
|
||||
do_GetService("@mozilla.org/app-startup/commandLineService;1",&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr <nsICmdLineHandler> handler;
|
||||
|
@ -720,10 +721,10 @@ DoCommandLines(nsICmdLineService* cmdLineArgs, PRBool heedGeneralStartupPrefs, P
|
|||
PR_sscanf(tempString.get(), "%d", &height);
|
||||
|
||||
if (heedGeneralStartupPrefs) {
|
||||
nsCOMPtr<nsIAppShellService> appShellService
|
||||
(do_GetService("@mozilla.org/appshell/appShellService;1", &rv));
|
||||
nsCOMPtr<nsIAppStartup> appStartup
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = appShellService->CreateStartupState(width, height, windowOpened);
|
||||
rv = appStartup->CreateStartupState(width, height, windowOpened);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
|
@ -956,7 +957,7 @@ ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native)
|
|||
|
||||
// Initialize the cmd line service
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs
|
||||
(do_GetService("@mozilla.org/appshell/commandLineService;1"));
|
||||
(do_GetService("@mozilla.org/app-startup/commandLineService;1"));
|
||||
NS_ENSURE_TRUE(cmdLineArgs, NS_ERROR_FAILURE);
|
||||
|
||||
rv = cmdLineArgs->Initialize(gArgc, gArgv);
|
||||
|
@ -968,15 +969,8 @@ ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native)
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService
|
||||
(do_GetService("@mozilla.org/appshell/appShellService;1"));
|
||||
NS_ENSURE_TRUE(appShellService, NS_ERROR_UNEXPECTED);
|
||||
|
||||
rv = appShellService->Initialize(cmdLineArgs, native);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIWindowCreator> creator = new nsWindowCreator();
|
||||
if (!creator) return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsCOMPtr<nsIWindowCreator> creator (do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
if (!creator) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch
|
||||
(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
|
||||
|
@ -1310,11 +1304,11 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
|
|||
|
||||
ioParamBlock->SetObjects(dlgArray);
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService
|
||||
(do_GetService("@mozilla.org/appshell/appShellService;1"));
|
||||
NS_ENSURE_TRUE(appShellService, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIAppStartup> appStartup
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
NS_ENSURE_TRUE(appStartup, NS_ERROR_FAILURE);
|
||||
|
||||
appShellService->EnterLastWindowClosingSurvivalArea();
|
||||
appStartup->EnterLastWindowClosingSurvivalArea();
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = windowWatcher->OpenWindow(nsnull,
|
||||
|
@ -1324,7 +1318,7 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
|
|||
ioParamBlock,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
appShellService->ExitLastWindowClosingSurvivalArea();
|
||||
appStartup->ExitLastWindowClosingSurvivalArea();
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -1916,12 +1910,12 @@ int xre_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
NS_TIMELINE_LEAVE("startupNotifier");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService;
|
||||
appShellService = do_GetService("@mozilla.org/appshell/appShellService;1");
|
||||
NS_ENSURE_TRUE(appShellService, 1);
|
||||
nsCOMPtr<nsIAppStartup> appStartup
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
NS_ENSURE_TRUE(appStartup, 1);
|
||||
|
||||
// So we can open and close windows during startup
|
||||
appShellService->EnterLastWindowClosingSurvivalArea();
|
||||
appStartup->EnterLastWindowClosingSurvivalArea();
|
||||
|
||||
// Profile Migration
|
||||
if (gAppData->flags & NS_XRE_ENABLE_PROFILE_MIGRATOR && gDoMigration) {
|
||||
|
@ -1933,9 +1927,9 @@ int xre_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
}
|
||||
dirProvider.DoStartup();
|
||||
|
||||
NS_TIMELINE_ENTER("appShellService->CreateHiddenWindow");
|
||||
rv = appShellService->CreateHiddenWindow();
|
||||
NS_TIMELINE_LEAVE("appShellService->CreateHiddenWindow");
|
||||
NS_TIMELINE_ENTER("appStartup->CreateHiddenWindow");
|
||||
rv = appStartup->CreateHiddenWindow();
|
||||
NS_TIMELINE_LEAVE("appStartup->CreateHiddenWindow");
|
||||
NS_ENSURE_SUCCESS(rv, 1);
|
||||
|
||||
// Extension Compatibility Checking and Startup
|
||||
|
@ -1983,10 +1977,10 @@ int xre_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
#endif
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs
|
||||
(do_GetService("@mozilla.org/appshell/commandLineService;1"));
|
||||
(do_GetService("@mozilla.org/app-startup/commandLineService;1"));
|
||||
NS_ENSURE_TRUE(cmdLineArgs, 1);
|
||||
|
||||
// This will go away once Components are handling there own commandlines
|
||||
// This will go away once Components are handling their own commandlines
|
||||
// if we have no command line arguments, we need to heed the
|
||||
// "general.startup.*" prefs
|
||||
// if we had no command line arguments, argc == 1.
|
||||
|
@ -1999,12 +1993,12 @@ int xre_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
|
||||
// Make sure there exists at least 1 window.
|
||||
NS_TIMELINE_ENTER("Ensure1Window");
|
||||
rv = appShellService->Ensure1Window(cmdLineArgs);
|
||||
rv = appStartup->Ensure1Window(cmdLineArgs);
|
||||
NS_TIMELINE_LEAVE("Ensure1Window");
|
||||
NS_ENSURE_SUCCESS(rv, 1);
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
appShellService->ExitLastWindowClosingSurvivalArea();
|
||||
appStartup->ExitLastWindowClosingSurvivalArea();
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_ENABLE_XREMOTE
|
||||
|
@ -2017,13 +2011,13 @@ int xre_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
#endif /* MOZ_ENABLE_XREMOTE */
|
||||
|
||||
// enable win32 DDE responses and Mac appleevents responses
|
||||
nativeApp->SetShouldShowUI(PR_TRUE);
|
||||
nativeApp->Enable();
|
||||
|
||||
// Start main event loop
|
||||
NS_TIMELINE_ENTER("appShell->Run");
|
||||
rv = appShellService->Run();
|
||||
NS_TIMELINE_LEAVE("appShell->Run");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appshell");
|
||||
NS_TIMELINE_ENTER("appStartup->Run");
|
||||
rv = appStartup->Run();
|
||||
NS_TIMELINE_LEAVE("appStartup->Run");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appstartup");
|
||||
|
||||
#ifdef MOZ_ENABLE_XREMOTE
|
||||
// shut down the x remote proxy window
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is 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>
|
||||
* Blake Ross <blake@netscape.com>
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/* nsINativeAppSupport
|
||||
*
|
||||
* This "pseudo" (in the XPCOM sense) interface provides for
|
||||
* platform-specific general aplication support:
|
||||
* o It manages the details of the simple DDE communication
|
||||
* supported on the Win32 platform (it is the addition of this
|
||||
* item that prompted the creation of this interface.
|
||||
*
|
||||
* Due to the nature of the beast, this interface is not a full-blown
|
||||
* XPCOM component. The primary reason is that objects that implement
|
||||
* this interface generally must be operational *before* XPCOM (or any
|
||||
* of the rest of Mozilla) are initialized. As a result, this
|
||||
* interface is instantiated by somewhat unconventional means.
|
||||
*
|
||||
* To create the implementor of this interface, you call the function
|
||||
* NS_CreateNativeAppSupport. This is done in the startup code
|
||||
* in nsAppRunner.cpp
|
||||
*
|
||||
* The interface provides these functions:
|
||||
* start - You call this to inform the native app support that the
|
||||
* application is starting. In addition, it serves as a
|
||||
* query as to whether the application should continue to
|
||||
* run.
|
||||
*
|
||||
* If the returned boolean result is PR_FALSE, then the
|
||||
* application should exit without further processing. In
|
||||
* such cases, the returned nsresult indicates whether the
|
||||
* reason to exit is due to an error or not.
|
||||
*
|
||||
* Win32 Note: In the case of starting a second instance
|
||||
* of this executable, this function will return
|
||||
* PR_FALSE and nsresult==NS_OK. This means that
|
||||
* the command line arguments have been
|
||||
* successfully passed to the instance of the
|
||||
* application acting as a DDE server.
|
||||
*
|
||||
* stop - You call this to inform the native app support that the
|
||||
* application *wishes* to terminate. If the returned boolean
|
||||
* value is PR_FALSE, then the application should continue
|
||||
* (as if there were still additional top-level windows open).
|
||||
*
|
||||
* Win32 Note: If this is the instance of the application
|
||||
* acting as the DDE server, and there are current
|
||||
* DDE conversations active with other instances
|
||||
* acting as DDE clients, then this function will
|
||||
* return PR_FALSE.
|
||||
*
|
||||
* quit - Like Stop, but this method *forces* termination (or more
|
||||
* precisely, indicates that the application is about to be
|
||||
* terminated regardless of what a call to Stop might have
|
||||
* returned.
|
||||
*
|
||||
* This method is intended to be called when the user selects
|
||||
* the "Quit" option (close all windows and exit).
|
||||
*
|
||||
* Win32 Note: Stop is problematic in the case of "Quit" (close
|
||||
* all windows and exit the application) because
|
||||
* either we don't Quit or (potentially) we lose
|
||||
* requests coming from other instances of the
|
||||
* application. The strategy is to give preference
|
||||
* to the user's explicit Quit request. In the
|
||||
* unlikely event that a request is pending from
|
||||
* another instance of the application, then such
|
||||
* requests are essentially ignored. This is
|
||||
* roughly equivalent to handling that request by
|
||||
* opening a new window, followed by immediately
|
||||
* closing it. Since this is the same as if the
|
||||
* request came in immediately before the Quit
|
||||
* call (versus immediately after it), no harm.
|
||||
*
|
||||
* There is an exposure here: Upon return from this
|
||||
* function, any DDE connect request (for Mozilla)
|
||||
* will fail and other instances of the application
|
||||
* will start up as a DDE server. In that case,
|
||||
* those instances may do things that conflict with
|
||||
* the subsequent shutting down of the instance that
|
||||
* is quitting. For this reason, the call to Quit
|
||||
* should be deferred as long as possible.
|
||||
*
|
||||
* onLastWindowClosing - Called when the last window is closed. Used as a
|
||||
* "soft" shutdown, passwords are flushed.
|
||||
*/
|
||||
|
||||
interface nsIXULWindow;
|
||||
interface nsICmdLineService;
|
||||
|
||||
[scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)]
|
||||
interface nsINativeAppSupport : nsISupports {
|
||||
// Startup/shutdown.
|
||||
boolean start();
|
||||
void enable();
|
||||
boolean stop();
|
||||
void quit();
|
||||
|
||||
void onLastWindowClosing();
|
||||
void ReOpen();
|
||||
};
|
|
@ -35,37 +35,45 @@
|
|||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsNativeAppSupportBase.h"
|
||||
|
||||
nsNativeAppSupportBase::nsNativeAppSupportBase()
|
||||
{
|
||||
}
|
||||
|
||||
nsNativeAppSupportBase::~nsNativeAppSupportBase() {
|
||||
nsNativeAppSupportBase::~nsNativeAppSupportBase()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsNativeAppSupportBase, nsINativeAppSupport)
|
||||
|
||||
// Start answer defaults to OK.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::Start( PRBool *result ) {
|
||||
NS_ENSURE_ARG( result );
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
nsNativeAppSupportBase::Start( PRBool *result )
|
||||
{
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::Enable()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Stop answer defaults to OK.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::Stop( PRBool *result ) {
|
||||
NS_ENSURE_ARG( result );
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
nsNativeAppSupportBase::Stop( PRBool *result )
|
||||
{
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Quit is a 0x90.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::Quit() {
|
||||
return NS_OK;
|
||||
nsNativeAppSupportBase::Quit()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -74,55 +82,7 @@ nsNativeAppSupportBase::ReOpen()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Show splash screen if implementation has one.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::ShowSplashScreen() {
|
||||
NS_NOTREACHED("Don't call me, I'm obsolete!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Hide splash screen if there is one.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::HideSplashScreen() {
|
||||
NS_NOTREACHED("Don't call me, I'm obsolete!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::SetIsServerMode(PRBool aIsServerMode) {
|
||||
NS_NOTREACHED("Don't call me, I'm obsolete!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::GetIsServerMode(PRBool *aIsServerMode) {
|
||||
NS_NOTREACHED("Don't call me, I'm obsolete!");
|
||||
*aIsServerMode = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::SetShouldShowUI(PRBool aShouldShowUI) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::GetShouldShowUI(PRBool *aShouldShowUI) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::StartServerMode() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::OnLastWindowClosing() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::EnsureProfile(nsICmdLineService* args)
|
||||
{
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
NS_IMETHOD Start(PRBool* aRetVal);
|
||||
NS_IMETHOD ReOpen();
|
||||
NS_IMETHOD SetShouldShowUI(PRBool aValue);
|
||||
NS_IMETHOD Enable();
|
||||
|
||||
private:
|
||||
PRBool mCanShowUI;
|
||||
|
@ -99,11 +99,10 @@ private:
|
|||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportMac::SetShouldShowUI(PRBool aValue)
|
||||
nsNativeAppSupportMac::Enable()
|
||||
{
|
||||
NS_ASSERTION(aValue, "True is the only allowed value!");
|
||||
mCanShowUI = aValue;
|
||||
return NS_OK;
|
||||
mCanShowUI = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean start (); */
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "nsIPref.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsXPCOM.h"
|
||||
#ifdef MOZ_PHOENIX
|
||||
|
@ -289,13 +290,18 @@ private:
|
|||
* whether Mozilla is already running.
|
||||
*/
|
||||
|
||||
class nsNativeAppSupportOS2 : public nsNativeAppSupportBase {
|
||||
class nsNativeAppSupportOS2 : public nsNativeAppSupportBase,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Overrides of base implementation.
|
||||
NS_IMETHOD Start( PRBool *aResult );
|
||||
NS_IMETHOD Stop( PRBool *aResult );
|
||||
NS_IMETHOD Quit();
|
||||
NS_IMETHOD SetShouldShowUI(PRBool aValue);
|
||||
void Quit();
|
||||
NS_IMETHOD Enable();
|
||||
|
||||
// The "old" Start method (renamed).
|
||||
NS_IMETHOD StartDDE();
|
||||
|
@ -350,6 +356,13 @@ private:
|
|||
friend struct MessageWindow;
|
||||
}; // nsNativeAppSupportOS2
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsNativeAppSupportOS2)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsNativeAppSupportBase)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsNativeAppSupportOS2, nsNativeAppSupportBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsNativeAppSupportOS2, nsNativeAppSupportBase)
|
||||
|
||||
void
|
||||
nsNativeAppSupportOS2::CheckConsole() {
|
||||
return;
|
||||
|
@ -912,6 +925,19 @@ nsNativeAppSupportOS2::Stop( PRBool *aResult ) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportOS2::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
{
|
||||
if (strcmp(aTopic, "quit-application") == 0) {
|
||||
Quit();
|
||||
} else {
|
||||
NS_ERROR("Unexpected observer topic.");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Terminate DDE regardless.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportOS2::Quit() {
|
||||
|
@ -920,7 +946,7 @@ nsNativeAppSupportOS2::Quit() {
|
|||
// window as we will destroy ours under our lock.
|
||||
// When the mutex goes off the stack, it is unlocked via destructor.
|
||||
Mutex mutexLock(mMutexName);
|
||||
NS_ENSURE_TRUE(mutexLock.Lock(MOZ_DDE_START_TIMEOUT), NS_ERROR_FAILURE );
|
||||
NS_ENSURE_TRUE(mutexLock.Lock(MOZ_DDE_START_TIMEOUT), NS_ERROR_FAILURE);
|
||||
|
||||
// If we've got a message window to receive IPC or new window requests,
|
||||
// get rid of it as we are shutting down.
|
||||
|
@ -951,10 +977,17 @@ nsNativeAppSupportOS2::Quit() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportOS2::SetShouldShowUI(PRBool aValue)
|
||||
nsNativeAppSupportOS2::Enable()
|
||||
{
|
||||
NS_ASSERTION(aValue, "True is the only allowed value!");
|
||||
mCanHandleRequests = aValue;
|
||||
mCanHandleRequests = PR_TRUE;
|
||||
nsCOMPtr<nsIObserverService> obs
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
if (obs) {
|
||||
obs->AddObserver(this, "quit-application", PR_FALSE);
|
||||
} else {
|
||||
NS_ERROR("No observer service?");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1614,14 +1647,11 @@ nsNativeAppSupportOS2::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
|
|||
}
|
||||
|
||||
// OK, now create nsICmdLineService object from argc/argv.
|
||||
static NS_DEFINE_CID( kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID );
|
||||
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
rv = compMgr->CreateInstance( kCmdLineServiceCID,
|
||||
0,
|
||||
NS_GET_IID( nsICmdLineService ),
|
||||
(void**)aResult );
|
||||
rv = compMgr->CreateInstanceByContractID("@mozilla.org/app-startup/commandLineService;1",
|
||||
0, NS_GET_IID( nsICmdLineService ),
|
||||
(void**) aResult);
|
||||
|
||||
if ( NS_FAILED( rv ) || NS_FAILED( ( rv = (*aResult)->Initialize( argc, argv ) ) ) ) {
|
||||
#if MOZ_DEBUG_DDE
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include "nsIPref.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsXPCOM.h"
|
||||
#ifdef MOZ_PHOENIX
|
||||
|
@ -264,13 +265,18 @@ private:
|
|||
* whether Mozilla is already running.
|
||||
*/
|
||||
|
||||
class nsNativeAppSupportWin : public nsNativeAppSupportBase {
|
||||
class nsNativeAppSupportWin : public nsNativeAppSupportBase,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Overrides of base implementation.
|
||||
NS_IMETHOD Start( PRBool *aResult );
|
||||
NS_IMETHOD Stop( PRBool *aResult );
|
||||
NS_IMETHOD Quit();
|
||||
NS_IMETHOD SetShouldShowUI(PRBool aValue);
|
||||
NS_IMETHOD Enable();
|
||||
|
||||
// The "old" Start method (renamed).
|
||||
NS_IMETHOD StartDDE();
|
||||
|
@ -326,6 +332,13 @@ private:
|
|||
friend struct MessageWindow;
|
||||
}; // nsNativeAppSupportWin
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsNativeAppSupportWin)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsNativeAppSupportBase)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsNativeAppSupportWin, nsNativeAppSupportBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsNativeAppSupportWin, nsNativeAppSupportBase)
|
||||
|
||||
void
|
||||
nsNativeAppSupportWin::CheckConsole() {
|
||||
for ( int i = 1; i < __argc; i++ ) {
|
||||
|
@ -766,6 +779,19 @@ nsNativeAppSupportWin::Stop( PRBool *aResult ) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportWin::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
{
|
||||
if (strcmp(aTopic, "quit-application") == 0) {
|
||||
Quit();
|
||||
} else {
|
||||
NS_ERROR("Unexpected observer topic.");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Terminate DDE regardless.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportWin::Quit() {
|
||||
|
@ -774,7 +800,7 @@ nsNativeAppSupportWin::Quit() {
|
|||
// window as we will destroy ours under our lock.
|
||||
// When the mutex goes off the stack, it is unlocked via destructor.
|
||||
Mutex mutexLock(mMutexName);
|
||||
NS_ENSURE_TRUE(mutexLock.Lock(MOZ_DDE_START_TIMEOUT), NS_ERROR_FAILURE );
|
||||
NS_ENSURE_TRUE(mutexLock.Lock(MOZ_DDE_START_TIMEOUT), NS_ERROR_FAILURE);
|
||||
|
||||
// If we've got a message window to receive IPC or new window requests,
|
||||
// get rid of it as we are shutting down.
|
||||
|
@ -814,10 +840,18 @@ nsNativeAppSupportWin::Quit() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportWin::SetShouldShowUI(PRBool aValue)
|
||||
nsNativeAppSupportWin::Enable()
|
||||
{
|
||||
NS_ASSERTION(aValue, "True is the only allowed value!");
|
||||
mCanHandleRequests = aValue;
|
||||
mCanHandleRequests = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
if (obs) {
|
||||
obs->AddObserver(this, "quit-application", PR_FALSE);
|
||||
} else {
|
||||
NS_ERROR("No observer service?");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1499,14 +1533,11 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
|
|||
}
|
||||
|
||||
// OK, now create nsICmdLineService object from argc/argv.
|
||||
static NS_DEFINE_CID( kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID );
|
||||
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
rv = compMgr->CreateInstance( kCmdLineServiceCID,
|
||||
0,
|
||||
NS_GET_IID( nsICmdLineService ),
|
||||
(void**)aResult );
|
||||
rv = compMgr->CreateInstanceByContractID("@mozilla.org/app-startup/commandLineService;1",
|
||||
0, NS_GET_IID( nsICmdLineService ),
|
||||
(void**) aResult);
|
||||
|
||||
if ( NS_FAILED( rv ) || NS_FAILED( ( rv = (*aResult)->Initialize( argc, argv ) ) ) ) {
|
||||
#if MOZ_DEBUG_DDE
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* 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 of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -34,26 +35,32 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* This file has *public* stuff needed for the Win32 implementation of
|
||||
* the nsINativeAppSupport interface. It has to be broken out into a
|
||||
* separate file in order to ensure that the generated .h file can be
|
||||
* used in a Win32 .rc file. See /mozilla/xpfe/bootstrap/splash.rc.
|
||||
*
|
||||
* This file, and the generated .h, are only needed on Win32 platforms.
|
||||
*/
|
||||
|
||||
#ifndef nsAppShellCIDs_h__
|
||||
#define nsAppShellCIDs_h__
|
||||
#include "nsIFactory.h"
|
||||
// Constants identifying Win32 "native" resources.
|
||||
|
||||
// 43147b80-8a39-11d2-9938-0080c7cb1080
|
||||
#define NS_APPSHELL_SERVICE_CID \
|
||||
{ 0x43147b80, 0x8a39, 0x11d2, \
|
||||
{0x99, 0x38, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x80} }
|
||||
#ifdef MOZ_PHOENIX
|
||||
|
||||
// XXX: This is temporary...
|
||||
// 106b6f40-d79e-11d2-99db-0080c7cb1080
|
||||
#define NS_PROTOCOL_HELPER_CID \
|
||||
{ 0x106b6f40, 0xd79e, 0x11d2, \
|
||||
{0x99, 0xdb, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x80} }
|
||||
// Splash screen dialog ID.
|
||||
#define IDD_SPLASH 100
|
||||
|
||||
#define NS_SESSIONHISTORY_CID \
|
||||
{ 0x68e73d52, 0x12eb, 0x11d3, { 0xbd, 0xc0, 0x00, 0x50, 0x04, 0x0a, 0x9b, 0x44 } }
|
||||
// Splash screen bitmap ID.
|
||||
#define IDB_SPLASH 101
|
||||
|
||||
extern nsresult NS_NewSessionHistoryFactory(nsIFactory** aResult);
|
||||
// DDE application name
|
||||
#define ID_DDE_APPLICATION_NAME 102
|
||||
|
||||
#endif /* nsAppShellCIDs_h__ */
|
||||
#define IDI_APPICON 0
|
||||
#define IDI_DOCUMENT 1
|
||||
|
||||
#endif
|
||||
|
||||
// String that goes in the WinXP Start Menu.
|
||||
#define IDS_STARTMENU_APPNAME 103
|
|
@ -46,7 +46,6 @@
|
|||
#include "nsIAppShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsGtkEventHandler.h"
|
||||
#include <stdlib.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
@ -126,7 +125,6 @@ static unsigned long getNextRequest (void *aClosure) {
|
|||
//
|
||||
//-------------------------------------------------------------------------
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -206,22 +204,6 @@ NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav)
|
|||
|
||||
sInitialized = PR_TRUE;
|
||||
|
||||
int argc = bac ? *bac : 0;
|
||||
char **argv = bav;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs = do_GetService(kCmdLineServiceCID);
|
||||
if (cmdLineArgs) {
|
||||
rv = cmdLineArgs->GetArgc(&argc);
|
||||
if(NS_FAILED(rv))
|
||||
argc = bac ? *bac : 0;
|
||||
|
||||
rv = cmdLineArgs->GetArgv(&argv);
|
||||
if(NS_FAILED(rv))
|
||||
argv = bav;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIDragService.h"
|
||||
#include "nsIDragSessionXlib.h"
|
||||
#include "nsITimer.h"
|
||||
|
@ -68,7 +67,6 @@
|
|||
#define CHAR_BUF_SIZE 80
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
||||
|
||||
/* nsAppShell static members */
|
||||
|
@ -178,17 +176,6 @@ NS_METHOD nsAppShell::Create(int* bac, char ** bav)
|
|||
char **argv = bav;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs = do_GetService(kCmdLineServiceCID);
|
||||
if (cmdLineArgs) {
|
||||
rv = cmdLineArgs->GetArgc(&argc);
|
||||
if(NS_FAILED(rv))
|
||||
argc = bac ? *bac : 0;
|
||||
|
||||
rv = cmdLineArgs->GetArgv(&argv);
|
||||
if(NS_FAILED(rv))
|
||||
argv = bav;
|
||||
}
|
||||
|
||||
char *displayName = nsnull;
|
||||
Bool synchronize = False;
|
||||
int i;
|
||||
|
|
|
@ -48,30 +48,17 @@ GRE_MODULE = 1
|
|||
|
||||
EXPORTS = \
|
||||
nsIWebShellWindow.h \
|
||||
nsAppShellCIDs.h \
|
||||
nsISplashScreen.h \
|
||||
nsAppShellCID.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIAppShellService.idl \
|
||||
nsICmdLineService.idl \
|
||||
nsICmdLineHandler.idl \
|
||||
nsIWindowMediator.idl \
|
||||
nsIWindowMediatorListener.idl \
|
||||
nsIXULWindow.idl \
|
||||
nsIUserInfo.idl \
|
||||
nsINativeAppSupport.idl \
|
||||
nsIPopupWindowManager.idl \
|
||||
nsICloseAllWindows.idl \
|
||||
nsIXULBrowserWindow.idl \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
XPIDLSRCS += nsINativeAppSupportWin.idl
|
||||
endif
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
EXPORTS += nsAppleEvents.h
|
||||
XPIDLSRCS += nsICloseAllWindows.idl
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -12,19 +11,18 @@
|
|||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
* The Original Code is Mozilla Gecko.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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"),
|
||||
* 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
|
||||
|
@ -36,18 +34,9 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsEditorService.h"
|
||||
#include "nsString.h"
|
||||
#include "plstr.h"
|
||||
#ifndef nsAppShellCID_h__
|
||||
#define nsAppShellCID_h__
|
||||
|
||||
nsEditorService::nsEditorService()
|
||||
{
|
||||
}
|
||||
#define NS_APPSHELLSERVICE_CONTRACTID "@mozilla.org/appshell/appShellService;1"
|
||||
|
||||
nsEditorService::~nsEditorService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsEditorService, nsICmdLineHandler)
|
||||
|
||||
CMDLINEHANDLER_IMPL(nsEditorService,"-edit","general.startup.editor","chrome://editor/content/editor.xul","Start with editor.","@mozilla.org/commandlinehandler/general-startup;1?type=editor","Editor Startup Handler", PR_TRUE,"about:blank", PR_TRUE)
|
||||
#endif
|
|
@ -39,9 +39,8 @@
|
|||
|
||||
interface nsIXULWindow;
|
||||
interface nsIURI;
|
||||
interface nsICmdLineService;
|
||||
interface nsINativeAppSupport;
|
||||
interface nsIDOMWindowInternal;
|
||||
interface nsIAppShell;
|
||||
|
||||
[ptr] native JSContext(JSContext);
|
||||
|
||||
|
@ -49,49 +48,9 @@ interface nsIDOMWindowInternal;
|
|||
struct JSContext;
|
||||
%}
|
||||
|
||||
[scriptable, uuid(E5E5AF70-8A38-11D2-9938-0080C7CB1080)]
|
||||
[scriptable, uuid(70c04d53-150f-450b-9106-387487a3c031)]
|
||||
interface nsIAppShellService : nsISupports
|
||||
{
|
||||
|
||||
const PRUint32 eConsiderQuit = 1; // attempt to quit if all windows are closed
|
||||
const PRUint32 eAttemptQuit = 2; // try to close all windows, then quit if successful
|
||||
const PRUint32 eForceQuit = 3; // quit, damnit
|
||||
|
||||
/**
|
||||
* Required initialization routine.
|
||||
* @param aCmdLineService is stored and passed to appshell components as
|
||||
* they are initialized.
|
||||
* @param aNativeAppSupportOrSplashScreen is an object that can be
|
||||
* QI'd to either an nsINativeAppSupport or
|
||||
* nsISplashScreen; this object will be used to
|
||||
* implement HideSplashScreen.
|
||||
*/
|
||||
void initialize(in nsICmdLineService aCmdLineService,
|
||||
in nsISupports nativeAppSupportOrSplashScreen);
|
||||
|
||||
/**
|
||||
* Starts up the profile manager with the given arguments
|
||||
* @param aCmdLineService the arguments given to the program
|
||||
* @param canInteract If FALSE and UI is needed, will fail
|
||||
*/
|
||||
void doProfileStartup(in nsICmdLineService aCmdLineService, in boolean canInteract);
|
||||
|
||||
/**
|
||||
* Getter for "native app support."
|
||||
*/
|
||||
readonly attribute nsINativeAppSupport nativeAppSupport;
|
||||
|
||||
/**
|
||||
* Runs an application event loop: normally the main event pump which
|
||||
* defines the lifetime of the application.
|
||||
*/
|
||||
void run();
|
||||
|
||||
/**
|
||||
* Exit the event loop, shut down the app
|
||||
*/
|
||||
void quit(in PRUint32 aFerocity);
|
||||
|
||||
/**
|
||||
* Create a window.
|
||||
* @param aParent the parent window. Can be null.
|
||||
|
@ -110,6 +69,8 @@ interface nsIAppShellService : nsISupports
|
|||
* tag in the XUL. Set to NS_SIZETOCONTENT to force
|
||||
* the window to wrap to its contents.
|
||||
* @param aInitialHeight like aInitialWidth, but subtly different.
|
||||
* @param aAppShell a widget "appshell" (event processor) to associate
|
||||
* with the new window
|
||||
* @param aResult the newly created window is returned here.
|
||||
*/
|
||||
const long SIZE_TO_CONTENT = -1;
|
||||
|
@ -119,7 +80,8 @@ interface nsIAppShellService : nsISupports
|
|||
in boolean aLoadDefaultPage,
|
||||
in PRUint32 aChromeMask,
|
||||
in long aInitialWidth,
|
||||
in long aInitialHeight);
|
||||
in long aInitialHeight,
|
||||
in nsIAppShell aAppShell);
|
||||
|
||||
/**
|
||||
* Close a window.
|
||||
|
@ -128,7 +90,9 @@ interface nsIAppShellService : nsISupports
|
|||
void closeTopLevelWindow(in nsIXULWindow aWindow);
|
||||
|
||||
[noscript]
|
||||
void createHiddenWindow();
|
||||
void createHiddenWindow(in nsIAppShell aAppShell);
|
||||
|
||||
void destroyHiddenWindow();
|
||||
|
||||
/**
|
||||
* Return the (singleton) application hidden window, automatically created
|
||||
|
@ -146,7 +110,6 @@ interface nsIAppShellService : nsISupports
|
|||
*/
|
||||
readonly attribute nsIDOMWindowInternal hiddenDOMWindow;
|
||||
|
||||
|
||||
/**
|
||||
* Return the (singleton) application hidden window as an nsIDOMWindowInternal,
|
||||
* and, the corresponding JavaScript context pointer. This is useful
|
||||
|
@ -162,7 +125,9 @@ interface nsIAppShellService : nsISupports
|
|||
* Add a window to the application's registry of windows. These windows
|
||||
* are generally shown in the Windows taskbar, and the application
|
||||
* knows it can't quit until it's out of registered windows.
|
||||
* @param aWindow yes
|
||||
* @param aWindow the window to register
|
||||
* @note When this method is successful, it fires the global notification
|
||||
* "xul-window-registered"
|
||||
*/
|
||||
void registerTopLevelWindow(in nsIXULWindow aWindow);
|
||||
|
||||
|
@ -183,39 +148,4 @@ interface nsIAppShellService : nsISupports
|
|||
* false if aWindow is becoming nonmodal (or being closed)
|
||||
*/
|
||||
void topLevelWindowIsModal(in nsIXULWindow aWindow, in boolean aModal);
|
||||
|
||||
/**
|
||||
* Remove the splash screen (if visible). This need be called
|
||||
* only once per application session.
|
||||
*/
|
||||
void hideSplashScreen();
|
||||
|
||||
/**
|
||||
* During application startup (and at other times!) we may temporarily
|
||||
* encounter a situation where all application windows will be closed
|
||||
* but we don't want to take this as a signal to quit the app. Bracket
|
||||
* the code where the last window could close with these.
|
||||
* (And at application startup, on platforms that don't normally quit
|
||||
* when the last window has closed, call Enter once, but not Exit)
|
||||
*/
|
||||
void enterLastWindowClosingSurvivalArea();
|
||||
void exitLastWindowClosingSurvivalArea();
|
||||
|
||||
/**
|
||||
* Creates the initial state of the application by launching tasks
|
||||
* specfied by "general.startup.*" prefs.
|
||||
* @param aWindowWidth the width to make the initial window(s) opened
|
||||
* @param aWindowHeight the height to make the initial window(s) opened
|
||||
* @note SIZE_TO_CONTENT may be used for width or height.
|
||||
* @return TRUE if a window was opened
|
||||
*/
|
||||
boolean createStartupState(in long aWindowWidth, in long aWindowHeight);
|
||||
|
||||
/**
|
||||
* Ensures that at least one window exists after creating the startup state.
|
||||
* If one has not been made, this will create a browser window.
|
||||
* @param aCmdLineService the command line from which startup args can be read.
|
||||
*/
|
||||
void ensure1Window(in nsICmdLineService aCmdLineService);
|
||||
};
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
interface nsICloseAllWindows : nsISupports
|
||||
{
|
||||
/**
|
||||
Closes all open windows, optionally asking to confirm changes if any.
|
||||
Returns TRUE is the user does not cancel from any confirmation dialog.
|
||||
*/
|
||||
* Closes all open windows, optionally asking to confirm changes if any.
|
||||
* @return TRUE if the user does not cancel from any confirmation dialog.
|
||||
*/
|
||||
boolean closeAll(in boolean askSave);
|
||||
};
|
||||
|
||||
|
|
|
@ -39,13 +39,6 @@
|
|||
#include "nsIFactory.idl"
|
||||
#include "nsICmdLineHandler.idl"
|
||||
|
||||
%{C++
|
||||
// e34783f5-ac08-11d2-8d19-00805fc2500c
|
||||
#define NS_COMMANDLINE_SERVICE_CID \
|
||||
{ 0xe34783f5, 0xac08, 0x11d2, \
|
||||
{0x8d, 0x19, 0x00, 0x80, 0x5f, 0xc2, 0x50,0xc} }
|
||||
%}
|
||||
|
||||
[ptr] native charArray(char*);
|
||||
[scriptable, uuid(e34783f4-ac08-11d2-8d19-00805fc2500c)]
|
||||
interface nsICmdLineService : nsISupports
|
||||
|
@ -98,5 +91,4 @@ interface nsICmdLineService : nsISupports
|
|||
* string if you want the "default" handler
|
||||
*/
|
||||
nsICmdLineHandler getHandlerForParam(in string param);
|
||||
|
||||
};
|
||||
|
|
|
@ -41,69 +41,78 @@
|
|||
|
||||
/**
|
||||
* The nsIXULWindow
|
||||
*
|
||||
* When the window is destroyed, it will fire a "xul-window-destroyed"
|
||||
* notification through the global observer service.
|
||||
*/
|
||||
|
||||
interface nsIDocShell;
|
||||
interface nsIDocShellTreeItem;
|
||||
interface nsIAppShell;
|
||||
interface nsIXULBrowserWindow;
|
||||
|
||||
[scriptable, uuid(5d72a699-a252-4161-a45f-e7d35e78b7f3)]
|
||||
interface nsIXULWindow : nsISupports
|
||||
{
|
||||
/**
|
||||
The docshell owning the XUL for this window.
|
||||
*/
|
||||
* The docshell owning the XUL for this window.
|
||||
*/
|
||||
readonly attribute nsIDocShell docShell;
|
||||
|
||||
/**
|
||||
Indicates if this window is instrinsically sized.
|
||||
*/
|
||||
* Indicates if this window is instrinsically sized.
|
||||
*/
|
||||
attribute boolean intrinsicallySized;
|
||||
|
||||
/**
|
||||
This returns the primary content shell.
|
||||
|
||||
Note that this is a docshell tree item and therefore can not be assured of
|
||||
what object it is. It could be an editor, a docshell, or a browser object.
|
||||
Or down the road any other object that supports being a DocShellTreeItem
|
||||
Query accordingly to determine the capabilities.
|
||||
*/
|
||||
* The primary content shell.
|
||||
*
|
||||
* Note that this is a docshell tree item and therefore can not be assured of
|
||||
* what object it is. It could be an editor, a docshell, or a browser object.
|
||||
* Or down the road any other object that supports being a DocShellTreeItem
|
||||
* Query accordingly to determine the capabilities.
|
||||
*/
|
||||
readonly attribute nsIDocShellTreeItem primaryContentShell;
|
||||
|
||||
/**
|
||||
This returns the content shell specified by the supplied id.
|
||||
|
||||
Note that this is a docshell tree item and therefore can not be assured of
|
||||
what object it is. It could be an editor, a docshell, or a browser object.
|
||||
Or down the road any other object that supports being a DocShellTreeItem
|
||||
Query accordingly to determine the capabilities.
|
||||
*/
|
||||
* The content shell specified by the supplied id.
|
||||
*
|
||||
* Note that this is a docshell tree item and therefore can not be assured of
|
||||
* what object it is. It could be an editor, a docshell, or a browser object.
|
||||
* Or down the road any other object that supports being a DocShellTreeItem
|
||||
* Query accordingly to determine the capabilities.
|
||||
*/
|
||||
nsIDocShellTreeItem getContentShellById(in wstring ID);
|
||||
|
||||
/**
|
||||
Tell this window that it has picked up or lost a child XUL window
|
||||
@param aChild the child window being added or removed
|
||||
*/
|
||||
* Tell this window that it has picked up a child XUL window
|
||||
* @param aChild the child window being added
|
||||
*/
|
||||
void addChildWindow(in nsIXULWindow aChild);
|
||||
|
||||
/**
|
||||
* Tell this window that it has lost a child XUL window
|
||||
* @param aChild the child window being removed
|
||||
*/
|
||||
void removeChildWindow(in nsIXULWindow aChild);
|
||||
|
||||
/**
|
||||
Move the window to a centered position.
|
||||
@param aRelative the window relative to which the window is moved.
|
||||
See screen parameter for details. if null, the
|
||||
window is centered relative to the main screen.
|
||||
@param aScreen PR_TRUE to center the window relative to the screen
|
||||
containing aRelative. PR_FALSE to center it relative
|
||||
to aRelative itself.
|
||||
@param aAlert PR_TRUE to move the window to an alert position,
|
||||
generally centered horizontally and 1/3 down from the top.
|
||||
*/
|
||||
* Move the window to a centered position.
|
||||
* @param aRelative the window relative to which the window is moved.
|
||||
* See screen parameter for details. if null, the
|
||||
* window is centered relative to the main screen.
|
||||
* @param aScreen PR_TRUE to center the window relative to the screen
|
||||
* containing aRelative. PR_FALSE to center it relative
|
||||
* to aRelative itself.
|
||||
* @param aAlert PR_TRUE to move the window to an alert position,
|
||||
* generally centered horizontally and 1/3 down from the top.
|
||||
*/
|
||||
void center(in nsIXULWindow aRelative, in boolean aScreen, in boolean aAlert);
|
||||
|
||||
/**
|
||||
Shows the window as a modal window. That is, ensures that it is visible
|
||||
and runs a local event loop, exiting only once the window has been closed.
|
||||
*/
|
||||
* Shows the window as a modal window. That is, ensures that it is visible
|
||||
* and runs a local event loop, exiting only once the window has been closed.
|
||||
*/
|
||||
void showModal();
|
||||
|
||||
const unsigned long lowestZ = 0;
|
||||
|
@ -112,20 +121,20 @@ interface nsIXULWindow : nsISupports
|
|||
const unsigned long raisedZ = 6; /* "alwaysRaised" attribute */
|
||||
const unsigned long highestZ = 9;
|
||||
|
||||
attribute unsigned long zLevel;
|
||||
attribute unsigned long zLevel;
|
||||
|
||||
/**
|
||||
* contextFlags are from nsIWindowCreator2
|
||||
*/
|
||||
attribute PRUint32 contextFlags;
|
||||
attribute PRUint32 contextFlags;
|
||||
|
||||
/**
|
||||
Create a new window.
|
||||
@param aChromeFlags: see nsIWebBrowserChrome
|
||||
@return the newly minted window
|
||||
*/
|
||||
nsIXULWindow createNewWindow(in PRInt32 aChromeFlags);
|
||||
* Create a new window.
|
||||
* @param aChromeFlags see nsIWebBrowserChrome
|
||||
* @return the newly minted window
|
||||
*/
|
||||
nsIXULWindow createNewWindow(in PRInt32 aChromeFlags,
|
||||
in nsIAppShell aAppShell);
|
||||
|
||||
attribute nsIXULBrowserWindow XULBrowserWindow;
|
||||
};
|
||||
|
||||
|
|
|
@ -72,16 +72,11 @@ REQUIRES = xpcom \
|
|||
windowwatcher \
|
||||
browser \
|
||||
caps \
|
||||
profile \
|
||||
unicharutil \
|
||||
uconv \
|
||||
exthandler \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PHOENIX
|
||||
REQUIRES += profilemanager
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
nsChromeTreeOwner.cpp \
|
||||
nsContentTreeOwner.cpp \
|
||||
|
@ -89,33 +84,11 @@ CPPSRCS = \
|
|||
nsAppShellService.cpp \
|
||||
nsAppShellWindowEnumerator.cpp \
|
||||
nsWebShellWindow.cpp \
|
||||
nsCommandLineService.cpp \
|
||||
nsWindowMediator.cpp \
|
||||
nsAbout.cpp \
|
||||
nsAppShellFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
CPPSRCS += nsUserInfoOS2.cpp
|
||||
else
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
CPPSRCS += nsUserInfoWin.cpp
|
||||
else
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS += \
|
||||
nsUserInfoMac.cpp \
|
||||
nsCommandLineServiceMac.cpp \
|
||||
$(NULL)
|
||||
OS_CXXFLAGS += -fexceptions
|
||||
EXTRA_COMPONENTS += nsCloseAllWindows.js
|
||||
else
|
||||
CPPSRCS += nsUserInfoUnix.cpp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_COMPONENTS = nsCloseAllWindows.js
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
EXTRA_DSO_LIBS = gkgfx
|
||||
endif
|
||||
|
@ -128,11 +101,5 @@ EXTRA_DSO_LDOPTS = \
|
|||
$(MOZ_JS_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifeq (,$(filter-out mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
SHARED_LIBRARY_LIBS = $(DIST)/lib/$(LIB_PREFIX)appleevents_s.$(LIB_SUFFIX)
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../../bootstrap/appleevents
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -34,45 +34,31 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsAbout.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsCommandLineService.h"
|
||||
#include "nsAppShellService.h"
|
||||
#include "nsWindowMediator.h"
|
||||
#include "nsChromeTreeOwner.h"
|
||||
#include "nsAppShellCID.h"
|
||||
|
||||
#include "nsUserInfo.h"
|
||||
|
||||
/* extern the factory entry points for each component... */
|
||||
nsresult NS_NewAppShellServiceFactory(nsIFactory** aFactory);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCmdLineService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShellService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowMediator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUserInfo)
|
||||
|
||||
static const nsModuleComponentInfo gAppShellModuleInfo[] =
|
||||
{
|
||||
{ "AppShell Service",
|
||||
NS_APPSHELL_SERVICE_CID,
|
||||
"@mozilla.org/appshell/appShellService;1",
|
||||
NS_APPSHELLSERVICE_CID,
|
||||
NS_APPSHELLSERVICE_CONTRACTID,
|
||||
nsAppShellServiceConstructor,
|
||||
},
|
||||
{ "CommandLine Service",
|
||||
NS_COMMANDLINE_SERVICE_CID,
|
||||
"@mozilla.org/appshell/commandLineService;1",
|
||||
nsCmdLineServiceConstructor,
|
||||
},
|
||||
{ "Window Mediator",
|
||||
NS_WINDOWMEDIATOR_CID,
|
||||
NS_WINDOWMEDIATOR_CONTRACTID,
|
||||
|
@ -82,12 +68,7 @@ static const nsModuleComponentInfo gAppShellModuleInfo[] =
|
|||
NS_ABOUT_CID,
|
||||
NS_ABOUT_MODULE_CONTRACTID_PREFIX,
|
||||
nsAbout::Create,
|
||||
},
|
||||
{ "User Info Service",
|
||||
NS_USERINFO_CID,
|
||||
NS_USERINFO_CONTRACTID,
|
||||
nsUserInfoConstructor,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(nsresult)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -34,83 +34,48 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsAppShellService_h
|
||||
#define __nsAppShellService_h
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsINativeAppSupport.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "plevent.h"
|
||||
|
||||
//Interfaces Needed
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsPIWindowWatcher.h"
|
||||
#include "nsISplashScreen.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
// {0099907D-123C-4853-A46A-43098B5FB68C}
|
||||
#define NS_APPSHELLSERVICE_CID \
|
||||
{ 0x99907d, 0x123c, 0x4853, { 0xa4, 0x6a, 0x43, 0x9, 0x8b, 0x5f, 0xb6, 0x8c } }
|
||||
|
||||
class nsAppShellService : public nsIAppShellService,
|
||||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
nsAppShellService(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAPPSHELLSERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
protected:
|
||||
virtual ~nsAppShellService();
|
||||
nsAppShellService();
|
||||
|
||||
protected:
|
||||
~nsAppShellService();
|
||||
|
||||
void RegisterObserver(PRBool aRegister);
|
||||
NS_IMETHOD JustCreateTopWindow(nsIXULWindow *aParent,
|
||||
nsIURI *aUrl,
|
||||
PRBool aShowWindow, PRBool aLoadDefaultPage,
|
||||
PRUint32 aChromeMask,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
|
||||
PRBool aIsHiddenWindow, nsIXULWindow **aResult);
|
||||
PRBool aIsHiddenWindow, nsIAppShell* aAppShell,
|
||||
nsIXULWindow **aResult);
|
||||
PRUint32 CalculateWindowZLevel(nsIXULWindow *aParent, PRUint32 aChromeMask);
|
||||
nsresult SetXPConnectSafeContext();
|
||||
nsresult ClearXPConnectSafeContext();
|
||||
void AttemptingQuit(PRBool aAttempt);
|
||||
|
||||
nsCOMPtr<nsIAppShell> mAppShell;
|
||||
nsCOMPtr<nsICmdLineService> mCmdLineService;
|
||||
nsCOMPtr<nsIWindowMediator> mWindowMediator;
|
||||
nsCOMPtr<nsPIWindowWatcher> mWindowWatcher;
|
||||
nsCOMPtr<nsIXULWindow> mHiddenWindow;
|
||||
PRBool mXPCOMShuttingDown;
|
||||
#ifndef MOZ_XUL_APP
|
||||
nsCOMPtr<nsISplashScreen> mSplashScreen;
|
||||
#endif
|
||||
nsCOMPtr<nsINativeAppSupport> mNativeAppSupport;
|
||||
|
||||
PRUint16 mModalWindowCount;
|
||||
PRInt32 mConsiderQuitStopper; // if > 0, Quit(eConsiderQuit) fails
|
||||
PRPackedBool mShuttingDown; // Quit method reentrancy check
|
||||
PRPackedBool mAttemptingQuit; // Quit(eAttemptQuit) still trying
|
||||
|
||||
// A "last event" that is used to flush the appshell's event queue.
|
||||
PR_STATIC_CALLBACK(void*) HandleExitEvent(PLEvent* aEvent);
|
||||
PR_STATIC_CALLBACK(void) DestroyExitEvent(PLEvent* aEvent);
|
||||
|
||||
private:
|
||||
#ifndef MOZ_XUL_APP
|
||||
nsresult CheckAndRemigrateDefunctProfile();
|
||||
#endif
|
||||
|
||||
nsresult LaunchTask(const char *aParam,
|
||||
PRInt32 height, PRInt32 width,
|
||||
PRBool *windowOpened);
|
||||
|
||||
nsresult OpenWindow(const nsAFlatCString& aChromeURL,
|
||||
const nsAFlatString& aAppArgs,
|
||||
PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width);
|
||||
|
||||
PRPackedBool mXPCOMShuttingDown;
|
||||
PRUint16 mModalWindowCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -62,4 +62,9 @@ protected:
|
|||
PRBool ArgsMatch(const char *lookingFor, const char *userGave);
|
||||
};
|
||||
|
||||
// e34783f5-ac08-11d2-8d19-00805fc2500c
|
||||
#define NS_COMMANDLINESERVICE_CID \
|
||||
{ 0xe34783f5, 0xac08, 0x11d2, \
|
||||
{0x8d, 0x19, 0x00, 0x80, 0x5f, 0xc2, 0x50,0xc} }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "nsILocalFileMac.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIIOService.h"
|
||||
|
@ -65,6 +65,7 @@
|
|||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsAEEventHandling.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
// NSPR
|
||||
#include "prmem.h"
|
||||
|
@ -74,9 +75,6 @@
|
|||
#include "pprio.h" // PR_Init_Log
|
||||
#endif
|
||||
|
||||
#include "nsAppShellCIDs.h"
|
||||
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
||||
// the static instance
|
||||
nsMacCommandLine nsMacCommandLine::sMacCommandLine;
|
||||
|
||||
|
@ -402,12 +400,12 @@ OSErr nsMacCommandLine::Quit(TAskSave askSave)
|
|||
if (NS_FAILED(rv) || !doQuit)
|
||||
return errAEEventNotHandled;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService =
|
||||
do_GetService(kAppShellServiceCID, &rv);
|
||||
nsCOMPtr<nsIAppStartup> appStartup =
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return errAEEventNotHandled;
|
||||
|
||||
(void)appShellService->Quit(nsIAppShellService::eAttemptQuit);
|
||||
(void)appStartup->Quit(nsIAppStartup::eAttemptQuit);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is 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):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "nsPreloader.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIAppStartupNotifier.h"
|
||||
|
||||
struct preloadEntry {
|
||||
PRBool isService;
|
||||
const char* contractId;
|
||||
};
|
||||
|
||||
static preloadEntry preloadedObjects[] = {
|
||||
// necko
|
||||
{PR_TRUE, "@mozilla.org/network/io-service;1" },
|
||||
// rdf
|
||||
{PR_TRUE, "@mozilla.org/rdf/rdf-service;1" },
|
||||
// preferences
|
||||
{PR_TRUE, "@mozilla.org/preferences-service;1" },
|
||||
// string bundles
|
||||
{PR_TRUE, "@mozilla.org/intl/stringbundle;1" },
|
||||
// docshell
|
||||
{PR_FALSE, "@mozilla.org/docshell/html;1" },
|
||||
// imglib
|
||||
|
||||
// appcomps
|
||||
// parser
|
||||
};
|
||||
|
||||
#define PRELOADED_SERVICES_COUNT (sizeof(preloadedObjects) / sizeof(preloadedObjects[0]))
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPreloader, nsICmdLineHandler)
|
||||
|
||||
nsPreloader::nsPreloader()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPreloader::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIObserver> startupNotifier =
|
||||
do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = startupNotifier->Observe(nsnull, NS_LITERAL_STRING("preloaded-services").get(), nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsPreloader::~nsPreloader()
|
||||
{
|
||||
}
|
||||
|
||||
CMDLINEHANDLER1_IMPL(nsPreloader, // classname
|
||||
"-server", // arguments
|
||||
"general.startup.server", // pref name (not used)
|
||||
"Load and stay resident!", // command line help text
|
||||
PR_FALSE, // handles window arguments?
|
||||
"", // no window arguments
|
||||
PR_FALSE) // don't open a window
|
||||
|
||||
CMDLINEHANDLER_GETCHROMEURL_IMPL(nsPreloader,nsnull)
|
||||
CMDLINEHANDLER_GETDEFAULTARGS_IMPL(nsPreloader,"")
|
||||
|
||||
NS_METHOD
|
||||
nsPreloader::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService("@mozilla.org/categorymanager;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS,
|
||||
"Preloader Commandline Handler",
|
||||
NS_PRELOADER_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// now register all the well-known services
|
||||
|
||||
PRInt32 i;
|
||||
for (i=0; i<PRELOADED_SERVICES_COUNT; i++) {
|
||||
nsCAutoString categoryEntry;
|
||||
|
||||
if (preloadedObjects[i].isService)
|
||||
categoryEntry.Append("service,");
|
||||
|
||||
categoryEntry.Append(preloadedObjects[i].contractId);
|
||||
|
||||
catman->AddCategoryEntry("preloaded-services",
|
||||
categoryEntry.get(), // key - must be unique
|
||||
categoryEntry.get(), // value - the contractid
|
||||
PR_TRUE, PR_TRUE, nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPreloader::UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aFile, const char *registryLocation,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("@mozilla.org/categorymanager;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = catman->DeleteCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS,
|
||||
NS_PRELOADER_CONTRACTID,
|
||||
PR_TRUE);
|
||||
|
||||
// unregister well-known services?
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -72,7 +72,6 @@
|
|||
#include "nsIAppShell.h"
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "nsXULWindow.h"
|
||||
|
||||
// Helper classes
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "prprf.h"
|
||||
|
@ -86,6 +85,7 @@
|
|||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsAppShellCID.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
|
@ -109,7 +109,6 @@
|
|||
#define ZLEVEL_ATTRIBUTE NS_LITERAL_STRING("zlevel")
|
||||
// CIDs
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
@ -363,7 +362,7 @@ NS_IMETHODIMP nsXULWindow::ShowModal()
|
|||
mContinueModalLoop = PR_TRUE;
|
||||
EnableParent(PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID));
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
if (appShellService)
|
||||
appShellService->TopLevelWindowIsModal(
|
||||
NS_STATIC_CAST(nsIXULWindow*, this), PR_TRUE);
|
||||
|
@ -434,7 +433,8 @@ NS_IMETHODIMP nsXULWindow::Destroy()
|
|||
if(!mWindow)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID));
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
NS_ASSERTION(appShell, "Couldn't get appShell... xpcom shutdown?");
|
||||
if(appShell)
|
||||
appShell->UnregisterTopLevelWindow(NS_STATIC_CAST(nsIXULWindow*, this));
|
||||
|
||||
|
@ -442,25 +442,6 @@ NS_IMETHODIMP nsXULWindow::Destroy()
|
|||
if (parentWindow)
|
||||
parentWindow->RemoveChildWindow(this);
|
||||
|
||||
// Anyone still using native menus should add themselves here.
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
{
|
||||
// unregister as document listener
|
||||
// this is needed for menus
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
if(mDocShell)
|
||||
mDocShell->GetContentViewer(getter_AddRefs(cv));
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
||||
if(docv)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
docv->GetDocument(getter_AddRefs(doc));
|
||||
/* if(doc)
|
||||
doc->RemoveObserver(NS_STATIC_CAST(nsIDocumentObserver*, this)); */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// let's make sure the window doesn't get deleted out from under us
|
||||
// while we are trying to close....this can happen if the docshell
|
||||
// we close ends up being the last owning reference to this xulwindow
|
||||
|
@ -534,14 +515,18 @@ NS_IMETHODIMP nsXULWindow::Destroy()
|
|||
mWindow = nsnull;
|
||||
}
|
||||
|
||||
/* Inform the appshellservice we've destroyed this window and it could
|
||||
/* Inform appstartup we've destroyed this window and it could
|
||||
quit now if it wanted. This must happen at least after mDocShell
|
||||
is destroyed, because onunload handlers fire then, and those being
|
||||
script, anything could happen. A new window could open, even.
|
||||
See bug 130719. */
|
||||
if(appShell)
|
||||
appShell->Quit(nsIAppShellService::eConsiderQuit);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obssvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
NS_ASSERTION(obssvc, "Couldn't get observer service?");
|
||||
|
||||
if (obssvc)
|
||||
obssvc->NotifyObservers(nsnull, "xul-window-destroyed", nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -760,15 +745,14 @@ NS_IMETHODIMP nsXULWindow::SetVisibility(PRBool aVisibility)
|
|||
if(windowMediator)
|
||||
windowMediator->UpdateWindowTimeStamp(NS_STATIC_CAST(nsIXULWindow*, this));
|
||||
|
||||
// Hide splash screen (if there is one).
|
||||
static PRBool splashScreenGone = PR_FALSE;
|
||||
if(!splashScreenGone)
|
||||
{
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID));
|
||||
if(appShellService)
|
||||
appShellService->HideSplashScreen();
|
||||
splashScreenGone = PR_TRUE;
|
||||
}
|
||||
// notify observers so that we can hide the splash screen if possible
|
||||
nsCOMPtr<nsIObserverService> obssvc
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
NS_WARN_IF_FALSE(obssvc, "Couldn't get observer service.");
|
||||
if (obssvc) {
|
||||
obssvc->NotifyObservers(nsnull, "xul-window-visible", nsnull);
|
||||
}
|
||||
|
||||
mDebuting = PR_FALSE;
|
||||
NS_TIMELINE_LEAVE("nsXULWindow::SetVisibility");
|
||||
return NS_OK;
|
||||
|
@ -1556,22 +1540,18 @@ NS_IMETHODIMP nsXULWindow::GetWindowDOMElement(nsIDOMElement** aDOMElement)
|
|||
nsCOMPtr<nsIContentViewer> cv;
|
||||
|
||||
mDocShell->GetContentViewer(getter_AddRefs(cv));
|
||||
if(!cv)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_TRUE(cv, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
||||
if(!docv)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_TRUE(docv, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
docv->GetDocument(getter_AddRefs(doc));
|
||||
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc));
|
||||
if(!domdoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_TRUE(domdoc, NS_ERROR_FAILURE);
|
||||
|
||||
domdoc->GetDocumentElement(aDOMElement);
|
||||
if(!*aDOMElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_TRUE(*aDOMElement, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1700,20 +1680,20 @@ NS_IMETHODIMP nsXULWindow::ExitModalLoop(nsresult aStatus)
|
|||
|
||||
// top-level function to create a new window
|
||||
NS_IMETHODIMP nsXULWindow::CreateNewWindow(PRInt32 aChromeFlags,
|
||||
nsIXULWindow **_retval)
|
||||
nsIAppShell* aAppShell, nsIXULWindow **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
if (aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)
|
||||
return CreateNewChromeWindow(aChromeFlags, _retval);
|
||||
return CreateNewContentWindow(aChromeFlags, _retval);
|
||||
return CreateNewChromeWindow(aChromeFlags, aAppShell, _retval);
|
||||
return CreateNewContentWindow(aChromeFlags, aAppShell, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(PRInt32 aChromeFlags,
|
||||
nsIXULWindow **_retval)
|
||||
nsIAppShell* aAppShell, nsIXULWindow **_retval)
|
||||
{
|
||||
NS_TIMELINE_ENTER("nsXULWindow::CreateNewChromeWindow");
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID));
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);
|
||||
|
||||
// Just do a normal create of a window and return.
|
||||
|
@ -1725,7 +1705,7 @@ NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(PRInt32 aChromeFlags,
|
|||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
appShell->CreateTopLevelWindow(parent, nsnull, PR_FALSE, PR_FALSE,
|
||||
aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT, getter_AddRefs(newWindow));
|
||||
nsIAppShellService::SIZE_TO_CONTENT, aAppShell, getter_AddRefs(newWindow));
|
||||
|
||||
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
|
||||
|
||||
|
@ -1742,10 +1722,10 @@ NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(PRInt32 aChromeFlags,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
|
||||
nsIXULWindow **_retval)
|
||||
nsIAppShell* aAppShell, nsIXULWindow **_retval)
|
||||
{
|
||||
NS_TIMELINE_ENTER("nsXULWindow::CreateNewContentWindow");
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID));
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIXULWindow> parent;
|
||||
|
@ -1789,7 +1769,7 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
|
|||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
appShell->CreateTopLevelWindow(parent, uri, PR_FALSE, PR_FALSE,
|
||||
aChromeFlags, 615, 480,
|
||||
aChromeFlags, 615, 480, aAppShell,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
|
||||
|
@ -1800,7 +1780,7 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
|
|||
if(browserChrome)
|
||||
browserChrome->SetChromeFlags(aChromeFlags);
|
||||
|
||||
nsCOMPtr<nsIAppShell> subShell(do_CreateInstance(kAppShellCID));
|
||||
nsCOMPtr<nsIAppShell> subShell(do_CreateInstance(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(subShell, NS_ERROR_FAILURE);
|
||||
|
||||
subShell->Create(0, nsnull);
|
||||
|
|
|
@ -118,9 +118,9 @@ protected:
|
|||
PRInt32 aCY);
|
||||
NS_IMETHOD ExitModalLoop(nsresult aStatus);
|
||||
NS_IMETHOD CreateNewChromeWindow(PRInt32 aChromeFlags,
|
||||
nsIXULWindow **_retval);
|
||||
nsIAppShell* aAppShell, nsIXULWindow **_retval);
|
||||
NS_IMETHOD CreateNewContentWindow(PRInt32 aChromeFlags,
|
||||
nsIXULWindow **_retval);
|
||||
nsIAppShell* aAppShell, nsIXULWindow **_retval);
|
||||
|
||||
void EnableParent(PRBool aEnable);
|
||||
PRBool ConstrainToZLevel(PRBool aImmediate, nsWindowZ *aPlacement,
|
||||
|
|
|
@ -78,6 +78,7 @@ REQUIRES = xpcom \
|
|||
content \
|
||||
pref \
|
||||
appshell \
|
||||
appcomps \
|
||||
gfx \
|
||||
xpinstall \
|
||||
uriloader \
|
||||
|
@ -122,7 +123,6 @@ PREF_JS_EXPORTS = $(srcdir)/browser-prefs.js
|
|||
|
||||
CPPSRCS = \
|
||||
nsAppRunner.cpp \
|
||||
nsWindowCreator.cpp \
|
||||
showOSAlert.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ REQUIRES = xpcom \
|
|||
docshell \
|
||||
webbrwsr \
|
||||
appshell \
|
||||
appcomps \
|
||||
caps \
|
||||
uriloader \
|
||||
$(NULL)
|
||||
|
@ -94,7 +95,7 @@ FORCE_STATIC_LIB = 1
|
|||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir) \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../../appshell/src/ \
|
||||
-I$(srcdir)/../../components/startup/src \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -52,10 +52,8 @@
|
|||
#include "nsCommandLineServiceMac.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIAppShellService.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
AEApplicationClass
|
||||
|
@ -329,11 +327,11 @@ void AEApplicationClass::HandleReOpen(AEDesc *token, const AppleEvent *appleEven
|
|||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsINativeAppSupport> nas;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID, &rv));
|
||||
NS_WARN_IF_FALSE(rv==NS_OK, "Failed to get AppShellService");
|
||||
if(NS_FAILED(rv)) ThrowIfOSErr(errAEEventNotHandled);
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
NS_WARN_IF_FALSE(appStartup, "Failed to get appstartup service");
|
||||
if(!appStartup) ThrowIfOSErr(errAEEventNotHandled);
|
||||
|
||||
rv = appShell->GetNativeAppSupport(getter_AddRefs(nas));
|
||||
rv = appStartup->GetNativeAppSupport(getter_AddRefs(nas));
|
||||
NS_WARN_IF_FALSE(rv==NS_OK, "Failed to get NativeAppSupport");
|
||||
if(NS_FAILED(rv)) ThrowIfOSErr(errAEEventNotHandled);
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "nsWindowUtils.h"
|
||||
#include "nsMacUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsWindowUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
|
|
@ -68,8 +68,8 @@
|
|||
#include "nsICmdLineService.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIAppStartupNotifier.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "prprf.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
|
@ -85,7 +85,7 @@
|
|||
#include "nsIEventQueueService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsBuildID.h"
|
||||
#include "nsWindowCreator.h"
|
||||
#include "nsIWindowCreator.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
|
@ -130,6 +130,8 @@
|
|||
#endif
|
||||
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
#define UILOCALE_CMD_LINE_ARG "-UILocale"
|
||||
|
@ -374,10 +376,6 @@ static void InitializeMacOSXApp(int argc, char* argv[])
|
|||
#include <gtk/gtk.h>
|
||||
#endif //MOZ_WIDGET_GTK || MOZ_WIDGET_GTK2
|
||||
|
||||
/* Define Class IDs */
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
|
||||
#include "nsNativeAppSupport.h"
|
||||
|
||||
/*********************************************/
|
||||
|
@ -438,9 +436,9 @@ static nsresult GetNativeAppSupport(nsINativeAppSupport** aNativeApp)
|
|||
NS_ENSURE_ARG_POINTER(aNativeApp);
|
||||
*aNativeApp = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID));
|
||||
if (appShellService)
|
||||
appShellService->GetNativeAppSupport(aNativeApp);
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
if (appStartup)
|
||||
appStartup->GetNativeAppSupport(aNativeApp);
|
||||
|
||||
return *aNativeApp ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -511,12 +509,12 @@ static nsresult OpenWindow(const nsCString& aChromeURL,
|
|||
// profile" is moot (because they don't support "-turbo",
|
||||
// basically). Specifically, because they don't do turbo, they will
|
||||
// *always* have a profile selected.
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService("@mozilla.org/appshell/appShellService;1"));
|
||||
nsCOMPtr <nsICmdLineService> cmdLine(do_GetService("@mozilla.org/appshell/commandLineService;1"));
|
||||
if (appShell && cmdLine)
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
nsCOMPtr <nsICmdLineService> cmdLine(do_GetService(NS_COMMANDLINESERVICE_CONTRACTID));
|
||||
if (appStartup && cmdLine)
|
||||
{
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
if (NS_SUCCEEDED(appShell->GetNativeAppSupport(getter_AddRefs(nativeApp))))
|
||||
if (NS_SUCCEEDED(appStartup->GetNativeAppSupport(getter_AddRefs(nativeApp))))
|
||||
{
|
||||
// Make sure profile has been selected.
|
||||
// At this point, we have to look for failure. That
|
||||
|
@ -621,7 +619,7 @@ LaunchApplicationWithArgs(const char *commandLineArg,
|
|||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLine =
|
||||
do_GetService("@mozilla.org/appshell/commandLineService;1",&rv);
|
||||
do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr <nsICmdLineHandler> handler;
|
||||
|
@ -747,9 +745,9 @@ nsresult DoCommandLines(nsICmdLineService* cmdLineArgs, PRBool heedGeneralStartu
|
|||
PR_sscanf(tempString.get(), "%d", &height);
|
||||
|
||||
if (heedGeneralStartupPrefs) {
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService("@mozilla.org/appshell/appShellService;1", &rv));
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = appShell->CreateStartupState(width, height, windowOpened);
|
||||
rv = appStartup->CreateStartupState(width, height, windowOpened);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
|
@ -957,31 +955,13 @@ static nsresult InitializeProfileService(nsICmdLineService *cmdLineArgs)
|
|||
}
|
||||
}
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID, &rv));
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = appShellService->DoProfileStartup(cmdLineArgs, shouldShowUI);
|
||||
rv = appStartup->DoProfileStartup(cmdLineArgs, shouldShowUI);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult InitializeWindowCreator()
|
||||
{
|
||||
// create an nsWindowCreator and give it to the WindowWatcher service
|
||||
nsWindowCreator *creatorCallback = new nsWindowCreator();
|
||||
if (!creatorCallback)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback));
|
||||
if (windowCreator) {
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
if (wwatch) {
|
||||
wwatch->SetWindowCreator(windowCreator);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Maximum allowed / used length of alert message is 255 chars, due to restrictions on Mac.
|
||||
// Please make sure that file contents and fallback_alert_text are at most 255 chars.
|
||||
// Fallback_alert_text must be non-const, because of inplace conversion on Mac.
|
||||
|
@ -1074,8 +1054,8 @@ static nsresult VerifyInstallation(int argc, char **argv)
|
|||
#endif
|
||||
|
||||
// Note: nativeApp is an owning reference that this function has responsibility
|
||||
// to release. This responsibility is delegated to the app shell service
|
||||
// (see nsAppShellService::Initialize call, below).
|
||||
// to release. This responsibility is delegated to the app startup service
|
||||
// (see nsAppStartup::Initialize call, below).
|
||||
static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -1167,7 +1147,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||
NS_TIMELINE_ENTER("cmdLineArgs");
|
||||
|
||||
// Initialize the cmd line service
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs(do_GetService(kCmdLineServiceCID, &rv));
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs(do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Could not obtain CmdLine processing service\n");
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -1187,14 +1167,14 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||
return rv;
|
||||
NS_TIMELINE_LEAVE("InstallGlobalLocale");
|
||||
|
||||
NS_TIMELINE_ENTER("appShell");
|
||||
NS_TIMELINE_ENTER("appStartup");
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID, &rv));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get the appshell service");
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
NS_ASSERTION(appStartup, "failed to get the appstartup service");
|
||||
|
||||
/* if we couldn't get the nsIAppShellService service, then we should hide the
|
||||
splash screen and return */
|
||||
if (NS_FAILED(rv))
|
||||
/* if we couldn't get the nsIAppStartup service, then we should hide the
|
||||
splash screen and return (and something is seriously screwed up) */
|
||||
if (!appStartup)
|
||||
{
|
||||
// See if platform supports nsINativeAppSupport.
|
||||
nsCOMPtr<nsINativeAppSupport> nativeAppSupport(do_QueryInterface(nativeAppOwner));
|
||||
|
@ -1215,24 +1195,30 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_TIMELINE_LEAVE("appShell");
|
||||
NS_TIMELINE_LEAVE("appStartup");
|
||||
|
||||
NS_TIMELINE_ENTER("appShell->Initialize");
|
||||
NS_TIMELINE_ENTER("appStartup->Initialize");
|
||||
|
||||
// Create the Application Shell instance...
|
||||
rv = appShell->Initialize(cmdLineArgs, nativeAppOwner);
|
||||
rv = appStartup->Initialize(cmdLineArgs, nativeAppOwner);
|
||||
|
||||
NS_TIMELINE_LEAVE("appShell->Initialize");
|
||||
NS_TIMELINE_LEAVE("appStartup->Initialize");
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appshell");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appstartup");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = InitializeWindowCreator();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize window creator");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIWindowCreator> wcreator (do_QueryInterface(appStartup));
|
||||
NS_ASSERTION(wcreator, "appstartup doesn't do nsIWindowCreator?");
|
||||
NS_ENSURE_TRUE(wcreator, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
NS_ASSERTION(wwatch, "Couldn't get the window watcher!");
|
||||
NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
|
||||
|
||||
wwatch->SetWindowCreator(wcreator);
|
||||
|
||||
// So we can open and close windows during startup
|
||||
appShell->EnterLastWindowClosingSurvivalArea();
|
||||
appStartup->EnterLastWindowClosingSurvivalArea();
|
||||
|
||||
// Initialize Profile Service here.
|
||||
NS_TIMELINE_ENTER("InitializeProfileService");
|
||||
|
@ -1247,9 +1233,9 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||
CheckUseAccessibleSkin();
|
||||
NS_TIMELINE_LEAVE("CheckUseAccessibleSkin");
|
||||
|
||||
NS_TIMELINE_ENTER("appShell->CreateHiddenWindow");
|
||||
appShell->CreateHiddenWindow();
|
||||
NS_TIMELINE_LEAVE("appShell->CreateHiddenWindow");
|
||||
NS_TIMELINE_ENTER("appStartup->CreateHiddenWindow");
|
||||
appStartup->CreateHiddenWindow();
|
||||
NS_TIMELINE_LEAVE("appStartup->CreateHiddenWindow");
|
||||
|
||||
// This will go away once Components are handling there own commandlines
|
||||
// if we have no command line arguments, we need to heed the
|
||||
|
@ -1296,13 +1282,13 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||
|
||||
// Make sure there exists at least 1 window.
|
||||
NS_TIMELINE_ENTER("Ensure1Window");
|
||||
rv = appShell->Ensure1Window(cmdLineArgs);
|
||||
rv = appStartup->Ensure1Window(cmdLineArgs);
|
||||
NS_TIMELINE_LEAVE("Ensure1Window");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to Ensure1Window");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#if !defined(XP_MAC) && !defined(XP_MACOSX)
|
||||
appShell->ExitLastWindowClosingSurvivalArea();
|
||||
appStartup->ExitLastWindowClosingSurvivalArea();
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_ENABLE_XREMOTE
|
||||
|
@ -1331,10 +1317,10 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||
nativeAppOwner = nsnull;
|
||||
|
||||
// Start main event loop
|
||||
NS_TIMELINE_ENTER("appShell->Run");
|
||||
rv = appShell->Run();
|
||||
NS_TIMELINE_LEAVE("appShell->Run");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appshell");
|
||||
NS_TIMELINE_ENTER("appStartup->Run");
|
||||
rv = appStartup->Run();
|
||||
NS_TIMELINE_LEAVE("appStartup->Run");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appstartup");
|
||||
|
||||
#ifdef MOZ_TIMELINE
|
||||
// Make sure we print this out even if timeline is runtime disabled
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
#include <TextUtils.h>
|
||||
#include <ControlDefinitions.h>
|
||||
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsNativeAppSupportBase.h"
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
@ -60,7 +60,7 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
#define rSplashDialog 512
|
||||
|
||||
|
@ -381,13 +381,13 @@ nsNativeAppSupportMac::ReOpen()
|
|||
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)
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
if (appStartup)
|
||||
{
|
||||
PRBool openedAWindow = PR_FALSE;
|
||||
appShell->CreateStartupState(nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT,
|
||||
&openedAWindow);
|
||||
appStartup->CreateStartupState(nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT,
|
||||
&openedAWindow);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1862,11 +1862,11 @@ nsNativeAppSupportOS2::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<nsIAppStartup> appStartup(do_GetService(appStartup));
|
||||
if (!appStartup) return;
|
||||
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
rv = appShell->GetNativeAppSupport(getter_AddRefs( nativeApp ));
|
||||
rv = appStartup->GetNativeAppSupport(getter_AddRefs( nativeApp ));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
// first see if there is a url
|
||||
|
@ -1911,17 +1911,17 @@ nsNativeAppSupportOS2::HandleRequest( LPBYTE request, PRBool newWindow ) {
|
|||
rv = args->GetCmdLineValue( "-kill", getter_Copies(arg));
|
||||
if ( NS_SUCCEEDED(rv) && (const char*)arg ) {
|
||||
// Turn off server mode.
|
||||
nsCOMPtr<nsIAppShellService> appShell =
|
||||
do_GetService( "@mozilla.org/appshell/appShellService;1", &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
nsCOMPtr<nsIAppStartup> appStartup
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
if (!appStartup) return;
|
||||
|
||||
nsCOMPtr<nsINativeAppSupport> native;
|
||||
rv = appShell->GetNativeAppSupport( getter_AddRefs( native ));
|
||||
rv = appStartup->GetNativeAppSupport( getter_AddRefs( native ));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
native->SetIsServerMode( PR_FALSE );
|
||||
|
||||
// close app if there are no more top-level windows.
|
||||
appShell->Quit(nsIAppShellService::eConsiderQuit);
|
||||
appStartup->Quit(nsIAppShellService::eConsiderQuit);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2155,7 +2155,7 @@ nsNativeAppSupportOS2::EnsureProfile(nsICmdLineService* args)
|
|||
|
||||
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));
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// If we have a profile, everything is fine.
|
||||
|
@ -2181,7 +2181,7 @@ nsNativeAppSupportOS2::EnsureProfile(nsICmdLineService* args)
|
|||
canInteract = PR_FALSE;
|
||||
}
|
||||
}
|
||||
rv = appShell->DoProfileStartup(args, canInteract);
|
||||
rv = appStartup->DoProfileStartup(args, canInteract);
|
||||
|
||||
mForceProfileStartup = PR_FALSE;
|
||||
|
||||
|
@ -2461,8 +2461,8 @@ nsNativeAppSupportOS2::OnLastWindowClosing() {
|
|||
profileCount > 1 ) {
|
||||
// Turn off turbo mode and quit the application.
|
||||
SetIsServerMode( PR_FALSE );
|
||||
nsCOMPtr<nsIAppShellService> appShell =
|
||||
do_GetService( "@mozilla.org/appshell/appShellService;1", &rv);
|
||||
nsCOMPtr<nsIAppStartup> appShell
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
appShell->Quit(nsIAppShellService::eAttemptQuit);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
#include "nsIDocShell.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
@ -69,6 +69,9 @@
|
|||
#include "nsNetCID.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
#ifdef XPCOM_GLUE
|
||||
#include "nsStringSupport.h"
|
||||
|
@ -949,14 +952,15 @@ struct MessageWindow {
|
|||
if ( NS_SUCCEEDED( rv ) )
|
||||
winHooksService->StartupRemoveOption("-turbo");
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv );
|
||||
nsCOMPtr<nsIAppStartup> appStartup
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
nsCOMPtr<nsINativeAppSupport> native;
|
||||
rv = appShell->GetNativeAppSupport( getter_AddRefs( native ) );
|
||||
rv = appStartup->GetNativeAppSupport( getter_AddRefs( native ) );
|
||||
if ( NS_SUCCEEDED( rv ) )
|
||||
native->SetIsServerMode( PR_FALSE );
|
||||
if ( !win )
|
||||
appShell->Quit(nsIAppShellService::eAttemptQuit);
|
||||
appStartup->Quit(nsIAppStartup::eAttemptQuit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1749,11 +1753,11 @@ 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));
|
||||
nsCOMPtr<nsIAppStartup> appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
rv = appShell->GetNativeAppSupport(getter_AddRefs( nativeApp ));
|
||||
rv = appStartup->GetNativeAppSupport(getter_AddRefs( nativeApp ));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
// first see if there is a url
|
||||
|
@ -1798,17 +1802,17 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
|
|||
rv = args->GetCmdLineValue( "-kill", getter_Copies(arg));
|
||||
if ( NS_SUCCEEDED(rv) && (const char*)arg ) {
|
||||
// Turn off server mode.
|
||||
nsCOMPtr<nsIAppShellService> appShell =
|
||||
do_GetService( "@mozilla.org/appshell/appShellService;1", &rv);
|
||||
nsCOMPtr<nsIAppStartup> appStartup
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsCOMPtr<nsINativeAppSupport> native;
|
||||
rv = appShell->GetNativeAppSupport( getter_AddRefs( native ));
|
||||
rv = appStartup->GetNativeAppSupport( getter_AddRefs( native ));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
native->SetIsServerMode( PR_FALSE );
|
||||
|
||||
// close app if there are no more top-level windows.
|
||||
appShell->Quit(nsIAppShellService::eConsiderQuit);
|
||||
appStartup->Quit(nsIAppStartup::eConsiderQuit);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2021,15 +2025,13 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
|
|||
}
|
||||
}
|
||||
|
||||
// OK, now create nsICmdLineService object from argc/argv.
|
||||
static NS_DEFINE_CID( kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID );
|
||||
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
rv = compMgr->CreateInstance( kCmdLineServiceCID,
|
||||
0,
|
||||
NS_GET_IID( nsICmdLineService ),
|
||||
(void**)aResult );
|
||||
|
||||
rv = compMgr->CreateInstanceByContractID(
|
||||
NS_COMMANDLINESERVICE_CONTRACTID,
|
||||
nsnull, NS_GET_IID(nsICmdLineService),
|
||||
(void**) aResult);
|
||||
|
||||
if ( NS_FAILED( rv ) || NS_FAILED( ( rv = (*aResult)->Initialize( argc, argv ) ) ) ) {
|
||||
#if MOZ_DEBUG_DDE
|
||||
|
@ -2097,7 +2099,7 @@ printf( "Setting ddexec subkey entries\n" );
|
|||
|
||||
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));
|
||||
nsCOMPtr<nsIAppStartup> appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// If we have a profile, everything is fine -
|
||||
|
@ -2123,7 +2125,7 @@ printf( "Setting ddexec subkey entries\n" );
|
|||
canInteract = PR_FALSE;
|
||||
}
|
||||
}
|
||||
rv = appShell->DoProfileStartup(args, canInteract);
|
||||
rv = appStartup->DoProfileStartup(args, canInteract);
|
||||
|
||||
mForceProfileStartup = PR_FALSE;
|
||||
|
||||
|
@ -2605,10 +2607,10 @@ nsNativeAppSupportWin::OnLastWindowClosing() {
|
|||
profileCount > 1 ) {
|
||||
// Turn off turbo mode and quit the application.
|
||||
SetIsServerMode( PR_FALSE );
|
||||
nsCOMPtr<nsIAppShellService> appShell =
|
||||
do_GetService( "@mozilla.org/appshell/appShellService;1", &rv);
|
||||
nsCOMPtr<nsIAppStartup> appStartup
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
appShell->Quit(nsIAppShellService::eAttemptQuit);
|
||||
appStartup->Quit(nsIAppStartup::eAttemptQuit);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2637,8 +2639,8 @@ nsNativeAppSupportWin::OnLastWindowClosing() {
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell =
|
||||
do_GetService( "@mozilla.org/appshell/appShellService;1", &rv);
|
||||
nsCOMPtr<nsIAppStartup> appStartup
|
||||
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
// Instead of staying alive, launch a new instance of the application and then
|
||||
// terminate for real. We take steps to ensure that the new instance will run
|
||||
|
@ -2680,7 +2682,7 @@ nsNativeAppSupportWin::OnLastWindowClosing() {
|
|||
|
||||
// Turn off turbo mode and quit the application.
|
||||
SetIsServerMode( PR_FALSE );
|
||||
appShell->Quit(nsIAppShellService::eAttemptQuit);
|
||||
appStartup->Quit(nsIAppStartup::eAttemptQuit);
|
||||
|
||||
// Done. This app will now commence shutdown.
|
||||
}
|
||||
|
|
|
@ -64,9 +64,8 @@
|
|||
#include <string.h>
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsXPFEComponentCID.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_PHOTON
|
||||
|
@ -142,9 +141,9 @@ void beos_signal_handler(int signum) {
|
|||
fprintf(stderr, "beos_signal_handler: %d\n", signum);
|
||||
#endif
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID,&rv));
|
||||
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
// Failed to get the appshell service so shutdown the hard way
|
||||
// Failed to get the appstartup service so shutdown the hard way
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "beos_signal_handler: appShell->do_GetService() failed\n");
|
||||
#endif
|
||||
|
@ -152,7 +151,7 @@ void beos_signal_handler(int signum) {
|
|||
}
|
||||
|
||||
// Exit the appshell so that the app can shutdown normally
|
||||
appShellService->Quit(nsIAppShellService::eAttemptQuit);
|
||||
appStartup->Quit(nsIAppStartup::eAttemptQuit);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* There are several ways to open a new window in Mozilla: directly, using
|
||||
nsAppShellService; indirectly, using the Open method on an extant
|
||||
window, the OpenWindow method on the nsWindowWatcher service, and this
|
||||
WindowCreator. I think that's all of them, for petessake. But
|
||||
the conditions under which each should be used are definite, if
|
||||
not clear, and there is no overlap.
|
||||
|
||||
Basically, you should never use nsAppShellService. That's the basic
|
||||
method that all others boil down to, and it creates partially initialized
|
||||
windows. Trust the other means of opening windows to use nsAppShellService
|
||||
and then finish the new window's initialization. nsAppShellService is
|
||||
also strictly a Mozilla-only service; it's unavailable (or should be)
|
||||
to embedding apps. So it's not merely inadvisable but also illegal
|
||||
for any code that may execute in an embedding context to use that service.
|
||||
|
||||
Unless you're writing window opening code yourself, you want to use
|
||||
the Open method on an extant window, or lacking one of those, the
|
||||
OpenWindow method on the nsWindowWatcher service. (The former calls
|
||||
through to the latter.) Both methods are equally at home in Mozilla
|
||||
and embedding contexts. They differentiate between which kind of window
|
||||
to open in different ways, depending on whether there is an extant
|
||||
window.
|
||||
|
||||
Lacking an extant window, it's this object, the nsWindowCreator,
|
||||
that allows new window creation and properly distinguishes between
|
||||
Mozilla and embedding contexts. This source file contains the
|
||||
Mozilla version, which calls through to nsAppShellService.
|
||||
*/
|
||||
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsWindowCreator.h"
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
||||
nsWindowCreator::nsWindowCreator() {
|
||||
}
|
||||
|
||||
nsWindowCreator::~nsWindowCreator() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsWindowCreator, nsIWindowCreator, nsIWindowCreator2)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
PRBool cancel;
|
||||
return CreateChromeWindow2(aParent, aChromeFlags, 0, 0, &cancel, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowCreator::CreateChromeWindow2( nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
PRUint32 aContextFlags,
|
||||
nsIURI *aURI,
|
||||
PRBool *aCancel,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCancel);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*aCancel = PR_FALSE;
|
||||
*_retval = 0;
|
||||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
|
||||
if (aParent) {
|
||||
nsCOMPtr<nsIXULWindow> xulParent(do_GetInterface(aParent));
|
||||
NS_ASSERTION(xulParent, "window created using non-XUL parent. that's unexpected, but may work.");
|
||||
|
||||
if (xulParent)
|
||||
xulParent->CreateNewWindow(aChromeFlags, getter_AddRefs(newWindow));
|
||||
// And if it fails, don't try again without a parent. It could fail
|
||||
// intentionally (bug 115969).
|
||||
} else { // try using basic methods:
|
||||
/* You really shouldn't be making dependent windows without a parent.
|
||||
But unparented modal (and therefore dependent) windows happen
|
||||
in our codebase, so we allow it after some bellyaching: */
|
||||
if (aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT)
|
||||
NS_WARNING("dependent window created without a parent");
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID));
|
||||
if (!appShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
appShell->CreateTopLevelWindow(0, 0, PR_FALSE, PR_FALSE,
|
||||
aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT, getter_AddRefs(newWindow));
|
||||
}
|
||||
|
||||
// if anybody gave us anything to work with, use it
|
||||
if (newWindow) {
|
||||
newWindow->SetContextFlags(aContextFlags);
|
||||
nsCOMPtr<nsIInterfaceRequestor> thing(do_QueryInterface(newWindow));
|
||||
if (thing)
|
||||
thing->GetInterface(NS_GET_IID(nsIWebBrowserChrome), (void **) _retval);
|
||||
}
|
||||
|
||||
return *_retval ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
|
@ -44,7 +44,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
MODULE = browser
|
||||
|
||||
DIRS = src samples resources
|
||||
DIRS = public src samples resources
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -44,9 +44,8 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
MODULE = browser
|
||||
XPIDL_MODULE = mozbrwsr
|
||||
GRE_MODULE = 1
|
||||
|
||||
XPIDLSRCS = nsIBrowserInstance.idl nsIXULBrowserWindow.idl
|
||||
XPIDLSRCS = nsIBrowserInstance.idl
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -1921,10 +1921,10 @@ function applyTheme(themeName)
|
|||
pref.setComplexValue("general.skins.selectedSkin", Components.interfaces.nsISupportsString, str);
|
||||
|
||||
// shut down quicklaunch so the next launch will have the new skin
|
||||
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
|
||||
appShell = appShell.QueryInterface(Components.interfaces.nsIAppShellService);
|
||||
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Components.interfaces.nsIAppStartup);
|
||||
try {
|
||||
appShell.nativeAppSupport.isServerMode = false;
|
||||
appStartup.nativeAppSupport.isServerMode = false;
|
||||
}
|
||||
catch(ex) {
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ REQUIRES = xpcom \
|
|||
content \
|
||||
docshell \
|
||||
appshell \
|
||||
appcomps \
|
||||
dom \
|
||||
js \
|
||||
uriloader \
|
||||
|
|
|
@ -83,9 +83,7 @@
|
|||
#include "plevent.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIAppStartup.h"
|
||||
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIBrowserHistory.h"
|
||||
|
@ -102,9 +100,7 @@
|
|||
// Stuff to implement file download dialog.
|
||||
#include "nsIProxyObjectManager.h"
|
||||
|
||||
#if defined(MOZ_PHOENIX) || defined(MOZ_XULRUNNER)
|
||||
#include "nsToolkitCompsCID.h"
|
||||
#endif
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
// If DEBUG, NS_BUILD_REFCNT_LOGGING, MOZ_PERF_METRICS, or MOZ_JPROF is
|
||||
// defined, enable the PageCycler.
|
||||
|
@ -115,8 +111,6 @@
|
|||
/* Define Class IDs */
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
|
||||
#ifdef DEBUG
|
||||
static int APP_DEBUG = 0; // Set to 1 in debugger to turn on debugging.
|
||||
|
@ -225,18 +219,18 @@ public:
|
|||
nsresult rv;
|
||||
// make sure our timer is stopped first
|
||||
StopTimer();
|
||||
nsCOMPtr<nsIAppShellService> appShellServ =
|
||||
do_GetService(kAppShellServiceCID, &rv);
|
||||
nsCOMPtr<nsIAppStartup> appStartup =
|
||||
do_GetService(NS_APPSTARTUP_CONTRACTID, &rv);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIProxyObjectManager> pIProxyObjectManager =
|
||||
do_GetService(kProxyObjectManagerCID, &rv);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIAppShellService> appShellProxy;
|
||||
rv = pIProxyObjectManager->GetProxyForObject(NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIAppShellService),
|
||||
appShellServ, PROXY_ASYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(appShellProxy));
|
||||
nsCOMPtr<nsIAppStartup> appStartupProxy;
|
||||
rv = pIProxyObjectManager->GetProxyForObject(NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIAppStartup),
|
||||
appStartup, PROXY_ASYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(appStartupProxy));
|
||||
|
||||
(void)appShellProxy->Quit(nsIAppShellService::eAttemptQuit);
|
||||
(void)appStartupProxy->Quit(nsIAppStartup::eAttemptQuit);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -526,7 +520,7 @@ nsBrowserInstance::StartPageCycler(PRBool* aIsPageCycling)
|
|||
*aIsPageCycling = PR_FALSE;
|
||||
if (!sCmdLineURLUsed) {
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs =
|
||||
do_GetService(kCmdLineServiceCID, &rv);
|
||||
do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (APP_DEBUG) fprintf(stderr, "Could not obtain CmdLine processing service\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче