diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-08-29 08:21:54 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-08-30 05:23:20 +0800 |
commit | 32f545cdf031ebe3718791f18e8fb6b6141fd081 (patch) | |
tree | 980723161c32da855ca91b135318d7fa67dc18c7 /modules/mail | |
parent | e8382099228d46ebef684c5384bab6ec710283ce (diff) | |
download | gsoc2013-evolution-32f545cdf031ebe3718791f18e8fb6b6141fd081.tar gsoc2013-evolution-32f545cdf031ebe3718791f18e8fb6b6141fd081.tar.gz gsoc2013-evolution-32f545cdf031ebe3718791f18e8fb6b6141fd081.tar.bz2 gsoc2013-evolution-32f545cdf031ebe3718791f18e8fb6b6141fd081.tar.lz gsoc2013-evolution-32f545cdf031ebe3718791f18e8fb6b6141fd081.tar.xz gsoc2013-evolution-32f545cdf031ebe3718791f18e8fb6b6141fd081.tar.zst gsoc2013-evolution-32f545cdf031ebe3718791f18e8fb6b6141fd081.zip |
Simplify EPlugin loading at startup.
- Require all EPlugin and EPluginHook subtypes be registered before
loading plugins. This drastically simplifies the EPlugin/EPluginHook
negotiation.
- Turn most EPluginHook subtypes into GTypeModules and register their
types from an e_module_load() function (does not include shell hooks).
- Convert EPluginLib and the Mono and Python bindings to GTypeModules
and register their types from an e_module_load() function, and kill
EPluginTypeHook.
Diffstat (limited to 'modules/mail')
-rw-r--r-- | modules/mail/Makefile.am | 10 | ||||
-rw-r--r-- | modules/mail/e-attachment-handler-mail.h | 65 | ||||
-rw-r--r-- | modules/mail/e-mail-attachment-handler.c (renamed from modules/mail/e-attachment-handler-mail.c) | 99 | ||||
-rw-r--r-- | modules/mail/e-mail-attachment-handler.h | 67 | ||||
-rw-r--r-- | modules/mail/e-mail-config-hook.c | 69 | ||||
-rw-r--r-- | modules/mail/e-mail-config-hook.h | 33 | ||||
-rw-r--r-- | modules/mail/e-mail-event-hook.c | 93 | ||||
-rw-r--r-- | modules/mail/e-mail-event-hook.h | 33 | ||||
-rw-r--r-- | modules/mail/e-mail-junk-hook.c | 323 | ||||
-rw-r--r-- | modules/mail/e-mail-junk-hook.h | 66 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-backend.c | 31 | ||||
-rw-r--r-- | modules/mail/em-mailer-prefs.c | 26 | ||||
-rw-r--r-- | modules/mail/evolution-module-mail.c | 12 |
13 files changed, 775 insertions, 152 deletions
diff --git a/modules/mail/Makefile.am b/modules/mail/Makefile.am index 866a137b08..462161843c 100644 --- a/modules/mail/Makefile.am +++ b/modules/mail/Makefile.am @@ -12,8 +12,14 @@ module_LTLIBRARIES = libevolution-module-mail.la libevolution_module_mail_la_SOURCES = \ evolution-module-mail.c \ - e-attachment-handler-mail.c \ - e-attachment-handler-mail.h \ + e-mail-attachment-handler.c \ + e-mail-attachment-handler.h \ + e-mail-config-hook.c \ + e-mail-config-hook.h \ + e-mail-event-hook.c \ + e-mail-event-hook.h \ + e-mail-junk-hook.c \ + e-mail-junk-hook.h \ e-mail-shell-backend.c \ e-mail-shell-backend.h \ e-mail-shell-content.c \ diff --git a/modules/mail/e-attachment-handler-mail.h b/modules/mail/e-attachment-handler-mail.h deleted file mode 100644 index c62ea99cab..0000000000 --- a/modules/mail/e-attachment-handler-mail.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * e-attachment-handler-mail.h - * - * 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/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef E_ATTACHMENT_HANDLER_MAIL_H -#define E_ATTACHMENT_HANDLER_MAIL_H - -#include <widgets/misc/e-attachment-handler.h> - -/* Standard GObject macros */ -#define E_TYPE_ATTACHMENT_HANDLER_MAIL \ - (e_attachment_handler_mail_get_type ()) -#define E_ATTACHMENT_HANDLER_MAIL(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_ATTACHMENT_HANDLER_MAIL, EAttachmentHandlerMail)) -#define E_ATTACHMENT_HANDLER_MAIL_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_ATTACHMENT_HANDLER_MAIL, EAttachmentHandlerMailClass)) -#define E_IS_ATTACHMENT_HANDLER_MAIL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_ATTACHMENT_HANDLER_MAIL)) -#define E_IS_ATTACHMENT_HANDLER_MAIL_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_ATTACHMENT_HANDLER_MAIL)) -#define E_ATTACHMENT_HANDLER_MAIL_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_ATTACHMENT_HANDLER_MAIL, EAttachmentHandlerMailClass)) - -G_BEGIN_DECLS - -typedef struct _EAttachmentHandlerMail EAttachmentHandlerMail; -typedef struct _EAttachmentHandlerMailClass EAttachmentHandlerMailClass; -typedef struct _EAttachmentHandlerMailPrivate EAttachmentHandlerMailPrivate; - -struct _EAttachmentHandlerMail { - EAttachmentHandler parent; - EAttachmentHandlerMailPrivate *priv; -}; - -struct _EAttachmentHandlerMailClass { - EAttachmentHandlerClass parent_class; -}; - -GType e_attachment_handler_mail_get_type (void); - -G_END_DECLS - -#endif /* E_ATTACHMENT_HANDLER_MAIL_H */ diff --git a/modules/mail/e-attachment-handler-mail.c b/modules/mail/e-mail-attachment-handler.c index c17c97d8ca..91fe5d3e5f 100644 --- a/modules/mail/e-attachment-handler-mail.c +++ b/modules/mail/e-mail-attachment-handler.c @@ -1,5 +1,5 @@ /* - * e-attachment-handler-mail.c + * e-mail-attachment-handler.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,7 @@ * */ -#include "e-attachment-handler-mail.h" +#include "e-mail-attachment-handler.h" #include <glib/gi18n.h> #include <camel/camel-folder.h> @@ -29,15 +29,16 @@ #include "mail/em-composer-utils.h" #include "mail/mail-tools.h" -#define E_ATTACHMENT_HANDLER_MAIL_GET_PRIVATE(obj) \ +#define E_MAIL_ATTACHMENT_HANDLER_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_ATTACHMENT_HANDLER_MAIL, EAttachmentHandlerMailPrivate)) + ((obj), E_TYPE_MAIL_ATTACHMENT_HANDLER, EMailAttachmentHandlerPrivate)) -struct _EAttachmentHandlerMailPrivate { +struct _EMailAttachmentHandlerPrivate { gint placeholder; }; static gpointer parent_class; +static GType mail_attachment_handler_type; static const gchar *ui = "<ui>" @@ -57,7 +58,7 @@ static GtkTargetEntry target_table[] = { }; static void -attachment_handler_mail_forward (GtkAction *action, +mail_attachment_handler_forward (GtkAction *action, EAttachmentView *view) { EAttachment *attachment; @@ -79,7 +80,7 @@ attachment_handler_mail_forward (GtkAction *action, } static void -attachment_handler_mail_reply_all (GtkAction *action, +mail_attachment_handler_reply_all (GtkAction *action, EAttachmentView *view) { EAttachment *attachment; @@ -103,7 +104,7 @@ attachment_handler_mail_reply_all (GtkAction *action, } static void -attachment_handler_mail_reply_sender (GtkAction *action, +mail_attachment_handler_reply_sender (GtkAction *action, EAttachmentView *view) { EAttachment *attachment; @@ -133,25 +134,25 @@ static GtkActionEntry standard_entries[] = { N_("_Forward"), NULL, NULL, /* XXX Add a tooltip! */ - G_CALLBACK (attachment_handler_mail_forward) }, + G_CALLBACK (mail_attachment_handler_forward) }, { "mail-reply-all", "mail-reply-all", N_("Reply to _All"), NULL, NULL, /* XXX Add a tooltip! */ - G_CALLBACK (attachment_handler_mail_reply_all) }, + G_CALLBACK (mail_attachment_handler_reply_all) }, { "mail-reply-sender", "mail-reply-sender", N_("_Reply to Sender"), NULL, NULL, /* XXX Add a tooltip! */ - G_CALLBACK (attachment_handler_mail_reply_sender) } + G_CALLBACK (mail_attachment_handler_reply_sender) } }; static void -attachment_handler_mail_message_rfc822 (EAttachmentView *view, +mail_attachment_handler_message_rfc822 (EAttachmentView *view, GdkDragContext *drag_context, gint x, gint y, @@ -213,7 +214,7 @@ exit: } static void -attachment_handler_mail_x_uid_list (EAttachmentView *view, +mail_attachment_handler_x_uid_list (EAttachmentView *view, GdkDragContext *drag_context, gint x, gint y, @@ -380,7 +381,7 @@ exit: } static void -attachment_handler_mail_update_actions (EAttachmentView *view) +mail_attachment_handler_update_actions (EAttachmentView *view) { EAttachment *attachment; CamelMimePart *mime_part; @@ -413,7 +414,7 @@ exit: } static void -attachment_handler_mail_constructed (GObject *object) +mail_attachment_handler_constructed (GObject *object) { EAttachmentHandler *handler; EAttachmentView *view; @@ -443,28 +444,28 @@ attachment_handler_mail_constructed (GObject *object) g_signal_connect ( view, "update-actions", - G_CALLBACK (attachment_handler_mail_update_actions), + G_CALLBACK (mail_attachment_handler_update_actions), NULL); g_signal_connect ( view, "drag-data-received", - G_CALLBACK (attachment_handler_mail_message_rfc822), + G_CALLBACK (mail_attachment_handler_message_rfc822), NULL); g_signal_connect ( view, "drag-data-received", - G_CALLBACK (attachment_handler_mail_x_uid_list), + G_CALLBACK (mail_attachment_handler_x_uid_list), NULL); } static GdkDragAction -attachment_handler_mail_get_drag_actions (EAttachmentHandler *handler) +mail_attachment_handler_get_drag_actions (EAttachmentHandler *handler) { return GDK_ACTION_COPY; } static const GtkTargetEntry * -attachment_handler_mail_get_target_table (EAttachmentHandler *handler, +mail_attachment_handler_get_target_table (EAttachmentHandler *handler, guint *n_targets) { if (n_targets != NULL) @@ -474,51 +475,51 @@ attachment_handler_mail_get_target_table (EAttachmentHandler *handler, } static void -attachment_handler_mail_class_init (EAttachmentHandlerMailClass *class) +mail_attachment_handler_class_init (EMailAttachmentHandlerClass *class) { GObjectClass *object_class; EAttachmentHandlerClass *handler_class; parent_class = g_type_class_peek_parent (class); - g_type_class_add_private (class, sizeof (EAttachmentHandlerMailPrivate)); + g_type_class_add_private (class, sizeof (EMailAttachmentHandlerPrivate)); object_class = G_OBJECT_CLASS (class); - object_class->constructed = attachment_handler_mail_constructed; + object_class->constructed = mail_attachment_handler_constructed; handler_class = E_ATTACHMENT_HANDLER_CLASS (class); - handler_class->get_drag_actions = attachment_handler_mail_get_drag_actions; - handler_class->get_target_table = attachment_handler_mail_get_target_table; + handler_class->get_drag_actions = mail_attachment_handler_get_drag_actions; + handler_class->get_target_table = mail_attachment_handler_get_target_table; } static void -attachment_handler_mail_init (EAttachmentHandlerMail *handler) +mail_attachment_handler_init (EMailAttachmentHandler *handler) { - handler->priv = E_ATTACHMENT_HANDLER_MAIL_GET_PRIVATE (handler); + handler->priv = E_MAIL_ATTACHMENT_HANDLER_GET_PRIVATE (handler); } GType -e_attachment_handler_mail_get_type (void) +e_mail_attachment_handler_get_type (void) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EAttachmentHandlerMailClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) attachment_handler_mail_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EAttachmentHandlerMail), - 0, /* n_preallocs */ - (GInstanceInitFunc) attachment_handler_mail_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_ATTACHMENT_HANDLER, - "EAttachmentHandlerMail", &type_info, 0); - } + return mail_attachment_handler_type; +} - return type; +void +e_mail_attachment_handler_register_type (GTypeModule *type_module) +{ + static const GTypeInfo type_info = { + sizeof (EMailAttachmentHandlerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_attachment_handler_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailAttachmentHandler), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_attachment_handler_init, + NULL /* value_table */ + }; + + mail_attachment_handler_type = g_type_module_register_type ( + type_module, E_TYPE_ATTACHMENT_HANDLER, + "EMailAttachmentHandler", &type_info, 0); } diff --git a/modules/mail/e-mail-attachment-handler.h b/modules/mail/e-mail-attachment-handler.h new file mode 100644 index 0000000000..13032b488c --- /dev/null +++ b/modules/mail/e-mail-attachment-handler.h @@ -0,0 +1,67 @@ +/* + * e-mail-attachment-handler.h + * + * 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/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_ATTACHMENT_HANDLER_H +#define E_MAIL_ATTACHMENT_HANDLER_H + +#include <widgets/misc/e-attachment-handler.h> + +/* Standard GObject macros */ +#define E_TYPE_MAIL_ATTACHMENT_HANDLER \ + (e_mail_attachment_handler_get_type ()) +#define E_MAIL_ATTACHMENT_HANDLER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_ATTACHMENT_HANDLER, EMailAttachmentHandler)) +#define E_MAIL_ATTACHMENT_HANDLER_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_ATTACHMENT_HANDLER, EMailAttachmentHandlerClass)) +#define E_IS_MAIL_ATTACHMENT_HANDLER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_ATTACHMENT_HANDLER)) +#define E_IS_MAIL_ATTACHMENT_HANDLER_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MAIL_ATTACHMENT_HANDLER)) +#define E_MAIL_ATTACHMENT_HANDLER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MAIL_ATTACHMENT_HANDLER, EMailAttachmentHandlerClass)) + +G_BEGIN_DECLS + +typedef struct _EMailAttachmentHandler EMailAttachmentHandler; +typedef struct _EMailAttachmentHandlerClass EMailAttachmentHandlerClass; +typedef struct _EMailAttachmentHandlerPrivate EMailAttachmentHandlerPrivate; + +struct _EMailAttachmentHandler { + EAttachmentHandler parent; + EMailAttachmentHandlerPrivate *priv; +}; + +struct _EMailAttachmentHandlerClass { + EAttachmentHandlerClass parent_class; +}; + +GType e_mail_attachment_handler_get_type (void); +void e_mail_attachment_handler_register_type + (GTypeModule *type_module); + +G_END_DECLS + +#endif /* E_MAIL_ATTACHMENT_HANDLER_H */ diff --git a/modules/mail/e-mail-config-hook.c b/modules/mail/e-mail-config-hook.c new file mode 100644 index 0000000000..4b37a6b171 --- /dev/null +++ b/modules/mail/e-mail-config-hook.c @@ -0,0 +1,69 @@ +/* + * e-mail-config-hook.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/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-config-hook.h" + +#include "e-util/e-config.h" +#include "mail/em-config.h" + +static const EConfigHookTargetMask no_masks[] = { + { NULL } +}; + +static const EConfigHookTargetMap targets[] = { + { "folder", EM_CONFIG_TARGET_FOLDER, no_masks }, + { "prefs", EM_CONFIG_TARGET_PREFS, no_masks }, + { "account", EM_CONFIG_TARGET_ACCOUNT, no_masks }, + { NULL } +}; + +static void +mail_config_hook_class_init (EPluginHookClass *class) +{ + gint ii; + + class->id = "org.gnome.evolution.mail.config:1.0"; + + for (ii = 0; targets[ii].type != NULL; ii++) + e_config_hook_class_add_target_map ( + (EConfigHookClass *) class, &targets[ii]); +} + +void +e_mail_config_hook_register_type (GTypeModule *type_module) +{ + const GTypeInfo type_info = { + sizeof (EConfigHookClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_config_hook_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EConfigHook), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + NULL /* value_table */ + }; + + g_type_module_register_type ( + type_module, e_config_hook_get_type (), + "EMailConfigHook", &type_info, 0); +} diff --git a/modules/mail/e-mail-config-hook.h b/modules/mail/e-mail-config-hook.h new file mode 100644 index 0000000000..e54ad81815 --- /dev/null +++ b/modules/mail/e-mail-config-hook.h @@ -0,0 +1,33 @@ +/* + * e-mail-config-hook.h + * + * 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/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_CONFIG_HOOK_H +#define E_MAIL_CONFIG_HOOK_H + +#include <glib-object.h> + +G_BEGIN_DECLS + +void e_mail_config_hook_register_type (GTypeModule *type_module); + +G_END_DECLS + +#endif /* E_MAIL_CONFIG_HOOK_H */ diff --git a/modules/mail/e-mail-event-hook.c b/modules/mail/e-mail-event-hook.c new file mode 100644 index 0000000000..a6be6d294f --- /dev/null +++ b/modules/mail/e-mail-event-hook.c @@ -0,0 +1,93 @@ +/* + * e-mail-event-hook.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/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-event-hook.h" + +#include "e-util/e-event.h" +#include "mail/em-event.h" + +static const EEventHookTargetMask folder_masks[] = { + { "newmail", EM_EVENT_FOLDER_NEWMAIL }, + { NULL } +}; + +static const EEventHookTargetMask composer_masks[] = { + { "sendoption", EM_EVENT_COMPOSER_SEND_OPTION }, + { NULL } +}; + +static const EEventHookTargetMask message_masks[] = { + { "replyall", EM_EVENT_MESSAGE_REPLY_ALL }, + { "reply", EM_EVENT_MESSAGE_REPLY }, + { NULL } +}; + +static const EEventHookTargetMask send_receive_masks[] = { + { "sendreceive", EM_EVENT_SEND_RECEIVE }, + { NULL } +}; + +static const EEventHookTargetMask custom_icon_masks[] = { + { "customicon", EM_EVENT_CUSTOM_ICON }, + { NULL } +}; + +static const EEventHookTargetMap targets[] = { + { "folder", EM_EVENT_TARGET_FOLDER, folder_masks }, + { "message", EM_EVENT_TARGET_MESSAGE, message_masks }, + { "composer", EM_EVENT_TARGET_COMPOSER, composer_masks }, + { "sendreceive", EM_EVENT_TARGET_SEND_RECEIVE, send_receive_masks }, + { "customicon", EM_EVENT_TARGET_CUSTOM_ICON, custom_icon_masks }, + { NULL } +}; + +static void +mail_event_hook_class_init (EPluginHookClass *class) +{ + gint ii; + + class->id = "org.gnome.evolution.mail.events:1.0"; + + for (ii = 0; targets[ii].type != NULL; ii++) + e_event_hook_class_add_target_map ( + (EEventHookClass *) class, &targets[ii]); +} + +void +e_mail_event_hook_register_type (GTypeModule *type_module) +{ + const GTypeInfo type_info = { + sizeof (EEventHookClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_event_hook_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EEventHook), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + NULL /* value_table */ + }; + + g_type_module_register_type ( + type_module, e_event_hook_get_type (), + "EMailEventHook", &type_info, 0); +} diff --git a/modules/mail/e-mail-event-hook.h b/modules/mail/e-mail-event-hook.h new file mode 100644 index 0000000000..9cad43a0c2 --- /dev/null +++ b/modules/mail/e-mail-event-hook.h @@ -0,0 +1,33 @@ +/* + * e-mail-event-hook.h + * + * 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/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_EVENT_HOOK_H +#define E_MAIL_EVENT_HOOK_H + +#include <glib-object.h> + +G_BEGIN_DECLS + +void e_mail_event_hook_register_type (GTypeModule *type_module); + +G_END_DECLS + +#endif /* E_MAIL_EVENT_HOOK_H */ diff --git a/modules/mail/e-mail-junk-hook.c b/modules/mail/e-mail-junk-hook.c new file mode 100644 index 0000000000..2687223af9 --- /dev/null +++ b/modules/mail/e-mail-junk-hook.c @@ -0,0 +1,323 @@ +/* + * e-mail-junk-hook.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/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-junk-hook.h" + +#include <glib/gi18n.h> +#include <camel/camel-junk-plugin.h> + +#include "e-util/e-error.h" +#include "mail/em-junk.h" +#include "mail/em-utils.h" +#include "mail/mail-session.h" + +#define E_MAIL_JUNK_HOOK_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_JUNK_HOOK, EMailJunkHookPrivate)) + +struct _EMailJunkHookPrivate { + EMJunkInterface interface; +}; + +struct ErrorData { + const gchar *error_message; + GError *error; +}; + +static gpointer parent_class; +static GType mail_junk_hook_type; + +static gboolean +mail_junk_hook_idle_cb (struct ErrorData *data) +{ + GtkWidget *widget; + + widget = e_error_new ( + NULL, data->error_message, data->error->message, NULL); + em_utils_show_error_silent (widget); + + g_error_free (data->error); + g_slice_free (struct ErrorData, data); + + return FALSE; +} + +static void +mail_junk_hook_error (const gchar *error_message, + GError *error) +{ + struct ErrorData *data; + + g_return_if_fail (error != NULL); + + data = g_slice_new (struct ErrorData); + data->error_message = error_message; + data->error = error; + + g_idle_add ((GSourceFunc) mail_junk_hook_idle_cb, data); +} + +static const gchar * +mail_junk_hook_get_name (CamelJunkPlugin *junk_plugin) +{ + EMJunkInterface *interface; + + interface = (EMJunkInterface *) junk_plugin; + + if (!interface->hook->plugin->enabled) + return _("None"); + + return interface->hook->plugin->name; +} + +static void +mail_junk_hook_plugin_init (CamelJunkPlugin *junk_plugin) +{ + EMJunkInterface *interface; + EPluginClass *class; + + interface = (EMJunkInterface *) junk_plugin; + + class = E_PLUGIN_GET_CLASS (interface->hook->plugin); + g_return_if_fail (class->enable != NULL); + + class->enable (interface->hook->plugin, 1); +} + +static gboolean +mail_junk_hook_check_junk (CamelJunkPlugin *junk_plugin, + CamelMimeMessage *mime_message) +{ + EMJunkTarget target = { mime_message, NULL }; + EMJunkInterface *interface; + gpointer result; + + interface = (EMJunkInterface *) junk_plugin; + + if (!interface->hook->plugin->enabled) + return FALSE; + + result = e_plugin_invoke ( + interface->hook->plugin, + interface->check_junk, &target); + + if (target.error != NULL) + mail_junk_hook_error ("mail:junk-check-error", target.error); + + return (result != NULL); +} + +static void +mail_junk_hook_report_junk (CamelJunkPlugin *junk_plugin, + CamelMimeMessage *mime_message) +{ + EMJunkTarget target = { mime_message, NULL }; + EMJunkInterface *interface; + + interface = (EMJunkInterface *) junk_plugin; + + if (!interface->hook->plugin->enabled) + return; + + e_plugin_invoke ( + interface->hook->plugin, + interface->report_junk, &target); + + if (target.error != NULL) + mail_junk_hook_error ("mail:junk-report-error", target.error); +} + +static void +mail_junk_hook_report_notjunk (CamelJunkPlugin *junk_plugin, + CamelMimeMessage *mime_message) +{ + EMJunkTarget target = { mime_message, NULL }; + EMJunkInterface *interface; + + interface = (EMJunkInterface *) junk_plugin; + + if (!interface->hook->plugin->enabled) + return; + + e_plugin_invoke ( + interface->hook->plugin, + interface->report_notjunk, &target); + + if (target.error != NULL) + mail_junk_hook_error ( + "mail:junk-not-report-error", target.error); +} + +static void +mail_junk_hook_commit_reports (CamelJunkPlugin *junk_plugin) +{ + EMJunkInterface *interface; + + interface = (EMJunkInterface *) junk_plugin; + + if (!interface->hook->plugin->enabled) + return; + + e_plugin_invoke ( + interface->hook->plugin, + interface->commit_reports, NULL); +} + +static void +mail_junk_hook_finalize (GObject *object) +{ + EMailJunkHookPrivate *priv; + + priv = E_MAIL_JUNK_HOOK_GET_PRIVATE (object); + + g_free (priv->interface.check_junk); + g_free (priv->interface.report_junk); + g_free (priv->interface.report_notjunk); + g_free (priv->interface.commit_reports); + g_free (priv->interface.validate_binary); + g_free (priv->interface.plugin_name); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static gint +mail_junk_hook_construct (EPluginHook *hook, + EPlugin *plugin, + xmlNodePtr node) +{ + EMailJunkHookPrivate *priv; + gchar *property; + + priv = E_MAIL_JUNK_HOOK_GET_PRIVATE (hook); + + /* Chain up to parent's construct() method. */ + if (E_PLUGIN_HOOK_CLASS (parent_class)->construct (hook, plugin, node) == -1) + return -1; + + if (!plugin->enabled) + return -1; + + node = xmlFirstElementChild (node); + + if (node == NULL) + return -1; + + if (g_strcmp0 ((gchar *) node->name, "interface") != 0) + return -1; + + property = e_plugin_xml_prop (node, "check_junk"); + priv->interface.check_junk = property; + + property = e_plugin_xml_prop (node, "report_junk"); + priv->interface.report_junk = property; + + property = e_plugin_xml_prop (node, "report_non_junk"); + priv->interface.report_notjunk = property; + + property = e_plugin_xml_prop (node, "commit_reports"); + priv->interface.commit_reports = property; + + property = e_plugin_xml_prop (node, "validate_binary"); + priv->interface.validate_binary = property; + + property = e_plugin_xml_prop (node, "name"); + priv->interface.plugin_name = property; + + if (priv->interface.check_junk == NULL) + return -1; + + if (priv->interface.report_junk == NULL) + return -1; + + if (priv->interface.report_notjunk == NULL) + return -1; + + if (priv->interface.commit_reports == NULL) + return -1; + + mail_session_add_junk_plugin ( + priv->interface.plugin_name, &priv->interface.camel); + + return 0; +} + +static void +mail_junk_hook_class_init (EMailJunkHookClass *class) +{ + GObjectClass *object_class; + EPluginHookClass *plugin_hook_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMailJunkHookPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->finalize = mail_junk_hook_finalize; + + plugin_hook_class = E_PLUGIN_HOOK_CLASS (class); + plugin_hook_class->construct = mail_junk_hook_construct; + plugin_hook_class->id = "org.gnome.evolution.mail.junk:1.0"; +} + +static void +mail_junk_hook_init (EMailJunkHook *mail_junk_hook) +{ + EMJunkInterface *interface; + + mail_junk_hook->priv = E_MAIL_JUNK_HOOK_GET_PRIVATE (mail_junk_hook); + + interface = &mail_junk_hook->priv->interface; + interface->camel.get_name = mail_junk_hook_get_name; + interface->camel.api_version = 1; + interface->camel.check_junk = mail_junk_hook_check_junk; + interface->camel.report_junk = mail_junk_hook_report_junk; + interface->camel.report_notjunk = mail_junk_hook_report_notjunk; + interface->camel.commit_reports = mail_junk_hook_commit_reports; + interface->camel.init = mail_junk_hook_plugin_init; + interface->hook = E_PLUGIN_HOOK (mail_junk_hook); +} + +GType +e_mail_junk_hook_get_type (void) +{ + return mail_junk_hook_type; +} + +void +e_mail_junk_hook_register_type (GTypeModule *type_module) +{ + const GTypeInfo type_info = { + sizeof (EMailJunkHookClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_junk_hook_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailJunkHook), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_junk_hook_init, + NULL /* value_table */ + }; + + mail_junk_hook_type = g_type_module_register_type ( + type_module, E_TYPE_PLUGIN_HOOK, + "EMailJunkHook", &type_info, 0); +} diff --git a/modules/mail/e-mail-junk-hook.h b/modules/mail/e-mail-junk-hook.h new file mode 100644 index 0000000000..f5882e66b3 --- /dev/null +++ b/modules/mail/e-mail-junk-hook.h @@ -0,0 +1,66 @@ +/* + * e-mail-junk-hook.h + * + * 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/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_JUNK_HOOK_H +#define E_MAIL_JUNK_HOOK_H + +#include <e-util/e-plugin.h> + +/* Standard GObject macros */ +#define E_TYPE_MAIL_JUNK_HOOK \ + (e_mail_junk_hook_get_type ()) +#define E_MAIL_JUNK_HOOK(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_JUNK_HOOK, EMailJunkHook)) +#define E_MAIL_JUNK_HOOK_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_JUNK_HOOK, EMailJunkHookClass)) +#define E_IS_MAIL_JUNK_HOOK(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_JUNK_HOOK)) +#define E_IS_MAIL_JUNK_HOOK_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MAIL_JUNK_HOOK)) +#define E_MAIL_JUNK_HOOK_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MAIL_JUNK_HOOK, EMailJunkHookClass)) + +G_BEGIN_DECLS + +typedef struct _EMailJunkHook EMailJunkHook; +typedef struct _EMailJunkHookClass EMailJunkHookClass; +typedef struct _EMailJunkHookPrivate EMailJunkHookPrivate; + +struct _EMailJunkHook { + EPluginHook parent; + EMailJunkHookPrivate *priv; +}; + +struct _EMailJunkHookClass { + EPluginHookClass parent_class; +}; + +GType e_mail_junk_hook_get_type (void); +void e_mail_junk_hook_register_type (GTypeModule *type_module); + +G_END_DECLS + +#endif /* E_MAIL_JUNK_HOOK_H */ diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 2d6e1a9779..fd1e7263c4 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -42,7 +42,6 @@ #include "e-mail-shell-sidebar.h" #include "e-mail-shell-view.h" -#include "e-attachment-handler-mail.h" #include "e-mail-browser.h" #include "e-mail-local.h" #include "e-mail-reader.h" @@ -51,12 +50,9 @@ #include "em-account-prefs.h" #include "em-composer-prefs.h" #include "em-composer-utils.h" -#include "em-config.h" -#include "em-event.h" #include "em-folder-utils.h" #include "em-format-hook.h" #include "em-format-html-display.h" -#include "em-junk-hook.h" #include "em-mailer-prefs.h" #include "em-network-prefs.h" #include "em-utils.h" @@ -85,22 +81,6 @@ static GType mail_shell_backend_type; extern gint camel_application_is_exiting; static void -mail_shell_backend_init_hooks (void) -{ - e_plugin_hook_register_type (em_config_hook_get_type ()); - e_plugin_hook_register_type (em_event_hook_get_type ()); - e_plugin_hook_register_type (em_junk_hook_get_type ()); - - /* EMFormat classes must be registered before EMFormatHook. */ - em_format_hook_register_type (em_format_get_type ()); - em_format_hook_register_type (em_format_html_get_type ()); - em_format_hook_register_type (em_format_html_display_get_type ()); - e_plugin_hook_register_type (em_format_hook_get_type ()); - - em_junk_hook_register_type (emj_get_type ()); -} - -static void mail_shell_backend_init_importers (void) { EImportClass *import_class; @@ -812,10 +792,15 @@ mail_shell_backend_constructed (GObject *object) /* This also initializes Camel, so it needs to happen early. */ mail_session_init (shell_backend); - mail_shell_backend_init_hooks (); - mail_shell_backend_init_importers (); + /* Register format types for EMFormatHook. */ + em_format_hook_register_type (em_format_get_type ()); + em_format_hook_register_type (em_format_html_get_type ()); + em_format_hook_register_type (em_format_html_display_get_type ()); + + /* Register plugin hook types. */ + em_format_hook_get_type (); - e_attachment_handler_mail_get_type (); + mail_shell_backend_init_importers (); g_signal_connect ( shell, "notify::online", diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c index e2c956e0ff..621dae4ce5 100644 --- a/modules/mail/em-mailer-prefs.c +++ b/modules/mail/em-mailer-prefs.c @@ -47,7 +47,7 @@ #include "e-mail-label-manager.h" #include "mail-config.h" -#include "em-junk-hook.h" +#include "em-junk.h" #include "em-config.h" #include "mail-session.h" @@ -710,17 +710,17 @@ junk_plugin_changed (GtkWidget *combo, EMMailerPrefs *prefs) gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/junk/default_plugin", def_plugin, NULL); while (plugins) { - struct _EMJunkHookItem *item = plugins->data;; + EMJunkInterface *iface = plugins->data; - if (item->plugin_name && def_plugin && !strcmp (item->plugin_name, def_plugin)) { + if (iface->plugin_name && def_plugin && !strcmp (iface->plugin_name, def_plugin)) { gboolean status; - session->junk_plugin = CAMEL_JUNK_PLUGIN (&(item->csp)); - status = e_plugin_invoke (item->hook->hook.plugin, item->validate_binary, NULL) != NULL; + session->junk_plugin = CAMEL_JUNK_PLUGIN (&iface->camel); + status = e_plugin_invoke (iface->hook->plugin, iface->validate_binary, NULL) != NULL; if ((gboolean)status == TRUE) { gchar *text, *html; gtk_image_set_from_stock (prefs->plugin_image, "gtk-dialog-info", GTK_ICON_SIZE_MENU); - text = g_strdup_printf (_("%s plugin is available and the binary is installed."), item->plugin_name); + text = g_strdup_printf (_("%s plugin is available and the binary is installed."), iface->plugin_name); html = g_strdup_printf ("<i>%s</i>", text); gtk_label_set_markup (prefs->plugin_status, html); g_free (html); @@ -728,7 +728,7 @@ junk_plugin_changed (GtkWidget *combo, EMMailerPrefs *prefs) } else { gchar *text, *html; gtk_image_set_from_stock (prefs->plugin_image, "gtk-dialog-warning", GTK_ICON_SIZE_MENU); - text = g_strdup_printf (_("%s plugin is not available. Please check whether the package is installed."), item->plugin_name); + text = g_strdup_printf (_("%s plugin is not available. Please check whether the package is installed."), iface->plugin_name); html = g_strdup_printf ("<i>%s</i>", text); gtk_label_set_markup (prefs->plugin_status, html); g_free (html); @@ -761,20 +761,20 @@ junk_plugin_setup (GtkWidget *combo, EMMailerPrefs *prefs) } while (plugins) { - struct _EMJunkHookItem *item = plugins->data;; + EMJunkInterface *iface = plugins->data; - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), item->plugin_name); - if (!def_set && pdefault && item->plugin_name && !strcmp(pdefault, item->plugin_name)) { + gtk_combo_box_append_text (GTK_COMBO_BOX (combo), iface->plugin_name); + if (!def_set && pdefault && iface->plugin_name && !strcmp(pdefault, iface->plugin_name)) { gboolean status; def_set = TRUE; gtk_combo_box_set_active (GTK_COMBO_BOX (combo), index); - status = e_plugin_invoke (item->hook->hook.plugin, item->validate_binary, NULL) != NULL; + status = e_plugin_invoke (iface->hook->plugin, iface->validate_binary, NULL) != NULL; if (status) { gchar *text, *html; gtk_image_set_from_stock (prefs->plugin_image, "gtk-dialog-info", GTK_ICON_SIZE_MENU); /* May be a better text */ - text = g_strdup_printf (_("%s plugin is available and the binary is installed."), item->plugin_name); + text = g_strdup_printf (_("%s plugin is available and the binary is installed."), iface->plugin_name); html = g_strdup_printf ("<i>%s</i>", text); gtk_label_set_markup (prefs->plugin_status, html); g_free (html); @@ -783,7 +783,7 @@ junk_plugin_setup (GtkWidget *combo, EMMailerPrefs *prefs) gchar *text, *html; gtk_image_set_from_stock (prefs->plugin_image, "gtk-dialog-warning", GTK_ICON_SIZE_MENU); /* May be a better text */ - text = g_strdup_printf (_("%s plugin is not available. Please check whether the package is installed."), item->plugin_name); + text = g_strdup_printf (_("%s plugin is not available. Please check whether the package is installed."), iface->plugin_name); html = g_strdup_printf ("<i>%s</i>", text); gtk_label_set_markup (prefs->plugin_status, html); g_free (html); diff --git a/modules/mail/evolution-module-mail.c b/modules/mail/evolution-module-mail.c index 97bc953c41..1bb58c7742 100644 --- a/modules/mail/evolution-module-mail.c +++ b/modules/mail/evolution-module-mail.c @@ -19,6 +19,12 @@ * */ +#include "e-mail-attachment-handler.h" + +#include "e-mail-config-hook.h" +#include "e-mail-event-hook.h" +#include "e-mail-junk-hook.h" + #include "e-mail-shell-backend.h" #include "e-mail-shell-content.h" #include "e-mail-shell-sidebar.h" @@ -34,6 +40,12 @@ e_module_load (GTypeModule *type_module) { /* Register dynamically loaded types. */ + e_mail_attachment_handler_register_type (type_module); + + e_mail_config_hook_register_type (type_module); + e_mail_event_hook_register_type (type_module); + e_mail_junk_hook_register_type (type_module); + e_mail_shell_backend_register_type (type_module); e_mail_shell_content_register_type (type_module); e_mail_shell_sidebar_register_type (type_module); |