From d10adfea7a903356ccf15161955325a83ebd9863 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Mon, 2 Jul 2001 05:24:44 +0000 Subject: use ECARD_UID_LINK_PREFIX. 2001-07-01 Chris Toshok * gui/contact-list-editor/e-contact-list-editor.c (fill_in_info): use ECARD_UID_LINK_PREFIX. * gui/contact-list-editor/e-contact-list-model.c (e_contact_list_model_get_email): use ECARD_UID_LINK_PREFIX. * backend/ebook/e-destination.h: add prototype for e_destination_importv_list. * backend/ebook/e-destination.c (e_destination_importv_list): new function, take an ECard corresponding to an address list and resolve any linked cards, returning an EDestination vector. * backend/ebook/e-card.h (ECARD_UID_LINK_PREFIX): #define this here, since we need to use it in a few places. svn path=/trunk/; revision=10667 --- addressbook/backend/ebook/e-destination.c | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'addressbook/backend/ebook/e-destination.c') diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c index 172afb6da6..4a1d2992cb 100644 --- a/addressbook/backend/ebook/e-destination.c +++ b/addressbook/backend/ebook/e-destination.c @@ -729,6 +729,55 @@ e_destination_importv (const gchar *str) return destv; } +EDestination ** +e_destination_importv_list (EBook *book, ECard *list) +{ + EList *email_list; + EIterator *email_iter; + EDestination **destv; + gint j = 0; + + if (!e_card_evolution_list (list)) + return NULL; + + gtk_object_get (GTK_OBJECT(list), + "email", &email_list, + NULL); + + destv = g_new0 (EDestination *, e_list_length (email_list) +1); + + email_iter = e_list_get_iterator (email_list); + + while (e_iterator_is_valid (email_iter)) { + const char *email = e_iterator_get (email_iter); + + if (!strncmp (email, ECARD_UID_LINK_PREFIX, strlen (ECARD_UID_LINK_PREFIX))) { + /* it's a serialized uid */ + ECard *card; + const char *uid; + uid = email + strlen (ECARD_UID_LINK_PREFIX); + card = e_book_get_card (book, uid); + if (card) { + EDestination *dest = e_destination_new (); + e_destination_set_card (dest, card, 0); + gtk_object_unref (GTK_OBJECT (card)); /* XXX ? */ + destv[j++] = dest; + } + } + else { + /* it's an email address */ + EDestination *dest = e_destination_new(); + dest->priv->string_email = g_strdup (email); + + if (dest) { + destv[j++] = dest; + } + } + } + + return destv; +} + static void touch_cb (EBook *book, const gchar *addr, ECard *card, gpointer closure) { -- cgit v1.2.3