aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
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
parent4d02935fbb960375d57912bdd6ca20d2ba73b233 (diff)
downloadgsoc2013-evolution-eb53bcf0593cd55a33dc827397274aa862740cfc.tar.gz
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')
-rw-r--r--calendar/gui/e-cal-model.c2
-rw-r--r--calendar/gui/itip-utils.c52
-rw-r--r--calendar/gui/itip-utils.h1
3 files changed, 37 insertions, 18 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index ef3c0624df..34408b0151 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 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);
}
}
diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h
index 0362cb0314..bf9f5417c8 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,