diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-04-27 06:22:29 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-04-27 06:22:29 +0800 |
commit | 81270ea009bdca0a9527737efa7ecb27a6260bff (patch) | |
tree | bdf75a062bf5d62ed071bea74ce88b6bef186e91 /calendar/gui/itip-utils.c | |
parent | 1af7571c5c475ecf3f95d56a0fe7af78c7be3180 (diff) | |
download | gsoc2013-evolution-81270ea009bdca0a9527737efa7ecb27a6260bff.tar.gz gsoc2013-evolution-81270ea009bdca0a9527737efa7ecb27a6260bff.tar.zst gsoc2013-evolution-81270ea009bdca0a9527737efa7ecb27a6260bff.zip |
Add itip_get_user_identities().
Convenience function returns a NULL-terminated array of name + address
strings based on registered mail identities.
Diffstat (limited to 'calendar/gui/itip-utils.c')
-rw-r--r-- | calendar/gui/itip-utils.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index d6b7893694..4ab53de115 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -62,6 +62,48 @@ static icalproperty_method itip_methods_enum[] = { }; /** + * itip_get_user_identities: + * + * Returns a %NULL-terminated array of name + address strings based on + * registered mail identities. Free the returned array with g_strfreev(). + * + * Returns: an %NULL-terminated array of mail identity strings + **/ +gchar ** +itip_get_user_identities (void) +{ + EAccountList *account_list; + EIterator *iterator; + gchar **identities; + gint length, ii = 0; + + account_list = e_get_account_list (); + length = e_list_length (E_LIST (account_list)); + iterator = e_list_get_iterator (E_LIST (account_list)); + + identities = g_new0 (gchar *, length + 1); + + while (e_iterator_is_valid (iterator)) { + EAccount *account; + + /* XXX EIterator misuses const. */ + account = (EAccount *) e_iterator_get (iterator); + + if (account->enabled) + identities[ii++] = g_strdup_printf ( + "%s <%s>", + account->id->name, + account->id->address); + + e_iterator_next (iterator); + } + + g_object_unref (iterator); + + return identities; +} + +/** * itip_address_is_user: * @address: an email address * @@ -79,7 +121,8 @@ itip_address_is_user (const gchar *address) account_list = e_get_account_list (); - account = e_account_list_find ( + /* XXX EAccountList misuses const. */ + account = (EAccount *) e_account_list_find ( account_list, E_ACCOUNT_FIND_ID_ADDRESS, address); return (account != NULL); |