eaa183009532550614b9f519e73eb9b4fe9d65d6
[platform/upstream/dbus.git] / bus / kdbus-d.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* kdbus-d.h  kdbus related daemon functions
3  *
4  * Copyright (C) 2013  Samsung Electronics
5  *
6  * Licensed under the Academic Free License version 2.1
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version and under the terms of the GNU
12  * Lesser General Public License as published by the
13  * Free Software Foundation; either version 2.1 of the License, or (at
14  * your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  *
25  */
26
27 #ifndef KDBUS_D_H_
28 #define KDBUS_D_H_
29
30
31 #include <dbus/dbus-bus.h>
32 #include "bus.h"
33 #include <dbus/dbus-server.h>
34 #include <linux/types.h>
35 #include <dbus/dbus-transport-kdbus.h>
36
37 __u64 sender_name_to_id(const char* name, DBusError* error);
38 char* make_kdbus_bus(DBusBusType type, const char* address, DBusError *error);
39 DBusServer* empty_server_init(char* address);
40
41 dbus_bool_t kdbus_register_policy (const DBusString *service_name, DBusConnection* connection);
42 dbus_uint32_t kdbus_request_name(DBusConnection* connection, const DBusString *service_name, dbus_uint32_t flags, __u64 sender_id);
43 dbus_uint32_t kdbus_release_name(DBusConnection* connection, const DBusString *service_name, __u64 sender_id);
44 dbus_bool_t kdbus_list_services (DBusConnection* connection, char ***listp, int *array_len);
45 dbus_bool_t kdbus_list_queued (DBusConnection *connection, DBusList **return_list, const char *name, DBusError *error);
46 dbus_bool_t kdbus_add_match_rule (DBusConnection* connection, DBusMessage* message, const char* text, DBusError* error);
47 dbus_bool_t kdbus_remove_match (DBusConnection* connection, DBusMessage* message, DBusError* error);
48
49 dbus_bool_t add_match_kdbus (DBusTransport* transport, __u64 id, const char *rule);
50 dbus_bool_t remove_match_kdbus (DBusTransport* transport, __u64 id);
51
52 struct nameInfo
53 {
54   __u64 uniqueId;
55   __u64 userId;
56   __u64 processId;
57   __u32 sec_label_len;
58   char *sec_label;
59 };
60 int kdbus_NameQuery(const char* name, DBusTransport* transport, struct nameInfo* pInfo);
61
62 int kdbus_get_name_owner(DBusConnection* connection, const char* name, char* owner);
63 dbus_bool_t kdbus_get_unix_user(DBusConnection* connection, const char* name, unsigned long* uid, DBusError* error);
64 dbus_bool_t kdbus_get_connection_unix_process_id(DBusConnection* connection, const char* name, unsigned long* pid, DBusError* error);
65 dbus_bool_t kdbus_get_connection_unix_selinux_security_context(DBusConnection* connection, DBusMessage* message, DBusMessage* reply, DBusError* error);
66
67 dbus_bool_t dbus_connection_get_unix_user (DBusConnection *connection, unsigned long  *uid);
68 dbus_bool_t dbus_connection_get_unix_process_id (DBusConnection *connection, unsigned long  *pid);
69
70 DBusConnection* daemon_as_client(DBusBusType type, char* address, DBusError *error);
71 dbus_bool_t register_daemon_name(DBusConnection* connection);
72 DBusConnection* create_phantom_connection(DBusConnection* connection, const char* unique_name, DBusError* error);
73 dbus_bool_t register_kdbus_starters(DBusConnection* connection);
74 dbus_bool_t update_kdbus_starters(DBusConnection* connection);
75
76 void handleNameOwnerChanged(DBusMessage *msg, BusTransaction *transaction, DBusConnection *connection);
77 #endif /* KDBUS_H_ */