Thunderbird default mail/news client support for GNOME (bug 252056). r=mscott.

This commit is contained in:
bryner%brianryner.com 2004-07-24 23:54:29 +00:00
Родитель 884d677117
Коммит ee0713fbfb
27 изменённых файлов: 897 добавлений и 120 удалений

Просмотреть файл

@ -965,6 +965,8 @@ mail/components/addrbook/skin/Makefile
mail/components/prefwindow/Makefile
mail/components/prefwindow/skin/mac/Makefile
mail/components/prefwindow/skin/Makefile
mail/components/build/Makefile
mail/components/gnome/Makefile
mail/extensions/Makefile
mail/extensions/smime/Makefile
mail/extensions/smime/skin/mac/Makefile

Просмотреть файл

@ -16,7 +16,7 @@
# Reserved.
#
## $Id: mozilla.in,v 1.2 2004/02/20 18:13:45 pkw%us.ibm.com Exp $
## $Id: mozilla.in,v 1.3 2004/07/24 23:54:25 bryner%brianryner.com Exp $
##
## Usage:
##
@ -78,18 +78,19 @@ MRE_HOME=%MREDIR%
# Use run-mozilla.sh in the current dir if it exists
# If not, then start resolving symlinks until we find run-mozilla.sh
found=0
progname=$0
progname="$0"
curdir=`dirname "$progname"`
progbase=`basename "$progname"`
run_moz="$curdir/run-mozilla.sh"
if test -x "$run_moz"; then
dist_bin=$curdir
dist_bin="$curdir"
found=1
else
here=`/bin/pwd`
while [ -h "$progname" ]; do
bn=`basename "$progname"`
cd `dirname "$progname"`
progname=`/bin/ls -l "$bn" |sed -e 's/^.* -> //' `
progname=`/bin/ls -l "$bn" | sed -e 's/^.* -> //' `
if [ ! -x "$progname" ]; then
break
fi
@ -107,7 +108,7 @@ fi
if [ $found = 0 ]; then
# Check default compile-time libdir
if [ -x "$moz_libdir/run-mozilla.sh" ]; then
dist_bin=$moz_libdir
dist_bin="$moz_libdir"
else
echo "Cannot find mozilla runtime directory. Exiting."
exit 1
@ -117,17 +118,95 @@ fi
script_args=""
moreargs=""
debugging=0
MOZILLA_BIN="%MOZILLA-BIN%"
MOZILLA_BIN="${progbase}-bin"
# The following is to check for a currently running instance.
# This is taken almost verbatim from the Mozilla RPM package's launch script.
MOZ_CLIENT_PROGRAM="$dist_bin/mozilla-xremote-client"
check_running() {
"${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" 'ping()' 2>/dev/null >/dev/null
RETURN_VAL=$?
if [ $RETURN_VAL -eq 0 ]; then
echo 1
return 1
else
echo 0
return 0
fi
}
if [ "$OSTYPE" = "beos" ]; then
mimeset -F $MOZILLA_BIN
mimeset -F "$MOZILLA_BIN"
fi
ALREADY_RUNNING=`check_running`
################################################################ Parse Arguments
# If there's a command line argument but it doesn't begin with a -
# it's probably a url. Try to send it to a running instance.
_USE_EXIST=0
_NEW_WINDOW=
_optOne="$1"
case "${_optOne}" in
-*)
;;
*)
_USE_EXIST=1
;;
esac
_optOthers=
_optLast=
for i in "$@"; do
_optLast="${i}"
done #last arg
for i in "$@"; do
[ $i = ${_optLast} ] && break
_optOthers="${_optOthers} ${i}"
done #others arg
#???: needs check if othersopt begin with -* ?
if [ `expr "${_optLast}" : '.*:/.*'` -eq 0 -a \( -f "${_optLast}" -o -d "${_optLast}" \) ]; then
# Last argument seems to be a local file/directory
# Check, if it is absolutely specified (ie. /home/foo/file vs. ./file)
# If it is just "relatively" (./file) specified, make it absolutely
[ `expr "${_optLast}" : '/.*'` -eq 0 ] && _optLast="file://`pwd`/${_optLast}"
elif [ `expr "${_optLast}" : '.*:/.*'` -gt 0 -o -n "${_optOthers}" ]; then #???? like before...
_NEW_WINDOW=1
fi
################################################################ Parse Arguments
########################################################################### Main
if [ $ALREADY_RUNNING -eq 1 ]; then
# There's an instance already running. Use it.
# Any command line args passed in?
if [ $# -gt 0 ]; then
# There were "some" command line args.
if [ ${_USE_EXIST} -eq 1 ]; then
# We should use an existing instance, as _USE_EXIST=$_USE_EXIST=-1
_open_type="window"
#_open_type="tab"
_remote_cmd="openURL(${_optLast} , new-${_open_type})"
"${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "${_remote_cmd}"
unset _remote_cmd _open_type
exit $?
fi
else
# No command line args. Open new window/tab
#exec "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(openBrowser)"
"${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(openInbox)"
exit $?
fi
fi
# Default action - no running instance or _USE_EXIST (${_USE_EXIST}) ! -eq 1
########################################################################### Main
while [ $# -gt 0 ]
do
case "$1" in
-p | -pure)
MOZILLA_BIN="%MOZILLA-BIN%.pure"
-p | --pure | -pure)
MOZILLA_BIN="${MOZILLA_BIN}.pure"
shift
;;
-g | --debug)

