[libgdata] contacts: Use "default" instead of the user's username in request URIs



commit 2e26e1a0ca6ce6ac25f621b9ad057a65b71dc286
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Aug 26 09:37:44 2010 +0100

    contacts: Use "default" instead of the user's username in request URIs
    
    Just like with the Calendar service, this magically fixes batch operations
    so that the contact's ID can be used in them, rather than its self URI.

 gdata/services/contacts/gdata-contacts-service.c |    2 +-
 gdata/tests/contacts.c                           |   16 +++-------------
 2 files changed, 4 insertions(+), 14 deletions(-)
---
diff --git a/gdata/services/contacts/gdata-contacts-service.c b/gdata/services/contacts/gdata-contacts-service.c
index 7d72a98..b450eae 100644
--- a/gdata/services/contacts/gdata-contacts-service.c
+++ b/gdata/services/contacts/gdata-contacts-service.c
@@ -196,7 +196,7 @@ gdata_contacts_service_insert_contact (GDataContactsService *self, GDataContacts
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
 	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-	uri = _gdata_service_build_uri (FALSE, "http://www.google.com/m8/feeds/contacts/%s/full";, gdata_service_get_username (GDATA_SERVICE (self)));
+	uri = g_strconcat (_gdata_service_get_scheme (), "://www.google.com/m8/feeds/contacts/default/full", NULL);
 	entry = gdata_service_insert_entry (GDATA_SERVICE (self), uri, GDATA_ENTRY (contact), cancellable, error);
 	g_free (uri);
 
diff --git a/gdata/tests/contacts.c b/gdata/tests/contacts.c
index f819f53..698c2cc 100644
--- a/gdata/tests/contacts.c
+++ b/gdata/tests/contacts.c
@@ -1236,7 +1236,6 @@ test_batch (gconstpointer service)
 	GDataService *service2;
 	GDataContactsContact *contact, *contact2, *contact3;
 	GDataEntry *inserted_entry, *inserted_entry2, *inserted_entry3;
-	GDataLink *self_link;
 	gchar *feed_uri;
 	guint op_id, op_id2, op_id3;
 	GError *error = NULL, *entry_error = NULL;
@@ -1275,12 +1274,9 @@ test_batch (gconstpointer service)
 	contact2 = gdata_contacts_contact_new (NULL);
 	gdata_entry_set_title (GDATA_ENTRY (contact2), "Brian");
 
-	/* The contacts API is weird in that you can't do a GET on a contact's ID URI â?? you have to use their self link URI instead */
-	self_link = gdata_entry_look_up_link (inserted_entry, GDATA_LINK_SELF);
-
 	operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service), "http://www.google.com/m8/feeds/contacts/default/full/batch";);
 	op_id = gdata_test_batch_operation_insertion (operation, GDATA_ENTRY (contact2), &inserted_entry2, NULL);
-	op_id2 = gdata_test_batch_operation_query (operation, gdata_link_get_uri (self_link), GDATA_TYPE_CONTACTS_CONTACT, inserted_entry, NULL,
+	op_id2 = gdata_test_batch_operation_query (operation, gdata_entry_get_id (inserted_entry), GDATA_TYPE_CONTACTS_CONTACT, inserted_entry, NULL,
 	                                           NULL);
 	g_assert_cmpuint (op_id, !=, op_id2);
 
@@ -1377,15 +1373,12 @@ static void
 test_batch_async (BatchAsyncData *data, gconstpointer service)
 {
 	GDataBatchOperation *operation;
-	GDataLink *self_link;
 	guint op_id;
 	GMainLoop *main_loop;
 
 	/* Run an async query operation on the contact */
-	self_link = gdata_entry_look_up_link (GDATA_ENTRY (data->new_contact), GDATA_LINK_SELF);
-
 	operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service), "http://www.google.com/m8/feeds/contacts/default/full/batch";);
-	op_id = gdata_test_batch_operation_query (operation, gdata_link_get_uri (self_link), GDATA_TYPE_CONTACTS_CONTACT,
+	op_id = gdata_test_batch_operation_query (operation, gdata_entry_get_id (GDATA_ENTRY (data->new_contact)), GDATA_TYPE_CONTACTS_CONTACT,
 	                                          GDATA_ENTRY (data->new_contact), NULL, NULL);
 
 	main_loop = g_main_loop_new (NULL, TRUE);
@@ -1412,16 +1405,13 @@ static void
 test_batch_async_cancellation (BatchAsyncData *data, gconstpointer service)
 {
 	GDataBatchOperation *operation;
-	GDataLink *self_link;
 	guint op_id;
 	GMainLoop *main_loop;
 	GCancellable *cancellable;
 
 	/* Run an async query operation on the contact */
-	self_link = gdata_entry_look_up_link (GDATA_ENTRY (data->new_contact), GDATA_LINK_SELF);
-
 	operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service), "http://www.google.com/m8/feeds/contacts/default/full/batch";);
-	op_id = gdata_test_batch_operation_query (operation, gdata_link_get_uri (self_link), GDATA_TYPE_CONTACTS_CONTACT,
+	op_id = gdata_test_batch_operation_query (operation, gdata_entry_get_id (GDATA_ENTRY (data->new_contact)), GDATA_TYPE_CONTACTS_CONTACT,
 	                                          GDATA_ENTRY (data->new_contact), NULL, NULL);
 
 	main_loop = g_main_loop_new (NULL, TRUE);



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