5 * Copyright (C) 2007-2012 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef __CONNMAN_DBUS_H
23 #define __CONNMAN_DBUS_H
25 #include <dbus/dbus.h>
31 #define CONNMAN_SERVICE "net.connman"
32 #define CONNMAN_PATH "/net/connman"
34 #define CONNMAN_DEBUG_INTERFACE CONNMAN_SERVICE ".Debug"
35 #define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error"
36 #define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent"
37 #define CONNMAN_COUNTER_INTERFACE CONNMAN_SERVICE ".Counter"
39 #define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
40 #define CONNMAN_MANAGER_PATH "/"
42 #define CONNMAN_CLOCK_INTERFACE CONNMAN_SERVICE ".Clock"
43 #define CONNMAN_TASK_INTERFACE CONNMAN_SERVICE ".Task"
44 #define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
45 #define CONNMAN_PROVIDER_INTERFACE CONNMAN_SERVICE ".Provider"
46 #define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
47 #define CONNMAN_SESSION_INTERFACE CONNMAN_SERVICE ".Session"
48 #define CONNMAN_NOTIFICATION_INTERFACE CONNMAN_SERVICE ".Notification"
49 #define CONNMAN_PEER_INTERFACE CONNMAN_SERVICE ".Peer"
51 #define CONNMAN_PRIVILEGE_MODIFY 1
52 #define CONNMAN_PRIVILEGE_SECRET 2
54 typedef void (* connman_dbus_append_cb_t) (DBusMessageIter *iter,
57 DBusConnection *connman_dbus_get_connection(void);
59 void connman_dbus_property_append_basic(DBusMessageIter *iter,
60 const char *key, int type, void *val);
61 void connman_dbus_property_append_dict(DBusMessageIter *iter, const char *key,
62 connman_dbus_append_cb_t function, void *user_data);
63 void connman_dbus_property_append_array(DBusMessageIter *iter,
64 const char *key, int type,
65 connman_dbus_append_cb_t function, void *user_data);
66 void connman_dbus_property_append_fixed_array(DBusMessageIter *iter,
67 const char *key, int type, void *val, int len);
69 dbus_bool_t connman_dbus_property_changed_basic(const char *path,
70 const char *interface, const char *key,
72 dbus_bool_t connman_dbus_property_changed_dict(const char *path,
73 const char *interface, const char *key,
74 connman_dbus_append_cb_t function, void *user_data);
75 dbus_bool_t connman_dbus_property_changed_array(const char *path,
76 const char *interface, const char *key, int type,
77 connman_dbus_append_cb_t function, void *user_data);
79 dbus_bool_t connman_dbus_setting_changed_basic(const char *owner,
80 const char *path, const char *key,
82 dbus_bool_t connman_dbus_setting_changed_dict(const char *owner,
83 const char *path, const char *key,
84 connman_dbus_append_cb_t function,
86 dbus_bool_t connman_dbus_setting_changed_array(const char *owner,
87 const char *path, const char *key, int type,
88 connman_dbus_append_cb_t function,
91 static inline void connman_dbus_dict_open(DBusMessageIter *iter,
92 DBusMessageIter *dict)
94 dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
95 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
96 DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
97 DBUS_DICT_ENTRY_END_CHAR_AS_STRING, dict);
100 static inline void connman_dbus_dict_open_variant(DBusMessageIter *iter,
101 DBusMessageIter *dict)
103 dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
104 DBUS_TYPE_ARRAY_AS_STRING
105 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
106 DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
107 DBUS_DICT_ENTRY_END_CHAR_AS_STRING, dict);
110 static inline void connman_dbus_array_open(DBusMessageIter *iter,
111 DBusMessageIter *dict)
113 dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
114 DBUS_TYPE_ARRAY_AS_STRING
115 DBUS_TYPE_STRING_AS_STRING,
119 static inline void connman_dbus_dict_close(DBusMessageIter *iter,
120 DBusMessageIter *dict)
122 dbus_message_iter_close_container(iter, dict);
125 static inline void connman_dbus_dict_append_basic(DBusMessageIter *dict,
126 const char *key, int type, void *val)
128 DBusMessageIter entry;
130 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
132 connman_dbus_property_append_basic(&entry, key, type, val);
133 dbus_message_iter_close_container(dict, &entry);
136 static inline void connman_dbus_dict_append_dict(DBusMessageIter *dict,
137 const char *key, connman_dbus_append_cb_t function,
140 DBusMessageIter entry;
142 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
144 connman_dbus_property_append_dict(&entry, key, function, user_data);
145 dbus_message_iter_close_container(dict, &entry);
148 static inline void connman_dbus_dict_append_array(DBusMessageIter *dict,
149 const char *key, int type, connman_dbus_append_cb_t function,
152 DBusMessageIter entry;
154 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
156 connman_dbus_property_append_array(&entry, key,
157 type, function, user_data);
158 dbus_message_iter_close_container(dict, &entry);
161 static inline void connman_dbus_dict_append_fixed_array(DBusMessageIter *dict,
162 const char *key, int type, void *val, int len)
164 DBusMessageIter entry;
166 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
168 connman_dbus_property_append_fixed_array(&entry, key, type, val, len);
169 dbus_message_iter_close_container(dict, &entry);
172 dbus_bool_t connman_dbus_validate_ident(const char *ident);
173 char *connman_dbus_encode_string(const char *value);
175 typedef void (* connman_dbus_get_connection_unix_user_cb_t) (unsigned int uid,
176 void *user_data, int err);
178 int connman_dbus_get_connection_unix_user(DBusConnection *connection,
179 const char *bus_name,
180 connman_dbus_get_connection_unix_user_cb_t func,
183 typedef void (* connman_dbus_get_context_cb_t) (const unsigned char *context,
184 void *user_data, int err);
186 int connman_dbus_get_selinux_context(DBusConnection *connection,
188 connman_dbus_get_context_cb_t func,
195 #endif /* __CONNMAN_DBUS_H */