Просмотреть файл

@ -115,6 +115,13 @@ pref("network.image.imageBehavior", 2);
// End seamonkey suite mailnews.js pref overrides
/////////////////////////////////////////////////////////////////
#ifdef MOZ_WIDGET_GTK2
// whether to check if we're the default mail client on startup (GNOME)
pref("mail.checkDefaultMail", true);
// whether to check if we're the default news client on startup (GNOME)
pref("mail.checkDefaultNews", false);
#endif
/////////////////////////////////////////////////////////////////
// Overrides for generic app behavior from the seamonkey suite's all.js
/////////////////////////////////////////////////////////////////

Просмотреть файл

@ -67,10 +67,8 @@ en-US.jar:
+ locale/en-US/global/brand.properties (locale/brand.properties)
*+ locale/en-US/global/brand.dtd (locale/brand.dtd)
+ locale/en-US/communicator/utilityOverlay.dtd (locale/utilityOverlay.dtd)
+ locale/en-US/messenger-mapi/mapi.properties (locale/mapi.properties)
US.jar:
+ locale/US/messenger-region/region.properties (locale/region.properties)
*+ locale/US/global-region/region.dtd (locale/region.dtd)
en-win.jar:
+ locale/en-US/messenger-mapi/mapi.properties (locale/mapi.properties)

Просмотреть файл

@ -1,4 +1,10 @@
brandShortName=Mozilla Thunderbird
#We don't have a real property for the REAL short name (Thunderbird), uses thisone temporarily
#We can't change brandShortName because that's used by non forked thunderbird/seamonkey code
#where it really needs to be the full name for thunderbird
brandRealShortName=Thunderbird
brandFullName=Mozilla Thunderbird
vendorShortName=Mozilla Thunderbird
sidebarName=Sidebar

Просмотреть файл

@ -1,7 +1,12 @@
# Mail Integration Dialog
dialogTitle=%S
dialogText=Do you want to use %S as the default mail application?
newsDialogText=Do you want to use %S as the default news application?
checkboxText=Do not display this dialog again
setDefaultMail=%S is not currently set as your default mail application. Would you like to make it your default mail application?
setDefaultNews=%S is not currently set as your default news application. Woudl you like to make it your default news application?
alreadyDefaultMail=%S is already set as your default mail application.
alreadyDefaultNews=%S is already set as your default news application.
# MAPI Messages
loginText=Please enter your password for %S:

Просмотреть файл

@ -28,5 +28,11 @@ include $(DEPTH)/config/autoconf.mk
DIRS = compose prefwindow addrbook migration
ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
DIRS += gnome
endif
DIRS += build
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1 @@
Makefile

Просмотреть файл

