From 1e8c2df476794bcb93962ec65ccbe5e1e8e33f66 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Tue, 3 Apr 2007 09:14:16 +0000 Subject: Add pluggable junk filter code and move SA options to the plugins. svn path=/trunk/; revision=33367 --- mail/ChangeLog | 27 ++++ mail/em-folder-browser.c | 2 +- mail/em-folder-view.c | 2 +- mail/em-junk-hook.c | 13 +- mail/em-junk-hook.h | 2 + mail/em-mailer-prefs.c | 162 +++++++++++++++++++- mail/em-mailer-prefs.h | 6 + mail/evolution-mail.schemas.in.in | 58 ++++++++ mail/mail-component.c | 30 ++++ mail/mail-config.glade | 300 ++++++++++++++++---------------------- mail/mail-session.c | 30 ++++ mail/mail-session.h | 4 + 12 files changed, 446 insertions(+), 190 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index b3cfbc2d1b..edc0006f28 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,30 @@ +2007-04-03 Srinivasa Ragavan + + Reworked the SPAM plugins with more UI options and support for + multiple plugins. + + * em-folder-view.c: + * em-junk-hook.c: (emjh_construct_item), (emjh_construct): + * em-junk-hook.h: + * em-mailer-prefs.c: (junk_days_activate), (emmp_empty_junk_init), + (junk_plugin_changed), (junk_plugin_setup), + (create_combo_text_widget), (em_mailer_prefs_construct): + * em-mailer-prefs.h: + * evolution-mail.schemas.in.in: + * mail-component.c: (impl_createView), (mc_quit_delete), + (impl_quit): + * mail-config.glade: + * mail-session.c: (init), (mail_session_add_junk_plugin), + (mail_session_get_junk_plugins): + * mail-session.h: + +2007-04-03 Srinivasa Ragavan + + ** Fix for bug #411331 + + * em-folder-browser.c: (emfb_gui_folder_changed): Fix the message + selection. + 2007-04-03 Matthew Barnes * evolution-mail.schemas.in.in: diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c index 267341c7fc..e24cb2e3a0 100644 --- a/mail/em-folder-browser.c +++ b/mail/em-folder-browser.c @@ -1709,7 +1709,7 @@ emfb_gui_folder_changed(CamelFolder *folder, void *dummy, EMFolderBrowser *emfb) mi = camel_folder_get_message_info(emfb->view.folder, emfb->priv->select_uid); if (mi) { camel_folder_free_message_info(emfb->view.folder, mi); - em_folder_view_set_message(&emfb->view, emfb->priv->select_uid, TRUE); + em_folder_view_set_message(&emfb->view, emfb->priv->select_uid, FALSE); g_free (emfb->priv->select_uid); emfb->priv->select_uid = NULL; } diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 7246895f99..0ec83e1df0 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -1882,7 +1882,7 @@ static const EMFolderViewEnable emfv_enable_map[] = { { "MessageMarkAsImportant", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_IMPORTANT }, { "MessageMarkAsUnimportant", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_UNIMPORTANT }, { "MessageMarkAsJunk", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_JUNK }, - { "MessageMarkAsNotJunk", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_NOT_JUNK }, + { "MessageMarkAsNotJunk", EM_POPUP_SELECT_MANY }, { "MessageFollowUpFlag", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_FLAG_FOLLOWUP }, { "MessageFollowUpComplete", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_FLAG_COMPLETED }, { "MessageFollowUpClear", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_FLAG_CLEAR }, diff --git a/mail/em-junk-hook.c b/mail/em-junk-hook.c index b02bc4cb59..52fa280588 100644 --- a/mail/em-junk-hook.c +++ b/mail/em-junk-hook.c @@ -187,13 +187,16 @@ emjh_construct_item(EPluginHook *eph, EMJunkHookGroup *group, xmlNodePtr root) item->report_junk = e_plugin_xml_prop(root, "report_junk"); item->report_non_junk = e_plugin_xml_prop(root, "report_non_junk"); item->commit_reports = e_plugin_xml_prop(root, "commit_reports"); + item->validate_binary = e_plugin_xml_prop(root, "validate_binary"); + + item->plugin_name = e_plugin_xml_prop(root, "name"); item->hook = emjh; if (item->check_junk == NULL || item->report_junk == NULL || item->report_non_junk == NULL || item->commit_reports == NULL) goto error; - /* assign the plugin to the session*/ - session->junk_plugin = CAMEL_JUNK_PLUGIN (&(item->csp)); + /* Add the plugin to the session plugin list*/ + mail_session_add_junk_plugin (item->plugin_name, CAMEL_JUNK_PLUGIN (&(item->csp))); return item; error: @@ -242,15 +245,14 @@ static int emjh_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) { xmlNodePtr node; - static gboolean loaded = FALSE; d(printf("loading junk hook\n")); if (((EPluginHookClass *)emjh_parent_class)->construct(eph, ep, root) == -1) return -1; - if (!ep->enabled || loaded) { - g_warning ("ignored this junk plugin: not enabled or we have already loaded one"); + if (!ep->enabled) { + g_warning ("ignored this junk plugin: not enabled"); return -1; } @@ -268,7 +270,6 @@ emjh_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) } eph->plugin = ep; - loaded = TRUE; return 0; } diff --git a/mail/em-junk-hook.h b/mail/em-junk-hook.h index 378277b3f9..df043fc1d6 100644 --- a/mail/em-junk-hook.h +++ b/mail/em-junk-hook.h @@ -54,6 +54,8 @@ struct _EMJunkHookItem { char *report_junk; char *report_non_junk; char *commit_reports; + char *validate_binary; + char *plugin_name; }; struct _EMJunkHookGroup { diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index 064ef1256a..d724223e88 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -57,12 +57,16 @@ #include "e-util/e-util-private.h" #include "mail-config.h" +#include "em-junk-hook.h" #include "em-config.h" +#include "mail-session.h" static void em_mailer_prefs_class_init (EMMailerPrefsClass *class); static void em_mailer_prefs_init (EMMailerPrefs *dialog); static void em_mailer_prefs_finalise (GObject *obj); +GtkWidget * create_combo_text_widget (); + static GtkVBoxClass *parent_class = NULL; enum { @@ -631,6 +635,47 @@ emmp_empty_trash_init (EMMailerPrefs *prefs) gtk_widget_set_sensitive ((GtkWidget *) prefs->empty_trash_days, !locked); } +static void +junk_days_activate (GtkWidget *item, EMMailerPrefs *prefs) +{ + int days; + + days = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "days")); + gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/junk/empty_on_exit_days", days, NULL); +} + +static void +emmp_empty_junk_init (EMMailerPrefs *prefs) +{ + int locked, days, hist = 0, i; + GtkWidget *menu, *item; + + toggle_button_init (prefs, prefs->empty_junk, FALSE, + "/apps/evolution/mail/junk/empty_on_exit", + G_CALLBACK (toggle_button_toggled)); + + days = gconf_client_get_int(prefs->gconf, "/apps/evolution/mail/junk/empty_on_exit_days", NULL); + menu = gtk_menu_new(); + for (i = 0; i < G_N_ELEMENTS (empty_trash_frequency); i++) { + if (days >= empty_trash_frequency[i].days) + hist = i; + + item = gtk_menu_item_new_with_label (_(empty_trash_frequency[i].label)); + g_object_set_data ((GObject *) item, "days", GINT_TO_POINTER (empty_trash_frequency[i].days)); + g_signal_connect (item, "activate", G_CALLBACK (junk_days_activate), prefs); + + gtk_widget_show (item); + gtk_menu_shell_append((GtkMenuShell *)menu, item); + } + + gtk_widget_show(menu); + gtk_option_menu_set_menu((GtkOptionMenu *)prefs->empty_junk_days, menu); + gtk_option_menu_set_history((GtkOptionMenu *)prefs->empty_junk_days, hist); + + locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/junk/empty_on_exit_days", NULL); + gtk_widget_set_sensitive ((GtkWidget *) prefs->empty_junk_days, !locked); +} + static void http_images_changed (GtkWidget *widget, EMMailerPrefs *prefs) { @@ -646,6 +691,7 @@ http_images_changed (GtkWidget *widget, EMMailerPrefs *prefs) gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/load_http_images", when, NULL); } + static void notify_type_changed (GtkWidget *widget, EMMailerPrefs *prefs) { @@ -712,6 +758,106 @@ emmp_free(EConfig *ec, GSList *items, void *data) g_slist_free(items); } +static void +junk_plugin_changed (GtkWidget *combo, EMMailerPrefs *prefs) +{ + char *def_plugin = gtk_combo_box_get_active_text(combo); + const GList *plugins = mail_session_get_junk_plugins(); + + gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/junk/default_plugin", def_plugin, NULL); + while (plugins) { + struct _EMJunkHookItem *item = plugins->data;; + + if (item->plugin_name && def_plugin && !strcmp (item->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); + if (status) { + char *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); + html = g_strdup_printf ("%s", text); + gtk_label_set_markup (prefs->plugin_status, html); + g_free (html); + g_free (text); + } else { + char *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); + html = g_strdup_printf ("%s", text); + gtk_label_set_markup (prefs->plugin_status, html); + g_free (html); + g_free (text); + } + break; + } + plugins = plugins->next; + } +} + +static void +junk_plugin_setup (GtkWidget *combo, EMMailerPrefs *prefs) +{ + int index = 0; + gboolean def_set = FALSE; + const GList *plugins = mail_session_get_junk_plugins(); + char *pdefault = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/junk/default_plugin", NULL); + + if (!plugins || !g_list_length (plugins)) { + gtk_combo_box_append_text (combo, _("No Junk plugin available")); + gtk_combo_box_set_active (combo, 0); + gtk_widget_set_sensitive ((GtkWidget *) combo, FALSE); + gtk_widget_hide (prefs->plugin_image); + gtk_widget_hide (prefs->plugin_status); + gtk_image_set_from_stock (prefs->plugin_image, NULL, 0); + g_free (pdefault); + + return; + } + + while (plugins) { + struct _EMJunkHookItem *item = plugins->data;; + + gtk_combo_box_append_text (combo, item->plugin_name); + if (!def_set && pdefault && item->plugin_name && !strcmp(pdefault, item->plugin_name)) { + gboolean status; + + def_set = TRUE; + gtk_combo_box_set_active (combo, index); + status = e_plugin_invoke(item->hook->hook.plugin, item->validate_binary, NULL); + if (status) { + char *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); + html = g_strdup_printf ("%s", text); + gtk_label_set_markup (prefs->plugin_status, html); + g_free (html); + g_free (text); + } else { + char *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); + html = g_strdup_printf ("%s", text); + gtk_label_set_markup (prefs->plugin_status, html); + g_free (html); + g_free (text); + } + } + plugins = plugins->next; + index++; + } + + g_signal_connect (combo, "changed", G_CALLBACK(junk_plugin_changed), prefs); + g_free (pdefault); +} + +GtkWidget * +create_combo_text_widget () { + return gtk_combo_box_new_text (); +} + static void em_mailer_prefs_construct (EMMailerPrefs *prefs) { @@ -729,7 +875,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) EMConfigTargetPrefs *target; GSList *l; char *gladefile; - + gladefile = g_build_filename (EVOLUTION_GLADEDIR, "mail-config.glade", NULL); @@ -1048,12 +1194,16 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) toggle_button_init (prefs, prefs->check_incoming, FALSE, "/apps/evolution/mail/junk/check_incoming", G_CALLBACK (toggle_button_toggled)); - - prefs->sa_local_tests_only = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkSALocalTestsOnly")); - toggle_button_init (prefs, prefs->sa_local_tests_only, TRUE, - "/apps/evolution/mail/junk/sa/local_only", - G_CALLBACK (toggle_button_toggled_not)); + prefs->empty_junk = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "junk_empty_check")); + prefs->empty_junk_days = GTK_OPTION_MENU (glade_xml_get_widget (gui, "junk_empty_combo")); + emmp_empty_junk_init (prefs); + + prefs->default_junk_plugin = GTK_COMBO_BOX (glade_xml_get_widget (gui, "default_junk_plugin")); + prefs->plugin_status = GTK_LABEL (glade_xml_get_widget (gui, "plugin_status")); + prefs->plugin_image = GTK_IMAGE (glade_xml_get_widget (gui, "plugin_image")); + junk_plugin_setup (prefs->default_junk_plugin, prefs); + /* get our toplevel widget */ target = em_config_target_new_prefs(ec, prefs->gconf); e_config_set_target((EConfig *)ec, (EConfigTarget *)target); diff --git a/mail/em-mailer-prefs.h b/mail/em-mailer-prefs.h index 9a8222a3ba..f6adc4593e 100644 --- a/mail/em-mailer-prefs.h +++ b/mail/em-mailer-prefs.h @@ -122,8 +122,14 @@ struct _EMMailerPrefs { /* Junk prefs */ struct _GtkToggleButton *check_incoming; + struct _GtkToggleButton *empty_junk; + struct _GtkOptionMenu *empty_junk_days; + struct _GtkToggleButton *sa_local_tests_only; struct _GtkToggleButton *sa_use_daemon; + struct _GtkComboBox *default_junk_plugin; + struct _GtkLabel *plugin_status; + struct _GtkImage *plugin_image; }; struct _EMMailerPrefsClass { diff --git a/mail/evolution-mail.schemas.in.in b/mail/evolution-mail.schemas.in.in index 1fbbd9b25f..e2f7d41abb 100644 --- a/mail/evolution-mail.schemas.in.in +++ b/mail/evolution-mail.schemas.in.in @@ -869,6 +869,64 @@ + + /schemas/apps/evolution/mail/junk/empty_on_exit + /apps/evolution/mail/junk/empty_on_exit + evolution-mail + bool + false + + Empty Junk folders on exit + + Empty all Junk folders when exiting Evolution. + + + + + + /schemas/apps/evolution/mail/junk/empty_on_exit_days + /apps/evolution/mail/junk/empty_on_exit_days + evolution-mail + int + 0 + + Minimum days between emptying the junk on exit + + Minimum time between emptying the junk on exit, in days. + + + + + + /schemas/apps/evolution/mail/junk/empty_date + /apps/evolution/mail/junk/empty_date + evolution-mail + int + 0 + + Last time empty junk was run + + The last time empty junk was run, in days since the epoch. + + + + + + /schemas/apps/evolution/mail/junk/default_plugin + /apps/evolution/mail/junk/default_plugin + evolution-mail + string + Spamassasin + + The default plugin for Junk hook + + This is the default junk plugin, even though there are multiple plugins + enabled. If the default listed plugin is disabled, then it wont fall back + to the other available plugins. + + + + /schemas/apps/evolution/mail/junk/sa/local_only /apps/evolution/mail/junk/sa/local_only diff --git a/mail/mail-component.c b/mail/mail-component.c index efeb17dab3..c91096eec0 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -702,6 +702,7 @@ impl_createView (PortableServer_Servant servant, if ((uri = em_folder_tree_model_get_selected (priv->model))) { em_folder_tree_set_selected ((EMFolderTree *) tree_widget, uri); + em_folder_view_set_folder_uri (view_widget, uri); g_free (uri); } @@ -784,6 +785,24 @@ mc_quit_sync(CamelStore *store, struct _store_info *si, MailComponent *mc) mail_sync_store(store, mc->priv->quit_expunge, mc_quit_sync_done, mc); } +static void +mc_quit_delete (CamelStore *store, struct _store_info *si, MailComponent *mc) +{ + CamelFolder *folder = camel_store_get_junk (store, NULL); + + if (folder) { + GPtrArray *uids; + int i; + + uids = camel_folder_get_uids (folder); + camel_folder_freeze(folder); + for (i=0;ilen;i++) + camel_folder_set_message_flags(folder, uids->pdata[i], CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN); + camel_folder_thaw(folder); + camel_folder_free_uids (folder, uids); + } +} + static CORBA_boolean impl_quit(PortableServer_Servant servant, CORBA_Environment *ev) { @@ -793,6 +812,8 @@ impl_quit(PortableServer_Servant servant, CORBA_Environment *ev) switch (mc->priv->quit_state) { case MC_QUIT_START: { int now = time(NULL)/60/60/24, days; + gboolean empty_junk; + GConfClient *gconf = mail_config_get_gconf_client(); mail_vfolder_shutdown(); @@ -801,6 +822,15 @@ impl_quit(PortableServer_Servant servant, CORBA_Environment *ev) && ((days = gconf_client_get_int(gconf, "/apps/evolution/mail/trash/empty_on_exit_days", NULL)) == 0 || (days + gconf_client_get_int(gconf, "/apps/evolution/mail/trash/empty_date", NULL)) <= now); + empty_junk = gconf_client_get_bool(gconf, "/apps/evolution/mail/junk/empty_on_exit", NULL) + && ((days = gconf_client_get_int(gconf, "/apps/evolution/mail/junk/empty_on_exit_days", NULL)) == 0 + || (days + gconf_client_get_int(gconf, "/apps/evolution/mail/junk/empty_date", NULL)) <= now); + + if (empty_junk) { + g_hash_table_foreach(mc->priv->store_hash, (GHFunc)mc_quit_delete, mc); + gconf_client_set_int(gconf, "/apps/evolution/mail/junk/empty_date", now, NULL); + } + g_hash_table_foreach(mc->priv->store_hash, (GHFunc)mc_quit_sync, mc); if (mc->priv->quit_expunge) diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 6a1442b88b..2d94f86894 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -6569,13 +6569,13 @@ For example: "Work" or "Personal" 12 True False - 18 + 6 True False - 12 + 0 @@ -6603,47 +6603,26 @@ For example: "Work" or "Personal" - + + 12 True + 4 + 1 False - 0 + 3 + 0 - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - + True False - 0 + 6 - + True - - False + _Default junk plugin: + True False GTK_JUSTIFY_LEFT False @@ -6658,24 +6637,19 @@ For example: "Work" or "Personal" 0 - 0 + 6 False False - + True - Checks incoming mail messages to be Junk - True - Check in_coming mail for junk - True - GTK_RELIEF_NORMAL - True - False - False - True + create_combo_text_widget + 0 + 0 + Fri, 23 Mar 2007 09:28:55 GMT 0 @@ -6685,99 +6659,107 @@ For example: "Work" or "Personal" - 0 - True - True + 0 + 1 + 2 + 3 + fill - - - 0 - True - True - - - - - 0 - False - False - - - - - True - False - 12 - - - - True - <span weight="bold">Filter Options</span> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - False - 0 + + + True + Checks incoming mail messages to be Junk + True + Check in_coming mail for junk + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 0 + 1 + 4 + fill + + + - + True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + False + 3 + + + + True + 4 + gtk-dialog-info + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + - 0 - False - False + 0 + 1 + 3 + 4 + 15 + fill - + True False - 6 + 4 - + True True - I_nclude remote tests + Delete junk mails on e_xit True GTK_RELIEF_NORMAL True @@ -6793,60 +6775,10 @@ For example: "Work" or "Personal" - + True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - <small>This will make the the filter more reliable, but slower</small> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - + True + -1 0 @@ -6856,9 +6788,12 @@ For example: "Work" or "Personal" - 0 - False - False + 0 + 1 + 1 + 2 + 4 + fill @@ -6875,6 +6810,19 @@ For example: "Work" or "Personal" False + + + + True + False + 0 + + + 0 + False + False + + False diff --git a/mail/mail-session.c b/mail/mail-session.c index ee5febe99d..174df09224 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -68,6 +68,7 @@ typedef struct _MailSession { gboolean interactive; FILE *filter_logfile; + GList *junk_plugins; MailAsyncEvent *async; } MailSession; @@ -92,6 +93,7 @@ static void init (MailSession *session) { session->async = mail_async_event_new(); + session->junk_plugins = NULL; } static void @@ -712,3 +714,31 @@ mail_session_flush_filter_log (void) if (ms->filter_logfile) fflush (ms->filter_logfile); } + +void +mail_session_add_junk_plugin (const char *plugin_name, CamelJunkPlugin *junk_plugin) +{ + MailSession *ms = (MailSession *) session; + GConfClient *gconf; + char *def_plugin; + + gconf = mail_config_get_gconf_client (); + def_plugin = gconf_client_get_string (gconf, "/apps/evolution/mail/junk/default_plugin", NULL); + + ms->junk_plugins = g_list_append(ms->junk_plugins, junk_plugin); + if (def_plugin && plugin_name) { + if (!strcmp(def_plugin, plugin_name)) { + printf("Loading %s as the default junk plugin\n"); + session->junk_plugin = junk_plugin; + } + } + + g_free (def_plugin); +} + +const GList * +mail_session_get_junk_plugins () +{ + MailSession *ms = (MailSession *) session; + return ms->junk_plugins; +} diff --git a/mail/mail-session.h b/mail/mail-session.h index 2a7559964c..f49d4bb559 100644 --- a/mail/mail-session.h +++ b/mail/mail-session.h @@ -49,6 +49,10 @@ void mail_session_forget_password (const char *key); void mail_session_flush_filter_log (void); +void mail_session_add_junk_plugin (const char *plugin_name, CamelJunkPlugin *junk_plugin); + +const GList * mail_session_get_junk_plugins (); + extern CamelSession *session; #ifdef __cplusplus -- cgit v1.2.3