[librest/wip/baedert/tests: 1/4] Use goffset for message sizes



commit 3b669e5390123d7a259d5f402d6cabb50c88b858
Author: Timm Bäder <mail baedert org>
Date:   Tue Jul 26 14:57:27 2016 +0200

    Use goffset for message sizes
    
    That's what libsoup uses as well.

 rest-extras/youtube-proxy.c |    2 +-
 rest-extras/youtube-proxy.h |    2 +-
 rest/rest-proxy-call.c      |   27 ++++++++-------------------
 rest/rest-proxy-call.h      |   17 ++++++++---------
 4 files changed, 18 insertions(+), 30 deletions(-)
---
diff --git a/rest-extras/youtube-proxy.c b/rest-extras/youtube-proxy.c
index be0cf08..d953dd4 100644
--- a/rest-extras/youtube-proxy.c
+++ b/rest-extras/youtube-proxy.c
@@ -245,7 +245,7 @@ typedef struct {
   SoupMessage *message;
   GObject *weak_object;
   gpointer user_data;
-  gsize uploaded;
+  goffset uploaded;
 } YoutubeProxyUploadClosure;
 
 static void
diff --git a/rest-extras/youtube-proxy.h b/rest-extras/youtube-proxy.h
index 1fe6c20..3c8892a 100644
--- a/rest-extras/youtube-proxy.h
+++ b/rest-extras/youtube-proxy.h
@@ -78,7 +78,7 @@ void youtube_proxy_set_user_auth (YoutubeProxy *proxy,
 typedef void (*YoutubeProxyUploadCallback)(YoutubeProxy  *proxy,
                                            const gchar   *payload,
                                            gsize          total,
-                                           gsize          uploaded,
+                                           goffset        uploaded,
                                            const GError  *error,
                                            GObject       *weak_object,
                                            gpointer       user_data);
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index ecbcd90..6c68897 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -53,7 +53,7 @@ struct _RestProxyCallUploadClosure {
   GObject *weak_object;
   gpointer userdata;
   SoupMessage *message;
-  gsize uploaded;
+  goffset uploaded;
 };
 typedef struct _RestProxyCallUploadClosure RestProxyCallUploadClosure;
 
@@ -645,14 +645,15 @@ finish_call (RestProxyCall *call, SoupMessage *message, GError **error)
 static void
 _continuous_call_message_completed_cb (SoupSession *session,
                                        SoupMessage *message,
-                                       gpointer     userdata)
+                                       gpointer     user_data)
 {
+  GTask *task = user_data;
   RestProxyCallContinuousClosure *closure;
   RestProxyCall *call;
   RestProxyCallPrivate *priv;
   GError *error = NULL;
 
-  closure = (RestProxyCallContinuousClosure *)userdata;
+  closure = (RestProxyCallContinuousClosure *)g_task_get_task_data (task);
   call = closure->call;
   priv = GET_PRIVATE (call);
 
@@ -661,22 +662,10 @@ _continuous_call_message_completed_cb (SoupSession *session,
 
   _handle_error_from_message (message, &error);
 
-  closure->callback (closure->call,
-                     NULL,
-                     0,
-                     error,
-                     closure->weak_object,
-                     closure->userdata);
-
-  g_clear_error (&error);
-
-  /* Success. We don't need the weak reference any more */
-  if (closure->weak_object)
-  {
-    g_object_weak_unref (closure->weak_object,
-        (GWeakNotify)_call_async_weak_notify_cb,
-        closure);
-  }
+  if (error != NULL)
+    g_task_return_error (task, error);
+  else
+    g_task_return_boolean (task, TRUE);
 
   priv->cur_call_closure = NULL;
   g_object_unref (closure->call);
diff --git a/rest/rest-proxy-call.h b/rest/rest-proxy-call.h
index f8ff714..4c09bd1 100644
--- a/rest/rest-proxy-call.h
+++ b/rest/rest-proxy-call.h
@@ -150,7 +150,6 @@ RestParams *rest_proxy_call_get_params (RestProxyCall *call);
 
 typedef void (*RestProxyCallAsyncCallback)(RestProxyCall *call,
                                            const GError  *error,
-                                           GObject       *weak_object,
                                            gpointer       userdata);
 
 void rest_proxy_call_invoke_async (RestProxyCall       *call,
@@ -166,25 +165,25 @@ typedef void (*RestProxyCallContinuousCallback) (RestProxyCall *call,
                                                  const gchar   *buf,
                                                  gsize          len,
                                                  const GError  *error,
-                                                 GObject       *weak_object,
                                                  gpointer       userdata);
 
-gboolean rest_proxy_call_continuous (RestProxyCall                    *call,
-                                     RestProxyCallContinuousCallback   callback,
-                                     GObject                          *weak_object,
-                                     gpointer                          userdata,
-                                     GError                          **error);
+void rest_proxy_call_continuous (RestProxyCall                    *call,
+                                 RestProxyCallContinuousCallback   continuous_callback,
+                                 GCancellable                     *cancellable,
+                                 GAsyncReadyCallback               callback,
+                                 gpointer                          user_data);
+gboolean rest_proxy_call_continuous_finish (RestProxyCall *call,
+                                            GAsyncResult  *result,
+                                            GError        **error);
 
 typedef void (*RestProxyCallUploadCallback) (RestProxyCall *call,
                                              gsize          total,
                                              gsize          uploaded,
                                              const GError  *error,
-                                             GObject       *weak_object,
                                              gpointer       userdata);
 
 gboolean rest_proxy_call_upload (RestProxyCall                *call,
                                  RestProxyCallUploadCallback   callback,
-                                 GObject                      *weak_object,
                                  gpointer                      userdata,
                                  GError                      **error);
 


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