@ -0,0 +1,87 @@
# ***** 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.
#
# The Initial Developer of the Original Code is
# IBM Corporation.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Brian Ryner <bryner@brianryner.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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = mailcomps
LIBRARY_NAME = mailcomps
SHORT_LIBNAME = mailcmp
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsMailCompsModule
REQUIRES = \
xpcom \
xulapp \
mailprofilemigration \
string \
xpcom \
libreg \
intl \
pref \
msgbase \
$(NULL)
CPPSRCS = nsModule.cpp \
$(NULL)
LOCAL_INCLUDES = \
-I$(srcdir)/../migration/src \
-I$(srcdir)/../gnome \
$(NULL)
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)profilemigration_s.$(LIB_SUFFIX) \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)mail_gnome_s.$(LIB_SUFFIX)
endif
EXTRA_DSO_LDOPTS += \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_XPCOM_OBSOLETE_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,106 @@
/* -*- 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.
*
* The Initial Developer of the Original Code is
* IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@brianryner.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 ***** */
#include "nsIGenericFactory.h"
#include "nsMailMigrationCID.h"
#include "nsProfileMigrator.h"
#include "nsSeamonkeyProfileMigrator.h"
#include "nsDogbertProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsProfileMigrator)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSeamonkeyProfileMigrator)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDogbertProfileMigrator)
#ifdef XP_WIN32
#include "nsOEProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOEProfileMigrator)
#include "nsOutlookProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOutlookProfileMigrator)
#endif
#if defined(XP_WIN32) || defined(XP_MACOSX)
#include "nsEudoraProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsEudoraProfileMigrator)
#endif
#ifdef MOZ_WIDGET_GTK2
#include "nsMailGNOMEIntegration.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMailGNOMEIntegration, Init)
#endif
static const nsModuleComponentInfo components[] = {
{ "Profile Importer",
NS_THUNDERBIRD_PROFILEIMPORT_CID,
NS_PROFILEMIGRATOR_CONTRACTID,
nsProfileMigratorConstructor },
{ "Seamonkey Profile Migrator",
NS_SEAMONKEYPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey",
nsSeamonkeyProfileMigratorConstructor },
{ "Netscape Communicator 4.x",
NS_DOGBERTPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "dogbert",
nsDogbertProfileMigratorConstructor },
#ifdef XP_WIN32
{ "Outlook Express Profile Migrator",
NS_OEXPRESSPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "oexpress",
nsOEProfileMigratorConstructor },
{ "Outlook Profile Migrator",
NS_OUTLOOKPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "outlook",
nsOutlookProfileMigratorConstructor },
#endif
#if defined (XP_WIN32) || defined (XP_MACOSX)
{ "Eudora Profile Migrator",
NS_EUDORAPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "eudora",
nsEudoraProfileMigratorConstructor },
#endif
#ifdef MOZ_WIDGET_GTK2
{ "Mail GNOME Integration",
NS_MAILGNOMEINTEGRATION_CID,
"@mozilla.org/mapiregistry;1",
nsMailGNOMEIntegrationConstructor },
#endif
};
NS_IMPL_NSGETMODULE(nsMailCompsModule, components)

Просмотреть файл

@ -0,0 +1 @@
Makefile

Просмотреть файл

@ -0,0 +1,66 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Mozilla GNOME integration code.
#
# The Initial Developer of the Original Code is
# IBM Corporation.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Brian Ryner <bryner@brianryner.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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = mail_gnome
LIBRARY_NAME = mail_gnome_s
MODULE_NAME = nsMailGNOMEModule
REQUIRES = \
xpcom \
string \
mozgnome \
msgbase \
appshell \
intl \
windowwatcher \
pref \
$(NULL)
CPPSRCS = nsMailGNOMEIntegration.cpp
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(TK_CFLAGS)

Просмотреть файл

@ -0,0 +1,20 @@
<?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>

Просмотреть файл

@ -0,0 +1,2 @@
messenger.jar:
* content/messenger-mapi/contents.rdf (contents.rdf)

Просмотреть файл

