aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/itip-utils.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-04-26 23:21:38 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:41:57 +0800
commiteb53bcf0593cd55a33dc827397274aa862740cfc (patch)
tree00925bd9805dc96dbd1e8a7d8d2c11cfb40ae2fe /calendar/gui/itip-utils.c
parent4d02935fbb960375d57912bdd6ca20d2ba73b233 (diff)
downloadgsoc2013-evolution-eb53bcf0593cd55a33dc827397274aa862740cfc.tar
gsoc2013-evolution-eb53bcf0593cd55a33dc827397274aa862740cfc.tar.gz
gsoc2013-evolution-eb53bcf0593cd55a33dc827397274aa862740cfc.tar.bz2
gsoc2013-evolution-eb53bcf0593cd55a33dc827397274aa862740cfc.tar.lz
gsoc2013-evolution-eb53bcf0593cd55a33dc827397274aa862740cfc.tar.xz
gsoc2013-evolution-eb53bcf0593cd55a33dc827397274aa862740cfc.tar.zst
gsoc2013-evolution-eb53bcf0593cd55a33dc827397274aa862740cfc.zip
Add itip_address_is_user().
Convenience function that checks whether the given email address matches a registered mail identity.
Diffstat (limited to 'calendar/gui/itip-utils.c')
-rw-r--r--calendar/gui/itip-utils.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index 1ce299e18b..d6b7893694 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);
}
}