diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 11 | ||||
-rw-r--r-- | mail/em-junk-hook.c | 44 | ||||
-rw-r--r-- | mail/em-junk-hook.h | 5 | ||||
-rw-r--r-- | mail/mail.error.xml | 13 |
4 files changed, 69 insertions, 4 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 62bda655cc..8e3a8ba172 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,14 @@ +2008-04-25 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #273041 + + * mail.error.xml: (junk-check-error), (junk-report-error), + (junk-not-report-error): New error messages added. + * em-junk-hook.h: (struct _EMJunkHookTarget), (em_junk_error_quark): + * em-junk-hook.c: (manage_error), (em_junk_check_junk), + (em_junk_report_junk), (em_junk_report_non_junk): + Allow propagation of the error from the plugin in the hook target. + 2008-04-23 Milan Crha <mcrha@redhat.com> * em-format-html-display.c: (efhd_update_bar): diff --git a/mail/em-junk-hook.c b/mail/em-junk-hook.c index ee4a6ed614..24341c960f 100644 --- a/mail/em-junk-hook.c +++ b/mail/em-junk-hook.c @@ -30,6 +30,8 @@ #include "em-junk-hook.h" #include "mail-session.h" #include <e-util/e-icon-factory.h> +#include "e-util/e-error.h" +#include "em-utils.h" #include <camel/camel-junk-plugin.h> #include <glib/gi18n.h> @@ -61,6 +63,15 @@ static const EPluginHookTargetKey emjh_flag_map[] = { </hook> */ + +static void manage_error (const char *msg, GError *error); + +GQuark +em_junk_error_quark (void) +{ + return g_quark_from_static_string ("em-junk-error-quark"); +} + static const char * em_junk_get_name (CamelJunkPlugin *csp); @@ -90,11 +101,17 @@ em_junk_check_junk(CamelJunkPlugin *csp, CamelMimeMessage *m) struct _EMJunkHookItem *item = (EMJunkHookItem *)csp; if (item->hook && item->hook->hook.plugin->enabled) { + gboolean res; EMJunkHookTarget target = { - m + m, + NULL }; - return e_plugin_invoke(item->hook->hook.plugin, item->check_junk, &target) != NULL; + res = e_plugin_invoke(item->hook->hook.plugin, item->check_junk, &target) != NULL; + + manage_error ("mail:junk-check-error", target.error); + + return res; } return FALSE; @@ -107,10 +124,13 @@ em_junk_report_junk(CamelJunkPlugin *csp, CamelMimeMessage *m) if (item->hook && item->hook->hook.plugin->enabled) { EMJunkHookTarget target = { - m + m, + NULL }; e_plugin_invoke(item->hook->hook.plugin, item->report_junk, &target); + + manage_error ("mail:junk-report-error", target.error); } } @@ -121,9 +141,11 @@ em_junk_report_non_junk(CamelJunkPlugin *csp, CamelMimeMessage *m) if (item->hook && item->hook->hook.plugin->enabled) { EMJunkHookTarget target = { - m + m, + NULL }; e_plugin_invoke(item->hook->hook.plugin, item->report_non_junk, &target); + manage_error ("mail:junk-not-report-error", target.error); } } @@ -279,6 +301,20 @@ emjh_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) return 0; } +static void +manage_error (const char *msg, GError *error) +{ + GtkWidget *w; + + if (!error) + return; + + w = e_error_new (NULL, msg, error->message, NULL); + em_utils_show_error_silent (w); + + g_error_free (error); +} + /*XXX: don't think we need here*/ static void emjh_enable(EPluginHook *eph, int state) diff --git a/mail/em-junk-hook.h b/mail/em-junk-hook.h index 952c0b914e..940607e323 100644 --- a/mail/em-junk-hook.h +++ b/mail/em-junk-hook.h @@ -43,8 +43,13 @@ typedef struct _EMJunkHookTarget EMJunkHookTarget; typedef void (*EMJunkHookFunc)(struct _EPlugin *plugin, EMJunkHookTarget *data); +GQuark em_junk_error_quark (void); + +#define EM_JUNK_ERROR em_junk_error_quark () + struct _EMJunkHookTarget { struct _CamelMimeMessage *m; + GError *error; }; struct _EMJunkHookItem { diff --git a/mail/mail.error.xml b/mail/mail.error.xml index e8ce35614d..9caf7158a6 100644 --- a/mail/mail.error.xml +++ b/mail/mail.error.xml @@ -411,6 +411,19 @@ You can choose to ignore this folder, overwrite or append its contents, or quit. <_secondary xml:space="preserve">You do not have sufficient permissions to delete this mail.</_secondary> </error> + <error id="junk-check-error" type="error"> + <_primary>Check Junk Failed</_primary> + <_secondary xml:space="preserve">{0}</_secondary> + </error> + + <error id="junk-report-error" type="error"> + <_primary>Report Junk Failed</_primary> + <_secondary xml:space="preserve">{0}</_secondary> + </error> + <error id="junk-not-report-error" type="error"> + <_primary>Report Not Junk Failed</_primary> + <_secondary xml:space="preserve">{0}</_secondary> + </error> </error-list> |