@ -0,0 +1,345 @@
/* -*- 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 the Mozilla GNOME integration code.
*
* The Initial Developer of the Original Code is
* IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@brianryner.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 ***** */
#include "nsMailGNOMEIntegration.h"
#include "nsIGenericFactory.h"
#include "nsIGConfService.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "prenv.h"
#include "nsICmdLineService.h"
#include "nsIStringBundle.h"
#include "nsIPromptService.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include <glib.h>
#include <limits.h>
#include <stdlib.h>
static const char* const sMailProtocols[] = {
"mailto"
};
static const char* const sNewsProtocols[] = {
"news",
"snews",
"nntp"
};
nsresult
nsMailGNOMEIntegration::Init()
{
// GConf _must_ be available, or we do not allow CreateInstance to succeed.
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
if (!gconf)
return NS_ERROR_NOT_AVAILABLE;
// Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use
// the locale encoding. If it's not set, they use UTF-8.
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nsnull;
// Get the path we were launched from.
nsCOMPtr<nsICmdLineService> cmdService =
do_GetService("@mozilla.org/appshell/commandLineService;1");
if (!cmdService)
return NS_ERROR_NOT_AVAILABLE;
nsXPIDLCString programName;
cmdService->GetProgramName(getter_Copies(programName));
// Make sure we have an absolute pathname.
if (programName[0] != '/') {
// First search PATH if we were just launched as 'thunderbird-bin'.
// If we were launched as './thunderbird-bin', this will just return
// the original string.
gchar *appPath = g_find_program_in_path(programName.get());
// Now resolve it.
char resolvedPath[PATH_MAX] = "";
if (realpath(appPath, resolvedPath)) {
mAppPath.Assign(resolvedPath);
}
g_free(appPath);
} else {
mAppPath.Assign(programName);
}
// strip "-bin" off of the binary name
if (StringEndsWith(mAppPath, NS_LITERAL_CSTRING("-bin")))
mAppPath.SetLength(mAppPath.Length() - 4);
PRBool isDefault;
nsMailGNOMEIntegration::GetIsDefaultMailClient(&isDefault);
mShowMailDialog = !isDefault;
nsMailGNOMEIntegration::GetIsDefaultNewsClient(&isDefault);
mShowNewsDialog = !isDefault;
return NS_OK;
}
NS_IMPL_ISUPPORTS1(nsMailGNOMEIntegration, nsIMapiRegistry)
PRBool
nsMailGNOMEIntegration::KeyMatchesAppName(const char *aKeyValue) const
{
gchar *commandPath;
if (mUseLocaleFilenames) {
gchar *nativePath = g_filename_from_utf8(aKeyValue, -1, NULL, NULL, NULL);
if (!nativePath) {
NS_ERROR("Error converting path to filesystem encoding");
return PR_FALSE;
}
commandPath = g_find_program_in_path(nativePath);
g_free(nativePath);
} else {
commandPath = g_find_program_in_path(aKeyValue);
}
if (!commandPath)
return PR_FALSE;
PRBool matches = mAppPath.Equals(commandPath);
g_free(commandPath);
return matches;
}
nsresult
nsMailGNOMEIntegration::CheckDefault(const char* const *aProtocols,
unsigned int aLength, PRBool *aIsDefault)
{
*aIsDefault = PR_FALSE;
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
PRBool enabled;
nsCAutoString handler;
for (unsigned int i = 0; i < aLength; ++i) {
handler.Truncate();
nsresult rv = gconf->GetAppForProtocol(nsDependentCString(aProtocols[i]),
&enabled, handler);
NS_ENSURE_SUCCESS(rv, 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.
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 NS_ERROR_FAILURE;
}
if (!KeyMatchesAppName(handler.get()) || !enabled)
return NS_OK; // the handler is disabled or set to another app
}
*aIsDefault = PR_TRUE;
return NS_OK;
}
nsresult
nsMailGNOMEIntegration::MakeDefault(const char* const *aProtocols,
unsigned int aLength)
{
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCAutoString appKeyValue(mAppPath + NS_LITERAL_CSTRING(" \"%s\""));
for (unsigned int i = 0; i < aLength; ++i) {
nsresult rv = gconf->SetAppForProtocol(nsDependentCString(aProtocols[i]),
appKeyValue);
NS_ENSURE_SUCCESS(rv, rv);
}
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::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://global/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("@mozilla.org/embedcomp/prompt-service;1");
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;
}

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- 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
*
@ -11,19 +12,19 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
* The Original Code is the Mozilla GNOME integration code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Srilatha Moturi <srilatha@netscape.com>
* Brian Ryner <bryner@brianryner.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* 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
@ -35,36 +36,36 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#ifndef nsMailGNOMEIntegration_h_
#define nsMailGNOMEIntegration_h_
interface nsIDOMWindow;
#include "nsIMapiRegistry.h"
#include "nsString.h"
/**
* This interface provides support for registering Mozilla as the default
* Mail Client. This interface can also be used to get/set the user preference
* for the default Mail Client.
*
*/
[scriptable, uuid(c5be14ba-4e0a-4eec-a1b8-04363761d63c)]
interface nsIMapiRegistry: nsISupports {
#define NS_MAILGNOMEINTEGRATION_CID \
{0xbddef0f4, 0x5e2d, 0x4846, {0xbd, 0xec, 0x86, 0xd0, 0x78, 0x1d, 0x8d, 0xed}}
/** This is set to TRUE if Mozilla is the default Application
*/
attribute boolean isDefaultMailClient;
class nsMailGNOMEIntegration : public nsIMapiRegistry
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMAPIREGISTRY
/** This is set TRUE only once per session.
*/
readonly attribute boolean showDialog;
NS_HIDDEN_(nsresult) Init();
/** This will bring the dialog asking the user if he/she wants to set
* Mozilla as default Mail Client.
* Call this only if Mozilla is not the default Mail client
*/
void showMailIntegrationDialog(in nsIDOMWindow parentWindow);
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;
nsCString mAppPath;
};
%{C++
#define NS_IMAPIREGISTRY_CONTRACTID "@mozilla.org/mapiregistry;1"
#define NS_IMAPIREGISTRY_CLASSNAME "Mozilla MAPI Registry"
%}
#endif

