[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])],,
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])
#ifdef G_OS_UNIX
#include <gio/gunixsocketaddress.h>
+#ifdef KDBUS_TRANSPORT
#include <gio/gkdbusconnection.h>
#endif
+#endif
#ifdef G_OS_WIN32
#include <windows.h>
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);
{
}
#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;
if (connectable != NULL)
{
-
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
if (g_strcmp0 (transport_name, "kdbus") == 0)
{
GKdbusConnection *connection;
}
else
{
+#endif
GSocketClient *client;
GSocketConnection *connection;
goto out;
ret = G_IO_STREAM (connection);
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
}
+#endif
if (nonce_file != NULL)
{
#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
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,
{
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)
{
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);
#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
gboolean from_mainloop;
} ReadWithControlData;
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
typedef struct
{
GKdbus *kdbus;
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,
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,
return FALSE;
}
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
static void
_g_kdbus_read (GKdbus *kdbus,
void *buffer,
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,
}
}
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
static gssize
_g_kdbus_read_finish (GKdbus *kdbus,
GAsyncResult *result,
else
return g_simple_async_result_get_op_res_gssize (simple);
}
+#endif
static gssize
_g_socket_read_with_control_messages_finish (GSocket *socket,
/* 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;
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)
{
/* 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 */
}
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))
simple = data->simple;
#endif
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
if (G_IS_KDBUS_CONNECTION (data->worker->stream))
{
GError *error;
}
else
{
+#endif
GOutputStream *ostream;
#ifdef G_OS_UNIX
GUnixFDList *fd_list;
write_message_async_cb,
data);
}
+#if defined (G_OS_UNIX) && (KDBUS_TRANSPORT)
}
+#endif
+
#ifdef G_OS_UNIX
out:
#endif
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));
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 ();
return ret;
}
+#ifdef KDBUS_TRANSPORT
static gboolean
try_kdbus (GDBusServer *server,
const gchar *address_entry,
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
#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)