From 7227de80fcbb36710159bc923f5ec3b3f08a4e00 Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Tue, 7 Sep 2004 22:24:45 +0000 Subject: [PATCH] fixes bug 258217 "Windows DDE code should extract application name from nsXREAppData" r=bsmedberg git-svn-id: svn://10.0.0.236/trunk@161883 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/app/splash.rc | 2 -- mozilla/browser/app/splashos2.rc | 13 ------------ mozilla/calendar/sunbird/app/splash.rc | 4 ---- mozilla/calendar/sunbird/app/splashos2.rc | 13 ------------ mozilla/composer/app/module.rc | 4 ---- mozilla/composer/app/splash.rc | 4 ---- mozilla/mail/app/splash.rc | 4 ---- mozilla/mail/app/splashos2.rc | 9 -------- mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp | 19 +++++------------ mozilla/toolkit/xre/nsNativeAppSupportWin.cpp | 21 ++++++------------- 10 files changed, 11 insertions(+), 82 deletions(-) diff --git a/mozilla/browser/app/splash.rc b/mozilla/browser/app/splash.rc index d314a65ed31..a5bb52fe5b2 100644 --- a/mozilla/browser/app/splash.rc +++ b/mozilla/browser/app/splash.rc @@ -48,10 +48,8 @@ IDI_APPLICATION ICON FIREFOX_ICO STRINGTABLE DISCARDABLE BEGIN #ifdef DEBUG - ID_DDE_APPLICATION_NAME, "Firefox Debug" IDS_STARTMENU_APPNAME, "Firefox Debug" #else - ID_DDE_APPLICATION_NAME, "Firefox" IDS_STARTMENU_APPNAME, "Firefox" #endif END diff --git a/mozilla/browser/app/splashos2.rc b/mozilla/browser/app/splashos2.rc index 226165ad441..cd82e3ccc70 100644 --- a/mozilla/browser/app/splashos2.rc +++ b/mozilla/browser/app/splashos2.rc @@ -29,10 +29,6 @@ // Splash screen bitmap ID. #define IDB_SPLASH 101 -// DDE application name -#define ID_DDE_APPLICATION_NAME 102 - - ICON 1 FIREFOX_ICO DLGTEMPLATE IDD_SPLASH DISCARDABLE @@ -44,15 +40,6 @@ END //BITMAP IDB_SPLASH "splash.bmp" -STRINGTABLE DISCARDABLE -BEGIN -#ifdef DEBUG - ID_DDE_APPLICATION_NAME, "Firefox Debug" -#else - ID_DDE_APPLICATION_NAME, "Firefox" -#endif -END - #ifdef MOZ_STATIC_BUILD #include "wdgtos2rc.h" diff --git a/mozilla/calendar/sunbird/app/splash.rc b/mozilla/calendar/sunbird/app/splash.rc index aade6739a41..19e455e4509 100644 --- a/mozilla/calendar/sunbird/app/splash.rc +++ b/mozilla/calendar/sunbird/app/splash.rc @@ -44,15 +44,11 @@ IDI_APPICON ICON "sunbird.ico" IDI_APPLICATION ICON "sunbird.ico" -#define ID_DDE_APPLICATION_NAME 102 - STRINGTABLE DISCARDABLE BEGIN #ifdef DEBUG - ID_DDE_APPLICATION_NAME, "Sunbird Debug" IDS_STARTMENU_APPNAME, "Sunbird Debug" #else - ID_DDE_APPLICATION_NAME, "Sunbird" IDS_STARTMENU_APPNAME, "Sunbird" #endif END diff --git a/mozilla/calendar/sunbird/app/splashos2.rc b/mozilla/calendar/sunbird/app/splashos2.rc index 25d9cfc63f9..6815e4ee0c4 100644 --- a/mozilla/calendar/sunbird/app/splashos2.rc +++ b/mozilla/calendar/sunbird/app/splashos2.rc @@ -29,10 +29,6 @@ // Splash screen bitmap ID. #define IDB_SPLASH 101 -// DDE application name -#define ID_DDE_APPLICATION_NAME 102 - - ICON 1 SUNBIRD_ICO DLGTEMPLATE IDD_SPLASH DISCARDABLE @@ -44,15 +40,6 @@ END //BITMAP IDB_SPLASH "splash.bmp" -STRINGTABLE DISCARDABLE -BEGIN -#ifdef DEBUG - ID_DDE_APPLICATION_NAME, "Sunbird Debug" -#else - ID_DDE_APPLICATION_NAME, "Sunbird" -#endif -END - #ifdef MOZ_STATIC_BUILD #include "wdgtos2rc.h" diff --git a/mozilla/composer/app/module.rc b/mozilla/composer/app/module.rc index bc13b8c3ffc..f81b8735ffa 100644 --- a/mozilla/composer/app/module.rc +++ b/mozilla/composer/app/module.rc @@ -91,9 +91,6 @@ // Splash screen bitmap ID. #define IDB_SPLASH 101 -// DDE application name -#define ID_DDE_APPLICATION_NAME 102 - // Program icon. IDI_APPLICATION ICON "mozilla.ico" @@ -120,7 +117,6 @@ IDD_SPLASH DIALOGEX STRINGTABLE DISCARDABLE BEGIN - ID_DDE_APPLICATION_NAME, "Composer" IDS_STARTMENU_APPNAME, "Composer" END diff --git a/mozilla/composer/app/splash.rc b/mozilla/composer/app/splash.rc index 0c7db09be90..f390ba41c72 100644 --- a/mozilla/composer/app/splash.rc +++ b/mozilla/composer/app/splash.rc @@ -46,9 +46,6 @@ // Splash screen bitmap ID. #define IDB_SPLASH 101 -// DDE application name -#define ID_DDE_APPLICATION_NAME 102 - // Program icon. IDI_APPLICATION ICON "mozilla.ico" @@ -75,6 +72,5 @@ IDD_SPLASH DIALOGEX STRINGTABLE DISCARDABLE BEGIN - ID_DDE_APPLICATION_NAME, "Composer" IDS_STARTMENU_APPNAME, "Composer" END diff --git a/mozilla/mail/app/splash.rc b/mozilla/mail/app/splash.rc index b7563c5f7ca..786e4b1934c 100644 --- a/mozilla/mail/app/splash.rc +++ b/mozilla/mail/app/splash.rc @@ -43,15 +43,11 @@ // Program icon. IDI_APPLICATION ICON THUNDERBIRD_ICO -#define ID_DDE_APPLICATION_NAME 102 - STRINGTABLE DISCARDABLE BEGIN #ifdef DEBUG - ID_DDE_APPLICATION_NAME, "Thunderbird Debug" IDS_STARTMENU_APPNAME, "Thunderbird Debug" #else - ID_DDE_APPLICATION_NAME, "Thunderbird" IDS_STARTMENU_APPNAME, "Thunderbird" #endif END diff --git a/mozilla/mail/app/splashos2.rc b/mozilla/mail/app/splashos2.rc index fac3d71e53e..7a450646dda 100644 --- a/mozilla/mail/app/splashos2.rc +++ b/mozilla/mail/app/splashos2.rc @@ -29,10 +29,6 @@ // Splash screen bitmap ID. #define IDB_SPLASH 101 -// DDE application name -#define ID_DDE_APPLICATION_NAME 102 - - ICON 1 "mozos2.ico" DLGTEMPLATE IDD_SPLASH DISCARDABLE @@ -44,11 +40,6 @@ END //BITMAP IDB_SPLASH "splash.bmp" -STRINGTABLE DISCARDABLE -BEGIN - ID_DDE_APPLICATION_NAME, "Thunderbird" -END - #ifdef MOZ_STATIC_BUILD // XXX This code is copied from resource.h and widget.rc. It's a work-around diff --git a/mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp b/mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp index 1a2b3ed8a05..128fd73c6ca 100644 --- a/mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp +++ b/mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp @@ -45,6 +45,8 @@ #include "nsNativeAppSupportBase.h" #include "nsNativeAppSupportOS2.h" +#include "nsAppRunner.h" +#include "nsXULAppAPI.h" #include "nsString.h" #include "nsICmdLineService.h" #include "nsCOMPtr.h" @@ -342,7 +344,6 @@ private: static HSZ mApplication, mTopics[ topicCount ]; static DWORD mInstance; - static char *mAppName; static PRBool mCanHandleRequests; static char mMutexName[]; static PRBool mUseDDE; @@ -581,7 +582,7 @@ struct MessageWindow { if ( !mClassName ) { sprintf( classNameBuffer, "%s%s", - nsNativeAppSupportOS2::mAppName, + gAppData->appName, "MessageWindow" ); mClassName = classNameBuffer; } @@ -716,8 +717,6 @@ private: USHORT mMsgWindowAtom; }; // struct MessageWindow -static char nameBuffer[128] = { 0 }; -char *nsNativeAppSupportOS2::mAppName = nameBuffer; PRBool nsNativeAppSupportOS2::mUseDDE = PR_FALSE; /* Start: Tries to find the "message window" to determine if it @@ -754,17 +753,9 @@ nsNativeAppSupportOS2::Start( PRBool *aResult ) { } // Grab mutex first. - int retval; - UINT id = ID_DDE_APPLICATION_NAME; - retval = WinLoadString( NULLHANDLE, NULLHANDLE, id, sizeof(nameBuffer), nameBuffer ); - if ( retval == 0 ) { - // No app name; just keep running. - *aResult = PR_TRUE; - return NS_OK; - } // Build mutex name from app name. - PR_snprintf( mMutexName, sizeof mMutexName, "%s%s", nameBuffer, MOZ_STARTUP_MUTEX_NAME ); + PR_snprintf( mMutexName, sizeof mMutexName, "%s%s", gAppData->appName, MOZ_STARTUP_MUTEX_NAME ); Mutex startupLock = Mutex( mMutexName ); NS_ENSURE_TRUE( startupLock.Lock( MOZ_DDE_START_TIMEOUT ), NS_ERROR_FAILURE ); @@ -875,7 +866,7 @@ nsNativeAppSupportOS2::StartDDE() { NS_ERROR_FAILURE ); // Allocate DDE strings. - NS_ENSURE_TRUE( ( mApplication = WinDdeCreateStringHandle( mAppName, CP_WINANSI ) ) && InitTopicStrings(), + NS_ENSURE_TRUE( ( mApplication = WinDdeCreateStringHandle( gAppData->appName, CP_WINANSI ) ) && InitTopicStrings(), NS_ERROR_FAILURE ); // Next step is to register a DDE service. diff --git a/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp b/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp index 0b8baef9610..4a95d1eb3ef 100644 --- a/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp +++ b/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp @@ -38,6 +38,8 @@ #include "nsNativeAppSupportBase.h" #include "nsNativeAppSupportWin.h" +#include "nsAppRunner.h" +#include "nsXULAppAPI.h" #include "nsString.h" #include "nsICmdLineService.h" #include "nsCOMPtr.h" @@ -318,7 +320,6 @@ private: static HSZ mApplication, mTopics[ topicCount ]; static DWORD mInstance; - static char *mAppName; static PRBool mCanHandleRequests; static PRBool mSupportingDDEExec; static char mMutexName[]; @@ -447,7 +448,7 @@ struct MessageWindow { ::_snprintf( classNameBuffer, sizeof classNameBuffer, "%s%s", - nsNativeAppSupportWin::mAppName, + gAppData->appName, "MessageWindow" ); mClassName = classNameBuffer; } @@ -566,9 +567,6 @@ private: HWND mHandle; }; // struct MessageWindow -static char nameBuffer[128] = { 0 }; -char *nsNativeAppSupportWin::mAppName = nameBuffer; - /* Start: Tries to find the "message window" to determine if it * exists. If so, then Mozilla is already running. In that * case, we use the handle to the "message" window and send @@ -585,6 +583,7 @@ NS_IMETHODIMP nsNativeAppSupportWin::Start( PRBool *aResult ) { NS_ENSURE_ARG( aResult ); NS_ENSURE_TRUE( mInstance == 0, NS_ERROR_NOT_INITIALIZED ); + NS_ENSURE_STATE( gAppData ); if (getenv("MOZ_NO_REMOTE")) { @@ -596,17 +595,9 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) { *aResult = PR_FALSE; // Grab mutex first. - int retval; - UINT id = ID_DDE_APPLICATION_NAME; - retval = LoadString( (HINSTANCE) NULL, id, (LPTSTR) nameBuffer, sizeof(nameBuffer) ); - if ( retval == 0 ) { - // No app name; just keep running. - *aResult = PR_TRUE; - return NS_OK; - } // Build mutex name from app name. - ::_snprintf( mMutexName, sizeof mMutexName, "%s%s", nameBuffer, MOZ_STARTUP_MUTEX_NAME ); + ::_snprintf( mMutexName, sizeof mMutexName, "%s%s", gAppData->appName, MOZ_STARTUP_MUTEX_NAME ); Mutex startupLock = Mutex( mMutexName ); NS_ENSURE_TRUE( startupLock.Lock( MOZ_DDE_START_TIMEOUT ), NS_ERROR_FAILURE ); @@ -733,7 +724,7 @@ nsNativeAppSupportWin::StartDDE() { NS_ERROR_FAILURE ); // Allocate DDE strings. - NS_ENSURE_TRUE( ( mApplication = DdeCreateStringHandle( mInstance, mAppName, CP_WINANSI ) ) && InitTopicStrings(), + NS_ENSURE_TRUE( ( mApplication = DdeCreateStringHandle( mInstance, gAppData->appName, CP_WINANSI ) ) && InitTopicStrings(), NS_ERROR_FAILURE ); // Next step is to register a DDE service.