[libsocialweb: 2/7] facebook: Support upload progress.
- From: Eitan Isaacson <eitani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsocialweb: 2/7] facebook: Support upload progress.
- Date: Wed, 13 Apr 2011 17:09:25 +0000 (UTC)
commit 8064080f24bb8bbb106f86575db7835ab94c6956
Author: Eitan Isaacson <eitan isaacson collabora co uk>
Date: Tue Apr 5 18:58:34 2011 -0700
facebook: Support upload progress.
services/facebook/facebook.c | 38 +++++++++++++++++++++++---------------
1 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/services/facebook/facebook.c b/services/facebook/facebook.c
index 6bfef4a..0e3825f 100644
--- a/services/facebook/facebook.c
+++ b/services/facebook/facebook.c
@@ -640,12 +640,12 @@ status_update_iface_init (gpointer g_iface,
}
static gint
-_upload_file (SwServiceFacebook *self,
- MediaType upload_type,
- const gchar *filename,
- GHashTable *fields,
- RestProxyCallAsyncCallback upload_cb,
- GError **error)
+_upload_file (SwServiceFacebook *self,
+ MediaType upload_type,
+ const gchar *filename,
+ GHashTable *fields,
+ RestProxyCallUploadCallback upload_cb,
+ GError **error)
{
SwServiceFacebookPrivate *priv = self->priv;
RestProxyCall *call = NULL;
@@ -731,11 +731,11 @@ _upload_file (SwServiceFacebook *self,
opid = sw_next_opid ();
- rest_proxy_call_async (call,
- upload_cb,
- G_OBJECT (self),
- GINT_TO_POINTER (opid),
- NULL);
+ rest_proxy_call_upload (call,
+ upload_cb,
+ G_OBJECT (self),
+ GINT_TO_POINTER (opid),
+ NULL);
OUT:
@@ -753,6 +753,8 @@ _upload_file (SwServiceFacebook *self,
static void
_upload_photo_cb (RestProxyCall *call,
+ gsize total,
+ gsize uploaded,
const GError *error,
GObject *weak_object,
gpointer user_data)
@@ -764,7 +766,9 @@ _upload_photo_cb (RestProxyCall *call,
sw_photo_upload_iface_emit_photo_upload_progress (facebook, opid, -1,
error->message);
} else {
- sw_photo_upload_iface_emit_photo_upload_progress (facebook, opid, 100, "");
+ gint percent = (gdouble) uploaded / (gdouble) total * 100;
+ sw_photo_upload_iface_emit_photo_upload_progress (facebook, opid, percent,
+ "");
}
}
@@ -779,7 +783,7 @@ _facebook_photo_upload_upload_photo (SwPhotoUploadIface *self,
GError *error = NULL;
opid = _upload_file (facebook, PHOTO, filename, fields,
- (RestProxyCallAsyncCallback) _upload_photo_cb, &error);
+ (RestProxyCallUploadCallback) _upload_photo_cb, &error);
if (error) {
dbus_g_method_return_error (context, error);
@@ -802,6 +806,8 @@ photo_upload_iface_init (gpointer g_iface,
static void
_upload_video_cb (RestProxyCall *call,
+ gsize total,
+ gsize uploaded,
const GError *error,
GObject *weak_object,
gpointer user_data)
@@ -813,7 +819,9 @@ _upload_video_cb (RestProxyCall *call,
sw_video_upload_iface_emit_video_upload_progress (facebook, opid, -1,
error->message);
} else {
- sw_video_upload_iface_emit_video_upload_progress (facebook, opid, 100, "");
+ gint percent = (gdouble) uploaded / (gdouble) total * 100;
+ sw_video_upload_iface_emit_video_upload_progress (facebook, opid, percent,
+ "");
}
}
@@ -828,7 +836,7 @@ _facebook_video_upload_upload_video (SwVideoUploadIface *self,
GError *error = NULL;
opid = _upload_file (facebook, VIDEO, filename, fields,
- (RestProxyCallAsyncCallback) _upload_video_cb, &error);
+ (RestProxyCallUploadCallback) _upload_video_cb, &error);
if (error) {
dbus_g_method_return_error (context, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]