michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: /* nsINativeAppSupport michael@0: * michael@0: * This "pseudo" (in the XPCOM sense) interface provides for michael@0: * platform-specific general application support: michael@0: * o It manages the details of the simple DDE communication michael@0: * supported on the Win32 platform (it is the addition of this michael@0: * item that prompted the creation of this interface. michael@0: * michael@0: * Due to the nature of the beast, this interface is not a full-blown michael@0: * XPCOM component. The primary reason is that objects that implement michael@0: * this interface generally must be operational *before* XPCOM (or any michael@0: * of the rest of Mozilla) are initialized. As a result, this michael@0: * interface is instantiated by somewhat unconventional means. michael@0: * michael@0: * To create the implementor of this interface, you call the function michael@0: * NS_CreateNativeAppSupport. This is done in the startup code michael@0: * in nsAppRunner.cpp michael@0: * michael@0: * The interface provides these functions: michael@0: * start - You call this to inform the native app support that the michael@0: * application is starting. In addition, it serves as a michael@0: * query as to whether the application should continue to michael@0: * run. michael@0: * michael@0: * If the returned boolean result is PR_FALSE, then the michael@0: * application should exit without further processing. In michael@0: * such cases, the returned nsresult indicates whether the michael@0: * reason to exit is due to an error or not. michael@0: * michael@0: * Win32 Note: In the case of starting a second instance michael@0: * of this executable, this function will return michael@0: * PR_FALSE and nsresult==NS_OK. This means that michael@0: * the command line arguments have been michael@0: * successfully passed to the instance of the michael@0: * application acting as a DDE server. michael@0: * michael@0: * stop - You call this to inform the native app support that the michael@0: * application *wishes* to terminate. If the returned boolean michael@0: * value is PR_FALSE, then the application should continue michael@0: * (as if there were still additional top-level windows open). michael@0: * michael@0: * Win32 Note: If this is the instance of the application michael@0: * acting as the DDE server, and there are current michael@0: * DDE conversations active with other instances michael@0: * acting as DDE clients, then this function will michael@0: * return PR_FALSE. michael@0: * michael@0: * quit - Like Stop, but this method *forces* termination (or more michael@0: * precisely, indicates that the application is about to be michael@0: * terminated regardless of what a call to Stop might have michael@0: * returned. michael@0: * michael@0: * This method is intended to be called when the user selects michael@0: * the "Quit" option (close all windows and exit). michael@0: * michael@0: * Win32 Note: Stop is problematic in the case of "Quit" (close michael@0: * all windows and exit the application) because michael@0: * either we don't Quit or (potentially) we lose michael@0: * requests coming from other instances of the michael@0: * application. The strategy is to give preference michael@0: * to the user's explicit Quit request. In the michael@0: * unlikely event that a request is pending from michael@0: * another instance of the application, then such michael@0: * requests are essentially ignored. This is michael@0: * roughly equivalent to handling that request by michael@0: * opening a new window, followed by immediately michael@0: * closing it. Since this is the same as if the michael@0: * request came in immediately before the Quit michael@0: * call (versus immediately after it), no harm. michael@0: * michael@0: * There is an exposure here: Upon return from this michael@0: * function, any DDE connect request (for Mozilla) michael@0: * will fail and other instances of the application michael@0: * will start up as a DDE server. In that case, michael@0: * those instances may do things that conflict with michael@0: * the subsequent shutting down of the instance that michael@0: * is quitting. For this reason, the call to Quit michael@0: * should be deferred as long as possible. michael@0: * michael@0: * onLastWindowClosing - Called when the last window is closed. Used as a michael@0: * "soft" shutdown, passwords are flushed. michael@0: */ michael@0: michael@0: interface nsIXULWindow; michael@0: interface nsICmdLineService; michael@0: michael@0: [scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)] michael@0: interface nsINativeAppSupport : nsISupports { michael@0: // Startup/shutdown. michael@0: boolean start(); michael@0: void enable(); michael@0: boolean stop(); michael@0: void quit(); michael@0: michael@0: void onLastWindowClosing(); michael@0: void ReOpen(); michael@0: };