From 7992cb8d3c210e2025651af1422c3f06b92449b8 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Wed, 17 May 2000 01:55:46 +0000 Subject: [PATCH] Fix for 35866 -- have the splash screen show progress message (for now, just during autoreg). --- xpfe/bootstrap/Splash.rsrc | Bin 57619 -> 57629 bytes xpfe/bootstrap/nsAppRunner.cpp | 24 ++++ xpfe/bootstrap/nsNativeAppSupportMac.cpp | 150 +++++++++++++---------- 3 files changed, 112 insertions(+), 62 deletions(-) diff --git a/xpfe/bootstrap/Splash.rsrc b/xpfe/bootstrap/Splash.rsrc index 6e398cced23418f75c2f61ded68093752cadc9c6..7ae4c6eb092560b7c8a4e3236ffc18ce20d73db0 100644 GIT binary patch delta 498 zcmbPyhi#1JhI>HFaCf8M#Cww;-IrxFn)E;? ziNPnbb7qeHQzHWg7N9IhDZ`c{32{K20AeEp&cwX@yvp4C(qaZ?Lp>t~?%;x)#NrIS zqT-@txHVYC)(7?b0 z47PbtwhEB_62xW#`VSbUmPqVeB=&qH_HGcHyBHE$LBT=J;=YN=&SAj{VW~yMnfZAN pL8-<0rA5i9d;vxIS*gh-`9%sY%89@r0fuZ)u&WC=T0n-N0RZwHd{zJe delta 459 zcmY+Aze_?<6vvOg8p03?A?OEP2x&+~johk1$qXw|c}vstde!HT_vGGNwCNHAE!Km! zf@o?C>K|}xZEDCLOIus5Vn%fequ++U zI_yrP>DxJb)qpxI;I{8jdmLi4gk&lib|$!4WK`m$5lw1y`x*_aDWWnibkiV7Cd^|_ Inbqr(AK%G=*8l(j diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 7f48f9682fb8..0f8ed313ca96 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -35,6 +35,7 @@ #include "nsIThread.h" #include "nsIAppShellService.h" #include "nsIAppShellComponent.h" +#include "nsIObserverService.h" #include "nsAppShellCIDs.h" #include "prprf.h" #include "nsCRT.h" @@ -744,6 +745,18 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) fpsetmask(0); #endif + // Setup an autoreg obserer, so that we can update a progress + // string in the splash screen + nsCOMPtr obsService = do_GetService(NS_OBSERVERSERVICE_PROGID); + if (obsService) + { + nsCOMPtr splashScreenObserver = do_QueryInterface(nativeApp); + if (splashScreenObserver) + { + obsService->AddObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).GetUnicode()); + } + } + //---------------------------------------------------------------- // XPInstall needs to clean up after any updates that couldn't // be completed because components were in use. This must be done @@ -775,6 +788,16 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) // XXX: This call will be replaced by a registry initialization... NS_SetupRegistry_1( needAutoreg ); + // remove the nativeApp as an XPCOM autoreg observer + if (obsService) + { + nsCOMPtr splashScreenObserver = do_QueryInterface(nativeApp); + if (splashScreenObserver) + { + obsService->RemoveObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).GetUnicode()); + } + } + // Start up the core services: // Initialize the cmd line service @@ -811,6 +834,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) splashScreen->Hide(); } } + // Release argument object. NS_IF_RELEASE( nativeApp ); return rv; diff --git a/xpfe/bootstrap/nsNativeAppSupportMac.cpp b/xpfe/bootstrap/nsNativeAppSupportMac.cpp index 938717c35db2..f6fef70aea5e 100644 --- a/xpfe/bootstrap/nsNativeAppSupportMac.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportMac.cpp @@ -20,89 +20,115 @@ * Contributor(s): */ #include "nsNativeAppSupport.h" - +#include "nsString.h" + #include #include #include - - + +#include "nsIObserver.h" + #define rSplashDialog 512 -class nsSplashScreenMac : public nsISplashScreen { +class nsSplashScreenMac : public nsISplashScreen, + public nsIObserver +{ public: - nsSplashScreenMac() - : mDialog( 0 ), mPicHandle( 0 ), mRefCnt( 0 ) { - } - ~nsSplashScreenMac() { - Hide(); - } + + // dialog itemse + enum { + eSplashPictureItem = 1, + eSplashStatusTextItem + }; + + nsSplashScreenMac(); + virtual ~nsSplashScreenMac(); + + NS_DECL_ISUPPORTS NS_IMETHOD Show(); NS_IMETHOD Hide(); - // nsISupports methods - NS_IMETHOD_(nsrefcnt) AddRef() { - mRefCnt++; - return mRefCnt; - } - NS_IMETHOD_(nsrefcnt) Release() { - --mRefCnt; - if ( !mRefCnt ) { - delete this; - return 0; - } - return mRefCnt; - } - NS_IMETHOD QueryInterface( const nsIID &iid, void**p ) { - nsresult rv = NS_OK; - if ( p ) { - *p = 0; - if ( iid.Equals( NS_GET_IID( nsISplashScreen ) ) ) { - nsISplashScreen *result = this; - *p = result; - NS_ADDREF( result ); - } else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) { - nsISupports *result = NS_STATIC_CAST( nsISupports*, this ); - *p = result; - NS_ADDREF( result ); - } else { - rv = NS_NOINTERFACE; - } - } else { - rv = NS_ERROR_NULL_POINTER; - } - return rv; - } + NS_DECL_NSIOBSERVER + +protected: DialogPtr mDialog; - PicHandle mPicHandle; - nsrefcnt mRefCnt; + }; // class nsSplashScreenMac + +nsSplashScreenMac::nsSplashScreenMac() +: mDialog(nsnull) +{ + NS_INIT_REFCNT(); +} + + +nsSplashScreenMac::~nsSplashScreenMac() +{ + Hide(); +} + + +NS_IMPL_ISUPPORTS2(nsSplashScreenMac, nsISplashScreen, nsIObserver); + NS_IMETHODIMP -nsSplashScreenMac::Show() { - mDialog = ::GetNewDialog( rSplashDialog, nil, (WindowPtr)-1L ); - mPicHandle = GetPicture( rSplashDialog ); - SetWindowPic( mDialog, mPicHandle ); - ::ShowWindow( mDialog ); - ::SetPort( mDialog ); - Rect rect = (**mPicHandle).picFrame; - ::DrawPicture( mPicHandle, &rect ); - return NS_OK; +nsSplashScreenMac::Show() +{ + mDialog = ::GetNewDialog(rSplashDialog, nil, (WindowPtr)-1L); + if (!mDialog) return NS_ERROR_FAILURE; + + ::ShowWindow(mDialog); + ::SetPort(mDialog); + + ::DrawDialog(mDialog); // we don't handle events for this dialog, so we + // need to draw explicitly. Yuck. + return NS_OK; } NS_IMETHODIMP -nsSplashScreenMac::Hide() { - if ( mDialog ) { - ReleaseResource( (Handle)mPicHandle ); - mPicHandle = 0; - SetWindowPic( mDialog, NULL ); - DisposeWindow( mDialog ); - mDialog = 0; +nsSplashScreenMac::Hide() +{ + if (mDialog) + { + ::DisposeDialog( mDialog ); + mDialog = nsnull; } - return NS_OK; + return NS_OK; } + +NS_IMETHODIMP +nsSplashScreenMac::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +{ + // update a string in the dialog + + nsCAutoString statusString; + statusString.AssignWithConversion(someData); + + Handle item = nsnull; + Rect itemRect; + short itemType; + ::GetDialogItem(mDialog, eSplashStatusTextItem, &itemType, &item, &itemRect); + if (!item) return NS_OK; + + // convert string to Pascal string + Str255 statusPStr; + PRInt32 maxLen = statusString.Length(); + if (maxLen > 254) + maxLen = 254; + strncpy((char *)&statusPStr[1], (const char *)statusString, maxLen); + statusPStr[0] = maxLen; + + ::SetDialogItemText(item, statusPStr); + ::DrawDialog(mDialog); + return NS_OK; +} + + +#pragma mark - + nsresult NS_CreateSplashScreen(nsISplashScreen**aResult) { if ( aResult ) {