#include "dbus-threads-internal.h"
#include "dbus-connection-internal.h"
#include "dbus-string.h"
+#include "dbus-transport-kdbus.h"
+
/**
* @defgroup DBusBus Message bus APIs
if (bd->is_well_known)
{
int i;
- _DBUS_LOCK (bus);
+
+ if (!_DBUS_LOCK (bus))
+ _dbus_assert_not_reached ("global locks should have been initialized "
+ "when we attached bus data");
+
/* We may be stored in more than one slot */
/* This should now be impossible - these slots are supposed to
* be cleared on disconnect, so should not need to be cleared on
_dbus_bus_notify_shared_connection_disconnected_unlocked (DBusConnection *connection)
{
int i;
-
- _DBUS_LOCK (bus);
+
+ if (!_DBUS_LOCK (bus))
+ {
+ /* If it was in bus_connections, we would have initialized global locks
+ * when we added it. So, it can't be. */
+ return;
+ }
/* We are expecting to have the connection saved in only one of these
* slots, but someone could in a pathological case set system and session
connection = NULL;
- _DBUS_LOCK (bus);
+ if (!_DBUS_LOCK (bus))
+ {
+ _DBUS_SET_OOM (error);
+ /* do not "goto out", that would try to unlock */
+ return NULL;
+ }
if (!init_connections_unlocked ())
{
goto out;
}
+ _dbus_verbose (" !!! dbus_connection_open finished successfully !!!! \n"); //todo RP to be removed
+
if (!dbus_bus_register (connection, error))
{
_dbus_connection_close_possibly_shared (connection);
*/
dbus_connection_set_exit_on_disconnect (connection,
TRUE);
-
- _DBUS_LOCK (bus_datas);
+
+ if (!_DBUS_LOCK (bus_datas))
+ _dbus_assert_not_reached ("global locks were initialized already");
+
bd = ensure_bus_data (connection);
_dbus_assert (bd != NULL); /* it should have been created on
register, so OOM not possible */
DBusError *error)
{
DBusMessage *message, *reply;
- char *name;
+ char name[18];
BusData *bd;
dbus_bool_t retval;
message = NULL;
reply = NULL;
- _DBUS_LOCK (bus_datas);
+ if (!_DBUS_LOCK (bus_datas))
+ {
+ _DBUS_SET_OOM (error);
+ /* do not "goto out", that would try to unlock */
+ return FALSE;
+ }
bd = ensure_bus_data (connection);
if (bd == NULL)
retval = TRUE;
goto out;
}
-
- message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- "Hello");
+ if(dbus_transport_is_kdbus(connection))
+ {
+ if(!bus_register_kdbus(name, connection, error))
+ goto out;
- if (!message)
- {
- _DBUS_SET_OOM (error);
- goto out;
- }
-
- reply = dbus_connection_send_with_reply_and_block (connection, message, -1, error);
+ if(!bus_register_policy_kdbus(name, connection, error))
+ goto out;
+
+ dbus_connection_set_is_authenticated(connection);
+ }
+ else
+ {
+ message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ "Hello");
+
+ if (!message)
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+
+ reply = dbus_connection_send_with_reply_and_block (connection, message, -1, error);
+
+ if (reply == NULL)
+ goto out;
+ else if (dbus_set_error_from_message (error, reply))
+ goto out;
+ else if (!dbus_message_get_args (reply, error,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_INVALID))
+ goto out;
+ }
- if (reply == NULL)
- goto out;
- else if (dbus_set_error_from_message (error, reply))
- goto out;
- else if (!dbus_message_get_args (reply, error,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_INVALID))
- goto out;
-
bd->unique_name = _dbus_strdup (name);
if (bd->unique_name == NULL)
{
_DBUS_SET_OOM (error);
goto out;
}
-
+ //_dbus_verbose("-- Our uniqe name is: %s\n", bd->unique_name);
retval = TRUE;
out:
_dbus_return_val_if_fail (connection != NULL, FALSE);
_dbus_return_val_if_fail (unique_name != NULL, FALSE);
- _DBUS_LOCK (bus_datas);
-
+ if (!_DBUS_LOCK (bus_datas))
+ {
+ /* do not "goto out", that would try to unlock */
+ return FALSE;
+ }
+
bd = ensure_bus_data (connection);
if (bd == NULL)
goto out;
_dbus_return_val_if_fail (connection != NULL, NULL);
- _DBUS_LOCK (bus_datas);
-
+ if (!_DBUS_LOCK (bus_datas))
+ {
+ /* We'd have initialized locks when we gave it its unique name, if it
+ * had one. Don't "goto out", that would try to unlock. */
+ return NULL;
+ }
+
bd = ensure_bus_data (connection);
if (bd == NULL)
goto out;
unsigned int flags,
DBusError *error)
{
- DBusMessage *message, *reply;
- dbus_uint32_t result;
-
- _dbus_return_val_if_fail (connection != NULL, 0);
- _dbus_return_val_if_fail (name != NULL, 0);
- _dbus_return_val_if_fail (_dbus_check_is_valid_bus_name (name), 0);
- _dbus_return_val_if_error_is_set (error, 0);
+ dbus_uint32_t result;
+
+ _dbus_return_val_if_fail (connection != NULL, 0);
+ _dbus_return_val_if_fail (name != NULL, 0);
+ _dbus_return_val_if_fail (_dbus_check_is_valid_bus_name (name), 0);
+ _dbus_return_val_if_error_is_set (error, 0);
+
+ if(!dbus_transport_is_kdbus(connection))
+ {
+ DBusMessage *message, *reply;
+
+ message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ "RequestName");
+ if (message == NULL)
+ {
+ _DBUS_SET_OOM (error);
+ return -1;
+ }
+
+ if (!dbus_message_append_args (message,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_INVALID))
+ {
+ dbus_message_unref (message);
+ _DBUS_SET_OOM (error);
+ return -1;
+ }
+
+ reply = dbus_connection_send_with_reply_and_block (connection, message, -1,
+ error);
+
+ dbus_message_unref (message);
+
+ if (reply == NULL)
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ return -1;
+ }
+
+ if (dbus_set_error_from_message (error, reply))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ dbus_message_unref (reply);
+ return -1;
+ }
+
+ if (!dbus_message_get_args (reply, error,
+ DBUS_TYPE_UINT32, &result,
+ DBUS_TYPE_INVALID))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ dbus_message_unref (reply);
+ return -1;
+ }
+
+ dbus_message_unref (reply);
+ }
+ else
+ {
+ if(!bus_register_policy_kdbus(name, connection, error))
+ return -1;
+
+ result = bus_request_name_kdbus(connection, name, flags, error);
+ }
- message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- "RequestName");
-
- if (message == NULL)
- {
- _DBUS_SET_OOM (error);
- return -1;
- }
-
- if (!dbus_message_append_args (message,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_UINT32, &flags,
- DBUS_TYPE_INVALID))
- {
- dbus_message_unref (message);
- _DBUS_SET_OOM (error);
- return -1;
- }
-
- reply = dbus_connection_send_with_reply_and_block (connection, message, -1,
- error);
-
- dbus_message_unref (message);
-
- if (reply == NULL)
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- return -1;
- }
-
- if (dbus_set_error_from_message (error, reply))
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- dbus_message_unref (reply);
- return -1;
- }
-
- if (!dbus_message_get_args (reply, error,
- DBUS_TYPE_UINT32, &result,
- DBUS_TYPE_INVALID))
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- dbus_message_unref (reply);
- return -1;
- }
-
- dbus_message_unref (reply);
-
- return result;
+ return result;
}
const char *rule,
DBusError *error)
{
- DBusMessage *msg;
+ _dbus_return_if_fail (rule != NULL);
- _dbus_return_if_fail (rule != NULL);
+ if(!dbus_transport_is_kdbus(connection))
+ {
+ DBusMessage *msg;
- msg = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
+ msg = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS,
"AddMatch");
- if (msg == NULL)
- {
- _DBUS_SET_OOM (error);
- return;
- }
-
- if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &rule,
- DBUS_TYPE_INVALID))
- {
- dbus_message_unref (msg);
- _DBUS_SET_OOM (error);
- return;
- }
-
- send_no_return_values (connection, msg, error);
-
- dbus_message_unref (msg);
+ if (msg == NULL)
+ {
+ _DBUS_SET_OOM (error);
+ return;
+ }
+
+ if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &rule,
+ DBUS_TYPE_INVALID))
+ {
+ dbus_message_unref (msg);
+ _DBUS_SET_OOM (error);
+ return;
+ }
+
+ send_no_return_values (connection, msg, error);
+
+ dbus_message_unref (msg);
+ }
+ else
+ dbus_bus_add_match_kdbus(connection, rule, error);
}
/**