[libgdata] picasaweb: Add gdata_picasaweb_service_insert_album_async()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] picasaweb: Add gdata_picasaweb_service_insert_album_async()
- Date: Sun, 7 Nov 2010 16:16:06 +0000 (UTC)
commit 79f37d272c704ef2000c087e6e9d70e599314c91
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Nov 7 15:49:02 2010 +0000
picasaweb: Add gdata_picasaweb_service_insert_album_async()
Helps: bgo#633363
docs/reference/gdata-sections.txt | 1 +
gdata/gdata.symbols | 1 +
gdata/services/picasaweb/gdata-picasaweb-service.c | 30 +++++++++++++
gdata/services/picasaweb/gdata-picasaweb-service.h | 2 +
gdata/tests/picasaweb.c | 46 ++++++++++++++++++++
5 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 7e8a956..48a4e04 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -1338,6 +1338,7 @@ gdata_picasaweb_service_upload_file
gdata_picasaweb_service_upload_file_async
gdata_picasaweb_service_upload_file_finish
gdata_picasaweb_service_insert_album
+gdata_picasaweb_service_insert_album_async
<SUBSECTION Standard>
gdata_picasaweb_service_get_type
GDATA_IS_PICASAWEB_SERVICE
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 5ab8320..9e0c8ed 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -854,3 +854,4 @@ gdata_contacts_service_insert_group
gdata_contacts_service_insert_group_async
gdata_youtube_service_upload_video_async
gdata_youtube_service_upload_video_finish
+gdata_picasaweb_service_insert_album_async
diff --git a/gdata/services/picasaweb/gdata-picasaweb-service.c b/gdata/services/picasaweb/gdata-picasaweb-service.c
index e09df6d..38e6056 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-service.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-service.c
@@ -683,3 +683,33 @@ gdata_picasaweb_service_insert_album (GDataPicasaWebService *self, GDataPicasaWe
GDATA_ENTRY (album), cancellable, error));
}
+/**
+ * gdata_picasaweb_service_insert_album_async:
+ * @self: a #GDataPicasaWebService
+ * @album: a #GDataPicasaWebAlbum to create on the server
+ * @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 a new album described by @album. The user must be authenticated to use this function. @self and @album 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 #GDataPicasaWebAlbum representing the inserted album and to check for
+ * possible errors.
+ *
+ * For more details, see gdata_picasaweb_service_insert_album(), which is the synchronous version of this function, and
+ * gdata_service_insert_entry_async(), which is the base asynchronous insertion function.
+ *
+ * Since: 0.8.0
+ **/
+void
+gdata_picasaweb_service_insert_album_async (GDataPicasaWebService *self, GDataPicasaWebAlbum *album, GCancellable *cancellable,
+ GAsyncReadyCallback callback, gpointer user_data)
+{
+ g_return_if_fail (GDATA_IS_PICASAWEB_SERVICE (self));
+ g_return_if_fail (GDATA_IS_PICASAWEB_ALBUM (album));
+ g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+
+ gdata_service_insert_entry_async (GDATA_SERVICE (self), "http://picasaweb.google.com/data/feed/api/user/default", GDATA_ENTRY (album),
+ cancellable, callback, user_data);
+}
diff --git a/gdata/services/picasaweb/gdata-picasaweb-service.h b/gdata/services/picasaweb/gdata-picasaweb-service.h
index 0191edd..d368f69 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-service.h
+++ b/gdata/services/picasaweb/gdata-picasaweb-service.h
@@ -93,6 +93,8 @@ GDataPicasaWebFile *gdata_picasaweb_service_upload_file_finish (GDataPicasaWebSe
GDataPicasaWebAlbum *gdata_picasaweb_service_insert_album (GDataPicasaWebService *self, GDataPicasaWebAlbum *album, GCancellable *cancellable,
GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+void gdata_picasaweb_service_insert_album_async (GDataPicasaWebService *self, GDataPicasaWebAlbum *album, GCancellable *cancellable,
+ GAsyncReadyCallback callback, gpointer user_data);
G_END_DECLS
diff --git a/gdata/tests/picasaweb.c b/gdata/tests/picasaweb.c
index cfd4080..72a4c88 100644
--- a/gdata/tests/picasaweb.c
+++ b/gdata/tests/picasaweb.c
@@ -1085,6 +1085,51 @@ test_insert_album (gconstpointer service)
}
static void
+test_insert_album_async_cb (GDataService *service, GAsyncResult *async_result, GMainLoop *main_loop)
+{
+ GDataEntry *entry;
+ GError *error = NULL;
+
+ entry = gdata_service_insert_entry_finish (service, async_result, &error);
+ g_assert_no_error (error);
+ g_assert (GDATA_IS_PICASAWEB_ALBUM (entry));
+ g_clear_error (&error);
+
+ /* Test the album was uploaded correctly */
+ g_assert_cmpstr (gdata_entry_get_title (entry), ==, "Asynchronous album!");
+
+ /* Delete the album, just to be tidy */
+ g_assert (gdata_service_delete_entry (GDATA_SERVICE (service), entry, NULL, &error) == TRUE);
+ g_assert_no_error (error);
+ g_clear_error (&error);
+
+ g_main_loop_quit (main_loop);
+ g_object_unref (entry);
+}
+
+static void
+test_insert_album_async (gconstpointer service)
+{
+ GDataPicasaWebAlbum *album;
+ GMainLoop *main_loop;
+
+ album = gdata_picasaweb_album_new (NULL);
+ g_assert (GDATA_IS_PICASAWEB_ALBUM (album));
+
+ /* Set various properties */
+ gdata_entry_set_title (GDATA_ENTRY (album), "Asynchronous album!");
+
+ main_loop = g_main_loop_new (NULL, TRUE);
+
+ gdata_picasaweb_service_insert_album_async (GDATA_PICASAWEB_SERVICE (service), album, NULL, (GAsyncReadyCallback) test_insert_album_async_cb,
+ main_loop);
+
+ g_main_loop_run (main_loop);
+ g_main_loop_unref (main_loop);
+ g_object_unref (album);
+}
+
+static void
test_query_all_albums (gconstpointer service)
{
GDataFeed *album_feed, *photo_feed;
@@ -1335,6 +1380,7 @@ main (int argc, char *argv[])
g_test_add_data_func ("/picasaweb/query/album", service, test_album);
g_test_add_data_func ("/picasaweb/insert/album", service, test_insert_album);
+ g_test_add_data_func ("/picasaweb/insert/album/async", service, test_insert_album_async);
g_test_add_data_func ("/picasaweb/query/photo_feed", service, test_photo_feed);
g_test_add_data_func ("/picasaweb/query/photo_feed_entry", service, test_photo_feed_entry);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]