Added --enable-kdbus-transport flag
authorLukasz Skalski <l.skalski@partner.samsung.com>
Mon, 21 Oct 2013 11:50:22 +0000 (13:50 +0200)
committerLukasz Skalski <l.skalski@partner.samsung.com>
Fri, 25 Oct 2013 15:58:38 +0000 (17:58 +0200)
configure.ac
gio/gdbusaddress.c
gio/gdbusconnection.c
gio/gdbusprivate.c
gio/gdbusserver.c

index e61fd9e..6a268e1 100644 (file)
@@ -235,6 +235,10 @@ AC_ARG_ENABLE(gc_friendly,
               [AS_HELP_STRING([--enable-gc-friendly],
                               [turn on garbage collector friendliness [default=no]])],,
               [enable_gc_friendly=no])
+AC_ARG_ENABLE(kdbus_transport,
+              [AS_HELP_STRING([--enable-kdbus-transport],
+                             [enable kdbus transport [default=no]])],,
+              [enable_kdbus_transport=no])
 AC_ARG_ENABLE(mem_pools,
               [AS_HELP_STRING([--disable-mem-pools],
                              [disable all glib memory pools])],,
@@ -255,6 +259,12 @@ AS_IF([test "x$enable_gc_friendly" = "xyes"], [
   AC_MSG_RESULT([yes])
 ], [ AC_MSG_RESULT([no]) ])
 
+AC_MSG_CHECKING([kdbus transport])
+AS_IF([test "x$enable_kdbus_transport" = "xyes"], [
+  AC_MSG_RESULT([yes])
+  CFLAGS="$CFLAGS -DKDBUS_TRANSPORT"
+], [ AC_MSG_RESULT([no]) ])
+
 AC_MSG_CHECKING([whether to disable memory pools])
 AS_IF([test "x$disable_mem_pools" = "xno"], [
   AC_MSG_RESULT([no])
index d260785..970b36f 100644 (file)
 
 #ifdef G_OS_UNIX
 #include <gio/gunixsocketaddress.h>
+#ifdef KDBUS_TRANSPORT
 #include <gio/gkdbusconnection.h>
 #endif
+#endif
 
 #ifdef G_OS_WIN32
 #include <windows.h>
@@ -402,7 +404,11 @@ g_dbus_is_supported_address (const gchar  *string,
         goto out;
 
       supported = FALSE;
-      if ((g_strcmp0 (transport_name, "unix") == 0) || (g_strcmp0 (transport_name, "kdbus") == 0))
+      if ((g_strcmp0 (transport_name, "unix") == 0) 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT) 
+      || (g_strcmp0 (transport_name, "kdbus") == 0)
+#endif
+      )
         supported = is_valid_unix (a[n], key_value_pairs, error);
       else if (g_strcmp0 (transport_name, "tcp") == 0)
         supported = is_valid_tcp (a[n], key_value_pairs, error);
@@ -554,7 +560,11 @@ g_dbus_address_connect (const gchar   *address_entry,
     {
     }
 #ifdef G_OS_UNIX
-  else if ((g_strcmp0 (transport_name, "unix") == 0) || (g_strcmp0 (transport_name, "kdbus") == 0))
+  else if ((g_strcmp0 (transport_name, "unix") == 0)
+#ifdef KDBUS_TRANSPORT
+          || (g_strcmp0 (transport_name, "kdbus") == 0)
+#endif
+          )
     {
       const gchar *path;
       const gchar *abstract;
@@ -665,7 +675,7 @@ g_dbus_address_connect (const gchar   *address_entry,
 
   if (connectable != NULL)
     {
-
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
       if (g_strcmp0 (transport_name, "kdbus") == 0)
         {
           GKdbusConnection *connection;
@@ -687,6 +697,7 @@ g_dbus_address_connect (const gchar   *address_entry,
         }
       else
         {
+#endif
           GSocketClient *client;
           GSocketConnection *connection;
 
@@ -702,7 +713,9 @@ g_dbus_address_connect (const gchar   *address_entry,
             goto out;
 
           ret = G_IO_STREAM (connection);
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
         }
+#endif
 
       if (nonce_file != NULL)
         {
index 9f7e13a..13f5493 100644 (file)
 #include "gdbusaddress.h"
 #include "gdbusmessage.h"
 #include "gdbusconnection.h"
-#include "gkdbusconnection.h"
 #include "gdbuserror.h"
 #include "gioenumtypes.h"
 #include "gdbusintrospection.h"
 #include "gsimpleasyncresult.h"
 
 #ifdef G_OS_UNIX
+#ifdef KDBUS_TRANSPORT
+#include "gkdbusconnection.h"
+#endif
 #include "gunixconnection.h"
 #include "gunixfdmessage.h"
 #endif
@@ -1648,15 +1650,17 @@ g_dbus_connection_send_message_unlocked (GDBusConnection   *connection,
                        error))
     goto out;
 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
   if (G_IS_KDBUS_CONNECTION (connection->stream)){
     if ((connection->bus_unique_name) != NULL) 
       {
         g_dbus_message_set_sender(message, connection->bus_unique_name);
-        #ifdef KDBUS_DEBUG 
-          g_print (" KDBUS_DEBUG: (%s()): set_sender ok!\n",__FUNCTION__);
+        #ifdef KDBUS_TRANSPORT_DEBUG 
+          g_print (" KDBUS_TRANSPORT_DEBUG: (%s()): set_sender ok!\n",__FUNCTION__);
         #endif
       }
   }
+#endif
 
   blob = g_dbus_message_to_blob (message,
                                  &blob_size,
@@ -2589,10 +2593,11 @@ initable_init (GInitable     *initable,
     {
       g_assert_not_reached ();
     }
-
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
   /* TODO: [KDBUS] Our kdbus daemon doesn't support connection authentication */
   if (!G_IS_KDBUS_CONNECTION (connection->stream))
     {
+#endif
       /* Authenticate the connection */
       if (connection->flags & G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER)
         {
@@ -2630,7 +2635,9 @@ initable_init (GInitable     *initable,
           g_object_unref (connection->authentication_observer);
           connection->authentication_observer = NULL;
         }
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
   }
+#endif
   //g_output_stream_flush (G_SOCKET_CONNECTION (connection->stream)
 
   //g_debug ("haz unix fd passing powers: %d", connection->capabilities & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
index be6644c..d4bf386 100644 (file)
 #include "gsocketoutputstream.h"
 
 #ifdef G_OS_UNIX
+#ifdef KDBUS_TRANSPORT
+#include "gkdbusconnection.h"
+#endif
 #include "gunixfdmessage.h"
 #include "gunixconnection.h"
-#include "gkdbusconnection.h"
 #include "gunixcredentialsmessage.h"
 #endif
 
@@ -118,6 +120,7 @@ typedef struct
   gboolean from_mainloop;
 } ReadWithControlData;
 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
 typedef struct
 {
   GKdbus *kdbus;
@@ -141,16 +144,6 @@ read_kdbus_data_free (ReadKdbusData *data)
   g_free (data);
 }
 
-static void
-read_with_control_data_free (ReadWithControlData *data)
-{
-  g_object_unref (data->socket);
-  if (data->cancellable != NULL)
-    g_object_unref (data->cancellable);
-  g_object_unref (data->simple);
-  g_free (data);
-}
-
 static gboolean
 _g_kdbus_read_ready (GKdbus      *kdbus,
                      GIOCondition  condition,
@@ -182,6 +175,17 @@ _g_kdbus_read_ready (GKdbus      *kdbus,
 
   return FALSE;
 }
+#endif
+
+static void
+read_with_control_data_free (ReadWithControlData *data)
+{
+  g_object_unref (data->socket);
+  if (data->cancellable != NULL)
+    g_object_unref (data->cancellable);
+  g_object_unref (data->simple);
+  g_free (data);
+}
 
 static gboolean
 _g_socket_read_with_control_messages_ready (GSocket      *socket,
@@ -223,6 +227,7 @@ _g_socket_read_with_control_messages_ready (GSocket      *socket,
   return FALSE;
 }
 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
 static void
 _g_kdbus_read (GKdbus                  *kdbus,
                void                    *buffer,
@@ -257,6 +262,7 @@ _g_kdbus_read (GKdbus                  *kdbus,
   g_source_attach (source, g_main_context_get_thread_default ());
   g_source_unref (source);
 }
+#endif
 
 static void
 _g_socket_read_with_control_messages (GSocket                 *socket,
@@ -306,6 +312,7 @@ _g_socket_read_with_control_messages (GSocket                 *socket,
     }
 }
 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
 static gssize
 _g_kdbus_read_finish (GKdbus       *kdbus,
                                              GAsyncResult  *result,
@@ -321,6 +328,7 @@ _g_kdbus_read_finish (GKdbus       *kdbus,
   else
     return g_simple_async_result_get_op_res_gssize (simple);
 }
+#endif
 
 static gssize
 _g_socket_read_with_control_messages_finish (GSocket       *socket,
@@ -473,7 +481,9 @@ struct GDBusWorker
 
   /* if GSocket and GKdbus are NULL, stream is GSocketConnection */
   GSocket *socket;
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
   GKdbus  *kdbus;
+#endif
 
   /* used for reading */
   GMutex                              read_lock;
@@ -836,9 +846,11 @@ _g_dbus_worker_do_read_cb (GInputStream  *input_stream,
 
   worker->read_buffer_cur_size += bytes_read;
 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
   /* For KDBUS transport we don't have to read message header */
   if (G_IS_KDBUS_CONNECTION (worker->stream))
     worker->read_buffer_bytes_wanted = worker->read_buffer_cur_size;
+#endif
 
   if (worker->read_buffer_bytes_wanted == worker->read_buffer_cur_size)
     {
@@ -959,6 +971,7 @@ _g_dbus_worker_do_read_unlocked (GDBusWorker *worker)
   /* ensure we have a (big enough) buffer */
   if (worker->read_buffer == NULL || worker->read_buffer_bytes_wanted > worker->read_buffer_allocated_size)
     {
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
       if (G_IS_KDBUS_CONNECTION (worker->stream))
         {
           /* For KDBUS transport we have to alloc buffer only once - DBUS_MAXIMUM_MESSAGE_LENGTH=2^27 */
@@ -967,10 +980,13 @@ _g_dbus_worker_do_read_unlocked (GDBusWorker *worker)
         }
       else
         {
+#endif
           /* TODO: 4096 is randomly chosen; might want a better chosen default minimum */
           worker->read_buffer_allocated_size = MAX (worker->read_buffer_bytes_wanted, 4096);
           worker->read_buffer = g_realloc (worker->read_buffer, worker->read_buffer_allocated_size);
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
         }
+#endif
     }
 
   if (G_IS_KDBUS_CONNECTION (worker->stream))
@@ -1126,6 +1142,7 @@ write_message_continue_writing (MessageToWriteData *data)
   simple = data->simple;
 #endif
 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
   if (G_IS_KDBUS_CONNECTION (data->worker->stream))
     {
       GError *error;
@@ -1139,6 +1156,7 @@ write_message_continue_writing (MessageToWriteData *data)
     }
   else
     {
+#endif
       GOutputStream *ostream;
 #ifdef G_OS_UNIX
       GUnixFDList *fd_list;
@@ -1258,7 +1276,10 @@ write_message_continue_writing (MessageToWriteData *data)
                                         write_message_async_cb,
                                         data);
          }
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
     }
+#endif
+
 #ifdef G_OS_UNIX
  out:
 #endif
@@ -1600,9 +1621,11 @@ continue_writing (GDBusWorker *worker)
       worker->close_expected = TRUE;
       worker->output_pending = PENDING_CLOSE;
 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
       if (G_IS_KDBUS_CONNECTION (worker->stream))
           g_kdbus_connection_close (worker->stream, NULL, NULL);
       else
+#endif
           g_io_stream_close_async (worker->stream, G_PRIORITY_DEFAULT,
                                    NULL, iostream_close_cb,
                                    _g_dbus_worker_ref (worker));
@@ -1828,8 +1851,10 @@ _g_dbus_worker_new (GIOStream                              *stream,
   if (G_IS_SOCKET_CONNECTION (worker->stream))
     worker->socket = g_socket_connection_get_socket (G_SOCKET_CONNECTION (worker->stream));
 
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
   if (G_IS_KDBUS_CONNECTION (worker->stream))
     worker->kdbus = g_kdbus_connection_get_kdbus (G_KDBUS_CONNECTION (worker->stream));
+#endif
 
   worker->shared_thread_data = _g_dbus_shared_thread_ref ();
 
index 20374b2..48ceb73 100644 (file)
@@ -634,6 +634,7 @@ random_ascii (void)
   return ret;
 }
 
+#ifdef KDBUS_TRANSPORT
 static gboolean
 try_kdbus (GDBusServer *server,
            const gchar *address_entry,
@@ -643,6 +644,7 @@ try_kdbus (GDBusServer *server,
   g_print ("GDBusServer - KDBUS\n");
   return TRUE;
 }
+#endif
 
 /* note that address_entry has already been validated => exactly one of path, tmpdir or abstract keys are set */
 static gboolean
@@ -1081,9 +1083,11 @@ initable_init (GInitable     *initable,
 #ifdef G_OS_UNIX
           else if (g_strcmp0 (transport_name, "unix") == 0)
             ret = try_unix (server, address_entry, key_value_pairs, &this_error);
+#ifdef KDBUS_TRANSPORT
           else if (g_strcmp0 (transport_name, "kdbus") == 0)
             ret = try_kdbus (server, address_entry, key_value_pairs, &this_error);
 #endif
+#endif
           else if (g_strcmp0 (transport_name, "tcp") == 0)
             ret = try_tcp (server, address_entry, key_value_pairs, FALSE, &this_error);
           else if (g_strcmp0 (transport_name, "nonce-tcp") == 0)