[grilo/0.1.x] net: detect in runtime use-thread-context property



commit 7afcee64755938f926e8e91d21ca5f8e5491f11e
Author: VÃctor Manuel JÃquez Leal <vjaquez igalia com>
Date:   Thu Apr 26 21:57:51 2012 +0200

    net: detect in runtime use-thread-context property
    
    Instead of messing with autotools, it is better to know in run-time if
    the required property is available.
    
    Revert "grl-net: Use libsoup context threads for libsoup 2.39 or above"
    This reverts commit 98fb065f9d52092d2cbf29dcdc1784f9ff087e74.
    
    Signed-off-by: VÃctor Manuel JÃquez Leal <vjaquez igalia com>

 configure.ac          |    6 ------
 libs/net/Makefile.am  |    5 -----
 libs/net/grl-net-wc.c |   21 ++++++++++++++++-----
 3 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a278ad1..edf7730 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,11 +119,6 @@ PKG_CHECK_MODULES(NET, libsoup-2.4,
 PKG_CHECK_EXISTS([libsoup-2.4 >= 2.33.4],
 		 [HAVE_CACHED_LIBSOUP=yes],
 		 [HAVE_CACHED_LIBSOUP=no])
-
-PKG_CHECK_EXISTS([libsoup-2.4 >= 2.39.0],
-       [HAVE_THREAD_CONTEXT_LIBSOUP=yes],
-       [HAVE_THREAD_CONTEXT_LIBSOUP=no])
-
 AC_ARG_ENABLE([grl_net],
         AS_HELP_STRING([--enable-grl-net],
                 [Enable Grilo Net library (default: auto)]),
@@ -142,7 +137,6 @@ AC_ARG_ENABLE([grl_net],
 
 AM_CONDITIONAL(BUILD_GRILO_NET, test "x$HAVE_LIBSOUP" = "xyes")
 AM_CONDITIONAL(BUILD_GRILO_NET_WITH_CACHE, test "x$HAVE_CACHED_LIBSOUP" = "xyes")
-AM_CONDITIONAL(BUILD_GRILO_NET_WITH_THREAD_CONTEXT, test "x$HAVE_THREAD_CONTEXT_LIBSOUP" = "xyes")
 
 # ----------------------------------------------------------
 # DEBUG SUPPORT
diff --git a/libs/net/Makefile.am b/libs/net/Makefile.am
index 27f0c76..5414369 100644
--- a/libs/net/Makefile.am
+++ b/libs/net/Makefile.am
@@ -25,11 +25,6 @@ libgrlnet_ GRL_MAJORMINOR@_la_CFLAGS += \
 	-DLIBSOUP_WITH_CACHE
 endif
 
-if BUILD_GRILO_NET_WITH_THREAD_CONTEXT
-libgrlnet_ GRL_MAJORMINOR@_la_CFLAGS += \
-	-DLIBSOUP_WITH_THREAD_CONTEXT
-endif
-
 libgrlnet_ GRL_MAJORMINOR@_la_LIBADD =	\
 	$(top_builddir)/src/lib GRL_NAME@.la	\
 	$(DEPS_LIBS)				\
diff --git a/libs/net/grl-net-wc.c b/libs/net/grl-net-wc.c
index 7b540f7..b822a0f 100644
--- a/libs/net/grl-net-wc.c
+++ b/libs/net/grl-net-wc.c
@@ -195,6 +195,21 @@ grl_net_wc_class_init (GrlNetWcClass *klass)
                                                       G_PARAM_STATIC_STRINGS));
 }
 
+/*
+ * use-thread-context is available for libsoup-2.4 >= 2.39.0
+ * We check in run-time if it's available
+ */
+static void
+set_thread_context (GrlNetWc *self)
+{
+    GrlNetWcPrivate *priv = self->priv;
+    GObjectClass *klass = G_OBJECT_GET_CLASS (priv->session);
+    GParamSpec *spec = g_object_class_find_property (klass,
+                                                     "use-thread-context");
+    if (spec)
+      g_object_set (priv->session, "use-thread-context", TRUE, NULL);
+}
+
 static void
 grl_net_wc_init (GrlNetWc *wc)
 {
@@ -205,11 +220,7 @@ grl_net_wc_init (GrlNetWc *wc)
   wc->priv->session = soup_session_async_new ();
   wc->priv->pending = g_queue_new ();
 
-#ifdef LIBSOUP_WITH_THREAD_CONTEXT
-  g_object_set (wc->priv->session,
-                SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
-                NULL);
-#endif
+  set_thread_context (wc);
 
 #ifdef LIBSOUP_USE_UNSTABLE_REQUEST_API
   wc->priv->requester = soup_requester_new();



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