Bug 441050 - Kill winhooks UI, create something better, r=Neil
authorFrank Wein <mcsmurf@mcsmurf.de>
Wed, 03 Sep 2008 23:57:29 +0200
changeset 254 26e570823110f86fabe302a10a2e48df292b9ac3
parent 253 e8fdf415c5710e10b4c0c11aab206f06a6c707da
child 255 bd65ac0df8c2379e5bf38c6091b5f1afe72edf66
push idunknown
push userunknown
push dateunknown
reviewersNeil
bugs441050
Bug 441050 - Kill winhooks UI, create something better, r=Neil
mailnews/base/prefs/resources/content/accountUtils.js
mailnews/base/prefs/resources/content/pref-mailnews.js
mailnews/base/prefs/resources/content/pref-mailnews.xul
mailnews/mapi/mapihook/src/Makefile.in
mailnews/mapi/mapihook/src/msgMapiSupport.cpp
mailnews/mapi/mapihook/src/nsMapiRegistry.cpp
mailnews/mapi/mapihook/src/nsMapiRegistry.h
mailnews/mapi/mapihook/src/nsMapiRegistryUtils.cpp
mailnews/mapi/mapihook/src/nsMapiRegistryUtils.h
suite/browser/navigator.js
suite/common/defaultClientDialog.js
suite/common/defaultClientDialog.xul
suite/common/jar.mn
suite/common/pref/pref-advanced.xul
suite/common/pref/pref-navigator.js
suite/locales/en-US/chrome/common/defaultClientDialog.dtd
suite/locales/en-US/chrome/common/pref/pref-advanced.dtd
suite/locales/jar.mn
--- a/mailnews/base/prefs/resources/content/accountUtils.js
+++ b/mailnews/base/prefs/resources/content/accountUtils.js
@@ -71,58 +71,35 @@ function getInvalidAccounts(accounts)
             else {
               invalidAccounts[invalidAccounts.length] = account;
             }
         }
     }
     return invalidAccounts;
 }
 
-// This function gets called from verifyAccounts.
-// We do not have to do anything on
-// unix and mac but on windows we have to bring up a 
-// dialog based on the settings the user has.
-// This will bring up the dialog only once per session and only if we
-// are not the default mail client.
 function showMailIntegrationDialog() {
-    var mapiRegistry = null;
-    try {
-        var mapiRegistryProgID = "@mozilla.org/mapiregistry;1" 
-        if (mapiRegistryProgID in Components.classes) {
-          mapiRegistry = Components.classes[mapiRegistryProgID].getService(Components.interfaces.nsIMapiRegistry);
-        }
-    }
-    catch (ex) { 
-    }
+  const nsIShellService = Components.interfaces.nsIShellService;
 
-    // showDialog is TRUE only if we did not bring up this dialog already
-    // and we are not the default mail client
-    var prefLocked = false;
-    if (mapiRegistry && mapiRegistry.showDialog) {
-        const prefbase = "system.windows.lock_ui.";
-        try {
-            var prefService = Components.classes["@mozilla.org/preferences-service;1"]
-                          .getService()
-                          .QueryInterface(Components.interfaces.nsIPrefService);
-            var prefBranch = prefService.getBranch(prefbase);
-        
-            if (prefBranch && prefBranch.prefIsLocked("defaultMailClient")) {
-                prefLocked = true;
-                mapiRegistry.isDefaultMailClient = prefBranch.getBoolPref("defaultMailClient") ;
-            }
-        }
-        catch (ex) {}
-        try {
-          if (!prefLocked)
-            mapiRegistry.showMailIntegrationDialog(window /* parent window */);
-        }
-        catch (ex) {
-          dump("mapi code failed:  " + ex + "\n");
-        }
-    }
+  try {
+    var shellService = Components.classes["@mozilla.org/suite/shell-service;1"]
+                                 .getService(nsIShellService);
+    var accountManager = Components.classes[accountManagerContractID].getService(Components.interfaces.nsIMsgAccountManager);
+    var defaultAccount = accountManager.defaultAccount;
+    var appTypesCheck = shellService.shouldBeDefaultClientFor &
+                        (nsIShellService.MAIL | nsIShellService.NEWS);
+
+    // show the default client dialog only if we have at least one account,
+    // if we should check for the default client, and we want to check if we are 
+    // the default for mail/news and are not the default client for mail/news
+    if (appTypesCheck && shellService.shouldCheckDefaultClient &&
+        !shellService.isDefaultClient(true, appTypesCheck))
+        window.openDialog("chrome://communicator/content/defaultClientDialog.xul",
+                        "DefaultClient", "modal,centerscreen,chrome,resizable=no");
+  } catch (ex) {}
 }
 
 function verifyAccounts(wizardCallback) 
 {
 	var openWizard = false;
   var prefillAccount;
 	var state=true;
 	var ret = true;
@@ -190,25 +167,24 @@ function verifyAccounts(wizardCallback)
           {
             localFoldersExists = false;
           }
 
           // we didn't create the MsgAccountWizard - we need to verify that local folders exists.
           if (!localFoldersExists)
             am.createLocalMailAccount();
         }
-        
-        // This will only succeed on SeaMonkey windows builds
-        var mapiRegistryProgID = "@mozilla.org/mapiregistry;1" 
-        if (mapiRegistryProgID in Components.classes)
+
+        // This will do nothing on platforms without a shell service
+        const NS_SHELLSERVICE_CID = "@mozilla.org/suite/shell-service;1"
+        if (NS_SHELLSERVICE_CID in Components.classes)
         {
           // hack, set a time out to do this, so that the window can load first
           setTimeout(showMailIntegrationDialog, 0);
         }
-
         return ret;
     }
     catch (ex) {
         dump("error verifying accounts " + ex + "\n");
         return false;
     }
 }
 
--- a/mailnews/base/prefs/resources/content/pref-mailnews.js
+++ b/mailnews/base/prefs/resources/content/pref-mailnews.js
@@ -15,38 +15,38 @@
  * The Original Code is mozilla.org code.
  *
  * The Initial Developer of the Original Code is
  * Mark Banner <bugzilla@standard8.plus.com>
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
+ *   Frank Wein <mcsmurf@mcsmurf.de>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-if ("@mozilla.org/browser/shell-service;1" in Components.classes)
+if ("@mozilla.org/suite/shell-service;1" in Components.classes)
   const nsIShellService = Components.interfaces.nsIShellService;
 
 function Startup()
 {
   startPageCheck();
-
   defaultClientSetup();
 }
 
 function startPageCheck()
 {
   var checked = document.getElementById("mailnews.start_page.enabled").value;
   var urlElement = document.getElementById("mailnewsStartPageUrl");
   var prefLocked = document.getElementById("mailnews.start_page.url").locked;
@@ -58,70 +58,45 @@ function setHomePageToDefaultPage()
 {
   var startPagePref = document.getElementById("mailnews.start_page.url");
 
   startPagePref.value = startPagePref.defaultValue;
 }
 
 function defaultClientSetup()
 {
-  if ("@mozilla.org/browser/shell-service;1" in Components.classes) {
-    var shellService = Components.classes["@mozilla.org/browser/shell-service;1"]
+  if ("@mozilla.org/suite/shell-service;1" in Components.classes) {
+    var shellService = Components.classes["@mozilla.org/suite/shell-service;1"]
                                  .getService(nsIShellService);
 
     document.getElementById("setDefaultMail").disabled =
       shellService.isDefaultClient(false, nsIShellService.MAIL);
 
     document.getElementById("setDefaultNews").disabled =
       shellService.isDefaultClient(false, nsIShellService.NEWS);
 
-    return;
+    document.getElementById("defaultMailPrefs").hidden = false;
   }
-  if ("@mozilla.org/mapiregistry;1" in Components.classes) {
-    var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"]
-                     .getService(Components.interfaces.nsIMapiRegistry);
-
-    document.getElementById("setDefaultMail").disabled =
-      mapiRegistry.isDefaultMailClient;
-
-    document.getElementById("setDefaultNews").disabled =
-      mapiRegistry.isDefaultNewsClient;
-
-    return;
-  }
-
-  document.getElementById("defaultMailPrefs").hidden = true;
 }
 
 function onSetDefaultMail()
 {
-  if ("@mozilla.org/browser/shell-service;1" in Components.classes) {
-    var shellService = Components.classes["@mozilla.org/browser/shell-service;1"]
-                                 .getService(nsIShellService);
+  var shellService = Components.classes["@mozilla.org/suite/shell-service;1"]
+                               .getService(nsIShellService);
+  var appTypes = shellService.shouldBeDefaultClientFor;
 
-    shellService.setDefaultClient(false, false, nsIShellService.MAIL);
-  }
-  else if ("@mozilla.org/mapiregistry;1" in Components.classes) {
-    var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"]
-                     .getService(Components.interfaces.nsIMapiRegistry);
+  shellService.setDefaultClient(false, false, nsIShellService.MAIL);
+  shellService.shouldBeDefaultClientFor |= nsIShellService.MAIL;
 
-    mapiRegistry.isDefaultMailClient = true;
-
-  }
   document.getElementById("setDefaultMail").disabled = true;
 }
 
 function onSetDefaultNews()
 {
-  if ("@mozilla.org/browser/shell-service;1" in Components.classes) {
-    var shellService = Components.classes["@mozilla.org/browser/shell-service;1"]
-                                 .getService(nsIShellService);
+  var shellService = Components.classes["@mozilla.org/suite/shell-service;1"]
+                               .getService(nsIShellService);
+  var appTypes = shellService.shouldBeDefaultClientFor;
 
-    shellService.setDefaultClient(false, false, nsIShellService.NEWS);
-  }
-  else if ("@mozilla.org/mapiregistry;1" in Components.classes) {
-    var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"]
-                     .getService(Components.interfaces.nsIMapiRegistry);
+  shellService.setDefaultClient(false, false, nsIShellService.NEWS);
+  shellService.shouldBeDefaultClientFor |= nsIShellService.NEWS;
 
-    mapiRegistry.isDefaultNewsClient = true;
-  }
   document.getElementById("setDefaultNews").disabled = true;
 }
--- a/mailnews/base/prefs/resources/content/pref-mailnews.xul
+++ b/mailnews/base/prefs/resources/content/pref-mailnews.xul
@@ -99,17 +99,17 @@
 
       <hbox align="center">
         <checkbox id="mailPreserveThreading"
                   label="&preserveThreading.label;"
                   accesskey="&preserveThreading.accesskey;"
                   preference="mailnews.thread_pane_column_unthreads"
                   reversed="true" />
       </hbox>
-      <vbox id="defaultMailPrefs">
+      <vbox id="defaultMailPrefs" hidden="true">
         <separator class="thin"/>
 
         <description>&defaultMailSettings.description;</description>
         <hbox class="indent" align="center">
           <button id="setDefaultMail" accesskey="&setDefaultMail.accesskey;"
                   label="&setDefaultMail.label;" oncommand="onSetDefaultMail();"
                   preference="system.windows.lock_ui.defaultMailClient"/>
           <button id="setDefaultNews" accesskey="&setDefaultNews.accesskey;"
--- a/mailnews/mapi/mapihook/src/Makefile.in
+++ b/mailnews/mapi/mapihook/src/Makefile.in
@@ -79,20 +79,16 @@ CPPSRCS		= \
 		msgMapiFactory.cpp \
 		msgMapiHook.cpp \
 		msgMapiImp.cpp \
 		msgMapiMain.cpp \
 		msgMapiSupport.cpp \
 		Registry.cpp \
 		$(NULL)
 
-ifndef MOZ_THUNDERBIRD
-CPPSRCS        += nsMapiRegistry.cpp nsMapiRegistryUtils.cpp
-endif
-
 LOBJS		= ../build/msgMapi_i.$(OBJ_SUFFIX)
 
 ifndef MOZ_STATIC_MAIL_BUILD
 
 ifdef USE_SHORT_LIBNAME
 EXTRA_DSO_LIBS	= msgbsutl
 else
 EXTRA_DSO_LIBS	= msgbaseutil
--- a/mailnews/mapi/mapihook/src/msgMapiSupport.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiSupport.cpp
@@ -42,21 +42,16 @@
 #include "nsIObserverService.h"
 #include "nsIAppStartupNotifier.h"
 #include "nsIServiceManager.h"
 #include "nsIComponentManager.h"
 #include "nsICategoryManager.h"
 #include "Registry.h"
 #include "msgMapiSupport.h"
 
-#ifndef MOZ_THUNDERBIRD
-#include "nsMapiRegistryUtils.h" 
-#include "nsMapiRegistry.h"
-#endif
-
 #include "msgMapiImp.h"
 
 /** Implementation of the nsIMapiSupport interface.
  *  Use standard implementation of nsISupports stuff.
  */
 
 NS_IMPL_THREADSAFE_ISUPPORTS2(nsMapiSupport, nsIMapiSupport, nsIObserver)
 
@@ -167,38 +162,25 @@ nsMapiSupport::RegisterServer()
 NS_IMETHODIMP
 nsMapiSupport::UnRegisterServer()
 {
   // TODO: Figure out what kind of error propogation to pass back
   ::UnregisterServer(CLSID_CMapiImp, "MozillaMapi", "MozillaMapi.1");
   return NS_OK;
 }
 
-
-#ifndef MOZ_THUNDERBIRD
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsMapiRegistry)
-#endif
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMapiSupport)
 
 // The list of components we register
 static const nsModuleComponentInfo components[] = 
 {
-#ifndef MOZ_THUNDERBIRD
   {
-    NS_IMAPIREGISTRY_CLASSNAME, 
-    NS_IMAPIREGISTRY_CID,
-    NS_IMAPIREGISTRY_CONTRACTID, 
-    nsMapiRegistryConstructor
-  },
-#endif
-
-{
     NS_IMAPISUPPORT_CLASSNAME,
     NS_IMAPISUPPORT_CID,
     NS_IMAPISUPPORT_CONTRACTID,
     nsMapiSupportConstructor,
     nsMapiRegistrationProc,
     nsnull
-}
+  }
 };
 
 NS_IMPL_NSGETMODULE(msgMapiModule, components)
 
