[libgdata] contacts: Add a code example for using batch operations
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] contacts: Add a code example for using batch operations
- Date: Thu, 30 Dec 2010 14:11:57 +0000 (UTC)
commit c68d0d81945184ca7896360edf05b0aef2bbe899
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 30 13:55:31 2010 +0000
contacts: Add a code example for using batch operations
Helps: bgo#579885
gdata/services/contacts/gdata-contacts-service.c | 70 ++++++++++++++++++++++
1 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/gdata/services/contacts/gdata-contacts-service.c b/gdata/services/contacts/gdata-contacts-service.c
index 65531ae..12b2912 100644
--- a/gdata/services/contacts/gdata-contacts-service.c
+++ b/gdata/services/contacts/gdata-contacts-service.c
@@ -72,6 +72,76 @@
* </programlisting>
* </example>
*
+ * The Contacts service can be manipulated using batch operations, too. See the
+ * <ulink type="http" url="http://code.google.com/apis/contacts/docs/3.0/developers_guide_protocol.html#Batch">online documentation on batch
+ * operations</ulink> for more information.
+ *
+ * <example>
+ * <title>Performing a Batch Operation on Contacts</title>
+ * <programlisting>
+ * GDataContactsService *service;
+ * GDataBatchOperation *operation;
+ * GDataFeed *feed;
+ * GDataLink *batch_link;
+ * GList *i;
+ * GError *error = NULL;
+ *
+ * /<!-- -->* Create a service *<!-- -->/
+ * service = create_contacts_service ();
+ *
+ * /<!-- -->* Create the batch operation; this requires that we have done a query first so that we can get the batch link *<!-- -->/
+ * feed = do_some_query (service);
+ * batch_link = gdata_feed_look_up_link (feed, GDATA_LINK_BATCH);
+ * operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service), gdata_link_get_uri (batch_link));
+ * g_object_unref (feed);
+ *
+ * gdata_batch_operation_add_query (operation, contact_entry_id_to_query, GDATA_TYPE_CONTACTS_CONTACT,
+ * (GDataBatchOperationCallback) batch_query_cb, user_data);
+ * gdata_batch_operation_add_insertion (operation, new_entry, (GDataBatchOperationCallback) batch_insertion_cb, user_data);
+ * gdata_batch_operation_add_update (operation, old_entry, (GDataBatchOperationCallback) batch_update_cb, user_data);
+ * gdata_batch_operation_add_deletion (operation, entry_to_delete, (GDataBatchOperationCallback) batch_deletion_cb, user_data);
+ *
+ * /<!-- -->* Run the batch operation and handle the results in the various callbacks *<!-- -->/
+ * gdata_test_batch_operation_run (operation, NULL, &error);
+ *
+ * g_object_unref (operation);
+ * g_object_unref (service);
+ *
+ * if (error != NULL) {
+ * g_error ("Error running batch operation: %s", error->message);
+ * g_error_free (error);
+ * return;
+ * }
+ *
+ * static void
+ * batch_query_cb (guint operation_id, GDataBatchOperationType operation_type, GDataEntry *entry, GError *error, gpointer user_data)
+ * {
+ * /<!-- -->* operation_type == GDATA_BATCH_OPERATION_QUERY *<!-- -->/
+ * /<!-- -->* Reference and do something with the returned entry. *<!-- -->/
+ * }
+ *
+ * static void
+ * batch_insertion_cb (guint operation_id, GDataBatchOperationType operation_type, GDataEntry *entry, GError *error, gpointer user_data)
+ * {
+ * /<!-- -->* operation_type == GDATA_BATCH_OPERATION_INSERTION *<!-- -->/
+ * /<!-- -->* Reference and do something with the returned entry. *<!-- -->/
+ * }
+ *
+ * static void
+ * batch_update_cb (guint operation_id, GDataBatchOperationType operation_type, GDataEntry *entry, GError *error, gpointer user_data)
+ * {
+ * /<!-- -->* operation_type == GDATA_BATCH_OPERATION_UPDATE *<!-- -->/
+ * /<!-- -->* Reference and do something with the returned entry. *<!-- -->/
+ * }
+ *
+ * static void
+ * batch_deletion_cb (guint operation_id, GDataBatchOperationType operation_type, GDataEntry *entry, GError *error, gpointer user_data)
+ * {
+ * /<!-- -->* operation_type == GDATA_BATCH_OPERATION_DELETION, entry == NULL *<!-- -->/
+ * }
+ * </programlisting>
+ * </example>
+ *
* Since: 0.2.0
**/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]