| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef __GDBUS_H |
| 25 |
#define __GDBUS_H |
| 26 |
|
| 27 |
#ifdef __cplusplus |
| 28 |
extern "C" { |
| 29 |
#endif |
| 30 |
|
| 31 |
#include <dbus/dbus.h> |
| 32 |
#include <glib.h> |
| 33 |
|
| 34 |
typedef enum GDBusMethodFlags GDBusMethodFlags; |
| 35 |
typedef enum GDBusSignalFlags GDBusSignalFlags; |
| 36 |
typedef enum GDBusPropertyFlags GDBusPropertyFlags; |
| 37 |
typedef enum GDBusSecurityFlags GDBusSecurityFlags; |
| 38 |
|
| 39 |
typedef struct GDBusArgInfo GDBusArgInfo; |
| 40 |
typedef struct GDBusMethodTable GDBusMethodTable; |
| 41 |
typedef struct GDBusSignalTable GDBusSignalTable; |
| 42 |
typedef struct GDBusPropertyTable GDBusPropertyTable; |
| 43 |
typedef struct GDBusSecurityTable GDBusSecurityTable; |
| 44 |
|
| 45 |
typedef void (* GDBusWatchFunction) (DBusConnection *connection, |
| 46 |
void *user_data); |
| 47 |
|
| 48 |
typedef void (* GDBusMessageFunction) (DBusConnection *connection, |
| 49 |
DBusMessage *message, void *user_data); |
| 50 |
|
| 51 |
typedef gboolean (* GDBusSignalFunction) (DBusConnection *connection, |
| 52 |
DBusMessage *message, void *user_data); |
| 53 |
|
| 54 |
DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, |
| 55 |
DBusError *error); |
| 56 |
|
| 57 |
DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, |
| 58 |
DBusError *error); |
| 59 |
|
| 60 |
gboolean g_dbus_request_name(DBusConnection *connection, const char *name, |
| 61 |
DBusError *error); |
| 62 |
|
| 63 |
gboolean g_dbus_set_disconnect_function(DBusConnection *connection, |
| 64 |
GDBusWatchFunction function, |
| 65 |
void *user_data, DBusFreeFunction destroy); |
| 66 |
|
| 67 |
typedef void (* GDBusDestroyFunction) (void *user_data); |
| 68 |
|
| 69 |
typedef DBusMessage * (* GDBusMethodFunction) (DBusConnection *connection, |
| 70 |
DBusMessage *message, void *user_data); |
| 71 |
|
| 72 |
typedef gboolean (*GDBusPropertyGetter)(const GDBusPropertyTable *property, |
| 73 |
DBusMessageIter *iter, void *data); |
| 74 |
|
| 75 |
typedef guint32 GDBusPendingPropertySet; |
| 76 |
|
| 77 |
typedef void (*GDBusPropertySetter)(const GDBusPropertyTable *property, |
| 78 |
DBusMessageIter *value, GDBusPendingPropertySet id, |
| 79 |
void *data); |
| 80 |
|
| 81 |
typedef gboolean (*GDBusPropertyExists)(const GDBusPropertyTable *property, |
| 82 |
void *data); |
| 83 |
|
| 84 |
typedef guint32 GDBusPendingReply; |
| 85 |
|
| 86 |
typedef void (* GDBusSecurityFunction) (DBusConnection *connection, |
| 87 |
const char *action, |
| 88 |
gboolean interaction, |
| 89 |
GDBusPendingReply pending); |
| 90 |
|
| 91 |
enum GDBusFlags { |
| 92 |
G_DBUS_FLAG_ENABLE_EXPERIMENTAL = (1 << 0), |
| 93 |
}; |
| 94 |
|
| 95 |
enum GDBusMethodFlags { |
| 96 |
G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0), |
| 97 |
G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1), |
| 98 |
G_DBUS_METHOD_FLAG_ASYNC = (1 << 2), |
| 99 |
G_DBUS_METHOD_FLAG_EXPERIMENTAL = (1 << 3), |
| 100 |
}; |
| 101 |
|
| 102 |
enum GDBusSignalFlags { |
| 103 |
G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0), |
| 104 |
G_DBUS_SIGNAL_FLAG_EXPERIMENTAL = (1 << 1), |
| 105 |
}; |
| 106 |
|
| 107 |
enum GDBusPropertyFlags { |
| 108 |
G_DBUS_PROPERTY_FLAG_DEPRECATED = (1 << 0), |
| 109 |
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL = (1 << 1), |
| 110 |
}; |
| 111 |
|
| 112 |
enum GDBusSecurityFlags { |
| 113 |
G_DBUS_SECURITY_FLAG_DEPRECATED = (1 << 0), |
| 114 |
G_DBUS_SECURITY_FLAG_BUILTIN = (1 << 1), |
| 115 |
G_DBUS_SECURITY_FLAG_ALLOW_INTERACTION = (1 << 2), |
| 116 |
}; |
| 117 |
|
| 118 |
struct GDBusArgInfo { |
| 119 |
const char *name; |
| 120 |
const char *signature; |
| 121 |
}; |
| 122 |
|
| 123 |
struct GDBusMethodTable { |
| 124 |
const char *name; |
| 125 |
GDBusMethodFunction function; |
| 126 |
GDBusMethodFlags flags; |
| 127 |
unsigned int privilege; |
| 128 |
const GDBusArgInfo *in_args; |
| 129 |
const GDBusArgInfo *out_args; |
| 130 |
}; |
| 131 |
|
| 132 |
struct GDBusSignalTable { |
| 133 |
const char *name; |
| 134 |
GDBusSignalFlags flags; |
| 135 |
const GDBusArgInfo *args; |
| 136 |
}; |
| 137 |
|
| 138 |
struct GDBusPropertyTable { |
| 139 |
const char *name; |
| 140 |
const char *type; |
| 141 |
GDBusPropertyGetter get; |
| 142 |
GDBusPropertySetter set; |
| 143 |
GDBusPropertyExists exists; |
| 144 |
GDBusPropertyFlags flags; |
| 145 |
}; |
| 146 |
|
| 147 |
struct GDBusSecurityTable { |
| 148 |
unsigned int privilege; |
| 149 |
const char *action; |
| 150 |
GDBusSecurityFlags flags; |
| 151 |
GDBusSecurityFunction function; |
| 152 |
}; |
| 153 |
|
| 154 |
#define GDBUS_ARGS(args...) (const GDBusArgInfo[]) { args, { } } |
| 155 |
|
| 156 |
#define GDBUS_METHOD(_name, _in_args, _out_args, _function) \ |
| 157 |
.name = _name, \ |
| 158 |
.in_args = _in_args, \ |
| 159 |
.out_args = _out_args, \ |
| 160 |
.function = _function |
| 161 |
|
| 162 |
#define GDBUS_ASYNC_METHOD(_name, _in_args, _out_args, _function) \ |
| 163 |
.name = _name, \ |
| 164 |
.in_args = _in_args, \ |
| 165 |
.out_args = _out_args, \ |
| 166 |
.function = _function, \ |
| 167 |
.flags = G_DBUS_METHOD_FLAG_ASYNC |
| 168 |
|
| 169 |
#define GDBUS_DEPRECATED_METHOD(_name, _in_args, _out_args, _function) \ |
| 170 |
.name = _name, \ |
| 171 |
.in_args = _in_args, \ |
| 172 |
.out_args = _out_args, \ |
| 173 |
.function = _function, \ |
| 174 |
.flags = G_DBUS_METHOD_FLAG_DEPRECATED |
| 175 |
|
| 176 |
#define GDBUS_DEPRECATED_ASYNC_METHOD(_name, _in_args, _out_args, _function) \ |
| 177 |
.name = _name, \ |
| 178 |
.in_args = _in_args, \ |
| 179 |
.out_args = _out_args, \ |
| 180 |
.function = _function, \ |
| 181 |
.flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_DEPRECATED |
| 182 |
|
| 183 |
#define GDBUS_EXPERIMENTAL_METHOD(_name, _in_args, _out_args, _function) \ |
| 184 |
.name = _name, \ |
| 185 |
.in_args = _in_args, \ |
| 186 |
.out_args = _out_args, \ |
| 187 |
.function = _function, \ |
| 188 |
.flags = G_DBUS_METHOD_FLAG_EXPERIMENTAL |
| 189 |
|
| 190 |
#define GDBUS_EXPERIMENTAL_ASYNC_METHOD(_name, _in_args, _out_args, _function) \ |
| 191 |
.name = _name, \ |
| 192 |
.in_args = _in_args, \ |
| 193 |
.out_args = _out_args, \ |
| 194 |
.function = _function, \ |
| 195 |
.flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_EXPERIMENTAL |
| 196 |
|
| 197 |
#define GDBUS_NOREPLY_METHOD(_name, _in_args, _out_args, _function) \ |
| 198 |
.name = _name, \ |
| 199 |
.in_args = _in_args, \ |
| 200 |
.out_args = _out_args, \ |
| 201 |
.function = _function, \ |
| 202 |
.flags = G_DBUS_METHOD_FLAG_NOREPLY |
| 203 |
|
| 204 |
#define GDBUS_SIGNAL(_name, _args) \ |
| 205 |
.name = _name, \ |
| 206 |
.args = _args |
| 207 |
|
| 208 |
#define GDBUS_DEPRECATED_SIGNAL(_name, _args) \ |
| 209 |
.name = _name, \ |
| 210 |
.args = _args, \ |
| 211 |
.flags = G_DBUS_SIGNAL_FLAG_DEPRECATED |
| 212 |
|
| 213 |
#define GDBUS_EXPERIMENTAL_SIGNAL(_name, _args) \ |
| 214 |
.name = _name, \ |
| 215 |
.args = _args, \ |
| 216 |
.flags = G_DBUS_SIGNAL_FLAG_EXPERIMENTAL |
| 217 |
|
| 218 |
void g_dbus_set_flags(int flags); |
| 219 |
|
| 220 |
gboolean g_dbus_register_interface(DBusConnection *connection, |
| 221 |
const char *path, const char *name, |
| 222 |
const GDBusMethodTable *methods, |
| 223 |
const GDBusSignalTable *signals, |
| 224 |
const GDBusPropertyTable *properties, |
| 225 |
void *user_data, |
| 226 |
GDBusDestroyFunction destroy); |
| 227 |
gboolean g_dbus_unregister_interface(DBusConnection *connection, |
| 228 |
const char *path, const char *name); |
| 229 |
|
| 230 |
gboolean g_dbus_register_security(const GDBusSecurityTable *security); |
| 231 |
gboolean g_dbus_unregister_security(const GDBusSecurityTable *security); |
| 232 |
|
| 233 |
void g_dbus_pending_success(DBusConnection *connection, |
| 234 |
GDBusPendingReply pending); |
| 235 |
void g_dbus_pending_error(DBusConnection *connection, |
| 236 |
GDBusPendingReply pending, |
| 237 |
const char *name, const char *format, ...) |
| 238 |
__attribute__((format(printf, 4, 5))); |
| 239 |
void g_dbus_pending_error_valist(DBusConnection *connection, |
| 240 |
GDBusPendingReply pending, const char *name, |
| 241 |
const char *format, va_list args); |
| 242 |
|
| 243 |
DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name, |
| 244 |
const char *format, ...) |
| 245 |
__attribute__((format(printf, 3, 4))); |
| 246 |
DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name, |
| 247 |
const char *format, va_list args); |
| 248 |
DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...); |
| 249 |
DBusMessage *g_dbus_create_reply_valist(DBusMessage *message, |
| 250 |
int type, va_list args); |
| 251 |
|
| 252 |
gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message); |
| 253 |
gboolean g_dbus_send_error(DBusConnection *connection, DBusMessage *message, |
| 254 |
const char *name, const char *format, ...) |
| 255 |
__attribute__((format(printf, 4, 5))); |
| 256 |
gboolean g_dbus_send_error_valist(DBusConnection *connection, |
| 257 |
DBusMessage *message, const char *name, |
| 258 |
const char *format, va_list args); |
| 259 |
gboolean g_dbus_send_reply(DBusConnection *connection, |
| 260 |
DBusMessage *message, int type, ...); |
| 261 |
gboolean g_dbus_send_reply_valist(DBusConnection *connection, |
| 262 |
DBusMessage *message, int type, va_list args); |
| 263 |
|
| 264 |
gboolean g_dbus_emit_signal(DBusConnection *connection, |
| 265 |
const char *path, const char *interface, |
| 266 |
const char *name, int type, ...); |
| 267 |
gboolean g_dbus_emit_signal_valist(DBusConnection *connection, |
| 268 |
const char *path, const char *interface, |
| 269 |
const char *name, int type, va_list args); |
| 270 |
|
| 271 |
guint g_dbus_add_service_watch(DBusConnection *connection, const char *name, |
| 272 |
GDBusWatchFunction connect, |
| 273 |
GDBusWatchFunction disconnect, |
| 274 |
void *user_data, GDBusDestroyFunction destroy); |
| 275 |
guint g_dbus_add_disconnect_watch(DBusConnection *connection, const char *name, |
| 276 |
GDBusWatchFunction function, |
| 277 |
void *user_data, GDBusDestroyFunction destroy); |
| 278 |
guint g_dbus_add_signal_watch(DBusConnection *connection, |
| 279 |
const char *sender, const char *path, |
| 280 |
const char *interface, const char *member, |
| 281 |
GDBusSignalFunction function, void *user_data, |
| 282 |
GDBusDestroyFunction destroy); |
| 283 |
guint g_dbus_add_properties_watch(DBusConnection *connection, |
| 284 |
const char *sender, const char *path, |
| 285 |
const char *interface, |
| 286 |
GDBusSignalFunction function, void *user_data, |
| 287 |
GDBusDestroyFunction destroy); |
| 288 |
gboolean g_dbus_remove_watch(DBusConnection *connection, guint tag); |
| 289 |
void g_dbus_remove_all_watches(DBusConnection *connection); |
| 290 |
|
| 291 |
void g_dbus_pending_property_success(GDBusPendingPropertySet id); |
| 292 |
void g_dbus_pending_property_error_valist(GDBusPendingReply id, |
| 293 |
const char *name, const char *format, va_list args); |
| 294 |
void g_dbus_pending_property_error(GDBusPendingReply id, const char *name, |
| 295 |
const char *format, ...); |
| 296 |
void g_dbus_emit_property_changed(DBusConnection *connection, |
| 297 |
const char *path, const char *interface, |
| 298 |
const char *name); |
| 299 |
gboolean g_dbus_get_properties(DBusConnection *connection, const char *path, |
| 300 |
const char *interface, DBusMessageIter *iter); |
| 301 |
|
| 302 |
gboolean g_dbus_attach_object_manager(DBusConnection *connection); |
| 303 |
gboolean g_dbus_detach_object_manager(DBusConnection *connection); |
| 304 |
|
| 305 |
typedef struct GDBusClient GDBusClient; |
| 306 |
typedef struct GDBusProxy GDBusProxy; |
| 307 |
|
| 308 |
GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path, |
| 309 |
const char *interface); |
| 310 |
|
| 311 |
GDBusProxy *g_dbus_proxy_ref(GDBusProxy *proxy); |
| 312 |
void g_dbus_proxy_unref(GDBusProxy *proxy); |
| 313 |
|
| 314 |
const char *g_dbus_proxy_get_path(GDBusProxy *proxy); |
| 315 |
const char *g_dbus_proxy_get_interface(GDBusProxy *proxy); |
| 316 |
|
| 317 |
gboolean g_dbus_proxy_get_property(GDBusProxy *proxy, const char *name, |
| 318 |
DBusMessageIter *iter); |
| 319 |
|
| 320 |
gboolean g_dbus_proxy_refresh_property(GDBusProxy *proxy, const char *name); |
| 321 |
|
| 322 |
typedef void (* GDBusResultFunction) (const DBusError *error, void *user_data); |
| 323 |
|
| 324 |
gboolean g_dbus_proxy_set_property_basic(GDBusProxy *proxy, |
| 325 |
const char *name, int type, const void *value, |
| 326 |
GDBusResultFunction function, void *user_data, |
| 327 |
GDBusDestroyFunction destroy); |
| 328 |
|
| 329 |
typedef void (* GDBusSetupFunction) (DBusMessageIter *iter, void *user_data); |
| 330 |
typedef void (* GDBusReturnFunction) (DBusMessage *message, void *user_data); |
| 331 |
|
| 332 |
gboolean g_dbus_proxy_method_call(GDBusProxy *proxy, const char *method, |
| 333 |
GDBusSetupFunction setup, |
| 334 |
GDBusReturnFunction function, void *user_data, |
| 335 |
GDBusDestroyFunction destroy); |
| 336 |
|
| 337 |
typedef void (* GDBusProxyFunction) (GDBusProxy *proxy, void *user_data); |
| 338 |
typedef void (* GDBusPropertyFunction) (GDBusProxy *proxy, const char *name, |
| 339 |
DBusMessageIter *iter, void *user_data); |
| 340 |
|
| 341 |
gboolean g_dbus_proxy_set_property_watch(GDBusProxy *proxy, |
| 342 |
GDBusPropertyFunction function, void *user_data); |
| 343 |
|
| 344 |
GDBusClient *g_dbus_client_new(DBusConnection *connection, |
| 345 |
const char *service, const char *path); |
| 346 |
|
| 347 |
GDBusClient *g_dbus_client_ref(GDBusClient *client); |
| 348 |
void g_dbus_client_unref(GDBusClient *client); |
| 349 |
|
| 350 |
gboolean g_dbus_client_set_connect_watch(GDBusClient *client, |
| 351 |
GDBusWatchFunction function, void *user_data); |
| 352 |
gboolean g_dbus_client_set_disconnect_watch(GDBusClient *client, |
| 353 |
GDBusWatchFunction function, void *user_data); |
| 354 |
gboolean g_dbus_client_set_signal_watch(GDBusClient *client, |
| 355 |
GDBusMessageFunction function, void *user_data); |
| 356 |
|
| 357 |
gboolean g_dbus_client_set_proxy_handlers(GDBusClient *client, |
| 358 |
GDBusProxyFunction proxy_added, |
| 359 |
GDBusProxyFunction proxy_removed, |
| 360 |
GDBusPropertyFunction property_changed, |
| 361 |
void *user_data); |
| 362 |
|
| 363 |
#ifdef __cplusplus |
| 364 |
} |
| 365 |
#endif |
| 366 |
|
| 367 |
#endif |