Bug 455823 - No icon displayed for HTML and EML files and links to websites under Windows, r=Neil, a2.0a1=KaiRo
authorFrank Wein <mcsmurf@mcsmurf.de>
Tue, 23 Sep 2008 20:48:02 +0200
changeset 404 580ea3dd210c42a5c90377ef669780a667cadc8a
parent 403 9fdc552b6f7bab56f9f246374b64697568887ba0
child 405 e842bdf573c3ae1e87a02ae0916d9c3a4c80b8a3
push idunknown
push userunknown
push dateunknown
reviewersNeil
bugs455823
Bug 455823 - No icon displayed for HTML and EML files and links to websites under Windows, r=Neil, a2.0a1=KaiRo
suite/installer/windows/nsis/shared.nsh
suite/shell/src/nsWindowsShellService.cpp
suite/shell/src/nsWindowsShellService.h
--- a/suite/installer/windows/nsis/shared.nsh
+++ b/suite/installer/windows/nsis/shared.nsh
@@ -148,17 +148,17 @@
   WriteRegStr SHCTX "$0\.htm"   "" "SeaMonkeyHTML"
   WriteRegStr SHCTX "$0\.html"  "" "SeaMonkeyHTML"
   WriteRegStr SHCTX "$0\.shtml" "" "SeaMonkeyHTML"
   WriteRegStr SHCTX "$0\.xht"   "" "SeaMonkeyHTML"
   WriteRegStr SHCTX "$0\.xhtml" "" "SeaMonkeyHTML"
 
   ; An empty string is used for the 5th param because SeaMonkeyHTML is not a
   ; protocol handler
-  ${AddHandlerValues} "$0\SeaMonkeyHTML" "$2" "$8,1" "${AppRegName} Document" "" "true"
+  ${AddHandlerValues} "$0\SeaMonkeyHTML" "$2" "$INSTDIR\chrome\icons\default\html-file.ico" "${AppRegName} Document" "" "true"
 
   ${AddHandlerValues} "$0\SeaMonkeyURL" "$2" "$8,0" "${AppRegName} URL" "true" "true"
   ${AddHandlerValues} "$0\gopher" "$2" "$8,0" "URL:Gopher Protocol" "true" "true"
 
   ; An empty string is used for the 4th & 5th params because the following
   ; protocol handlers already have a display name and additional keys required
   ; for a protocol handler.
   ${AddHandlerValues} "$0\ftp" "$2" "$8,0" "" "" "true"
@@ -166,17 +166,17 @@
   ${AddHandlerValues} "$0\https" "$2" "$8,0" "" "" "true"
 
   ; MAIL/NEWS part
   ; Associate the .eml file handler with SeaMonkeyEML
   WriteRegStr SHCTX "$0\.eml"   "" "SeaMonkeyEML"
 
   ; An empty string is used for the 5th param because SeaMonkeyEML is not a
   ; protocol handler
-  ${AddHandlerValues} "$0\SeaMonkeyEML"  "$2" "$8,1" "${AppRegNameMail} Document" "" ""
+  ${AddHandlerValues} "$0\SeaMonkeyEML"  "$2" "$INSTDIR\chrome\icons\default\misc-file.ico" "${AppRegNameMail} Document" "" ""
 
   ${AddHandlerValues} "$0\SeaMonkeyCOMPOSE"  "$3" "$8,0" "${AppRegNameMail} URL" "true" ""
   ${AddHandlerValues} "$0\SeaMonkeyNEWS" "$2" "$8,0" "${AppRegNameNews} URL" "true" ""
 
   ; An empty string is used for the 4th & 5th params because the following
   ; protocol handlers already have a display name and additional keys required
   ; for a protocol handler.
   ${AddHandlerValues} "$0\mailto" "$3" "$8,0" "${AppRegNameMail} URL" "true" ""
