mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 380786 - clean up xpfe/ after suite moving to toolkit - clean up xpfe/components, r=ted sr=Neil
This commit is contained in:
parent
35b176b8c7
commit
93edae459d
@ -590,18 +590,12 @@ MAKEFILES_xpfe="
|
||||
xpfe/components/related/Makefile
|
||||
xpfe/components/related/src/Makefile
|
||||
xpfe/components/related/public/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
|
||||
xpfe/components/winhooks/Makefile
|
||||
xpfe/components/windowds/Makefile
|
||||
xpfe/components/build/Makefile
|
||||
xpfe/components/xremote/Makefile
|
||||
xpfe/components/xremote/public/Makefile
|
||||
xpfe/components/xremote/src/Makefile
|
||||
xpfe/appshell/Makefile
|
||||
xpfe/appshell/src/Makefile
|
||||
xpfe/appshell/public/Makefile
|
||||
|
@ -96,14 +96,10 @@ LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/.. \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_XUL_APP
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(topsrcdir)/toolkit/xre \
|
||||
-I$(topsrcdir)/toolkit/components/startup/src \
|
||||
$(NULL)
|
||||
else
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/xpfe/components/startup/src
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
@ -77,53 +77,33 @@ DIRS += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifneq (,$(MOZ_THUNDERBIRD)$(MOZ_SUITE)$(MOZ_SUNBIRD))
|
||||
DIRS += autocomplete
|
||||
endif
|
||||
|
||||
ifdef MOZ_SUITE
|
||||
DIRS += related
|
||||
|
||||
ifdef SUITE_USING_XPFE_DM
|
||||
DIRS += download-manager
|
||||
endif
|
||||
|
||||
ifndef MOZ_PLACES
|
||||
DIRS += history
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DIRS += winhooks
|
||||
endif
|
||||
endif # MOZ_SUITE
|
||||
|
||||
ifdef MOZ_HAVE_BROWSER
|
||||
DIRS += \
|
||||
directory \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_PHOENIX
|
||||
ifndef MOZ_XULRUNNER
|
||||
DIRS += \
|
||||
related \
|
||||
autocomplete \
|
||||
$(NULL)
|
||||
|
||||
ifdef SUITE_USING_XPFE_DM
|
||||
DIRS += download-manager
|
||||
endif
|
||||
|
||||
ifndef MOZ_XUL_APP
|
||||
DIRS += startup
|
||||
endif
|
||||
ifndef MOZ_PLACES
|
||||
DIRS += history
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_SUITE
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DIRS += winhooks
|
||||
endif
|
||||
endif
|
||||
|
||||
# build should be last
|
||||
DIRS += build
|
||||
|
||||
else
|
||||
# !MOZ_HAVE_BROWSER
|
||||
|
||||
DIRS += \
|
||||
autocomplete \
|
||||
$(NULL)
|
||||
|
||||
endif
|
||||
|
||||
ifndef MOZ_XUL_APP
|
||||
ifdef MOZ_ENABLE_XREMOTE
|
||||
TOOL_DIRS += xremote
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,46 +0,0 @@
|
||||
# ***** 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
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -1,62 +0,0 @@
|
||||
# ***** 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 = appcomps
|
||||
XPIDL_MODULE = appstartup
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIAppStartup.idl \
|
||||
nsICloseAllWindows.idl \
|
||||
nsICmdLineHandler.idl \
|
||||
nsICmdLineService.idl \
|
||||
nsINativeAppSupport.idl \
|
||||
nsIUserInfo.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = nsISplashScreen.h
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
XPIDLSRCS += nsINativeAppSupportWin.idl
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -1,122 +0,0 @@
|
||||
/* -*- 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) 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 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;
|
||||
interface nsINativeAppSupport;
|
||||
|
||||
[scriptable, uuid(0f4ae035-4643-44c5-a596-ff81b8c29f08)]
|
||||
interface nsIAppStartup : nsISupports
|
||||
{
|
||||
/**
|
||||
* Required initialization routine.
|
||||
* @param aNativeAppSupportOrSplashScreen
|
||||
* This 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 nsISupports nativeAppSupportOrSplashScreen);
|
||||
|
||||
/**
|
||||
* Create the hidden window. Only bootstrap code (nsAppRunner.cpp) should call
|
||||
* this method.
|
||||
*/
|
||||
void createHiddenWindow();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Remove the splash screen (if visible). This need be called
|
||||
* only once per application session.
|
||||
*/
|
||||
void hideSplashScreen();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
};
|
@ -1,50 +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):
|
||||
* 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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(2f977d49-5485-11d4-87e2-0010a4e75ef2)]
|
||||
interface nsICloseAllWindows : nsISupports
|
||||
{
|
||||
/**
|
||||
* 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);
|
||||
};
|
||||
|
@ -1,205 +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):
|
||||
* 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"),
|
||||
* 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"
|
||||
|
||||
|
||||
%{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 "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(ae12670a-1dd1-11b2-80cd-82ec93559deb)]
|
||||
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;
|
||||
};
|
||||
|
@ -1,94 +0,0 @@
|
||||
/* -*- Mode: IDL; 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 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 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"
|
||||
#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);
|
||||
};
|
@ -1,192 +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):
|
||||
* Bill Law <law@netscape.com>
|
||||
* Blake Ross <blake@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 "nsISupports.idl"
|
||||
|
||||
/* nsINativeAppSupport
|
||||
*
|
||||
* This "pseudo" (in the XPCOM sense) interface provides for
|
||||
* platform-specific general aplication support:
|
||||
* o It subsumes the old "NS_CanRun" and "NS_CreateSplashScreen"
|
||||
* functions that managed display of the application splash
|
||||
* screen at startup.
|
||||
* 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 mozilla/xpfe/bootstrap.
|
||||
*
|
||||
* You can use this interface by obtaining an instance via the
|
||||
* "nativeAppSupport" attribute of the nsIAppShellService
|
||||
* interface/service.
|
||||
*
|
||||
* 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. In that respect, it is rougly equivalent to the
|
||||
* NS_CanStart function, which it replaces.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* showSplashScreen - Causes the platform-specific splash screen to be
|
||||
* displayed. This is a replacement for the old
|
||||
* method of invoking the Show() method on the
|
||||
* nsISplashScreen interface obtained by calling
|
||||
* NS_CreateSplashScreen.
|
||||
*
|
||||
* hideSplashScreen - Causes the splash screen to be removed (if it is
|
||||
* being shown). This replaces the old method of
|
||||
* invoking the Hide() method on the nsISplashScreen
|
||||
* interface maintained by the app shell service.
|
||||
*
|
||||
* startServerMode - Method that "starts" server mode. Typically, this
|
||||
* will create a hidden Navigator window (and then close
|
||||
* it) in order to fill the cache, load shared libraries,
|
||||
* etc. Note that this method does not set the
|
||||
* isServerMode attribute, nor does setting that attribute
|
||||
* "start" server mode (at least in the same sense as is
|
||||
* meant by this method). Basically, native code will
|
||||
* set isServerMode to tell nsAppRunner; nsAppRunner will
|
||||
* then call this method (implemented back in the same
|
||||
* native code) at the appropriate time for any additional
|
||||
* server-mode startup to be completed.
|
||||
*
|
||||
* onLastWindowClosing - Called when the last window is closed. Used as a
|
||||
* "soft" shutdown, passwords are flushed.
|
||||
*
|
||||
* This interface has these attributes:
|
||||
* isServerMode - Boolean attribute indicating whether the application
|
||||
* is running in "server mode." Server mode means the
|
||||
* application was started to pre-load shared-libraries,
|
||||
* initialize services, and open a hidden Navigator window
|
||||
* in order to quickly surface that window when the user
|
||||
* launches the application in the normal mode. This
|
||||
* mode is currently Win32-only (and may really only make
|
||||
* sense there) and is intended to be initiated from the
|
||||
* Windows startup folder at system initialization.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
interface nsIXULWindow;
|
||||
interface nsICmdLineService;
|
||||
|
||||
[scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)]
|
||||
interface nsINativeAppSupport : nsISupports {
|
||||
// Startup/shutdown.
|
||||
boolean start();
|
||||
boolean stop();
|
||||
void quit();
|
||||
|
||||
[noscript] void ensureProfile(in nsICmdLineService aCmdService);
|
||||
|
||||
// Splash screen functions.
|
||||
void showSplashScreen();
|
||||
void hideSplashScreen();
|
||||
|
||||
// Server mode.
|
||||
attribute boolean isServerMode;
|
||||
attribute boolean shouldShowUI;
|
||||
void startServerMode();
|
||||
|
||||
void onLastWindowClosing();
|
||||
void ReOpen();
|
||||
};
|
@ -1,68 +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):
|
||||
* 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"),
|
||||
* 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 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.
|
||||
*/
|
||||
|
||||
%{C++
|
||||
// Constants identifying Win32 "native" resources.
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
|
||||
// Splash screen dialog ID.
|
||||
#define IDD_SPLASH 100
|
||||
|
||||
// Splash screen bitmap ID.
|
||||
#define IDB_SPLASH 101
|
||||
|
||||
// DDE application name
|
||||
#define ID_DDE_APPLICATION_NAME 102
|
||||
|
||||
#define IDI_APPICON 0
|
||||
#define IDI_DOCUMENT 1
|
||||
|
||||
#endif
|
||||
|
||||
// String that goes in the WinXP Start Menu.
|
||||
#define IDS_STARTMENU_APPNAME 103
|
||||
%}
|
@ -1,74 +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):
|
||||
* 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"),
|
||||
* 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 nsISplashScreen_h__
|
||||
#define nsISplashScreen_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {B5030250-D530-11d3-8070-00600811A9C3}
|
||||
#define NS_ISPLASHSCREEN_IID \
|
||||
{ 0xb5030250, 0xd530, 0x11d3, { 0x80, 0x70, 0x0, 0x60, 0x8, 0x11, 0xa9, 0xc3 } }
|
||||
|
||||
/*
|
||||
* This class specifies the interface to be used by xp code to manage the
|
||||
platform-specific splash screen. Each platform (that has a splash screen)
|
||||
should implement this interface and return a instance of that class from
|
||||
the function NS_CreateSplashScreen.
|
||||
|
||||
Note that the nature of the splash screen object is such that it is
|
||||
impossible to obtain an instance of this interface via standard XPCOM
|
||||
means (componenter manager/service manager).
|
||||
|
||||
For the same reason, implementors should take care to implement this
|
||||
interface without introducing any dependencies on other components.
|
||||
This includes XPCOM itself as it will not have been initialized when
|
||||
an object that implements this interface will be created. Implementors
|
||||
should implement the nsISupports member functions "manually" (rather
|
||||
than via the standard NS_*IMPL macros) to avoid any dependencies
|
||||
lurking in those macros.
|
||||
*/
|
||||
class nsISplashScreen : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISPLASHSCREEN_IID)
|
||||
NS_IMETHOD Show() = 0;
|
||||
NS_IMETHOD Hide() = 0;
|
||||
}; // class nsISplashScreen
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsISplashScreen, NS_ISPLASHSCREEN_IID)
|
||||
|
||||
#endif // nsISplashScreen_h__
|
@ -1,65 +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):
|
||||
* 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"),
|
||||
* 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"
|
||||
|
||||
[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"
|
||||
|
||||
%}
|
@ -1,93 +0,0 @@
|
||||
# ***** 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 = appcomps
|
||||
LIBRARY_NAME = appstartup_s
|
||||
FORCE_STATIC_LIB = 1
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
js \
|
||||
widget \
|
||||
appshell \
|
||||
exthandler \
|
||||
dom \
|
||||
necko \
|
||||
pref \
|
||||
embed_base \
|
||||
webbrwsr \
|
||||
windowwatcher \
|
||||
intl \
|
||||
profile \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsAppStartup.cpp \
|
||||
nsCommandLineService.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq (os2,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += nsUserInfoOS2.cpp
|
||||
else
|
||||
ifeq (WINNT,$(OS_ARCH))
|
||||
CPPSRCS += nsUserInfoWin.cpp
|
||||
else
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += \
|
||||
nsUserInfoMac.cpp \
|
||||
nsCommandLineServiceMac.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../../../bootstrap/appleevents
|
||||
OS_CXXFLAGS += -fexceptions
|
||||
else
|
||||
CPPSRCS += nsUserInfoUnix.cpp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_COMPONENTS = nsCloseAllWindows.js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -1,933 +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. 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 "nsICloseAllWindows.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIProfileChangeStatus.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
#include "prprf.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsAppShellCID.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
#include "nsEmbedCID.h"
|
||||
|
||||
class nsAppStartupExitEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsAppStartupExitEvent(nsAppStartup *service)
|
||||
: mService(service) {}
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
// Tell the appshell to exit
|
||||
mService->mAppShell->Exit();
|
||||
|
||||
// We're done "shutting down".
|
||||
mService->mShuttingDown = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsAppStartup> mService;
|
||||
};
|
||||
|
||||
NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
//
|
||||
// nsAppStartup
|
||||
//
|
||||
|
||||
nsAppStartup::nsAppStartup() :
|
||||
mConsiderQuitStopper(0),
|
||||
mShuttingDown(PR_FALSE),
|
||||
mAttemptingQuit(PR_FALSE)
|
||||
{ }
|
||||
|
||||
|
||||
//
|
||||
// nsAppStartup->nsISupports
|
||||
//
|
||||
|
||||
NS_IMPL_ISUPPORTS5(nsAppStartup,
|
||||
nsIAppStartup,
|
||||
nsIWindowCreator,
|
||||
nsIWindowCreator2,
|
||||
nsIObserver,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
|
||||
//
|
||||
// nsAppStartup->nsIAppStartup
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::Initialize(nsISupports *aNativeAppSupportOrSplashScreen)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Remember where the native app support lives.
|
||||
mNativeAppSupport = do_QueryInterface(aNativeAppSupportOrSplashScreen);
|
||||
|
||||
// Or, remember the splash screen (for backward compatibility).
|
||||
if (!mNativeAppSupport)
|
||||
mSplashScreen = do_QueryInterface(aNativeAppSupportOrSplashScreen);
|
||||
|
||||
// Create widget application shell
|
||||
mAppShell = do_GetService(kAppShellCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIObserverService> os
|
||||
(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
os->AddObserver(this, "skin-selected", PR_TRUE);
|
||||
os->AddObserver(this, "locale-selected", PR_TRUE);
|
||||
os->AddObserver(this, "xpinstall-restart", 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);
|
||||
os->AddObserver(this, "xul-window-visible", PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
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::DoProfileStartup(nsICmdLineService *aCmdLineService,
|
||||
PRBool canInteract)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIProfileInternal> profileMgr
|
||||
(do_GetService(NS_PROFILE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
EnterLastWindowClosingSurvivalArea();
|
||||
|
||||
// If we are being launched in turbo mode, profile mgr cannot show UI
|
||||
rv = profileMgr->StartupWithArgs(aCmdLineService, canInteract);
|
||||
if (!canInteract && rv == NS_ERROR_PROFILE_REQUIRES_INTERACTION) {
|
||||
NS_WARNING("nsIProfileInternal::StartupWithArgs returned NS_ERROR_PROFILE_REQUIRES_INTERACTION");
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CheckAndRemigrateDefunctProfile();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to check and remigrate profile");
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
ExitLastWindowClosingSurvivalArea();
|
||||
|
||||
// if Quit() was called while we were starting up we have a failure situation...
|
||||
if (mShuttingDown)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::GetNativeAppSupport(nsINativeAppSupport **aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult, "Null out param");
|
||||
|
||||
if (!mNativeAppSupport)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ADDREF(*aResult = mNativeAppSupport);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
// Check to see if we should quit in this case.
|
||||
if (mNativeAppSupport) {
|
||||
PRBool serverMode = PR_FALSE;
|
||||
mNativeAppSupport->GetIsServerMode(&serverMode);
|
||||
if (serverMode) {
|
||||
// stop! give control to server mode
|
||||
mShuttingDown = PR_FALSE;
|
||||
mNativeAppSupport->OnLastWindowClosing();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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", &rv);
|
||||
obsService->NotifyObservers(nsnull, "quit-application", nsnull);
|
||||
|
||||
// first shutdown native app support; doing this first will prevent new
|
||||
// requests to open additional windows coming in.
|
||||
if (mNativeAppSupport) {
|
||||
mNativeAppSupport->Quit();
|
||||
mNativeAppSupport = 0;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService
|
||||
(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
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<nsIRunnable> event = new nsAppStartupExitEvent(this);
|
||||
if (event) {
|
||||
rv = NS_DispatchToCurrentThread(event);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
postedExitEvent = PR_TRUE;
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAppStartup::CheckAndRemigrateDefunctProfile()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRInt32 secondsBeforeDefunct;
|
||||
rv = prefBranch->GetIntPref("profile.seconds_until_defunct", &secondsBeforeDefunct);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// -1 is the value for "never go defunct"
|
||||
// if the pref is set to -1, we'll never prompt the user to remigrate
|
||||
// see all.js (and all-ns.js)
|
||||
if (secondsBeforeDefunct == -1)
|
||||
return NS_OK;
|
||||
|
||||
// used for converting
|
||||
// seconds -> millisecs
|
||||
// and microsecs -> millisecs
|
||||
PRInt64 oneThousand = LL_INIT(0, 1000);
|
||||
|
||||
PRInt64 defunctInterval;
|
||||
// Init as seconds
|
||||
LL_I2L(defunctInterval, secondsBeforeDefunct);
|
||||
// Convert secs to millisecs
|
||||
LL_MUL(defunctInterval, defunctInterval, oneThousand);
|
||||
|
||||
nsCOMPtr<nsIProfileInternal> profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsXPIDLString profileName;
|
||||
PRInt64 lastModTime;
|
||||
profileMgr->GetCurrentProfile(getter_Copies(profileName));
|
||||
rv = profileMgr->GetProfileLastModTime(profileName.get(), &lastModTime);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// convert "now" from microsecs to millisecs
|
||||
PRInt64 nowInMilliSecs = PR_Now();
|
||||
LL_DIV(nowInMilliSecs, nowInMilliSecs, oneThousand);
|
||||
|
||||
// determine (using the pref value) when the profile would be considered defunct
|
||||
PRInt64 defunctIntervalAgo;
|
||||
LL_SUB(defunctIntervalAgo, nowInMilliSecs, defunctInterval);
|
||||
|
||||
// if we've used our current 6.x / mozilla profile more recently than
|
||||
// when we'd consider it defunct, don't remigrate
|
||||
if (LL_CMP(lastModTime, >, defunctIntervalAgo))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsILocalFile> origProfileDir;
|
||||
rv = profileMgr->GetOriginalProfileDir(profileName, getter_AddRefs(origProfileDir));
|
||||
// if this fails
|
||||
// then the current profile is a new one (not from 4.x)
|
||||
// so we are done.
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
// Now, we know that a matching 4.x profile exists
|
||||
// See if it has any newer files in it than our defunct profile.
|
||||
nsCOMPtr<nsISimpleEnumerator> dirEnum;
|
||||
rv = origProfileDir->GetDirectoryEntries(getter_AddRefs(dirEnum));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRBool promptForRemigration = PR_FALSE;
|
||||
PRBool hasMore;
|
||||
while (NS_SUCCEEDED(dirEnum->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsILocalFile> currElem;
|
||||
rv = dirEnum->GetNext(getter_AddRefs(currElem));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRInt64 currElemModTime;
|
||||
rv = currElem->GetLastModifiedTime(&currElemModTime);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
// if this file in our 4.x profile is more recent than when we last used our mozilla / 6.x profile
|
||||
// we should prompt for re-migration
|
||||
if (LL_CMP(currElemModTime, >, lastModTime)) {
|
||||
promptForRemigration = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If nothing in the 4.x dir is newer than our defunct profile, return.
|
||||
if (!promptForRemigration)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> stringBundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> migrationBundle, brandBundle;
|
||||
rv = stringBundleService->CreateBundle("chrome://communicator/locale/profile/migration.properties", getter_AddRefs(migrationBundle));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = stringBundleService->CreateBundle("chrome://branding/locale/brand.properties", getter_AddRefs(brandBundle));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsXPIDLString brandName;
|
||||
rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), getter_Copies(brandName));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsXPIDLString dialogText;
|
||||
rv = migrationBundle->GetStringFromName(NS_LITERAL_STRING("confirmRemigration").get(), getter_Copies(dialogText));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIPromptService> promptService(do_GetService(NS_PROMPTSERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
PRInt32 buttonPressed;
|
||||
rv = promptService->ConfirmEx(nsnull, brandName.get(),
|
||||
dialogText.get(), nsIPromptService::STD_YES_NO_BUTTONS,
|
||||
nsnull, nsnull, nsnull, nsnull, nsnull, &buttonPressed);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (buttonPressed == 0) {
|
||||
// Need to shut down the current profile before remigrating it
|
||||
profileMgr->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
|
||||
// If this fails, it will restore what was there.
|
||||
rv = profileMgr->RemigrateProfile(profileName.get());
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Remigration of profile failed.");
|
||||
// Whether or not we succeeded or failed, need to reset this.
|
||||
profileMgr->SetCurrentProfile(profileName.get());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
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::HideSplashScreen()
|
||||
{
|
||||
// Hide the splash screen.
|
||||
if ( mNativeAppSupport ) {
|
||||
mNativeAppSupport->HideSplashScreen();
|
||||
} else if ( mSplashScreen ) {
|
||||
mSplashScreen->Hide();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::CreateStartupState(PRInt32 aWindowWidth, PRInt32 aWindowHeight,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
nsresult rv;
|
||||
|
||||
// If starting up in server mode, then we do things differently.
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
rv = GetNativeAppSupport(getter_AddRefs(nativeApp));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRBool isServerMode = PR_FALSE;
|
||||
nativeApp->GetIsServerMode(&isServerMode);
|
||||
if (isServerMode) {
|
||||
nativeApp->StartServerMode();
|
||||
}
|
||||
PRBool shouldShowUI = PR_TRUE;
|
||||
nativeApp->GetShouldShowUI(&shouldShowUI);
|
||||
if (!shouldShowUI) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
rv = startupBranch->GetBoolPref(childArray[i], &prefValue);
|
||||
if (NS_SUCCEEDED(rv) && 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);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::Ensure1Window(nsICmdLineService *aCmdLineService)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return 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);
|
||||
|
||||
rv = OpenBrowserWindow(height, width);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAppStartup::LaunchTask(const char *aParam, PRInt32 height, PRInt32 width, PRBool *windowOpened)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
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) {
|
||||
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 {
|
||||
rv = OpenWindow(chromeUrlForTask, EmptyString(), 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;
|
||||
|
||||
// Make sure a profile is selected.
|
||||
|
||||
// We need the native app support object. If this fails, we still proceed.
|
||||
// That's because some platforms don't have a native app
|
||||
// support implementation. On those platforms, "ensuring a
|
||||
// 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<nsINativeAppSupport> nativeApp;
|
||||
if (NS_SUCCEEDED(GetNativeAppSupport(getter_AddRefs(nativeApp))))
|
||||
{
|
||||
nsCOMPtr <nsICmdLineService> cmdLine =
|
||||
do_GetService(NS_COMMANDLINESERVICE_CONTRACTID);
|
||||
|
||||
if (cmdLine) {
|
||||
// Make sure profile has been selected.
|
||||
// At this point, we have to look for failure. That
|
||||
// handles the case where the user chooses "Exit" on
|
||||
// the profile manager window.
|
||||
if (NS_FAILED(nativeApp->EnsureProfile(cmdLine)))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
|
||||
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 (!urlToLoad.IsEmpty()) {
|
||||
|
||||
#ifdef DEBUG_CMD_LINE
|
||||
printf("url to load: %s\n", urlToLoad.get());
|
||||
#endif /* DEBUG_CMD_LINE */
|
||||
|
||||
nsAutoString url;
|
||||
// convert the cmdLine URL to Unicode
|
||||
rv = NS_CopyNativeToUnicode(nsDependentCString(urlToLoad), url);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("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_ConvertUTF16toUTF8(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, 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, "skin-selected") ||
|
||||
!strcmp(aTopic, "locale-selected") ||
|
||||
!strcmp(aTopic, "xpinstall-restart")) {
|
||||
if (mNativeAppSupport)
|
||||
mNativeAppSupport->SetIsServerMode(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).EqualsLiteral("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 if (!strcmp(aTopic, "xul-window-visible")) {
|
||||
// Hide splash screen (if there is one).
|
||||
static PRBool splashScreenGone = PR_FALSE;
|
||||
if(!splashScreenGone) {
|
||||
HideSplashScreen();
|
||||
splashScreenGone = PR_TRUE;
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("Unexpected observer topic.");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1,99 +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. 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 "nsISplashScreen.h"
|
||||
#include "nsINativeAppSupport.h"
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
struct PLEvent;
|
||||
|
||||
// {A70A1E2B-1FCB-41ca-B011-1D207B9EA7A9}
|
||||
#define NS_SEAMONKEY_APPSTARTUP_CID \
|
||||
{ 0xa70a1e2b, 0x1fcb, 0x41ca, { 0xb0, 0x11, 0x1d, 0x20, 0x7b, 0x9e, 0xa7, 0xa9 } }
|
||||
|
||||
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();
|
||||
|
||||
private:
|
||||
friend class nsAppStartupExitEvent;
|
||||
|
||||
~nsAppStartup() { }
|
||||
|
||||
void AttemptingQuit(PRBool aAttempt);
|
||||
|
||||
nsresult CheckAndRemigrateDefunctProfile();
|
||||
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;
|
||||
nsCOMPtr<nsISplashScreen> mSplashScreen;
|
||||
nsCOMPtr<nsINativeAppSupport> mNativeAppSupport;
|
||||
|
||||
PRInt32 mConsiderQuitStopper; // if > 0, Quit(eConsiderQuit) fails
|
||||
PRPackedBool mShuttingDown; // Quit method reentrancy check
|
||||
PRPackedBool mAttemptingQuit; // Quit(eAttemptQuit) still trying
|
||||
};
|
||||
|
||||
#endif // nsAppStartup_h__
|
@ -1,144 +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):
|
||||
* 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))
|
||||
return this;
|
||||
|
||||
Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return null;
|
||||
},
|
||||
|
||||
// ---------- 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;
|
||||
}
|
@ -1,403 +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):
|
||||
*
|
||||
* 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 "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 reinterpret_cast<void*>(ToNewCString(fileurl));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 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(reinterpret_cast<void*>(nsCRT::strdup("-progname")));
|
||||
mArgValueList.AppendElement(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(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(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(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((void *)PL_strdup("1"));
|
||||
//mArgCount++;
|
||||
|
||||
// Append the url to the arrays
|
||||
//mArgList.AppendElement((void *)PL_strdup("-url"));
|
||||
mArgValueList.AppendElement(ProcessURLArg(aArgv[i]));
|
||||
mArgCount++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* This is a value to the previous option.
|
||||
* Store it in the mArgValue array
|
||||
*/
|
||||
mArgValueList.AppendElement(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(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)
|
||||
{
|
||||
nsresult rv = GetCmdLineValue("-url", aResult);
|
||||
if (NS_SUCCEEDED(rv) && *aResult && !strncmp(*aResult, "chrome:", 7)) {
|
||||
nsMemory::Free(*aResult);
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetProgramName(char ** aResult)
|
||||
{
|
||||
*aResult = nsCRT::strdup((char *)mArgValueList.SafeElementAt(0));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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 = reinterpret_cast<char*>(mArgList[curr-1]);
|
||||
if ( str )
|
||||
nsMemory::Free(str);
|
||||
--curr;
|
||||
}
|
||||
|
||||
curr = mArgValueList.Count();
|
||||
while ( curr ) {
|
||||
char* str = 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
|
||||
|
@ -1,71 +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):
|
||||
*
|
||||
* 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 __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
|
@ -1,420 +0,0 @@
|
||||
/* -*- 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
|
||||
*
|
||||
* 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):
|
||||
* Simon Fraser <sfraser@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.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 ***** */
|
||||
|
||||
// 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 "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;
|
||||
|
||||
// Here, we may actually get useful args.
|
||||
// Copy them first to mArgv.
|
||||
for (int arg = 0; arg < argc; arg++)
|
||||
AddToCommandLine(argv[arg]);
|
||||
|
||||
// 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 (::GetCurrentEventKeyModifiers() & 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_ConvertASCIItoUTF16(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
|
@ -1,115 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is 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 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 ***** */
|
||||
|
||||
// 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_
|
@ -1,55 +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):
|
||||
* 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"),
|
||||
* 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 __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 */
|
@ -1,142 +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):
|
||||
*
|
||||
* 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 "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,71 +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):
|
||||
* 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"),
|
||||
* 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 __nsUserInfoMac_h
|
||||
#define __nsUserInfoMac_h
|
||||
|
||||
#include "nsIUserInfo.h"
|
||||
|
||||
|
||||
#include <InternetConfig.h>
|
||||
|
||||
class nsUserInfo: public nsIUserInfo
|
||||
|
||||
{
|
||||
public:
|
||||
nsUserInfo(void);
|
||||
virtual ~nsUserInfo();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIUSERINFO
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
nsresult EnsureInitted();
|
||||
|
||||
static OSType GetAppCreatorCode();
|
||||
static PRUnichar* PStringToNewUCS2(ConstStr255Param str);
|
||||
|
||||
protected:
|
||||
|
||||
ICInstance mInstance;
|
||||
PRBool mInitted;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __nsUserInfo_h */
|
@ -1,87 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is 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 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 *****
|
||||
* 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;
|
||||
}
|
@ -1,199 +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):
|
||||
* 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"),
|
||||
* 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 "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;
|
||||
}
|
||||
|
@ -1,93 +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):
|
||||
* Doug Turner <dougt@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"),
|
||||
* 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 "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;
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
#
|
||||
# ***** 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
|
||||
# Christopher Blizzard <blizzard@mozilla.org>.
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xremoteservice
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -1,52 +0,0 @@
|
||||
#
|
||||
# ***** 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
|
||||
# Christopher Blizzard <blizzard@mozilla.org>.
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = appcomps
|
||||
XPIDL_MODULE = xremoteservice
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsISuiteRemoteService.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -1,61 +0,0 @@
|
||||
/* ***** 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
|
||||
* Christopher Blizzard <blizzard@mozilla.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
*
|
||||
* 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"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
|
||||
/**
|
||||
* Responds to incoming xremote requests for the mozilla suite.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(52add212-2067-4575-8d26-edd5165179b1)]
|
||||
interface nsISuiteRemoteService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Parse the command given.
|
||||
*
|
||||
* @param aCommand The command string, e.g. "openURL(http://www.foo.com/)"
|
||||
* @param aContext The domwindow to target the command at. May be null, and
|
||||
* may be ignored.
|
||||
*/
|
||||
void parseCommand (in string aCommand, in nsIDOMWindow aContext);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_SUITEREMOTESERVICE_CONTRACTID "@mozilla.org/browser/xremoteservice;2"
|
||||
%}
|
@ -1,81 +0,0 @@
|
||||
#
|
||||
# ***** 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
|
||||
# Christopher Blizzard <blizzard@mozilla.org>.
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = appcomps
|
||||
LIBRARY_NAME = xremoteservice
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = XRemoteServiceModule
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
PACKAGE_FILE = xremote.pkg
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
dom \
|
||||
content \
|
||||
layout \
|
||||
widget \
|
||||
uriloader \
|
||||
docshell \
|
||||
pref \
|
||||
windowwatcher \
|
||||
necko \
|
||||
appshell \
|
||||
toolkitcomps \
|
||||
appcomps \
|
||||
exthandler \
|
||||
profile \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
XRemoteService.cpp \
|
||||
XRemoteContentListener.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
@ -1,122 +0,0 @@
|
||||
/* ***** 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
|
||||
* Christopher Blizzard <blizzard@mozilla.org>.
|
||||
* 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 ***** */
|
||||
|
||||
#include "XRemoteContentListener.h"
|
||||
|
||||
XRemoteContentListener::XRemoteContentListener()
|
||||
{
|
||||
}
|
||||
|
||||
XRemoteContentListener::~XRemoteContentListener()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(XRemoteContentListener,
|
||||
nsIURIContentListener,
|
||||
nsIInterfaceRequestor)
|
||||
|
||||
// nsIURIContentListener
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::OnStartURIOpen(nsIURI *aURI, PRBool *_retval)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::DoContent(const char *aContentType,
|
||||
PRBool aIsContentPreferred,
|
||||
nsIRequest *request,
|
||||
nsIStreamListener **aContentHandler,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_NOTREACHED("XRemoteContentListener::DoContent");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::IsPreferred(const char *aContentType,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::CanHandleContent(const char *aContentType,
|
||||
PRBool aIsContentPreferred,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_NOTREACHED("XRemoteContentListener::CanHandleContent");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::GetLoadCookie(nsISupports * *aLoadCookie)
|
||||
{
|
||||
*aLoadCookie = mLoadCookie;
|
||||
NS_IF_ADDREF(*aLoadCookie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
mLoadCookie = aLoadCookie;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::GetParentContentListener(nsIURIContentListener * *aParentContentListener)
|
||||
{
|
||||
*aParentContentListener = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::SetParentContentListener(nsIURIContentListener * aParentContentListener)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_IMETHODIMP
|
||||
XRemoteContentListener::GetInterface(const nsIID & uuid, void * *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
return QueryInterface(uuid, result);
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/* ***** 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
|
||||
* Christopher Blizzard <blizzard@mozilla.org>.
|
||||
* 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 ***** */
|
||||
|
||||
#include <nsIURIContentListener.h>
|
||||
#include <nsIInterfaceRequestor.h>
|
||||
#include <nsCOMPtr.h>
|
||||
|
||||
class XRemoteContentListener : public nsIURIContentListener,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
XRemoteContentListener();
|
||||
virtual ~XRemoteContentListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
private:
|
||||
|
||||
nsCOMPtr<nsISupports> mLoadCookie;
|
||||
};
|
@ -1,776 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=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
|
||||
* Christopher Blizzard <blizzard@mozilla.org>.
|
||||
* 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 ***** */
|
||||
|
||||
#include "XRemoteService.h"
|
||||
#include "XRemoteContentListener.h"
|
||||
#include "nsIBrowserDOMWindow.h"
|
||||
|
||||
#include <nsIGenericFactory.h>
|
||||
#include <nsIWebNavigation.h>
|
||||
#include <nsPIDOMWindow.h>
|
||||
#include <nsIDOMChromeWindow.h>
|
||||
#include <nsIDocShell.h>
|
||||
#include <nsIBaseWindow.h>
|
||||
#include <nsIServiceManager.h>
|
||||
#include <nsString.h>
|
||||
#include <nsCRT.h>
|
||||
#include <nsIPrefBranch.h>
|
||||
#include <nsIPrefService.h>
|
||||
#include <nsIWindowWatcher.h>
|
||||
#include <nsXPCOM.h>
|
||||
#include <nsISupportsPrimitives.h>
|
||||
#include <nsIInterfaceRequestor.h>
|
||||
#include <nsIInterfaceRequestorUtils.h>
|
||||
#include <nsIDocShellTreeItem.h>
|
||||
#include <nsIDocShellTreeOwner.h>
|
||||
#include <nsIURILoader.h>
|
||||
#include <nsCURILoader.h>
|
||||
#include <nsIURIFixup.h>
|
||||
#include <nsCDefaultURIFixup.h>
|
||||
#include <nsIURI.h>
|
||||
#include <nsNetUtil.h>
|
||||
#include <nsIWindowMediator.h>
|
||||
#include <nsCExternalHandlerService.h>
|
||||
#include <nsIExternalProtocolService.h>
|
||||
#include <nsIProfile.h>
|
||||
|
||||
#include "nsICmdLineHandler.h"
|
||||
|
||||
XRemoteService::XRemoteService()
|
||||
{
|
||||
}
|
||||
|
||||
XRemoteService::~XRemoteService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(XRemoteService, nsISuiteRemoteService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
XRemoteService::ParseCommand(const char *aCommand, nsIDOMWindow* aWindow)
|
||||
{
|
||||
NS_ASSERTION(aCommand, "Tell me what to do, or shut up!");
|
||||
|
||||
// begin our parse
|
||||
nsCString tempString(aCommand);
|
||||
|
||||
// find the () in the command
|
||||
PRInt32 begin_arg = tempString.FindChar('(');
|
||||
PRInt32 end_arg = tempString.RFindChar(')');
|
||||
|
||||
// make sure that both were found, the string doesn't start with '('
|
||||
// and that the ')' follows the '('
|
||||
if (begin_arg == kNotFound || end_arg == kNotFound ||
|
||||
begin_arg == 0 || end_arg < begin_arg)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// truncate the closing paren and anything following it
|
||||
tempString.Truncate(end_arg);
|
||||
|
||||
// save the argument and trim whitespace off of it
|
||||
nsCString argument(tempString);
|
||||
argument.Cut(0, begin_arg + 1);
|
||||
argument.Trim(" ", PR_TRUE, PR_TRUE);
|
||||
|
||||
// remove the argument
|
||||
tempString.Truncate(begin_arg);
|
||||
|
||||
// get the action, strip off whitespace and convert to lower case
|
||||
nsCString action(tempString);
|
||||
action.Trim(" ", PR_TRUE, PR_TRUE);
|
||||
ToLowerCase(action);
|
||||
|
||||
// pull off the noraise argument if it's there.
|
||||
PRUint32 index = 0;
|
||||
PRBool raiseWindow = PR_TRUE;
|
||||
nsCString lastArgument;
|
||||
|
||||
FindLastInList(argument, lastArgument, &index);
|
||||
if (lastArgument.LowerCaseEqualsLiteral("noraise")) {
|
||||
argument.Truncate(index);
|
||||
raiseWindow = PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
/*
|
||||
openURL ( )
|
||||
Prompts for a URL with a dialog box.
|
||||
openURL (URL)
|
||||
Opens the specified document without prompting.
|
||||
openURL (URL, new-window)
|
||||
Create a new window displaying the the specified document.
|
||||
*/
|
||||
|
||||
/*
|
||||
openFile ( )
|
||||
Prompts for a file with a dialog box.
|
||||
openFile (File)
|
||||
Opens the specified file without prompting.
|
||||
|
||||
*/
|
||||
|
||||
if (action.Equals("openurl") || action.Equals("openfile")) {
|
||||
rv = OpenURL(argument, aWindow, PR_TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
saveAs ( )
|
||||
Prompts for a file with a dialog box (like the menu item).
|
||||
saveAs (Output-File)
|
||||
Writes HTML to the specified file without prompting.
|
||||
saveAs (Output-File, Type)
|
||||
Writes to the specified file with the type specified -
|
||||
the type may be HTML, Text, or PostScript.
|
||||
|
||||
*/
|
||||
|
||||
else if (action.Equals("saveas")) {
|
||||
if (argument.IsEmpty()) {
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
else {
|
||||
// check to see if it has a type on it
|
||||
index = 0;
|
||||
FindLastInList(argument, lastArgument, &index);
|
||||
if (lastArgument.LowerCaseEqualsLiteral("html")) {
|
||||
argument.Truncate(index);
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
else if (lastArgument.EqualsIgnoreCase("text", PR_TRUE)) {
|
||||
argument.Truncate(index);
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
else if (lastArgument.EqualsIgnoreCase("postscript", PR_TRUE)) {
|
||||
argument.Truncate(index);
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
mailto ( )
|
||||
pops up the mail dialog with the To: field empty.
|
||||
mailto (a, b, c)
|
||||
Puts the addresses "a, b, c" in the default To: field.
|
||||
|
||||
*/
|
||||
|
||||
else if (action.Equals("mailto")) {
|
||||
// if you prepend mailto: to the string it will be a mailto: url
|
||||
// and openurl should work fine.
|
||||
nsCString tempArg("mailto:");
|
||||
tempArg.Append(argument);
|
||||
rv = OpenURL(tempArg, aWindow, PR_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
addBookmark ( )
|
||||
Adds the current document to the bookmark list.
|
||||
addBookmark (URL)
|
||||
Adds the given document to the bookmark list.
|
||||
addBookmark (URL, Title)
|
||||
Adds the given document to the bookmark list,
|
||||
with the given title.
|
||||
*/
|
||||
|
||||
else if (action.Equals("addbookmark")) {
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* some extensions! */
|
||||
|
||||
/*
|
||||
ping()
|
||||
Just responds with an OK to let a client know that we are here.
|
||||
*/
|
||||
|
||||
else if (action.Equals("ping")) {
|
||||
// the 200 will get filled in below
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
xfeDoCommand()
|
||||
This is an interface to make the xfe "do stuff." Lifted from
|
||||
the old Netscape 4.x interface.
|
||||
*/
|
||||
|
||||
else if (action.Equals("xfedocommand")) {
|
||||
rv = XfeDoCommand(argument, aWindow);
|
||||
}
|
||||
|
||||
// bad command
|
||||
else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
XRemoteService::FindRestInList(nsCString &aString, nsCString &retString,
|
||||
PRUint32 *aIndexRet)
|
||||
{
|
||||
// init our return
|
||||
*aIndexRet = 0;
|
||||
nsCString tempString;
|
||||
PRInt32 strIndex;
|
||||
// find out if there's a comma from the start of the string
|
||||
strIndex = aString.FindChar(',');
|
||||
|
||||
// give up now if you can
|
||||
if (strIndex == kNotFound)
|
||||
return;
|
||||
|
||||
// cut the string down to the first ,
|
||||
tempString = Substring(aString, strIndex+1, aString.Length());
|
||||
|
||||
// strip off leading + trailing whitespace
|
||||
tempString.Trim(" ", PR_TRUE, PR_TRUE);
|
||||
|
||||
// see if we've reduced it to nothing
|
||||
if (tempString.IsEmpty())
|
||||
return;
|
||||
|
||||
*aIndexRet = strIndex;
|
||||
|
||||
// otherwise, return it as a new C string
|
||||
retString = tempString;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
XRemoteService::FindLastInList(nsCString &aString, nsCString &retString,
|
||||
PRUint32 *aIndexRet)
|
||||
{
|
||||
// init our return
|
||||
*aIndexRet = 0;
|
||||
// make a copy to work with
|
||||
nsCString tempString = aString;
|
||||
PRInt32 strIndex;
|
||||
// find out of there's a , at the end of the string
|
||||
strIndex = tempString.RFindChar(',');
|
||||
|
||||
// give up now if you can
|
||||
if (strIndex == kNotFound)
|
||||
return;
|
||||
|
||||
// cut the string down to the first ,
|
||||
tempString.Cut(0, strIndex + 1);
|
||||
|
||||
// strip off leading + trailing whitespace
|
||||
tempString.Trim(" ", PR_TRUE, PR_TRUE);
|
||||
|
||||
// see if we've reduced it to nothing
|
||||
if (tempString.IsEmpty())
|
||||
return;
|
||||
|
||||
*aIndexRet = strIndex;
|
||||
|
||||
// otherwise, return it as a new C string
|
||||
retString = tempString;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
XRemoteService::OpenChromeWindow(nsIDOMWindow *aParent,
|
||||
const char *aUrl, const char *aFeatures,
|
||||
nsISupports *aArguments,
|
||||
nsIDOMWindow **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> watcher;
|
||||
watcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
||||
|
||||
if (!watcher)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return watcher->OpenWindow(aParent, aUrl, "_blank",
|
||||
aFeatures, aArguments, _retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
XRemoteService::GetBrowserLocation(char **_retval)
|
||||
{
|
||||
// get the browser chrome URL
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!prefs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
prefs->GetCharPref("browser.chromeURL", _retval);
|
||||
|
||||
// fallback
|
||||
if (!*_retval)
|
||||
*_retval = nsCRT::strdup("chrome://navigator/content/navigator.xul");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XRemoteService::GetMailLocation(char **_retval)
|
||||
{
|
||||
// get the mail chrome URL
|
||||
*_retval = nsCRT::strdup("chrome://messenger/content/");
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
XRemoteService::GetComposeLocation(const char **_retval)
|
||||
{
|
||||
// get the Compose chrome URL
|
||||
*_retval = "chrome://messenger/content/messengercompose/messengercompose.xul";
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XRemoteService::GetCalendarLocation(char **_retval)
|
||||
{
|
||||
// get the calendar chrome URL
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!prefs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
prefs->GetCharPref("calendar.chromeURL", _retval);
|
||||
|
||||
// fallback
|
||||
if (!*_retval)
|
||||
*_retval = nsCRT::strdup("chrome://calendar/content/calendar.xul");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
XRemoteService::MayOpenURL(const nsCString &aURL)
|
||||
{
|
||||
// by default, we assume nothing can be loaded.
|
||||
PRBool allowURL= PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIExternalProtocolService> extProtService =
|
||||
do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID);
|
||||
if (extProtService) {
|
||||
nsCAutoString scheme;
|
||||
|
||||
// empty URLs will be treated as about:blank by OpenURL
|
||||
if (aURL.IsEmpty()) {
|
||||
scheme.AssignLiteral("about");
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID);
|
||||
if (fixup) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv =
|
||||
fixup->CreateFixupURI(aURL, nsIURIFixup::FIXUP_FLAGS_MAKE_ALTERNATE_URI,
|
||||
getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv) && uri) {
|
||||
uri->GetScheme(scheme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!scheme.IsEmpty()) {
|
||||
// if the given URL scheme corresponds to an exposed protocol, then we
|
||||
// can try to load it. otherwise, we must not.
|
||||
PRBool isExposed;
|
||||
nsresult rv = extProtService->IsExposedProtocol(scheme.get(), &isExposed);
|
||||
if (NS_SUCCEEDED(rv) && isExposed)
|
||||
allowURL = PR_TRUE; // ok, we can load this URL.
|
||||
}
|
||||
}
|
||||
|
||||
return allowURL;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XRemoteService::OpenURL(nsCString &aArgument,
|
||||
nsIDOMWindow *aParent,
|
||||
PRBool aOpenBrowser)
|
||||
{
|
||||
// the eventual toplevel target of the load
|
||||
nsCOMPtr<nsIDOMWindowInternal> finalWindow = do_QueryInterface(aParent);
|
||||
|
||||
// see if there's a new-window or new-tab argument on the end
|
||||
nsCString lastArgument;
|
||||
PRBool newWindow = PR_FALSE, newTab = PR_FALSE;
|
||||
PRUint32 index = 0;
|
||||
FindLastInList(aArgument, lastArgument, &index);
|
||||
|
||||
newTab = lastArgument.LowerCaseEqualsLiteral("new-tab");
|
||||
|
||||
if (newTab || lastArgument.LowerCaseEqualsLiteral("new-window")) {
|
||||
aArgument.Truncate(index);
|
||||
// only open new windows if it's OK to do so
|
||||
if (!newTab && aOpenBrowser)
|
||||
newWindow = PR_TRUE;
|
||||
// recheck for a possible noraise argument since it might have
|
||||
// been before the new-window argument
|
||||
FindLastInList(aArgument, lastArgument, &index);
|
||||
if (lastArgument.LowerCaseEqualsLiteral("noraise"))
|
||||
aArgument.Truncate(index);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowserDOMWindow> bwin;
|
||||
|
||||
// If it's OK to open a new browser window and a new window flag
|
||||
// wasn't passed in then try to find a current window. If that's
|
||||
// not found then go ahead and open a new window.
|
||||
// If we're trying to open a new tab, we'll fall back to opening
|
||||
// a new window if there's no browser window open, so look for it
|
||||
// here.
|
||||
if (aOpenBrowser && (!newWindow || newTab)) {
|
||||
nsCOMPtr<nsIDOMWindowInternal> lastUsedWindow;
|
||||
FindWindow(NS_LITERAL_STRING("navigator:browser").get(),
|
||||
getter_AddRefs(lastUsedWindow));
|
||||
|
||||
if (lastUsedWindow) {
|
||||
finalWindow = lastUsedWindow;
|
||||
nsCOMPtr<nsIWebNavigation> navNav(do_GetInterface(finalWindow));
|
||||
nsCOMPtr<nsIDocShellTreeItem> navItem(do_QueryInterface(navNav));
|
||||
if (navItem) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
||||
navItem->GetRootTreeItem(getter_AddRefs(rootItem));
|
||||
nsCOMPtr<nsIDOMWindow> rootWin(do_GetInterface(rootItem));
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(rootWin));
|
||||
if (chromeWin)
|
||||
chromeWin->GetBrowserDOMWindow(getter_AddRefs(bwin));
|
||||
}
|
||||
}
|
||||
if (!finalWindow || !bwin)
|
||||
newWindow = PR_TRUE;
|
||||
}
|
||||
|
||||
// check if we can handle this type of URL
|
||||
if (!MayOpenURL(aArgument))
|
||||
return NS_ERROR_ABORT;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// try to fixup the argument passed in
|
||||
nsString url;
|
||||
url.AssignWithConversion(aArgument.get());
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), url);
|
||||
|
||||
if (newWindow) {
|
||||
nsXPIDLCString urlString;
|
||||
GetBrowserLocation(getter_Copies(urlString));
|
||||
if (!urlString)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISupportsString> arg;
|
||||
arg = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
|
||||
if (!arg)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// save the url into the string object
|
||||
arg->SetData(url);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
rv = OpenChromeWindow(finalWindow, urlString, "chrome,all,dialog=no",
|
||||
arg, getter_AddRefs(window));
|
||||
}
|
||||
|
||||
// if no new window flag was set but there's no parent then we have
|
||||
// to pass everything off to the uri loader
|
||||
else if (!finalWindow) {
|
||||
nsCOMPtr<nsIURILoader> loader;
|
||||
loader = do_GetService(NS_URI_LOADER_CONTRACTID);
|
||||
if (!loader)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
XRemoteContentListener *listener;
|
||||
listener = new XRemoteContentListener();
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// we own it
|
||||
NS_ADDREF(listener);
|
||||
nsCOMPtr<nsISupports> listenerRef;
|
||||
listenerRef = do_QueryInterface(static_cast<nsIURIContentListener *>
|
||||
(listener));
|
||||
// now the listenerref is the only reference
|
||||
NS_RELEASE(listener);
|
||||
|
||||
// double-check our uri object
|
||||
if (!uri)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// open a channel
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), uri);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// load it
|
||||
rv = loader->OpenURI(channel, PR_TRUE, listener);
|
||||
}
|
||||
|
||||
else if (newTab && aOpenBrowser) {
|
||||
if (bwin && uri) {
|
||||
nsCOMPtr<nsIDOMWindow> container;
|
||||
rv = bwin->OpenURI(uri, 0,
|
||||
nsIBrowserDOMWindow::OPEN_NEWTAB,
|
||||
nsIBrowserDOMWindow::OPEN_EXTERNAL,
|
||||
getter_AddRefs(container));
|
||||
}
|
||||
else {
|
||||
NS_ERROR("failed to open remote URL in new tab");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
else if (bwin && uri) { // unspecified new browser URL; use prefs
|
||||
nsCOMPtr<nsIDOMWindow> container;
|
||||
rv = bwin->OpenURI(uri, 0,
|
||||
nsIBrowserDOMWindow::OPEN_DEFAULTWINDOW,
|
||||
nsIBrowserDOMWindow::OPEN_EXTERNAL,
|
||||
getter_AddRefs(container));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
else { // non-browser URLs
|
||||
// find the primary content shell for the window that we've been
|
||||
// asked to load into.
|
||||
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(finalWindow));
|
||||
if (!win) {
|
||||
NS_WARNING("Failed to get script object for browser instance");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = win->GetDocShell();
|
||||
if (!docShell) {
|
||||
NS_WARNING("Failed to get docshell object for browser instance");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(docShell));
|
||||
if (!item) {
|
||||
NS_WARNING("failed to get doc shell tree item for browser instance");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||
item->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||
if (!treeOwner) {
|
||||
NS_WARNING("failed to get tree owner");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> primaryContent;
|
||||
treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent));
|
||||
|
||||
docShell = do_QueryInterface(primaryContent);
|
||||
if (!docShell) {
|
||||
NS_WARNING("failed to get docshell from primary content item");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav;
|
||||
webNav = do_GetInterface(docShell);
|
||||
if (!webNav) {
|
||||
NS_WARNING("failed to get web nav from inner docshell");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = webNav->LoadURI(url.get(),
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE,
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsnull);
|
||||
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XRemoteService::XfeDoCommand(nsCString &aArgument,
|
||||
nsIDOMWindow *aParent)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// see if there are any arguments on the end
|
||||
nsCString restArgument;
|
||||
PRUint32 index;
|
||||
FindRestInList(aArgument, restArgument, &index);
|
||||
|
||||
if (!restArgument.IsEmpty())
|
||||
aArgument.Truncate(index);
|
||||
nsCOMPtr<nsISupportsString> arg;
|
||||
arg = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// pass the second argument as parameter
|
||||
arg->SetData(NS_ConvertUTF8toUTF16(restArgument));
|
||||
|
||||
// someone requested opening mail/news
|
||||
if (aArgument.LowerCaseEqualsLiteral("openinbox")) {
|
||||
|
||||
// check to see if it's already running
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWindow;
|
||||
|
||||
rv = FindWindow(NS_LITERAL_STRING("mail:3pane").get(),
|
||||
getter_AddRefs(domWindow));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// focus the window if it was found
|
||||
if (domWindow) {
|
||||
domWindow->Focus();
|
||||
}
|
||||
|
||||
// otherwise open a new mail/news window
|
||||
else {
|
||||
// get the mail chrome location
|
||||
nsXPIDLCString mailLocation;
|
||||
GetMailLocation(getter_Copies(mailLocation));
|
||||
if (!mailLocation)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = OpenChromeWindow(0, mailLocation, "chrome,all,dialog=no",
|
||||
arg, getter_AddRefs(newWindow));
|
||||
}
|
||||
}
|
||||
|
||||
// open a new browser window
|
||||
else if (aArgument.LowerCaseEqualsLiteral("openbrowser")) {
|
||||
// Get the browser URL and the default start page URL.
|
||||
nsCOMPtr<nsICmdLineHandler> browserHandler =
|
||||
do_GetService("@mozilla.org/commandlinehandler/general-startup;1?type=browser");
|
||||
|
||||
if (!browserHandler)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLCString browserLocation;
|
||||
browserHandler->GetChromeUrlForTask(getter_Copies(browserLocation));
|
||||
|
||||
nsXPIDLString startPage;
|
||||
browserHandler->GetDefaultArgs(getter_Copies(startPage));
|
||||
|
||||
arg->SetData(startPage);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = OpenChromeWindow(0, browserLocation, "chrome,all,dialog=no",
|
||||
arg, getter_AddRefs(newWindow));
|
||||
}
|
||||
|
||||
// open a new compose window
|
||||
else if (aArgument.LowerCaseEqualsLiteral("composemessage")) {
|
||||
/*
|
||||
* Here we change to OpenChromeWindow instead of OpenURL so as to
|
||||
* pass argument values to the compose window, especially attachments
|
||||
*/
|
||||
const char * composeLocation;
|
||||
rv = GetComposeLocation(&composeLocation);
|
||||
if (rv != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = OpenChromeWindow(0, composeLocation, "chrome,all,dialog=no",
|
||||
arg, getter_AddRefs(newWindow));
|
||||
}
|
||||
|
||||
// open a new calendar window
|
||||
else if (aArgument.LowerCaseEqualsLiteral("opencalendar")) {
|
||||
|
||||
// check to see if it's already running
|
||||
nsCOMPtr<nsIDOMWindowInternal> aWindow;
|
||||
|
||||
rv = FindWindow(NS_LITERAL_STRING("calendarMainWindow").get(),
|
||||
getter_AddRefs(aWindow));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// focus the window if it was found
|
||||
if (aWindow) {
|
||||
aWindow->Focus();
|
||||
}
|
||||
|
||||
// otherwise open a new calendar window
|
||||
else {
|
||||
nsXPIDLCString calendarChrome;
|
||||
rv = GetCalendarLocation(getter_Copies(calendarChrome));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = OpenChromeWindow(0, calendarChrome, "chrome,all,dialog=no",
|
||||
arg, getter_AddRefs(newWindow));
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XRemoteService::FindWindow(const PRUnichar *aType,
|
||||
nsIDOMWindowInternal **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIWindowMediator> mediator;
|
||||
mediator = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
|
||||
|
||||
if (!mediator)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mediator->GetMostRecentWindow(aType, _retval);
|
||||
}
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(XRemoteService)
|
||||
|
||||
static const nsModuleComponentInfo components[] = {
|
||||
{ "XRemoteService",
|
||||
NS_XREMOTESERVICE_CID,
|
||||
"@mozilla.org/browser/xremoteservice;2",
|
||||
XRemoteServiceConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(XRemoteServiceModule, components)
|
@ -1,100 +0,0 @@
|
||||
/* ***** 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
|
||||
* Christopher Blizzard <blizzard@mozilla.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
*
|
||||
* 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 "nsISuiteRemoteService.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIDOMWindowInternal;
|
||||
|
||||
// {3dfe7324-1dd2-11b2-9ff2-8853f91e8a20}
|
||||
|
||||
#define NS_XREMOTESERVICE_CID \
|
||||
{ 0x3dfe7324, 0x1dd2, 0x11b2, \
|
||||
{ 0x9f, 0xf2, 0x88, 0x53, 0xf9, 0x1e, 0x8a, 0x20 } }
|
||||
|
||||
class XRemoteService : public nsISuiteRemoteService
|
||||
{
|
||||
public:
|
||||
XRemoteService();
|
||||
virtual ~XRemoteService();
|
||||
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_XREMOTESERVICE_CID)
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSISUITEREMOTESERVICE
|
||||
|
||||
private:
|
||||
// find the last argument in an argument string
|
||||
void FindLastInList(nsCString &aString, nsCString &retString,
|
||||
PRUint32 *aIndexRet);
|
||||
|
||||
// find the second argument through the last argument in the string
|
||||
void FindRestInList(nsCString &aString, nsCString &retString,
|
||||
PRUint32 *aIndexRet);
|
||||
|
||||
// short cut for opening chrome windows
|
||||
nsresult OpenChromeWindow(nsIDOMWindow *aParent,
|
||||
const char *aUrl,
|
||||
const char *aFeatures,
|
||||
nsISupports *aArguments,
|
||||
nsIDOMWindow **_retval);
|
||||
|
||||
// get the primary browser chrome location
|
||||
nsresult GetBrowserLocation(char **_retval);
|
||||
nsresult GetMailLocation(char **_retval);
|
||||
nsresult GetComposeLocation(const char **_retval);
|
||||
nsresult GetCalendarLocation(char **_retval);
|
||||
|
||||
// returns true if the URL may be loaded.
|
||||
PRBool MayOpenURL(const nsCString &aURL);
|
||||
|
||||
// remote command handlers
|
||||
nsresult OpenURL(nsCString &aArgument,
|
||||
nsIDOMWindow* aParent,
|
||||
PRBool aOpenBrowser);
|
||||
|
||||
// handle xfe commands
|
||||
nsresult XfeDoCommand(nsCString &aArgument,
|
||||
nsIDOMWindow* aParent);
|
||||
|
||||
// find the most recent window of a certain type
|
||||
nsresult FindWindow(const PRUnichar *aType,
|
||||
nsIDOMWindowInternal **_retval);
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
[xpfe-browser browser mail]
|
||||
#if SHARED_LIBRARY
|
||||
dist/bin/components/@SHARED_LIBRARY@
|
||||
#else
|
||||
!staticcomp @LIBRARY@ @MODULE_NAME@
|
||||
#endif
|
||||
!xpt dist/bin/components/xremoteservice.xpt
|
Loading…
Reference in New Issue
Block a user