[grilo/0.1.x] net: Add "user-agent" property



commit 0045b23b0b232401269ee5e0c2f83b967146a9a7
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Wed May 16 13:31:10 2012 +0000

    net: Add "user-agent" property
    
    This fixes https://bugzilla.gnome.org/show_bug.cgi?id=672923
    
    Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>

 libs/net/grl-net-wc.c |   23 +++++++++++++++++++++++
 libs/net/grl-net-wc.h |    3 +++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libs/net/grl-net-wc.c b/libs/net/grl-net-wc.c
index 7468d88..68c9971 100644
--- a/libs/net/grl-net-wc.c
+++ b/libs/net/grl-net-wc.c
@@ -52,6 +52,7 @@ enum {
   PROP_THROTTLING,
   PROP_CACHE,
   PROP_CACHE_SIZE,
+  PROP_USER_AGENT,
 };
 
 #define GRL_NET_WC_GET_PRIVATE(object)			\
@@ -145,6 +146,20 @@ grl_net_wc_class_init (GrlNetWcClass *klass)
                                                       G_PARAM_READWRITE |
                                                       G_PARAM_CONSTRUCT |
                                                       G_PARAM_STATIC_STRINGS));
+  /**
+   * GrlNetWc::user-agent
+   *
+   * User agent identifier.
+   */
+  g_object_class_install_property (g_klass,
+                                   PROP_USER_AGENT,
+                                   g_param_spec_string ("user-agent",
+                                                        "User Agent",
+                                                        "User agent identifier",
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT |
+                                                        G_PARAM_STATIC_STRINGS));
 }
 
 /*
@@ -216,6 +231,11 @@ grl_net_wc_set_property (GObject *object,
   case PROP_CACHE_SIZE:
     grl_net_wc_set_cache_size (wc, g_value_get_uint (value));
     break;
+  case PROP_USER_AGENT:
+    g_object_set (G_OBJECT (wc->priv->session),
+                  "user-agent", g_value_get_string (value),
+                  NULL);
+    break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (wc, propid, pspec);
   }
@@ -244,6 +264,9 @@ grl_net_wc_get_property (GObject *object,
   case PROP_CACHE_SIZE:
     g_value_set_uint (value, cache_get_size (wc));
     break;
+  case PROP_USER_AGENT:
+    g_object_get_property (G_OBJECT (wc->priv->session), "user_agent", value);
+    break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (wc, propid, pspec);
   }
diff --git a/libs/net/grl-net-wc.h b/libs/net/grl-net-wc.h
index fc472e0..abc7630 100644
--- a/libs/net/grl-net-wc.h
+++ b/libs/net/grl-net-wc.h
@@ -138,6 +138,9 @@ void grl_net_wc_set_cache (GrlNetWc *self,
 void grl_net_wc_set_cache_size (GrlNetWc *self,
                                 guint cache_size);
 
+void grl_net_wc_set_user_agent (GrlNetWc *self,
+                                const gchar *user_agent);
+
 void grl_net_wc_flush_delayed_requests (GrlNetWc *self);
 
 G_END_DECLS



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