1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/xre/nsINativeAppSupport.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,104 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +/* nsINativeAppSupport 1.12 + * 1.13 + * This "pseudo" (in the XPCOM sense) interface provides for 1.14 + * platform-specific general application support: 1.15 + * o It manages the details of the simple DDE communication 1.16 + * supported on the Win32 platform (it is the addition of this 1.17 + * item that prompted the creation of this interface. 1.18 + * 1.19 + * Due to the nature of the beast, this interface is not a full-blown 1.20 + * XPCOM component. The primary reason is that objects that implement 1.21 + * this interface generally must be operational *before* XPCOM (or any 1.22 + * of the rest of Mozilla) are initialized. As a result, this 1.23 + * interface is instantiated by somewhat unconventional means. 1.24 + * 1.25 + * To create the implementor of this interface, you call the function 1.26 + * NS_CreateNativeAppSupport. This is done in the startup code 1.27 + * in nsAppRunner.cpp 1.28 + * 1.29 + * The interface provides these functions: 1.30 + * start - You call this to inform the native app support that the 1.31 + * application is starting. In addition, it serves as a 1.32 + * query as to whether the application should continue to 1.33 + * run. 1.34 + * 1.35 + * If the returned boolean result is PR_FALSE, then the 1.36 + * application should exit without further processing. In 1.37 + * such cases, the returned nsresult indicates whether the 1.38 + * reason to exit is due to an error or not. 1.39 + * 1.40 + * Win32 Note: In the case of starting a second instance 1.41 + * of this executable, this function will return 1.42 + * PR_FALSE and nsresult==NS_OK. This means that 1.43 + * the command line arguments have been 1.44 + * successfully passed to the instance of the 1.45 + * application acting as a DDE server. 1.46 + * 1.47 + * stop - You call this to inform the native app support that the 1.48 + * application *wishes* to terminate. If the returned boolean 1.49 + * value is PR_FALSE, then the application should continue 1.50 + * (as if there were still additional top-level windows open). 1.51 + * 1.52 + * Win32 Note: If this is the instance of the application 1.53 + * acting as the DDE server, and there are current 1.54 + * DDE conversations active with other instances 1.55 + * acting as DDE clients, then this function will 1.56 + * return PR_FALSE. 1.57 + * 1.58 + * quit - Like Stop, but this method *forces* termination (or more 1.59 + * precisely, indicates that the application is about to be 1.60 + * terminated regardless of what a call to Stop might have 1.61 + * returned. 1.62 + * 1.63 + * This method is intended to be called when the user selects 1.64 + * the "Quit" option (close all windows and exit). 1.65 + * 1.66 + * Win32 Note: Stop is problematic in the case of "Quit" (close 1.67 + * all windows and exit the application) because 1.68 + * either we don't Quit or (potentially) we lose 1.69 + * requests coming from other instances of the 1.70 + * application. The strategy is to give preference 1.71 + * to the user's explicit Quit request. In the 1.72 + * unlikely event that a request is pending from 1.73 + * another instance of the application, then such 1.74 + * requests are essentially ignored. This is 1.75 + * roughly equivalent to handling that request by 1.76 + * opening a new window, followed by immediately 1.77 + * closing it. Since this is the same as if the 1.78 + * request came in immediately before the Quit 1.79 + * call (versus immediately after it), no harm. 1.80 + * 1.81 + * There is an exposure here: Upon return from this 1.82 + * function, any DDE connect request (for Mozilla) 1.83 + * will fail and other instances of the application 1.84 + * will start up as a DDE server. In that case, 1.85 + * those instances may do things that conflict with 1.86 + * the subsequent shutting down of the instance that 1.87 + * is quitting. For this reason, the call to Quit 1.88 + * should be deferred as long as possible. 1.89 + * 1.90 + * onLastWindowClosing - Called when the last window is closed. Used as a 1.91 + * "soft" shutdown, passwords are flushed. 1.92 + */ 1.93 + 1.94 +interface nsIXULWindow; 1.95 +interface nsICmdLineService; 1.96 + 1.97 +[scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)] 1.98 +interface nsINativeAppSupport : nsISupports { 1.99 + // Startup/shutdown. 1.100 + boolean start(); 1.101 + void enable(); 1.102 + boolean stop(); 1.103 + void quit(); 1.104 + 1.105 + void onLastWindowClosing(); 1.106 + void ReOpen(); 1.107 +};