5 * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
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.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <dbus/dbus.h>
34 typedef void (* GDBusWatchFunction) (DBusConnection *connection,
37 typedef gboolean (* GDBusSignalFunction) (DBusConnection *connection,
38 DBusMessage *message, void *user_data);
40 DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
43 DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
46 gboolean g_dbus_request_name(DBusConnection *connection, const char *name,
49 gboolean g_dbus_set_disconnect_function(DBusConnection *connection,
50 GDBusWatchFunction function,
51 void *user_data, DBusFreeFunction destroy);
53 typedef void (* GDBusDestroyFunction) (void *user_data);
55 typedef DBusMessage * (* GDBusMethodFunction) (DBusConnection *connection,
56 DBusMessage *message, void *user_data);
58 typedef guint32 GDBusPendingReply;
60 typedef void (* GDBusSecurityFunction) (DBusConnection *connection,
61 DBusMessage *message, GDBusPendingReply pending);
64 G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0),
65 G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
66 G_DBUS_METHOD_FLAG_ASYNC = (1 << 2),
70 G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0),
74 G_DBUS_PROPERTY_FLAG_DEPRECATED = (1 << 0),
79 const char *signature;
81 GDBusMethodFunction function;
82 GDBusMethodFlags flags;
83 unsigned int privilege;
88 const char *signature;
89 GDBusSignalFlags flags;
95 GDBusPropertyFlags flags;
99 unsigned int privilege;
100 GDBusSecurityFunction function;
101 } GDBusSecurityTable;
103 gboolean g_dbus_register_interface(DBusConnection *connection,
104 const char *path, const char *name,
105 const GDBusMethodTable *methods,
106 const GDBusSignalTable *signals,
107 const GDBusPropertyTable *properties,
109 GDBusDestroyFunction destroy);
110 gboolean g_dbus_unregister_interface(DBusConnection *connection,
111 const char *path, const char *name);
113 gboolean g_dbus_register_security(const GDBusSecurityTable *security);
114 gboolean g_dbus_unregister_security(const GDBusSecurityTable *security);
116 void g_dbus_pending_success(DBusConnection *connection,
117 GDBusPendingReply pending);
118 void g_dbus_pending_error(DBusConnection *connection,
119 GDBusPendingReply pending, DBusMessage *error);
121 DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name,
122 const char *format, ...)
123 __attribute__((format(printf, 3, 4)));
124 DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
125 const char *format, va_list args);
126 DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...);
127 DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
128 int type, va_list args);
130 gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message);
131 gboolean g_dbus_send_reply(DBusConnection *connection,
132 DBusMessage *message, int type, ...);
133 gboolean g_dbus_send_reply_valist(DBusConnection *connection,
134 DBusMessage *message, int type, va_list args);
136 gboolean g_dbus_emit_signal(DBusConnection *connection,
137 const char *path, const char *interface,
138 const char *name, int type, ...);
139 gboolean g_dbus_emit_signal_valist(DBusConnection *connection,
140 const char *path, const char *interface,
141 const char *name, int type, va_list args);
143 guint g_dbus_add_service_watch(DBusConnection *connection, const char *name,
144 GDBusWatchFunction connect,
145 GDBusWatchFunction disconnect,
146 void *user_data, GDBusDestroyFunction destroy);
147 guint g_dbus_add_disconnect_watch(DBusConnection *connection, const char *name,
148 GDBusWatchFunction function,
149 void *user_data, GDBusDestroyFunction destroy);
150 guint g_dbus_add_signal_watch(DBusConnection *connection,
151 const char *sender, const char *path,
152 const char *interface, const char *member,
153 GDBusSignalFunction function, void *user_data,
154 GDBusDestroyFunction destroy);
155 gboolean g_dbus_remove_watch(DBusConnection *connection, guint tag);
156 void g_dbus_remove_all_watches(DBusConnection *connection);
162 #endif /* __GDBUS_H */