зеркало из https://github.com/mozilla/gecko-dev.git
Bug #353906 --> modernize mail's registry code, implementing toolkit's nsIShellService, separating it out from the MAPI implementation. We now have a new default client dialog, and new options UI.
this work is a precursor for vista integration sr=bienvenu
This commit is contained in:
Родитель
afd0d3cba1
Коммит
8f592119ba
|
@ -135,6 +135,7 @@ pref("extensions.dss.switchPending", false); // Non-dynamic switch pending af
|
|||
pref("xpinstall.whitelist.add", "update.mozilla.org");
|
||||
pref("xpinstall.whitelist.add.103", "addons.mozilla.org");
|
||||
|
||||
pref("mail.shell.checkDefaultClient", true);
|
||||
pref("mail.phishing.detection.enabled", true); // enable / disable phishing detection for link clicks
|
||||
pref("mail.spellcheck.inline", true);
|
||||
pref("mail.showPreviewText", true); // enables preview text in mail alerts and folder tooltips
|
||||
|
@ -213,12 +214,6 @@ pref("network.cookie.cookieBehavior", 3); // 0-Accept, 1-dontAcceptForeign, 2-do
|
|||
// End seamonkey suite mailnews.js pref overrides
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
// whether to check if we are the default mail, news or feed client
|
||||
// on startup.
|
||||
pref("mail.checkDefaultMail", true);
|
||||
pref("mail.checkDefaultNews", false);
|
||||
pref("mail.checkDefaultFeed", false);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Overrides for generic app behavior from the seamonkey suite's all.js
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -44,6 +44,10 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
DEFINES += -DMOZ_APP_VERSION=$(MOZ_APP_VERSION)
|
||||
|
||||
ifneq (,$(filter windows gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
|
||||
DEFINES += -DHAVE_SHELL_SERVICE=1
|
||||
endif
|
||||
|
||||
ifndef MOZ_BRANDING_DIRECTORY
|
||||
DEFINES += -DMOZ_USE_GENERIC_BRANDING
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# ***** 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 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):
|
||||
#
|
||||
# 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 dialog can only be opened if we have a shell service
|
||||
|
||||
var gDefaultClientDialog = {
|
||||
onLoad: function ()
|
||||
{
|
||||
var nsIShellService = Components.interfaces.nsIShellService;
|
||||
var shellSvc = Components.classes["@mozilla.org/mail/shell-service;1"]
|
||||
.getService(nsIShellService);
|
||||
|
||||
// initialize the check boxes based on the default app states.
|
||||
var mailCheckbox = document.getElementById('checkMail');
|
||||
var newsCheckbox = document.getElementById('checkNews');
|
||||
var rssCheckbox = document.getElementById('checkRSS');
|
||||
|
||||
mailCheckbox.disabled = shellSvc.isDefaultClient(false, nsIShellService.MAIL);
|
||||
// as an optimization, if we aren't already the default mail client, then pre-check that option
|
||||
// for the user. We'll leave news and RSS alone.
|
||||
mailCheckbox.checked = true;
|
||||
newsCheckbox.checked = newsCheckbox.disabled = shellSvc.isDefaultClient(false, nsIShellService.NEWS);
|
||||
rssCheckbox.checked = rssCheckbox.disabled = shellSvc.isDefaultClient(false, nsIShellService.RSS);
|
||||
|
||||
// read the raw pref value and not shellSvc.shouldCheckDefaultMail
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
document.getElementById('checkOnStartup').checked = prefs.getBoolPref("mail.shell.checkDefaultClient");
|
||||
},
|
||||
|
||||
onAccept: function()
|
||||
{
|
||||
// for each checked item, if we aren't already the default, make us the default.
|
||||
var nsIShellService = Components.interfaces.nsIShellService;
|
||||
var shellSvc = Components.classes["@mozilla.org/mail/shell-service;1"]
|
||||
.getService(nsIShellService);
|
||||
var appTypes = 0;
|
||||
if (document.getElementById('checkMail').checked && !shellSvc.isDefaultClient(false, nsIShellService.MAIL))
|
||||
appTypes |= nsIShellService.MAIL;
|
||||
if (document.getElementById('checkNews').checked && !shellSvc.isDefaultClient(false, nsIShellService.NEWS))
|
||||
appTypes |= nsIShellService.NEWS;
|
||||
if (document.getElementById('checkRSS').checked && !shellSvc.isDefaultClient(false, nsIShellService.RSS))
|
||||
appTypes |= nsIShellService.RSS;
|
||||
|
||||
if (appTypes)
|
||||
shellSvc.setDefaultClient(false, appTypes);
|
||||
|
||||
shellSvc.shouldCheckDefaultClient = document.getElementById('checkOnStartup').checked;
|
||||
}
|
||||
};
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0"?>
|
||||
# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# ***** 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 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
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
<!ENTITY % defaultClientDTD SYSTEM "chrome://messenger/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="gDefaultClientDialog.onLoad();"
|
||||
ondialogaccept="return gDefaultClientDialog.onAccept();"
|
||||
title="&defaultClient.title;">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/defaultClientDialog.js"/>
|
||||
|
||||
<description>&defaultClient.intro;</description>
|
||||
<listbox rows="3" seltype="single">
|
||||
<listitem id="checkMail" type="checkbox" label="&email.label;"/>
|
||||
<listitem id="checkNews" type="checkbox" label="&newsgroups.label;"/>
|
||||
<listitem id="checkRSS" type="checkbox" label="&rss.label;"/>
|
||||
</listbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
<checkbox id="checkOnStartup" label="&checkOnStartup.label;" accesskey="&checkOnStartup.accesskey;"/>
|
||||
|
||||
</dialog>
|
|
@ -70,6 +70,7 @@
|
|||
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
|
||||
<stringbundle id="bundle_shell" src="chrome://messenger/locale/shellservice.properties"/>
|
||||
<stringbundle id="bundle_findBar" src="chrome://global/locale/findbar.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
|
|
|
@ -863,6 +863,19 @@ function delayedOnLoadMessenger()
|
|||
gStartMsgKey = (window.arguments.length > 1) ? window.arguments[1]: nsMsgKey_None;
|
||||
gSearchEmailAddress = (window.arguments.length > 2) ? window.arguments[2] : null;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
var nsIShellService = Components.interfaces.nsIShellService;
|
||||
var shellService = Components.classes["@mozilla.org/mail/shell-service;1"].getService(nsIShellService);
|
||||
|
||||
// show the default client dialog only if we have at least one account,
|
||||
// if we should check for the default client,
|
||||
// and we aren't already the default for all of our recognized types (mail, news, rss)
|
||||
if (accountManager.defaultAccount && shellService.shouldCheckDefaultClient
|
||||
&& !shellService.isDefaultClient(false, nsIShellService.MAIL | nsIShellService.NEWS | nsIShellService.RSS))
|
||||
window.openDialog("chrome://messenger/content/defaultClientDialog.xul", "Default Client",
|
||||
"modal,centerscreen,chrome,resizable=no");
|
||||
#endif
|
||||
|
||||
setTimeout("loadStartFolder(gStartFolderUri);", 0);
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ messenger.jar:
|
|||
* content/messenger/subscribe.xul (content/subscribe.xul)
|
||||
content/messenger/subscribe.js (content/subscribe.js)
|
||||
* content/messenger/aboutDialog.xul (content/aboutDialog.xul)
|
||||
* content/messenger/defaultClientDialog.xul (content/defaultClientDialog.xul)
|
||||
* content/messenger/defaultClientDialog.js (content/defaultClientDialog.js)
|
||||
* content/messenger/msgSelectOffline.xul (content/msgSelectOffline.xul)
|
||||
* content/messenger/msgPrintEngine.xul (content/msgPrintEngine.xul)
|
||||
* content/messenger/searchBar.js (content/searchBar.js)
|
||||
|
|
|
@ -44,7 +44,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
DIRS = compose preferences addrbook migration
|
||||
|
||||
ifneq (,$(filter gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
|
||||
ifneq (,$(filter windows gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
|
||||
DIRS += shell
|
||||
endif
|
||||
|
||||
|
|
|
@ -61,11 +61,16 @@ REQUIRES = \
|
|||
msgbase \
|
||||
mailnews \
|
||||
import \
|
||||
shellservice \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = nsModule.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,shell32)
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../migration/src \
|
||||
-I$(srcdir)/../shell \
|
||||
|
@ -75,7 +80,7 @@ SHARED_LIBRARY_LIBS = \
|
|||
../migration/src/$(LIB_PREFIX)profilemigration_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter mac cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
|
||||
ifneq (,$(filter windows mac cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
|
||||
SHARED_LIBRARY_LIBS += ../shell/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsOEProfileMigrator)
|
|||
#include "nsOutlookProfileMigrator.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOutlookProfileMigrator)
|
||||
|
||||
#include "nsMailWinIntegration.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowsShellService)
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN32) || defined(XP_MACOSX)
|
||||
|
@ -107,16 +109,22 @@ static const nsModuleComponentInfo components[] = {
|
|||
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "eudora",
|
||||
nsEudoraProfileMigratorConstructor },
|
||||
#endif
|
||||
#ifdef XP_WIN32
|
||||
{ "Mail Windows Integration",
|
||||
NS_MAILWININTEGRATION_CID,
|
||||
"@mozilla.org/mail/shell-service;1",
|
||||
nsWindowsShellServiceConstructor},
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
{ "Mail GNOME Integration",
|
||||
NS_MAILGNOMEINTEGRATION_CID,
|
||||
"@mozilla.org/mapiregistry;1",
|
||||
"@mozilla.org/mail/shell-service;1",
|
||||
nsMailGNOMEIntegrationConstructor },
|
||||
#endif
|
||||
#ifdef XP_MACOSX
|
||||
{ "Mail Mac Integration",
|
||||
NS_MAILMACINTEGRATION_CID,
|
||||
"@mozilla.org/mapiregistry;1",
|
||||
"@mozilla.org/mail/shell-service;1",
|
||||
nsMailMacIntegrationConstructor },
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -44,6 +44,6 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifneq (,$(filter gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
|
||||
ifneq (,$(filter windows gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
|
||||
DEFINES += -DHAVE_SHELL_SERVICE=1
|
||||
endif
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# ***** 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 Thunderbird Preferences System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Scott MacGregor.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Scott MacGregor <mscott@mozilla.org>
|
||||
# Asaf Romano <mozilla.mano@sent.com>
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
const kMailApp = 1;
|
||||
const kNewsApp = 2;
|
||||
const kFeedApp = 3;
|
||||
|
||||
var gDefaultClientPane = {
|
||||
mMapiBundle: null,
|
||||
mBrandBundle: null,
|
||||
|
||||
init: function ()
|
||||
{
|
||||
this.mBrandBundle = document.getElementById("brandBundle");
|
||||
this.mMapiBundle = document.getElementById("mapiBundle");
|
||||
},
|
||||
|
||||
checkDefaultAppNow: function (appType)
|
||||
{
|
||||
var mapiReg = Components.classes["@mozilla.org/mapiregistry;1"]
|
||||
.getService(Components.interfaces.nsIMapiRegistry);
|
||||
|
||||
var brandShortName = this.mBrandBundle.getString("brandShortName");
|
||||
var promptTitle = this.mMapiBundle
|
||||
.getFormattedString("dialogTitle", [brandShortName]);
|
||||
var promptMessage;
|
||||
var IPS = Components.interfaces.nsIPromptService;
|
||||
var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(IPS);
|
||||
|
||||
var isDefault;
|
||||
var str;
|
||||
if (appType == kMailApp)
|
||||
{
|
||||
isDefault = mapiReg.isDefaultMailClient;
|
||||
str = "Mail";
|
||||
}
|
||||
else if (appType == kNewsApp)
|
||||
{
|
||||
isDefault = mapiReg.isDefaultNewsClient;
|
||||
str = "News";
|
||||
}
|
||||
else if (appType == kFeedApp)
|
||||
{
|
||||
isDefault = mapiReg.isDefaultFeedClient;
|
||||
str = "Feed";
|
||||
}
|
||||
else {
|
||||
throw ("Invalid appType value passed to gGeneralPane.checkDefaultAppNow");
|
||||
}
|
||||
|
||||
if (!isDefault)
|
||||
{
|
||||
promptMessage = this.mMapiBundle.getFormattedString("setDefault" + str,
|
||||
[brandShortName]);
|
||||
|
||||
var rv = prompt.confirmEx(window, promptTitle, promptMessage,
|
||||
(IPS.BUTTON_TITLE_YES * IPS.BUTTON_POS_0) +
|
||||
(IPS.BUTTON_TITLE_NO * IPS.BUTTON_POS_1),
|
||||
null, null, null, null, { });
|
||||
if (rv == 0)
|
||||
{
|
||||
if (appType == kMailApp)
|
||||
mapiReg.isDefaultMailClient = true;
|
||||
else if (appType == kNewsApp)
|
||||
mapiReg.isDefaultNewsClient = true;
|
||||
else
|
||||
mapiReg.isDefaultFeedClient = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
promptMessage = this.mMapiBundle.getFormattedString("alreadyDefault" + str,
|
||||
[brandShortName]);
|
||||
|
||||
prompt.alert(window, promptTitle, promptMessage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# ***** 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 Firefox Preferences System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Asaf Romano.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Asaf Romano <mozilla.mano@sent.com>
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
|
||||
|
||||
<!DOCTYPE dialog [
|
||||
<!ENTITY % brandDTD SYSTEM
|
||||
"chrome://branding/locale/brand.dtd">
|
||||
%brandDTD;
|
||||
<!ENTITY % defaultClientDTD SYSTEM
|
||||
"chrome://messenger/locale/preferences/defaultClient.dtd">
|
||||
%defaultClientDTD;
|
||||
]>
|
||||
|
||||
<prefwindow id="DefaultClientDialog"
|
||||
type="child"
|
||||
title="&window.title;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
dlgbuttons="accept,cancel"
|
||||
style="width: &window.width; !important;">
|
||||
<prefpane id="DefaultClientPane" onpaneload="gDefaultClientPane.init();">
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://messenger/content/preferences/defaultClient.js"/>
|
||||
<preferences>
|
||||
<preference id="mail.checkDefaultMail"
|
||||
name="mail.checkDefaultMail"
|
||||
type="bool"/>
|
||||
<preference id="mail.checkDefaultNews"
|
||||
name="mail.checkDefaultNews"
|
||||
type="bool"/>
|
||||
<preference id="mail.checkDefaultFeed"
|
||||
name="mail.checkDefaultFeed"
|
||||
type="bool"/>
|
||||
</preferences>
|
||||
|
||||
<stringbundle id="mapiBundle"
|
||||
src="chrome://messenger-mapi/locale/mapi.properties"/>
|
||||
<stringbundle id="brandBundle"
|
||||
src="chrome://branding/locale/brand.properties"/>
|
||||
|
||||
<description>&whenStartingCheckFor.label;</description>
|
||||
|
||||
<hbox align="center" flex="1">
|
||||
<checkbox id="checkDefaultMail"
|
||||
preference="mail.checkDefaultMail"
|
||||
label="&mailApplication.label;"
|
||||
accesskey="&mailApplication.accesskey;"
|
||||
flex="1"/>
|
||||
<button label="&checkNow.label;"
|
||||
accesskey="&checkMailNow.accesskey;"
|
||||
oncommand="gDefaultClientPane.checkDefaultAppNow(kMailApp);"/>
|
||||
</hbox>
|
||||
<hbox align="center" flex="1">
|
||||
<checkbox id="checkDefaultNews"
|
||||
preference="mail.checkDefaultNews"
|
||||
label="&newsApplication.label;"
|
||||
accesskey="&newsApplication.accesskey;"
|
||||
flex="1"/>
|
||||
<button label="&checkNow.label;"
|
||||
accesskey="&checkNewsNow.accesskey;"
|
||||
oncommand="gDefaultClientPane.checkDefaultAppNow(kNewsApp);"/>
|
||||
</hbox>
|
||||
#ifdef XP_MACOSX
|
||||
<hbox align="center" flex="1">
|
||||
<checkbox id="checkDefaultFeed"
|
||||
preference="mail.checkDefaultFeed"
|
||||
label="&rssFeeds.label;"
|
||||
accesskey="&rssFeeds.accesskey;"
|
||||
flex="1"/>
|
||||
<button label="&checkNow.label;"
|
||||
accesskey="&checkFeedAggregatorNow.accesskey;"
|
||||
oncommand="gDefaultClientPane.checkDefaultAppNow(kFeedApp);"/>
|
||||
</hbox>
|
||||
#endif
|
||||
</prefpane>
|
||||
</prefwindow>
|
|
@ -46,73 +46,43 @@ var gGeneralPane = {
|
|||
|
||||
this.startPageCheck();
|
||||
this.mailSoundCheck();
|
||||
|
||||
#ifdef XP_WIN
|
||||
document.getElementById('mail.checkDefaultMail').valueFromPreferences = this.onReadDefaultMailPref();
|
||||
document.getElementById('mail.checkDefaultNews').valueFromPreferences = this.onReadDefaultNewsPref();
|
||||
document.getElementById('mail.checkDefaultFeed').valueFromPreferences = this.onReadDefaultFeedPref();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
// first check whether nsIMapiRegistry is available. if it's not,
|
||||
// hide the whole default mail/news app section.
|
||||
var mapiReg;
|
||||
try {
|
||||
mapiReg = Components.classes["@mozilla.org/mapiregistry;1"].getService(Components.interfaces.nsIMapiRegistry);
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
if (!mapiReg)
|
||||
document.getElementById("defaultClientBox").hidden = true;
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
/**
|
||||
* Checks whether Thunderbird is currently registered with the operating
|
||||
* system as the default app for mail, rss and news. If Thunderbird is not currently the
|
||||
* default app, the user is given the option of making it the default for each type;
|
||||
* otherwise, the user is informed that Thunderbird is already the default.
|
||||
*/
|
||||
checkDefaultNow: function (aAppType)
|
||||
{
|
||||
var nsIShellService = Components.interfaces.nsIShellService;
|
||||
var shellSvc = Components.classes["@mozilla.org/mail/shell-service;1"].getService(nsIShellService);
|
||||
// if we are already the default for all the types we handle, then alert the user.
|
||||
if (shellSvc.isDefaultClient(false, nsIShellService.MAIL | nsIShellService.NEWS | nsIShellService.RSS))
|
||||
{
|
||||
var brandBundle = document.getElementById("bundleBrand");
|
||||
var shellBundle = document.getElementById("bundleShell");
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
var promptTitle = shellBundle.getString("alreadyDefaultClientTitle");
|
||||
var promptMessage;
|
||||
const IPS = Components.interfaces.nsIPromptService;
|
||||
var psvc = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(IPS);
|
||||
|
||||
promptMessage = shellBundle.getFormattedString("alreadyDefault", [brandShortName]);
|
||||
psvc.alert(window, promptTitle, promptMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise, bring up the default client dialog
|
||||
window.openDialog("chrome://messenger/content/defaultClientDialog.xul", "Default Client",
|
||||
"modal,centerscreen,chrome,resizable=no");
|
||||
}
|
||||
},
|
||||
#endif
|
||||
},
|
||||
|
||||
#ifdef XP_WIN
|
||||
onReadDefaultMailPref: function()
|
||||
{
|
||||
var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"].getService(Components.interfaces.nsIMapiRegistry);
|
||||
document.getElementById('defaultMailClient').checked = mapiRegistry.isDefaultMailClient;
|
||||
return mapiRegistry.isDefaultMailClient;
|
||||
},
|
||||
|
||||
onWriteDefaultMailPref: function()
|
||||
{
|
||||
var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"].getService(Components.interfaces.nsIMapiRegistry);
|
||||
var makeDefaultMailClient = document.getElementById('mail.checkDefaultMail').value;
|
||||
if (mapiRegistry.isDefaultMailClient != makeDefaultMailClient)
|
||||
mapiRegistry.isDefaultMailClient = makeDefaultMailClient;
|
||||
},
|
||||
|
||||
onReadDefaultNewsPref: function()
|
||||
{
|
||||
var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"].getService(Components.interfaces.nsIMapiRegistry);
|
||||
document.getElementById('defaultNewsClient').checked = mapiRegistry.isDefaultNewsClient;
|
||||
return mapiRegistry.isDefaultNewsClient;
|
||||
},
|
||||
|
||||
onWriteDefaultNewsPref: function()
|
||||
{
|
||||
var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"].getService(Components.interfaces.nsIMapiRegistry);
|
||||
var makeDefaultNewsClient = document.getElementById('mail.checkDefaultNews').value;
|
||||
if (mapiRegistry.isDefaultNewsClient != makeDefaultNewsClient)
|
||||
mapiRegistry.isDefaultNewsClient = makeDefaultNewsClient;
|
||||
},
|
||||
|
||||
onReadDefaultFeedPref: function()
|
||||
{
|
||||
var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"].getService(Components.interfaces.nsIMapiRegistry);
|
||||
document.getElementById('defaultFeedClient').checked = mapiRegistry.isDefaultFeedClient;
|
||||
return mapiRegistry.isDefaultFeedClient;
|
||||
},
|
||||
|
||||
onWriteDefaultFeed: function()
|
||||
{
|
||||
var mapiRegistry = Components.classes["@mozilla.org/mapiregistry;1"].getService(Components.interfaces.nsIMapiRegistry);
|
||||
var makeDefaultFeedClient = document.getElementById('mail.checkDefaultFeed').value;
|
||||
if (mapiRegistry.isDefaultFeedClient != makeDefaultFeedClient)
|
||||
mapiRegistry.isDefaultFeedClient = makeDefaultFeedClient;
|
||||
},
|
||||
|
||||
#endif
|
||||
startPageCheck: function()
|
||||
{
|
||||
document.getElementById("mailnewsStartPageUrl").disabled = !document.getElementById("mailnewsStartPageEnabled").checked;
|
||||
|
@ -131,15 +101,6 @@ var gGeneralPane = {
|
|||
this.mPane.userChangedValue(startPageUrlField);
|
||||
},
|
||||
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
openDefaultClientDialog: function ()
|
||||
{
|
||||
document.documentElement
|
||||
.openSubDialog("chrome://messenger/content/preferences/defaultClient.xul",
|
||||
"", null);
|
||||
},
|
||||
#endif
|
||||
|
||||
showConnections: function ()
|
||||
{
|
||||
document.documentElement
|
||||
|
|
|
@ -51,81 +51,36 @@
|
|||
<script type="application/x-javascript" src="chrome://messenger/content/preferences/general.js"/>
|
||||
|
||||
<preferences>
|
||||
<preference id="mail.checkDefaultMail"
|
||||
name="mail.checkDefaultMail"
|
||||
#ifdef XP_WIN
|
||||
onchange="return gGeneralPane.onWriteDefaultMailPref();"
|
||||
#endif
|
||||
type="bool"/>
|
||||
#ifdef XP_WIN
|
||||
<preference id="mail.checkDefaultNews"
|
||||
name="mail.checkDefaultNews"
|
||||
onchange="return gGeneralPane.onWriteDefaultNewsPref();"
|
||||
type="bool"/>
|
||||
<preference id="mail.checkDefaultFeed"
|
||||
name="mail.checkDefaultFeed"
|
||||
onchange="return gGeneralPane.onWriteDefaultFeed();"
|
||||
type="bool"/>
|
||||
#endif
|
||||
<preference id="mail.shell.checkDefaultClient" name="mail.shell.checkDefaultClient" type="bool"/>
|
||||
<preference id="mail.pane_config.dynamic" name="mail.pane_config.dynamic" type="int"/>
|
||||
<preference id="mailnews.reuse_message_window" name="mailnews.reuse_message_window" type="bool"/>
|
||||
<preference id="mailnews.start_page.enabled" name="mailnews.start_page.enabled" type="bool"/>
|
||||
<preference id="mailnews.start_page.url" name="mailnews.start_page.url" type="wstring"/>
|
||||
<preference id="mail.biff.show_alert" name="mail.biff.show_alert" type="bool"/>
|
||||
<preference id="mail.biff.play_sound" name="mail.biff.play_sound" type="bool"/>
|
||||
<preference id="pref.general.disable_button.default_mail"
|
||||
name="pref.general.disable_button.default_mail"
|
||||
type="bool"/>
|
||||
#ifdef XP_MACOSX
|
||||
<preference id="mail.biff.animate_dock_icon" name="mail.biff.animate_dock_icon" type="bool"/>
|
||||
#endif
|
||||
</preferences>
|
||||
|
||||
<groupbox align="start" id="defaultClientBox">
|
||||
<caption label="&generalSettings.caption;"/>
|
||||
|
||||
#ifdef XP_WIN
|
||||
<label value="&generalSettings.label;"/>
|
||||
<hbox class="indent">
|
||||
<checkbox id="defaultMailClient" label="&setDefaultMailClient.label;"
|
||||
accesskey="&setDefaultMailClient.accesskey;"
|
||||
preference="mail.checkDefaultMail"/>
|
||||
|
||||
<checkbox id="defaultNewsClient" label="&setDefaultNewsClient.label;"
|
||||
preference="mail.checkDefaultNews"
|
||||
accesskey="&setDefaultNewsClient.accesskey;"/>
|
||||
|
||||
<checkbox id="defaultFeedClient" label="&setDefaultFeedClient.label;"
|
||||
preference="mail.checkDefaultFeed"
|
||||
accesskey="&setDefaultFeedClient.accesskey;"/>
|
||||
</hbox>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
<hbox flex="1" align="center">
|
||||
<checkbox id="checkDefaultMail"
|
||||
preference="mail.checkDefaultMail"
|
||||
label="&checkDefaultMailClient.label;"
|
||||
accesskey="&checkDefaultMailClient.accesskey;"
|
||||
flex="1"/>
|
||||
<button label="&defaultClientAdvanced.label;"
|
||||
accesskey="&defaultClientAdvanced.accesskey;"
|
||||
oncommand="gGeneralPane.openDefaultClientDialog()"/>
|
||||
<stringbundle id="bundleShell" src="chrome://messenger/locale/shellservice.properties"/>
|
||||
<stringbundle id="bundleBrand" src="chrome://branding/locale/brand.properties"/>
|
||||
|
||||
<groupbox id="systemDefaultsGroup" orient="vertical">
|
||||
<caption label="&systemDefaults.label;"/>
|
||||
<hbox id="checkDefaultBox" align="center" flex="1">
|
||||
<checkbox id="alwaysCheckDefault" preference="mail.shell.checkDefaultClient"
|
||||
label="&alwaysCheckDefault.label;" accesskey="&alwaysCheckDefault.accesskey;"
|
||||
flex="1" style="height: &alwaysCheckDefault.height;"/>
|
||||
<button id="checkDefaultButton" label="&checkNow.label;" accesskey="&checkNow.accesskey;"
|
||||
oncommand="gGeneralPane.checkDefaultNow();" preference="pref.general.disable_button.default_mail"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
#endif
|
||||
</groupbox>
|
||||
|
||||
<!--
|
||||
<groupbox>
|
||||
<caption label="&windowSettings.label;"/>
|
||||
<label value="&selectWindowLayout.label;" accesskey="&selectWindowLayout.accesskey;" control="mailPaneConfig"/>
|
||||
<hbox align="center" class="indent">
|
||||
<radiogroup id="mailPaneConfig" preference="mail.pane_config.dynamic" orient="horizontal">
|
||||
<radio class="mailPaneConfigIcon" value="0" id="classic"/>
|
||||
<radio class="mailPaneConfigIcon" value="1" id="wide"/>
|
||||
<radio class="mailPaneConfigIcon" value="2" id="vertical"/>
|
||||
</radiogroup>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
-->
|
||||
|
||||
<groupbox>
|
||||
<caption label="&messengerStartPage.label;"/>
|
||||
<hbox align="start">
|
||||
|
|
|
@ -32,10 +32,6 @@ messenger.jar:
|
|||
* content/messenger/preferences/fonts.xul
|
||||
* content/messenger/preferences/notifications.xul
|
||||
* content/messenger/preferences/notifications.js
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
* content/messenger/preferences/defaultClient.xul
|
||||
* content/messenger/preferences/defaultClient.js
|
||||
#endif
|
||||
* content/messenger/AccountManager.xul (/mailnews/base/prefs/resources/content/AccountManager.xul)
|
||||
content/messenger/AccountManager.js (/mailnews/base/prefs/resources/content/AccountManager.js)
|
||||
content/messenger/am-main.xul (/mailnews/base/prefs/resources/content/am-main.xul)
|
||||
|
@ -73,7 +69,7 @@ messenger.jar:
|
|||
content/messenger/aw-login.js (/mailnews/base/prefs/resources/content/aw-login.js)
|
||||
content/messenger/aw-accname.js (/mailnews/base/prefs/resources/content/aw-accname.js)
|
||||
content/messenger/aw-done.js (/mailnews/base/prefs/resources/content/aw-done.js)
|
||||
content/messenger/accountUtils.js (/mailnews/base/prefs/resources/content/accountUtils.js)
|
||||
* content/messenger/accountUtils.js (/mailnews/base/prefs/resources/content/accountUtils.js)
|
||||
content/messenger/amUtils.js (/mailnews/base/prefs/resources/content/amUtils.js)
|
||||
content/messenger/ispUtils.js (/mailnews/base/prefs/resources/content/ispUtils.js)
|
||||
content/messenger/SmtpServerEdit.xul (/mailnews/base/prefs/resources/content/SmtpServerEdit.xul)
|
||||
|
|
|
@ -42,11 +42,14 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public
|
||||
|
||||
MODULE = shellservice
|
||||
LIBRARY_NAME = shellservice_s
|
||||
MODULE_NAME = nsMailShellModule
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
|
@ -58,8 +61,13 @@ REQUIRES = \
|
|||
windowwatcher \
|
||||
pref \
|
||||
embed_base \
|
||||
msgMapi \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
CPPSRCS = nsMailWinIntegration.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
|
||||
CPPSRCS = nsMailGNOMEIntegration.cpp
|
||||
endif
|
||||
|
@ -71,5 +79,13 @@ endif
|
|||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
JS_SET_MAIL_COMPONENT = nsSetDefaultMail.js
|
||||
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
|
||||
libs::
|
||||
$(INSTALL) $(srcdir)/$(JS_SET_MAIL_COMPONENT) $(DIST)/bin/components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)/bin/components/$(JS_SET_MAIL_COMPONENT)
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the packages being supplied by this jar -->
|
||||
<RDF:Seq about="urn:mozilla:package:root">
|
||||
<RDF:li resource="urn:mozilla:package:messenger-mapi"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- package information -->
|
||||
<RDF:Description about="urn:mozilla:package:messenger-mapi"
|
||||
chrome:displayName="Messenger"
|
||||
chrome:author="mozilla.org"
|
||||
chrome:name="messenger-mapi"
|
||||
#expand chrome:localeVersion="__MOZILLA_LOCALE_VERSION__"
|
||||
#expand chrome:skinVersion="__MOZILLA_SKIN_VERSION__">
|
||||
</RDF:Description>
|
||||
|
||||
</RDF:RDF>
|
|
@ -1,2 +0,0 @@
|
|||
messenger.jar:
|
||||
* content/messenger-mapi/contents.rdf (contents.rdf)
|
|
@ -65,6 +65,13 @@ static const char* const sNewsProtocols[] = {
|
|||
"nntp"
|
||||
};
|
||||
|
||||
static const char* const sFeedProtocols[] = {
|
||||
"feed"
|
||||
};
|
||||
|
||||
nsMailGNOMEIntegration::nsMailGNOMEIntegration(): mCheckedThisSession(PR_FALSE)
|
||||
{}
|
||||
|
||||
nsresult
|
||||
nsMailGNOMEIntegration::Init()
|
||||
{
|
||||
|
@ -90,19 +97,64 @@ nsMailGNOMEIntegration::Init()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = appPath->GetNativePath(mAppPath);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool isDefault;
|
||||
nsMailGNOMEIntegration::GetIsDefaultMailClient(&isDefault);
|
||||
mShowMailDialog = !isDefault;
|
||||
NS_IMPL_ISUPPORTS1(nsMailGNOMEIntegration, nsIShellService)
|
||||
|
||||
nsMailGNOMEIntegration::GetIsDefaultNewsClient(&isDefault);
|
||||
mShowNewsDialog = !isDefault;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::IsDefaultClient(PRBool aStartupCheck, PRUint16 aApps, PRBool * aIsDefaultClient)
|
||||
{
|
||||
*aIsDefaultClient = PR_TRUE;
|
||||
if (aApps & nsIShellService::MAIL)
|
||||
*aIsDefaultClient &= checkDefault(sMailProtocols, NS_ARRAY_LENGTH(sMailProtocols));
|
||||
if (aApps & nsIShellService::NEWS)
|
||||
*aIsDefaultClient &= checkDefault(sNewsProtocols, NS_ARRAY_LENGTH(sNewsProtocols));
|
||||
if (aApps & nsIShellService::RSS)
|
||||
*aIsDefaultClient &= checkDefault(sFeedProtocols, NS_ARRAY_LENGTH(sFeedProtocols));
|
||||
|
||||
// If this is the first mail window, maintain internal state that we've
|
||||
// checked this session (so that subsequent window opens don't show the
|
||||
// default client dialog).
|
||||
if (aStartupCheck)
|
||||
mCheckedThisSession = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMailGNOMEIntegration, nsIMapiRegistry)
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::SetDefaultClient(PRBool aForAllUsers, PRUint16 aApps)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aApps & nsIShellService::MAIL)
|
||||
rv |= MakeDefault(sMailProtocols, NS_ARRAY_LENGTH(sMailProtocols));
|
||||
if (aApps & nsIShellService::NEWS)
|
||||
rv |= MakeDefault(sNewsProtocols, NS_ARRAY_LENGTH(sNewsProtocols));
|
||||
if (aApps & nsIShellService::RSS)
|
||||
rv |= MakeDefault(sFeedProtocols, NS_ARRAY_LENGTH(sFeedProtocols));
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::GetShouldCheckDefaultClient(PRBool* aResult)
|
||||
{
|
||||
if (mCheckedThisSession)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
return prefs->GetBoolPref("mail.shell.checkDefaultClient", aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::SetShouldCheckDefaultClient(PRBool aShouldCheck)
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
return prefs->SetBoolPref("mail.shell.checkDefaultClient", aShouldCheck);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMailGNOMEIntegration::KeyMatchesAppName(const char *aKeyValue) const
|
||||
|
@ -129,11 +181,9 @@ nsMailGNOMEIntegration::KeyMatchesAppName(const char *aKeyValue) const
|
|||
return matches;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMailGNOMEIntegration::CheckDefault(const char* const *aProtocols,
|
||||
unsigned int aLength, PRBool *aIsDefault)
|
||||
PRBool
|
||||
nsMailGNOMEIntegration::CheckDefault(const char* const *aProtocols, unsigned int aLength)
|
||||
{
|
||||
*aIsDefault = PR_FALSE;
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
|
||||
PRBool enabled;
|
||||
|
@ -143,27 +193,26 @@ nsMailGNOMEIntegration::CheckDefault(const char* const *aProtocols,
|
|||
handler.Truncate();
|
||||
nsresult rv = gconf->GetAppForProtocol(nsDependentCString(aProtocols[i]),
|
||||
&enabled, handler);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// The string will be something of the form: [/path/to/]app "%s"
|
||||
// We want to remove all of the parameters and get just the binary name.
|
||||
|
||||
// The string will be something of the form: [/path/to/]app "%s"
|
||||
// We want to remove all of the parameters and get just the binary name.
|
||||
gint argc;
|
||||
gchar **argv;
|
||||
|
||||
gint argc;
|
||||
gchar **argv;
|
||||
if (g_shell_parse_argv(handler.get(), &argc, &argv, NULL) && argc > 0) {
|
||||
handler.Assign(argv[0]);
|
||||
g_strfreev(argv);
|
||||
} else
|
||||
return PR_FALSE;
|
||||
|
||||
if (g_shell_parse_argv(handler.get(), &argc, &argv, NULL) && argc > 0) {
|
||||
handler.Assign(argv[0]);
|
||||
g_strfreev(argv);
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!KeyMatchesAppName(handler.get()) || !enabled)
|
||||
return PR_FALSE; // the handler is disabled or set to another app
|
||||
}
|
||||
|
||||
if (!KeyMatchesAppName(handler.get()) || !enabled)
|
||||
return NS_OK; // the handler is disabled or set to another app
|
||||
}
|
||||
|
||||
*aIsDefault = PR_TRUE;
|
||||
return NS_OK;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -181,163 +230,3 @@ nsMailGNOMEIntegration::MakeDefault(const char* const *aProtocols,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::GetIsDefaultMailClient(PRBool *aIsDefault)
|
||||
{
|
||||
return CheckDefault(sMailProtocols, NS_ARRAY_LENGTH(sMailProtocols),
|
||||
aIsDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::SetIsDefaultMailClient(PRBool aIsDefault)
|
||||
{
|
||||
NS_ASSERTION(!aIsDefault, "Should never be called with aIsDefault=false");
|
||||
return MakeDefault(sMailProtocols, NS_ARRAY_LENGTH(sMailProtocols));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::GetIsDefaultNewsClient(PRBool *aIsDefault)
|
||||
{
|
||||
return CheckDefault(sNewsProtocols, NS_ARRAY_LENGTH(sNewsProtocols),
|
||||
aIsDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::SetIsDefaultNewsClient(PRBool aIsDefault)
|
||||
{
|
||||
NS_ASSERTION(!aIsDefault, "Should never be called with aIsDefault=false");
|
||||
return MakeDefault(sNewsProtocols, NS_ARRAY_LENGTH(sNewsProtocols));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::GetIsDefaultFeedClient(PRBool *aIsDefault)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::SetIsDefaultFeedClient(PRBool aIsDefault)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::GetShowDialog(PRBool *aShow)
|
||||
{
|
||||
*aShow = (mShowMailDialog || mShowNewsDialog);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::ShowMailIntegrationDialog(nsIDOMWindow* aParentWindow)
|
||||
{
|
||||
nsCOMPtr<nsIPrefService> pref = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIPrefBranch> branch;
|
||||
pref->GetBranch("", getter_AddRefs(branch));
|
||||
|
||||
PRBool showMailDialog, showNewsDialog;
|
||||
branch->GetBoolPref("mail.checkDefaultMail", &showMailDialog);
|
||||
branch->GetBoolPref("mail.checkDefaultNews", &showNewsDialog);
|
||||
|
||||
if (!((mShowMailDialog && showMailDialog) ||
|
||||
(mShowNewsDialog && showNewsDialog)))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(bundleService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
bundleService->CreateBundle("chrome://branding/locale/brand.properties",
|
||||
getter_AddRefs(brandBundle));
|
||||
NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE);
|
||||
|
||||
nsXPIDLString brandShortName;
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandShortName));
|
||||
|
||||
nsCOMPtr<nsIStringBundle> mapiBundle;
|
||||
bundleService->CreateBundle("chrome://messenger-mapi/locale/mapi.properties",
|
||||
getter_AddRefs(mapiBundle));
|
||||
NS_ENSURE_TRUE(mapiBundle, NS_ERROR_FAILURE);
|
||||
|
||||
nsXPIDLString dialogTitle;
|
||||
const PRUnichar *brandStrings[] = { brandShortName.get() };
|
||||
|
||||
nsresult rv =
|
||||
mapiBundle->FormatStringFromName(NS_LITERAL_STRING("dialogTitle").get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogTitle));
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLString checkboxText;
|
||||
rv = mapiBundle->GetStringFromName(NS_LITERAL_STRING("checkboxText").get(),
|
||||
getter_Copies(checkboxText));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPromptService> promptService =
|
||||
do_GetService(NS_PROMPTSERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(promptService, NS_ERROR_FAILURE);
|
||||
|
||||
if (mShowMailDialog && showMailDialog) {
|
||||
nsXPIDLString dialogText;
|
||||
rv = mapiBundle->FormatStringFromName(NS_LITERAL_STRING("dialogText").get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogText));
|
||||
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRInt32 buttonPressed = 0;
|
||||
rv = promptService->ConfirmEx(aParentWindow, dialogTitle, dialogText.get(),
|
||||
(nsIPromptService::BUTTON_TITLE_YES *
|
||||
nsIPromptService::BUTTON_POS_0) +
|
||||
(nsIPromptService::BUTTON_TITLE_NO *
|
||||
nsIPromptService::BUTTON_POS_1),
|
||||
nsnull, nsnull, nsnull,
|
||||
checkboxText, &checkValue, &buttonPressed);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (checkValue)
|
||||
branch->SetBoolPref("mail.checkDefaultMail", PR_FALSE);
|
||||
mShowMailDialog = PR_FALSE;
|
||||
|
||||
if (buttonPressed == 0) {
|
||||
rv = nsMailGNOMEIntegration::SetIsDefaultMailClient(PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
if (mShowNewsDialog && showNewsDialog) {
|
||||
nsXPIDLString dialogText;
|
||||
rv = mapiBundle->FormatStringFromName(NS_LITERAL_STRING("newsDialogText").get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogText));
|
||||
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRInt32 buttonPressed = 0;
|
||||
rv = promptService->ConfirmEx(aParentWindow, dialogTitle, dialogText.get(),
|
||||
(nsIPromptService::BUTTON_TITLE_YES *
|
||||
nsIPromptService::BUTTON_POS_0) +
|
||||
(nsIPromptService::BUTTON_TITLE_NO *
|
||||
nsIPromptService::BUTTON_POS_1),
|
||||
nsnull, nsnull, nsnull,
|
||||
checkboxText, &checkValue, &buttonPressed);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (checkValue)
|
||||
branch->SetBoolPref("mail.checkDefaultNews", PR_FALSE);
|
||||
mShowNewsDialog = PR_FALSE;
|
||||
|
||||
if (buttonPressed == 0)
|
||||
rv = nsMailGNOMEIntegration::SetIsDefaultNewsClient(PR_TRUE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailGNOMEIntegration::RegisterMailAndNewsClient()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,32 +39,31 @@
|
|||
#ifndef nsMailGNOMEIntegration_h_
|
||||
#define nsMailGNOMEIntegration_h_
|
||||
|
||||
#include "nsIMapiRegistry.h"
|
||||
#include "nsIShellService.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_MAILGNOMEINTEGRATION_CID \
|
||||
{0xbddef0f4, 0x5e2d, 0x4846, {0xbd, 0xec, 0x86, 0xd0, 0x78, 0x1d, 0x8d, 0xed}}
|
||||
|
||||
class nsMailGNOMEIntegration : public nsIMapiRegistry
|
||||
class nsMailGNOMEIntegration : public nsIShellService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMAPIREGISTRY
|
||||
NS_DECL_NSISHELLSERVICE
|
||||
|
||||
NS_HIDDEN_(nsresult) Init();
|
||||
nsMailGNOMEIntegration();
|
||||
|
||||
protected:
|
||||
virtual ~nsMailGNOMEIntegration() {};
|
||||
|
||||
PRBool KeyMatchesAppName(const char *aKeyValue) const;
|
||||
PRBool checkDefault(const char* const *aProtocols, unsigned int aLength);
|
||||
nsresult MakeDefault(const char* const *aProtocols, unsigned int aLength);
|
||||
private:
|
||||
~nsMailGNOMEIntegration() {}
|
||||
|
||||
NS_HIDDEN_(PRBool) KeyMatchesAppName(const char *aKeyValue) const;
|
||||
NS_HIDDEN_(nsresult) CheckDefault(const char* const *aProtocols,
|
||||
unsigned int aLength, PRBool *aIsDefault);
|
||||
NS_HIDDEN_(nsresult) MakeDefault(const char* const *aProtocols,
|
||||
unsigned int aLength);
|
||||
|
||||
PRPackedBool mUseLocaleFilenames;
|
||||
PRPackedBool mShowMailDialog;
|
||||
PRPackedBool mShowNewsDialog;
|
||||
PRPackedBool mCheckedThisSession;
|
||||
nsCString mAppPath;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Asaf Romano <mozilla.mano@sent.com>
|
||||
* Scott MacGregor <mscott@mozilla.org>
|
||||
*
|
||||
* 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
|
||||
|
@ -59,23 +60,69 @@ extern "C" {
|
|||
extern OSStatus _LSSaveAndRefresh(void);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMailMacIntegration, nsIMapiRegistry)
|
||||
NS_IMPL_ISUPPORTS1(nsMailMacIntegration, nsIShellService)
|
||||
|
||||
nsMailMacIntegration::nsMailMacIntegration()
|
||||
nsMailMacIntegration::nsMailMacIntegration(): mCheckedThisSession(PR_FALSE)
|
||||
{}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::IsDefaultClient(PRBool aStartupCheck, PRUint16 aApps, PRBool * aIsDefaultClient)
|
||||
{
|
||||
PRBool isDefault;
|
||||
GetIsDefaultMailClient(&isDefault);
|
||||
mShowMailDialog = !isDefault;
|
||||
GetIsDefaultNewsClient(&isDefault);
|
||||
mShowNewsDialog = !isDefault;
|
||||
GetIsDefaultFeedClient(&isDefault);
|
||||
mShowFeedDialog = !isDefault;
|
||||
*aIsDefaultClient = PR_TRUE;
|
||||
if (aApps & nsIShellService::MAIL)
|
||||
*aIsDefaultClient &= isDefaultHandlerForProtocol(CFSTR("mailto"));
|
||||
if (aApps & nsIShellService::NEWS)
|
||||
*aIsDefaultClient &= isDefaultHandlerForProtocol(CFSTR("news"));
|
||||
if (aApps & nsIShellService::RSS)
|
||||
*aIsDefaultClient &= isDefaultHandlerForProtocol(CFSTR("feed"));
|
||||
|
||||
// if this is the first mail window, maintain internal state that we've
|
||||
// checked this session (so that subsequent window opens don't show the
|
||||
// default client dialog.
|
||||
|
||||
if (aStartupCheck)
|
||||
mCheckedThisSession = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMailMacIntegration::IsDefaultHandlerForProtocol(CFStringRef aScheme,
|
||||
PRBool *aIsDefault)
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::SetDefaultClient(PRBool aForAllUsers, PRUint16 aApps)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aApps & nsIShellService::MAIL)
|
||||
rv |= setAsDefaultHandlerForProtocol(CFSTR("mailto"));
|
||||
if (aApps & nsIShellService::RSS)
|
||||
rv |= setAsDefaultHandlerForProtocol(CFSTR("news"));
|
||||
if (aApps & nsIShellService::RSS)
|
||||
rv |= setAsDefaultHandlerForProtocol(CFSTR("feed"));
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::GetShouldCheckDefaultClient(PRBool* aResult)
|
||||
{
|
||||
if (mCheckedThisSession)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
return prefs->GetBoolPref("mail.shell.checkDefaultClient", aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::SetShouldCheckDefaultClient(PRBool aShouldCheck)
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
return prefs->SetBoolPref("mail.shell.checkDefaultClient", aShouldCheck);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMailMacIntegration::isDefaultHandlerForProtocol(CFStringRef aScheme)
|
||||
{
|
||||
PRBool isDefault = PR_FALSE;
|
||||
// Since neither Launch Services nor Internet Config actually differ between
|
||||
// bundles which have the same bundle identifier (That is, if we set our
|
||||
// URL of our bundle as the default handler for the given protocol,
|
||||
|
@ -88,7 +135,7 @@ nsMailMacIntegration::IsDefaultHandlerForProtocol(CFStringRef aScheme,
|
|||
// CFBundleGetIdentifier is expected to return NULL only if the specified
|
||||
// bundle doesn't have a bundle identifier in its dictionary. In this case,
|
||||
// that means a failure, since our bundle does have an identifier.
|
||||
return NS_ERROR_FAILURE;
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
::CFRetain(tbirdID);
|
||||
|
@ -109,18 +156,17 @@ nsMailMacIntegration::IsDefaultHandlerForProtocol(CFStringRef aScheme,
|
|||
if (defaultHandlerID) {
|
||||
::CFRetain(defaultHandlerID);
|
||||
// and compare it to our bundle identifier
|
||||
*aIsDefault = ::CFStringCompare(tbirdID, defaultHandlerID, 0)
|
||||
isDefault = ::CFStringCompare(tbirdID, defaultHandlerID, 0)
|
||||
== kCFCompareEqualTo;
|
||||
::CFRelease(defaultHandlerID);
|
||||
}
|
||||
else {
|
||||
// If the bundle doesn't have an identifier in its info property list,
|
||||
// it's not our bundle.
|
||||
*aIsDefault = PR_FALSE;
|
||||
isDefault = PR_FALSE;
|
||||
}
|
||||
|
||||
::CFRelease(defaultHandlerBundle);
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
::CFRelease(defaultHandlerURL);
|
||||
|
@ -128,16 +174,15 @@ nsMailMacIntegration::IsDefaultHandlerForProtocol(CFStringRef aScheme,
|
|||
else {
|
||||
// If |_LSCopyDefaultSchemeHandlerURL| failed, there's no default
|
||||
// handler for the given protocol
|
||||
*aIsDefault = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
isDefault = PR_FALSE;
|
||||
}
|
||||
|
||||
::CFRelease(tbirdID);
|
||||
return rv;
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMailMacIntegration::SetAsDefaultHandlerForProtocol(CFStringRef aScheme)
|
||||
nsMailMacIntegration::setAsDefaultHandlerForProtocol(CFStringRef aScheme)
|
||||
{
|
||||
CFURLRef tbirdURL = ::CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
|
||||
|
@ -148,189 +193,5 @@ nsMailMacIntegration::SetAsDefaultHandlerForProtocol(CFStringRef aScheme)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::GetIsDefaultMailClient(PRBool *aIsDefault)
|
||||
{
|
||||
return IsDefaultHandlerForProtocol(CFSTR("mailto"), aIsDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::SetIsDefaultMailClient(PRBool aIsDefault)
|
||||
{
|
||||
NS_ASSERTION(!aIsDefault, "Should never be called with aIsDefault=false");
|
||||
return SetAsDefaultHandlerForProtocol(CFSTR("mailto"));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::GetIsDefaultNewsClient(PRBool *aIsDefault)
|
||||
{
|
||||
return IsDefaultHandlerForProtocol(CFSTR("news"), aIsDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::SetIsDefaultNewsClient(PRBool aIsDefault)
|
||||
{
|
||||
NS_ASSERTION(!aIsDefault, "Should never be called with aIsDefault=false");
|
||||
return SetAsDefaultHandlerForProtocol(CFSTR("news"));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::GetIsDefaultFeedClient(PRBool *aIsDefault)
|
||||
{
|
||||
return IsDefaultHandlerForProtocol(CFSTR("feed"), aIsDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::SetIsDefaultFeedClient(PRBool aIsDefault)
|
||||
{
|
||||
NS_ASSERTION(!aIsDefault, "Should never be called with aIsDefault=false");
|
||||
return SetAsDefaultHandlerForProtocol(CFSTR("feed"));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::GetShowDialog(PRBool *aShow)
|
||||
{
|
||||
*aShow = (mShowMailDialog || mShowNewsDialog || mShowFeedDialog);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::ShowMailIntegrationDialog(nsIDOMWindow* aParentWindow)
|
||||
{
|
||||
nsCOMPtr<nsIPrefService> pref = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIPrefBranch> branch;
|
||||
pref->GetBranch("mail.", getter_AddRefs(branch));
|
||||
|
||||
PRBool showMailDialog, showNewsDialog, showFeedDialog;
|
||||
branch->GetBoolPref("checkDefaultMail", &showMailDialog);
|
||||
branch->GetBoolPref("checkDefaultNews", &showNewsDialog);
|
||||
branch->GetBoolPref("checkDefaultFeed", &showFeedDialog);
|
||||
|
||||
if (!((mShowMailDialog && showMailDialog) ||
|
||||
(mShowNewsDialog && showNewsDialog) ||
|
||||
(mShowFeedDialog && showFeedDialog)))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(bundleService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
bundleService->CreateBundle("chrome://branding/locale/brand.properties",
|
||||
getter_AddRefs(brandBundle));
|
||||
NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE);
|
||||
|
||||
nsXPIDLString brandShortName;
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandShortName));
|
||||
|
||||
nsCOMPtr<nsIStringBundle> mapiBundle;
|
||||
bundleService->CreateBundle("chrome://messenger-mapi/locale/mapi.properties",
|
||||
getter_AddRefs(mapiBundle));
|
||||
NS_ENSURE_TRUE(mapiBundle, NS_ERROR_FAILURE);
|
||||
|
||||
nsXPIDLString dialogTitle;
|
||||
const PRUnichar *brandStrings[] = { brandShortName.get() };
|
||||
|
||||
nsresult rv =
|
||||
mapiBundle->FormatStringFromName(NS_LITERAL_STRING("dialogTitle").get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogTitle));
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLString checkboxText;
|
||||
rv = mapiBundle->GetStringFromName(NS_LITERAL_STRING("checkboxText").get(),
|
||||
getter_Copies(checkboxText));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPromptService> promptService =
|
||||
do_GetService(NS_PROMPTSERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(promptService, NS_ERROR_FAILURE);
|
||||
|
||||
if (mShowMailDialog && showMailDialog) {
|
||||
nsXPIDLString dialogText;
|
||||
rv = mapiBundle->FormatStringFromName(NS_LITERAL_STRING("dialogText").get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogText));
|
||||
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRInt32 buttonPressed = 0;
|
||||
rv = promptService->ConfirmEx(aParentWindow, dialogTitle, dialogText.get(),
|
||||
(nsIPromptService::BUTTON_TITLE_YES *
|
||||
nsIPromptService::BUTTON_POS_0) +
|
||||
(nsIPromptService::BUTTON_TITLE_NO *
|
||||
nsIPromptService::BUTTON_POS_1),
|
||||
nsnull, nsnull, nsnull,
|
||||
checkboxText, &checkValue, &buttonPressed);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (checkValue)
|
||||
branch->SetBoolPref("checkDefaultMail", PR_FALSE);
|
||||
mShowMailDialog = PR_FALSE;
|
||||
|
||||
if (buttonPressed == 0) {
|
||||
rv = SetIsDefaultMailClient(PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
if (mShowNewsDialog && showNewsDialog) {
|
||||
nsXPIDLString dialogText;
|
||||
rv = mapiBundle->FormatStringFromName(
|
||||
NS_LITERAL_STRING("newsDialogText").get(),
|
||||
brandStrings, 1, getter_Copies(dialogText));
|
||||
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRInt32 buttonPressed = 0;
|
||||
rv = promptService->ConfirmEx(aParentWindow, dialogTitle, dialogText.get(),
|
||||
(nsIPromptService::BUTTON_TITLE_YES *
|
||||
nsIPromptService::BUTTON_POS_0) +
|
||||
(nsIPromptService::BUTTON_TITLE_NO *
|
||||
nsIPromptService::BUTTON_POS_1),
|
||||
nsnull, nsnull, nsnull,
|
||||
checkboxText, &checkValue, &buttonPressed);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (checkValue)
|
||||
branch->SetBoolPref("checkDefaultNews", PR_FALSE);
|
||||
mShowNewsDialog = PR_FALSE;
|
||||
|
||||
if (buttonPressed == 0)
|
||||
rv = SetIsDefaultNewsClient(PR_TRUE);
|
||||
}
|
||||
|
||||
if (mShowFeedDialog && showFeedDialog) {
|
||||
nsXPIDLString dialogText;
|
||||
rv = mapiBundle->FormatStringFromName(
|
||||
NS_LITERAL_STRING("feedDialogText").get(),
|
||||
brandStrings, 1, getter_Copies(dialogText));
|
||||
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRInt32 buttonPressed = 0;
|
||||
rv = promptService->ConfirmEx(aParentWindow, dialogTitle, dialogText.get(),
|
||||
(nsIPromptService::BUTTON_TITLE_YES *
|
||||
nsIPromptService::BUTTON_POS_0) +
|
||||
(nsIPromptService::BUTTON_TITLE_NO *
|
||||
nsIPromptService::BUTTON_POS_1),
|
||||
nsnull, nsnull, nsnull,
|
||||
checkboxText, &checkValue, &buttonPressed);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (checkValue)
|
||||
branch->SetBoolPref("checkDefaultFeed", PR_FALSE);
|
||||
mShowMailDialog = PR_FALSE;
|
||||
|
||||
if (buttonPressed == 0) {
|
||||
rv = SetIsDefaultFeedClient(PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMailMacIntegration::RegisterMailAndNewsClient()
|
||||
{
|
||||
// Be gentle, do nothing. The OS will do it for us on the first launch
|
||||
// of Thunderbird (based on entries from the bundle's info property list).
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -39,31 +39,28 @@
|
|||
#ifndef nsMailMacIntegration_h_
|
||||
#define nsMailMacIntegration_h_
|
||||
|
||||
#include "nsIMapiRegistry.h"
|
||||
#include "nsIShellService.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#define NS_MAILMACINTEGRATION_CID \
|
||||
{0x85a27035, 0xb970, 0x4079, {0xb9, 0xd2, 0xe2, 0x1f, 0x69, 0xe6, 0xb2, 0x1f}}
|
||||
|
||||
class nsMailMacIntegration : public nsIMapiRegistry
|
||||
class nsMailMacIntegration : public nsIShellService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMAPIREGISTRY
|
||||
NS_DECL_NSISHELLSERVICE
|
||||
nsMailMacIntegration();
|
||||
|
||||
protected:
|
||||
nsresult IsDefaultHandlerForProtocol(CFStringRef aScheme,
|
||||
PRBool *aIsDefault);
|
||||
nsresult SetAsDefaultHandlerForProtocol(CFStringRef aScheme);
|
||||
PRBool isDefaultHandlerForProtocol(CFStringRef aScheme);
|
||||
nsresult setAsDefaultHandlerForProtocol(CFStringRef aScheme);
|
||||
|
||||
private:
|
||||
~nsMailMacIntegration() {}
|
||||
|
||||
PRBool mShowMailDialog;
|
||||
PRBool mShowNewsDialog;
|
||||
PRBool mShowFeedDialog;
|
||||
|
||||
virtual ~nsMailMacIntegration() {};
|
||||
PRBool mCheckedThisSession;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,465 @@
|
|||
/* -*- 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 Thunderbird Windows Integration.
|
||||
*
|
||||
* 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):
|
||||
*
|
||||
* 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 "nsMailWinIntegration.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIMapiSupport.h"
|
||||
#include "shlobj.h"
|
||||
|
||||
#include <mbstring.h>
|
||||
|
||||
#define MOZ_CLIENT_MAIL_KEY "Software\\Clients\\Mail"
|
||||
#define MOZ_CLIENT_NEWS_KEY "Software\\Clients\\News"
|
||||
|
||||
#ifndef MAX_BUF
|
||||
#define MAX_BUF 4096
|
||||
#endif
|
||||
|
||||
#define REG_FAILED(val) \
|
||||
(val != ERROR_SUCCESS)
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsWindowsShellService, nsIShellService)
|
||||
|
||||
static nsresult
|
||||
OpenUserKeyForReading(HKEY aStartKey, const char* aKeyName, HKEY* aKey)
|
||||
{
|
||||
DWORD result = ::RegOpenKeyEx(aStartKey, aKeyName, 0, KEY_READ, aKey);
|
||||
|
||||
switch (result) {
|
||||
case ERROR_SUCCESS:
|
||||
break;
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return NS_ERROR_FILE_ACCESS_DENIED;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
if (aStartKey == HKEY_LOCAL_MACHINE)
|
||||
{
|
||||
// prevent infinite recursion on the second pass through here if
|
||||
// ::RegOpenKeyEx fails in the all-users case.
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return OpenUserKeyForReading(HKEY_LOCAL_MACHINE, aKeyName, aKey);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
OpenKeyForWriting(const char* aKeyName, HKEY* aKey, PRBool aForAllUsers, PRBool aCreate)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
HKEY rootKey = aForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
|
||||
DWORD result = ::RegOpenKeyEx(rootKey, aKeyName, 0, KEY_READ | KEY_WRITE, aKey);
|
||||
|
||||
switch (result) {
|
||||
case ERROR_SUCCESS:
|
||||
break;
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return NS_ERROR_FILE_ACCESS_DENIED;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
if (aCreate)
|
||||
result = ::RegCreateKey(HKEY_LOCAL_MACHINE, aKeyName, aKey);
|
||||
rv = NS_ERROR_FILE_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Default Mail Registry Settings
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef enum { NO_SUBSTITUTION = 0x00,
|
||||
PATH_SUBSTITUTION = 0x01,
|
||||
APPNAME_SUBSTITUTION = 0x02,
|
||||
USE_FOR_DEFAULT_TEST = 0x04} SettingFlags;
|
||||
|
||||
#define CLS "SOFTWARE\\Classes\\"
|
||||
#define MAILCLIENTS "SOFTWARE\\Clients\\Mail\\"
|
||||
#define NEWSCLIENTS "SOFTWARE\\Clients\\News\\"
|
||||
#define DI "\\DefaultIcon"
|
||||
#define CLS_EML "ThunderbirdEML"
|
||||
#define SOP "\\shell\\open\\command"
|
||||
#define EXE "thunderbird.exe"
|
||||
|
||||
#define VAL_URL_ICON "%APPPATH%,0"
|
||||
#define VAL_FILE_ICON "%APPPATH%,1"
|
||||
#define VAL_OPEN "%APPPATH% \"%1\""
|
||||
#define VAL_OPEN_WITH_URL "%APPPATH% -url \"%1\""
|
||||
#define VAL_DLLPATH "%APPPATH%\\mozMapi32.dll"
|
||||
|
||||
#define MAKE_KEY_NAME1(PREFIX, MID) \
|
||||
PREFIX MID
|
||||
|
||||
#define MAKE_KEY_NAME2(PREFIX, MID, SUFFIX) \
|
||||
PREFIX MID SUFFIX
|
||||
|
||||
static SETTING gMailSettings[] = {
|
||||
// File Extensions
|
||||
{ MAKE_KEY_NAME1(CLS, ".eml"), "", "", NO_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(CLS, CLS_EML, DI), "", VAL_FILE_ICON, PATH_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(CLS, CLS_EML, SOP), "", VAL_OPEN, PATH_SUBSTITUTION},
|
||||
|
||||
// Protocol Handlers
|
||||
{ MAKE_KEY_NAME2(CLS, "mailto", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION},
|
||||
// we use the following key for our default mail app test so don't set the NON_ESSENTIAL flag
|
||||
{ MAKE_KEY_NAME2(CLS, "mailto", SOP), "", "%APPPATH% -compose \"%1\"", PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
|
||||
// Windows XP Start Menu
|
||||
{ MAKE_KEY_NAME1(MAILCLIENTS, "%APPNAME%"),
|
||||
"DLLPath",
|
||||
VAL_DLLPATH,
|
||||
PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", DI),
|
||||
"",
|
||||
"%APPPATH%,0",
|
||||
PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", SOP),
|
||||
"",
|
||||
"%APPPATH% -mail",
|
||||
PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME1(MAILCLIENTS, "%APPNAME%\\shell\\properties\\command"),
|
||||
"",
|
||||
"%APPPATH% -options",
|
||||
PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%\\Protocols\\mailto", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION | APPNAME_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%\\Protocols\\mailto", SOP), "", "%APPPATH% -compose \"%1\"", PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%\\.eml", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION | APPNAME_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%\\.eml", SOP), "", VAL_OPEN, PATH_SUBSTITUTION | APPNAME_SUBSTITUTION }
|
||||
|
||||
// These values must be set by hand, since they contain localized strings.
|
||||
// shell\properties (default) REG_SZ Firefox &Options
|
||||
};
|
||||
|
||||
static SETTING gNewsSettings[] = {
|
||||
// Protocol Handlers
|
||||
{ MAKE_KEY_NAME2(CLS, "news", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "news", SOP), "", "%APPPATH% -mail \"%1\"", PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
{ MAKE_KEY_NAME2(CLS, "nntp", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "nntp", SOP), "", "%APPPATH% -mail \"%1\"", PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
{ MAKE_KEY_NAME2(CLS, "snews", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "snews", SOP), "", "%APPPATH% -mail \"%1\"", PATH_SUBSTITUTION},
|
||||
|
||||
// Client Keys
|
||||
{ MAKE_KEY_NAME1(NEWSCLIENTS, "%APPNAME%"),
|
||||
"DLLPath",
|
||||
VAL_DLLPATH,
|
||||
PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", DI),
|
||||
"",
|
||||
"%APPPATH%,0",
|
||||
PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", SOP),
|
||||
"",
|
||||
"%APPPATH% -mail",
|
||||
PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%\\Protocols\\news", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION | APPNAME_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%\\Protocols\\news", SOP), "", "%APPPATH% -mail \"%1\"", PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%\\Protocols\\nntp", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION | APPNAME_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%\\Protocols\\nntp", SOP), "", "%APPPATH% -mail \"%1\"", PATH_SUBSTITUTION | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%\\Protocols\\snews", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION | APPNAME_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%\\Protocols\\snews", SOP), "", "%APPPATH% -mail \"%1\"", PATH_SUBSTITUTION | APPNAME_SUBSTITUTION }
|
||||
};
|
||||
|
||||
static SETTING gFeedSettings[] = {
|
||||
// Protocol Handlers
|
||||
{ MAKE_KEY_NAME2(CLS, "feed", DI), "", VAL_URL_ICON, PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "feed", SOP), "", "%APPPATH% -mail \"%1\"", PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
};
|
||||
|
||||
nsWindowsShellService::nsWindowsShellService()
|
||||
:mCheckedThisSession(PR_FALSE)
|
||||
{
|
||||
nsresult rv;
|
||||
// fill in mAppPath
|
||||
char buf[MAX_BUF];
|
||||
::GetModuleFileName(NULL, buf, sizeof(buf));
|
||||
::GetShortPathName(buf, buf, sizeof(buf));
|
||||
ToUpperCase(mAppPath = buf);
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIStringBundle> bundle, brandBundle;
|
||||
rv = bundleService->CreateBundle("chrome://branding/locale/brand.properties", getter_AddRefs(brandBundle));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
|
||||
getter_Copies(mBrandFullName));
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(mBrandShortName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::IsDefaultClient(PRBool aStartupCheck, PRUint16 aApps, PRBool *aIsDefaultClient)
|
||||
{
|
||||
*aIsDefaultClient = PR_TRUE;
|
||||
|
||||
// for each type,
|
||||
if (aApps & nsIShellService::MAIL)
|
||||
*aIsDefaultClient &= TestForDefault(gMailSettings, sizeof(gMailSettings)/sizeof(SETTING));
|
||||
if (aApps & nsIShellService::NEWS)
|
||||
*aIsDefaultClient &= TestForDefault(gNewsSettings, sizeof(gNewsSettings)/sizeof(SETTING));
|
||||
if (aApps & nsIShellService::RSS)
|
||||
*aIsDefaultClient &= TestForDefault(gFeedSettings, sizeof(gFeedSettings)/sizeof(SETTING));
|
||||
|
||||
// If this is the first mail window, maintain internal state that we've
|
||||
// checked this session (so that subsequent window opens don't show the
|
||||
// default client dialog).
|
||||
if (aStartupCheck)
|
||||
mCheckedThisSession = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::SetDefaultClient(PRBool aForAllUsers, PRUint16 aApps)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aApps & nsIShellService::MAIL)
|
||||
rv |= setDefaultMail(aForAllUsers);
|
||||
if (aApps & nsIShellService::NEWS)
|
||||
rv |= setDefaultNews(aForAllUsers);
|
||||
if (aApps & nsIShellService::RSS)
|
||||
setKeysForSettings(gFeedSettings, sizeof(gFeedSettings)/sizeof(SETTING),
|
||||
NS_ConvertUTF16toUTF8(mBrandFullName).get(), aForAllUsers);
|
||||
|
||||
// Refresh the Shell
|
||||
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::GetShouldCheckDefaultClient(PRBool* aResult)
|
||||
{
|
||||
if (mCheckedThisSession)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
return prefs->GetBoolPref("mail.shell.checkDefaultClient", aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::SetShouldCheckDefaultClient(PRBool aShouldCheck)
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
return prefs->SetBoolPref("mail.shell.checkDefaultClient", aShouldCheck);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWindowsShellService::setDefaultMail(PRBool aForAllUsers)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ConvertUTF16toUTF8 appName(mBrandFullName);
|
||||
setKeysForSettings(gMailSettings, sizeof(gMailSettings)/sizeof(SETTING), appName.get(), aForAllUsers);
|
||||
|
||||
// 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)
|
||||
// for Tools / Internet Options / Programs) so pass in
|
||||
// true for all users.
|
||||
SetRegKey(NS_LITERAL_CSTRING(MOZ_CLIENT_MAIL_KEY).get(), "", appName.get(), PR_TRUE, /* aForAllUsers */ PR_TRUE);
|
||||
|
||||
nsCAutoString nativeFullName;
|
||||
// For now, we use 'A' APIs (see bug 240272, 239279)
|
||||
NS_CopyUnicodeToNative(mBrandFullName, nativeFullName);
|
||||
|
||||
nsCAutoString key1(NS_LITERAL_CSTRING(MAILCLIENTS));
|
||||
key1.Append(appName);
|
||||
key1.Append("\\");
|
||||
SetRegKey(key1.get(), "", nativeFullName.get(), PR_TRUE, aForAllUsers);
|
||||
|
||||
// Set the Options and Safe Mode start menu context menu item labels
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = bundleService->CreateBundle("chrome://messenger/locale/shellservice.properties", getter_AddRefs(bundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCAutoString optionsKey(NS_LITERAL_CSTRING(MAILCLIENTS "%APPNAME%\\shell\\properties"));
|
||||
optionsKey.ReplaceSubstring("%APPNAME%", appName.get());
|
||||
|
||||
const PRUnichar* brandNameStrings[] = { mBrandShortName.get() };
|
||||
|
||||
// Set the Options menu item
|
||||
nsXPIDLString optionsTitle;
|
||||
bundle->FormatStringFromName(NS_LITERAL_STRING("optionsLabel").get(),
|
||||
brandNameStrings, 1, getter_Copies(optionsTitle));
|
||||
// Set the registry keys
|
||||
nsCAutoString nativeTitle;
|
||||
// For the now, we use 'A' APIs (see bug 240272, 239279)
|
||||
NS_CopyUnicodeToNative(optionsTitle, nativeTitle);
|
||||
SetRegKey(optionsKey.get(), "", nativeTitle.get(), PR_TRUE, aForAllUsers);
|
||||
|
||||
// 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
|
||||
nsWindowsShellService::setDefaultNews(PRBool aForAllUsers)
|
||||
{
|
||||
NS_ConvertUTF16toUTF8 appName(mBrandFullName);
|
||||
setKeysForSettings(gNewsSettings, sizeof(gNewsSettings)/sizeof(SETTING), appName.get(), aForAllUsers);
|
||||
|
||||
// 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)
|
||||
// for Tools / Internet Options / Programs) so pass in
|
||||
// true for all users.
|
||||
SetRegKey(NS_LITERAL_CSTRING(MOZ_CLIENT_NEWS_KEY).get(), "", appName.get(), PR_TRUE, /* aForAllUsers */ PR_TRUE);
|
||||
|
||||
nsCAutoString nativeFullName;
|
||||
// For now, we use 'A' APIs (see bug 240272, 239279)
|
||||
NS_CopyUnicodeToNative(mBrandFullName, nativeFullName);
|
||||
nsCAutoString key1(NS_LITERAL_CSTRING(NEWSCLIENTS));
|
||||
key1.Append(appName);
|
||||
key1.Append("\\");
|
||||
SetRegKey(key1.get(), "", nativeFullName.get(), PR_TRUE, aForAllUsers);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindowsShellService::SetRegKey(const char* aKeyName, const char* aValueName,
|
||||
const char* aValue, PRBool aReplaceExisting,
|
||||
PRBool aForAllUsers)
|
||||
{
|
||||
char buf[MAX_BUF];
|
||||
DWORD len = sizeof buf;
|
||||
|
||||
HKEY theKey;
|
||||
nsresult rv = OpenKeyForWriting(aKeyName, &theKey, aForAllUsers, PR_TRUE);
|
||||
if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) return;
|
||||
|
||||
// If we're not allowed to replace an existing key, and one exists (i.e. the
|
||||
// result isn't ERROR_FILE_NOT_FOUND, then just return now.
|
||||
if (!aReplaceExisting && rv != NS_ERROR_FILE_NOT_FOUND)
|
||||
return;
|
||||
|
||||
// Get the old value
|
||||
DWORD result = ::RegQueryValueEx(theKey, aValueName, NULL, NULL, (LPBYTE)buf, &len);
|
||||
|
||||
// Set the new value
|
||||
if (REG_FAILED(result) || strcmp(buf, aValue) != 0)
|
||||
::RegSetValueEx(theKey, aValueName, 0, REG_SZ,
|
||||
(LPBYTE)aValue, nsDependentCString(aValue).Length());
|
||||
|
||||
// Close the key we opened.
|
||||
::RegCloseKey(theKey);
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
PRBool isDefault = PR_TRUE;
|
||||
NS_ConvertUTF16toUTF8 appName(mBrandFullName);
|
||||
char currValue[MAX_BUF];
|
||||
SETTING* end = aSettings + aSize;
|
||||
for (SETTING * settings = aSettings; settings < end; ++settings)
|
||||
{
|
||||
if (settings->flags & USE_FOR_DEFAULT_TEST)
|
||||
{
|
||||
nsCAutoString data(settings->valueData);
|
||||
nsCAutoString key(settings->keyName);
|
||||
if (settings->flags & PATH_SUBSTITUTION) {
|
||||
PRInt32 offset = data.Find("%APPPATH%");
|
||||
data.Replace(offset, 9, mAppPath);
|
||||
}
|
||||
if (settings->flags & APPNAME_SUBSTITUTION) {
|
||||
PRInt32 offset = key.Find("%APPNAME%");
|
||||
key.Replace(offset, 9, appName);
|
||||
}
|
||||
|
||||
::ZeroMemory(currValue, sizeof(currValue));
|
||||
HKEY theKey;
|
||||
nsresult rv = OpenUserKeyForReading(HKEY_CURRENT_USER, key.get(), &theKey);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
DWORD len = sizeof currValue;
|
||||
DWORD result = ::RegQueryValueEx(theKey, settings->valueName, NULL, NULL, (LPBYTE)currValue, &len);
|
||||
// Close the key we opened.
|
||||
::RegCloseKey(theKey);
|
||||
if (REG_FAILED(result) || strcmp(data.get(), currValue) != 0) {
|
||||
// Key wasn't set, or was set to something else (something else became the default browser)
|
||||
isDefault = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // for each registry key we want to look at
|
||||
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
|
||||
/* helper routine. Iterate over the passed in settings array, setting each key
|
||||
* in the windows registry.
|
||||
*/
|
||||
|
||||
void
|
||||
nsWindowsShellService::setKeysForSettings(SETTING aSettings[], PRInt32 aSize, const char * aAppName, PRBool aForAllUsers)
|
||||
{
|
||||
SETTING* settings;
|
||||
SETTING* end = aSettings + aSize;
|
||||
|
||||
for (settings = aSettings; settings < end; ++settings) {
|
||||
nsCAutoString data(settings->valueData);
|
||||
nsCAutoString key(settings->keyName);
|
||||
if (settings->flags & PATH_SUBSTITUTION) {
|
||||
PRInt32 offset = data.Find("%APPPATH%");
|
||||
data.Replace(offset, 9, mAppPath);
|
||||
}
|
||||
if (settings->flags & APPNAME_SUBSTITUTION) {
|
||||
PRInt32 offset = key.Find("%APPNAME%");
|
||||
key.Replace(offset, 9, aAppName);
|
||||
}
|
||||
|
||||
SetRegKey(key.get(), settings->valueName, data.get(),
|
||||
PR_TRUE, aForAllUsers);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/* -*- 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 Thunderbird Windows Integration.
|
||||
*
|
||||
* 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):
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef nsMailWinIntegration_h_
|
||||
#define nsMailWinIntegration_h_
|
||||
|
||||
#include "nsIShellService.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define NS_MAILWININTEGRATION_CID \
|
||||
{0x2ebbe84, 0xc179, 0x4598, {0xaf, 0x18, 0x1b, 0xf2, 0xc4, 0xbc, 0x1d, 0xf9}}
|
||||
|
||||
typedef struct {
|
||||
char* keyName;
|
||||
char* valueName;
|
||||
char* valueData;
|
||||
|
||||
PRInt32 flags;
|
||||
} SETTING;
|
||||
|
||||
class nsWindowsShellService : public nsIShellService
|
||||
{
|
||||
public:
|
||||
nsWindowsShellService();
|
||||
virtual ~nsWindowsShellService() {};
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISHELLSERVICE
|
||||
|
||||
protected:
|
||||
void SetRegKey(const char* aKeyName, const char* aValueName,
|
||||
const char* aValue,
|
||||
PRBool aReplaceExisting, PRBool aForAllUsers);
|
||||
|
||||
PRBool TestForDefault(SETTING aSettings[], PRInt32 aSize);
|
||||
void setKeysForSettings(SETTING aSettings[], PRInt32 aSize,
|
||||
const char * aAppname, PRBool aForAllUsers);
|
||||
nsresult setDefaultMail(PRBool aForAllUsers);
|
||||
nsresult setDefaultNews(PRBool aForAllUsers);
|
||||
|
||||
private:
|
||||
PRBool mCheckedThisSession;
|
||||
nsCString mAppPath;
|
||||
nsXPIDLString mBrandFullName;
|
||||
nsXPIDLString mBrandShortName;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,139 @@
|
|||
/* ***** 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 <mscott@mozilla.org>.
|
||||
* 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 ***** */
|
||||
|
||||
|
||||
/* This file implements the nsICommandLineHandler interface.
|
||||
*
|
||||
* This component handles the startup command line argument of the form:
|
||||
* -setDefaultMail
|
||||
* by making the current executable the "default mail app."
|
||||
*/
|
||||
|
||||
function nsSetDefaultMail() {
|
||||
}
|
||||
|
||||
nsSetDefaultMail.prototype = {
|
||||
/* nsISupports */
|
||||
QueryInterface: function nsSetDefault_QI(iid) {
|
||||
if (!iid.equals(Components.interfaces.nsICommandLineHandler) &&
|
||||
!iid.equals(Components.interfaces.nsISupports))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/* nsICommandLineHandler */
|
||||
handle : function nsSetDefault_handle(cmdline) {
|
||||
if (cmdline.handleFlag("setDefaultMail", false)) {
|
||||
var shell = Components.classes["@mozilla.org/mail/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
shell.setDefaultClient(true, Components.interfaces.nsIShellService.MAIL);
|
||||
}
|
||||
},
|
||||
|
||||
helpText : " -setDefaultMail Set this app as the default mail client.\n"
|
||||
}
|
||||
|
||||
const contractID = "@mozilla.org/mail/default-mail-clh;1";
|
||||
const CID = Components.ID("{ED117D0A-F6C2-47d8-8A71-0E15BABD2554}");
|
||||
|
||||
var ModuleAndFactory = {
|
||||
/* nsISupports */
|
||||
QueryInterface: function nsSetDefault_QI(iid) {
|
||||
if (!iid.equals(Components.interfaces.nsIModule) &&
|
||||
!iid.equals(Components.interfaces.nsIFactory) &&
|
||||
!iid.equals(Components.interfaces.nsISupports))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/* nsIModule */
|
||||
getClassObject: function (compMgr, cid, iid) {
|
||||
if (!cid.equals(CID))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
return this.QueryInterface(iid);
|
||||
},
|
||||
|
||||
registerSelf: function mod_regself(compMgr, fileSpec, location, type) {
|
||||
var compReg =
|
||||
compMgr.QueryInterface( Components.interfaces.nsIComponentRegistrar );
|
||||
|
||||
compReg.registerFactoryLocation( CID,
|
||||
"Default Mail Cmdline Handler",
|
||||
contractID,
|
||||
fileSpec,
|
||||
location,
|
||||
type );
|
||||
|
||||
var catMan = Components.classes["@mozilla.org/categorymanager;1"]
|
||||
.getService(Components.interfaces.nsICategoryManager);
|
||||
|
||||
catMan.addCategoryEntry("command-line-handler",
|
||||
"m-setdefaultmail",
|
||||
contractID, true, true);
|
||||
},
|
||||
|
||||
unregisterSelf : function mod_unregself(compMgr, location, type) {
|
||||
var catMan = Components.classes["@mozilla.org/categorymanager;1"]
|
||||
.getService(Components.interfaces.nsICategoryManager);
|
||||
|
||||
catMan.deleteCategoryEntry("command-line-handler",
|
||||
"m-setdefaultmail", true);
|
||||
},
|
||||
|
||||
canUnload: function(compMgr) {
|
||||
return true;
|
||||
},
|
||||
|
||||
/* nsIFactory */
|
||||
createInstance: function mod_CI(outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return new nsSetDefaultMail().QueryInterface(iid);
|
||||
},
|
||||
|
||||
lockFactory : function mod_lock(lock) {
|
||||
/* no-op */
|
||||
}
|
||||
}
|
||||
|
||||
// NSGetModule: Return the nsIModule object.
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return ModuleAndFactory;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# ***** 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
|
|
@ -0,0 +1,83 @@
|
|||
/* -*- 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
|
||||
* Scott MacGregor <mscott@mozilla.org>.
|
||||
* 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"
|
||||
|
||||
[scriptable, uuid(95F53544-F445-48d1-B3A2-D54AA020BC3D)]
|
||||
interface nsIShellService : nsISupports
|
||||
{
|
||||
/**
|
||||
* app types we can be registered to handle
|
||||
*/
|
||||
const unsigned short MAIL = 0x0001;
|
||||
const unsigned short NEWS = 0x0002;
|
||||
const unsigned short RSS = 0x0004;
|
||||
|
||||
/**
|
||||
* Determines whether or not Thunderbird is the "Default Client" for the
|
||||
* passed in app type.
|
||||
*
|
||||
* This is simply whether or not Thunderbid is registered to handle
|
||||
* the url scheme associatd with the app.
|
||||
*
|
||||
* @param aStartupCheck true if this is the check being performed
|
||||
* by the first mail window at startup,
|
||||
* false otherwise.
|
||||
* @param aApps the application types being tested (Mail, News, RSS, etc.)
|
||||
*/
|
||||
boolean isDefaultClient(in boolean aStartupCheck, in unsigned short aApps);
|
||||
|
||||
/**
|
||||
* Registers Thunderbird as the "Default Mail Client" for the
|
||||
* passed in app type.
|
||||
*
|
||||
* @param aForAllUsers Whether or not Thunderbird should attempt
|
||||
* to become the default client for all
|
||||
* users on a multi-user system.
|
||||
* @param aApps the application types being tested (Mail, News, RSS, etc.)
|
||||
*/
|
||||
void setDefaultClient(in boolean aForAllUsers, 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 "mail.shell.checkDefaultClient" is true, otherwise it
|
||||
* is false.
|
||||
*/
|
||||
attribute boolean shouldCheckDefaultClient;
|
||||
};
|
|
@ -157,6 +157,7 @@ components/xuldoc.xpt
|
|||
components/xultmpl.xpt
|
||||
components/downloadmanager.xpt
|
||||
#endif
|
||||
components/nsUnsetDefaultMail.js
|
||||
components/nsBackgroundUpdateService.js
|
||||
components/nsDownloadProgressListener.js
|
||||
components/xptitemp.dat
|
||||
|
|
|
@ -112,7 +112,6 @@ bin\MapiProxy.dll
|
|||
bin\mozMapi32.dll
|
||||
bin\components\mapihook.xpt
|
||||
bin\components\nsSetDefaultMail.js
|
||||
bin\components\nsUnsetDefaultMail.js
|
||||
bin\components\offlineStartup.js
|
||||
bin\components\nsMailDefaultHandler.js
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<!ENTITY defaultClient.title "Default Client">
|
||||
<!ENTITY defaultClient.intro "Use &brandShortName; as the default client for:">
|
||||
|
||||
<!ENTITY email.label "E-Mail">
|
||||
<!ENTITY newsgroups.label "Newsgroups">
|
||||
<!ENTITY rss.label "RSS Feeds">
|
||||
|
||||
<!ENTITY checkOnStartup.label "Always perform this check when starting &brandShortName;">
|
||||
<!ENTITY checkOnStartup.accesskey "A">
|
|
@ -1,13 +0,0 @@
|
|||
<!ENTITY window.title "Default Client Settings">
|
||||
<!ENTITY window.width "400px">
|
||||
<!ENTITY checkNow.label "Check Now">
|
||||
<!ENTITY whenStartingCheckFor.label "When starting, &brandShortName; should check to see if it is the default application for">
|
||||
<!ENTITY mailApplication.label "Mail">
|
||||
<!ENTITY mailApplication.accesskey "M">
|
||||
<!ENTITY checkMailNow.accesskey "C">
|
||||
<!ENTITY newsApplication.label "News">
|
||||
<!ENTITY newsApplication.accesskey "N">
|
||||
<!ENTITY checkNewsNow.accesskey "h">
|
||||
<!ENTITY rssFeeds.label "RSS Feeds">
|
||||
<!ENTITY rssFeeds.accesskey "R">
|
||||
<!ENTITY checkFeedAggregatorNow.accesskey "e">
|
|
@ -1,15 +1,14 @@
|
|||
<!ENTITY generalSettings.caption "Default Settings">
|
||||
<!ENTITY generalSettings.label "Make &brandShortName; the default application for:">
|
||||
<!ENTITY setDefaultMailClient.label "Mail">
|
||||
<!ENTITY setDefaultMailClient.accesskey "M">
|
||||
<!ENTITY setDefaultNewsClient.label "News">
|
||||
<!ENTITY setDefaultNewsClient.accesskey "N">
|
||||
<!ENTITY setDefaultFeedClient.label "RSS Feeds">
|
||||
<!ENTITY setDefaultFeedClient.accesskey "F">
|
||||
<!ENTITY checkDefaultMailClient.label "&brandShortName; should check to see if it is the default mail client when starting">
|
||||
<!ENTITY checkDefaultMailClient.accesskey "n">
|
||||
<!ENTITY defaultClientAdvanced.label "Advanced...">
|
||||
<!ENTITY defaultClientAdvanced.accesskey "d">
|
||||
<!ENTITY systemDefaults.label "System Defaults">
|
||||
<!ENTITY alwaysCheckDefault.label "Always check to see if &brandShortName; is the default mail client on startup">
|
||||
<!ENTITY alwaysCheckDefault.accesskey "l">
|
||||
<!-- LOCALIZATION NOTE (alwaysCheckDefault.height):
|
||||
There's some sort of bug which makes wrapping checkboxes not properly reflow,
|
||||
causing the bottom border of the groupbox to be cut off; set this
|
||||
appropriately if your localization causes this checkbox to wrap.
|
||||
-->
|
||||
<!ENTITY alwaysCheckDefault.height "3em">
|
||||
<!ENTITY checkNow.label "Check Now">
|
||||
<!ENTITY checkNow.accesskey "N">
|
||||
|
||||
<!ENTITY windowSettings.label "Window Configuration">
|
||||
<!ENTITY selectWindowLayout.label "Select the window layout you prefer for Mail.">
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
optionsLabel=%S &Options
|
||||
safeModeLabel=%S &Safe Mode
|
||||
alreadyDefaultClientTitle=Default Client
|
||||
alreadyDefault=%S is already set as your default mail client.
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
locale/@AB_CD@/messenger/start.dtd (%chrome/messenger/start.dtd)
|
||||
locale/@AB_CD@/messenger/credits.dtd (%chrome/messenger/credits.dtd)
|
||||
locale/@AB_CD@/messenger/aboutDialog.dtd (%chrome/messenger/aboutDialog.dtd)
|
||||
locale/@AB_CD@/messenger/defaultClientDialog.dtd (%chrome/messenger/defaultClientDialog.dtd)
|
||||
locale/@AB_CD@/messenger/virtualFolderProperties.dtd (%chrome/messenger/virtualFolderProperties.dtd)
|
||||
locale/@AB_CD@/messenger/virtualFolderListDialog.dtd (%chrome/messenger/virtualFolderListDialog.dtd)
|
||||
locale/@AB_CD@/messenger/mailOverlay.dtd (%chrome/messenger/mailOverlay.dtd)
|
||||
|
@ -80,6 +81,7 @@
|
|||
locale/@AB_CD@/messenger/eudoraImportMsgs.properties (%chrome/messenger/eudoraImportMsgs.properties)
|
||||
locale/@AB_CD@/messenger/oeImportMsgs.properties (%chrome/messenger/oeImportMsgs.properties)
|
||||
locale/@AB_CD@/messenger/outlookImportMsgs.properties (%chrome/messenger/outlookImportMsgs.properties)
|
||||
locale/@AB_CD@/messenger/shellservice.properties (%chrome/messenger/shellservice.properties)
|
||||
locale/@AB_CD@/messenger/addressbook/abMainWindow.dtd (%chrome/messenger/addressbook/abMainWindow.dtd)
|
||||
locale/@AB_CD@/messenger/addressbook/abNewCardDialog.dtd (%chrome/messenger/addressbook/abNewCardDialog.dtd)
|
||||
locale/@AB_CD@/messenger/addressbook/abContactsPanel.dtd (%chrome/messenger/addressbook/abContactsPanel.dtd)
|
||||
|
@ -118,7 +120,6 @@
|
|||
locale/@AB_CD@/messenger/preferences/changeaction.dtd (%chrome/messenger/preferences/changeaction.dtd)
|
||||
locale/@AB_CD@/messenger/preferences/fonts.dtd (%chrome/messenger/preferences/fonts.dtd)
|
||||
locale/@AB_CD@/messenger/preferences/notifications.dtd (%chrome/messenger/preferences/notifications.dtd)
|
||||
locale/@AB_CD@/messenger/preferences/defaultClient.dtd (%chrome/messenger/preferences/defaultClient.dtd)
|
||||
locale/@AB_CD@/messenger/preferences/preferences.properties (%chrome/messenger/preferences/preferences.properties)
|
||||
locale/@AB_CD@/messenger/migration/migration.dtd (%chrome/messenger/migration/migration.dtd)
|
||||
locale/@AB_CD@/messenger/migration/migration.properties (%chrome/messenger/migration/migration.properties)
|
||||
|
|
|
@ -78,6 +78,7 @@ function getInvalidAccounts(accounts)
|
|||
return invalidAccounts;
|
||||
}
|
||||
|
||||
#ifndef MOZ_THUNDERBIRD
|
||||
// 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
|
||||
|
@ -121,13 +122,15 @@ function showMailIntegrationDialog() {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
function verifyAccounts(wizardcallback) {
|
||||
//check to see if the function is called with the callback and if so set the global variable gReturnmycall to true
|
||||
if(wizardcallback)
|
||||
function verifyAccounts(wizardcallback)
|
||||
{
|
||||
//check to see if the function is called with the callback and if so set the global variable gReturnmycall to true
|
||||
if(wizardcallback)
|
||||
gReturnmycall = true;
|
||||
var openWizard = false;
|
||||
var prefillAccount;
|
||||
var prefillAccount;
|
||||
var state=true;
|
||||
var ret = true;
|
||||
|
||||
|
@ -215,8 +218,12 @@ function verifyAccounts(wizardcallback) {
|
|||
messengerMigrator.createLocalMailAccount(false /* false, since we are not migrating */);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MOZ_THUNDERBIRD
|
||||
// seamonkey still uses this...
|
||||
// hack, set a time out to do this, so that the window can load first
|
||||
setTimeout("showMailIntegrationDialog();",0);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ messenger.jar:
|
|||
content/messenger/aw-login.js (base/prefs/resources/content/aw-login.js)
|
||||
content/messenger/aw-accname.js (base/prefs/resources/content/aw-accname.js)
|
||||
content/messenger/aw-done.js (base/prefs/resources/content/aw-done.js)
|
||||
content/messenger/accountUtils.js (base/prefs/resources/content/accountUtils.js)
|
||||
* content/messenger/accountUtils.js (base/prefs/resources/content/accountUtils.js)
|
||||
content/messenger/amUtils.js (base/prefs/resources/content/amUtils.js)
|
||||
content/messenger/ispUtils.js (base/prefs/resources/content/ispUtils.js)
|
||||
content/messenger/SmtpServerEdit.xul (base/prefs/resources/content/SmtpServerEdit.xul)
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
[noscript, uuid(8967fed2-c8bb-11d5-a3e9-00b0d0f3baa7)]
|
||||
[noscript, uuid(2907B676-C4BD-49af-880A-E27A0616291E)]
|
||||
interface nsIMapiSupport : nsISupports {
|
||||
|
||||
/** Initiates MAPI support
|
||||
|
@ -54,6 +54,18 @@ interface nsIMapiSupport : nsISupports {
|
|||
*/
|
||||
|
||||
void shutdownMAPISupport();
|
||||
|
||||
/** registerServer - register the mapi DLL with the desktop
|
||||
* Typically called by the window shell service when we are
|
||||
* made the default mail app
|
||||
*/
|
||||
void registerServer();
|
||||
|
||||
/** unRegisterServer - unregister the mapi DLL with the desktop
|
||||
* Typically called by the window shell service when we are
|
||||
* removed as the default mail app.
|
||||
*/
|
||||
void unRegisterServer();
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -83,11 +83,13 @@ CPPSRCS = \
|
|||
msgMapiImp.cpp \
|
||||
msgMapiMain.cpp \
|
||||
msgMapiSupport.cpp \
|
||||
nsMapiRegistry.cpp \
|
||||
nsMapiRegistryUtils.cpp \
|
||||
Registry.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_THUNDERBIRD
|
||||
CPPSRCS += nsMapiRegistry.cpp nsMapiRegistryUtils.cpp
|
||||
endif
|
||||
|
||||
LOBJS = ../build/msgMapi_i.$(OBJ_SUFFIX)
|
||||
|
||||
ifndef MOZ_STATIC_MAIL_BUILD
|
||||
|
|
|
@ -45,10 +45,14 @@
|
|||
#include "nsIComponentManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsCRT.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.
|
||||
|
@ -153,18 +157,39 @@ nsMapiSupport::ShutdownMAPISupport()
|
|||
return NS_OK ;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiSupport::RegisterServer()
|
||||
{
|
||||
// TODO: Figure out what kind of error propogation to pass back
|
||||
::RegisterServer(CLSID_CMapiImp, "Mozilla MAPI", "MozillaMapi", "MozillaMapi.1");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -36,6 +36,13 @@
|
|||
*
|
||||
* ***** 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 "nsXPIDLString.h"
|
||||
#include "nsIPromptService.h"
|
||||
|
|
|
@ -35,6 +35,13 @@
|
|||
*
|
||||
* ***** 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____
|
||||
|
||||
|
|
|
@ -38,6 +38,13 @@
|
|||
*
|
||||
* ***** 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
|
||||
|
||||
|
@ -55,6 +62,7 @@
|
|||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsEmbedCID.h"
|
||||
#include "nsIMapiSupport.h"
|
||||
#include <mbstring.h>
|
||||
|
||||
#define EXE_EXTENSION ".EXE"
|
||||
|
@ -1022,9 +1030,10 @@ nsresult nsMapiRegistryUtils::setDefaultMailClient()
|
|||
MOZ_HWND_BROADCAST_MSG_TIMEOUT,
|
||||
NULL);
|
||||
|
||||
// register the new mapi server
|
||||
RegisterServer(CLSID_CMapiImp, "Mozilla MAPI", "MozillaMapi", "MozillaMapi.1");
|
||||
return rv;
|
||||
// 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() {
|
||||
|
@ -1186,8 +1195,10 @@ nsresult nsMapiRegistryUtils::unsetDefaultMailClient() {
|
|||
SMTO_NORMAL|SMTO_ABORTIFHUNG,
|
||||
MOZ_HWND_BROADCAST_MSG_TIMEOUT,
|
||||
NULL);
|
||||
|
||||
UnregisterServer(CLSID_CMapiImp, "MozillaMapi", "MozillaMapi.1");
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,13 @@
|
|||
*
|
||||
* ***** 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____
|
||||
|
||||
|
@ -42,7 +49,6 @@
|
|||
#include <string.h>
|
||||
#include <winreg.h>
|
||||
|
||||
#include "Registry.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
|
|
|
@ -130,10 +130,6 @@ DIRS += \
|
|||
bookmarks/public \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DIRS += winhooks
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifndef MOZ_XUL_APP
|
||||
|
|
Загрузка…
Ссылка в новой задаче