From 2c0ce47a992b68ccfe06d6b3da22da3aec07e872 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Thu, 24 Jan 2008 03:03:46 +0000 Subject: ** Fix for bug #510779 2008-01-24 Srinivasa Ragavan ** Fix for bug #510779 * em-mailer-prefs.c: (jh_tree_refill), (jh_add_cb), (jh_remove_cb), (init_junk_tree), (custom_junk_button_toggled), (em_mailer_prefs_construct): Added UI for the new junk preferences. * em-mailer-prefs.h: * evolution-mail.schemas.in: Add schema for junk header and address lookup. * mail-config.c: (gconf_jh_check_changed), (gconf_lookup_book_changed), (gconf_jh_headers_changed), (mail_config_init), (mail_config_reload_junk_headers), (mail_config_get_lookup_book): * mail-config.glade: * mail-config.h: * mail-session.c: (class_init), (lookup_addressbook), (mail_session_init), (mail_session_set_junk_headers): * mail-session.h: 2008-01-22 Srinivasa Ragavan ** Fix for bug #405777 * em-folder-view.c: (emfv_setup_view_instance), (emfv_setting_notify): Don't break abstraction. Call the right derived class. svn path=/trunk/; revision=34873 --- mail/ChangeLog | 28 ++++++ mail/em-folder-view.c | 7 +- mail/em-mailer-prefs.c | 190 +++++++++++++++++++++++++++++++++++++ mail/em-mailer-prefs.h | 10 +- mail/evolution-mail.schemas.in | 43 ++++++++- mail/mail-config.c | 97 +++++++++++++++++++ mail/mail-config.glade | 211 ++++++++++++++++++++++++++++++++++++++--- mail/mail-config.h | 3 + mail/mail-session.c | 31 +++++- mail/mail-session.h | 1 + 10 files changed, 602 insertions(+), 19 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 749497b5ed..6e604454e8 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,31 @@ +2008-01-24 Srinivasa Ragavan + + ** Fix for bug #510779 + + * em-mailer-prefs.c: (jh_tree_refill), (jh_add_cb), (jh_remove_cb), + (init_junk_tree), (custom_junk_button_toggled), + (em_mailer_prefs_construct): Added UI for the new junk preferences. + * em-mailer-prefs.h: + * evolution-mail.schemas.in: Add schema for junk header and address + lookup. + * mail-config.c: (gconf_jh_check_changed), + (gconf_lookup_book_changed), (gconf_jh_headers_changed), + (mail_config_init), (mail_config_reload_junk_headers), + (mail_config_get_lookup_book): + * mail-config.glade: + * mail-config.h: + * mail-session.c: (class_init), (lookup_addressbook), + (mail_session_init), (mail_session_set_junk_headers): + * mail-session.h: + +2008-01-22 Srinivasa Ragavan + + ** Fix for bug #405777 + + * em-folder-view.c: (emfv_setup_view_instance), + (emfv_setting_notify): Don't break abstraction. Call the right derived + class. + 2008-01-20 Srinivasa Ragavan * message-list.etspec: Revert the last cursor remove commit. It breaks diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 1ff388e504..e9f798ca2d 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -589,7 +589,7 @@ emfv_setup_view_instance(EMFolderView *emfv) { static GalViewCollection *collection = NULL; struct _EMFolderViewPrivate *p = emfv->priv; - gboolean outgoing, show_wide; + gboolean outgoing, show_wide=FALSE; char *id; g_return_if_fail (emfv->folder); @@ -647,7 +647,7 @@ emfv_setup_view_instance(EMFolderView *emfv) id = mail_config_folder_to_safe_url (emfv->folder); p->view_instance = gal_view_instance_new (collection, id); - show_wide = em_folder_browser_get_wide ((EMFolderBrowser *) emfv); + show_wide = emfv->list_active ? em_folder_browser_get_wide ((EMFolderBrowser *) emfv):FALSE; if (show_wide) { char *safe_id, *filename; @@ -3158,7 +3158,8 @@ emfv_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, EMFold if (camel_object_meta_set (emfv->folder, "evolution:show_preview", state_gconf ? "1" : "0")) camel_object_state_write (emfv->folder); - em_folder_browser_show_preview ((EMFolderBrowser *)emfv, state_gconf); + if (emfv->list_active) + em_folder_browser_show_preview ((EMFolderBrowser *)emfv, state_gconf); bonobo_ui_component_set_prop (emfv->uic, "/commands/ViewPreview", "state", state_gconf ? "1" : "0", NULL); break; } case EMFV_SHOW_DELETED: { diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index 85a2ce1e32..26a68d0fc2 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -197,6 +197,10 @@ enum { LABEL_LIST_COLUMN_NAME }; +enum { + JH_LIST_COLUMN_NAME, + JH_LIST_COLUMN_VALUE, +}; static void label_sensitive_buttons (EMMailerPrefs *prefs) { @@ -302,6 +306,156 @@ label_tree_refill (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpoint e_util_labels_free (labels); } + +static void +jh_tree_refill (EMMailerPrefs *prefs) +{ + GtkListStore *store = prefs->junk_header_list_store; + GSList *l, *cjh = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL); + + gtk_list_store_clear (store); + + for (l = cjh; l; l = l->next) { + GtkTreeIter iter; + char **tokens = g_strsplit (l->data, "=", 2); + + gtk_list_store_append (store, &iter); + gtk_list_store_set ( + store, &iter, + JH_LIST_COLUMN_NAME , tokens[0] ? tokens[0] : "", + JH_LIST_COLUMN_VALUE, tokens[1] ? tokens[1] : "" , + -1); + g_strfreev (tokens); + } + + g_slist_foreach (cjh, (GFunc) g_free, NULL); + g_slist_free (cjh); +} + +static void +jh_add_cb (GtkWidget *widget, gpointer user_data) +{ + EMMailerPrefs *prefs = (EMMailerPrefs *) user_data; + GtkWidget *dialog, *l1, *l2, *entry1, *entry2, *vbox, *hbox; + int response; + dialog = gtk_dialog_new_with_buttons (_("Add Custom Junk Header"), (GtkWindow *)gtk_widget_get_toplevel (widget), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); + + vbox = gtk_vbox_new (FALSE, 6); + hbox = gtk_hbox_new (FALSE, 0); + l1 = gtk_label_new_with_mnemonic (_("Header Name:")); + l2 = gtk_label_new_with_mnemonic (_("Header Value Contains:")); + entry1 = gtk_entry_new (); + entry2 = gtk_entry_new (); + gtk_box_pack_start ((GtkBox *) hbox, l1, FALSE, FALSE, 6); + gtk_box_pack_start ((GtkBox *)hbox, entry1, FALSE, FALSE, 6); + gtk_box_pack_start ((GtkBox *)vbox, hbox, FALSE, FALSE, 6); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start ((GtkBox *)hbox, l2, FALSE, FALSE, 6); + gtk_box_pack_start ((GtkBox *)hbox, entry2, FALSE, FALSE, 6); + gtk_box_pack_start ((GtkBox *)vbox, hbox, FALSE, FALSE, 6); + + gtk_widget_show_all (vbox); + gtk_container_add ((GtkContainer *)((GtkDialog *)dialog)->vbox, vbox); + response = gtk_dialog_run ((GtkDialog *)dialog); + if (response == GTK_RESPONSE_ACCEPT) { + const char *name = gtk_entry_get_text ((GtkEntry *)entry1); + const char *value = gtk_entry_get_text ((GtkEntry *)entry2); + char *tok; + GSList *list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL); + + //FIXME: Validate the values + + tok = g_strdup_printf ("%s=%s", name, value); + list = g_slist_append (list, tok); + gconf_client_set_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, list, NULL); + g_slist_foreach (list, (GFunc)g_free, NULL); + + g_slist_free (list); + } + gtk_widget_destroy (dialog); + jh_tree_refill (prefs); +} + +static void +jh_remove_cb (GtkWidget *widget, gpointer user_data) +{ + EMMailerPrefs *prefs = user_data; + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + + g_return_if_fail (prefs != NULL); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->junk_header_tree)); + if (gtk_tree_selection_get_selected (selection, &model, &iter)) { + char *name=NULL, *value=NULL; + GSList *prev = NULL, *node, *list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL); + gtk_tree_model_get (model, &iter, JH_LIST_COLUMN_NAME, &name, JH_LIST_COLUMN_VALUE, &value, -1); + node = list; + while (node) { + char *test; + int len = strlen (name); + test = strncmp (node->data, name, len) == 0 ? node->data+len:NULL; + + if (test) { + test++; + if (strcmp (test, value) == 0) + break; + } + + prev = node; + node = node->next; + } + + if (prev && !node) { + /* Not found. So what? */ + } else if (prev && node) { + prev->next = node->next; + g_free (node->data); + } else if (!prev && node) { + list = list->next; + g_free (node->data); + } + + gconf_client_set_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, list, NULL); + + g_slist_foreach (list, (GFunc)g_free, NULL); + g_slist_free (list); + g_free (name); + g_free (value); + + jh_tree_refill (prefs); + } +} + + +static GtkListStore * +init_junk_tree (GtkWidget *label_tree, EMMailerPrefs *prefs) +{ + GtkListStore *store; + GtkCellRenderer *renderer; + gint col; + + g_return_val_if_fail (label_tree != NULL, NULL); + g_return_val_if_fail (prefs != NULL, NULL); + + store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); + gtk_tree_view_set_model (GTK_TREE_VIEW (label_tree), GTK_TREE_MODEL (store)); + + renderer = gtk_cell_renderer_text_new (); + col = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (label_tree), -1, _("Header"), renderer, "text", JH_LIST_COLUMN_NAME, NULL); + g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL); + + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (label_tree), -1, _("Contains Value"), renderer, "text", JH_LIST_COLUMN_VALUE, NULL); + g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL); + + label_tree_refill (NULL, 0, NULL, prefs); + + return store; +} + static GtkListStore * init_label_tree (GtkWidget *label_tree, EMMailerPrefs *prefs, gboolean locked) { @@ -670,6 +824,23 @@ photo_toggle_changed (GtkToggleButton *toggle, EMMailerPrefs *prefs) gtk_widget_set_sensitive ((GtkWidget *) prefs->photo_local, FALSE); } +static void +custom_junk_button_toggled (GtkToggleButton *toggle, EMMailerPrefs *prefs) +{ + toggle_button_toggled (toggle, prefs); + if (gtk_toggle_button_get_active (toggle)) { + gtk_widget_set_sensitive ((GtkWidget *) prefs->junk_header_remove, TRUE); + gtk_widget_set_sensitive ((GtkWidget *) prefs->junk_header_add, TRUE); + gtk_widget_set_sensitive ((GtkWidget *) prefs->junk_header_tree, TRUE); + } else { + gtk_widget_set_sensitive ((GtkWidget *) prefs->junk_header_tree, FALSE); + gtk_widget_set_sensitive ((GtkWidget *) prefs->junk_header_add, FALSE); + gtk_widget_set_sensitive ((GtkWidget *) prefs->junk_header_remove, FALSE); + } + + +} + #if 0 // not used at the moment, commenting out static void @@ -1317,6 +1488,25 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) prefs->plugin_image = GTK_IMAGE (glade_xml_get_widget (gui, "plugin_image")); junk_plugin_setup (GTK_WIDGET (prefs->default_junk_plugin), prefs); + prefs->junk_header_check = (GtkToggleButton *)glade_xml_get_widget (gui, "junk_header_check"); + prefs->junk_header_tree = (GtkTreeView *)glade_xml_get_widget (gui, "junk_header_tree"); + prefs->junk_header_add = (GtkButton *)glade_xml_get_widget (gui, "junk_header_add"); + prefs->junk_header_remove = (GtkButton *)glade_xml_get_widget (gui, "junk_header_remove"); + prefs->junk_book_lookup = (GtkToggleButton *)glade_xml_get_widget (gui, "lookup_book"); + toggle_button_init (prefs, prefs->junk_book_lookup, FALSE, + "/apps/evolution/mail/junk/lookup_addressbook", + G_CALLBACK (toggle_button_toggled)); + + prefs->junk_header_list_store = init_junk_tree ((GtkWidget *)prefs->junk_header_tree, prefs); + toggle_button_init (prefs, prefs->junk_header_check, FALSE, + "/apps/evolution/mail/junk/check_custom_header", + G_CALLBACK (custom_junk_button_toggled)); + + custom_junk_button_toggled (prefs->junk_header_check, prefs); + jh_tree_refill (prefs); + g_signal_connect (G_OBJECT (prefs->junk_header_add), "clicked", G_CALLBACK (jh_add_cb), prefs); + g_signal_connect (G_OBJECT (prefs->junk_header_remove), "clicked", G_CALLBACK (jh_remove_cb), 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 16df0a93f4..007fcdf566 100644 --- a/mail/em-mailer-prefs.h +++ b/mail/em-mailer-prefs.h @@ -123,12 +123,20 @@ struct _EMMailerPrefs { 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 _GtkToggleButton *junk_header_check; + struct _GtkTreeView *junk_header_tree; + struct _GtkListStore *junk_header_list_store; + struct _GtkButton *junk_header_add; + struct _GtkButton *junk_header_remove; + struct _GtkToggleButton *junk_book_lookup; + }; struct _EMMailerPrefsClass { diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index ebe54e0e10..36a685b45b 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -969,7 +969,7 @@ int 0 - Level beyond which it should the message should be logged. + Level beyond which the message should be logged. This can have three possible values. 0 for errors. 1 for warnings. 2 for debug messages. @@ -1098,6 +1098,47 @@ + + /schemas/apps/evolution/mail/junk/lookup_addressbook + /apps/evolution/mail/junk/lookup_addressbook + evolution-mail + bool + false + + Determines whether to lookup in addressbook for sender email + + Determines whether to loopup the sender email in addressbook. If found, it shouldn't be a spam. It looks up in the books marked for autocompletion. It can be slow, if remote addressbooks (like ldap) are marked for autocompletion. + + + + + + /schemas/apps/evolution/mail/junk/check_custom_header + /apps/evolution/mail/junk/check_custom_header + evolution-mail + bool + true + + Determines whether to use custom headers to check for junk + + Determines whether to use custom headers to check for junk. If this option is enabled and the headers are mentioned, it will be improve the junk checking speed. + + + + + /schemas/apps/evolution/mail/junk/custom_header + /apps/evolution/mail/junk/custom_header + evolution-mail + list + string + [X-Spam-Flag=YES,X-Spam-Level=*****] + + Specifies the header to check for junk. + + Specifies the header to check for junk. The format is headername=value in gconf. + + + diff --git a/mail/mail-config.c b/mail/mail-config.c index 2a483750c8..90de0ec75b 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -111,6 +111,13 @@ typedef struct { GPtrArray *mime_types; guint mime_types_notify_id; + + GSList *jh_header; + gboolean jh_check; + guint jh_header_id; + guint jh_check_id; + gboolean book_lookup; + guint book_lookup_id; } MailConfig; static MailConfig *config = NULL; @@ -250,6 +257,59 @@ gconf_style_changed (GConfClient *client, guint cnxn_id, config_write_style (); } +static void +gconf_jh_check_changed (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer user_data) +{ + config->jh_check = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/junk/check_custom_header", NULL); + if (!config->jh_check) { + mail_session_set_junk_headers (NULL, NULL, 0); + } else { + config->jh_header = gconf_client_get_list (config->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL); + GSList *node = config->jh_header; + GPtrArray *name, *value; + name = g_ptr_array_new (); + value = g_ptr_array_new (); + while (node && node->data) { + char **tok = g_strsplit (node->data, "=", 2); + g_ptr_array_add (name, g_strdup(tok[0])); + g_ptr_array_add (value, g_strdup(tok[1])); + node = node->next; + g_strfreev (tok); + } + mail_session_set_junk_headers ((const char **)name->pdata, (const char **)value->pdata, name->len); + g_ptr_array_free (name, TRUE); + g_ptr_array_free (value, TRUE); + } +} + +static void +gconf_lookup_book_changed (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer data) +{ + config->book_lookup = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/junk/lookup_addressbook", NULL); +} + +static void +gconf_jh_headers_changed (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer user_data) +{ + config->jh_header = gconf_client_get_list (config->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL); + GSList *node = config->jh_header; + GPtrArray *name, *value; + name = g_ptr_array_new (); + value = g_ptr_array_new (); + while (node && node->data) { + char **tok = g_strsplit (node->data, "=", 2); + g_ptr_array_add (name, g_strdup(tok[0])); + g_ptr_array_add (value, g_strdup(tok[1])); + node = node->next; + g_strfreev (tok); + } + mail_session_set_junk_headers ((const char **)name->pdata, (const char **)value->pdata, name->len); +} + + static void gconf_address_count_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) @@ -329,6 +389,9 @@ mail_config_init (void) GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_add_dir (config->gconf, "/GNOME/Spell", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_add_dir (config->gconf, "/apps/evolution/mail/junk", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/fonts", gconf_style_changed, NULL, NULL, NULL); config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/address_compress", @@ -377,6 +440,18 @@ mail_config_init (void) config->magic_spacebar = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/magic_spacebar", NULL); config->accounts = e_account_list_new (config->gconf); config->signatures = e_signature_list_new (config->gconf); + + config->jh_check = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/junk/check_custom_header", NULL); + config->jh_check_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/junk/check_custom_header", + gconf_jh_check_changed, NULL, NULL, NULL); + config->jh_header_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/junk/custom_header", + gconf_jh_headers_changed, NULL, NULL, NULL); + config->book_lookup = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/junk/lookup_addressbook", NULL); + config->book_lookup_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/junk/lookup_addressbook", + gconf_lookup_book_changed, NULL, NULL, NULL); + + gconf_jh_check_changed (config->gconf, 0, NULL, config); + } @@ -1025,6 +1100,28 @@ mail_config_remove_signature (ESignature *signature) mail_config_save_signatures (); } +void +mail_config_reload_junk_headers () +{ + /* It automatically sets in the session */ + if (config == NULL) + mail_config_init (); + else + gconf_jh_check_changed (config->gconf, 0, NULL, config); + +} + +gboolean +mail_config_get_lookup_book() +{ + /* It automatically sets in the session */ + if (config == NULL) + mail_config_init (); + + return config->book_lookup; + +} + char * mail_config_signature_run_script (const char *script) { diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 2c054fd20d..20cba0d891 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -550,8 +550,8 @@ For example: "Work" or "Personal" * False - + @@ -633,8 +633,8 @@ For example: "Work" or "Personal" * False - + @@ -836,8 +836,8 @@ For example: "Work" or "Personal" * False - + @@ -890,8 +890,8 @@ For example: "Work" or "Personal" * False - + @@ -2804,7 +2804,7 @@ For example: "Work" or "Personal" True em_account_editor_folder_selector_button_new - Select Sent Folder + Select Sent Folder 0 0 Tue, 14 Dec 2004 17:07:09 GMT @@ -2823,7 +2823,7 @@ For example: "Work" or "Personal" True em_account_editor_folder_selector_button_new - Select Drafts Folder + Select Drafts Folder 0 0 Tue, 14 Dec 2004 17:07:02 GMT @@ -5268,6 +5268,7 @@ For example: "Work" or "Personal" True + True @@ -6477,7 +6478,7 @@ For example: "Work" or "Personal" 12 True - 4 + 8 1 False 3 @@ -6533,8 +6534,8 @@ For example: "Work" or "Personal" 0 1 - 2 - 3 + 6 + 7 fill @@ -6573,7 +6574,7 @@ For example: "Work" or "Personal" True 4 - gtk-dialog-info + gtk-info 0.5 0.5 0 @@ -6614,8 +6615,8 @@ For example: "Work" or "Personal" 0 1 - 3 - 4 + 7 + 8 15 fill @@ -6668,6 +6669,192 @@ For example: "Work" or "Personal" fill + + + + True + True + C_heck custom headers for junk + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 2 + 3 + 4 + fill + + + + + + + True + False + 6 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_SPREAD + 0 + + + + True + True + True + gtk-add + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + True + + + + + 0 + 1 + 3 + 4 + 22 + + + + + + True + True + Do _not mark messages as junk if sender is in my addressbook + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 4 + 5 + 4 + fill + + + + + + + True + False + 6 + + + + True + gtk-info + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + This option will be overridden if a match for custom junk headers is found. + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 0 + 1 + 5 + 6 + 23 + fill + + 0 diff --git a/mail/mail-config.h b/mail/mail-config.h index c08eaf34a4..8d9554969d 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -154,6 +154,9 @@ char *mail_config_folder_to_safe_url (struct _CamelFolder *folder); guint mail_config_get_error_timeout (void); guint mail_config_get_error_level (void); +void mail_config_reload_junk_headers (void); +gboolean mail_config_get_lookup_book(void); + GType evolution_mail_config_get_type (void); gboolean evolution_mail_config_factory_init (void); diff --git a/mail/mail-session.c b/mail/mail-session.c index 9ff70224ca..793796f330 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -86,6 +86,7 @@ static char *get_password(CamelSession *session, CamelService *service, const ch static void forget_password(CamelSession *session, CamelService *service, const char *domain, const char *item, CamelException *ex); static gboolean alert_user(CamelSession *session, CamelSessionAlertType type, const char *prompt, gboolean cancel); static CamelFilterDriver *get_filter_driver(CamelSession *session, const char *type, CamelException *ex); +static gboolean lookup_addressbook(CamelSession *session, const char *name); static void ms_thread_status(CamelSession *session, CamelSessionThreadMsg *msg, const char *text, int pc); static void *ms_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size); @@ -117,7 +118,7 @@ class_init (MailSessionClass *mail_session_class) camel_session_class->forget_password = forget_password; camel_session_class->alert_user = alert_user; camel_session_class->get_filter_driver = get_filter_driver; - + camel_session_class->lookup_addressbook = lookup_addressbook; camel_session_class->thread_msg_new = ms_thread_msg_new; camel_session_class->thread_msg_free = ms_thread_msg_free; camel_session_class->thread_status = ms_thread_status; @@ -376,6 +377,23 @@ static MailMsgInfo user_message_info = { (MailMsgFreeFunc) user_message_free }; +static gboolean +lookup_addressbook(CamelSession *session, const char *name) +{ + CamelInternetAddress *addr; + gboolean ret; + + if (!mail_config_get_lookup_book ()) + return FALSE; + + addr = camel_internet_address_new (); + camel_address_decode ((CamelAddress *)addr, name); + ret = em_utils_in_addressbook(addr); + camel_object_unref (addr); + + return ret; +} + static gboolean alert_user(CamelSession *session, CamelSessionAlertType type, const char *prompt, gboolean cancel) { @@ -679,7 +697,7 @@ mail_session_init (const char *base_directory) /* The shell will tell us to go online. */ camel_session_set_online ((CamelSession *) session, FALSE); - + mail_config_reload_junk_headers (); g_free (camel_dir); } @@ -760,3 +778,12 @@ mail_session_get_junk_plugins (void) MailSession *ms = (MailSession *) session; return ms->junk_plugins; } + +void +mail_session_set_junk_headers (const char **name, const char **value, int len) +{ + if (!session) + return; + + camel_session_set_junk_headers (session, name, value, len); +} diff --git a/mail/mail-session.h b/mail/mail-session.h index bb444b1c6a..e217d34ddd 100644 --- a/mail/mail-session.h +++ b/mail/mail-session.h @@ -52,6 +52,7 @@ 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 (void); +void mail_session_set_junk_headers (const char **name, const char **value, int len); extern CamelSession *session; -- cgit v1.2.3