[librest] flickr: Fix function setting regression



commit fe1a864e4a6739ad07d890cd47f8cf180a3d1cdf
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Tue Sep 2 18:07:03 2014 +0200

    flickr: Fix function setting regression
    
    Since commit c66b6d, RestProxyCall::url is regenerated after calling the
    RestProxyCall::prepare virtual method. This breaks the flickr code as
    it needs to reset RestProxyCall::url in order to remove the function
    from it.
    It used to do that by directly accessing RestProxyCall private
    data. Since c66b6d, this can be solved using only public methods as
    if the function is reset on the RestProxyCall in ::prepare, ::url will
    be regenerated to reflect that after ::prepare and ::serialize_params
    have been called.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708359

 rest-extras/flickr-proxy-call.c |   12 ++++++++----
 rest-extras/flickr-proxy.c      |    4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/rest-extras/flickr-proxy-call.c b/rest-extras/flickr-proxy-call.c
index a9bc6f7..d03f919 100644
--- a/rest-extras/flickr-proxy-call.c
+++ b/rest-extras/flickr-proxy-call.c
@@ -70,13 +70,17 @@ _prepare (RestProxyCall *call, GError **error)
   priv = FLICKR_PROXY_GET_PRIVATE (proxy);
   call_priv = call->priv;
 
-  /* We need to reset the URL because Flickr puts the function in the parameters */
 
   if (GET_PRIVATE (call)->upload) {
-    call_priv->url = g_strdup ("http://api.flickr.com/services/upload/";);
+    rest_proxy_bind (REST_PROXY(proxy), "upload");
+    rest_proxy_call_set_function (call, NULL);
   } else {
-    call_priv->url = g_strdup ("http://api.flickr.com/services/rest/";);
-    rest_proxy_call_add_param (call, "method", call_priv->function);
+    rest_proxy_bind (REST_PROXY(proxy), "rest");
+    rest_proxy_call_add_param (call, "method",
+                               rest_proxy_call_get_function (call));
+  /* We need to reset the function because Flickr puts the function in the
+   * parameters, not in the base URL */
+    rest_proxy_call_set_function (call, NULL);
   }
 
   rest_proxy_call_add_param (call, "api_key", priv->api_key);
diff --git a/rest-extras/flickr-proxy.c b/rest-extras/flickr-proxy.c
index 5b7d960..48f1c86 100644
--- a/rest-extras/flickr-proxy.c
+++ b/rest-extras/flickr-proxy.c
@@ -188,8 +188,8 @@ flickr_proxy_new_with_token (const char *api_key,
                        "api-key", api_key,
                        "shared-secret", shared_secret,
                        "token", token,
-                       "url-format", "http://api.flickr.com/services/rest/";,
-                       "binding-required", FALSE,
+                       "url-format", "http://api.flickr.com/services/%s/";,
+                       "binding-required", TRUE,
                        NULL);
 }
 


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