From 4b1e2fcb2b04c2aed2d897225b411ed5fff161fb Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Tue, 17 Oct 2006 18:05:43 +0000 Subject: [PATCH] Bug #353906 --> modernize mail's registry code to implement toolkit's shell service. When setting the mapi dll path key, be sure to strip off the process name from the app path. sr=bienvenu git-svn-id: svn://10.0.0.236/trunk@213755 18797224-902f-48f8-a5cc-f745e15eee43 --- .../components/shell/nsMailWinIntegration.cpp | 24 ++++++++++++++----- .../components/shell/nsMailWinIntegration.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/mozilla/mail/components/shell/nsMailWinIntegration.cpp b/mozilla/mail/components/shell/nsMailWinIntegration.cpp index 56ee27874f2..1e86ef9ad49 100644 --- a/mozilla/mail/components/shell/nsMailWinIntegration.cpp +++ b/mozilla/mail/components/shell/nsMailWinIntegration.cpp @@ -110,7 +110,8 @@ OpenKeyForWriting(const char* aKeyName, HKEY* aKey, PRBool aForAllUsers, PRBool typedef enum { NO_SUBSTITUTION = 0x00, PATH_SUBSTITUTION = 0x01, APPNAME_SUBSTITUTION = 0x02, - USE_FOR_DEFAULT_TEST = 0x04} SettingFlags; + MAPIDLLPATH_SUBSTITUTION = 0x04, + USE_FOR_DEFAULT_TEST = 0x08} SettingFlags; #define CLS "SOFTWARE\\Classes\\" #define MAILCLIENTS "SOFTWARE\\Clients\\Mail\\" @@ -124,7 +125,6 @@ typedef enum { NO_SUBSTITUTION = 0x00, #define VAL_FILE_ICON "%APPPATH%,1" #define VAL_OPEN "%APPPATH% \"%1\"" #define VAL_OPEN_WITH_URL "%APPPATH% -url \"%1\"" -#define VAL_DLLPATH "%APPPATH%\\mozMapi32.dll" #define MAKE_KEY_NAME1(PREFIX, MID) \ PREFIX MID @@ -146,8 +146,8 @@ static SETTING gMailSettings[] = { // Windows XP Start Menu { MAKE_KEY_NAME1(MAILCLIENTS, "%APPNAME%"), "DLLPath", - VAL_DLLPATH, - PATH_SUBSTITUTION | APPNAME_SUBSTITUTION }, + "%MAPIDLLPATH%", + MAPIDLLPATH_SUBSTITUTION | APPNAME_SUBSTITUTION }, { MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", DI), "", "%APPPATH%,0", @@ -181,8 +181,8 @@ static SETTING gNewsSettings[] = { // Client Keys { MAKE_KEY_NAME1(NEWSCLIENTS, "%APPNAME%"), "DLLPath", - VAL_DLLPATH, - PATH_SUBSTITUTION | APPNAME_SUBSTITUTION }, + "%MAPIDLLPATH%", + MAPIDLLPATH_SUBSTITUTION | APPNAME_SUBSTITUTION }, { MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", DI), "", "%APPPATH%,0", @@ -215,6 +215,14 @@ nsWindowsShellService::nsWindowsShellService() ::GetShortPathName(buf, buf, sizeof(buf)); ToUpperCase(mAppPath = buf); + mMapiDLLPath = mAppPath; + // remove the process name from the string (thunderbird.exe) + char* pathSep = (char *) _mbsrchr((const unsigned char *) mAppPath.get(), '\\'); + if (pathSep) + mMapiDLLPath.Truncate(pathSep - mAppPath.get() + 1); + // now append mozMapi32.dll + mMapiDLLPath += "mozMapi32.dll"; + nsCOMPtr bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv)); if (NS_SUCCEEDED(rv)) { @@ -454,6 +462,10 @@ nsWindowsShellService::setKeysForSettings(SETTING aSettings[], PRInt32 aSize, co PRInt32 offset = data.Find("%APPPATH%"); data.Replace(offset, 9, mAppPath); } + if (settings->flags & MAPIDLLPATH_SUBSTITUTION) { + PRInt32 offset = data.Find("%MAPIDLLPATH%"); + data.Replace(offset, 13, mMapiDLLPath); + } if (settings->flags & APPNAME_SUBSTITUTION) { PRInt32 offset = key.Find("%APPNAME%"); key.Replace(offset, 9, aAppName); diff --git a/mozilla/mail/components/shell/nsMailWinIntegration.h b/mozilla/mail/components/shell/nsMailWinIntegration.h index 417f960eeb7..d8042bb265b 100644 --- a/mozilla/mail/components/shell/nsMailWinIntegration.h +++ b/mozilla/mail/components/shell/nsMailWinIntegration.h @@ -78,6 +78,7 @@ protected: private: PRBool mCheckedThisSession; nsCString mAppPath; + nsCString mMapiDLLPath; nsXPIDLString mBrandFullName; nsXPIDLString mBrandShortName; };