*
* Copyright (C) 2003 CodeFactory AB
* Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
+ * Copyright (C) 2013 Samsung Electronics
*
* Licensed under the Academic Free License version 2.1
*
#include <dbus/dbus-marshal-recursive.h>
#include <string.h>
+#ifdef ENABLE_KDBUS_TRANSPORT
#include "kdbus-d.h"
#include <stdio.h>
#include <errno.h>
#include <limits.h>
+#endif
static DBusConnection *
bus_driver_get_conn_helper (DBusConnection *connection,
dbus_bool_t retval;
const char *null_service;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
return TRUE;
+#endif
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
{
DBusMessage *message;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
return TRUE;
+#endif
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
{
DBusMessage *message;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
return TRUE;
+#endif
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
return FALSE;
}
-
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
if(!kdbus_list_services (connection, &services, &len))
{
}
}
else
- if (!bus_registry_list_services (registry, &services, &len))
- {
- dbus_message_unref (reply);
- BUS_SET_OOM (error);
- return FALSE;
- }
+#endif
+ {
+
+ if (!bus_registry_list_services (registry, &services, &len))
+ {
+ dbus_message_unref (reply);
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+ }
dbus_message_iter_init_append (reply, &iter);
return FALSE;
}
- if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //not needed for kdbus, we got it from kdbus_list_services
+#endif
{
+
/* Include the bus driver in the list */
const char *v_STRING = DBUS_SERVICE_DBUS;
if (!dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING,
retval = FALSE;
reply = NULL;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
if (!bus_registry_acquire_kdbus_service (registry, connection,
message,
goto out;
}
else
+#endif
{
+
_dbus_string_init_const (&service_name, name);
if (!bus_registry_acquire_service (registry, connection,
&service_reply, transaction,
error))
goto out;
-
}
reply = dbus_message_new_method_return (message);
goto out;
}
- _dbus_verbose ("Reply sender: %s, destination: %s\n", dbus_message_get_sender(reply), dbus_message_get_destination(reply)); //todo kdbus incl
-
if (!bus_transaction_send_from_driver (transaction, connection, reply))
{
BUS_SET_OOM (error);
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
- registry = bus_connection_get_registry (connection);
-
if (!dbus_message_get_args (message, error,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID))
reply = NULL;
_dbus_string_init_const (&service_name, name);
+ registry = bus_connection_get_registry (connection);
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
- registry = (BusRegistry*) message;
- /* looks like hack? Yes.
- * But how to pass message to bus_registry_release_service in other way?
- * In kdbus mode we don't need registry, though.
- */
+ if (!bus_registry_release_service_kdbus (dbus_message_get_sender(message), connection,
+ &service_name, &service_reply,
+ transaction, error))
+ goto out;
}
-
+ else
+#endif
if (!bus_registry_release_service (registry, connection,
&service_name, &service_reply,
transaction, error))
}
else
{
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
int inter_ret;
struct nameInfo info;
}
}
else
+#endif
{
_dbus_string_init_const (&service_name, name);
service = bus_registry_lookup (registry, &service_name);
if (rule == NULL)
goto failed;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
if (!kdbus_add_match_rule (connection, message, text, error))
goto failed;
}
else
+#endif
{
+
matchmaker = bus_connection_get_matchmaker (connection);
if (!bus_matchmaker_add_rule (matchmaker, rule))
if (rule == NULL)
goto failed;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
if(!kdbus_remove_match(connection, message, error))
goto failed;
}
+#endif
/* Send the ack before we remove the rule, since the ack is undone
* on transaction cancel, but rule removal isn't.
message, error))
goto failed;
- if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(!bus_context_is_kdbus(bus_transaction_get_context (transaction)))
+#endif
{
matchmaker = bus_connection_get_matchmaker (connection);
BusRegistry *registry;
BusService *service;
DBusMessage *reply;
- char unique_name[(unsigned int)(snprintf((char*)base_name, 0, "%llu", ULLONG_MAX) + sizeof(":1."))];
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
DBUS_TYPE_INVALID))
goto failed;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
int ret;
struct nameInfo info;
+ char unique_name[(unsigned int)(snprintf((char*)base_name, 0, "%llu", ULLONG_MAX) + sizeof(":1."))];
ret = kdbus_NameQuery(text, dbus_connection_get_transport(connection), &info);
if(ret == 0) //unique id of the name
}
}
else
- {
+#endif
+ {
_dbus_string_init_const (&str, text);
service = bus_registry_lookup (registry, &str);
if (service == NULL &&
if (reply == NULL)
goto oom;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
if(!kdbus_get_connection_unix_user(connection, message, &uid, error))
goto failed;
}
else
+#endif
{
conn = bus_driver_get_conn_helper (connection, message, "UID", &service,
error);
if (reply == NULL)
goto oom;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
if(!kdbus_get_connection_unix_process_id(connection, message, &pid, error))
goto failed;
}
else
+#endif
{
conn = bus_driver_get_conn_helper (connection, message, "PID", &service,
error);
if (reply == NULL)
goto oom;
- if(bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
if(!kdbus_get_connection_unix_selinux_security_context(connection, message, reply, error))
goto failed;
}
else
+#endif
{
conn = bus_driver_get_conn_helper (connection, message, "security context",
&service, error);
if (reply == NULL)
goto oom;
- if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //todo kdbus incl
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(!bus_context_is_kdbus(bus_transaction_get_context (transaction)))
{
+#endif
conn = bus_driver_get_conn_helper (connection, message, "credentials",
&service, error);
if (!_dbus_asv_add_uint32 (&array_iter, "UnixUserID", ulong_val))
goto oom;
}
+#ifdef ENABLE_KDBUS_TRANSPORT
}
else
{
else
goto failed;
}
+#endif
if (!_dbus_asv_close (&reply_iter, &array_iter))
goto oom;