Просмотреть файл

@ -6,9 +6,7 @@ VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE=mailprofilemigration
LIBRARY_NAME = profilemigration
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
LIBRARY_NAME = profilemigration_s
MODULE_NAME = nsMailProfileMigratorModule
REQUIRES = \
@ -57,9 +55,6 @@ CPPSRCS += \
$(NULL)
endif
EXTRA_DSO_LDOPTS += \
$(MOZ_XPCOM_OBSOLETE_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -36,7 +36,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsILocalFile.h"
#include "nsIDOMWindowInternal.h"
#include "nsIProfileMigrator.h"
@ -291,62 +290,3 @@ cleanup:
NR_ShutdownRegistry();
return migrated;
}
// Make this into a component
#include "nsSeamonkeyProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsProfileMigrator)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSeamonkeyProfileMigrator)
#include "nsDogbertProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDogbertProfileMigrator)
#ifdef XP_WIN32
#include "nsOEProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOEProfileMigrator)
#include "nsOutlookProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOutlookProfileMigrator)
#endif
#if defined (XP_WIN32) || defined (XP_MACOSX)
#include "nsEudoraProfileMigrator.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsEudoraProfileMigrator)
#endif
static const nsModuleComponentInfo components[] =
{
{ "Profile Importer",
NS_THUNDERBIRD_PROFILEIMPORT_CID,
NS_PROFILEMIGRATOR_CONTRACTID,
nsProfileMigratorConstructor },
{ "Seamonkey Profile Migrator",
NS_SEAMONKEYPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "seamonkey",
nsSeamonkeyProfileMigratorConstructor },
{ "Netscape Communicator 4.x",
NS_DOGBERTPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "dogbert",
nsDogbertProfileMigratorConstructor },
#ifdef XP_WIN32
{ "Outlook Express Profile Migrator",
NS_OEXPRESSPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "oexpress",
nsOEProfileMigratorConstructor },
{ "Outlook Profile Migrator",
NS_OUTLOOKPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "outlook",
nsOutlookProfileMigratorConstructor },
#endif
#if defined (XP_WIN32) || defined (XP_MACOSX)
{ "Eudora Profile Migrator",
NS_EUDORAPROFILEMIGRATOR_CID,
NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "eudora",
nsEudoraProfileMigratorConstructor },
#endif
};
NS_IMPL_NSGETMODULE(nsMailProfileMigratorModule, components)

