#include "dbus-bus.h"
#include "dbus-marshal-basic.h"
#include "dbus-transport-kdbus.h"
+#include <stdlib.h>
#ifdef DBUS_DISABLE_CHECKS
#define TOOK_LOCK_CHECK(connection)
_dbus_assert (!connection->have_connection_lock);
#endif
- /* kdbus add-on [RP] - bus register for kdbus
- * Function checks if the method is kdbus. If yes - it registers on the bus, if no - does nothing and returns TRUE
- * Must be invoked before dbus_bus_register because in kdbus it's realized in different manner
- * and dbus_bus_register can not be used for that.
- * It does not collide with dbus_bus_register because dbus_bus_register at the beginning checks
- * whether unique_name has already been assigned and doesn't try to do it again.
- */
-
- if(!dbus_bus_register_kdbus(entry, connection, error))
- {
- _dbus_connection_close_possibly_shared (connection);
- dbus_connection_unref (connection);
- connection = NULL;
- }
-
return connection;
}
_dbus_verbose ("Message %p serial is %u\n",
message, dbus_message_get_serial (message));
+ if(dbus_transport_is_kdbus(connection))
+ {
+ const char* name;
+ char* sender;
+
+ name = dbus_bus_get_unique_name(connection);
+ sender = malloc (strlen(name) + 4);
+ if(sender)
+ {
+ strcpy(sender,":1.");
+ strcpy(&sender[3], name);
+ _dbus_verbose ("Message sender: %s\n", sender);
+ dbus_message_set_sender(message, sender);
+ free((void*)sender);
+ }
+ }
+
dbus_message_lock (message);
/* Now we need to run an iteration to hopefully just write the messages
}
/**
+ * Sets authenticated status for connection. Needed for kdbus, where authentication is
+ * made in different manner.
+ *
+ * @param connection the connection
+ */
+dbus_bool_t
+dbus_connection_set_is_authenticated (DBusConnection *connection)
+{
+ _dbus_return_val_if_fail (connection != NULL, FALSE);
+
+ CONNECTION_LOCK (connection);
+ connection->transport->authenticated = TRUE;
+ CONNECTION_UNLOCK (connection);
+
+ return TRUE;
+}
+
+/**
* Gets whether the connection is not authenticated as a specific
* user. If the connection is not authenticated, this function
* returns #TRUE, and if it is authenticated but as an anonymous user,
_dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection)
{
HAVE_LOCK_CHECK (connection);
-
+
if (connection->n_incoming > 0)
return DBUS_DISPATCH_DATA_REMAINS;
else if (!_dbus_transport_queue_messages (connection->transport))
{
DBusDispatchStatus status;
dbus_bool_t is_connected;
-
+
status = _dbus_transport_get_dispatch_status (connection->transport);
is_connected = _dbus_transport_get_is_connected (connection->transport);
return res;
}
-#ifdef DBUS_BUILD_TESTS
/**
* Returns the address of the transport object of this connection
*
{
return _dbus_transport_get_address (connection->transport);
}
-#endif
+
+DBusTransport*
+dbus_connection_get_transport(DBusConnection *connection)
+{
+ _dbus_return_val_if_fail (connection != NULL, NULL);
+
+ return connection->transport;
+}
+
/** @} */