[libgdata] Bug 615506 — totem: Youtube Search lasts forever while playing Video
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] Bug 615506 — totem: Youtube Search lasts forever while playing Video
- Date: Fri, 16 Apr 2010 18:47:01 +0000 (UTC)
commit e54748533b841ffa9decbb0245b1bdb39a86ae3e
Author: Philip Withnall <philip tecnocode co uk>
Date: Fri Apr 16 19:45:30 2010 +0100
Bug 615506 â?? totem: Youtube Search lasts forever while playing Video
Add a #GDataService:timeout property, proxying the #SoupSession:timeout
property, and allowing network requests to return with
%GDATA_SERVICE_ERROR_NETWORK_ERROR if the timeout is exceeded.
Helps: bgo#615506
docs/reference/gdata-sections.txt | 2 +
gdata/gdata-service.c | 76 ++++++++++++++++++++++++++++++++++++-
gdata/gdata-service.h | 3 +
gdata/gdata.symbols | 2 +
4 files changed, 81 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 2bccd5d..f6c6b03 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -32,6 +32,8 @@ gdata_service_get_username
gdata_service_get_password
gdata_service_get_proxy_uri
gdata_service_set_proxy_uri
+gdata_service_get_timeout
+gdata_service_set_timeout
<SUBSECTION Standard>
GDATA_SERVICE
GDATA_IS_SERVICE
diff --git a/gdata/gdata-service.c b/gdata/gdata-service.c
index a8ad4f8..bca00f0 100644
--- a/gdata/gdata-service.c
+++ b/gdata/gdata-service.c
@@ -67,6 +67,7 @@ static void real_append_query_headers (GDataService *self, SoupMessage *message)
static void real_parse_error_response (GDataService *self, GDataOperationType operation_type, guint status, const gchar *reason_phrase,
const gchar *response_body, gint length, GError **error);
static void notify_proxy_uri_cb (GObject *gobject, GParamSpec *pspec, GObject *self);
+static void notify_timeout_cb (GObject *gobject, GParamSpec *pspec, GObject *self);
static void debug_handler (const char *log_domain, GLogLevelFlags log_level, const char *message, gpointer user_data);
static void soup_log_printer (SoupLogger *logger, SoupLoggerLogLevel level, char direction, const char *data, gpointer user_data);
@@ -85,7 +86,8 @@ enum {
PROP_USERNAME,
PROP_PASSWORD,
PROP_AUTHENTICATED,
- PROP_PROXY_URI
+ PROP_PROXY_URI,
+ PROP_TIMEOUT
};
enum {
@@ -177,6 +179,22 @@ gdata_service_class_init (GDataServiceClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
+ * GDataService:timeout:
+ *
+ * A timeout, in seconds, for network operations. If the timeout is exceeded, the operation will be cancelled and
+ * %GDATA_SERVICE_ERROR_NETWORK_ERROR will be returned.
+ *
+ * If the timeout is <code class="literal">0</code>, operations will never time out.
+ *
+ * Since: 0.7.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_TIMEOUT,
+ g_param_spec_uint ("timeout",
+ "Timeout", "A timeout, in seconds, for network operations.",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
* GDataService::captcha-challenge:
* @service: the #GDataService which received the challenge
* @uri: the URI of the CAPTCHA image to be used
@@ -233,8 +251,9 @@ gdata_service_init (GDataService *self)
soup_session_add_feature (self->priv->session, SOUP_SESSION_FEATURE (logger));
}
- /* Proxy the SoupSession's proxy-uri property */
+ /* Proxy the SoupSession's proxy-uri and timeout properties */
g_signal_connect (self->priv->session, "notify::proxy-uri", (GCallback) notify_proxy_uri_cb, self);
+ g_signal_connect (self->priv->session, "notify::timeout", (GCallback) notify_timeout_cb, self);
}
static void
@@ -285,6 +304,9 @@ gdata_service_get_property (GObject *object, guint property_id, GValue *value, G
case PROP_PROXY_URI:
g_value_set_boxed (value, gdata_service_get_proxy_uri (GDATA_SERVICE (object)));
break;
+ case PROP_TIMEOUT:
+ g_value_set_uint (value, gdata_service_get_timeout (GDATA_SERVICE (object)));
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -304,6 +326,9 @@ gdata_service_set_property (GObject *object, guint property_id, const GValue *va
case PROP_PROXY_URI:
gdata_service_set_proxy_uri (GDATA_SERVICE (object), g_value_get_boxed (value));
break;
+ case PROP_TIMEOUT:
+ gdata_service_set_timeout (GDATA_SERVICE (object), g_value_get_uint (value));
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1889,6 +1914,53 @@ gdata_service_set_proxy_uri (GDataService *self, SoupURI *proxy_uri)
g_object_notify (G_OBJECT (self), "proxy-uri");
}
+static void
+notify_timeout_cb (GObject *gobject, GParamSpec *pspec, GObject *self)
+{
+ g_object_notify (self, "timeout");
+}
+
+/**
+ * gdata_service_get_timeout:
+ * @self: a #GDataService
+ *
+ * Gets the #GDataService:timeout property; the network timeout, in seconds.
+ *
+ * Return value: the timeout, or <code class="literal">0</code>
+ *
+ * Since: 0.7.0
+ **/
+guint
+gdata_service_get_timeout (GDataService *self)
+{
+ guint timeout;
+
+ g_return_val_if_fail (GDATA_IS_SERVICE (self), 0);
+
+ g_object_get (self->priv->session, SOUP_SESSION_TIMEOUT, &timeout, NULL);
+
+ return timeout;
+}
+
+/**
+ * gdata_service_set_timeout:
+ * @self: a #GDataService
+ * @timeout: the timeout, or <code class="literal">0</code>
+ *
+ * Sets the #GDataService:timeout property; the network timeout, in seconds.
+ *
+ * If @timeout is <code class="literal">0</code>, network operations will never time out.
+ *
+ * Since: 0.7.0
+ **/
+void
+gdata_service_set_timeout (GDataService *self, guint timeout)
+{
+ g_return_if_fail (GDATA_IS_SERVICE (self));
+ g_object_set (self->priv->session, SOUP_SESSION_TIMEOUT, timeout, NULL);
+ g_object_notify (G_OBJECT (self), "timeout");
+}
+
/**
* gdata_service_is_authenticated:
* @self: a #GDataService
diff --git a/gdata/gdata-service.h b/gdata/gdata-service.h
index 1e9cbdf..d3562d7 100644
--- a/gdata/gdata-service.h
+++ b/gdata/gdata-service.h
@@ -226,6 +226,9 @@ gboolean gdata_service_delete_entry_finish (GDataService *self, GAsyncResult *as
SoupURI *gdata_service_get_proxy_uri (GDataService *self);
void gdata_service_set_proxy_uri (GDataService *self, SoupURI *proxy_uri);
+guint gdata_service_get_timeout (GDataService *self);
+void gdata_service_set_timeout (GDataService *self, guint timeout);
+
gboolean gdata_service_is_authenticated (GDataService *self);
const gchar *gdata_service_get_client_id (GDataService *self);
const gchar *gdata_service_get_username (GDataService *self);
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 83938a2..22c8f4f 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -830,3 +830,5 @@ gdata_gcontact_language_set_label
gdata_contacts_contact_add_language
gdata_contacts_contact_get_languages
gdata_contacts_contact_remove_all_languages
+gdata_service_get_timeout
+gdata_service_set_timeout
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]