From cd8438a43b9197d3aac09afc27e2d54fdda58f06 Mon Sep 17 00:00:00 2001 From: "mcsmurf%mcsmurf.de" Date: Sat, 19 Apr 2008 11:29:41 +0000 Subject: [PATCH] meh, Windows tinderbox seems to be stuck, backing out Bug 380347 git-svn-id: svn://10.0.0.236/trunk@250496 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/suite/Makefile.in | 1 - mozilla/suite/browser/browser-prefs.js | 2 - mozilla/suite/build/Makefile.in | 12 +- mozilla/suite/build/nsSuiteModule.cpp | 6 - mozilla/suite/installer/windows/packages | 2 - .../chrome/common/shellservice.properties | 3 - mozilla/suite/locales/jar.mn | 1 - mozilla/suite/makefiles.sh | 3 - mozilla/suite/shell/Makefile.in | 51 - mozilla/suite/shell/public/Makefile.in | 49 - .../suite/shell/public/nsIShellService.idl | 115 -- mozilla/suite/shell/src/Makefile.in | 39 - mozilla/suite/shell/src/nsSetDefault.js | 87 -- .../suite/shell/src/nsWindowsShellService.cpp | 1370 ----------------- .../suite/shell/src/nsWindowsShellService.h | 92 -- 15 files changed, 1 insertion(+), 1832 deletions(-) delete mode 100644 mozilla/suite/locales/en-US/chrome/common/shellservice.properties delete mode 100644 mozilla/suite/shell/Makefile.in delete mode 100644 mozilla/suite/shell/public/Makefile.in delete mode 100644 mozilla/suite/shell/public/nsIShellService.idl delete mode 100644 mozilla/suite/shell/src/Makefile.in delete mode 100644 mozilla/suite/shell/src/nsSetDefault.js delete mode 100644 mozilla/suite/shell/src/nsWindowsShellService.cpp delete mode 100644 mozilla/suite/shell/src/nsWindowsShellService.h diff --git a/mozilla/suite/Makefile.in b/mozilla/suite/Makefile.in index edda0021ff6..d462820e069 100644 --- a/mozilla/suite/Makefile.in +++ b/mozilla/suite/Makefile.in @@ -56,7 +56,6 @@ DIRS += \ modules \ themes \ profile \ - shell \ build \ app \ $(NULL) diff --git a/mozilla/suite/browser/browser-prefs.js b/mozilla/suite/browser/browser-prefs.js index 4c6a3350e82..35a6692afa6 100644 --- a/mozilla/suite/browser/browser-prefs.js +++ b/mozilla/suite/browser/browser-prefs.js @@ -247,8 +247,6 @@ pref("browser.feeds.handler", "ask"); pref("browser.videoFeeds.handler", "ask"); pref("browser.audioFeeds.handler", "ask"); -pref("shell.checkDefaultClient", true); - pref("app.releaseNotesURL", "chrome://branding/locale/brand.properties"); pref("app.vendorURL", "chrome://branding/locale/brand.properties"); diff --git a/mozilla/suite/build/Makefile.in b/mozilla/suite/build/Makefile.in index 1f57576a6ef..083c8219059 100644 --- a/mozilla/suite/build/Makefile.in +++ b/mozilla/suite/build/Makefile.in @@ -54,7 +54,6 @@ REQUIRES = \ necko \ nkcache \ rdf \ - shellservice \ string \ suitebrowser \ suitemigration \ @@ -67,26 +66,17 @@ CPPSRCS = \ nsSuiteModule.cpp \ $(NULL) -ifeq ($(OS_ARCH),WINNT) -OS_LIBS += $(call EXPAND_LIBNAME,ole32 shell32) -endif - LOCAL_INCLUDES += \ -I$(topsrcdir)/suite/profile \ -I$(topsrcdir)/suite/profile/migration/src \ -I$(topsrcdir)/suite/browser/src \ - -I$(topsrcdir)/suite/shell/src \ $(NULL) SHARED_LIBRARY_LIBS = \ ../profile/$(LIB_PREFIX)suiteprofile_s.$(LIB_SUFFIX) \ ../profile/migration/src/$(LIB_PREFIX)suitemigration_s.$(LIB_SUFFIX) \ ../browser/src/$(LIB_PREFIX)suitebrowser_s.$(LIB_SUFFIX) \ - $(NULL) - -ifeq ($(OS_ARCH),WINNT) -SHARED_LIBRARY_LIBS += ../shell/src/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX) -endif + $(NULL) # Link to gkgfx for GNOME shell service ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2) diff --git a/mozilla/suite/build/nsSuiteModule.cpp b/mozilla/suite/build/nsSuiteModule.cpp index 90c4b0d5306..cb4c894435a 100644 --- a/mozilla/suite/build/nsSuiteModule.cpp +++ b/mozilla/suite/build/nsSuiteModule.cpp @@ -49,14 +49,12 @@ #if defined(XP_WIN) #include "nsUrlWidget.h" -#include "nsWindowsShellService.h" #endif ///////////////////////////////////////////////////////////////////////////// #if defined(XP_WIN) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUrlWidget, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowsShellService, Init) #endif // Windows NS_GENERIC_FACTORY_CONSTRUCTOR(nsSuiteDirectoryProvider) NS_GENERIC_FACTORY_CONSTRUCTOR(nsProfileMigrator) @@ -72,10 +70,6 @@ static const nsModuleComponentInfo components[] = { #ifdef XP_WIN { NS_IURLWIDGET_CLASSNAME, NS_IURLWIDGET_CID, NS_IURLWIDGET_CONTRACTID, nsUrlWidgetConstructor }, - { "SeaMonkey Windows Integration", - NS_SUITEWININTEGRATION_CID, - NS_SUITEWININTEGRATION_CONTRACTID, - nsWindowsShellServiceConstructor }, #endif // XP_WIN { "nsSuiteDirectoryProvider", diff --git a/mozilla/suite/installer/windows/packages b/mozilla/suite/installer/windows/packages index eab2b81c384..cdcdc85b52f 100644 --- a/mozilla/suite/installer/windows/packages +++ b/mozilla/suite/installer/windows/packages @@ -191,7 +191,6 @@ bin\components\related.xpt bin\components\satchel.dll bin\components\satchel.xpt bin\components\saxparser.xpt -bin\components\shellservice.xpt bin\components\shistory.xpt bin\components\sidebar.xpt bin\components\signonviewer.xpt @@ -274,7 +273,6 @@ bin\components\nsLoginManagerPrompter.js bin\components\nsPostUpdateWin.js bin\components\nsProxyAutoConfig.js bin\components\nsResetPref.js -bin\components\nsSetDefault.js bin\components\nsSetDefaultBrowser.js bin\components\nsSidebar.js bin\components\nsSuiteGlue.js diff --git a/mozilla/suite/locales/en-US/chrome/common/shellservice.properties b/mozilla/suite/locales/en-US/chrome/common/shellservice.properties deleted file mode 100644 index 38cc7c2b0bd..00000000000 --- a/mozilla/suite/locales/en-US/chrome/common/shellservice.properties +++ /dev/null @@ -1,3 +0,0 @@ -preferencesLabel=%S &Preferences -safeModeLabel=%S &Safe Mode -desktopBackgroundLeafNameWin=Desktop Background.bmp diff --git a/mozilla/suite/locales/jar.mn b/mozilla/suite/locales/jar.mn index 4199d2750fe..76aa1ece500 100644 --- a/mozilla/suite/locales/jar.mn +++ b/mozilla/suite/locales/jar.mn @@ -26,7 +26,6 @@ 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) diff --git a/mozilla/suite/makefiles.sh b/mozilla/suite/makefiles.sh index 70947b5a762..c8e19a0f4f4 100755 --- a/mozilla/suite/makefiles.sh +++ b/mozilla/suite/makefiles.sh @@ -58,9 +58,6 @@ add_makefiles " suite/profile/migration/Makefile suite/profile/migration/public/Makefile suite/profile/migration/src/Makefile - suite/shell/Makefile - suite/shell/public/Makefile - suite/shell/src/Makefile suite/themes/Makefile suite/themes/modern/Makefile suite/themes/classic/Makefile diff --git a/mozilla/suite/shell/Makefile.in b/mozilla/suite/shell/Makefile.in deleted file mode 100644 index db76c78fd63..00000000000 --- a/mozilla/suite/shell/Makefile.in +++ /dev/null @@ -1,51 +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 the Mozilla Browser code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2002 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Brian Ryner -# -# Alternatively, the contents of this file may be used under the terms of -# either 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 ***** - -DEPTH = ../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DIRS = public - -ifeq ($(OS_ARCH),WINNT) -DIRS += src -endif - -include $(topsrcdir)/config/rules.mk diff --git a/mozilla/suite/shell/public/Makefile.in b/mozilla/suite/shell/public/Makefile.in deleted file mode 100644 index 3a3186bde4b..00000000000 --- a/mozilla/suite/shell/public/Makefile.in +++ /dev/null @@ -1,49 +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): -# -# Alternatively, the contents of this file may be used under the terms of -# either 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 ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = shellservice -XPIDL_MODULE = shellservice - -XPIDLSRCS = nsIShellService.idl - -include $(topsrcdir)/config/rules.mk diff --git a/mozilla/suite/shell/public/nsIShellService.idl b/mozilla/suite/shell/public/nsIShellService.idl deleted file mode 100644 index fb6a411f6df..00000000000 --- a/mozilla/suite/shell/public/nsIShellService.idl +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: IDL; 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 Shell Service. - * - * 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): - * - * Alternatively, the contents of this file may be used under the terms of - * either 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 ***** */ - - -#include "nsISupports.idl" - -interface nsIDOMElement; - -[scriptable, uuid(95F53544-F445-48d1-B3A2-D54AA020BC3D)] -interface nsIShellService : nsISupports -{ - /** - * app types we can be registered to handle - */ - const unsigned short BROWSER = 0x0001; - const unsigned short MAIL = 0x0002; - const unsigned short NEWS = 0x0004; - - /** - * Determines whether or not SeaMonkey is the "Default Client" for the - * passed in app type. - * - * This is simply whether or not SeaMonkey is registered to handle - * the url schemes associated with the app. - * - * @param aStartupCheck true if this is the check being performed - * by the first window at startup, - * false otherwise. - * @param aApps the application types being tested (Browser, Mail, News) - */ - boolean isDefaultClient(in boolean aStartupCheck, in unsigned short aApps); - - /** - * Registers SeaMonkey as the "Default Client" for the - * passed in app types. - * - * @param aForAllUsers Whether or not SeaMonkey should attempt - * to become the default client for all - * users on a multi-user system. - * @param aClaimAllTypes Register SeaMonkey as the handler for - * additional protocols (ftp, chrome etc) - * and web documents (.html, .xhtml etc). - * @param aApps the application types being tested (Mail, News, Browser) - */ - void setDefaultClient(in boolean aForAllUsers, in boolean aClaimAllTypes, in unsigned short aApps); - - /** - * Used to determine whether or not to show a "Set Default Client" - * query dialog. This attribute is true if the application is starting - * up and "shell.checkDefaultClient" is true, otherwise it - * is false. - */ - attribute boolean shouldCheckDefaultClient; - - - /** - * Sets the desktop background image using either the HTML - * element supplied or the background image of the element supplied. - * - * @param aImageElement Either a HTML element or an element with - * a background image from which to source the - * background image. - * @param aPosition How to place the image on the desktop - */ - - void setDesktopBackground(in nsIDOMElement aElement, in long aPosition); - - /** - * Flags for positioning/sizing of the Desktop Background image. - */ - const long BACKGROUND_TILE = 1; - const long BACKGROUND_STRETCH = 2; - const long BACKGROUND_CENTER = 3; - - /** - * The desktop background color, visible when no background image is - * used, or if the background image is centered and does not fill the - * entire screen. An RGB value (r << 16 | g << 8 | b) - */ - attribute unsigned long desktopBackgroundColor; -}; diff --git a/mozilla/suite/shell/src/Makefile.in b/mozilla/suite/shell/src/Makefile.in deleted file mode 100644 index 9504b695d36..00000000000 --- a/mozilla/suite/shell/src/Makefile.in +++ /dev/null @@ -1,39 +0,0 @@ -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = shellservice -FORCE_STATIC_LIB=1 - -REQUIRES = \ - xpcom \ - string \ - uriloader \ - dom \ - intl \ - necko \ - content \ - imglib2 \ - gfx \ - widget \ - pref \ - msgMapi \ - layout \ - $(NULL) - -ifeq ($(OS_ARCH),WINNT) -CPPSRCS = nsWindowsShellService.cpp -OS_LIBS += $(call EXPAND_LIBNAME,ole32 version uuid shell32) - -EXTRA_COMPONENTS = nsSetDefault.js -endif - -ifdef CPPSRCS -LIBRARY_NAME = shellservice_s -endif - -include $(topsrcdir)/config/rules.mk - diff --git a/mozilla/suite/shell/src/nsSetDefault.js b/mozilla/suite/shell/src/nsSetDefault.js deleted file mode 100644 index 8419ac2e5fa..00000000000 --- a/mozilla/suite/shell/src/nsSetDefault.js +++ /dev/null @@ -1,87 +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 Default mail - * - * The Initial Developer of the Original Code is - * Scott MacGregor . - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Mark Banner - * Frank Wein - * - * Alternatively, the contents of this file may be used under the terms of - * either 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 component handles the startup command line arguments of the form: - * -setDefaultBrowser - * -setDefaultMail - */ - -const nsIShellService = Components.interfaces.nsIShellService; -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -function nsSetDefault() { -} - -nsSetDefault.prototype = { - handle: function nsSetDefault_handle(aCmdline) { - if (aCmdline.handleFlag("setDefaultBrowser", false)) { - var shell = Components.classes["@mozilla.org/suite/shell-service;1"] - .getService(nsIShellService); - shell.setDefaultClient(true, true, nsIShellService.BROWSER); - } - else if (aCmdline.handleFlag("setDefaultMail", false)) { - var shell = Components.classes["@mozilla.org/browser/shell-service;1"] - .getService(nsIShellService); - shell.setDefaultClient(true, true, nsIShellService.MAIL); - } - else if (aCmdline.handeFlag("setDefaultNews", false)) { - var shell = Components.classes["@mozilla.org/browser/shell-service;1"] - .getService(nsIShellService); - shell.setDefaultClient(true, true, nsIShellService.NEWS); - } - }, - - helpInfo: " -setDefaultBrowser Set this app as the default browser client.\n" + - " -setDefaultMail Set this app as the default mail client.\n" + - " -setDefaultNews Set this app as the default newsreader.\n", - - classDescription: "Set Default Suite Cmdline Handler", - contractID: "@mozilla.org/suite/default-browser-clh;1", - classID: Components.ID("{A3D5B950-690A-491F-A881-2C2CDCD241CB}"), - QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), - _xpcom_categories: [{ - category: "command-line-handler", - entry: "m-setdefault" - }] -} - -function NSGetModule(compMgr, fileSpec) { - return XPCOMUtils.generateModule([nsSetDefault]); -} - diff --git a/mozilla/suite/shell/src/nsWindowsShellService.cpp b/mozilla/suite/shell/src/nsWindowsShellService.cpp deleted file mode 100644 index 8e640c2a8a5..00000000000 --- a/mozilla/suite/shell/src/nsWindowsShellService.cpp +++ /dev/null @@ -1,1370 +0,0 @@ -/* -*- Mode: C++; 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 Shell Service. - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Ben Goodger (Clients, Mail, New Default Browser) - * Joe Hewitt (Set Background) - * Blake Ross (Desktop Color, DDE support) - * Jungshik Shin (I18N) - * Robert Strong (Long paths, DDE) - * Asaf Romano - * Ryan Jones - * Frank Wein - * - * Alternatively, the contents of this file may be used under the terms of - * either 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 ***** */ - -#include "gfxIImageFrame.h" -#include "imgIContainer.h" -#include "imgIRequest.h" -#include "nsIDOMHTMLImageElement.h" -#include "nsIImageLoadingContent.h" -#include "nsIPrefService.h" -#include "nsIPrefLocalizedString.h" -#include "nsWindowsShellService.h" -#include "nsIProcess.h" -#include "windows.h" -#include "shlobj.h" -#include "nsILocalFile.h" -#include "nsNetUtil.h" -#include "nsNativeCharsetUtils.h" -#include "nsStringEnumerator.h" -#include "nsUnicharUtils.h" -#include "nsIStringBundle.h" -#include "nsIServiceManager.h" -#include "nsServiceManagerUtils.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsDirectoryServiceUtils.h" -#include "nsCOMPtr.h" -#include "nsIMapiSupport.h" -#include - -#ifndef MAX_BUF -#define MAX_BUF 4096 -#endif - -#define SHELLSERVICE_PROPERTIES "chrome://communicator/locale/shellservice.properties" -#define BRAND_PROPERTIES "chrome://branding/locale/brand.properties" - -#define REG_SUCCEEDED(val) \ - (val == ERROR_SUCCESS) - -#define REG_FAILED(val) \ - (val != ERROR_SUCCESS) - -NS_IMPL_ISUPPORTS1(nsWindowsShellService, nsIShellService) - -static nsresult -OpenUserKeyForReading(HKEY aStartKey, LPCWSTR aKeyName, HKEY* aKey) -{ - DWORD res = ::RegOpenKeyExW(aStartKey, aKeyName, 0, KEY_READ, aKey); - - if (res == ERROR_FILE_NOT_FOUND && aStartKey != HKEY_LOCAL_MACHINE) { - // retry with HKEY_LOCAL_MACHINE - res = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, aKeyName, 0, KEY_READ, aKey); - } - - return REG_FAILED(res) ? NS_ERROR_FILE_ACCESS_DENIED : NS_OK; -} - -// Sets the default registry keys for Windows versions prior to Vista. -// Try to open / create the key in HKLM and if that fails try to do the same -// in HKCU. Though this is not strictly the behavior I would expect it is the -// same behavior that SeaMonkey and IE have when setting the default browser -// previous to Vista. -static nsresult -OpenKeyForWriting(HKEY aStartKey, LPCWSTR aKeyName, HKEY* aKey, - PRBool aHKLMOnly) -{ - DWORD dwDisp = 0; - DWORD res = ::RegCreateKeyExW(aStartKey, aKeyName, 0, NULL, - 0, KEY_READ | KEY_WRITE, NULL, aKey, - &dwDisp); - - if (REG_FAILED(res) && !aHKLMOnly) { - // fallback to HKCU immediately on error since we won't be able - // to create the key. - res = ::RegCreateKeyExW(HKEY_CURRENT_USER, aKeyName, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, aKey, &dwDisp); - } - - return REG_FAILED(res) ? NS_ERROR_FILE_ACCESS_DENIED : NS_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// Default SeaMonkey OS integration Registry Settings -// Note: Some settings only exist when using the installer! -// -// Default Browser settings: -// - File Extension Mappings -// ----------------------- -// The following file extensions: -// .htm .html .shtml .xht .xhtml -// are mapped like so: -// -// HKCU\SOFTWARE\Classes\.\ (default) REG_SZ SeaMonkeyHTML -// -// as aliases to the class: -// -// HKCU\SOFTWARE\Classes\SeaMonkeyHTML\ -// DefaultIcon (default) REG_SZ ,1 -// shell\open\command (default) REG_SZ -requestPending -osint -url "%1" -// shell\open\ddeexec (default) REG_SZ "%1",,0,0,,,, -// shell\open\ddeexec NoActivateHandler REG_SZ -// \Application (default) REG_SZ SeaMonkey -// \Topic (default) REG_SZ WWW_OpenURL -// -// - Windows Vista Protocol Handler -// -// HKCU\SOFTWARE\Classes\SeaMonkeyURL\(default) REG_SZ URL -// EditFlags REG_DWORD 2 -// FriendlyTypeName REG_SZ URL -// DefaultIcon (default) REG_SZ ,1 -// shell\open\command (default) REG_SZ -requestPending -osint -url "%1" -// shell\open\ddeexec (default) REG_SZ "%1",,0,0,,,, -// shell\open\ddeexec NoActivateHandler REG_SZ -// \Application (default) REG_SZ SeaMonkey -// \Topic (default) REG_SZ WWW_OpenURL -// -// - Protocol Mappings -// ----------------- -// The following protocols: -// HTTP, HTTPS, FTP -// are mapped like so: -// -// HKCU\SOFTWARE\Classes\\ -// DefaultIcon (default) REG_SZ ,1 -// shell\open\command (default) REG_SZ -requestPending -url "%1" -// shell\open\ddeexec (default) REG_SZ "%1",,0,0,,,, -// shell\open\ddeexec NoActivateHandler REG_SZ -// \Application (default) REG_SZ SeaMonkey -// \Topic (default) REG_SZ WWW_OpenURL -// -// - Windows Start Menu (Win2K SP2, XP SP1, and newer) -// ------------------------------------------------- -// The following keys are set to make SeaMonkey appear in the Start Menu as the -// browser: -// -// HKCU\SOFTWARE\Clients\StartMenuInternet\SEAMONKEY.EXE\ -// (default) REG_SZ -// DefaultIcon (default) REG_SZ ,0 -// InstallInfo HideIconsCommand REG_SZ /HideShortcuts -// InstallInfo IconsVisible REG_DWORD 1 -// InstallInfo ReinstallCommand REG_SZ /SetAsDefaultAppGlobal -// InstallInfo ShowIconsCommand REG_SZ /ShowShortcuts -// shell\open\command (default) REG_SZ -// shell\properties (default) REG_SZ &Preferences -// shell\properties\command (default) REG_SZ -preferences -// shell\safemode (default) REG_SZ &Safe Mode -// shell\safemode\command (default) REG_SZ -safe-mode -// -// -// -// Default Mail&News settings -// -// - File Extension Mappings -// ----------------------- -// The following file extension: -// .eml -// is mapped like this: -// -// HKCU\SOFTWARE\Classes\.eml (default) REG_SZ SeaMonkeyEML -// -// That aliases to this class: -// HKCU\SOFTWARE\Classes\SeaMonkeyEML\ (default) REG_SZ SeaMonkey (Mail) Document -// FriendlyTypeName REG_SZ SeaMonkey (Mail) Document -// DefaultIcon (default) REG_SZ ,0 -// shell\open\command (default) REG_SZ "%1" -// -// - Windows Vista Protocol Handler -// -// HKCU\SOFTWARE\Classes\SeaMonkey.Url.mailto (default) REG_SZ SeaMonkey (Mail) URL -// DefaultIcon REG_SZ ,0 -// EditFlags REG_DWORD 2 -// shell\open\command (default) REG_SZ -osint -compose "%1" -// -// HKCU\SOFTWARE\Classes\SeaMonkey.Url.news (default) REG_SZ SeaMonkey (News) URL -// DefaultIcon REG_SZ ,0 -// EditFlags REG_DWORD 2 -// shell\open\command (default) REG_SZ -osint -news "%1" -// -// -// - Protocol Mappings -// ----------------- -// The following protocol: -// mailto -// is mapped like this: -// -// HKCU\SOFTWARE\Classes\mailto\ (default) REG_SZ SeaMonkey (Mail) URL -// EditFlags REG_DWORD 2 -// URL Protocol REG_SZ -// DefaultIcon (default) REG_SZ ,0 -// shell\open\command (default) REG_SZ -osint -compose "%1" -// -// The following protocols: -// news,nntp,snews -// are mapped like this: -// -// HKCU\SOFTWARE\Classes\\ (default) REG_SZ SeaMonkey (News) URL -// EditFlags REG_DWORD 2 -// URL Protocol REG_SZ -// DefaultIcon (default) REG_SZ ,0 -// shell\open\command (default) REG_SZ -osint -news "%1" -// -// - Windows Start Menu (Win2K SP2, XP SP1, and newer) -// ------------------------------------------------- -// The following keys are set to make SeaMonkey appear in the Start Menu as -// the default mail program: -// -// HKCU\SOFTWARE\Clients\Mail\SeaMonkey -// (default) REG_SZ -// DLLPath REG_SZ \mozMapi32.dll -// DefaultIcon (default) REG_SZ ,0 -// InstallInfo HideIconsCommand REG_SZ /HideShortcuts -// InstallInfo ReinstallCommand REG_SZ /SetAsDefaultAppGlobal -// InstallInfo ShowIconsCommand REG_SZ /ShowShortcuts -// shell\open\command (default) REG_SZ -mail -// shell\properties (default) REG_SZ &Preferences -// shell\properties\command (default) REG_SZ -preferences -// -// Also set SeaMonkey as News reader (Usenet), though Windows does currently -// not expose a default news reader to UI. Applications like Outlook Express -// also add themselves to this registry key -// -// HKCU\SOFTWARE\Clients\News\SeaMonkey -// (default) REG_SZ -// DLLPath REG_SZ \mozMapi32.dll -// DefaultIcon (default) REG_SZ ,0 -// shell\open\command (default) REG_SZ -news -// -/////////////////////////////////////////////////////////////////////////////// - - - -typedef enum { - NO_SUBSTITUTION = 0x00, - APP_PATH_SUBSTITUTION = 0x01, - EXE_NAME_SUBSTITUTION = 0x02, - UNINST_PATH_SUBSTITUTION = 0x04, - MAPIDLL_PATH_SUBSTITUTION = 0x08, - HKLM_ONLY = 0x10, - USE_FOR_DEFAULT_TEST = 0x20, - NON_ESSENTIAL = 0x40, - APP_NAME_SUBSTITUTION = 0x80 -} SettingFlags; - -#define APP_REG_NAME L"SeaMonkey" -// APP_REG_NAME_MAIL and APP_REG_NAME_NEWS should be kept in synch with -// AppRegNameMail and AppRegNameNews in the installer file: defines.nsi.in -#define APP_REG_NAME_MAIL L"SeaMonkey (Mail)" -#define APP_REG_NAME_NEWS L"SeaMonkey (News)" -#define CLS "SOFTWARE\\Classes\\" -#define CLS_HTML "SeaMonkeyHTML" -#define CLS_URL "SeaMonkeyURL" -#define CLS_EML "SeaMonkeyEML" -#define CLS_MAILTOURL "SeaMonkey.Url.mailto" -#define CLS_NEWSURL "SeaMonkey.Url.news" -#define SMI "SOFTWARE\\Clients\\StartMenuInternet\\" -#define MAILCLIENTS "SOFTWARE\\Clients\\Mail\\" -#define NEWSCLIENTS "SOFTWARE\\Clients\\News\\" -#define MOZ_CLIENT_MAIL_KEY "Software\\Clients\\Mail" -#define MOZ_CLIENT_NEWS_KEY "Software\\Clients\\News" -#define DI "\\DefaultIcon" -#define II "\\InstallInfo" -#define SOP "\\shell\\open\\command" -#define DDE "\\shell\\open\\ddeexec\\" -#define DDE_NAME "SeaMonkey" // Keep in sync with app name from nsXREAppData -#define DDE_COMMAND "\"%1\",,0,0,,,," -// For the InstallInfo HideIconsCommand, ShowIconsCommand, and ReinstallCommand -// registry keys. This must be kept in sync with the uninstaller. -#define UNINSTALL_EXE "\\uninstall\\helper.exe" - -#define VAL_ICON "%APPPATH%,0" -#define VAL_FILE_ICON "%APPPATH%,1" -#define VAL_URL_OPEN "\"%APPPATH%\" -requestPending -osint -url \"%1\"" -#define VAL_MAIL_OPEN "\"%APPPATH%\" \"%1\"" - -#define MAKE_KEY_NAME1(PREFIX, MID) \ - PREFIX MID - -#define MAKE_KEY_NAME2(PREFIX, MID, SUFFIX) \ - PREFIX MID SUFFIX - -#define MAKE_KEY_NAME3(PREFIX, MID, MID2, SUFFIX) \ - PREFIX MID MID2 SUFFIX - -// The DefaultIcon registry key value should never be used (e.g. NON_ESSENTIAL) -// when checking if SeaMonkey is the default browser since other applications -// (e.g. MS Office) may modify the DefaultIcon registry key value to add Icon -// Handlers. -// see http://msdn2.microsoft.com/en-us/library/aa969357.aspx for more info. -static SETTING gBrowserSettings[] = { - // File Extension Aliases - { MAKE_KEY_NAME1(CLS, ".htm"), "", CLS_HTML, NO_SUBSTITUTION }, - { MAKE_KEY_NAME1(CLS, ".html"), "", CLS_HTML, NO_SUBSTITUTION }, - { MAKE_KEY_NAME1(CLS, ".shtml"), "", CLS_HTML, NO_SUBSTITUTION }, - { MAKE_KEY_NAME1(CLS, ".xht"), "", CLS_HTML, NO_SUBSTITUTION }, - { MAKE_KEY_NAME1(CLS, ".xhtml"), "", CLS_HTML, NO_SUBSTITUTION }, - - // File Extension Class - as of 1.8.1.2 the value for VAL_URL_OPEN is also - // checked for CLS_HTML since SeaMonkey should also own opening local files - // when set as the default browser. - { MAKE_KEY_NAME2(CLS, CLS_HTML, DI), "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, CLS_HTML, SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST }, - - // Protocol Handler Class - for Vista and above - { MAKE_KEY_NAME2(CLS, CLS_URL, DI), "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, CLS_URL, SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST }, - - // Protocol Handlers - { MAKE_KEY_NAME2(CLS, "HTTP", DI), "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST }, - { MAKE_KEY_NAME2(CLS, "HTTP", SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST }, - { MAKE_KEY_NAME2(CLS, "HTTPS", DI), "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST }, - { MAKE_KEY_NAME2(CLS, "HTTPS", SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST }, - { MAKE_KEY_NAME2(CLS, "FTP", DI), "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "FTP", SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "GOPHER", DI), "", VAL_FILE_ICON, APP_PATH_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "GOPHER", SOP), "", VAL_URL_OPEN, APP_PATH_SUBSTITUTION }, - - // DDE settings - { MAKE_KEY_NAME2(CLS, CLS_HTML, DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, CLS_HTML, DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, CLS_HTML, DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, CLS_URL, DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, CLS_URL, DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, CLS_URL, DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "HTTP", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTP", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTP", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "HTTPS", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTPS", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTPS", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "FTP", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "FTP", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "FTP", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "GOPHER", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "GOPHER", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "GOPHER", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - - // Windows XP Start Menu - { MAKE_KEY_NAME2(SMI, "%APPEXE%", DI), - "", - "%APPPATH%,0", - APP_PATH_SUBSTITUTION | EXE_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(SMI, "%APPEXE%", II), - "HideIconsCommand", - "\"%UNINSTPATH%\" /HideShortcuts", - UNINST_PATH_SUBSTITUTION | EXE_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(SMI, "%APPEXE%", II), - "ReinstallCommand", - "\"%UNINSTPATH%\" /SetAsDefaultAppGlobal", - UNINST_PATH_SUBSTITUTION | EXE_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(SMI, "%APPEXE%", II), - "ShowIconsCommand", - "\"%UNINSTPATH%\" /ShowShortcuts", - UNINST_PATH_SUBSTITUTION | EXE_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(SMI, "%APPEXE%", SOP), - "", - "%APPPATH%", - APP_PATH_SUBSTITUTION | EXE_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME1(SMI, "%APPEXE%\\shell\\properties\\command"), - "", - "\"%APPPATH%\" -preferences", - APP_PATH_SUBSTITUTION | EXE_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME1(SMI, "%APPEXE%\\shell\\safemode\\command"), - "", - "\"%APPPATH%\" -safe-mode", - APP_PATH_SUBSTITUTION | EXE_NAME_SUBSTITUTION | HKLM_ONLY } - - // These values must be set by hand, since they contain localized strings. - // seamonkey.exe\shell\properties (default) REG_SZ SeaMonkey &Preferences - // seamonkey.exe\shell\safemode (default) REG_SZ SeaMonkey &Safe Mode -}; - - - static SETTING gMailSettings[] = { - // File Extension Aliases - { MAKE_KEY_NAME1(CLS, ".eml"), "", CLS_EML, NO_SUBSTITUTION }, - // File Extension Class - { MAKE_KEY_NAME2(CLS, CLS_EML, DI), "", VAL_ICON, APP_PATH_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, CLS_EML, SOP), "", VAL_MAIL_OPEN, APP_PATH_SUBSTITUTION}, - - // Protocol Handler Class - for Vista and above - { MAKE_KEY_NAME2(CLS, CLS_MAILTOURL, DI), "", VAL_ICON, APP_PATH_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, CLS_MAILTOURL, SOP), "", "\"%APPPATH%\" -osint -compose \"%1\"", APP_PATH_SUBSTITUTION }, - - // Protocol Handlers - { MAKE_KEY_NAME2(CLS, "mailto", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION}, - { MAKE_KEY_NAME2(CLS, "mailto", SOP), "", "\"%APPPATH%\" -osint -compose \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST}, - - // Mail Client Keys - { MAKE_KEY_NAME1(MAILCLIENTS, "%APPNAME%"), - "DLLPath", - "%MAPIDLLPATH%", - MAPIDLL_PATH_SUBSTITUTION | HKLM_ONLY | APP_NAME_SUBSTITUTION }, - { MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", II), - "HideIconsCommand", - "\"%UNINSTPATH%\" /HideShortcuts", - UNINST_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", II), - "ReinstallCommand", - "\"%UNINSTPATH%\" /SetAsDefaultAppGlobal", - UNINST_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", II), - "ShowIconsCommand", - "\"%UNINSTPATH%\" /ShowShortcuts", - UNINST_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", DI), - "", - "%APPPATH%,0", - APP_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", SOP), - "", - "\"%APPPATH%\" -mail", - APP_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME1(MAILCLIENTS, "%APPNAME%\\shell\\properties\\command"), - "", - "\"%APPPATH%\" -preferences", - APP_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, - }; - - static SETTING gNewsSettings[] = { - // Protocol Handler Class - for Vista and above - { MAKE_KEY_NAME2(CLS, CLS_NEWSURL, DI), "", VAL_ICON, APP_PATH_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, CLS_NEWSURL, SOP), "", "\"%APPPATH%\" -osint -news \"%1\"", APP_PATH_SUBSTITUTION }, - - // Protocol Handlers - { MAKE_KEY_NAME2(CLS, "news", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION}, - { MAKE_KEY_NAME2(CLS, "news", SOP), "", "\"%APPPATH%\" -osint -news \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST}, - { MAKE_KEY_NAME2(CLS, "nntp", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION}, - { MAKE_KEY_NAME2(CLS, "nntp", SOP), "", "\"%APPPATH%\" -osint -news \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST}, - { MAKE_KEY_NAME2(CLS, "snews", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION}, - { MAKE_KEY_NAME2(CLS, "snews", SOP), "", "\"%APPPATH%\" -osint -news \"%1\"", APP_PATH_SUBSTITUTION}, - - // News Client Keys - { MAKE_KEY_NAME1(NEWSCLIENTS, "%APPNAME%"), - "DLLPath", - "%MAPIDLLPATH%", - MAPIDLL_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", DI), - "", - "%APPPATH%,0", - APP_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, - { MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", SOP), - "", - "\"%APPPATH%\" -mail", - APP_PATH_SUBSTITUTION | APP_NAME_SUBSTITUTION | HKLM_ONLY }, -}; - -// Support for versions of shlobj.h that don't include the Vista API's -#if !defined(IApplicationAssociationRegistration) - -typedef enum tagASSOCIATIONLEVEL { - AL_MACHINE, - AL_EFFECTIVE, - AL_USER -} ASSOCIATIONLEVEL; - -typedef enum tagASSOCIATIONTYPE { - AT_FILEEXTENSION, - AT_URLPROTOCOL, - AT_STARTMENUCLIENT, - AT_MIMETYPE -} ASSOCIATIONTYPE; - -MIDL_INTERFACE("4e530b0a-e611-4c77-a3ac-9031d022281b") -IApplicationAssociationRegistration : public IUnknown -{ - public: - virtual HRESULT STDMETHODCALLTYPE QueryCurrentDefault(LPCWSTR pszQuery, - ASSOCIATIONTYPE atQueryType, - ASSOCIATIONLEVEL alQueryLevel, - LPWSTR *ppszAssociation) = 0; - virtual HRESULT STDMETHODCALLTYPE QueryAppIsDefault(LPCWSTR pszQuery, - ASSOCIATIONTYPE atQueryType, - ASSOCIATIONLEVEL alQueryLevel, - LPCWSTR pszAppRegistryName, - BOOL *pfDefault) = 0; - virtual HRESULT STDMETHODCALLTYPE QueryAppIsDefaultAll(ASSOCIATIONLEVEL alQueryLevel, - LPCWSTR pszAppRegistryName, - BOOL *pfDefault) = 0; - virtual HRESULT STDMETHODCALLTYPE SetAppAsDefault(LPCWSTR pszAppRegistryName, - LPCWSTR pszSet, - ASSOCIATIONTYPE atSetType) = 0; - virtual HRESULT STDMETHODCALLTYPE SetAppAsDefaultAll(LPCWSTR pszAppRegistryName) = 0; - virtual HRESULT STDMETHODCALLTYPE ClearUserAssociations(void) = 0; -}; -#endif - -static const CLSID CLSID_ApplicationAssociationReg = {0x591209C7,0x767B,0x42B2,{0x9F,0xBA,0x44,0xEE,0x46,0x15,0xF2,0xC7}}; -static const IID IID_IApplicationAssociationReg = {0x4e530b0a,0xe611,0x4c77,{0xa3,0xac,0x90,0x31,0xd0,0x22,0x28,0x1b}}; - -/* helper routine. Iterate over the passed in settings object, - testing each key with the USE_FOR_DEFAULT_TEST to see if - we are handling it. -*/ -PRBool -nsWindowsShellService::TestForDefault(SETTING aSettings[], PRInt32 aSize) -{ - nsCOMPtr lf; - nsresult rv = NS_NewLocalFile(mAppShortPath, PR_TRUE, - getter_AddRefs(lf)); - - if (NS_FAILED(rv)) - return PR_FALSE; - - nsAutoString exeName; - rv = lf->GetLeafName(exeName); - if (NS_FAILED(rv)) - return PR_FALSE; - ToUpperCase(exeName); - - PRUnichar currValue[MAX_BUF]; - SETTING* end = aSettings + aSize; - for (SETTING * settings = aSettings; settings < end; ++settings) { - if (settings->flags & USE_FOR_DEFAULT_TEST) { - NS_ConvertUTF8toUTF16 dataLongPath(settings->valueData); - NS_ConvertUTF8toUTF16 dataShortPath(settings->valueData); - NS_ConvertUTF8toUTF16 key(settings->keyName); - NS_ConvertUTF8toUTF16 value(settings->valueName); - if (settings->flags & APP_PATH_SUBSTITUTION) { - PRInt32 offset = dataLongPath.Find("%APPPATH%"); - dataLongPath.Replace(offset, 9, mAppLongPath); - // Remove the quotes around %APPPATH% in VAL_OPEN for short paths - PRInt32 offsetQuoted = dataShortPath.Find("\"%APPPATH%\""); - if (offsetQuoted != -1) - dataShortPath.Replace(offsetQuoted, 11, mAppShortPath); - else - dataShortPath.Replace(offset, 9, mAppShortPath); - } - if (settings->flags & APP_NAME_SUBSTITUTION) { - PRInt32 offset = key.Find("%APPNAME%"); - key.Replace(offset, 9, mBrandFullName); - } - if (settings->flags & EXE_NAME_SUBSTITUTION) { - PRInt32 offset = key.Find("%APPEXE%"); - key.Replace(offset, 8, exeName); - } - - ::ZeroMemory(currValue, sizeof(currValue)); - HKEY theKey; - nsresult rv = OpenUserKeyForReading(HKEY_CURRENT_USER, key.get(), &theKey); - if (NS_SUCCEEDED(rv)) { - DWORD len = sizeof currValue; - DWORD res = ::RegQueryValueExW(theKey, value.get(), - NULL, NULL, (LPBYTE)currValue, &len); - // Close the key we opened. - ::RegCloseKey(theKey); - if (REG_FAILED(res) || - !dataLongPath.Equals(currValue, CaseInsensitiveCompare) && - !dataShortPath.Equals(currValue, CaseInsensitiveCompare)) { - // Key wasn't set, or was set to something else (something else became the default client) - return PR_FALSE; - } - } - } - } // for each registry key we want to look at - - return PR_TRUE; -} - -nsresult nsWindowsShellService::Init() -{ - nsresult rv; - - nsCOMPtr bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr brandBundle; - rv = bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle)); - NS_ENSURE_SUCCESS(rv, rv); - - brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(), - getter_Copies(mBrandFullName)); - brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), - getter_Copies(mBrandShortName)); - - PRUnichar appPath[MAX_BUF]; - if (!::GetModuleFileNameW(0, appPath, MAX_BUF)) - return NS_ERROR_FAILURE; - - mAppLongPath = appPath; - - nsCOMPtr lf; - rv = NS_NewLocalFile(mAppLongPath, PR_TRUE, - getter_AddRefs(lf)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr appDir; - rv = lf->GetParent(getter_AddRefs(appDir)); - NS_ENSURE_SUCCESS(rv, rv); - - appDir->GetPath(mUninstallPath); - mUninstallPath.AppendLiteral(UNINSTALL_EXE); - - // Support short path to the exe so if it is already set the user is not - // prompted to set the default mail client again. - if (!::GetShortPathNameW(appPath, appPath, MAX_BUF)) - return NS_ERROR_FAILURE; - - ToUpperCase(mAppShortPath = appPath); - - rv = NS_NewLocalFile(mAppLongPath, PR_TRUE, getter_AddRefs(lf)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = lf->SetLeafName(NS_LITERAL_STRING("mozMapi32.dll")); - NS_ENSURE_SUCCESS(rv, rv); - - return lf->GetPath(mMapiDLLPath); -} - -PRBool -nsWindowsShellService::IsDefaultClientVista(PRBool aStartupCheck, PRUint16 aApps, PRBool* aIsDefaultClient) -{ - IApplicationAssociationRegistration* pAAR; - - HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationReg, - NULL, - CLSCTX_INPROC, - IID_IApplicationAssociationReg, - (void**)&pAAR); - - if (SUCCEEDED(hr)) { - BOOL isDefaultBrowser = PR_TRUE; - BOOL isDefaultMail = PR_TRUE; - BOOL isDefaultNews = PR_TRUE; - if (aApps & nsIShellService::BROWSER) - pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE, APP_REG_NAME, &isDefaultBrowser); - if (aApps & nsIShellService::MAIL) - pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE, APP_REG_NAME_MAIL, &isDefaultMail); - if (aApps & nsIShellService::NEWS) - pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE, APP_REG_NAME_NEWS, &isDefaultNews); - - *aIsDefaultClient = isDefaultBrowser && isDefaultNews && isDefaultMail; - - // If this is the first application window, maintain internal state that we've - // checked this session (so that subsequent window opens don't show the default - // client dialog). - if (aStartupCheck) - mCheckedThisSessionClient = PR_TRUE; - - pAAR->Release(); - return PR_TRUE; - } - - return PR_FALSE; -} - -PRBool -nsWindowsShellService::SetDefaultClientVista(PRUint16 aApps) -{ - IApplicationAssociationRegistration* pAAR; - - HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationReg, - NULL, - CLSCTX_INPROC, - IID_IApplicationAssociationReg, - (void**)&pAAR); - - if (SUCCEEDED(hr)) { - if (aApps & nsIShellService::BROWSER) - pAAR->SetAppAsDefaultAll(APP_REG_NAME); - if (aApps & nsIShellService::MAIL) - pAAR->SetAppAsDefaultAll(APP_REG_NAME_MAIL); - if (aApps & nsIShellService::NEWS) - pAAR->SetAppAsDefaultAll(APP_REG_NAME_NEWS); - - pAAR->Release(); - return PR_TRUE; - } - - return PR_FALSE; -} - -NS_IMETHODIMP -nsWindowsShellService::IsDefaultClient(PRBool aStartupCheck, PRUint16 aApps, PRBool *aIsDefaultClient) -{ - if (IsDefaultClientVista(aStartupCheck, aApps, aIsDefaultClient)) - return NS_OK; - - *aIsDefaultClient = PR_TRUE; - - // for each type, check if it is the default app - // browser check needs to be at the top - if (aApps & nsIShellService::BROWSER) - *aIsDefaultClient &= TestForDefault(gBrowserSettings, sizeof(gBrowserSettings)/sizeof(SETTING)); - if (aApps & nsIShellService::MAIL) - *aIsDefaultClient &= TestForDefault(gMailSettings, sizeof(gMailSettings)/sizeof(SETTING)); - if (aApps & nsIShellService::NEWS) - *aIsDefaultClient &= TestForDefault(gNewsSettings, sizeof(gNewsSettings)/sizeof(SETTING)); - - // If this is the first application window, maintain internal state that we've - // checked this session (so that subsequent window opens don't show the - // default client dialog). - if (aStartupCheck) - mCheckedThisSessionClient = PR_TRUE; - - return NS_OK; -} - -static DWORD -DeleteRegKeyDefaultValue(HKEY baseKey, LPCWSTR keyName) -{ - HKEY key; - DWORD res = ::RegOpenKeyExW(baseKey, keyName, - 0, KEY_WRITE, &key); - if (res == ERROR_SUCCESS) { - res = ::RegDeleteValueW(key, NULL); - ::RegCloseKey(key); - } - return res; -} - -// Utility function to delete a registry subkey. -static DWORD -DeleteRegTree(HKEY baseKey, LPCWSTR keyName) -{ - // Make sure input subkey isn't null. - if (!keyName || !*keyName) - return ERROR_BADKEY; - - // Open subkey. - HKEY key; - DWORD res = ::RegOpenKeyExW(baseKey, keyName, 0, - KEY_ENUMERATE_SUB_KEYS | DELETE, &key); - - // Continue till we get an error or are done. - while (res == ERROR_SUCCESS) { - PRUnichar subkeyName[_MAX_PATH]; - DWORD len = sizeof subkeyName; - // Get first subkey name. Note that we always get the - // first one, then delete it. So we need to get - // the first one next time, also. - res = ::RegEnumKeyExW(key, 0, subkeyName, &len, NULL, NULL, - NULL, NULL); - if (res == ERROR_NO_MORE_ITEMS) { - // No more subkeys. Delete the main one. - res = ::RegDeleteKeyW(baseKey, keyName); - break; - } - // If we find another subkey, delete it, recursively. - if (res == ERROR_SUCCESS) { - // Another subkey, delete it, recursively. - res = DeleteRegTree(key, subkeyName); - } - } - - // Close the key we opened. - ::RegCloseKey(key); - return res; -} - -void -nsWindowsShellService::SetRegKey(const nsString& aKeyName, - const nsString& aValueName, - const nsString& aValue, - PRBool aHKLMOnly) -{ - PRUnichar buf[MAX_BUF]; - DWORD len = sizeof buf; - - HKEY theKey; - nsresult rv = OpenKeyForWriting(HKEY_LOCAL_MACHINE, aKeyName.get(), &theKey, - aHKLMOnly); - if (NS_FAILED(rv)) - return; - - // Get the old value - DWORD res = ::RegQueryValueExW(theKey, aValueName.get(), - NULL, NULL, (LPBYTE)buf, &len); - - // Set the new value - if (REG_FAILED(res) || !aValue.Equals(buf, CaseInsensitiveCompare)) { - ::RegSetValueExW(theKey, aValueName.get(), - 0, REG_SZ, (const BYTE *)aValue.get(), - (aValue.Length() + 1) * sizeof(PRUnichar)); - } - - // Close the key we opened. - ::RegCloseKey(theKey); -} - - -NS_IMETHODIMP -nsWindowsShellService::SetDefaultClient(PRBool aForAllUsers, - PRBool aClaimAllTypes, PRUint16 aApps) -{ - // Delete the protocol and file handlers under HKCU if they exist. This way - // the HKCU registry is cleaned up when HKLM is writeable or if it isn't - // the values will then be added under HKCU. - if (aApps & nsIShellService::BROWSER) { - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\http\\shell\\open"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\http\\DefaultIcon"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\https\\shell\\open"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\https\\DefaultIcon"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\ftp\\shell\\open"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\ftp\\DefaultIcon"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\gopher\\shell\\open"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\gopher\\DefaultIcon"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\SeaMonkeyURL"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\SeaMonkeyHTML"); - - (void)DeleteRegKeyDefaultValue(HKEY_CURRENT_USER, - L"Software\\Classes\\.htm"); - (void)DeleteRegKeyDefaultValue(HKEY_CURRENT_USER, - L"Software\\Classes\\.html"); - (void)DeleteRegKeyDefaultValue(HKEY_CURRENT_USER, - L"Software\\Classes\\.shtml"); - (void)DeleteRegKeyDefaultValue(HKEY_CURRENT_USER, - L"Software\\Classes\\.xht"); - (void)DeleteRegKeyDefaultValue(HKEY_CURRENT_USER, - L"Software\\Classes\\.xhtml"); - } - - if (aApps & nsIShellService::MAIL) { - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\SeaMonkeyEML"); - (void)DeleteRegKeyDefaultValue(HKEY_CURRENT_USER, - L"Software\\Classes\\.eml"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\mailto\\shell\\open"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\mailto\\DefaultIcon"); - } - - if (aApps & nsIShellService::NEWS) { - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\news\\shell\\open"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\news\\DefaultIcon"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\snews\\shell\\open"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\snews\\DefaultIcon"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\nntp\\shell\\open"); - (void)DeleteRegTree(HKEY_CURRENT_USER, - L"Software\\Classes\\nntp\\DefaultIcon"); - } - - if (!aForAllUsers && SetDefaultClientVista(aApps)) - return NS_OK; - - nsresult rv = NS_OK; - if (aApps & nsIShellService::BROWSER) - rv |= setDefaultBrowser(); - - if (aApps & nsIShellService::MAIL) - rv |= setDefaultMail(); - - if (aApps & nsIShellService::NEWS) - rv |= setDefaultNews(); - - // Refresh the Shell - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0); - return rv; -} - -NS_IMETHODIMP -nsWindowsShellService::GetShouldCheckDefaultClient(PRBool* aResult) -{ - if (mCheckedThisSessionClient) { - *aResult = PR_FALSE; - return NS_OK; - } - - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - return prefs->GetBoolPref("shell.checkDefaultClient", aResult); -} - - - -NS_IMETHODIMP -nsWindowsShellService::SetShouldCheckDefaultClient(PRBool aShouldCheck) -{ - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - NS_ENSURE_TRUE(prefs, NS_ERROR_FAILURE); - return prefs->SetBoolPref("shell.checkDefaultClient", aShouldCheck); -} - - -nsresult -nsWindowsShellService::setDefaultBrowser() -{ - SETTING* settings; - SETTING* end = gBrowserSettings + sizeof(gBrowserSettings)/sizeof(SETTING); - - nsCOMPtr lf; - nsresult rv = NS_NewLocalFile(mAppLongPath, PR_TRUE, - getter_AddRefs(lf)); - if (NS_FAILED(rv)) - return rv; - - nsAutoString exeName; - rv = lf->GetLeafName(exeName); - if (NS_FAILED(rv)) - return rv; - ToUpperCase(exeName); - - nsCOMPtr appDir; - rv = lf->GetParent(getter_AddRefs(appDir)); - if (NS_FAILED(rv)) - return rv; - - nsAutoString uninstLongPath; - appDir->GetPath(uninstLongPath); - uninstLongPath.AppendLiteral(UNINSTALL_EXE); - - for (settings = gBrowserSettings; settings < end; ++settings) { - NS_ConvertUTF8toUTF16 dataLongPath(settings->valueData); - NS_ConvertUTF8toUTF16 key(settings->keyName); - NS_ConvertUTF8toUTF16 value(settings->valueName); - if (settings->flags & APP_PATH_SUBSTITUTION) { - PRInt32 offset = dataLongPath.Find("%APPPATH%"); - dataLongPath.Replace(offset, 9, mAppLongPath); - } - if (settings->flags & UNINST_PATH_SUBSTITUTION) { - PRInt32 offset = dataLongPath.Find("%UNINSTPATH%"); - dataLongPath.Replace(offset, 12, uninstLongPath); - } - if (settings->flags & EXE_NAME_SUBSTITUTION) { - PRInt32 offset = key.Find("%APPEXE%"); - key.Replace(offset, 8, exeName); - } - - SetRegKey(key, value, dataLongPath, - (settings->flags & HKLM_ONLY)); - } - - // Select the Default Browser for the Windows XP Start Menu - SetRegKey(NS_LITERAL_STRING(SMI), EmptyString(), exeName, PR_TRUE); - - nsCOMPtr - bundleService(do_GetService("@mozilla.org/intl/stringbundle;1")); - if (!bundleService) - return NS_ERROR_FAILURE; - - nsCOMPtr bundle, brandBundle; - rv = bundleService->CreateBundle(SHELLSERVICE_PROPERTIES, getter_AddRefs(bundle)); - NS_ENSURE_SUCCESS(rv, rv); - rv = bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle)); - NS_ENSURE_SUCCESS(rv, rv); - - // Create the Start Menu item if it doesn't exist - nsString brandFullName; - brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(), - getter_Copies(brandFullName)); - - nsAutoString key1(NS_LITERAL_STRING(SMI)); - key1.Append(exeName); - key1.AppendLiteral("\\"); - SetRegKey(key1, EmptyString(), brandFullName, PR_TRUE); - - // Set the Preferences and Safe Mode start menu context menu item labels - nsAutoString preferencesKey(NS_LITERAL_STRING(SMI)); - preferencesKey.Append(exeName); - preferencesKey.AppendLiteral("\\shell\\properties"); - - nsAutoString safeModeKey(NS_LITERAL_STRING(SMI)); - safeModeKey.Append(exeName); - safeModeKey.AppendLiteral("\\shell\\safemode"); - - nsString brandShortName; - brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), - getter_Copies(brandShortName)); - - const PRUnichar* brandNameStrings[] = { brandShortName.get() }; - - // Set the Preferences menu item - nsString preferencesTitle; - bundle->FormatStringFromName(NS_LITERAL_STRING("preferencesLabel").get(), - brandNameStrings, 1, - getter_Copies(preferencesTitle)); - // Set the Safe Mode menu item - nsString safeModeTitle; - bundle->FormatStringFromName(NS_LITERAL_STRING("safeModeLabel").get(), - brandNameStrings, 1, - getter_Copies(safeModeTitle)); - - SetRegKey(preferencesKey, EmptyString(), preferencesTitle, PR_TRUE); - SetRegKey(safeModeKey, EmptyString(), safeModeTitle, PR_TRUE); - return NS_OK; - } - -nsresult -nsWindowsShellService::setDefaultMail() -{ - nsresult rv; - setKeysForSettings(gMailSettings, sizeof(gMailSettings)/sizeof(SETTING)); - - // at least for now, this key needs to be written to HKLM instead of HKCU - // which is where the windows operating system looks (at least on Win XP and - // earlier) - SetRegKey(NS_LITERAL_STRING(MOZ_CLIENT_MAIL_KEY), EmptyString(), mBrandFullName, PR_TRUE); - - nsAutoString key1(NS_LITERAL_STRING(MAILCLIENTS)); - key1.Append(mBrandFullName); - key1.AppendLiteral("\\"); - SetRegKey(key1, EmptyString(), mBrandFullName, PR_TRUE); - - // Set the Preferences and Safe Mode start menu context menu item labels - nsCOMPtr bundle; - nsCOMPtr bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = bundleService->CreateBundle(SHELLSERVICE_PROPERTIES, getter_AddRefs(bundle)); - NS_ENSURE_SUCCESS(rv, rv); - nsAutoString preferencesKey(NS_LITERAL_STRING(MAILCLIENTS)); - preferencesKey.AppendLiteral("%APPNAME%\\shell\\properties"); - PRInt32 offset = preferencesKey.Find("%APPNAME%"); - preferencesKey.Replace(offset, 9, mBrandFullName); - - const PRUnichar* brandNameStrings[] = { mBrandShortName.get() }; - - // Set the Preferences menu item - nsString preferencesTitle; - bundle->FormatStringFromName(NS_LITERAL_STRING("preferencesLabel").get(), - brandNameStrings, 1, getter_Copies(preferencesTitle)); - // Set the registry keys - SetRegKey(preferencesKey, EmptyString(), preferencesTitle, PR_TRUE); -#ifndef __MINGW32__ - // Tell the MAPI Service to register the mapi proxy dll now that we are the default mail application - nsCOMPtr mapiService (do_GetService(NS_IMAPISUPPORT_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - return mapiService->RegisterServer(); -#else - return NS_OK; -#endif -} - -nsresult -nsWindowsShellService::setDefaultNews() -{ - setKeysForSettings(gNewsSettings, sizeof(gNewsSettings)/sizeof(SETTING)); - - // at least for now, this key needs to be written to HKLM instead of HKCU - // which is where the windows operating system looks (at least on Win XP and earlier) - SetRegKey(NS_LITERAL_STRING(MOZ_CLIENT_NEWS_KEY), EmptyString(), mBrandFullName, PR_TRUE); - - nsAutoString key1(NS_LITERAL_STRING(NEWSCLIENTS)); - key1.Append(mBrandFullName); - key1.AppendLiteral("\\"); - SetRegKey(key1, EmptyString(), mBrandFullName, PR_TRUE); - return NS_OK; -} - -static nsresult -WriteBitmap(nsIFile* aFile, gfxIImageFrame* aImage) -{ - PRInt32 width, height; - aImage->GetWidth(&width); - aImage->GetHeight(&height); - - PRUint8* bits; - PRUint32 length; - aImage->LockImageData(); - aImage->GetImageData(&bits, &length); - if (!bits) { - aImage->UnlockImageData(); - return NS_ERROR_FAILURE; - } - - PRUint32 bpr; - aImage->GetImageBytesPerRow(&bpr); - PRInt32 bitCount = bpr/width; - - // initialize these bitmap structs which we will later - // serialize directly to the head of the bitmap file - BITMAPINFOHEADER bmi; - bmi.biSize = sizeof(BITMAPINFOHEADER); - bmi.biWidth = width; - bmi.biHeight = height; - bmi.biPlanes = 1; - bmi.biBitCount = (WORD)bitCount*8; - bmi.biCompression = BI_RGB; - bmi.biSizeImage = length; - bmi.biXPelsPerMeter = 0; - bmi.biYPelsPerMeter = 0; - bmi.biClrUsed = 0; - bmi.biClrImportant = 0; - - BITMAPFILEHEADER bf; - bf.bfType = 0x4D42; // 'BM' - bf.bfReserved1 = 0; - bf.bfReserved2 = 0; - bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); - bf.bfSize = bf.bfOffBits + bmi.biSizeImage; - - // get a file output stream - nsCOMPtr stream; - nsresult rv = NS_NewLocalFileOutputStream(getter_AddRefs(stream), aFile); - NS_ENSURE_SUCCESS(rv, rv); - - // write the bitmap headers and rgb pixel data to the file - rv = NS_ERROR_FAILURE; - if (stream) { - PRUint32 written; - stream->Write((const char*)&bf, sizeof(BITMAPFILEHEADER), &written); - if (written == sizeof(BITMAPFILEHEADER)) { - stream->Write((const char*)&bmi, sizeof(BITMAPINFOHEADER), &written); - if (written == sizeof(BITMAPINFOHEADER)) { - // write out the image data backwards because the desktop won't - // show bitmaps with negative heights for top-to-bottom - PRUint32 i = length; - rv = NS_OK; - do { - i -= bpr; - - stream->Write(((const char*)bits) + i, bpr, &written); - if (written != bpr) { - rv = NS_ERROR_FAILURE; - break; - } - } while (i != 0); - } - } - - stream->Close(); - } - - aImage->UnlockImageData(); - return rv; -} - -NS_IMETHODIMP -nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement, - PRInt32 aPosition) -{ - nsresult rv; - - nsCOMPtr gfxFrame; - - nsCOMPtr imgElement(do_QueryInterface(aElement)); - if (!imgElement) { - // XXX write background loading stuff! - } - else { - nsCOMPtr imageContent = - do_QueryInterface(aElement, &rv); - if (!imageContent) - return rv; - - // get the image container - nsCOMPtr request; - rv = imageContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, - getter_AddRefs(request)); - if (!request) - return rv; - nsCOMPtr container; - rv = request->GetImage(getter_AddRefs(container)); - if (!container) - return NS_ERROR_FAILURE; - - // get the current frame, which holds the image data - container->GetCurrentFrame(getter_AddRefs(gfxFrame)); - } - - if (!gfxFrame) - return NS_ERROR_FAILURE; - - // get the file name from localized strings - nsCOMPtr - bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr shellBundle; - rv = bundleService->CreateBundle(SHELLSERVICE_PROPERTIES, - getter_AddRefs(shellBundle)); - NS_ENSURE_SUCCESS(rv, rv); - - // e.g. "Desktop Background.bmp" - nsString fileLeafName; - rv = shellBundle->GetStringFromName - (NS_LITERAL_STRING("desktopBackgroundLeafNameWin").get(), - getter_Copies(fileLeafName)); - NS_ENSURE_SUCCESS(rv, rv); - - // get the profile root directory - nsCOMPtr file; - rv = NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_DIR, - getter_AddRefs(file)); - NS_ENSURE_SUCCESS(rv, rv); - - // eventually, the path is "%APPDATA%\Mozilla\SeaMonkey\Desktop Background.bmp" - rv = file->Append(fileLeafName); - NS_ENSURE_SUCCESS(rv, rv); - - nsAutoString path; - rv = file->GetPath(path); - NS_ENSURE_SUCCESS(rv, rv); - - // write the bitmap to a file in the profile directory - rv = WriteBitmap(file, gfxFrame); - - // if the file was written successfully, set it as the system wallpaper - if (NS_SUCCEEDED(rv)) { - PRBool result = PR_FALSE; - DWORD dwDisp = 0; - HKEY key; - // Try to create/open a subkey under HKCU. - DWORD res = ::RegCreateKeyExW(HKEY_CURRENT_USER, - L"Control Panel\\Desktop", - 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_WRITE, NULL, &key, &dwDisp); - if (REG_SUCCEEDED(res)) { - PRUnichar tile[2], style[2]; - switch (aPosition) { - case BACKGROUND_TILE: - tile[0] = '1'; - style[0] = '1'; - break; - case BACKGROUND_CENTER: - tile[0] = '0'; - style[0] = '0'; - break; - case BACKGROUND_STRETCH: - tile[0] = '0'; - style[0] = '2'; - break; - } - tile[1] = '\0'; - style[1] = '\0'; - - // The size is always 2 unicode characters. - PRInt32 size = 2 * sizeof(PRUnichar); - ::RegSetValueExW(key, L"TileWallpaper", - 0, REG_SZ, (const BYTE *)tile, size); - ::RegSetValueExW(key, L"WallpaperStyle", - 0, REG_SZ, (const BYTE *)style, size); - ::SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, (PVOID)path.get(), - SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); - // Close the key we opened. - ::RegCloseKey(key); - } - } - return rv; -} - -NS_IMETHODIMP -nsWindowsShellService::GetDesktopBackgroundColor(PRUint32* aColor) -{ - PRUint32 color = ::GetSysColor(COLOR_DESKTOP); - *aColor = (GetRValue(color) << 16) | (GetGValue(color) << 8) | GetBValue(color); - return NS_OK; -} - -NS_IMETHODIMP -nsWindowsShellService::SetDesktopBackgroundColor(PRUint32 aColor) -{ - int parameter = COLOR_BACKGROUND; - BYTE r = (aColor >> 16); - BYTE g = (aColor << 16) >> 24; - BYTE b = (aColor << 24) >> 24; - COLORREF color = RGB(r,g,b); - - ::SetSysColors(1, ¶meter, &color); - - PRBool result = PR_FALSE; - DWORD dwDisp = 0; - HKEY key; - // Try to create/open a subkey under HKCU. - DWORD rv = ::RegCreateKeyExW(HKEY_CURRENT_USER, - L"Control Panel\\Colors", 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, - &key, &dwDisp); - if (REG_SUCCEEDED(rv)) { - char rgb[12]; - sprintf((char*)rgb, "%u %u %u\0", r, g, b); - NS_ConvertUTF8toUTF16 backColor(rgb); - ::RegSetValueExW(key, L"Background", - 0, REG_SZ, (const BYTE *)backColor.get(), - (backColor.Length() + 1) * sizeof(PRUnichar)); - } - - // Close the key we opened. - ::RegCloseKey(key); - return NS_OK; -} - - -/* helper routine. Iterate over the passed in settings array, setting each key - * in the windows registry. -*/ - -void -nsWindowsShellService::setKeysForSettings(SETTING aSettings[], PRInt32 aSize) -{ - SETTING* settings; - SETTING* end = aSettings + aSize; - PRInt32 offset; - - for (settings = aSettings; settings < end; ++settings) - { - NS_ConvertUTF8toUTF16 data(settings->valueData); - NS_ConvertUTF8toUTF16 key(settings->keyName); - NS_ConvertUTF8toUTF16 value(settings->valueName); - if (settings->flags & APP_PATH_SUBSTITUTION) - { - offset = data.Find("%APPPATH%"); - data.Replace(offset, 9, mAppLongPath); - } - if (settings->flags & MAPIDLL_PATH_SUBSTITUTION) - { - offset = data.Find("%MAPIDLLPATH%"); - data.Replace(offset, 13, mMapiDLLPath); - } - if (settings->flags & APP_NAME_SUBSTITUTION) - { - offset = key.Find("%APPNAME%"); - key.Replace(offset, 9, mBrandFullName); - } - if (settings->flags & UNINST_PATH_SUBSTITUTION) - { - offset = data.Find("%UNINSTPATH%"); - data.Replace(offset, 12, mUninstallPath); - } - - SetRegKey(key, value, data, settings->flags & HKLM_ONLY); - } -} - diff --git a/mozilla/suite/shell/src/nsWindowsShellService.h b/mozilla/suite/shell/src/nsWindowsShellService.h deleted file mode 100644 index 9168a16cc02..00000000000 --- a/mozilla/suite/shell/src/nsWindowsShellService.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; 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 Shell Service. - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Ben Goodger - * Aaron Kaluszka - * Frank Wein - * - * Alternatively, the contents of this file may be used under the terms of - * either 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 ***** */ - -#include "nscore.h" -#include "nsIShellService.h" -#include "nsStringAPI.h" - -#include - -#define NS_SUITEWININTEGRATION_CONTRACTID "@mozilla.org/suite/shell-service;1" - -#define NS_SUITEWININTEGRATION_CID \ -{0x39b688ec, 0xe308, 0x49e5, {0xbe, 0x6b, 0x28, 0xdc, 0x7f, 0xcd, 0x61, 0x54}} - -typedef struct { - char* keyName; - char* valueName; - char* valueData; - - PRInt32 flags; -} SETTING; - -class nsWindowsShellService : public nsIShellService -{ -public: - nsWindowsShellService() : mCheckedThisSessionClient(PR_FALSE) {}; - ~nsWindowsShellService() {}; - NS_HIDDEN_(nsresult) Init(); - - NS_DECL_ISUPPORTS - NS_DECL_NSISHELLSERVICE - -protected: - PRBool IsDefaultClientVista(PRBool aStartupCheck, - PRUint16 aApps, PRBool* aIsDefaultClient); - PRBool SetDefaultClientVista(PRUint16 aApps); - void setKeysForSettings(SETTING aSettings[], PRInt32 aSize); - void SetRegKey(const nsString& aKeyName, - const nsString& aValueName, - const nsString& aValue, PRBool aHKLMOnly); - PRBool TestForDefault(SETTING aSettings[], PRInt32 aSize); - - nsresult setDefaultBrowser(); - nsresult setDefaultMail(); - nsresult setDefaultNews(); - -private: - PRBool mCheckedThisSessionClient; - nsString mAppLongPath; - nsString mAppShortPath; - nsString mMapiDLLPath; - nsString mUninstallPath; - nsString mBrandFullName; - nsString mBrandShortName; -}; -