aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-04-23 17:29:11 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-04-23 17:29:11 +0800
commit71e5a4dcbb6308b5ea842e37d81ab0d5ff8b56b8 (patch)
tree2b20aee8c3343c30a43923c8abcff8ef55996cdd
parent9364fe50368e2c48b1987edd43c92c1ecd1cd8cd (diff)
downloadgsoc2013-evolution-71e5a4dcbb6308b5ea842e37d81ab0d5ff8b56b8.tar.gz
gsoc2013-evolution-71e5a4dcbb6308b5ea842e37d81ab0d5ff8b56b8.tar.zst
gsoc2013-evolution-71e5a4dcbb6308b5ea842e37d81ab0d5ff8b56b8.zip
** Fix for bug #529375
2008-04-23 Milan Crha <mcrha@redhat.com> ** Fix for bug #529375 * evolution-mail.schemas.in: * mail-config.glade: * em-utils.h: (em_utils_in_addressbook): * em-utils.c: (em_utils_in_addressbook): * em-format-html.c: (emfh_gethttp): * mail-session.c: (lookup_addressbook): * mail-config.h: (mail_config_get_lookup_book_local_only): * mail-config.c: (struct MailConfig), (mail_config_init), (mail_config_get_lookup_book_local_only): * em-mailer-prefs.h: (struct _EMMailerPrefs): * em-mailer-prefs.c: (junk_book_lookup_button_toggled), (em_mailer_prefs_construct): Add new option /apps/evolution/mail/junk/lookup_addressbook_local_only to determine whether check for address in a local address book only. svn path=/trunk/; revision=35410
-rw-r--r--mail/ChangeLog19
-rw-r--r--mail/em-format-html.c2
-rw-r--r--mail/em-mailer-prefs.c14
-rw-r--r--mail/em-mailer-prefs.h2
-rw-r--r--mail/em-utils.c5
-rw-r--r--mail/em-utils.h2
-rw-r--r--mail/evolution-mail.schemas.in14
-rw-r--r--mail/mail-config.c22
-rw-r--r--mail/mail-config.glade39
-rw-r--r--mail/mail-config.h3
-rw-r--r--mail/mail-session.c2
11 files changed, 108 insertions, 16 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index cdf1e4f05b..8eb4bea73c 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,24 @@
2008-04-23 Milan Crha <mcrha@redhat.com>
+ ** Fix for bug #529375
+
+ * evolution-mail.schemas.in:
+ * mail-config.glade:
+ * em-utils.h: (em_utils_in_addressbook):
+ * em-utils.c: (em_utils_in_addressbook):
+ * em-format-html.c: (emfh_gethttp):
+ * mail-session.c: (lookup_addressbook):
+ * mail-config.h: (mail_config_get_lookup_book_local_only):
+ * mail-config.c: (struct MailConfig), (mail_config_init),
+ (mail_config_get_lookup_book_local_only):
+ * em-mailer-prefs.h: (struct _EMMailerPrefs):
+ * em-mailer-prefs.c: (junk_book_lookup_button_toggled),
+ (em_mailer_prefs_construct): Add new option
+ /apps/evolution/mail/junk/lookup_addressbook_local_only
+ to determine whether check for address in a local address book only.
+
+2008-04-23 Milan Crha <mcrha@redhat.com>
+
** Fix for bug #529179
* em-folder-browser.c: (struct _EMFolderBrowserPrivate),
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index b4e8308cf7..dcb9c5c82e 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -484,7 +484,7 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, int cancelled)
if (!(job->format->load_http_now
|| job->format->load_http == MAIL_CONFIG_HTTP_ALWAYS
|| (job->format->load_http == MAIL_CONFIG_HTTP_SOMETIMES
- && em_utils_in_addressbook((CamelInternetAddress *)camel_mime_message_get_from(job->format->format.message))))) {
+ && em_utils_in_addressbook((CamelInternetAddress *)camel_mime_message_get_from(job->format->format.message), FALSE)))) {
/* TODO: Ideally we would put the http requests into another queue and only send them out
if the user selects 'load images', when they do. The problem is how to maintain this
state with multiple renderings, and how to adjust the thread dispatch/setup routine to handle it */
diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c
index 26a68d0fc2..40b6188659 100644
--- a/mail/em-mailer-prefs.c
+++ b/mail/em-mailer-prefs.c
@@ -825,6 +825,13 @@ photo_toggle_changed (GtkToggleButton *toggle, EMMailerPrefs *prefs)
}
static void
+junk_book_lookup_button_toggled (GtkToggleButton *toggle, EMMailerPrefs *prefs)
+{
+ toggle_button_toggled (toggle, prefs);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->junk_lookup_local_only), gtk_toggle_button_get_active (toggle));
+}
+
+static void
custom_junk_button_toggled (GtkToggleButton *toggle, EMMailerPrefs *prefs)
{
toggle_button_toggled (toggle, prefs);
@@ -1493,10 +1500,17 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
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");
+ prefs->junk_lookup_local_only = (GtkToggleButton *)glade_xml_get_widget (gui, "junk_lookup_local_only");
toggle_button_init (prefs, prefs->junk_book_lookup, FALSE,
"/apps/evolution/mail/junk/lookup_addressbook",
+ G_CALLBACK (junk_book_lookup_button_toggled));
+
+ toggle_button_init (prefs, prefs->junk_lookup_local_only, FALSE,
+ "/apps/evolution/mail/junk/lookup_addressbook_local_only",
G_CALLBACK (toggle_button_toggled));
+ junk_book_lookup_button_toggled (prefs->junk_book_lookup, prefs);
+
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",
diff --git a/mail/em-mailer-prefs.h b/mail/em-mailer-prefs.h
index 007fcdf566..8f085142d3 100644
--- a/mail/em-mailer-prefs.h
+++ b/mail/em-mailer-prefs.h
@@ -136,7 +136,7 @@ struct _EMMailerPrefs {
struct _GtkButton *junk_header_add;
struct _GtkButton *junk_header_remove;
struct _GtkToggleButton *junk_book_lookup;
-
+ struct _GtkToggleButton *junk_lookup_local_only;
};
struct _EMMailerPrefsClass {
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 53e2fff906..73379af0ed 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1976,7 +1976,7 @@ emu_addr_cancel_book(void *data)
}
gboolean
-em_utils_in_addressbook(CamelInternetAddress *iaddr)
+em_utils_in_addressbook (CamelInternetAddress *iaddr, gboolean local_only)
{
GError *err = NULL;
GSList *s, *g, *addr_sources = NULL;
@@ -2027,6 +2027,9 @@ em_utils_in_addressbook(CamelInternetAddress *iaddr)
/* FIXME: this aint threadsafe by any measure, but what can you do eh??? */
for (g = e_source_list_peek_groups(emu_addr_list);g;g=g_slist_next(g)) {
+ if (local_only && e_source_group_peek_base_uri ((ESourceGroup *)g->data) && !g_str_has_prefix (e_source_group_peek_base_uri ((ESourceGroup *)g->data), "file://"))
+ continue;
+
for (s = e_source_group_peek_sources((ESourceGroup *)g->data);s;s=g_slist_next(s)) {
ESource *src = s->data;
const char *completion = e_source_get_property (src, "completion");
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 2b8fae822c..8f2cc83985 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -108,7 +108,7 @@ void em_utils_show_error_silent (struct _GtkWidget *widget);
void em_utils_show_info_silent (struct _GtkWidget *widget);
/* is this address in the addressbook? caches results */
-gboolean em_utils_in_addressbook(struct _CamelInternetAddress *addr);
+gboolean em_utils_in_addressbook (struct _CamelInternetAddress *addr, gboolean local_only);
struct _CamelMimePart *em_utils_contact_photo (struct _CamelInternetAddress *addr, gboolean local);
const char *em_utils_snoop_type(struct _CamelMimePart *part);
diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in
index e8d4629e72..8d2e34d335 100644
--- a/mail/evolution-mail.schemas.in
+++ b/mail/evolution-mail.schemas.in
@@ -1169,6 +1169,20 @@
</schema>
<schema>
+ <key>/schemas/apps/evolution/mail/junk/lookup_addressbook_local_only</key>
+ <applyto>/apps/evolution/mail/junk/lookup_addressbook_local_only</applyto>
+ <owner>evolution-mail</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Determines whether to look up addresses for junk filtering in local addressbook only</short>
+ <long>
+ This option is related to the key lookup_addressbook and is used to determine whether to look up addresses in local addressbook only to exclude mail sent by known contacts from junk filtering.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/evolution/mail/junk/check_custom_header</key>
<applyto>/apps/evolution/mail/junk/check_custom_header</applyto>
<owner>evolution-mail</owner>
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 09c4cd662c..43a0e8b65b 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -102,6 +102,7 @@ typedef struct {
GSList *jh_header;
gboolean jh_check;
gboolean book_lookup;
+ gboolean book_lookup_local_only;
} MailConfig;
static MailConfig *config = NULL;
@@ -498,6 +499,14 @@ mail_config_init (void)
config->book_lookup =
gconf_client_get_bool (config->gconf, key, NULL);
+ key = "/apps/evolution/mail/junk/lookup_addressbook_local_only";
+ func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+ gconf_client_notify_add (
+ config->gconf, key, func,
+ &config->book_lookup_local_only, NULL, NULL);
+ config->book_lookup_local_only =
+ gconf_client_get_bool (config->gconf, key, NULL);
+
gconf_jh_check_changed (config->gconf, 0, NULL, config);
}
@@ -1147,7 +1156,7 @@ mail_config_remove_signature (ESignature *signature)
}
void
-mail_config_reload_junk_headers ()
+mail_config_reload_junk_headers (void)
{
/* It automatically sets in the session */
if (config == NULL)
@@ -1158,14 +1167,23 @@ mail_config_reload_junk_headers ()
}
gboolean
-mail_config_get_lookup_book()
+mail_config_get_lookup_book (void)
{
/* It automatically sets in the session */
if (config == NULL)
mail_config_init ();
return config->book_lookup;
+}
+
+gboolean
+mail_config_get_lookup_book_local_only (void)
+{
+ /* It automatically sets in the session */
+ if (config == NULL)
+ mail_config_init ();
+ return config->book_lookup_local_only;
}
char *
diff --git a/mail/mail-config.glade b/mail/mail-config.glade
index f7a7050fa5..f73eaae09c 100644
--- a/mail/mail-config.glade
+++ b/mail/mail-config.glade
@@ -6478,7 +6478,7 @@ For example: &quot;Work&quot; or &quot;Personal&quot;</property>
<widget class="GtkTable" id="table34">
<property name="border_width">12</property>
<property name="visible">True</property>
- <property name="n_rows">8</property>
+ <property name="n_rows">9</property>
<property name="n_columns">1</property>
<property name="homogeneous">False</property>
<property name="row_spacing">3</property>
@@ -6534,8 +6534,8 @@ For example: &quot;Work&quot; or &quot;Personal&quot;</property>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
<property name="x_options">fill</property>
</packing>
</child>
@@ -6615,8 +6615,8 @@ For example: &quot;Work&quot; or &quot;Personal&quot;</property>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
<property name="x_padding">15</property>
<property name="x_options">fill</property>
</packing>
@@ -6799,6 +6799,29 @@ For example: &quot;Work&quot; or &quot;Personal&quot;</property>
</child>
<child>
+ <widget class="GtkCheckButton" id="junk_lookup_local_only">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Lookup in local addressbook only</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_padding">25</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkHBox" id="hbox244">
<property name="visible">True</property>
<property name="homogeneous">False</property>
@@ -6849,9 +6872,9 @@ For example: &quot;Work&quot; or &quot;Personal&quot;</property>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
- <property name="x_padding">23</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="x_padding">0</property>
<property name="x_options">fill</property>
</packing>
</child>
diff --git a/mail/mail-config.h b/mail/mail-config.h
index 8d9554969d..54950a5ebf 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -155,7 +155,8 @@ 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);
+gboolean mail_config_get_lookup_book (void);
+gboolean mail_config_get_lookup_book_local_only (void);
GType evolution_mail_config_get_type (void);
diff --git a/mail/mail-session.c b/mail/mail-session.c
index 597d7ab8a3..0a8af8e023 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -396,7 +396,7 @@ lookup_addressbook(CamelSession *session, const char *name)
addr = camel_internet_address_new ();
camel_address_decode ((CamelAddress *)addr, name);
- ret = em_utils_in_addressbook(addr);
+ ret = em_utils_in_addressbook (addr, mail_config_get_lookup_book_local_only ());
camel_object_unref (addr);
return ret;