Back to index

lightning-sunbird  0.9+nobinonly
nsNativeAppSupportBase.cpp
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  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #include "nsNativeAppSupportBase.h"
00039 
00040 PRBool nsNativeAppSupportBase::mLastWindowIsConfirmation = PR_FALSE;
00041 
00042 nsNativeAppSupportBase::nsNativeAppSupportBase()
00043     : mRefCnt( 0 ),
00044       mSplash( 0 ),
00045       mServerMode( PR_FALSE ),
00046       mShouldShowUI( PR_TRUE ),
00047       mShownTurboDialog( PR_FALSE ) {
00048 }
00049 
00050 nsNativeAppSupportBase::~nsNativeAppSupportBase() {
00051 }
00052 
00053 // Start answer defaults to OK.
00054 NS_IMETHODIMP
00055 nsNativeAppSupportBase::Start( PRBool *result ) {
00056     NS_ENSURE_ARG( result );
00057     *result = PR_TRUE;
00058     return NS_OK;
00059 }
00060 
00061 // Stop answer defaults to OK.
00062 NS_IMETHODIMP
00063 nsNativeAppSupportBase::Stop( PRBool *result ) {
00064     NS_ENSURE_ARG( result );
00065     *result = PR_TRUE;
00066     return NS_OK;
00067 }
00068 
00069 // Quit is a 0x90.
00070 NS_IMETHODIMP
00071 nsNativeAppSupportBase::Quit() {
00072     return NS_OK;
00073 }
00074 
00075 NS_IMETHODIMP
00076 nsNativeAppSupportBase::ReOpen()
00077 {
00078   return NS_OK;
00079 }
00080 
00081 // Show splash screen if implementation has one.
00082 NS_IMETHODIMP
00083 nsNativeAppSupportBase::ShowSplashScreen() {
00084     if ( !mSplash ) {
00085         CreateSplashScreen( getter_AddRefs( mSplash ) );
00086     }
00087     if ( mSplash ) {
00088         mSplash->Show();
00089     }
00090     return NS_OK;
00091 }
00092 
00093 // Hide splash screen if there is one.
00094 NS_IMETHODIMP
00095 nsNativeAppSupportBase::HideSplashScreen() {
00096     // See if there is a splash screen object.
00097     if ( mSplash ) {
00098         // Unhook it.
00099         nsCOMPtr<nsISplashScreen> splash = mSplash;
00100         mSplash = 0;
00101         // Hide it.
00102         splash->Hide();
00103     }
00104     return NS_OK;
00105 }
00106 
00107 NS_IMETHODIMP
00108 nsNativeAppSupportBase::SetIsServerMode(PRBool aIsServerMode) {
00109     mServerMode = aIsServerMode;
00110     return NS_OK;
00111 }
00112 
00113 NS_IMETHODIMP
00114 nsNativeAppSupportBase::GetIsServerMode(PRBool *aIsServerMode) {
00115     NS_ENSURE_ARG( aIsServerMode );
00116     *aIsServerMode = mServerMode;
00117     return NS_OK;
00118 }
00119 
00120 NS_IMETHODIMP
00121 nsNativeAppSupportBase::SetShouldShowUI(PRBool aShouldShowUI) {
00122     mShouldShowUI = aShouldShowUI;
00123     return NS_OK;
00124 }
00125 
00126 NS_IMETHODIMP
00127 nsNativeAppSupportBase::GetShouldShowUI(PRBool *aShouldShowUI) {
00128     NS_ENSURE_ARG( aShouldShowUI );
00129     *aShouldShowUI = mShouldShowUI;
00130     return NS_OK;
00131 }
00132 
00133 NS_IMETHODIMP
00134 nsNativeAppSupportBase::StartServerMode() {
00135     return NS_OK;
00136 }
00137 
00138 NS_IMETHODIMP
00139 nsNativeAppSupportBase::OnLastWindowClosing() {
00140     return NS_OK;
00141 }
00142 
00143 // Default implementation doesn't have a splash screen.
00144 NS_IMETHODIMP
00145 nsNativeAppSupportBase::CreateSplashScreen( nsISplashScreen **splash ) {
00146     NS_ENSURE_ARG( splash );
00147     *splash = 0;
00148     return NS_CreateSplashScreen( splash );
00149 }
00150 
00151 // Standard implementations of AddRef/Release/QueryInterface.
00152 NS_IMETHODIMP_(nsrefcnt)
00153 nsNativeAppSupportBase::AddRef() {
00154     ++mRefCnt;
00155     return mRefCnt;
00156 }
00157 
00158 NS_IMETHODIMP_(nsrefcnt)
00159 nsNativeAppSupportBase::Release() {
00160     --mRefCnt;
00161     if ( !mRefCnt ) {
00162         delete this;
00163         return 0;
00164     }
00165     return mRefCnt;
00166 }
00167 
00168 NS_IMETHODIMP
00169 nsNativeAppSupportBase::QueryInterface( const nsIID &iid, void**p ) {
00170     nsresult rv = NS_OK;
00171     if ( p ) {
00172         *p = 0;
00173         if ( iid.Equals( NS_GET_IID( nsINativeAppSupport ) ) ) {
00174             nsINativeAppSupport *result = this;
00175             *p = result;
00176             NS_ADDREF( result );
00177         } else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
00178             nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
00179             *p = result;
00180             NS_ADDREF( result );
00181         } else {
00182             rv = NS_NOINTERFACE;
00183         }
00184     } else {
00185         rv = NS_ERROR_NULL_POINTER;
00186     }
00187     return rv;
00188 }
00189 
00190 NS_IMETHODIMP
00191 nsNativeAppSupportBase::EnsureProfile(nsICmdLineService* args)
00192 {
00193     return NS_OK;
00194 }