1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6#include "nsISupports.idl" 7 8/* nsINativeAppSupport 9 * 10 * This "pseudo" (in the XPCOM sense) interface provides for 11 * platform-specific general application support: 12 * o It manages the details of the simple DDE communication 13 * supported on the Win32 platform (it is the addition of this 14 * item that prompted the creation of this interface. 15 * 16 * Due to the nature of the beast, this interface is not a full-blown 17 * XPCOM component. The primary reason is that objects that implement 18 * this interface generally must be operational *before* XPCOM (or any 19 * of the rest of Mozilla) are initialized. As a result, this 20 * interface is instantiated by somewhat unconventional means. 21 * 22 * To create the implementor of this interface, you call the function 23 * NS_CreateNativeAppSupport. This is done in the startup code 24 * in nsAppRunner.cpp 25 * 26 * The interface provides these functions: 27 * start - You call this to inform the native app support that the 28 * application is starting. In addition, it serves as a 29 * query as to whether the application should continue to 30 * run. 31 * 32 * If the returned boolean result is PR_FALSE, then the 33 * application should exit without further processing. In 34 * such cases, the returned nsresult indicates whether the 35 * reason to exit is due to an error or not. 36 * 37 * Win32 Note: In the case of starting a second instance 38 * of this executable, this function will return 39 * PR_FALSE and nsresult==NS_OK. This means that 40 * the command line arguments have been 41 * successfully passed to the instance of the 42 * application acting as a DDE server. 43 * 44 * stop - You call this to inform the native app support that the 45 * application *wishes* to terminate. If the returned boolean 46 * value is PR_FALSE, then the application should continue 47 * (as if there were still additional top-level windows open). 48 * 49 * Win32 Note: If this is the instance of the application 50 * acting as the DDE server, and there are current 51 * DDE conversations active with other instances 52 * acting as DDE clients, then this function will 53 * return PR_FALSE. 54 * 55 * quit - Like Stop, but this method *forces* termination (or more 56 * precisely, indicates that the application is about to be 57 * terminated regardless of what a call to Stop might have 58 * returned. 59 * 60 * This method is intended to be called when the user selects 61 * the "Quit" option (close all windows and exit). 62 * 63 * Win32 Note: Stop is problematic in the case of "Quit" (close 64 * all windows and exit the application) because 65 * either we don't Quit or (potentially) we lose 66 * requests coming from other instances of the 67 * application. The strategy is to give preference 68 * to the user's explicit Quit request. In the 69 * unlikely event that a request is pending from 70 * another instance of the application, then such 71 * requests are essentially ignored. This is 72 * roughly equivalent to handling that request by 73 * opening a new window, followed by immediately 74 * closing it. Since this is the same as if the 75 * request came in immediately before the Quit 76 * call (versus immediately after it), no harm. 77 * 78 * There is an exposure here: Upon return from this 79 * function, any DDE connect request (for Mozilla) 80 * will fail and other instances of the application 81 * will start up as a DDE server. In that case, 82 * those instances may do things that conflict with 83 * the subsequent shutting down of the instance that 84 * is quitting. For this reason, the call to Quit 85 * should be deferred as long as possible. 86 * 87 * onLastWindowClosing - Called when the last window is closed. Used as a 88 * "soft" shutdown, passwords are flushed. 89 */ 90 91interface nsIXULWindow; 92interface nsICmdLineService; 93 94[scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)] 95interface nsINativeAppSupport : nsISupports { 96 // Startup/shutdown. 97 boolean start(); 98 void enable(); 99 boolean stop(); 100 void quit(); 101 102 void onLastWindowClosing(); 103 void ReOpen(); 104}; 105