[evolution/wip/gsettings] Add itip_address_is_user().



commit eb53bcf0593cd55a33dc827397274aa862740cfc
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Apr 26 11:21:38 2011 -0400

    Add itip_address_is_user().
    
    Convenience function that checks whether the given email address matches
    a registered mail identity.

 calendar/gui/e-cal-model.c               |    2 +-
 calendar/gui/itip-utils.c                |   52 ++++++++++++++++++++----------
 calendar/gui/itip-utils.h                |    1 +
 plugins/groupwise-features/gw-ui.c       |    2 +-
 plugins/groupwise-features/proxy-login.c |    3 +-
 5 files changed, 40 insertions(+), 20 deletions(-)
---
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index ef3c062..34408b0 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -976,7 +976,7 @@ ecm_value_at (ETableModel *etm, gint col, gint row)
 					const gchar *text;
 
 					text = itip_strip_mailto (ca->value);
-					if (e_account_list_find (priv->accounts, E_ACCOUNT_FIND_ID_ADDRESS, text) != NULL) {
+					if (itip_address_is_user (text)) {
 						if (ca->delto != NULL)
 							retval = 3;
 						else
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index 1ce299e..d6b7893 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -61,6 +61,30 @@ static icalproperty_method itip_methods_enum[] = {
     ICAL_METHOD_DECLINECOUNTER,
 };
 
+/**
+ * itip_address_is_user:
+ * @address: an email address
+ *
+ * Looks for a registered mail identity with a matching email address.
+ *
+ * Returns: %TRUE if a match was found, %FALSE if not
+ **/
+gboolean
+itip_address_is_user (const gchar *address)
+{
+	EAccountList *account_list;
+	EAccount *account;
+
+	g_return_val_if_fail (address != NULL, FALSE);
+
+	account_list = e_get_account_list ();
+
+	account = e_account_list_find (
+		account_list, E_ACCOUNT_FIND_ID_ADDRESS, address);
+
+	return (account != NULL);
+}
+
 gboolean
 itip_organizer_is_user (ECalComponent *comp,
                         ECal *client)
@@ -102,9 +126,7 @@ itip_organizer_is_user_ex (ECalComponent *comp,
 			return FALSE;
 		}
 
-		user_org = e_account_list_find (
-			e_get_account_list (),
-			E_ACCOUNT_FIND_ID_ADDRESS, strip) != NULL;
+		user_org = itip_address_is_user (strip);
 	}
 
 	return user_org;
@@ -126,9 +148,7 @@ itip_sentby_is_user (ECalComponent *comp,
 	e_cal_component_get_organizer (comp, &organizer);
 	if (organizer.sentby != NULL) {
 		strip = itip_strip_mailto (organizer.sentby);
-		user_sentby = e_account_list_find (
-			e_get_account_list (),
-			E_ACCOUNT_FIND_ID_ADDRESS, strip) != NULL;
+		user_sentby = itip_address_is_user (strip);
 	}
 
 	return user_sentby;
@@ -918,21 +938,19 @@ comp_limit_attendees (ECalComponent *comp)
 		attendee_text = g_strdup (itip_strip_mailto (attendee));
 		g_free (attendee);
 		attendee_text = g_strstrip (attendee_text);
-		found = match = e_account_list_find (
-			e_get_account_list (),
-			E_ACCOUNT_FIND_ID_ADDRESS,
-			attendee_text) != NULL;
+		found = match = itip_address_is_user (attendee_text);
 
 		if (!found) {
 			param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER);
 			if (param) {
-				attendee_sentby = icalparameter_get_sentby (param);
-				attendee_sentby_text = g_strdup (itip_strip_mailto (attendee_sentby));
-				attendee_sentby_text = g_strstrip (attendee_sentby_text);
-				found = match = e_account_list_find (
-					e_get_account_list (),
-					E_ACCOUNT_FIND_ID_ADDRESS,
-					attendee_sentby_text) != NULL;
+				attendee_sentby =
+					icalparameter_get_sentby (param);
+				attendee_sentby =
+					itip_strip_mailto (attendee_sentby);
+				attendee_sentby_text =
+					g_strstrip (g_strdup (attendee_sentby));
+				found = match = itip_address_is_user (
+					attendee_sentby_text);
 			}
 		}
 
diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h
index 0362cb0..bf9f541 100644
--- a/calendar/gui/itip-utils.h
+++ b/calendar/gui/itip-utils.h
@@ -50,6 +50,7 @@ struct CalMimeAttach {
 	guint length;
 };
 
+gboolean	itip_address_is_user		(const gchar *address);
 gboolean	itip_organizer_is_user		(ECalComponent *comp,
 						 ECal *client);
 gboolean	itip_organizer_is_user_ex	(ECalComponent *comp,
diff --git a/plugins/groupwise-features/gw-ui.c b/plugins/groupwise-features/gw-ui.c
index 0d64bd9..08b9382 100644
--- a/plugins/groupwise-features/gw-ui.c
+++ b/plugins/groupwise-features/gw-ui.c
@@ -321,7 +321,7 @@ is_meeting_owner (ECalComponent *comp, ECal *client)
 	}
 
 	if (!ret_val)
-		ret_val = e_account_list_find (e_get_account_list (), E_ACCOUNT_FIND_ID_ADDRESS, strip) != NULL;
+		ret_val = itip_address_is_user (strip);
 
 	g_free (email);
 	return ret_val;
diff --git a/plugins/groupwise-features/proxy-login.c b/plugins/groupwise-features/proxy-login.c
index 2559dc2..3f80ac9 100644
--- a/plugins/groupwise-features/proxy-login.c
+++ b/plugins/groupwise-features/proxy-login.c
@@ -42,6 +42,7 @@
 #include <e-util/e-util-private.h>
 #include <e-util/e-account-utils.h>
 #include <shell/e-shell-view.h>
+#include <calendar/gui/itip-utils.h>
 
 #include <e-gw-container.h>
 #include <e-gw-connection.h>
@@ -335,7 +336,7 @@ proxy_soap_login (gchar *email, GtkWindow *error_parent)
 	/* README: There should not be the weird scenario of the proxy itself configured as an account.
 	   If so, it is violating the (li)unix philosophy of User creation. So dont care about that scenario*/
 
-	if (e_account_list_find (accounts, E_ACCOUNT_FIND_ID_ADDRESS, email) != NULL) {
+	if (itip_address_is_user (email)) {
 		e_alert_run_dialog_for_args (error_parent,
 					     "org.gnome.evolution.proxy-login:already-loggedin",
 					     email, NULL);



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