Back to index

lightning-sunbird  0.9+nobinonly
nsINativeAppSupport.idl
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Bill Law    <law@netscape.com>
00024  *   Blake Ross  <blake@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039  
00040 #include "nsISupports.idl"
00041 
00042 /* nsINativeAppSupport
00043  *
00044  * This "pseudo" (in the XPCOM sense) interface provides for
00045  * platform-specific general aplication support:
00046  *  o It subsumes the old "NS_CanRun" and "NS_CreateSplashScreen" 
00047  *    functions that managed display of the application splash 
00048  *    screen at startup.
00049  *  o It manages the details of the simple DDE communication 
00050  *    supported on the Win32 platform (it is the addition of this 
00051  *    item that prompted the creation of this interface.
00052  *
00053  * Due to the nature of the beast, this interface is not a full-blown
00054  * XPCOM component.  The primary reason is that objects that implement
00055  * this interface generally must be operational *before* XPCOM (or any
00056  * of the rest of Mozilla) are initialized.  As a result, this 
00057  * interface is instantiated by somewhat unconventional means.
00058  *
00059  * To create the implementor of this interface, you call the function
00060  * NS_CreateNativeAppSupport.  This is done in the startup code
00061  * in mozilla/xpfe/bootstrap.
00062  *
00063  * You can use this interface by obtaining an instance via the
00064  * "nativeAppSupport" attribute of the nsIAppShellService
00065  * interface/service.
00066  *
00067  * The interface provides these functions:
00068  *  start - You call this to inform the native app support that the  
00069  *          application is starting.  In addition, it serves as a
00070  *          query as to whether the application should continue to
00071  *          run.  In that respect, it is rougly equivalent to the
00072  *          NS_CanStart function, which it replaces.
00073  *
00074  *          If the returned boolean result is PR_FALSE, then the
00075  *          application should exit without further processing.  In
00076  *          such cases, the returned nsresult indicates whether the
00077  *          reason to exit is due to an error or not.
00078  *
00079  *          Win32 Note: In the case of starting a second instance
00080  *                      of this executable, this function will return
00081  *                      PR_FALSE and nsresult==NS_OK.  This means that
00082  *                      the command line arguments have been
00083  *                      successfully passed to the instance of the
00084  *                      application acting as a DDE server.
00085  *
00086  *  stop - You call this to inform the native app support that the
00087  *         application *wishes* to terminate.  If the returned boolean
00088  *         value is PR_FALSE, then the application should continue
00089  *         (as if there were still additional top-level windows open).
00090  *         
00091  *         Win32 Note: If this is the instance of the application
00092  *                     acting as the DDE server, and there are current
00093  *                     DDE conversations active with other instances
00094  *                     acting as DDE clients, then this function will
00095  *                     return PR_FALSE.
00096  * 
00097  *  quit - Like Stop, but this method *forces* termination (or more 
00098  *         precisely, indicates that the application is about to be
00099  *         terminated regardless of what a call to Stop might have
00100  *         returned.
00101  *
00102  *         This method is intended to be called when the user selects
00103  *         the "Quit" option (close all windows and exit).
00104  *
00105  *         Win32 Note: Stop is problematic in the case of "Quit" (close
00106  *                     all windows and exit the application) because
00107  *                     either we don't Quit or (potentially) we lose
00108  *                     requests coming from other instances of the
00109  *                     application.  The strategy is to give preference
00110  *                     to the user's explicit Quit request.  In the
00111  *                     unlikely event that a request is pending from
00112  *                     another instance of the application, then such
00113  *                     requests are essentially ignored.  This is
00114  *                     roughly equivalent to handling that request by
00115  *                     opening a new window, followed by immediately
00116  *                     closing it.  Since this is the same as if the
00117  *                     request came in immediately before the Quit
00118  *                     call (versus immediately after it), no harm.
00119  *
00120  *                     There is an exposure here: Upon return from this
00121  *                     function, any DDE connect request (for Mozilla)
00122  *                     will fail and other instances of the application
00123  *                     will start up as a DDE server.  In that case,
00124  *                     those instances may do things that conflict with
00125  *                     the subsequent shutting down of the instance that
00126  *                     is quitting.  For this reason, the call to Quit
00127  *                     should be deferred as long as possible.
00128  *
00129  *  showSplashScreen - Causes the platform-specific splash screen to be
00130  *                     displayed.  This is a replacement for the old
00131  *                     method of invoking the Show() method on the
00132  *                     nsISplashScreen interface obtained by calling
00133  *                     NS_CreateSplashScreen.
00134  *
00135  *  hideSplashScreen - Causes the splash screen to be removed (if it is
00136  *                     being shown).  This replaces the old method of
00137  *                     invoking the Hide() method on the nsISplashScreen
00138  *                     interface maintained by the app shell service.
00139  *
00140  *  startServerMode -  Method that "starts" server mode.  Typically, this
00141  *                     will create a hidden Navigator window (and then close
00142  *                     it) in order to fill the cache, load shared libraries,
00143  *                     etc.  Note that this method does not set the
00144  *                     isServerMode attribute, nor does setting that attribute
00145  *                     "start" server mode (at least in the same sense as is
00146  *                     meant by this method).  Basically, native code will
00147  *                     set isServerMode to tell nsAppRunner; nsAppRunner will
00148  *                     then call this method (implemented back in the same
00149  *                     native code) at the appropriate time for any additional
00150  *                     server-mode startup to be completed.
00151  *
00152  *  onLastWindowClosing -  Called when the last window is closed. Used as a
00153  *                         "soft" shutdown, passwords are flushed.
00154  *
00155  * This interface has these attributes:
00156  *  isServerMode - Boolean attribute indicating whether the application
00157  *                 is running in "server mode." Server mode means the
00158  *                 application was started to pre-load shared-libraries,
00159  *                 initialize services, and open a hidden Navigator window
00160  *                 in order to quickly surface that window when the user
00161  *                 launches the application in the normal mode.  This
00162  *                 mode is currently Win32-only (and may really only make
00163  *                 sense there) and is intended to be initiated from the
00164  *                 Windows startup folder at system initialization.
00165  *
00166  *
00167  */
00168 
00169 interface nsIXULWindow;
00170 interface nsICmdLineService;
00171 
00172 [scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)]
00173 interface nsINativeAppSupport : nsISupports {
00174     // Startup/shutdown.
00175     boolean start();
00176     boolean stop();
00177     void    quit();
00178 
00179     [noscript] void ensureProfile(in nsICmdLineService aCmdService);
00180 
00181     // Splash screen functions.
00182     void showSplashScreen();
00183     void hideSplashScreen();
00184 
00185     // Server mode.
00186     attribute boolean isServerMode;
00187     attribute boolean shouldShowUI;
00188     void startServerMode();
00189 
00190     void onLastWindowClosing();
00191     void ReOpen();
00192 };