diff options
Diffstat (limited to 'addressbook/backend')
-rw-r--r-- | addressbook/backend/ebook/e-card.h | 2 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-destination.c | 49 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-destination.h | 1 |
3 files changed, 52 insertions, 0 deletions
diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h index d54d4c95fe..fa448704a5 100644 --- a/addressbook/backend/ebook/e-card.h +++ b/addressbook/backend/ebook/e-card.h @@ -125,6 +125,8 @@ float e_card_get_use_score (ECard void e_card_touch (ECard *card); /* Evolution List convenience functions */ +/* used for encoding uids in email addresses */ +#define ECARD_UID_LINK_PREFIX "|X-EVOLUTION-UID=" gboolean e_card_evolution_list (ECard *card); gboolean e_card_evolution_list_show_addresses(ECard *card); 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) { diff --git a/addressbook/backend/ebook/e-destination.h b/addressbook/backend/ebook/e-destination.h index bacd9dd428..85edf594be 100644 --- a/addressbook/backend/ebook/e-destination.h +++ b/addressbook/backend/ebook/e-destination.h @@ -92,6 +92,7 @@ EDestination *e_destination_import (const gchar *str); gchar *e_destination_exportv (EDestination **); EDestination **e_destination_importv (const gchar *str); +EDestination **e_destination_importv_list (EBook *book, ECard *list); void e_destination_touch (EDestination *); |