[grilo-plugins] [flickr] Handle tags in search() function



commit ad1fd5c079e449a22a14ddd0985edc9b75e3843a
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Fri Jun 11 21:34:39 2010 +0200

    [flickr] Handle tags in search() function

 src/flickr/gflickr.c    |   20 ++++++++++++++++++--
 src/flickr/gflickr.h    |    1 +
 src/flickr/grl-flickr.c |    4 ++--
 3 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/flickr/gflickr.c b/src/flickr/gflickr.c
index 00d264f..588ae27 100644
--- a/src/flickr/gflickr.c
+++ b/src/flickr/gflickr.c
@@ -27,6 +27,7 @@
   "&extras=media,date_taken,owner_name,url_o,url_t"     \
   "&per_page=%d"                                        \
   "&page=%d"                                            \
+  "&tags=%s"                                            \
   "&text=%s"
 
 #define FLICKR_PHOTOS_GETINFO                   \
@@ -100,7 +101,10 @@ g_flickr_new (const gchar *api_key, const gchar *auth_token, const gchar *auth_s
 /* -------------------- PRIVATE API -------------------- */
 
 static gchar *
-get_api_sig_photos_search (GFlickr *f, const gchar *text, gint page) {
+get_api_sig_photos_search (GFlickr *f,
+                           const gchar *text,
+                           const gchar *tags,
+                           gint page) {
   gchar *signature;
   gchar *text_to_sign;
 
@@ -111,12 +115,14 @@ get_api_sig_photos_search (GFlickr *f, const gchar *text, gint page) {
                                   "method" FLICKR_PHOTOS_SEARCH_METHOD
                                   "page%d"
                                   "per_page%d"
+                                  "tags%s"
                                   "text%s",
                                   f->priv->auth_secret,
                                   f->priv->api_key,
                                   f->priv->auth_token,
                                   page,
                                   f->priv->per_page,
+                                  tags,
                                   text);
   signature = g_compute_checksum_for_string (G_CHECKSUM_MD5, text_to_sign, -1);
   g_free (text_to_sign);
@@ -342,13 +348,22 @@ g_flickr_photos_getInfo (GFlickr *f,
 void
 g_flickr_photos_search (GFlickr *f,
                         const gchar *text,
+                        const gchar *tags,
                         gint page,
                         GFlickrPhotoListCb callback,
                         gpointer user_data)
 {
   g_return_if_fail (G_IS_FLICKR (f));
 
-  gchar *api_sig = get_api_sig_photos_search (f, text, page);
+  if (!text) {
+    text = "";
+  }
+
+  if (!tags) {
+    tags = "";
+  }
+
+  gchar *api_sig = get_api_sig_photos_search (f, text, tags, page);
 
   /* Build the request */
   gchar *request = g_strdup_printf (FLICKR_PHOTOS_SEARCH,
@@ -357,6 +372,7 @@ g_flickr_photos_search (GFlickr *f,
                                     api_sig,
                                     f->priv->per_page,
                                     page,
+                                    tags,
                                     text);
   g_free (api_sig);
 
diff --git a/src/flickr/gflickr.h b/src/flickr/gflickr.h
index cc50c38..6a9dbdc 100644
--- a/src/flickr/gflickr.h
+++ b/src/flickr/gflickr.h
@@ -91,6 +91,7 @@ g_flickr_photos_getInfo (GFlickr *f,
 void
 g_flickr_photos_search (GFlickr *f,
                         const gchar *text,
+                        const gchar *tags,
                         gint page,
                         GFlickrPhotoListCb callback,
                         gpointer user_data);
diff --git a/src/flickr/grl-flickr.c b/src/flickr/grl-flickr.c
index 5cd12bd..32af640 100644
--- a/src/flickr/grl-flickr.c
+++ b/src/flickr/grl-flickr.c
@@ -294,7 +294,7 @@ search_cb (GFlickr *f, GList *photolist, gpointer user_data)
   if (sd->ss->count) {
     sd->offset = 0;
     sd->page++;
-    g_flickr_photos_search (f, sd->ss->text, sd->page, search_cb, sd);
+    g_flickr_photos_search (f, sd->ss->text, NULL, sd->page, search_cb, sd);
   } else {
     g_slice_free (SearchData, sd);
   }
@@ -352,5 +352,5 @@ grl_flickr_source_search (GrlMediaSource *source,
   sd->offset = ss->skip % per_page;
   sd->ss = ss;
 
-  g_flickr_photos_search (f, ss->text, sd->page, search_cb, sd);
+  g_flickr_photos_search (f, ss->text, NULL, sd->page, search_cb, sd);
 }



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