[gthumb] web uploaders: allow to cancel a photo upload
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] web uploaders: allow to cancel a photo upload
- Date: Fri, 2 Sep 2011 13:36:21 +0000 (UTC)
commit affae85c989dba69ce180cda70f6b25309677b15
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Sep 2 14:25:47 2011 +0200
web uploaders: allow to cancel a photo upload
extensions/facebook/facebook-connection.c | 12 +++++++++++-
extensions/flicker/flickr-connection.c | 12 +++++++++++-
extensions/oauth/oauth-connection.c | 12 +++++++++++-
extensions/picasaweb/google-connection.c | 16 +++++++++++++++-
4 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/extensions/facebook/facebook-connection.c b/extensions/facebook/facebook-connection.c
index ead45ec..fbc005a 100644
--- a/extensions/facebook/facebook-connection.c
+++ b/extensions/facebook/facebook-connection.c
@@ -51,6 +51,7 @@ facebook_connection_error_quark (void)
struct _FacebookConnectionPrivate
{
SoupSession *session;
+ SoupMessage *msg;
char *token;
char *secret;
char *session_key;
@@ -96,7 +97,12 @@ facebook_connection_exec (GthTask *base)
static void
facebook_connection_cancelled (GthTask *base)
{
- /* void */
+ FacebookConnection *self = FACEBOOK_CONNECTION (base);
+
+ if ((self->priv->session == NULL) || (self->priv->msg == NULL))
+ return;
+
+ soup_session_cancel_message (self->priv->session, self->priv->msg, SOUP_STATUS_CANCELLED);
}
@@ -123,6 +129,7 @@ facebook_connection_init (FacebookConnection *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FACEBOOK_TYPE_CONNECTION, FacebookConnectionPrivate);
self->priv->session = NULL;
+ self->priv->msg = NULL;
self->priv->token = NULL;
self->priv->secret = NULL;
self->priv->session_key = NULL;
@@ -207,6 +214,9 @@ facebook_connection_send_message (FacebookConnection *self,
user_data,
source_tag);
+ self->priv->msg = msg;
+ g_object_add_weak_pointer (G_OBJECT (msg), (gpointer *) &self->priv->msg);
+
soup_session_queue_message (self->priv->session,
msg,
soup_session_cb,
diff --git a/extensions/flicker/flickr-connection.c b/extensions/flicker/flickr-connection.c
index 6a251fe..d3c3d77 100644
--- a/extensions/flicker/flickr-connection.c
+++ b/extensions/flicker/flickr-connection.c
@@ -48,6 +48,7 @@ flickr_connection_error_quark (void)
struct _FlickrConnectionPrivate
{
SoupSession *session;
+ SoupMessage *msg;
char *frob;
char *token;
char *username;
@@ -91,7 +92,12 @@ flickr_connection_exec (GthTask *base)
static void
flickr_connection_cancelled (GthTask *base)
{
- /* void */
+ FlickrConnection *self = FLICKR_CONNECTION (base);
+
+ if ((self->priv->session == NULL) || (self->priv->msg == NULL))
+ return;
+
+ soup_session_cancel_message (self->priv->session, self->priv->msg, SOUP_STATUS_CANCELLED);
}
@@ -118,6 +124,7 @@ flickr_connection_init (FlickrConnection *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FLICKR_TYPE_CONNECTION, FlickrConnectionPrivate);
self->priv->session = NULL;
+ self->priv->msg = NULL;
self->priv->username = NULL;
self->priv->user_id = NULL;
self->priv->token = NULL;
@@ -213,6 +220,9 @@ flickr_connection_send_message (FlickrConnection *self,
user_data,
source_tag);
+ self->priv->msg = msg;
+ g_object_add_weak_pointer (G_OBJECT (msg), (gpointer *) &self->priv->msg);
+
soup_session_queue_message (self->priv->session,
msg,
soup_session_cb,
diff --git a/extensions/oauth/oauth-connection.c b/extensions/oauth/oauth-connection.c
index c9e15b8..4a7a48f 100644
--- a/extensions/oauth/oauth-connection.c
+++ b/extensions/oauth/oauth-connection.c
@@ -49,6 +49,7 @@ oauth_connection_error_quark (void)
struct _OAuthConnectionPrivate
{
SoupSession *session;
+ SoupMessage *msg;
char *timestamp;
char *nonce;
char *signature;
@@ -92,7 +93,12 @@ oauth_connection_exec (GthTask *base)
static void
oauth_connection_cancelled (GthTask *base)
{
- /* void */
+ OAuthConnection *self = OAUTH_CONNECTION (base);
+
+ if ((self->priv->session == NULL) || (self->priv->msg == NULL))
+ return;
+
+ soup_session_cancel_message (self->priv->session, self->priv->msg, SOUP_STATUS_CANCELLED);
}
@@ -119,6 +125,7 @@ oauth_connection_init (OAuthConnection *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, OAUTH_TYPE_CONNECTION, OAuthConnectionPrivate);
self->priv->session = NULL;
+ self->priv->msg = NULL;
self->priv->timestamp = NULL;
self->priv->nonce = NULL;
self->priv->signature = NULL;
@@ -207,6 +214,9 @@ oauth_connection_send_message (OAuthConnection *self,
user_data,
source_tag);
+ self->priv->msg = msg;
+ g_object_add_weak_pointer (G_OBJECT (msg), (gpointer *) &self->priv->msg);
+
soup_session_queue_message (self->priv->session,
msg,
soup_session_cb,
diff --git a/extensions/picasaweb/google-connection.c b/extensions/picasaweb/google-connection.c
index 1648257..dfd134b 100644
--- a/extensions/picasaweb/google-connection.c
+++ b/extensions/picasaweb/google-connection.c
@@ -49,6 +49,7 @@ struct _GoogleConnectionPrivate
{
char *service;
SoupSession *session;
+ SoupMessage *msg;
char *token;
char *challange_url;
GCancellable *cancellable;
@@ -87,7 +88,12 @@ google_connection_exec (GthTask *base)
static void
google_connection_cancelled (GthTask *base)
{
- /* void */
+ GoogleConnection *self = GOOGLE_CONNECTION (base);
+
+ if ((self->priv->session == NULL) || (self->priv->msg == NULL))
+ return;
+
+ soup_session_cancel_message (self->priv->session, self->priv->msg, SOUP_STATUS_CANCELLED);
}
@@ -115,6 +121,7 @@ google_connection_init (GoogleConnection *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GOOGLE_TYPE_CONNECTION, GoogleConnectionPrivate);
self->priv->service = NULL;
self->priv->session = NULL;
+ self->priv->msg = NULL;
self->priv->token = NULL;
self->priv->challange_url = NULL;
self->priv->cancellable = NULL;
@@ -183,6 +190,9 @@ google_connection_send_message (GoogleConnection *self,
user_data,
source_tag);
+ self->priv->msg = msg;
+ g_object_add_weak_pointer (G_OBJECT (msg), (gpointer *) &self->priv->msg);
+
value = g_strconcat ("GoogleLogin auth=", self->priv->token, NULL);
soup_message_headers_replace (msg->request_headers, "Authorization", value);
g_free (value);
@@ -372,9 +382,13 @@ google_connection_connect (GoogleConnection *self,
g_hash_table_insert (data_set, "logintoken", self->priv->token);
if (challange != NULL)
g_hash_table_insert (data_set, "logincaptcha", (char *) challange);
+
msg = soup_form_request_new_from_hash ("POST",
"https://www.google.com/accounts/ClientLogin",
data_set);
+ self->priv->msg = msg;
+ g_object_add_weak_pointer (G_OBJECT (msg), (gpointer *) &self->priv->msg);
+
soup_session_queue_message (self->priv->session, msg, connect_ready_cb, self);
g_hash_table_destroy (data_set);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]