Просмотреть файл

@ -20,8 +20,73 @@ function Startup()
// see bug #158711
var newMailNotificationAlertUI = document.getElementById("newMailNotificationAlert");
newMailNotificationAlertUI.hidden = !("@mozilla.org/alerts-service;1" in Components.classes);
#ifdef MOZ_WIDGET_GTK2
// first check whether GNOME 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;
return;
}
#endif
}
#ifdef MOZ_WIDGET_GTK2
function checkDefaultMailNow(isNews) {
var mapiReg = Components.classes["@mozilla.org/mapiregistry;1"]
.getService(Components.interfaces.nsIMapiRegistry);
var brandBundle = document.getElementById("brandBundle");
var mapiBundle = document.getElementById("mapiBundle");
var brandShortName = brandBundle.getString("brandRealShortName");
var promptTitle = mapiBundle.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 (isNews) {
isDefault = mapiReg.isDefaultNewsClient;
str = "News";
} else {
isDefault = mapiReg.isDefaultMailClient;
str = "Mail";
}
if (!isDefault) {
promptMessage = mapiBundle.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 (isNews)
mapiReg.isDefaultNewsClient = true;
else
mapiReg.isDefaultMailClient = true;
}
} else {
promptMessage = mapiBundle.getFormattedString("alreadyDefault" + str,
[brandShortName]);
prompt.alert(window, promptTitle, promptMessage);
}
}
#endif
function setColorWell(menu)
{
// Find the colorWell and colorPicker in the hierarchy.

Просмотреть файл

@ -34,6 +34,9 @@
onload="parent.initPanel('chrome://messenger/content/pref-mailnews.xul');"
headertitle="&pane.title;">
<stringbundle id="mapiBundle" src="chrome://messenger-mapi/locale/mapi.properties"/>
<stringbundle id="brandBundle" src="chrome://global/locale/brand.properties"/>
<script type="application/x-javascript" src="chrome://messenger/content/pref-mailnews.js"/>
<script type="application/x-javascript">
@ -42,6 +45,11 @@
var _elementIDs = ["mailnewsStartPageEnabled", "mailnewsStartPageUrl", "mailPaneConfig", "mailnewsDoubleClick2NewWindow", "mailRememberLastMsg",
"mailnewsSoundFileUrl", "newMailNotification", "newMailNotificationType",
"newMailNotificationAlert"];
#ifdef MOZ_WIDGET_GTK2
_elementIDs.push("checkDefaultMail");
_elementIDs.push("checkDefaultNews");
#endif
]]>
</script>
@ -49,6 +57,34 @@
<caption label="&generalSettings.label;"/>
<hbox id="mapi"/>
#ifdef MOZ_WIDGET_GTK2
<vbox align="left" id="defaultClientBox">
<label value="&whenStartingCheck.label;"/>
<grid flex="1" style="margin-left: 20px;">
<columns>
<column/>
<column flex="1" align="left"/>
</columns>
<rows>
<row>
<checkbox id="checkDefaultMail" prefstring="mail.checkDefaultMail"
label="&mailApplication.label;"
accesskey="&checkDefaultMail.accesskey;"/>
<button label="&checkNow.label;" accesskey="&checkNow.accesskey;"
oncommand="checkDefaultMailNow(false)"/>
</row>
<row>
<checkbox id="checkDefaultNews" prefstring="mail.checkDefaultNews"
label="&newsApplication.label;"
accesskey="&checkDefaultNews.accesskey;"/>
<button label="&checkNow.label;" accesskey="&checkNow.accesskey;"
oncommand="checkDefaultMailNow(true)"/>
</row>
</rows>
</grid>
</vbox>
<separator class="thin"/>
#endif
<checkbox id="mailRememberLastMsg" label="&rememberLastMsg.label;"
prefstring="mailnews.remember_selected_message"

Просмотреть файл

