- DBusServer *server;
-
- server = dbus_server_listen (_dbus_string_get_const_data(address), error);
- if (server == NULL)
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- goto failed;
- }
- else if (!setup_server (context, server, auth_mechanisms, error))
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- goto failed;
- }
-
- if (!_dbus_list_append (&context->servers, server))
- goto oom;
+ if(!strcmp(_dbus_string_get_const_data(address), "kdbus"))
+ {
+ DBusBusType type;
+ DBusServer* server;
+ char* bus_address;
+
+ if(!strcmp (context->type, "system"))
+ type = DBUS_BUS_SYSTEM;
+ else if(!strcmp (context->type, "session"))
+ type = DBUS_BUS_SESSION;
+ else
+ type = DBUS_BUS_STARTER;
+
+ bus_address = make_kdbus_bus(type, error);
+ if(bus_address == NULL)
+ goto failed;
+
+ server = empty_server_init(bus_address);
+ if(server == NULL)
+ {
+ free(bus_address);
+ goto failed;
+ }
+
+ if (!_dbus_list_append (&context->servers, server))
+ {
+ free(bus_address);
+ goto oom;
+ }
+
+ context->myKdbusConnection = daemon_as_client(type, bus_address, error);
+ if(context->myKdbusConnection == NULL)
+ goto failed;
+ }
+ else
+ {
+ DBusServer *server;
+
+ server = dbus_server_listen (_dbus_string_get_const_data(address), error);
+ if (server == NULL)
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
+ else if (!setup_server (context, server, auth_mechanisms, error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
+
+ if (!_dbus_list_append (&context->servers, server))
+ goto oom;
+ }