[daemon-dev][lib-fix] Start of daemon with kdbus and fix in match rules in libdbus
[platform/upstream/dbus.git] / bus / kdbus-d.c
1 /*
2  * kdbus-d.c
3  *
4  *  Created on: Sep 4, 2013
5  *      Author: r.pajak
6  *
7  *  kdbus add-on to dbus daemon
8  *
9  */
10
11 #include <kdbus-d.h>
12 #include <dbus/dbus-connection-internal.h>
13
14 dbus_bool_t make_kdbus_bus(DBusBusType type, DBusError *error)
15 {
16
17         return TRUE;
18 }
19
20 DBusConnection* daemon_as_client(DBusBusType type, DBusError *error)
21 {
22         DBusConnection* connection;
23
24         connection = dbus_bus_get(type, error);
25         if(connection == NULL)
26                 return NULL;
27
28         if(dbus_bus_request_name(connection, DBUS_SERVICE_DBUS, 0, error) != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
29                 goto failed;
30
31         dbus_bus_add_match(connection, "type='signal', member='NameAcquired'", error);
32         dbus_bus_add_match(connection, "type='signal', member='NameLost'", error);
33         if(dbus_error_is_set(error))
34                 goto failed;
35
36         return connection;
37
38 failed:
39         _dbus_connection_close_possibly_shared (connection);
40         dbus_connection_unref (connection);
41         connection = NULL;
42         return NULL;
43 }