@ -4,7 +4,7 @@ messenger.jar:
content/messenger/messengercompose/pref-sendOptions.xul (content/pref-sendOptions.xul)
+ content/messenger/pref-viewing_messages.xul (content/pref-viewing_messages.xul)
*+ content/messenger/pref-mailnews.xul (content/pref-mailnews.xul)
+ content/messenger/pref-mailnews.js (content/pref-mailnews.js)
*+ content/messenger/pref-mailnews.js (content/pref-mailnews.js)
*+ content/messenger/pref-advanced.xul (content/pref-advanced.xul)
*+ content/messenger/pref-advanced.js (content/pref-advanced.js)

Просмотреть файл

@ -35,3 +35,10 @@
<!ENTITY setDefaultMailClient.accesskey "u">
<!ENTITY setDefaultNewsClient.label "Use &vendorShortName; as the default news application">
<!ENTITY setDefaultNewsClient.accesskey "n">
<!ENTITY checkNow.label "Check Now">
<!ENTITY checkNow.accesskey "N">
<!ENTITY whenStartingCheck.label "When starting, &brandShortName; should check to see if it is the default application for">
<!ENTITY mailApplication.label "Mail">
<!ENTITY checkDefaultMail.accesskey "d">
<!ENTITY newsApplication.label "News">
<!ENTITY checkDefaultNews.accesskey "D">

Просмотреть файл

@ -113,7 +113,7 @@ function showMailIntegrationDialog() {
}
catch (ex) {}
try {
if (!prefLocked && !mapiRegistry.isDefaultMailClient)
if (!prefLocked)
mapiRegistry.showMailIntegrationDialog(window /* parent window */);
}
catch (ex) {

Просмотреть файл

@ -95,6 +95,7 @@ XPIDLSRCS = \
nsIMessengerOSIntegration.idl \
nsIMsgMdnGenerator.idl \
nsISpamSettings.idl \
nsIMapiRegistry.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -281,12 +281,10 @@ en-US.jar:
locale/en-US/messenger/vcard.properties (mime/cthandlers/resources/vcard.properties)
locale/en-US/messenger/smime.properties (mime/cthandlers/resources/smime.properties)
locale/en-US/messenger/markByDate.dtd (base/resources/locale/en-US/markByDate.dtd)
locale/en-US/messenger-mapi/pref-mailnewsOverlay.dtd (mapi/resources/locale/en-US/pref-mailnewsOverlay.dtd)
locale/en-US/messenger-mapi/mapi.properties (mapi/resources/locale/en-US/mapi.properties)
* locale/en-US/messenger-mapi/contents.rdf (mapi/resources/locale/en-US/contents.rdf)
US.jar:
* locale/US/messenger-region/contents.rdf (base/resources/locale/en-US/contents-region.rdf)
locale/US/messenger-region/region.properties (base/resources/locale/en-US/region.properties)
en-win.jar:
locale/en-US/messenger-mapi/pref-mailnewsOverlay.dtd (mapi/resources/locale/en-US/pref-mailnewsOverlay.dtd)
locale/en-US/messenger-mapi/mapi.properties (mapi/resources/locale/en-US/mapi.properties)
* locale/en-US/messenger-mapi/contents.rdf (mapi/resources/locale/en-US/contents.rdf)

Просмотреть файл

@ -46,7 +46,6 @@ MODULE = msgMapi
XPIDL_MODULE = mapihook
XPIDLSRCS = \
nsIMapiRegistry.idl \
nsIMapiSupport.idl \
$(NULL)

Просмотреть файл

@ -111,8 +111,12 @@ nsMapiRegistry::SetIsDefaultMailClient(PRBool aIsDefaultMailClient)
*/
NS_IMETHODIMP
nsMapiRegistry::ShowMailIntegrationDialog(nsIDOMWindow *aParentWindow) {
if (!m_ShowDialog || !m_registryUtils.getShowDialog() ||
m_registryUtils.IsDefaultMailClient()) {
return NS_OK;
}
nsresult rv;
if (!m_ShowDialog || !m_registryUtils.getShowDialog()) return NS_OK;
nsCOMPtr<nsIPromptService> promptService(do_GetService(
"@mozilla.org/embedcomp/prompt-service;1", &rv));
if (NS_SUCCEEDED(rv) && promptService)