deleted file mode 100644
--- a/mailnews/mapi/mapihook/src/nsMapiRegistry.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Srilatha Moturi <srilatha@netscape.com>
- *   Rajiv Dayal <rdayal@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
- 
-/***************************************************************************
-*
-* This File is no longer used by Thunderbird. Seamonkey is the only consumer.
-* See mozilla/mail/components/shell for the Thunderbird registry code
-*
-*****************************************************************************/
-
-#include "nsIServiceManager.h"
-#include "nsIPromptService.h"
-#include "nsIProxyObjectManager.h"
-#include "nsProxiedService.h"
-
-#include "nsMapiRegistryUtils.h" 
-#include "nsMapiRegistry.h"
-
-#include "nsIPrefService.h"
-#include "nsIPrefBranch.h"
-
-#include "nsEmbedCID.h"
-
-/** Implementation of the nsIMapiRegistry interface.
- *  Use standard implementation of nsISupports stuff.
- */
-NS_IMPL_ISUPPORTS1(nsMapiRegistry, nsIMapiRegistry)
-
-nsMapiRegistry::nsMapiRegistry() {
-    m_DefaultMailClient = m_registryUtils.IsDefaultMailClient();
-    m_DefaultNewsClient = m_registryUtils.IsDefaultNewsClient(); 
-    // m_ShowDialog should be initialized to false 
-    // if we are the default mail client.
-    m_ShowDialog = !m_registryUtils.HasRestrictedRegistryAccess() && !m_DefaultMailClient;
-}
-
-nsMapiRegistry::~nsMapiRegistry() {
-}
-
-NS_IMETHODIMP
-nsMapiRegistry::GetIsDefaultMailClient(PRBool * retval) {
-    // we need to get the value from registry everytime
-    // because the registry settings can be changed from
-    // other mail applications.
-    *retval = m_registryUtils.IsDefaultMailClient();
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsMapiRegistry::GetIsDefaultNewsClient(PRBool * retval) {
-    // we need to get the value from registry everytime
-    // because the registry settings can be changed from
-    // other mail applications.
-    *retval = m_registryUtils.IsDefaultNewsClient();
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsMapiRegistry::GetIsDefaultFeedClient(PRBool * retval) {
-    // we need to get the value from registry everytime
-    // because the registry settings can be changed from
-    // other applications.
-    *retval = m_registryUtils.IsDefaultFeedClient();
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsMapiRegistry::GetShowDialog(PRBool * retval) {
-    *retval = m_ShowDialog;
-    return NS_OK;
-}
-
-
-NS_IMETHODIMP
-nsMapiRegistry::SetIsDefaultMailClient(PRBool aIsDefaultMailClient) 
-{
-    nsresult rv = NS_OK ;
-
-    if (aIsDefaultMailClient)
-    {
-        rv = m_registryUtils.setDefaultMailClient();
-        if (NS_SUCCEEDED(rv))
-            m_DefaultMailClient = PR_TRUE;
-        else
-            m_registryUtils.ShowMapiErrorDialog(PR_TRUE);
-    }
-    else
-    {
-        rv = m_registryUtils.unsetDefaultMailClient();
-        if (NS_SUCCEEDED(rv))
-            m_DefaultMailClient = PR_FALSE;
-        else
-            m_registryUtils.ShowMapiErrorDialog(PR_TRUE);
-    }
-
-    return rv ;
-}
-
-NS_IMETHODIMP
-nsMapiRegistry::SetIsDefaultNewsClient(PRBool aIsDefaultNewsClient) 
-{
-    nsresult rv = NS_OK ;
-
-    if (aIsDefaultNewsClient)
-    {
-        rv = m_registryUtils.setDefaultNewsClient();
-        if (NS_SUCCEEDED(rv))
-            m_DefaultNewsClient = PR_TRUE;
-        else
-            m_registryUtils.ShowMapiErrorDialog(PR_FALSE);
-    }
-    else
-    {
-        rv = m_registryUtils.unsetDefaultNewsClient();
-        if (NS_SUCCEEDED(rv))
-            m_DefaultNewsClient = PR_FALSE;
-        else
-            m_registryUtils.ShowMapiErrorDialog(PR_FALSE);
-    }
-
-    return rv ;
-}
-
-NS_IMETHODIMP
-nsMapiRegistry::SetIsDefaultFeedClient(PRBool aIsDefaultFeedClient) 
-{
-    nsresult rv = NS_OK;
-    return aIsDefaultFeedClient ? m_registryUtils.setDefaultFeedClient() : m_registryUtils.unsetDefaultFeedClient();
-}
-
-NS_IMETHODIMP nsMapiRegistry::RegisterMailAndNewsClient()
-{
-  m_registryUtils.registerNewsApp(PR_FALSE);
-  m_registryUtils.registerMailApp(PR_FALSE);
-  return NS_OK;
-}
-
-/** This will bring up the dialog box only once per session and 
- * only if the current app is not default Mail Client.
- * This also checks the registry if the registry key
- * showMapiDialog is set
- */
-NS_IMETHODIMP
-nsMapiRegistry::ShowMailIntegrationDialog(nsIDOMWindow *aParentWindow) {
-    if (!m_ShowDialog || !m_registryUtils.getShowDialog() ||
-        m_registryUtils.IsDefaultMailClient()) {
-      return NS_OK;
-    }
-
-    nsresult rv;
-    nsCOMPtr<nsIPromptService> promptService(do_GetService(
-                  NS_PROMPTSERVICE_CONTRACTID, &rv));
-    if (NS_SUCCEEDED(rv) && promptService)
-    {
-        nsCOMPtr<nsIStringBundle> bundle;
-        rv = m_registryUtils.MakeMapiStringBundle (getter_AddRefs (bundle)) ;
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-
-        nsString dialogTitle;
-        const PRUnichar *brandStrings[] = { m_registryUtils.brandName() };
-        NS_NAMED_LITERAL_STRING(dialogTitlePropertyTag, "dialogTitle");
-        rv = bundle->FormatStringFromName(dialogTitlePropertyTag.get(),
-                                          brandStrings, 1,
-                                          getter_Copies(dialogTitle));
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-        
-        nsString dialogText;
-        NS_NAMED_LITERAL_STRING(dialogTextPropertyTag, "dialogText");
-        rv = bundle->FormatStringFromName(dialogTextPropertyTag.get(),
-                                          brandStrings, 1,
-                                          getter_Copies(dialogText));
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-
-        nsString checkboxText;
-        rv = bundle->GetStringFromName(
-                           NS_LITERAL_STRING("checkboxText").get(),
-                           getter_Copies(checkboxText));
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-
-        PRBool checkValue = PR_FALSE;
-        PRInt32 buttonPressed = 0;
-        rv = promptService->ConfirmEx(aParentWindow,
-                                      dialogTitle.get(),
-                                      dialogText.get(),
-                                      nsIPromptService::STD_YES_NO_BUTTONS,
-                                      nsnull,
-                                      nsnull,
-                                      nsnull,
-                                      checkboxText.get(),
-                                      &checkValue,
-                                      &buttonPressed);
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-        rv = m_registryUtils.SetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, 
-                                "showMapiDialog", (checkValue) ? "0" : "1");
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-
-        m_ShowDialog = PR_FALSE;
-        if (!buttonPressed)
-            rv = SetIsDefaultMailClient(PR_TRUE);
-    }
-    return rv;
-}
-
deleted file mode 100644
--- a/mailnews/mapi/mapihook/src/nsMapiRegistry.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Srilatha Moturi <srilatha@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/***************************************************************************
-*
-* This File is no longer used by Thunderbird. Seamonkey is the only consumer.
-* See mozilla/mail/components/shell for the Thunderbird registry code
-*
-*****************************************************************************/
-
-#ifndef nsmapiregistry_h____
-#define nsmapiregistry_h____
-
-#include "nsIMapiRegistry.h"
-
-#ifndef MAX_BUF
-#define MAX_BUF 4096
-#endif
-
-/* c5be14ba-4e0a-4eec-a1b8-04363761d63c */
-#define NS_IMAPIREGISTRY_CID \
- { 0xc5be14ba, 0x4e0a, 0x4eec, {0xa1, 0xb8, 0x04, 0x36, 0x37, 0x61, 0xd6, 0x3c} }
-#define NS_IMAPIREGISTRY_CONTRACTID    "@mozilla.org/mapiregistry;1"
-#define NS_IMAPIREGISTRY_CLASSNAME "Mozilla MAPI Registry"
-
-class nsMapiRegistry : public nsIMapiRegistry {
-public:
-    // ctor/dtor
-    nsMapiRegistry();
-    virtual ~nsMapiRegistry();
-
-    // Declare all interface methods we must implement.
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIMAPIREGISTRY
-
-protected:
-    
-    PRBool m_DefaultMailClient;
-    PRBool m_DefaultNewsClient;
-    PRBool m_ShowDialog;
-    nsMapiRegistryUtils m_registryUtils ;
-
-private:
-    // Special member to handle initialization.
-    PRBool mHaveBeenSet;
-}; // nsMapiRegistry
-
-#endif // nsmapiregistry_h____
deleted file mode 100644
--- a/mailnews/mapi/mapihook/src/nsMapiRegistryUtils.cpp
+++ /dev/null
@@ -1,1287 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Srilatha Moturi <srilatha@netscape.com>
- *   Jungshik Shin <jshin@mailaps.org>
- *   Scott MacGregor <mscott@mozilla.org>
- *   David Bienvenu < bienvenu@mozilla.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/***************************************************************************
-*
-* This File is no longer used by Thunderbird. Seamonkey is the only consumer.
-* See mozilla/mail/components/shell for the Thunderbird registry code
-*
-*****************************************************************************/
-
-#undef UNICODE
-#undef _UNICODE
-
-#include "nsIServiceManager.h"
-#include "msgMapiImp.h"
-#include "msgMapiMain.h"
-#include "nsMapiRegistryUtils.h"
-#include "nsString.h"
-#include "nsIStringBundle.h"
-#include "nsIPromptService.h"
-#include "plstr.h"
-#include "nsDirectoryService.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsAppDirectoryServiceDefs.h"
-#include "nsNativeCharsetUtils.h"
-#include "nsEmbedCID.h"
-#include "nsIMapiSupport.h"
-#include <mbstring.h>
-
-#define EXE_EXTENSION ".EXE"
-#define MOZ_HWND_BROADCAST_MSG_TIMEOUT 5000
-#define MOZ_CLIENT_MAIL_KEY "Software\\Clients\\Mail"
-#define MOZ_CLIENT_NEWS_KEY "Software\\Clients\\News"
-
-nsMapiRegistryUtils::nsMapiRegistryUtils()
-{
-   m_mapiStringBundle = nsnull ;
-
-   mRestrictedRegAccess = verifyRestrictedAccess();
-}
-
-const char * nsMapiRegistryUtils::thisApplication()
-{
-    if (m_thisApp.IsEmpty()) {
-        char buffer[MAX_PATH] = {0};
-        DWORD len = ::GetModuleFileName(NULL, buffer, MAX_PATH);
-        if (!len) return nsnull ;
-        len = ::GetShortPathName(buffer, buffer, MAX_PATH);
-        if (!len) return nsnull ;
-        m_thisApp = buffer;
-        ToUpperCase(m_thisApp);
-    }
-
-    return m_thisApp.get() ;
-}
-
-void nsMapiRegistryUtils::getVarValue(const PRUnichar * varName, nsString & result)
-{
-  nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(
-                                       NS_STRINGBUNDLE_CONTRACTID, &rv));
-  if (NS_FAILED(rv)) return;
-  nsCOMPtr<nsIStringBundle> brandBundle;
-  rv = bundleService->CreateBundle(
-              "chrome://branding/locale/brand.properties",
-              getter_AddRefs(brandBundle));
-  if (NS_SUCCEEDED(rv)) {
-    brandBundle->GetStringFromName(
-               varName,
-               getter_Copies(result));
-  }
-}
-
-const PRUnichar * nsMapiRegistryUtils::brandName()
-{
-  if (m_brand.IsEmpty())
-    getVarValue(NS_LITERAL_STRING("brandFullName").get(), m_brand);
-  return m_brand.get();
-}
-
-const nsString& nsMapiRegistryUtils::vendorName()
-{
-  if (m_vendor.IsEmpty())
-    getVarValue(NS_LITERAL_STRING("vendorShortName").get(), m_vendor);
-  return m_vendor;
-}
-
-
-PRBool nsMapiRegistryUtils::verifyRestrictedAccess() {
-  char   subKey[] = "Software\\Mozilla - Test Key";
-  PRBool result = PR_FALSE;
-  DWORD  dwDisp = 0;
-  HKEY   key;
-  // Try to create/open a subkey under HKLM.
-  DWORD rc = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE,
-                              subKey,
-                              0,
-                              NULL,
-                              REG_OPTION_NON_VOLATILE,
-                              KEY_WRITE,
-                              NULL,
-                              &key,
-                              &dwDisp);
-
-  if (rc == ERROR_SUCCESS) {
-    // Key was opened; first close it.
-    ::RegCloseKey(key);
-    // Delete it if we just created it.
-    switch(dwDisp) {
-        case REG_CREATED_NEW_KEY:
-            ::RegDeleteKey(HKEY_LOCAL_MACHINE, subKey);
-            break;
-        case REG_OPENED_EXISTING_KEY:
-            break;
-    }
-  } else {
-    // Can't create/open it; we don't have access.
-    result = PR_TRUE;
-  }
-  return result;
-}
-
-nsresult nsMapiRegistryUtils::SetRegistryKey(HKEY baseKey, const char * keyName,
-                        const char * valueName, char * value)
-{
-    nsresult result = NS_ERROR_FAILURE;
-    HKEY   key;
-    LONG   rc = ::RegCreateKey(baseKey, keyName, &key);
-
-    if (rc == ERROR_SUCCESS) {
-        rc = ::RegSetValueEx(key, valueName, NULL, REG_SZ,
-                                 (LPBYTE)(const char*)value, strlen(value));
-        if (rc == ERROR_SUCCESS) {
-            result = NS_OK;
-        }
-        ::RegCloseKey(key);
-    }
-    return result;
-}
-
-nsresult nsMapiRegistryUtils::DeleteRegistryValue(HKEY baseKey, const char * keyName,
-                        const char * valueName)
-{
-    nsresult result = NS_ERROR_FAILURE;
-    HKEY   key;
-    LONG   rc = ::RegOpenKey(baseKey, keyName, &key);
-
-    if (rc == ERROR_SUCCESS) {
-        rc = ::RegDeleteValue(key, valueName);
-        if (rc == ERROR_SUCCESS)
-            result = NS_OK;
-        ::RegCloseKey(key);
-    }
-    return result;
-}
-
-void nsMapiRegistryUtils::GetRegistryKey(HKEY baseKey, const char * keyName,
-                         const char * valueName, nsCAutoString & value)
-{
-    HKEY   key;
-    LONG   rc = ::RegOpenKey(baseKey, keyName, &key);
-    if (rc == ERROR_SUCCESS) {
-        char buffer[MAX_PATH] = {0};
-        DWORD len = sizeof buffer;
-        rc = ::RegQueryValueEx(key, valueName, NULL, NULL,
-                               (LPBYTE)buffer, &len);
-        if (rc == ERROR_SUCCESS) {
-            if (len)
-                value = buffer;
-        }
-        ::RegCloseKey(key);
-     }
-}
-
-nsresult nsMapiRegistryUtils::recursiveDeleteKey(HKEY hKeyParent, const char* lpszKeyChild)
-{
-    // Open the child.
-    HKEY hKeyChild ;
-    nsresult rv = NS_OK;
-
-    LONG lRes = ::RegOpenKeyEx(hKeyParent, lpszKeyChild, 0, KEY_ALL_ACCESS, &hKeyChild);
-    if (lRes != ERROR_SUCCESS)
-        return NS_ERROR_FAILURE;
-
-    // Enumerate all of the decendents of this child.
-    FILETIME time;
-    char szBuffer[MAX_PATH+1];
-    DWORD dwSize = MAX_PATH+1;
-    while (::RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL, NULL, NULL, &time) == S_OK)
-    {
-        // Delete the decendents of this child.
-        rv = recursiveDeleteKey(hKeyChild, szBuffer);
-        if (NS_FAILED(rv))
-        {
-            // Cleanup before exiting.
-            ::RegCloseKey(hKeyChild);
-            return rv;
-        }
-
-        dwSize = MAX_PATH+1;
-    }
-
-    // Close the child.
-    ::RegCloseKey(hKeyChild);
-
-    // Delete this child.
-    ::RegDeleteKey(hKeyParent, lpszKeyChild);
-    return rv;
-}
-
-/* static */
-void nsMapiRegistryUtils::RegCopyKey(HKEY aSrcKey, HKEY aDestKey, const char* aSubKeyName)
-{
-  HKEY srcSubKey, destSubKey;
-  char valueName[MAX_PATH + 1], keyName[MAX_PATH + 1];
-  BYTE valueData[MAX_PATH + 1];
-  DWORD nameSize, dataSize, keySize, valueType;
-
-  // open source key
-  if (::RegOpenKeyEx(aSrcKey, aSubKeyName, NULL, KEY_ALL_ACCESS, &srcSubKey) != ERROR_SUCCESS)
-    return;
-
-  // create target key
-  if (::RegCreateKeyEx(aDestKey, aSubKeyName, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &destSubKey, NULL) == ERROR_SUCCESS) {
-    for (DWORD valueIndex = 0;
-         nameSize = MAX_PATH + 1,
-         dataSize = MAX_PATH + 1,
-         ::RegEnumValue(srcSubKey, valueIndex, valueName, &nameSize, NULL, &valueType, valueData, &dataSize) == ERROR_SUCCESS;
-         valueIndex++)
-      ::RegSetValueEx(destSubKey, valueName, NULL, valueType, valueData, dataSize);
-
-    for (DWORD keyIndex = 0;
-         keySize = MAX_PATH + 1,
-         ::RegEnumKeyEx(srcSubKey, keyIndex, keyName, &keySize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS;
-         keyIndex++)
-      RegCopyKey(srcSubKey, destSubKey, keyName);
-
-    ::RegCloseKey(destSubKey);
-  }
-  ::RegCloseKey(srcSubKey);
-}
-
-PRBool nsMapiRegistryUtils::IsDefaultMailClient()
-{
-    if (!isSmartDll() && !isMozDll())
-        return PR_FALSE;
-
-    //first try to get the users default mail client
-    nsCAutoString name;
-    // old mail clients like netscape 4.x never channge the current user key, so it is possible for them to become
-    // the default mail client and we don't notice because we see that thunderbird still owns the HKCU key...
-    // doh!
-    // GetRegistryKey(HKEY_CURRENT_USER, "Software\\Clients\\Mail", "", name);
-
-    //if that fails then get the machine's default client
-    GetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\Mail", "", name);
-
-    if (!name.IsEmpty()) {
-         nsCAutoString keyName("Software\\Clients\\Mail\\");
-         keyName += name.get();
-         keyName += "\\Protocols\\mailto\\shell\\open\\command";
-
-         nsCAutoString result;
-         GetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", result);
-         if (!result.IsEmpty()) {
-             nsCAutoString strExtension;
-             strExtension.Assign(EXE_EXTENSION);
-             ToUpperCase(result);
-             PRInt32 index = result.RFind(strExtension.get());
-             if (index != kNotFound) {
-                 result.Truncate(index + strExtension.Length());
-             }
-
-             nsCAutoString thisApp (thisApplication());
-             // if result == thisApp, that by itself isn't a strong enough indication that everything
-             // is ok...also check HKLM\Software\Classes\mailto\shell\open\command
-             if (result == thisApp)
-             {
-               keyName = "Software\\Classes\\mailto\\shell\\open\\command";
-               nsCAutoString result;
-               GetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", result);
-               if (!result.IsEmpty()) {
-                  nsCAutoString strExtension;
-                  strExtension.Assign(EXE_EXTENSION);
-                  ToUpperCase(result);
-                  PRInt32 index = result.RFind(strExtension.get());
-                  if (index != kNotFound)
-                    result.Truncate(index + strExtension.Length());
-                  return (result == thisApp);
-               }
-             }
-        }
-    }
-    return PR_FALSE;
-
-}
-
-PRBool nsMapiRegistryUtils::IsDefaultNewsClient()
-{
-    //first try to get the users default news client
-    nsCAutoString name;
-    GetRegistryKey(HKEY_CURRENT_USER, "Software\\Clients\\News", "", name);
-
-     //if that fails then get the machine's default client
-    if(name.IsEmpty()) {
-        GetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\News", "", name);
-    }
-
-    if (!name.IsEmpty()) {
-         nsCAutoString keyName("Software\\Clients\\News\\");
-         keyName += name.get();
-
-         // let's only check news and instead of news, nntp and snews.
-         keyName += "\\Protocols\\news\\shell\\open\\command";
-         nsCAutoString result;
-         GetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", result);
-         if (!result.IsEmpty()) {
-             nsCAutoString strExtension;
-             strExtension.Assign(EXE_EXTENSION);
-             ToUpperCase(result);
-             PRInt32 index = result.RFind(strExtension.get());
-             if (index != kNotFound) {
-                 result.Truncate(index + strExtension.Length());
-             }
-             nsCAutoString thisApp (thisApplication()) ;
-             return (result == thisApp);
-        }
-    }
-
-    return PR_FALSE;
-}
-
-nsresult nsMapiRegistryUtils::saveDefaultNewsClient()
-{
-    nsCAutoString name ;
-    GetRegistryKey(HKEY_LOCAL_MACHINE,"Software\\Clients\\News", "", name);
-    return SetRegistryKey(HKEY_LOCAL_MACHINE,
-                            kAppDesktopKey,
-                            "HKEY_LOCAL_MACHINE\\Software\\Clients\\News",
-                            name.IsEmpty() ? "" : (char *)name.get());
-}
-
-nsresult nsMapiRegistryUtils::saveDefaultMailClient()
-{
-    nsCAutoString name ;
-    GetRegistryKey(HKEY_LOCAL_MACHINE,"Software\\Clients\\Mail", "", name);
-    return SetRegistryKey(HKEY_LOCAL_MACHINE,
-                            kAppDesktopKey,
-                            "HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail",
-                            name.IsEmpty() ? "" : (char *)name.get());
-}
-
-nsresult nsMapiRegistryUtils::saveUserDefaultNewsClient()
-{
-    nsCAutoString name ;
-    GetRegistryKey(HKEY_CURRENT_USER,"Software\\Clients\\News", "", name);
-    return SetRegistryKey(HKEY_LOCAL_MACHINE,
-                            kAppDesktopKey,
-                            "HKEY_CURRENT_USER\\Software\\Clients\\News",
-                            name.IsEmpty() ? "" : (char *)name.get());
-}
-
-nsresult nsMapiRegistryUtils::saveUserDefaultMailClient()
-{
-    nsCAutoString name ;
-    GetRegistryKey(HKEY_CURRENT_USER,"Software\\Clients\\Mail", "", name);
-    return SetRegistryKey(HKEY_LOCAL_MACHINE,
-                            kAppDesktopKey,
-                            "HKEY_CURRENT_USER\\Software\\Clients\\Mail",
-                            name.IsEmpty() ? "" : (char *)name.get());
-}
-
-/**
- * Check whether it is a smart dll or not. Smart dll is the one installed by
- * IE5 or Outlook Express which forwards the MAPI calls to the dll based on the
- * registry key setttings.
- * Returns TRUE if is a smart dll.
- */
-
-typedef HRESULT (FAR PASCAL GetOutlookVersionFunc)();
-PRBool nsMapiRegistryUtils::isSmartDll()
-{
-    char buffer[MAX_PATH] = {0};
-    if (GetSystemDirectory(buffer, sizeof(buffer)) == 0)
-        return PR_FALSE;
-    PL_strcatn(buffer, sizeof(buffer), "\\Mapi32.dll");
-
-    HINSTANCE hInst;
-    GetOutlookVersionFunc *doesExist = nsnull;
-    hInst = LoadLibrary(buffer);
-    if (hInst == nsnull)
-        return PR_FALSE;
-
-    doesExist = (GetOutlookVersionFunc *) GetProcAddress (hInst, "GetOutlookVersion");
-    FreeLibrary(hInst);
-
-    return (doesExist != nsnull);
-}
-
-typedef HRESULT (FAR PASCAL GetMapiDllVersion)();
-/**
- * Checks whether mapi32.dll is installed by this app.
- * Returns TRUE if it is.
- */
-PRBool nsMapiRegistryUtils::isMozDll()
-{
-    char buffer[MAX_PATH] = {0};
-    if (GetSystemDirectory(buffer, sizeof(buffer)) == 0)
-        return PR_FALSE;
-    PL_strcatn(buffer, sizeof(buffer), "\\Mapi32.dll");
-
-    HINSTANCE hInst;
-    GetMapiDllVersion *doesExist = nsnull;
-    hInst = LoadLibrary(buffer);
-    if (hInst == nsnull)
-        return PR_FALSE;
-
-    doesExist = (GetMapiDllVersion *) GetProcAddress (hInst, "GetMapiDllVersion");
-    FreeLibrary(hInst);
-
-    return (doesExist != nsnull);
-}
-
-/** Renames Mapi32.dl in system directory to Mapi32_moz_bak.dll
- *  copies the mozMapi32.dll from bin directory to the system directory
- */
-nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
-{
-    nsresult rv;
-    char buffer[MAX_PATH] = {0};
-    if (GetSystemDirectory(buffer, sizeof(buffer)) == 0)
-        return NS_ERROR_FAILURE;
-
-    nsCAutoString filePath(buffer);
-    filePath.AppendLiteral("\\Mapi32_moz_bak.dll");
-
-    nsCOMPtr<nsILocalFile> pCurrentMapiFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv);
-    if (NS_FAILED(rv) || !pCurrentMapiFile) return rv;
-    pCurrentMapiFile->InitWithNativePath(filePath);
-
-    nsCOMPtr<nsIFile> pMozMapiFile;
-    nsCOMPtr<nsIProperties> directoryService =
-          do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
-    if (!directoryService) return NS_ERROR_FAILURE;
-    rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
-                              NS_GET_IID(nsIFile),
-                              getter_AddRefs(pMozMapiFile));
-
-    if (NS_FAILED(rv)) return rv;
-    pMozMapiFile->AppendNative(NS_LITERAL_CSTRING("mozMapi32.dll"));
-
-    PRBool bExist;
-    rv = pMozMapiFile->Exists(&bExist);
-    if (NS_FAILED(rv) || !bExist) return rv;
-
-    rv = pCurrentMapiFile->Exists(&bExist);
-    if (NS_SUCCEEDED(rv) && bExist)
-    {
-        rv = pCurrentMapiFile->Remove(PR_FALSE);
-    }
-    if (NS_FAILED(rv)) return rv;
-    filePath.Assign(buffer);
-    filePath.AppendLiteral("\\Mapi32.dll");
-    pCurrentMapiFile->InitWithNativePath(filePath);
-    rv = pCurrentMapiFile->Exists(&bExist);
-    if (NS_SUCCEEDED(rv) && bExist)
-    {
-        rv = pCurrentMapiFile->MoveToNative(nsnull, NS_LITERAL_CSTRING("Mapi32_moz_bak.dll"));
-        if (NS_FAILED(rv)) return rv;
-        nsCAutoString fullFilePath(buffer);
-        fullFilePath.AppendLiteral("\\Mapi32_moz_bak.dll");
-        rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
-                            kAppDesktopKey,
-                            "Mapi_backup_dll",
-                            (char *)fullFilePath.get());
-        if (NS_FAILED(rv)) {
-             RestoreBackedUpMapiDll();
-             return rv;
-        }
-    }
-
-    NS_NAMED_LITERAL_CSTRING(fileName, "Mapi32.dll");
-    filePath.Assign(buffer);
-    pCurrentMapiFile->InitWithNativePath(filePath);
-    rv = pMozMapiFile->CopyToNative(pCurrentMapiFile, fileName);
-    if (NS_FAILED(rv))
-        RestoreBackedUpMapiDll();
-    return rv;
-}
-
-/** deletes the Mapi32.dll in system directory and renames Mapi32_moz_bak.dll
- *  to Mapi32.dll
- */
-nsresult nsMapiRegistryUtils::RestoreBackedUpMapiDll()
-{
-    nsresult rv;
-    char buffer[MAX_PATH] = {0};
-    if (GetSystemDirectory(buffer, sizeof(buffer)) == 0)
-        return NS_ERROR_FAILURE;
-
-    nsCAutoString filePath(buffer);
-    nsCAutoString previousFileName(buffer);
-    filePath.AppendLiteral("\\Mapi32.dll");
-    previousFileName.AppendLiteral("\\Mapi32_moz_bak.dll");
-
-    nsCOMPtr <nsILocalFile> pCurrentMapiFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
-    if (NS_FAILED(rv) || !pCurrentMapiFile) return NS_ERROR_FAILURE;
-    pCurrentMapiFile->InitWithNativePath(filePath);
-
-    nsCOMPtr<nsILocalFile> pPreviousMapiFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv);
-    if (NS_FAILED(rv) || !pPreviousMapiFile) return NS_ERROR_FAILURE;
-    pPreviousMapiFile->InitWithNativePath(previousFileName);
-
-    PRBool bExist;
-    rv = pCurrentMapiFile->Exists(&bExist);
-    if (NS_SUCCEEDED(rv) && bExist) {
-        rv = pCurrentMapiFile->Remove(PR_FALSE);
-        if (NS_FAILED(rv)) return rv;
-    }
-
-    rv = pPreviousMapiFile->Exists(&bExist);
-    if (NS_SUCCEEDED(rv) && bExist)
-        rv = pPreviousMapiFile->MoveToNative(nsnull, NS_LITERAL_CSTRING("Mapi32.dll"));
-    if (NS_SUCCEEDED(rv))
-        DeleteRegistryValue(HKEY_LOCAL_MACHINE,
-                            kAppDesktopKey,
-                            "Mapi_backup_dll");
-    return rv;
-}
-
-// aDefaultAppRegKey points to something like Software\Clients\News\Mozilla\Protocols
-// we will copy the keys into Software\Clases
-nsresult nsMapiRegistryUtils::setProtocolHandler(const char * aDefaultAppRegKey, const char * protocolName)
-{
-    HKEY srcKey;
-    HKEY trgKey;
-
-    ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, aDefaultAppRegKey, 0, KEY_READ, &srcKey);
-    ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Classes", 0, KEY_READ, &trgKey);
-
-    RegCopyKey(srcKey, trgKey, protocolName);
-
-    RegCloseKey(srcKey);
-    RegCloseKey(trgKey);
-    return NS_OK;
-}
-
-nsresult nsMapiRegistryUtils::setupFileExtension(const char * aDefaultAppRegKey, const char * aExtension)
-{
-
-  // aDefaultAppRegKey is "Software\\Classes\\"
-    nsCAutoString keyName;
-    keyName = aDefaultAppRegKey;
-    keyName.Append(aExtension);
-
-
-    nsCAutoString appName;
-    LossyCopyUTF16toASCII(brandName(), appName);
-
-    // save the current file extension settings to HKEY_LOCAL_MACHINE\Software\Clients\Thunderbird\<extension>
-    nsCAutoString saveKeyName("Software\\Clients\\Mail\\");
-    saveKeyName.Append(appName);
-    saveKeyName.AppendLiteral("\\");
-
-    HKEY srcKey;
-    HKEY trgKey;
-    ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, aDefaultAppRegKey, 0, KEY_READ, &srcKey);
-    ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,saveKeyName.get(), 0, KEY_READ, &trgKey);
-
-    RegCopyKey(srcKey, trgKey, aExtension);
-
-    nsresult rv = SetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", "");
-
-
-    if (NS_SUCCEEDED(rv))
-    {
-      // Classes\<extension>\shell\open\command value
-      nsCAutoString appPath (thisApplication());
-
-      appPath += " ";
-
-      appPath += "\"%1\"";
-      nsCAutoString shellOpenKey (keyName);
-      shellOpenKey.AppendLiteral("\\shell\\open\\command");
-
-      rv = SetRegistryKey(HKEY_LOCAL_MACHINE, shellOpenKey.get(), "", (char *)appPath.get());
-
-      // Classes\<extension>\DefaultIcon value
-      nsCAutoString iconPath(thisApplication());
-      iconPath += ",0";
-      nsCAutoString iconKey (keyName);
-      iconKey.AppendLiteral("\\DefaultIcon");
-      rv = SetRegistryKey(HKEY_LOCAL_MACHINE, iconKey.get(), "", (char *)iconPath.get());
-    }
-
-    return rv;
-}
-
-nsresult nsMapiRegistryUtils::restoreFileExtension(const char * aDefaultAppRegKey, const char * aExtension)
-{
-
-  // aDefaultAppRegKey is "Software\\Classes\\"
-  nsCAutoString keyName;
-  keyName = aDefaultAppRegKey;
-  keyName.Append(aExtension);
-
-  nsCAutoString appName;
-  LossyCopyUTF16toASCII(brandName(), appName);
-
-  // restore the file extension settings from HKEY_LOCAL_MACHINE\Software\Clients\Mail\Mail & News\<extension>
-
-  nsCAutoString saveKeyName("Software\\Clients\\Mail\\");
-  saveKeyName.Append(appName);
-  saveKeyName.AppendLiteral("\\");
-
-  recursiveDeleteKey(HKEY_LOCAL_MACHINE, keyName.get());
-  nsresult rv = SetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", "");
-
-  HKEY srcKey;
-  HKEY trgKey;
-  ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, saveKeyName.get(), 0, KEY_READ, &srcKey);
-  ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, aDefaultAppRegKey, 0, KEY_READ, &trgKey);
-
-  RegCopyKey(srcKey, trgKey, aExtension);
-
-  return rv;
-}
-
-
-nsresult nsMapiRegistryUtils::setupDefaultProtocolKey(const char * aDefaultAppRegKey, const char * aProtocol, const char * aProtocolEntryValue, const char * aCmdLineText)
-{
-    nsCAutoString keyName;
-    keyName = aDefaultAppRegKey;
-    keyName.Append(aProtocol);
-
-    nsCAutoString temp;
-    temp = aProtocolEntryValue;  // XXX this is bogus. SetRegistryKey should not require a char *..it should take a const char *
-
-    // Protocols\<proto scheme> default value (i.e. URL:News Protocol)
-    nsresult rv = SetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", (char *) temp.get());
-
-    SetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "URL Protocol", "");
-
-
-    if (NS_SUCCEEDED(rv))
-    {
-      // Protocols\<protocol scheme>\shell\open\command value
-      nsCAutoString appPath (thisApplication());
-
-      appPath += " ";
-      if (aCmdLineText)
-      {
-        appPath += aCmdLineText;
-        appPath += " ";
-      }
-
-      appPath += "%1";
-      nsCAutoString shellOpenKey (keyName);
-      shellOpenKey.AppendLiteral("\\shell\\open\\command");
-
-      rv = SetRegistryKey(HKEY_LOCAL_MACHINE, shellOpenKey.get(), "", (char *)appPath.get());
-
-      // Protocols\<protocol scheme>\DefaultIcon value
-      nsCAutoString iconPath(thisApplication());
-      iconPath += ",0";
-      nsCAutoString iconKey (keyName);
-      iconKey.AppendLiteral("\\DefaultIcon");
-      rv = SetRegistryKey(HKEY_LOCAL_MACHINE, iconKey.get(),"", (char *)iconPath.get());
-    }
-
-    return rv;
-}
-
-nsresult nsMapiRegistryUtils::registerMailApp(PRBool aForceRegistration)
-{
-    nsCAutoString keyName("Software\\Clients\\Mail\\");
-    nsCAutoString appName;
-    NS_CopyUnicodeToNative(vendorName(), appName);
-    nsresult rv = NS_OK;
-
-    if (mRestrictedRegAccess)
-      return NS_ERROR_FAILURE;
-
-    // Be SMART! If we have already set these keys up, don't do it again. Check the registeredAsNewsApp flag
-    // that we stored in our desktop registry scratchpad
-    nsCAutoString registeredAsMailApp;
-    GetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "registeredAsMailApp", registeredAsMailApp);
-
-    if (!aForceRegistration && registeredAsMailApp.Equals("1"))
-        return NS_OK;
-
-    // (1) Add our app to the list of keys under Software\\Clients\\Mail so we show up as a possible News application
-    if (!appName.IsEmpty()) {
-        keyName.Append(appName.get());
-
-        nsCOMPtr<nsIStringBundle> bundle;
-        rv = MakeMapiStringBundle (getter_AddRefs (bundle)) ;
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-
-        nsString defaultMailTitle;
-        // Use vendorName instead of brandname since brandName is product name
-        // and has more than just the name of the application
-        const PRUnichar *keyValuePrefixStr[] = { vendorName().get() };
-        NS_NAMED_LITERAL_STRING(defaultMailTitleTag, "defaultMailDisplayTitle");
-        rv = bundle->FormatStringFromName(defaultMailTitleTag.get(), keyValuePrefixStr, 1, getter_Copies(defaultMailTitle));
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-
-        nsCAutoString nativeTitle;
-        NS_CopyUnicodeToNative(defaultMailTitle, nativeTitle);
-        rv = SetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", const_cast<char *>(nativeTitle.get()) );
-    }
-    else
-        rv = NS_ERROR_FAILURE;
-
-    if (NS_SUCCEEDED(rv)) {
-        nsCAutoString thisApp (thisApplication()) ;
-        nsCAutoString dllPath (thisApp) ;
-        char* pathSep = (char *) _mbsrchr((const unsigned char *) thisApp.get(), '\\');
-        if (pathSep)
-            dllPath.Truncate(pathSep - thisApp.get() + 1);
-        dllPath += "mozMapi32.dll";
-
-        // (2) set the DllPath attribute on our new entry for MAPI
-        SetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "DLLPath", (char *)dllPath.get());
-
-        // (3) now that we have added Software\\Clients\\Mail\\<app name> add subkeys for each protocol mail supports
-        setupDefaultProtocolKey(nsCString(keyName + NS_LITERAL_CSTRING("\\Protocols\\")).get(), "mailto", "URL:MailTo Protocol", "-compose");
-
-
-        setupFileExtension("Software\\Classes\\", ".eml");
-
-        // (4) Software\Clients\News\<app name>\shell\open\command value
-        nsCAutoString appKeyName;
-        appKeyName.Assign(keyName);
-        appKeyName.AppendLiteral("\\shell\\open\\command");
-        nsCAutoString mailAppPath(thisApp);
-        mailAppPath += " -mail";
-        SetRegistryKey(HKEY_LOCAL_MACHINE, appKeyName.get(), "", (char *)mailAppPath.get());
-
-        // (5) Add a properties key that launches our options chrome
-#ifdef MOZ_THUNDERBIRD
-        appKeyName.Assign(keyName);
-        appKeyName.AppendLiteral("\\shell\\properties\\command");
-        nsCAutoString optionsPath(thisApp);
-        optionsPath += " -options";
-        SetRegistryKey(HKEY_LOCAL_MACHINE, appKeyName.get(), "", (char *)optionsPath.get());
-
-        nsCOMPtr<nsIStringBundle> bundle;
-        rv = MakeMapiStringBundle (getter_AddRefs (bundle));
-        if (bundle)
-        {
-          appKeyName.Assign(keyName);
-          appKeyName.AppendLiteral("\\shell\\properties");
-
-          nsString brandShortName;
-          getVarValue(NS_LITERAL_STRING("brandShortName").get(), brandShortName);
-
-          const PRUnichar* brandNameStrings[] = { brandShortName.get() };
-
-          nsString optionsTitle;
-          bundle->FormatStringFromName(NS_LITERAL_STRING("optionsLabel").get(),
-                                       brandNameStrings, 1, getter_Copies(optionsTitle));
-          nsCAutoString nativeOptionsTitle;
-          NS_CopyUnicodeToNative(optionsTitle, nativeOptionsTitle);
-          SetRegistryKey(HKEY_LOCAL_MACHINE, appKeyName.get(), "", (char *) nativeOptionsTitle.get());
-        }
-#endif
-
-        // (5) add a default icon entry to Software\\Clients\\Mail\\<app name>
-        nsCAutoString iconPath(thisApp);
-        iconPath += ",0";
-        nsCAutoString iconKeyName (keyName);
-        iconKeyName.AppendLiteral("\\DefaultIcon");
-        SetRegistryKey(HKEY_LOCAL_MACHINE, iconKeyName.get(),"", (char *)iconPath.get());
-
-        // if we got this far, set a flag in the registry so we know we have registered ourself as a default mail application
-        SetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "registeredAsMailApp", "1");
-    }
-
-    return rv;
-}
-
-nsresult nsMapiRegistryUtils::registerNewsApp(PRBool aForceRegistration)
-{
-    nsresult rv = NS_OK;
-    nsCAutoString keyName("Software\\Clients\\News\\");
-    nsCAutoString appName;
-    NS_CopyUnicodeToNative(vendorName(), appName);
-
-    // Be SMART! If we have already set these keys up, don't do it again. Check the registeredAsNewsApp flag
-    // that we stored in our desktop registry scratchpad
-    nsCAutoString registeredAsNewsApp;
-    GetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "registeredAsNewsApp", registeredAsNewsApp);
-
-    if (!aForceRegistration && registeredAsNewsApp.Equals("1"))
-        return NS_OK;
-
-    // (1) Add our app to the list of keys under Software\\Clients\\News so we show up as a possible News application
-    if (!appName.IsEmpty()) {
-        keyName.Append(appName.get());
-
-        nsCOMPtr<nsIStringBundle> bundle;
-        rv = MakeMapiStringBundle (getter_AddRefs (bundle)) ;
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-
-        nsString defaultMailTitle;
-        // Use vendorName instead of brandname since brandName is product name
-        // and has more than just the name of the application
-        const PRUnichar *keyValuePrefixStr[] = { vendorName().get() };
-        NS_NAMED_LITERAL_STRING(defaultMailTitleTag, "defaultMailDisplayTitle");
-        rv = bundle->FormatStringFromName(defaultMailTitleTag.get(),
-                                      keyValuePrefixStr, 1,
-                                      getter_Copies(defaultMailTitle));
-        if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-        nsCAutoString nativeTitle;
-        NS_CopyUnicodeToNative(defaultMailTitle, nativeTitle);
-
-        rv = SetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", const_cast<char *>(nativeTitle.get()) );
-    }
-    else
-        rv = NS_ERROR_FAILURE;
-
-    if (NS_SUCCEEDED(rv)) {
-        nsCAutoString thisApp (thisApplication());
-        if (NS_SUCCEEDED(rv)) {
-
-            // (3) now that we have added Software\\Clients\\News\\<app name>
-            //     add subkeys for each protocol news supports
-            nsCString protocolKeyName(keyName + NS_LITERAL_CSTRING("\\Protocols\\"));
-            setupDefaultProtocolKey(protocolKeyName.get(), "news", "URL:News Protocol", "-mail");
-            setupDefaultProtocolKey(protocolKeyName.get(), "nntp", "URL:NNTP Protocol", "-mail");
-            setupDefaultProtocolKey(protocolKeyName.get(), "snews", "URL:Snews Protocol", "-mail");
-
-            // (4) Software\Clients\News\<app name>\shell\open\command value
-            nsCAutoString appKeyName;
-            appKeyName.Assign(keyName);
-            appKeyName.AppendLiteral("\\shell\\open\\command");
-            rv = SetRegistryKey(HKEY_LOCAL_MACHINE, appKeyName.get(), "", (char *)thisApp.get());
-
-            // (5) add a default icon entry to Software\\Clients\\News\\<app name>
-                if (NS_SUCCEEDED(rv)) {
-                    nsCAutoString iconPath(thisApp);
-                    iconPath += ",0";
-                 nsCAutoString iconKeyName (keyName);
-                    iconKeyName.AppendLiteral("\\DefaultIcon");
-                 rv = SetRegistryKey(HKEY_LOCAL_MACHINE, iconKeyName.get(),"", (char *)iconPath.get());
-                }
-            }
-
-        // if we got this far, set a flag in the registry so we know we have registered ourself as a default news application
-        SetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "registeredAsNewsApp", "1");
-                }
-
-    return rv;
-}
-
-/** Sets Mozilla as the default News Client
- */
-nsresult nsMapiRegistryUtils::setDefaultNewsClient()
-{
-    nsresult rv;
-    nsresult mailKeySet=NS_ERROR_FAILURE;
-
-    if (mRestrictedRegAccess)
-      return NS_ERROR_FAILURE;
-
-    rv = saveDefaultNewsClient();
-
-    if (NS_FAILED(saveUserDefaultNewsClient()) || NS_FAILED(rv))
-      return NS_ERROR_FAILURE;
-
-    // make sure we have already registered ourself as a potential news application with the OS:
-    registerNewsApp(PR_TRUE);
-
-    // give Software\Clients\News a default value of our application name.
-    nsCAutoString appName;
-    NS_CopyUnicodeToNative(vendorName(), appName);
-
-    SetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\News", "", (char *)appName.get());
-
-    // delete the existing news related protocol keys from HKEY_LOCAL_MACHINE\Classes
-    recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\news");
-    recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\nntp");
-    recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\snews");
-
-    // copy our protocol handlers out to HKEY_LOCAL_MACHINE\Classes\<protocol>
-    nsCAutoString keyName("Software\\Clients\\News\\");
-    keyName.Append(appName);
-    keyName.AppendLiteral("\\Protocols\\");
-
-    rv = setProtocolHandler(keyName.get(), "news");
-    rv = setProtocolHandler(keyName.get(), "snews");
-    rv = setProtocolHandler(keyName.get(), "nntp");
-
-    rv = SetRegistryKey(HKEY_CURRENT_USER, "Software\\Clients\\News", "", (char *)appName.get());
-
-    // send out a system notifcation to let everyone know the default news client has changed
-    ::SendMessageTimeout( HWND_BROADCAST,
-                          WM_SETTINGCHANGE,
-                          0,
-                          (LPARAM)MOZ_CLIENT_NEWS_KEY,
-                          SMTO_NORMAL|SMTO_ABORTIFHUNG,
-                          MOZ_HWND_BROADCAST_MSG_TIMEOUT,
-                          NULL);
-    return rv;
-}
-
-nsresult nsMapiRegistryUtils::setDefaultFeedClient()
-{
-    return setupDefaultProtocolKey("Software\\Classes\\", "feed", "URL:Feed Protocol", "-mail");
-}
-
-nsresult nsMapiRegistryUtils::unsetDefaultFeedClient()
-{
-    // delete the existing mail related protocol keys from HKEY_LOCAL_MACHINE\Software\Classes
-    return recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\feed");
-}
-
-PRBool nsMapiRegistryUtils::IsDefaultFeedClient()
-{
-    //first try to get the users default news client
-    nsCAutoString result;
-    GetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\feed\\shell\\open\\command", "", result);
-
-    if (!result.IsEmpty()) {
-       nsCAutoString strExtension;
-       strExtension.Assign(EXE_EXTENSION);
-       ToUpperCase(result);
-       PRInt32 index = result.RFind(strExtension.get());
-       if (index != kNotFound)
-           result.Truncate(index + strExtension.Length());
-
-       nsCAutoString thisApp (thisApplication()) ;
-       return (result == thisApp);
-    }
-
-    return PR_FALSE;
-}
-
-/** Sets Mozilla as default Mail Client
- */
-nsresult nsMapiRegistryUtils::setDefaultMailClient()
-{
-  nsresult rv = NS_OK;
-  if (mRestrictedRegAccess)
-    return NS_ERROR_FAILURE;
-
-  if (!isSmartDll()) {
-    if (NS_FAILED(CopyMozMapiToWinSysDir()))
-      return NS_ERROR_FAILURE;
-  }
-
-  rv = saveDefaultMailClient();
-  if (NS_SUCCEEDED(rv))
-    rv = saveUserDefaultMailClient();
-
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // make sure we have already registered ourself as a potential mail application with the OS:
-  registerMailApp(PR_TRUE);
-
-  // give Software\Clients\Mail a default value of our application name.
-  nsCAutoString appName;
-  NS_CopyUnicodeToNative(vendorName(), appName);
-  SetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\Mail", "", (char *)appName.get());
-
-  // if we succeeded in setting ourselves as the default mapi client, then
-  // make sure we also set ourselves as the mailto protocol handler for the user...
-  nsCAutoString keyName("Software\\Clients\\Mail\\");
-  keyName.Append(appName);
-  keyName.AppendLiteral("\\Protocols\\");
-
-  // delete the existing mail related protocol keys from HKEY_LOCAL_MACHINE\Software\Classes
-  recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\mailto");
-  rv = setProtocolHandler(keyName.get(), "mailto");
-
-  rv = SetRegistryKey(HKEY_CURRENT_USER, "Software\\Clients\\Mail", "", (char *)appName.get());
-
-  // We are now the default mail client so set defaultMailHasBeenSet
-  if (NS_SUCCEEDED(rv))
-    rv = SetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "defaultMailHasBeenSet", "1");
-
-  // now notify anyone listening that there is a new default mail client in town
-  ::SendMessageTimeout( HWND_BROADCAST,
-                        WM_SETTINGCHANGE,
-                        0,
-                        (LPARAM)MOZ_CLIENT_MAIL_KEY,
-                        SMTO_NORMAL|SMTO_ABORTIFHUNG,
-                        MOZ_HWND_BROADCAST_MSG_TIMEOUT,
-                        NULL);
-
-  // Tell the MAPI Service to register the mapi proxy dll now that we are the default mail application
-  nsCOMPtr<nsIMapiSupport> mapiService (do_GetService(NS_IMAPISUPPORT_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-  return mapiService->RegisterServer();
-}
-
-nsresult nsMapiRegistryUtils::unsetDefaultNewsClient() {
-  nsresult rv = NS_OK;
-  nsresult mailKeySet = NS_ERROR_FAILURE;
-
-  if (mRestrictedRegAccess)
-    return NS_ERROR_FAILURE;
-
-  nsCAutoString name ;
-
-  // get the name of the default news client
-  GetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "HKEY_LOCAL_MACHINE\\Software\\Clients\\News", name);
-
-  // Use vendorName instead of brandname since brandName is product name
-  // and has more than just the name of the application
-  nsCAutoString appName;
-  NS_CopyUnicodeToNative(vendorName(), appName);
-
-  // if we are the current default client....
-  if (!name.IsEmpty() && !appName.IsEmpty() && name.Equals(appName))
-  {
-    // XXX Do we need to do anything here? Maybe we want to clear out name. If we were the previous default news client
-    // and the user is trying to unset us as the current default news client, we probably don't want to re-store ourselves
-    // again?
-
-    name = "";
-  }
-
-  // delete the protocol keys we copied to HKEY_LOCAL_MACHINE\Classes when we were made the default news application
-
-  recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\news");
-  recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\nntp");
-  recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\snews");
-
-  // set HKEY_LOCAL_MACHINE\Software\Clients\News
-  if (!name.IsEmpty())
-  {
-    mailKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\News", "", (char *)name.get());
-
-    // copy the protocol handlers for the original default news app out to HKEY_LOCAL_MACHINE\Classes\<protocol>
-    nsCAutoString keyName("Software\\Clients\\News\\");
-    keyName.Append(name);
-    keyName.AppendLiteral("\\Protocols\\");
-
-    rv = setProtocolHandler(keyName.get(), "news");
-    rv = setProtocolHandler(keyName.get(), "snews");
-    rv = setProtocolHandler(keyName.get(), "nntp");
-  }
-  else
-    mailKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\News","", "");
-
-  // change HKEY_CURRENT_USER\\Software\\Clients\\News
-  nsCAutoString userAppName ;
-  GetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "HKEY_CURRENT_USER\\Software\\Clients\\News", userAppName);
-
-  if (!userAppName.IsEmpty())
-    SetRegistryKey(HKEY_CURRENT_USER, "Software\\Clients\\News", "", (char *)userAppName.get());
-  else
-    DeleteRegistryValue(HKEY_CURRENT_USER, "Software\\Clients\\News", "");
-
-
-   // send out a system notifcation to let everyone know the default news client has changed
-  ::SendMessageTimeout( HWND_BROADCAST,
-                        WM_SETTINGCHANGE,
-                        0,
-                        (LPARAM)MOZ_CLIENT_NEWS_KEY,
-                        SMTO_NORMAL|SMTO_ABORTIFHUNG,
-                        MOZ_HWND_BROADCAST_MSG_TIMEOUT,
-                        NULL);
-  return mailKeySet;
-}
-
-/** Removes Mozilla as the default Mail client and restores the previous setting
- */
-nsresult nsMapiRegistryUtils::unsetDefaultMailClient() {
-  nsresult result = NS_OK;
-  nsresult mailKeySet = NS_ERROR_FAILURE;
-
-  if (mRestrictedRegAccess)
-    return NS_ERROR_FAILURE;
-
-  if (!isSmartDll())
-  {
-    result = RestoreBackedUpMapiDll();
-    NS_ENSURE_SUCCESS(result, result);
-  }
-
-  nsCAutoString name ;
-  GetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail", name);
-
-  // Use vendorName instead of brandname since brandName is product name
-  // and has more than just the name of the application
-  nsCAutoString appName;
-  NS_CopyUnicodeToNative(vendorName(), appName);
-
-  if (!name.IsEmpty() && !appName.IsEmpty() && name.Equals(appName)) {
-    nsCAutoString keyName("HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\");
-    keyName.Append(appName.get());
-    keyName.AppendLiteral("\\Protocols\\mailto\\shell\\open\\command");
-    nsCAutoString appPath ;
-    GetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, keyName.get(), appPath);
-    if (!appPath.IsEmpty()) {
-      keyName.Assign("Software\\Clients\\Mail\\");
-      keyName.Append(appName.get());
-      keyName.AppendLiteral("\\Protocols\\mailto\\shell\\open\\command");
-      result = SetRegistryKey(HKEY_LOCAL_MACHINE,
-                 keyName.get(),
-                 "", (char *)appPath.get());
-      if (NS_SUCCEEDED(result)) {
-        char* pathSep = (char *)
-            _mbsrchr((const unsigned char *) appPath.get(), '\\');
-        if (pathSep)
-            appPath.Truncate(pathSep - appPath.get() + 1);
-        appPath += "mozMapi32.dll";
-        keyName.Assign("Software\\Clients\\Mail\\");
-        keyName.Append(appName.get());
-        result = SetRegistryKey(HKEY_LOCAL_MACHINE,
-                                keyName.get(),
-                                "DLLPath", (char *) appPath.get());
-      }
-    }
-  }
-
-  recursiveDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Classes\\mailto");
-
-  if (!name.IsEmpty())  // Restore the previous default app for Software\Clients\Mail
-  {
-    // copy the protocol handlers for the original default mail app out to HKEY_LOCAL_MACHINE\Classes\<protocol>
-
-    nsCAutoString keyName("Software\\Clients\\Mail\\");
-    keyName.Append(name);
-    keyName.AppendLiteral("\\Protocols\\");
-    setProtocolHandler(keyName.get(), "mailto");
-
-    mailKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\Mail", "", (char *)name.get());
-  }
-  else
-    mailKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\Mail", "", "");
-
-  // change HKEY_CURRENT_USER\\Software\\Clients\\Mail
-  nsCAutoString userAppName ;
-  GetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey, "HKEY_CURRENT_USER\\Software\\Clients\\Mail", userAppName);
-
-  restoreFileExtension("Software\\Classes\\", ".eml");
-
-  if (!userAppName.IsEmpty())
-    SetRegistryKey(HKEY_CURRENT_USER, "Software\\Clients\\Mail", "", (char *)userAppName.get());
-  else
-    DeleteRegistryValue(HKEY_CURRENT_USER, "Software\\Clients\\Mail", "");
-
-  SetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey,"defaultMailHasBeenSet", "0");
-
-  ::SendMessageTimeout( HWND_BROADCAST,
-                        WM_SETTINGCHANGE,
-                        0,
-                        (LPARAM)MOZ_CLIENT_MAIL_KEY,
-                        SMTO_NORMAL|SMTO_ABORTIFHUNG,
-                        MOZ_HWND_BROADCAST_MSG_TIMEOUT,
-                        NULL);
-  // Tell the MAPI Service to unregister the mapi proxy dll now that we are the default mail application
-  nsCOMPtr<nsIMapiSupport> mapiService (do_GetService(NS_IMAPISUPPORT_CONTRACTID, &result));
-  NS_ENSURE_SUCCESS(result, result);
-  mapiService->UnRegisterServer();
-  return mailKeySet;
-}
-
-/** Returns FALSE if showMapiDialog is set to 0.
- *  Returns TRUE otherwise
- *  Also returns TRUE if the Mozilla has been set as the default mail client
- *  and some other application has changed that setting.
- *  This function gets called only if the current app is not the default mail
- *  client
- */
-PRBool nsMapiRegistryUtils::getShowDialog() {
-  PRBool rv = PR_FALSE;
-  nsCAutoString showDialog ;
-  GetRegistryKey(HKEY_LOCAL_MACHINE, kAppDesktopKey,
-                                      "showMapiDialog", showDialog);
-  // if the user has not selected the checkbox, show dialog
-  if (showDialog.IsEmpty() || showDialog.Equals("1"))
-    rv = PR_TRUE;
-
-  if (!rv)
-  {
-    // even if the user has selected the checkbox
-    // show it if some other application has changed the
-    // default setting.
-    nsCAutoString setMailDefault ;
-    GetRegistryKey(HKEY_LOCAL_MACHINE,kAppDesktopKey,
-                                   "defaultMailHasBeenSet", setMailDefault);
-    if (setMailDefault.Equals("1"))
-    {
-      // need to reset the defaultMailHasBeenSet to "0"
-      // so that after the dialog is displayed once,
-      // we do not keep displaying this dialog after the user has
-      // selected the checkbox
-      rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
-                          kAppDesktopKey,
-                          "defaultMailHasBeenSet", "0");
-      rv = PR_TRUE;
-    }
-  }
-  return rv;
-}
-
-nsresult nsMapiRegistryUtils::MakeMapiStringBundle(nsIStringBundle ** aMapiStringBundle)
-{
-  nsresult rv;
-
-  if (m_mapiStringBundle)
-  {
-    NS_ADDREF(*aMapiStringBundle = m_mapiStringBundle);
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = bundleService->CreateBundle(MAPI_PROPERTIES_CHROME, getter_AddRefs(m_mapiStringBundle));
-  NS_ENSURE_SUCCESS(rv, rv);
-  NS_ADDREF(*aMapiStringBundle = m_mapiStringBundle) ;
-  return rv ;
-}
-
-nsresult nsMapiRegistryUtils::ShowMapiErrorDialog(PRBool aForMail)
-{
-  nsresult rv;
-  nsCOMPtr<nsIPromptService> promptService(do_GetService(NS_PROMPTSERVICE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIStringBundle> bundle;
-  rv = MakeMapiStringBundle (getter_AddRefs (bundle)) ;
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsString dialogTitle;
-  const PRUnichar *brandStrings[] = { brandName() };
-  NS_NAMED_LITERAL_STRING(dialogTitlePropertyTag, "errorMessageTitle");
-  rv = bundle->FormatStringFromName(dialogTitlePropertyTag.get(),
-                                    brandStrings, 1,
-                                    getter_Copies(dialogTitle));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsString dialogText;
-
-  NS_NAMED_LITERAL_STRING(dialogTextPropertyTag, "errorMessage");
-  NS_NAMED_LITERAL_STRING(dialogTextPropertyTagForNews, "errorMessageNews");
-
-  rv = bundle->FormatStringFromName(aForMail ? dialogTextPropertyTag.get() : dialogTextPropertyTagForNews.get(),
-                                    brandStrings, 1,
-                                    getter_Copies(dialogText));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return promptService->Alert(nsnull, dialogTitle.get(), dialogText.get());
-}
deleted file mode 100644
--- a/mailnews/mapi/mapihook/src/nsMapiRegistryUtils.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Srilatha Moturi <srilatha@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/***************************************************************************
-*
-* This File is no longer used by Thunderbird. Seamonkey is the only consumer.
-* See mozilla/mail/components/shell for the Thunderbird registry code
-*
-*****************************************************************************/
-
-#ifndef nsmapiregistryutils_h____
-#define nsmapiregistryutils_h____
-
-#include <windows.h>
-#include <string.h>
-#include <winreg.h>
-
-#include "nsString.h"
-#include "nsIStringBundle.h"
-
-#ifndef MOZ_THUNDERBIRD
-#define kAppDesktopKey "Software\\Mozilla\\Desktop"
-#else
-#define kAppDesktopKey "Software\\Mozilla Thunderbird\\Desktop"
-#endif
-
-class nsMapiRegistryUtils
-{
-private :
-    nsCString m_thisApp;
-    nsString m_brand;
-    nsString m_vendor;
-
-    nsCOMPtr<nsIStringBundle> m_mapiStringBundle ;
-
-    // sets result to the value of varName (as defined in brand.properties)
-    void getVarValue(const PRUnichar * varName, nsString & result);
-
-    // verifyRestrictedAccess - Returns PR_TRUE if this user only has restricted access
-    // to the registry keys we need to modify. Consumers should call the public method 
-    PRBool verifyRestrictedAccess() ;
-
-    PRBool mRestrictedRegAccess; // cannot write to HKLM in the registry
-
-    static void RegCopyKey(HKEY aSrcKey, HKEY aDestKey, const char* aSubKeyName); // recursively copies the given sub key from the src key to the dest key
-    nsresult recursiveDeleteKey(HKEY hKeyParent, const char* lpszKeyChild);
-
-public :
-    nsMapiRegistryUtils() ;
-
-    // returns TRUE if the Mapi32.dll is smart dll.
-    PRBool isSmartDll();
-    // returns TRUE if the Mapi32.dll is a Mozilla dll.
-    PRBool isMozDll();
-
-    PRBool HasRestrictedRegistryAccess() { return mRestrictedRegAccess; }
-
-    // Returns the (fully-qualified) name of this executable.
-    const char * thisApplication() ; 
-    // This returns the brand name for this application
-    const PRUnichar * brandName() ;
-    // This returns the vendor name of this application
-    const nsString& vendorName();
-
-    // set the Windows registry key
-    nsresult SetRegistryKey(HKEY baseKey, const char * keyName, 
-                        const char * valueName, char * value);
-    // delete a registry key
-    nsresult DeleteRegistryValue(HKEY baseKey, const char * keyName, const char * valueName);
-
-    // get a Windows registry key
-    void GetRegistryKey(HKEY baseKey, const char * keyName, const char * valueName, nsCAutoString & value);
-
-    // Returns TRUE if the current application is default mail client.
-    PRBool IsDefaultMailClient();
-    nsresult setDefaultMailClient(); // Sets Mozilla as default Mail Client
-    nsresult unsetDefaultMailClient(); // Removes Mozilla as the default Mail client and restores the previous setting
-    nsresult saveDefaultMailClient(); // Save default mail client settings in HKEY_LOCAL_MACHINE\\Software\\Mozilla\\Desktop   
-    nsresult saveUserDefaultMailClient(); // save default 
-    PRBool IsDefaultFeedClient();
-    nsresult setDefaultFeedClient();
-    nsresult unsetDefaultFeedClient();
-       
-    PRBool IsDefaultNewsClient();      // Returns TRUE if the current application is default news client.  
-    nsresult setDefaultNewsClient();   // Sets Mozilla as the default News Client    
-    nsresult unsetDefaultNewsClient(); // Removes Mozilla as the default Mail client and restores the previous setting    
-    nsresult saveDefaultNewsClient();  // Saves the current setting of the default News Client in HKEY_LOCAL_MACHINE\\Software\\Mozilla\\Desktop
-    nsresult saveUserDefaultNewsClient();
-
-    nsresult setupDefaultProtocolKey(const char * aDefaultAppRegKey, const char * aProtocol, const char * aProtocolEntryValue, const char * aCmdLineParam); 
-    nsresult setProtocolHandler(const char * aDefaultAppRegKey, const char * protocolName); // installs protocol handler on Software\Classes\<protocolName>
-
-    nsresult setupFileExtension(const char * aDefaultAppRegKey, const char * aExtension);
-    nsresult restoreFileExtension(const char * aDefaultAppRegKey, const char * aExtension);
-
-    nsresult registerNewsApp(PRBool aForceRegistration); // aForceRegistration set to TRUE if we want to force the keys to be set again
-    nsresult registerMailApp(PRBool aForceRegistration);
-
-    nsresult CopyMozMapiToWinSysDir();
-    nsresult RestoreBackedUpMapiDll();
-
-    // Returns FALSE if showMapiDialog is set to 0.
-    PRBool getShowDialog() ;
-
-    // create a string bundle for MAPI messages
-    nsresult MakeMapiStringBundle(nsIStringBundle ** aMapiStringBundle) ;
-    // display an error dialog for MAPI messages
-    nsresult ShowMapiErrorDialog(PRBool aForMail); // set to false if showing a news error
-} ;
-
-#endif
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -2044,34 +2044,38 @@ function URLBarMouseDownHandler(aEvent)
 
 function URLBarClickHandler(aEvent)
 {
   if (!gIgnoreClick && gClickSelectsAll && gURLBar.selectionStart == gURLBar.selectionEnd)
     if (gClickAtEndSelects || gURLBar.selectionStart < gURLBar.value.length)
       gURLBar.select();
 }
 
-// This function gets the "windows hooks" service and has it check its setting
-// This will do nothing on platforms other than Windows.
+// This function gets the shell service and has it check its setting
+// This will do nothing on platforms without a shell service.
 function checkForDefaultBrowser()
 {
-  const NS_WINHOOKS_CONTRACTID = "@mozilla.org/winhooks;1";
-  var dialogShown = false;
-  if (NS_WINHOOKS_CONTRACTID in Components.classes) {
-    try {
-      dialogShown = Components.classes[NS_WINHOOKS_CONTRACTID]
-                      .getService(Components.interfaces.nsIWindowsHooks)
-                      .checkSettings(window);
-    } catch(e) {
-    }
+  const NS_SHELLSERVICE_CID = "@mozilla.org/suite/shell-service;1";
+  
+  if (NS_SHELLSERVICE_CID in Components.classes) {
+    const nsIShellService = Components.interfaces.nsIShellService;
+    var shellService = Components.classes["@mozilla.org/suite/shell-service;1"]
+                                 .getService(nsIShellService);
+    var appTypes = shellService.shouldBeDefaultClientFor;
 
-    if (dialogShown)  
-    {
+    // show the default client dialog only if we should check for the default
+    // client and we aren't already the default for the stored app types in
+    // shell.checkDefaultApps
+    if (appTypes && shellService.shouldCheckDefaultClient &&
+        !shellService.isDefaultClient(true, appTypes)) {
+      window.openDialog("chrome://communicator/content/defaultClientDialog.xul",
+                        "DefaultClient",
+                        "modal,centerscreen,chrome,resizable=no"); 
       // Force the sidebar to build since the windows 
-      // integration dialog may have come up.
+      // integration dialog has come up.
       SidebarRebuild();
     }
   }
 }
 
 function ShowAndSelectContentsOfURLBar()
 {
   var navBar = document.getElementById("nav-bar");
new file mode 100644
--- /dev/null
+++ b/suite/common/defaultClientDialog.js
@@ -0,0 +1,93 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Thunderbird Default Client Dialog
+ *
+ * The Initial Developer of the Original Code is
+ *   Scott MacGregor <mscott@mozilla.org>
+ * Portions created by the Initial Developer are Copyright (C) 2006
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Mark Banner <bugzilla@standard8.demon.co.uk>
+ *   Frank Wein <mcsmurf@mcsmurf.de>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// this dialog can only be opened if we have a shell service
+const nsIShellService = Components.interfaces.nsIShellService;
+const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
+
+function onLoad()
+{
+  var shellSvc = Components.classes["@mozilla.org/suite/shell-service;1"]
+                           .getService(nsIShellService);
+  var defaultList = document.getElementById("defaultList");
+  var appTypes = shellSvc.shouldBeDefaultClientFor;
+  /* Iterate through the list of possible default client types and check for
+     each list item if we want to be the default for that type using the AND
+     conjunction */
+  for (var i = 0; i < defaultList.getRowCount(); i++) {
+    var currentItem = defaultList.getItemAtIndex(i);
+    if (nsIShellService[currentItem.value] & appTypes)
+      currentItem.checked = true;
+
+    if (shellSvc.isDefaultClient(false, nsIShellService[currentItem.value]))
+      currentItem.disabled = true;
+  }
+}
+
+function onAccept()
+{
+  // for each checked item, if we aren't already the default, make us the default.
+  var shellSvc = Components.classes["@mozilla.org/suite/shell-service;1"]
+                           .getService(nsIShellService);
+  var pref = Components.classes["@mozilla.org/preferences-service;1"]
+                       .getService(nsIPrefBranch);
+  var appTypes = 0;
+  var appTypesCheck = 0;
+  var defaultList = document.getElementById("defaultList");
+
+  for (var i = 0; i < defaultList.getRowCount(); i++) {
+    var currentItem = defaultList.getItemAtIndex(i);
+    var currentAppType = nsIShellService[currentItem.value];
+    
+    if (currentItem.checked) {
+      appTypesCheck |= currentAppType;
+      
+      if (!currentItem.disabled)
+        appTypes |= currentAppType;
+    }
+  }
+ 
+  if (appTypes)
+    shellSvc.setDefaultClient(false, true, appTypes);
+
+  // Update the pref for which app types we should check if we are the default app
+  shellSvc.shouldBeDefaultClientFor = appTypesCheck;
+
+  shellSvc.shouldCheckDefaultClient = document.getElementById('checkOnStartup').checked;
+}
new file mode 100644
--- /dev/null
+++ b/suite/common/defaultClientDialog.xul
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Version: MPL 1.1/GPL 2.0/LGPL 2.1
+
+ The contents of this file are subject to the Mozilla Public License Version
+ 1.1 (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ for the specific language governing rights and limitations under the
+ License.
+
+ The Original Code is Thunderbird Default Client Dialog
+
+ The Initial Developer of the Original Code is
+ Scott MacGregor.
+ Portions created by the Initial Developer are Copyright (C) 2006
+ the Initial Developer. All Rights Reserved.
+
+ Contributor(s):
+   Scott MacGregor <mscott@mozilla.org>
+   Mark Banner <bugzilla@standard8.demon.co.uk>
+   Frank Wein <mcsmurf@mcsmurf.de>
+
+ Alternatively, the contents of this file may be used under the terms of
+ either of the GNU General Public License Version 2 or later (the "GPL"),
+ or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ in which case the provisions of the GPL or the LGPL are applicable instead
+ of those above. If you wish to allow use of your version of this file only
+ under the terms of either the GPL or the LGPL, and not to allow others to
+ use your version of this file under the terms of the MPL, indicate your
+ decision by deleting the provisions above and replace them with the notice
+ and other provisions required by the GPL or the LGPL. If you do not delete
+ the provisions above, a recipient may use your version of this file under
+ the terms of any one of the MPL, the GPL or the LGPL.
+
+ ***** END LICENSE BLOCK ***** -->
+
+<?xml-stylesheet href="chrome://global/skin/"?>
+
+<!DOCTYPE window [
+  <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
+  %brandDTD;
+  <!ENTITY % defaultClientDTD SYSTEM "chrome://communicator/locale/defaultClientDialog.dtd" >
+  %defaultClientDTD;
+]>
+
+<dialog xmlns:html="http://www.w3.org/1999/xhtml"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        id="defaultClientDialog"
+        buttons="accept,cancel"
+        onload="onLoad();"
+        ondialogaccept="return onAccept();"
+        title="&defaultClient.title;">
+  
+  <script type="application/x-javascript" src="chrome://communicator/content/defaultClientDialog.js"/>
+  
+  <description>&defaultClient.intro;</description>
+  <listbox rows="3" id="defaultList">
+    <listitem value="BROWSER" type="checkbox" label="&browser.label;"/>
+    <listitem value="MAIL" type="checkbox" label="&email.label;"/>
+    <listitem value="NEWS" type="checkbox" label="&newsgroups.label;"/>
+  </listbox>
+
+  <separator class="thin"/>
+  <checkbox id="checkOnStartup" checked="true" label="&checkOnStartup.label;" accesskey="&checkOnStartup.accesskey;"/>
+
+</dialog>
--- a/suite/common/jar.mn
+++ b/suite/common/jar.mn
@@ -49,16 +49,18 @@ comm.jar:
    content/communicator/askViewZoom.js
    content/communicator/browserBindings.xul
    content/communicator/communicator.css
    content/communicator/consoleOverlay.xul
    content/communicator/contentAreaUtils.js
    content/communicator/contentAreaDD.js
    content/communicator/contentAreaClick.js
    content/communicator/contentAreaContextOverlay.xul
+   content/communicator/defaultClientDialog.js
+   content/communicator/defaultClientDialog.xul
    content/communicator/editorBindings.xul
    content/communicator/findUtils.js
    content/communicator/helpEditorOverlay.xul
    content/communicator/helpMessengerOverlay.xul
    content/communicator/helpSecurityOverlay.xul
    content/communicator/helpOverlay.js
    content/communicator/helpOverlay.xul
 # the following file is a suite-specific override of the generic license.html, using suite/common/app-license.html as input:
--- a/suite/common/pref/pref-advanced.xul
+++ b/suite/common/pref/pref-advanced.xul
@@ -51,16 +51,19 @@
 
     <preferences id="advanced_preferences">
       <preference id="security.enable_java"
                   name="security.enable_java"
                   type="bool"/>
       <preference id="config.use_system_prefs"
                   name="config.use_system_prefs"
                   type="bool"/>
+      <preference id="shell.checkDefaultClient"
+                  name="shell.checkDefaultClient"
+                  type="bool"/>
     </preferences>
 
     <groupbox id="advancedSettings">
       <caption label="&prefEnableJava.caption;"/>
       <checkbox id="advancedJavaAllow"
                 label="&enbJavaCheck.label;"
                 accesskey="&enbJavaCheck.accesskey;"
                 preference="security.enable_java"/>
@@ -70,10 +73,18 @@
       <caption id="systemPrefCaption" label="&systemPref.caption;"/>
       <description>&systemPref.desc;</description>
       <checkbox id="systemPrefCheck"
                 label="&systemPrefCheck.label;"
                 accesskey="&systemPrefCheck.accesskey;"
                 preference="config.use_system_prefs"/>
     </groupbox>
 
+    <groupbox id="checkDefault">
+      <caption label="&prefCheckDefault.caption;"/>
+      <checkbox id="checkDefaultClient"
+                label="&prefCheckDefaultClient.label;"
+                accesskey="&prefCheckDefaultClient.accesskey;"
+                preference="shell.checkDefaultClient"/>
+    </groupbox>
+
   </prefpane>
 </overlay>
--- a/suite/common/pref/pref-navigator.js
+++ b/suite/common/pref/pref-navigator.js
@@ -290,125 +290,61 @@ function Startup()
   InitPlatformIntegration();
 }
 
 function SwitchPage(aIndex)
 {
   document.getElementById("behaviourDeck").selectedIndex = aIndex;
 }
 
-
 // platform integration
 
 function ApplySetAsDefaultBrowser()
 {
-  // In future, we will use the Shell Service here,
-  // for now, just use WinHooks.
-  window.gWinHooks.winhooks.settings = window.gWinHooks.prefs;
-}
+  const nsIShellService = Components.interfaces.nsIShellService;
+  var shellSvc = Components.classes["@mozilla.org/suite/shell-service;1"]
+                           .getService(nsIShellService);
+  var appTypes = shellSvc.shouldBeDefaultClientFor; 
 
-function UpdateDefaultBrowserGroup()
-{
-  // set description and button state according to integration setting
-  var state = window.gWinHooks.state;
-  var desc = document.getElementById("defaultBrowserDesc");
-  desc.textContent = desc.getAttribute("desc" + state);
-  document.getElementById("defaultBrowserButton").disabled = (state != PFINT_NOT_DEFAULT);
+  shellSvc.setDefaultClient(false, false, nsIShellService.BROWSER);
+
+  if (appTypes != (appTypes | nsIShellService.BROWSER))
+    shellSvc.shouldBeDefaultClientFor |= nsIShellService.BROWSER;
 }
 
 function InitPlatformIntegration()
 {
-  // In future, we will ask the Shell Service about platform integration here,
-  // for now, just check WinHooks.
-  var showDefaultBrowserGroup = /Win/.test(navigator.platform);
-  document.getElementById("defaultBrowserGroup").hidden = !showDefaultBrowserGroup;
-  if (!showDefaultBrowserGroup)
-    return;
-
-  // Determine if we have been selected as the default browser already, and
-  // enable/disable the "Set As Default" button accordingly.
-
-  // We store our state info in the same place as the code in pref-winhooks.js
-  // uses so that this panel and the Advanced/System panel are kept in sync.
-  if (!("gWinHooks" in window))
-  {
-    // Neither the Advanced/System panel nor this panel has appeared.
-    // Initialize the state information.
-    window.gWinHooks = {};
-
-    // Get winhooks service.
-    window.gWinHooks.winhooks = Components.classes["@mozilla.org/winhooks;1"]
-                                          .getService(Components.interfaces.nsIWindowsHooks);
-
-    // Extract current settings (these are what the user has checked on
-    // the Advanced/System panel).
-    window.gWinHooks.prefs = window.gWinHooks.winhooks.settings;
-  }
-  var winHooks = window.gWinHooks;
-  winHooks.state = PFINT_NOT_DEFAULT;
+  const NS_SHELLSERVICE_CID = "@mozilla.org/suite/shell-service;1";
 
-  // Start by checking http/https/ftp and html/xhtml/xml.
-  var prefs = winHooks.prefs;
-  if (prefs.isHandlingHTTP  &&
-      prefs.isHandlingHTTPS &&
-      prefs.isHandlingFTP   &&
-      prefs.isHandlingHTML  &&
-      prefs.isHandlingXHTML &&
-      prefs.isHandlingXML)
-  {
-    // The user *wants* us to be the default, so look if the registry matches.
-    // We test the registry settings using a scratch copy of the settings
-    // because we don't care about some of them, but we don't want to mess up
-    // the user's choices from the Advanced/System panel.
-    var testSettings = winHooks.winhooks.settings;
-    // Test that these are set.
-    testSettings.isHandlingHTTP   = true;
-    testSettings.isHandlingHTTPS  = true;
-    testSettings.isHandlingFTP    = true;
-    testSettings.isHandlingHTML   = true;
-    testSettings.isHandlingXHTML  = true;
-    testSettings.isHandlingXML    = true;
-    // Ignore the rest.
-    testSettings.isHandlingCHROME = false;
-    testSettings.isHandlingGOPHER = false;
-    testSettings.isHandlingJPEG   = false;
-    testSettings.isHandlingGIF    = false;
-    testSettings.isHandlingPNG    = false;
-    testSettings.isHandlingBMP    = false;
-    testSettings.isHandlingICO    = false;
-    testSettings.isHandlingXUL    = false;
-    // Now test whether the registry matches that.
-    if (testSettings.registryMatches)
-      winHooks.state = PFINT_DEFAULT;
+  if (NS_SHELLSERVICE_CID in Components.classes) {
+    const nsIShellService = Components.interfaces.nsIShellService;
+    var shellSvc = Components.classes["@mozilla.org/suite/shell-service;1"]
+                             .getService(nsIShellService);
+    var desc = document.getElementById("defaultBrowserDesc");
+    document.getElementById("defaultBrowserGroup").hidden = false;
+
+    if (shellSvc.isDefaultClient(false, nsIShellService.BROWSER))
+      desc.textContent = desc.getAttribute("desc1");
+    else {
+      desc.textContent = desc.getAttribute("desc0");
+      document.getElementById("defaultBrowserButton").disabled = false;
+    }
   }
-  UpdateDefaultBrowserGroup();
 }
 
 function SetAsDefaultBrowser()
 {
-  // In future, we will use the Shell Service here,
-  // for now, just process WinHooks.
-
-  // Extract current settings (these are what the
-  // user has checked on the Advanced/System panel).
-  var settings = window.gWinHooks.prefs;
-
-  // Turn on all "default browser" settings.
-  settings.isHandlingHTTP  = true;
-  settings.isHandlingHTTPS = true;
-  settings.isHandlingFTP   = true;
-  settings.isHandlingHTML  = true;
-  settings.isHandlingXHTML = true;
-  settings.isHandlingXML   = true;
+  document.getElementById("defaultBrowserButton").disabled = true;
 
   if (document.documentElement.instantApply)
   {
-    window.gWinHooks.state = PFINT_DEFAULT;
+    var desc = document.getElementById("defaultBrowserDesc"); 
+    desc.textContent = desc.getAttribute("desc1");
     ApplySetAsDefaultBrowser();
   }
   else
   {
     // register OK handler for the capturing phase
-    window.gWinHooks.state = PFINT_PENDING;
+    var desc = document.getElementById("defaultBrowserDesc");
+    desc.textContent = desc.getAttribute("desc2");
     window.addEventListener("dialogaccept", this.ApplySetAsDefaultBrowser, true);
   }
-  UpdateDefaultBrowserGroup();
 }
new file mode 100644
--- /dev/null
+++ b/suite/locales/en-US/chrome/common/defaultClientDialog.dtd
@@ -0,0 +1,9 @@
+<!ENTITY defaultClient.title  "Default Client">
+<!ENTITY defaultClient.intro  "Use &brandShortName; as the default client for:">
+
+<!ENTITY browser.label "Browser">
+<!ENTITY email.label "E-Mail">
+<!ENTITY newsgroups.label "Newsgroups">
+
+<!ENTITY checkOnStartup.label "Always perform this check when starting &brandShortName;">
+<!ENTITY checkOnStartup.accesskey "A">
--- a/suite/locales/en-US/chrome/common/pref/pref-advanced.dtd
+++ b/suite/locales/en-US/chrome/common/pref/pref-advanced.dtd
@@ -5,8 +5,12 @@
 
 <!ENTITY enbJavaCheck.label         "Enable Java">
 <!ENTITY enbJavaCheck.accesskey     "J">
 
 <!ENTITY systemPref.caption         "System Preferences">
 <!ENTITY systemPrefCheck.label      "Use Preferences from System">
 <!ENTITY systemPrefCheck.accesskey  "U">
 <!ENTITY systemPref.desc            "With this option, &brandShortName; inherits preferences from the system. These system settings will override the &brandShortName; preferences.">
+
+<!ENTITY prefCheckDefault.caption   "System Integration">
+<!ENTITY prefCheckDefaultClient.label "Check default application settings on startup">
+<!ENTITY prefCheckDefaultClient.accesskey "C">
--- a/suite/locales/jar.mn
+++ b/suite/locales/jar.mn
@@ -17,16 +17,17 @@
 % locale navigator-platform @AB_CD@ %locale/@AB_CD@/navigator-platform/
 % locale navigator-region @AB_CD@ %locale/@AB_CD@/navigator-region/
   locale/@AB_CD@/branding/brand.dtd                                         (%chrome/branding/brand.dtd)
   locale/@AB_CD@/branding/brand.properties                                  (%chrome/branding/brand.properties)
   locale/@AB_CD@/communicator/askViewZoom.dtd                               (%chrome/common/askViewZoom.dtd)
   locale/@AB_CD@/communicator/consoleOverlay.dtd                            (%chrome/common/consoleOverlay.dtd)
   locale/@AB_CD@/communicator/contentAreaCommands.dtd                       (%chrome/common/contentAreaCommands.dtd)
   locale/@AB_CD@/communicator/contentAreaCommands.properties                (%chrome/common/contentAreaCommands.properties)
+  locale/@AB_CD@/communicator/defaultClientDialog.dtd                       (%chrome/common/defaultClientDialog.dtd)
   locale/@AB_CD@/communicator/notification.properties                       (%chrome/common/notification.properties)
   locale/@AB_CD@/communicator/openLocation.dtd                              (%chrome/common/openLocation.dtd)
   locale/@AB_CD@/communicator/openLocation.properties                       (%chrome/common/openLocation.properties)
   locale/@AB_CD@/communicator/printPreview.dtd                              (%chrome/common/printPreview.dtd)
   locale/@AB_CD@/communicator/shellservice.properties                       (%chrome/common/shellservice.properties)
   locale/@AB_CD@/communicator/sanitize.dtd                                  (%chrome/common/sanitize.dtd)
   locale/@AB_CD@/communicator/tasksOverlay.dtd                              (%chrome/common/tasksOverlay.dtd)
   locale/@AB_CD@/communicator/typeaheadfind.properties                      (%chrome/common/typeaheadfind.properties)