diff options
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | mail/em-utils.c | 2 | ||||
-rw-r--r-- | modules/Makefile.am | 1 | ||||
-rw-r--r-- | modules/mailto-handler/Makefile.am | 54 | ||||
-rw-r--r-- | modules/mailto-handler/apps-evolution-mail-prompts-checkdefault.schemas.in (renamed from plugins/default-mailer/apps-evolution-mail-prompts-checkdefault.schemas.in) | 0 | ||||
-rw-r--r-- | modules/mailto-handler/evolution-mailto-handler.c | 274 | ||||
-rw-r--r-- | plugins/default-mailer/Makefile.am | 66 | ||||
-rw-r--r-- | plugins/default-mailer/default-mailer.c | 106 | ||||
-rw-r--r-- | plugins/default-mailer/org-gnome-default-mailer.eplug.xml | 20 | ||||
-rw-r--r-- | plugins/default-mailer/org-gnome-default-mailer.error.xml | 10 | ||||
-rw-r--r-- | shell/main.c | 3 |
11 files changed, 335 insertions, 205 deletions
diff --git a/configure.ac b/configure.ac index f4e00a99b0..5afd8917e1 100644 --- a/configure.ac +++ b/configure.ac @@ -1419,7 +1419,7 @@ plugins_base_always="calendar-file calendar-http itip-formatter plugin-manager d plugins_base="$plugins_base_always $SA_JUNK_PLUGIN $BF_JUNK_PLUGIN" dist_plugins_base="$plugins_base_always calendar-weather sa-junk-plugin bogo-junk-plugin" -plugins_standard_always="bbdb subject-thread save-calendar mail-to-task mailing-list-actions default-mailer prefer-plain mail-notification attachment-reminder backup-restore email-custom-header templates vcard-inline" +plugins_standard_always="bbdb subject-thread save-calendar mail-to-task mailing-list-actions prefer-plain mail-notification attachment-reminder backup-restore email-custom-header templates vcard-inline" plugins_standard="$plugins_standard_always" dist_plugins_standard="$plugins_standard audio-inline image-inline pst-import" @@ -1755,6 +1755,7 @@ modules/Makefile modules/addressbook/Makefile modules/calendar/Makefile modules/mail/Makefile +modules/mailto-handler/Makefile modules/network-manager/Makefile modules/connman/Makefile modules/plugin-lib/Makefile @@ -1772,7 +1773,6 @@ plugins/caldav/Makefile plugins/calendar-file/Makefile plugins/calendar-http/Makefile plugins/calendar-weather/Makefile -plugins/default-mailer/Makefile plugins/default-source/Makefile plugins/email-custom-header/Makefile plugins/external-editor/Makefile diff --git a/mail/em-utils.c b/mail/em-utils.c index c2982b66a5..ed6cef3779 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -149,7 +149,7 @@ em_utils_prompt_user(GtkWindow *parent, const gchar *promptkey, const gchar *tag g_object_unref (alert); if (promptkey) { - check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again.")); + check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again")); gtk_container_set_border_width((GtkContainer *)check, 12); container = gtk_dialog_get_content_area (GTK_DIALOG (mbox)); gtk_box_pack_start (GTK_BOX (container), check, TRUE, TRUE, 0); diff --git a/modules/Makefile.am b/modules/Makefile.am index 718cba2fa4..3920b51189 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -22,6 +22,7 @@ SUBDIRS = \ addressbook \ calendar \ mail \ + mailto-handler \ plugin-lib \ $(MONO_DIR) \ $(PYTHON_DIR) \ diff --git a/modules/mailto-handler/Makefile.am b/modules/mailto-handler/Makefile.am new file mode 100644 index 0000000000..8e61f34693 --- /dev/null +++ b/modules/mailto-handler/Makefile.am @@ -0,0 +1,54 @@ +module_LTLIBRARIES = libevolution-module-mailto-handler.la + +libevolution_module_mailto_handler_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"evolution-mailto-handler\" \ + $(GNOME_PLATFORM_CFLAGS) + +libevolution_module_mailto_handler_la_SOURCES = \ + evolution-mailto-handler.c + +libevolution_module_mailto_handler_la_LIBADD = \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/shell/libeshell.la \ + $(GNOME_PLATFORM_LIBS) + +libevolution_module_mailto_handler_la_LDFLAGS = \ + -module -avoid-version $(NO_UNDEFINED) + +schemadir = $(GCONF_SCHEMA_FILE_DIR) +schema_in_files = apps-evolution-mail-prompts-checkdefault.schemas.in +schema_DATA = $(schema_in_files:.schemas.in=.schemas) + +@INTLTOOL_SCHEMAS_RULE@ + +if GCONF_SCHEMAS_INSTALL + +if OS_WIN32 +install-data-local: + if test -z "$(DESTDIR)" ; then \ + for p in $(schema_DATA) ; do \ + (echo set GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE); \ + echo $(GCONFTOOL) --makefile-install-rule $$p) >_temp.bat; \ + cmd /c _temp.bat; \ + rm _temp.bat; \ + done \ + fi +else +install-data-local: + if test -z "$(DESTDIR)" ; then \ + for p in $(schema_DATA) ; do \ + GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \ + $(GCONFTOOL) --makefile-install-rule $$p; \ + done \ + fi +endif + +endif + +EXTRA_DIST = $(schema_in_files) + +DISTCLEANFILES = $(schema_DATA) + +-include $(top_srcdir)/git.mk diff --git a/plugins/default-mailer/apps-evolution-mail-prompts-checkdefault.schemas.in b/modules/mailto-handler/apps-evolution-mail-prompts-checkdefault.schemas.in index cdcaf7892a..cdcaf7892a 100644 --- a/plugins/default-mailer/apps-evolution-mail-prompts-checkdefault.schemas.in +++ b/modules/mailto-handler/apps-evolution-mail-prompts-checkdefault.schemas.in diff --git a/modules/mailto-handler/evolution-mailto-handler.c b/modules/mailto-handler/evolution-mailto-handler.c new file mode 100644 index 0000000000..076f2e0686 --- /dev/null +++ b/modules/mailto-handler/evolution-mailto-handler.c @@ -0,0 +1,274 @@ +/* + * evolution-mailto-handler.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + */ + +#include <config.h> +#include <glib/gi18n-lib.h> + +#include <shell/e-shell.h> +#include <e-util/e-binding.h> +#include <e-util/e-extension.h> + +/* Standard GObject macros */ +#define E_TYPE_MAILTO_HANDLER \ + (e_mailto_handler_get_type ()) +#define E_MAILTO_HANDLER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAILTO_HANDLER, EMailtoHandler)) + +#define MAILTO_COMMAND \ + "evolution --component=mail %s" + +typedef struct _EMailtoHandler EMailtoHandler; +typedef struct _EMailtoHandlerClass EMailtoHandlerClass; + +struct _EMailtoHandler { + EExtension parent; +}; + +struct _EMailtoHandlerClass { + EExtensionClass parent_class; +}; + +/* Module Entry Points */ +void e_module_load (GTypeModule *type_module); +void e_module_unload (GTypeModule *type_module); + +/* Forward Declarations */ +GType e_mailto_handler_get_type (void); + +G_DEFINE_DYNAMIC_TYPE (EMailtoHandler, e_mailto_handler, E_TYPE_EXTENSION) + +static EShell * +mailto_handler_get_shell (EMailtoHandler *extension) +{ + EExtensible *extensible; + + extensible = e_extension_get_extensible (E_EXTENSION (extension)); + + return E_SHELL (extensible); +} + +static gboolean +mailto_handler_is_evolution (const gchar *mailto_command) +{ + gint argc; + gchar **argv; + gchar *basename; + gboolean is_evolution; + + if (mailto_command == NULL) + return FALSE; + + /* Tokenize the mailto command. */ + if (!g_shell_parse_argv (mailto_command, &argc, &argv, NULL)) + return FALSE; + + g_return_val_if_fail (argc > 0, FALSE); + + /* Check the basename of the first token. */ + basename = g_path_get_basename (argv[0]); + is_evolution = g_str_has_prefix (basename, "evolution"); + g_free (basename); + + g_strfreev (argv); + + return is_evolution; +} + +static gboolean +mailto_handler_prompt (EMailtoHandler *extension) +{ + EShell *shell; + EShellSettings *shell_settings; + GtkWidget *container; + GtkWidget *dialog; + GtkWidget *widget; + const gchar *text; + gchar *markup; + gint response; + + shell = mailto_handler_get_shell (extension); + shell_settings = e_shell_get_shell_settings (shell); + + dialog = gtk_dialog_new_with_buttons ( + "", NULL, 0, + GTK_STOCK_NO, GTK_RESPONSE_NO, + GTK_STOCK_YES, GTK_RESPONSE_YES, + NULL); + + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); + + container = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + widget = gtk_hbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (widget), 5); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_image_new_from_stock ( + GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + widget = gtk_vbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + gtk_widget_show (widget); + + container = widget; + + text = _("Do you want to make Evolution your default email client?"); + markup = g_markup_printf_escaped ("<b>%s</b>", text); + widget = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (widget), markup); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + g_free (markup); + + text = _("_Do not show this message again"); + widget = gtk_check_button_new_with_mnemonic (text); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 12); + gtk_widget_show (widget); + + e_mutual_binding_new_with_negation ( + shell_settings, "mailto-handler-check", + widget, "active"); + + /* Direct input focus away from the checkbox. */ + widget = gtk_dialog_get_widget_for_response ( + GTK_DIALOG (dialog), GTK_RESPONSE_YES); + gtk_widget_grab_focus (widget); + + response = gtk_dialog_run (GTK_DIALOG (dialog)); + + gtk_widget_destroy (dialog); + + return (response == GTK_RESPONSE_YES); +} + +static void +mailto_handler_check (EMailtoHandler *extension) +{ + EShell *shell; + EShellSettings *shell_settings; + gboolean check_mailto_handler = TRUE; + gchar *mailto_command = NULL; + + shell = mailto_handler_get_shell (extension); + shell_settings = e_shell_get_shell_settings (shell); + + g_object_get ( + shell_settings, + "mailto-handler-command", &mailto_command, + "mailto-handler-check", &check_mailto_handler, + NULL); + + /* Should we check the "mailto" URI handler? */ + if (!check_mailto_handler) + goto exit; + + /* Is Evolution already handling "mailto" URIs? */ + if (mailto_handler_is_evolution (mailto_command)) + goto exit; + + /* Does the user want Evolution to handle them? */ + if (!mailto_handler_prompt (extension)) + goto exit; + + /* Configure Evolution to be the "mailto" URI handler. */ + + g_object_set ( + shell_settings, + "mailto-handler-command", MAILTO_COMMAND, + "mailto-handler-enabled", TRUE, + "mailto-handler-needs-terminal", FALSE, + NULL); + +exit: + g_free (mailto_command); +} + +static void +mailto_handler_constructed (GObject *object) +{ + EShell *shell; + EShellSettings *shell_settings; + EMailtoHandler *extension; + + extension = E_MAILTO_HANDLER (object); + + shell = mailto_handler_get_shell (extension); + shell_settings = e_shell_get_shell_settings (shell); + + e_shell_settings_install_property_for_key ( + "mailto-handler-check", + "/apps/evolution/mail/prompts/checkdefault"); + + e_shell_settings_install_property_for_key ( + "mailto-handler-command", + "/desktop/gnome/url-handlers/mailto/command"); + + e_shell_settings_install_property_for_key ( + "mailto-handler-enabled", + "/desktop/gnome/url-handlers/mailto/enabled"); + + e_shell_settings_install_property_for_key ( + "mailto-handler-needs-terminal", + "/desktop/gnome/url-handlers/mailto/needs_terminal"); + + g_signal_connect_swapped ( + shell, "event::ready-to-start", + G_CALLBACK (mailto_handler_check), extension); +} + +static void +e_mailto_handler_class_init (EMailtoHandlerClass *class) +{ + GObjectClass *object_class; + EExtensionClass *extension_class; + + object_class = G_OBJECT_CLASS (class); + object_class->constructed = mailto_handler_constructed; + + extension_class = E_EXTENSION_CLASS (class); + extension_class->extensible_type = E_TYPE_SHELL; +} + +static void +e_mailto_handler_class_finalize (EMailtoHandlerClass *class) +{ +} + +static void +e_mailto_handler_init (EMailtoHandler *extension) +{ +} + +G_MODULE_EXPORT void +e_module_load (GTypeModule *type_module) +{ + e_mailto_handler_register_type (type_module); +} + +G_MODULE_EXPORT void +e_module_unload (GTypeModule *type_module) +{ +} diff --git a/plugins/default-mailer/Makefile.am b/plugins/default-mailer/Makefile.am deleted file mode 100644 index b4132fd8eb..0000000000 --- a/plugins/default-mailer/Makefile.am +++ /dev/null @@ -1,66 +0,0 @@ -@EVO_PLUGIN_RULE@ - -error_DATA = org-gnome-default-mailer.error -errordir = $(privdatadir)/errors - -plugin_DATA = org-gnome-default-mailer.eplug - -plugin_LTLIBRARIES = liborg-gnome-default-mailer.la - -liborg_gnome_default_mailer_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets \ - $(GNOME_PLATFORM_CFLAGS) \ - $(EVOLUTION_MAIL_CFLAGS) - -liborg_gnome_default_mailer_la_SOURCES = default-mailer.c -liborg_gnome_default_mailer_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) -liborg_gnome_default_mailer_la_LIBADD = \ - $(top_builddir)/mail/libevolution-mail.la \ - $(EVOLUTION_MAIL_LIBS) \ - $(GNOME_PLATFORM_LIBS) - -schemadir = $(GCONF_SCHEMA_FILE_DIR) -schema_in_files = apps-evolution-mail-prompts-checkdefault.schemas.in -schema_DATA = $(schema_in_files:.schemas.in=.schemas) - -@INTLTOOL_SCHEMAS_RULE@ - -if GCONF_SCHEMAS_INSTALL - -if OS_WIN32 -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schema_DATA) ; do \ - (echo set GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE); \ - echo $(GCONFTOOL) --makefile-install-rule $$p) >_temp.bat; \ - cmd /c _temp.bat; \ - rm _temp.bat; \ - done \ - fi -else -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schema_DATA) ; do \ - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \ - $(GCONFTOOL) --makefile-install-rule $$p; \ - done \ - fi -endif - -endif - -EXTRA_DIST = \ - org-gnome-default-mailer.eplug.xml \ - org-gnome-default-mailer.error.xml \ - $(schema_in_files) - -BUILT_SOURCES = org-gnome-default-mailer.eplug \ - org-gnome-default-mailer.error - -CLEANFILES = $(BUILT_SOURCES) - -DISTCLEANFILES = $(schema_DATA) - --include $(top_srcdir)/git.mk diff --git a/plugins/default-mailer/default-mailer.c b/plugins/default-mailer/default-mailer.c deleted file mode 100644 index 47be2d5e85..0000000000 --- a/plugins/default-mailer/default-mailer.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Jonathan Dieter <jdieter99@gmx.net> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * Copyright 2005 Jonathan Dieter - * - */ - -#include <stdlib.h> -#include <string.h> - -#include <gconf/gconf-client.h> - -#include <mail/em-utils.h> -#include <shell/es-event.h> - -#define GCONF_KEY_CHECKDEFAULT "/apps/evolution/mail/prompts/checkdefault" -#define GCONF_KEY_MAILTO_ENABLED "/desktop/gnome/url-handlers/mailto/enabled" -#define GCONF_KEY_MAILTO_COMMAND "/desktop/gnome/url-handlers/mailto/command" -#define EVOLUTION_MAILTO_COMMAND "evolution --component=mail %s" - -void org_gnome_default_mailer_check_default (EPlugin *ep, ESEventTargetUpgrade *target); -gint e_plugin_lib_enable (EPlugin *ep, gint enable); - -gint -e_plugin_lib_enable (EPlugin *ep, gint enable) -{ - return 0; -} - -static gboolean -evolution_is_default_mailer (const gchar *mailto_command) -{ - gint argc; - gchar **argv; - gchar *basename; - gboolean is_default; - - if (mailto_command == NULL) - return FALSE; - - /* tokenize the mailto command */ - if (!g_shell_parse_argv (mailto_command, &argc, &argv, NULL)) - return FALSE; - - g_assert (argc > 0); - - /* check the basename of the first token */ - basename = g_path_get_basename (argv[0]); - is_default = g_str_has_prefix (basename, "evolution"); - g_free (basename); - - g_strfreev (argv); - - return is_default; -} - -void -org_gnome_default_mailer_check_default (EPlugin *ep, ESEventTargetUpgrade *target) -{ - GConfClient *client; - gchar *mailer; - GConfValue *is_key; - - client = gconf_client_get_default (); - - /* See whether the check default mailer key has already been set */ - is_key = gconf_client_get(client, GCONF_KEY_CHECKDEFAULT, NULL); - if (!is_key) - gconf_client_set_bool(client, GCONF_KEY_CHECKDEFAULT, TRUE, NULL); - else - gconf_value_free (is_key); - - /* Check whether we're supposed to check whether or not we are the default mailer */ - if (gconf_client_get_bool(client, GCONF_KEY_CHECKDEFAULT, NULL)) { - mailer = gconf_client_get_string(client, GCONF_KEY_MAILTO_COMMAND, NULL); - - /* Check whether we are the default mailer */ - if (!evolution_is_default_mailer (mailer)) { - /* Ask whether we should be the default mailer */ - if (em_utils_prompt_user(NULL, GCONF_KEY_CHECKDEFAULT, "org.gnome.default.mailer:check-default", NULL)) { - gconf_client_set_bool(client, GCONF_KEY_MAILTO_ENABLED, TRUE, NULL); - gconf_client_set_string(client, GCONF_KEY_MAILTO_COMMAND, EVOLUTION_MAILTO_COMMAND, NULL); - } - } - - g_free(mailer); - } - - g_object_unref (client); -} diff --git a/plugins/default-mailer/org-gnome-default-mailer.eplug.xml b/plugins/default-mailer/org-gnome-default-mailer.eplug.xml deleted file mode 100644 index 44c5febedf..0000000000 --- a/plugins/default-mailer/org-gnome-default-mailer.eplug.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<e-plugin-list> - <e-plugin - id="org.gnome.evolution.default.mailer" - type="shlib" - _name="Default Mail Client" - location="@PLUGINDIR@/liborg-gnome-default-mailer@SOEXT@"> - - <_description>Check whether Evolution is the default mail client on startup.</_description> - <author name="Jonathan Dieter" email="jdieter99@gmx.net"/> - - <hook class="org.gnome.evolution.shell.events:1.0"> - <event - id="upgrade.done" - handle="org_gnome_default_mailer_check_default" - target="upgrade" - /> - </hook> - </e-plugin> -</e-plugin-list> diff --git a/plugins/default-mailer/org-gnome-default-mailer.error.xml b/plugins/default-mailer/org-gnome-default-mailer.error.xml deleted file mode 100644 index 03e2e8262d..0000000000 --- a/plugins/default-mailer/org-gnome-default-mailer.error.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<error-list domain="org.gnome.default.mailer"> - - <error id="check-default" type="question" default="GTK_RESPONSE_YES"> - <_secondary>Do you want to make Evolution your default e-mail client?</_secondary> - <button stock="gtk-yes" response="GTK_RESPONSE_YES"/> - <button stock="gtk-no" response="GTK_RESPONSE_NO"/> - </error> - -</error-list> diff --git a/shell/main.c b/shell/main.c index 60871e60c2..c42917c1ff 100644 --- a/shell/main.c +++ b/shell/main.c @@ -552,6 +552,9 @@ main (gint argc, gchar **argv) * as both shell backends and certain plugins hook into this. */ e_shell_migrate_attempt (shell); + /* This is an alternative to the "upgrade.done" EEvent. */ + e_shell_event (shell, "ready-to-start", NULL); + g_idle_add ((GSourceFunc) idle_cb, remaining_args); gtk_main (); |