diff options
author | Hans Petter Jansson <hpj@ximian.com> | 2004-06-24 06:40:24 +0800 |
---|---|---|
committer | Hans Petter <hansp@src.gnome.org> | 2004-06-24 06:40:24 +0800 |
commit | 54a5d78f7876c7ebbe6e973a7d0321efb48128e0 (patch) | |
tree | c4cf1430105eddc54c3ea70e5aee7648e1effac6 /addressbook/util | |
parent | 00fc3d7f480b020e90de31894f575c54dd78a034 (diff) | |
download | gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.tar gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.tar.gz gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.tar.bz2 gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.tar.lz gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.tar.xz gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.tar.zst gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.zip |
Add an x-source-vcard target entry that includes the source book URI.
2004-06-23 Hans Petter Jansson <hpj@ximian.com>
* gui/component/addressbook-view.c: Add an x-source-vcard target entry
that includes the source book URI.
(destroy_merge_context): Implement.
(removed_contact_cb): Implement.
(merged_contact_cb): Implement.
(selector_tree_drag_data_received): Get the source and target books,
and see if we need to remove contacts from source after they're added
to target. Copy contacts sequentially, not in parallel, with a
callback.
* gui/widgets/e-addressbook-view.c: Add an x-source-vcard target entry
that includes the source book URI.
(table_drag_data_delete): Remove. This is handled by the drag target.
(table_drag_data_get): Handle more than one contact. Supply source.
(create_table_view): Don't connect to the delete signal.
* gui/widgets/e-minicard-view.c: Add an x-source-vcard target entry
that includes the source book URI.
(e_minicard_view_drag_data_delete): Remove. This is handled by the
drag target.
(e_minicard_view_drag_data_get): Handle x-source-vcard target.
(e_minicard_view_drag_begin): Don't connect to the delete signal.
(e_minicard_view_dispose): Don't disconnect from the delete signal.
(e_minicard_view_init): Don't init delete_id.
* gui/widgets/e-minicard-view.h: Remove delete_id from struct.
* util/eab-book-util.[ch] (eab_contact_list_from_string): Skip the
source URI if present.
(eab_book_and_contact_list_from_string): Create the source book from
the provided URI, if present.
(eab_book_and_contact_list_to_string): Include the book URI in
generated string.
svn path=/trunk/; revision=26485
Diffstat (limited to 'addressbook/util')
-rw-r--r-- | addressbook/util/eab-book-util.c | 65 | ||||
-rw-r--r-- | addressbook/util/eab-book-util.h | 3 |
2 files changed, 68 insertions, 0 deletions
diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c index 53a09c323b..f6429dee0a 100644 --- a/addressbook/util/eab-book-util.c +++ b/addressbook/util/eab-book-util.c @@ -188,6 +188,18 @@ eab_contact_list_from_string (const char *str) char *q; char *blank_line; + if (!p) + return NULL; + + if (!strncmp (p, "Book: ", 6)) { + p = strchr (p, '\n'); + if (!p) { + g_warning (G_STRLOC ": Got book but no newline!"); + return NULL; + } + p++; + } + while (*p) { if (*p != '\r') g_string_append_c (gstr, *p); @@ -240,6 +252,59 @@ eab_contact_list_to_string (GList *contacts) return g_string_free (str, FALSE); } +gboolean +eab_book_and_contact_list_from_string (const char *str, EBook **book, GList **contacts) +{ + const char *s0, *s1; + char *uri; + + g_return_val_if_fail (str != NULL, FALSE); + g_return_val_if_fail (book != NULL, FALSE); + g_return_val_if_fail (contacts != NULL, FALSE); + + *contacts = eab_contact_list_from_string (str); + + if (!strncmp (str, "Book: ", 6)) { + s0 = str + 6; + s1 = strchr (str, '\r'); + + if (!s1) + s1 = strchr (str, '\n'); + } else { + s0 = NULL; + s1 = NULL; + } + + if (!s0 || !s1) { + *book = NULL; + return FALSE; + } + + uri = g_strndup (s0, s1 - s0); + *book = e_book_new_from_uri (uri, NULL); + g_free (uri); + + return *book ? TRUE : FALSE; +} + +char * +eab_book_and_contact_list_to_string (EBook *book, GList *contacts) +{ + char *s0, *s1; + + s0 = eab_contact_list_to_string (contacts); + if (!s0) + s0 = g_strdup (""); + + if (book) + s1 = g_strconcat ("Book: ", e_book_get_uri (book), "\r\n", s0, NULL); + else + s1 = g_strdup (s0); + + g_free (s0); + return s1; +} + #if notyet /* * Convenience routine to check for addresses in the local address book. diff --git a/addressbook/util/eab-book-util.h b/addressbook/util/eab-book-util.h index ae3a45ef35..c1362f1571 100644 --- a/addressbook/util/eab-book-util.h +++ b/addressbook/util/eab-book-util.h @@ -54,6 +54,9 @@ guint eab_nickname_query (EBook * GList *eab_contact_list_from_string (const char *str); char *eab_contact_list_to_string (GList *contacts); +gboolean eab_book_and_contact_list_from_string (const char *str, EBook **book, GList **contacts); +char *eab_book_and_contact_list_to_string (EBook *book, GList *contacts); + /* Returns the EContact associated to email in the callback, or NULL if no match is found in the default address book. */ void eab_query_address_default (const gchar *email, |