--- a/suite/shell/src/nsWindowsShellService.cpp
+++ b/suite/shell/src/nsWindowsShellService.cpp
@@ -138,17 +138,17 @@ OpenKeyForWriting(HKEY aStartKey, LPCWST
 //    .htm .html .shtml .xht .xhtml
 //   are mapped like so:
 //
 //   HKCU\SOFTWARE\Classes\.<ext>\      (default)         REG_SZ   SeaMonkeyHTML
 //
 //   as aliases to the class:
 //
 //   HKCU\SOFTWARE\Classes\SeaMonkeyHTML\
-//     DefaultIcon                      (default)         REG_SZ     <apppath>,1
+//     DefaultIcon                      (default)         REG_SZ     <appfolder>\chrome\icons\default\html-file.ico
 //     shell\open\command               (default)         REG_SZ     <apppath> -requestPending -osint -url "%1"
 //     shell\open\ddeexec               (default)         REG_SZ     "%1",,0,0,,,,
 //     shell\open\ddeexec               NoActivateHandler REG_SZ
 //                       \Application   (default)         REG_SZ     SeaMonkey
 //                       \Topic         (default)         REG_SZ     WWW_OpenURL
 //
 // - Windows Vista Protocol Handler
 //
@@ -164,17 +164,17 @@ OpenKeyForWriting(HKEY aStartKey, LPCWST
 //
 // - Protocol Mappings
 //   -----------------
 //   The following protocols:
 //    HTTP, HTTPS, FTP
 //   are mapped like so:
 //
 //   HKCU\SOFTWARE\Classes\<protocol>\
-//     DefaultIcon                      (default)         REG_SZ     <apppath>,1
+//     DefaultIcon                      (default)         REG_SZ     <apppath>,0
 //     shell\open\command               (default)         REG_SZ     <apppath> -requestPending -url "%1"
 //     shell\open\ddeexec               (default)         REG_SZ     "%1",,0,0,,,,
 //     shell\open\ddeexec               NoActivateHandler REG_SZ
 //                       \Application   (default)         REG_SZ     SeaMonkey
 //                       \Topic         (default)         REG_SZ     WWW_OpenURL
 //
 // - Windows Start Menu (Win2K SP2, XP SP1, and newer)
 //   -------------------------------------------------
@@ -204,17 +204,17 @@ OpenKeyForWriting(HKEY aStartKey, LPCWST
 //    .eml
 //   is mapped like this:
 //
 //   HKCU\SOFTWARE\Classes\.eml         (default)         REG_SZ    SeaMonkeyEML
 //
 //   That aliases to this class:
 //   HKCU\SOFTWARE\Classes\SeaMonkeyEML\ (default)        REG_SZ    SeaMonkey (Mail) Document
 //                                      FriendlyTypeName  REG_SZ    SeaMonkey (Mail) Document
-//     DefaultIcon                      (default)         REG_SZ    <apppath>,0
+//     DefaultIcon                      (default)         REG_SZ    <appfolder>\chrome\icons\default\misc-file.ico
 //     shell\open\command               (default)         REG_SZ    <apppath> "%1"
 //
 // - Windows Vista Protocol Handler
 //
 //   HKCU\SOFTWARE\Classes\SeaMonkeyCOMPOSE (default)     REG_SZ    SeaMonkey (Mail) URL
 //                                       DefaultIcon      REG_SZ    <apppath>,0
 //                                       EditFlags        REG_DWORD 2
 //     shell\open\command                (default)        REG_SZ    <apppath> -osint -compose "%1"
@@ -273,25 +273,26 @@ OpenKeyForWriting(HKEY aStartKey, LPCWST
 //    DefaultIcon                    (default)           REG_SZ     <apppath>,0
 //    shell\open\command             (default)           REG_SZ     <apppath> -news
 //
 ///////////////////////////////////////////////////////////////////////////////
 
 
 
 typedef enum {
-  NO_SUBSTITUTION           = 0x00,
-  APP_PATH_SUBSTITUTION     = 0x01,
-  EXE_NAME_SUBSTITUTION     = 0x02,
-  UNINST_PATH_SUBSTITUTION  = 0x04,
-  MAPIDLL_PATH_SUBSTITUTION = 0x08,
-  HKLM_ONLY                 = 0x10,
-  USE_FOR_DEFAULT_TEST      = 0x20,
-  NON_ESSENTIAL             = 0x40,
-  APP_NAME_SUBSTITUTION     = 0x80
+  NO_SUBSTITUTION           = 0x000,
+  APP_PATH_SUBSTITUTION     = 0x001,
+  EXE_NAME_SUBSTITUTION     = 0x002,
+  UNINST_PATH_SUBSTITUTION  = 0x004,
+  MAPIDLL_PATH_SUBSTITUTION = 0x008,
+  HKLM_ONLY                 = 0x010,
+  USE_FOR_DEFAULT_TEST      = 0x020,
+  NON_ESSENTIAL             = 0x040,
+  APP_NAME_SUBSTITUTION     = 0x080,
+  APP_FOLDER_SUBSTITUTION   = 0x100
 } SettingFlags;
 
 #define APP_REG_NAME L"SeaMonkey"
 // APP_REG_NAME_MAIL and APP_REG_NAME_NEWS should be kept in synch with
 // AppRegNameMail and AppRegNameNews in the installer file: defines.nsi.in
 #define APP_REG_NAME_MAIL L"SeaMonkey (Mail)"
 #define APP_REG_NAME_NEWS L"SeaMonkey (News)"
 #define CLS "SOFTWARE\\Classes\\"
@@ -311,17 +312,18 @@ typedef enum {
 #define DDE "\\shell\\open\\ddeexec\\"
 #define DDE_NAME "SeaMonkey" // Keep in sync with app name from nsXREAppData
 #define DDE_COMMAND "\"%1\",,0,0,,,,"
 // For the InstallInfo HideIconsCommand, ShowIconsCommand, and ReinstallCommand
 // registry keys. This must be kept in sync with the uninstaller.
 #define UNINSTALL_EXE "\\uninstall\\helper.exe"
 
 #define VAL_ICON "%APPPATH%,0"
-#define VAL_FILE_ICON "%APPPATH%,1"
+#define VAL_HTML_ICON "%APPFOLDER%\\chrome\\icons\\default\\html-file.ico"
+#define VAL_MISC_ICON "%APPFOLDER%\\chrome\\icons\\default\\misc-file.ico"
 #define VAL_URL_OPEN "\"%APPPATH%\" -requestPending -osint -url \"%1\""
 #define VAL_MAIL_OPEN "\"%APPPATH%\" \"%1\""
 
 #define MAKE_KEY_NAME1(PREFIX, MID) \
   PREFIX MID
 
 #define MAKE_KEY_NAME2(PREFIX, MID, SUFFIX) \
   PREFIX MID SUFFIX
@@ -340,31 +342,31 @@ static SETTING gBrowserSettings[] = {
   { MAKE_KEY_NAME1(CLS, ".html"),   "", CLS_HTML, NO_SUBSTITUTION },
   { MAKE_KEY_NAME1(CLS, ".shtml"),  "", CLS_HTML, NO_SUBSTITUTION },
   { MAKE_KEY_NAME1(CLS, ".xht"),    "", CLS_HTML, NO_SUBSTITUTION },
   { MAKE_KEY_NAME1(CLS, ".xhtml"),  "", CLS_HTML, NO_SUBSTITUTION },
 
   // File Extension Class - as of 1.8.1.2 the value for VAL_URL_OPEN is also
   // checked for CLS_HTML since SeaMonkey should also own opening local files
   // when set as the default browser.
-  { MAKE_KEY_NAME2(CLS, CLS_HTML, DI),  "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION },
+  { MAKE_KEY_NAME2(CLS, CLS_HTML, DI),  "", VAL_HTML_ICON, APP_FOLDER_SUBSTITUTION },
   { MAKE_KEY_NAME2(CLS, CLS_HTML, SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST },
 
   // Protocol Handler Class - for Vista and above
-  { MAKE_KEY_NAME2(CLS, CLS_URL, DI),  "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION },
+  { MAKE_KEY_NAME2(CLS, CLS_URL, DI),  "", VAL_ICON, APP_PATH_SUBSTITUTION },
   { MAKE_KEY_NAME2(CLS, CLS_URL, SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST },
 
   // Protocol Handlers
-  { MAKE_KEY_NAME2(CLS, "HTTP", DI),    "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST },
+  { MAKE_KEY_NAME2(CLS, "HTTP", DI),    "", VAL_ICON, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST },
   { MAKE_KEY_NAME2(CLS, "HTTP", SOP),   "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST },
-  { MAKE_KEY_NAME2(CLS, "HTTPS", DI),   "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST },
+  { MAKE_KEY_NAME2(CLS, "HTTPS", DI),   "", VAL_ICON, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST },
   { MAKE_KEY_NAME2(CLS, "HTTPS", SOP),  "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST },
-  { MAKE_KEY_NAME2(CLS, "FTP", DI),     "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION },
+  { MAKE_KEY_NAME2(CLS, "FTP", DI),     "", VAL_ICON, APP_PATH_SUBSTITUTION },
   { MAKE_KEY_NAME2(CLS, "FTP", SOP),    "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION },
-  { MAKE_KEY_NAME2(CLS, "GOPHER", DI),  "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION },
+  { MAKE_KEY_NAME2(CLS, "GOPHER", DI),  "", VAL_ICON, APP_PATH_SUBSTITUTION },
   { MAKE_KEY_NAME2(CLS, "GOPHER", SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION },
 
   // DDE settings
   { MAKE_KEY_NAME2(CLS, CLS_HTML, DDE), "", DDE_COMMAND, NO_SUBSTITUTION },
   { MAKE_KEY_NAME3(CLS, CLS_HTML, DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION },
   { MAKE_KEY_NAME3(CLS, CLS_HTML, DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION },
   { MAKE_KEY_NAME2(CLS, CLS_URL, DDE), "", DDE_COMMAND, NO_SUBSTITUTION },
   { MAKE_KEY_NAME3(CLS, CLS_URL, DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION },
@@ -417,17 +419,17 @@ static SETTING gBrowserSettings[] = {
   //   seamonkey.exe\shell\safemode     (default)   REG_SZ  SeaMonkey &Safe Mode
 };
 
 
  static SETTING gMailSettings[] = {
    // File Extension Aliases
    { MAKE_KEY_NAME1(CLS, ".eml"),    "", CLS_EML, NO_SUBSTITUTION },
    // File Extension Class
-   { MAKE_KEY_NAME2(CLS, CLS_EML, DI),  "",  VAL_ICON, APP_PATH_SUBSTITUTION },
+   { MAKE_KEY_NAME2(CLS, CLS_EML, DI),  "",  VAL_MISC_ICON, APP_FOLDER_SUBSTITUTION },
    { MAKE_KEY_NAME2(CLS, CLS_EML, SOP), "",  VAL_MAIL_OPEN, APP_PATH_SUBSTITUTION},
 
    // Protocol Handler Class - for Vista and above
    { MAKE_KEY_NAME2(CLS, CLS_MAILTOURL, DI),  "", VAL_ICON, APP_PATH_SUBSTITUTION },
    { MAKE_KEY_NAME2(CLS, CLS_MAILTOURL, SOP), "", "\"%APPPATH%\" -osint -compose \"%1\"", APP_PATH_SUBSTITUTION },
 
    // Protocol Handlers
    { MAKE_KEY_NAME2(CLS, "mailto", DI),  "", VAL_ICON, APP_PATH_SUBSTITUTION},
@@ -587,17 +589,19 @@ nsresult nsWindowsShellService::Init()
   rv = NS_NewLocalFile(mAppLongPath, PR_TRUE,
                        getter_AddRefs(lf));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIFile> appDir;
   rv = lf->GetParent(getter_AddRefs(appDir));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  appDir->GetPath(mUninstallPath);
+  appDir->GetPath(mAppFolder);
+
+  mUninstallPath = mAppFolder;
   mUninstallPath.AppendLiteral(UNINSTALL_EXE);
 
   // Support short path to the exe so if it is already set the user is not
   // prompted to set the default mail client again.
   if (!::GetShortPathNameW(appPath, appPath, MAX_BUF))
     return NS_ERROR_FAILURE;
 
   ToUpperCase(mAppShortPath = appPath);
@@ -952,16 +956,20 @@ nsWindowsShellService::setDefaultBrowser
   nsAutoString uninstLongPath;
   appDir->GetPath(uninstLongPath);
   uninstLongPath.AppendLiteral(UNINSTALL_EXE);
 
   for (settings = gBrowserSettings; settings < end; ++settings) {
     NS_ConvertUTF8toUTF16 dataLongPath(settings->valueData);
     NS_ConvertUTF8toUTF16 key(settings->keyName);
     NS_ConvertUTF8toUTF16 value(settings->valueName);
+    if (settings->flags & APP_FOLDER_SUBSTITUTION) {
+      PRInt32 offset = dataLongPath.Find("%APPFOLDER%");
+      dataLongPath.Replace(offset, 11, mAppFolder);
+    }
     if (settings->flags & APP_PATH_SUBSTITUTION) {
       PRInt32 offset = dataLongPath.Find("%APPPATH%");
       dataLongPath.Replace(offset, 9, mAppLongPath);
     }
     if (settings->flags & UNINST_PATH_SUBSTITUTION) {
       PRInt32 offset = dataLongPath.Find("%UNINSTPATH%");
       dataLongPath.Replace(offset, 12, uninstLongPath);
     }
@@ -1338,16 +1346,21 @@ nsWindowsShellService::setKeysForSetting
   SETTING* end = aSettings + aSize;
   PRInt32 offset;
 
   for (settings = aSettings; settings < end; ++settings)
   {
     NS_ConvertUTF8toUTF16 data(settings->valueData);
     NS_ConvertUTF8toUTF16 key(settings->keyName);
     NS_ConvertUTF8toUTF16 value(settings->valueName);
+    if (settings->flags & APP_FOLDER_SUBSTITUTION)
+    {
+      offset = data.Find("%APPFOLDER%");
+      data.Replace(offset, 11, mAppFolder);
+    }
     if (settings->flags & APP_PATH_SUBSTITUTION)
     {
       offset = data.Find("%APPPATH%");
       data.Replace(offset, 9, mAppLongPath);
     }
     if (settings->flags & MAPIDLL_PATH_SUBSTITUTION)
     {
       offset = data.Find("%MAPIDLLPATH%");
--- a/suite/shell/src/nsWindowsShellService.h
+++ b/suite/shell/src/nsWindowsShellService.h
@@ -79,16 +79,17 @@ protected:
   nsresult setDefaultBrowser();
 #ifdef MOZ_MAIL_NEWS
   nsresult setDefaultMail();
   nsresult setDefaultNews();
 #endif
 
 private:
   PRBool mCheckedThisSessionClient;
+  nsString mAppFolder;
   nsString mAppLongPath;
   nsString mAppShortPath;
   nsString mMapiDLLPath;
   nsString mUninstallPath;
   nsString mBrandFullName;
   nsString mBrandShortName;
 };