evolution r35410 - trunk/mail



Author: mcrha
Date: Wed Apr 23 09:29:11 2008
New Revision: 35410
URL: http://svn.gnome.org/viewvc/evolution?rev=35410&view=rev

Log:
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.



Modified:
   trunk/mail/ChangeLog
   trunk/mail/em-format-html.c
   trunk/mail/em-mailer-prefs.c
   trunk/mail/em-mailer-prefs.h
   trunk/mail/em-utils.c
   trunk/mail/em-utils.h
   trunk/mail/evolution-mail.schemas.in
   trunk/mail/mail-config.c
   trunk/mail/mail-config.glade
   trunk/mail/mail-config.h
   trunk/mail/mail-session.c

Modified: trunk/mail/em-format-html.c
==============================================================================
--- trunk/mail/em-format-html.c	(original)
+++ trunk/mail/em-format-html.c	Wed Apr 23 09:29:11 2008
@@ -484,7 +484,7 @@
 		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 */

Modified: trunk/mail/em-mailer-prefs.c
==============================================================================
--- trunk/mail/em-mailer-prefs.c	(original)
+++ trunk/mail/em-mailer-prefs.c	Wed Apr 23 09:29:11 2008
@@ -825,6 +825,13 @@
 }
 
 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 @@
 	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",

Modified: trunk/mail/em-mailer-prefs.h
==============================================================================
--- trunk/mail/em-mailer-prefs.h	(original)
+++ trunk/mail/em-mailer-prefs.h	Wed Apr 23 09:29:11 2008
@@ -136,7 +136,7 @@
 	struct _GtkButton *junk_header_add;
 	struct _GtkButton *junk_header_remove;
 	struct _GtkToggleButton *junk_book_lookup;
-
+	struct _GtkToggleButton *junk_lookup_local_only;
 };
 
 struct _EMMailerPrefsClass {

Modified: trunk/mail/em-utils.c
==============================================================================
--- trunk/mail/em-utils.c	(original)
+++ trunk/mail/em-utils.c	Wed Apr 23 09:29:11 2008
@@ -1976,7 +1976,7 @@
 }
 
 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 @@
 	/* 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");

Modified: trunk/mail/em-utils.h
==============================================================================
--- trunk/mail/em-utils.h	(original)
+++ trunk/mail/em-utils.h	Wed Apr 23 09:29:11 2008
@@ -108,7 +108,7 @@
 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);

Modified: trunk/mail/evolution-mail.schemas.in
==============================================================================
--- trunk/mail/evolution-mail.schemas.in	(original)
+++ trunk/mail/evolution-mail.schemas.in	Wed Apr 23 09:29:11 2008
@@ -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>

Modified: trunk/mail/mail-config.c
==============================================================================
--- trunk/mail/mail-config.c	(original)
+++ trunk/mail/mail-config.c	Wed Apr 23 09:29:11 2008
@@ -102,6 +102,7 @@
 	GSList *jh_header;
 	gboolean jh_check;
 	gboolean book_lookup;
+	gboolean book_lookup_local_only;
 } MailConfig;
 
 static MailConfig *config = NULL;
@@ -498,6 +499,14 @@
 	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 @@
 }
 
 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 @@
 }
 
 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 *

Modified: trunk/mail/mail-config.glade
==============================================================================
--- trunk/mail/mail-config.glade	(original)
+++ trunk/mail/mail-config.glade	Wed Apr 23 09:29:11 2008
@@ -6478,7 +6478,7 @@
 		<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 @@
 		    <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 @@
 		    <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 @@
 		  </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 @@
 		    <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>

Modified: trunk/mail/mail-config.h
==============================================================================
--- trunk/mail/mail-config.h	(original)
+++ trunk/mail/mail-config.h	Wed Apr 23 09:29:11 2008
@@ -155,7 +155,8 @@
 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);
 

Modified: trunk/mail/mail-session.c
==============================================================================
--- trunk/mail/mail-session.c	(original)
+++ trunk/mail/mail-session.c	Wed Apr 23 09:29:11 2008
@@ -396,7 +396,7 @@
 
 	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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]