[libgdata] Bug 593336 — Query parameter "q=..." isn't valid for album kinds
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgdata] Bug 593336 — Query parameter "q=..." isn't valid for album kinds
- Date: Sun, 20 Sep 2009 16:21:24 +0000 (UTC)
commit 37d2830af877827a73ae9f68f49422b5c913a67c
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Sep 20 17:20:13 2009 +0100
Bug 593336 â?? Query parameter "q=..." isn't valid for album kinds
Also add checks in gdata_picasaweb_service_query_all_albums*() to ensure
the q parameter isn't set, including a corresponding error code and a
test in the suite. Closes: bgo#593336
gdata/gdata-service.h | 8 +++++---
gdata/services/picasaweb/gdata-picasaweb-service.c | 15 +++++++++++++++
gdata/tests/picasaweb.c | 20 ++++++++++++--------
3 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/gdata/gdata-service.h b/gdata/gdata-service.h
index fde1164..7c89cb7 100644
--- a/gdata/gdata-service.h
+++ b/gdata/gdata-service.h
@@ -43,8 +43,9 @@ G_BEGIN_DECLS
* @GDATA_SERVICE_ERROR_CONFLICT: There was a conflict when updating an entry on the server; the server-side copy was modified inbetween downloading
* and uploading the modified entry
* @GDATA_SERVICE_ERROR_FORBIDDEN: Generic error for a forbidden action (not due to having insufficient permissions)
- * @GDATA_SERVICE_ERROR_WITH_DOWNLOAD: Generic error when downloading a file (rather than querying for an entry).
- * @GDATA_SERVICE_ERROR_WITH_UPLOAD: Generic error when uploading a file (either inserting or updating an entry).
+ * @GDATA_SERVICE_ERROR_WITH_DOWNLOAD: Generic error when downloading a file (rather than querying for an entry)
+ * @GDATA_SERVICE_ERROR_WITH_UPLOAD: Generic error when uploading a file (either inserting or updating an entry)
+ * @GDATA_SERVICE_ERROR_BAD_QUERY_PARAMETER: A given query parameter was invalid for the query type
*
* Error codes for #GDataService operations.
**/
@@ -61,7 +62,8 @@ typedef enum {
GDATA_SERVICE_ERROR_CONFLICT,
GDATA_SERVICE_ERROR_FORBIDDEN,
GDATA_SERVICE_ERROR_WITH_DOWNLOAD,
- GDATA_SERVICE_ERROR_WITH_UPLOAD
+ GDATA_SERVICE_ERROR_WITH_UPLOAD,
+ GDATA_SERVICE_ERROR_BAD_QUERY_PARAMETER
} GDataServiceError;
/**
diff --git a/gdata/services/picasaweb/gdata-picasaweb-service.c b/gdata/services/picasaweb/gdata-picasaweb-service.c
index a9ff465..20b0119 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-service.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-service.c
@@ -129,6 +129,13 @@ gdata_picasaweb_service_query_all_albums (GDataPicasaWebService *self, GDataQuer
g_return_val_if_fail (GDATA_IS_PICASAWEB_SERVICE (self), NULL);
g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+ if (query != NULL && gdata_query_get_q (query) != NULL) {
+ /* Bug #593336 â?? Query parameter "q=..." isn't valid for album kinds */
+ g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_BAD_QUERY_PARAMETER,
+ _("Query parameter not allowed for albums."));
+ return NULL;
+ }
+
uri = create_uri (self, username);
if (uri == NULL) {
g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
@@ -175,6 +182,14 @@ gdata_picasaweb_service_query_all_albums_async (GDataPicasaWebService *self, GDa
g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
g_return_if_fail (callback != NULL);
+ if (query != NULL && gdata_query_get_q (query) != NULL) {
+ /* Bug #593336 â?? Query parameter "q=..." isn't valid for album kinds */
+ g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data,
+ GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_BAD_QUERY_PARAMETER,
+ _("Query parameter not allowed for albums."));
+ return;
+ }
+
uri = create_uri (self, username);
if (uri == NULL) {
g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data,
diff --git a/gdata/tests/picasaweb.c b/gdata/tests/picasaweb.c
index 71ce0dd..05de42e 100644
--- a/gdata/tests/picasaweb.c
+++ b/gdata/tests/picasaweb.c
@@ -554,21 +554,27 @@ test_album_feed (GDataService *service)
static void
test_query_all_albums (GDataService *service)
{
- GDataFeed *album_feed;
- GDataFeed *photo_feed;
+ GDataFeed *album_feed, *photo_feed;
+ GDataQuery *query;
GError *error = NULL;
GList *albums;
GDataEntry *entry;
GDataPicasaWebAlbum *album;
- /* TODO: find out whether I need to free this; probably */
+ /* Test a query with a "q" parameter; it should fail */
+ query = gdata_picasaweb_query_new ("foobar");
+ album_feed = gdata_picasaweb_service_query_all_albums (GDATA_PICASAWEB_SERVICE (service), query, NULL, NULL, NULL, NULL, &error);
+ g_assert_error (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_BAD_QUERY_PARAMETER);
+ g_assert (album_feed == NULL);
+ g_clear_error (&error);
+
+ /* Now try a proper query */
album_feed = gdata_picasaweb_service_query_all_albums (GDATA_PICASAWEB_SERVICE (service), NULL, NULL, NULL, NULL, NULL, &error);
g_assert_no_error (error);
g_assert (GDATA_IS_FEED (album_feed));
g_clear_error (&error);
albums = gdata_feed_get_entries (album_feed);
- /* g_object_unref (feed); TODO find out why this complains about not being an object */
entry = GDATA_ENTRY (g_list_nth_data (albums, TEST_ALBUM_INDEX));
album = GDATA_PICASAWEB_ALBUM (entry);
@@ -578,10 +584,8 @@ test_query_all_albums (GDataService *service)
g_assert (GDATA_IS_FEED (photo_feed));
g_clear_error (&error);
- /*g_object_unref(photo_feed);
- g_object_unref(album_feed);*/
-
- g_list_free(albums);
+ g_object_unref (photo_feed);
+ g_object_unref (album_feed);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]