[libgdata] contacts: Add gdata_contacts_service_insert_contact_async()



commit 89a659d6102433c63bfa4600a35e77b56d373b1b
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Oct 9 09:41:39 2010 +0100

    contacts: Add gdata_contacts_service_insert_contact_async()

 docs/reference/gdata-sections.txt                |    1 +
 gdata/gdata.symbols                              |    1 +
 gdata/services/contacts/gdata-contacts-service.c |   35 +++++++++++++++++++++-
 gdata/services/contacts/gdata-contacts-service.h |    2 +
 4 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 819ee67..8a461df 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -279,6 +279,7 @@ gdata_contacts_service_new
 gdata_contacts_service_query_contacts
 gdata_contacts_service_query_contacts_async
 gdata_contacts_service_insert_contact
+gdata_contacts_service_insert_contact_async
 <SUBSECTION Standard>
 gdata_contacts_service_get_type
 GDATA_CONTACTS_SERVICE
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 2ae9e23..b27c4e6 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -256,6 +256,7 @@ gdata_contacts_service_new
 gdata_contacts_service_query_contacts
 gdata_contacts_service_query_contacts_async
 gdata_contacts_service_insert_contact
+gdata_contacts_service_insert_contact_async
 gdata_contacts_query_get_type
 gdata_contacts_query_new
 gdata_contacts_query_new_with_limits
diff --git a/gdata/services/contacts/gdata-contacts-service.c b/gdata/services/contacts/gdata-contacts-service.c
index 6d48596..08c4def 100644
--- a/gdata/services/contacts/gdata-contacts-service.c
+++ b/gdata/services/contacts/gdata-contacts-service.c
@@ -187,7 +187,6 @@ gdata_contacts_service_query_contacts_async (GDataContactsService *self, GDataQu
 GDataContactsContact *
 gdata_contacts_service_insert_contact (GDataContactsService *self, GDataContactsContact *contact, GCancellable *cancellable, GError **error)
 {
-	/* TODO: Async variant */
 	gchar *uri;
 	GDataEntry *entry;
 
@@ -202,3 +201,37 @@ gdata_contacts_service_insert_contact (GDataContactsService *self, GDataContacts
 
 	return GDATA_CONTACTS_CONTACT (entry);
 }
+
+/**
+ * gdata_contacts_service_insert_contact_async:
+ * @self: a #GDataContactsService
+ * @contact: the #GDataContactsContact to insert
+ * @cancellable: optional #GCancellable object, or %NULL
+ * @callback: a #GAsyncReadyCallback to call when insertion is finished
+ * @user_data: (closure): data to pass to the @callback function
+ *
+ * Inserts @contact by uploading it to the online contacts service. @self and @contact are both reffed when this function is called, so can safely be
+ * unreffed after this function returns.
+ *
+ * @callback should call gdata_service_insert_entry_finish() to obtain a #GDataContactsContact representing the inserted contact and to check for
+ * possible errors.
+ *
+ * For more details, see gdata_contacts_service_insert_contact(), which is the synchronous version of this function,
+ * and gdata_service_insert_entry_async(), which is the base asynchronous insertion function.
+ *
+ * Since: 0.7.0
+ **/
+void
+gdata_contacts_service_insert_contact_async (GDataContactsService *self, GDataContactsContact *contact, GCancellable *cancellable,
+                                             GAsyncReadyCallback callback, gpointer user_data)
+{
+	gchar *uri;
+
+	g_return_if_fail (GDATA_IS_CONTACTS_SERVICE (self));
+	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (contact));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+
+	uri = g_strconcat (_gdata_service_get_scheme (), "://www.google.com/m8/feeds/contacts/default/full", NULL);
+	gdata_service_insert_entry_async (GDATA_SERVICE (self), uri, GDATA_ENTRY (contact), cancellable, callback, user_data);
+	g_free (uri);
+}
diff --git a/gdata/services/contacts/gdata-contacts-service.h b/gdata/services/contacts/gdata-contacts-service.h
index 3b58791..c3c442a 100644
--- a/gdata/services/contacts/gdata-contacts-service.h
+++ b/gdata/services/contacts/gdata-contacts-service.h
@@ -75,6 +75,8 @@ void gdata_contacts_service_query_contacts_async (GDataContactsService *self, GD
 
 GDataContactsContact *gdata_contacts_service_insert_contact (GDataContactsService *self, GDataContactsContact *contact,
                                                              GCancellable *cancellable, GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+void gdata_contacts_service_insert_contact_async (GDataContactsService *self, GDataContactsContact *contact, GCancellable *cancellable,
+                                                  GAsyncReadyCallback callback, gpointer user_data);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]