dbus-glib.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /* -*- mode: C; c-file-style: "gnu" -*- */
  2. /* dbus-glib.h GLib integration
  3. *
  4. * Copyright (C) 2002, 2003 CodeFactory AB
  5. * Copyright (C) 2003, 2004 Red Hat, Inc.
  6. *
  7. * Licensed under the Academic Free License version 2.1
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. */
  24. #ifndef DBUS_GLIB_H
  25. #define DBUS_GLIB_H
  26. #include <glib-object.h>
  27. #include <dbus/dbus-shared.h>
  28. G_BEGIN_DECLS
  29. #define DBUS_INSIDE_DBUS_GLIB_H 1
  30. /*
  31. * Convert to DBusConnection with dbus_g_connection_get_connection() in dbus-glib-lowlevel.h
  32. */
  33. typedef struct _DBusGConnection DBusGConnection;
  34. /*
  35. * Convert to DBusMessage with dbus_g_message_get_message() in dbus-glib-lowlevel.h
  36. */
  37. typedef struct _DBusGMessage DBusGMessage;
  38. #define DBUS_TYPE_G_CONNECTION (dbus_g_connection_get_g_type ())
  39. #define DBUS_TYPE_G_MESSAGE (dbus_g_message_get_g_type ())
  40. GType dbus_g_connection_get_g_type (void) G_GNUC_CONST;
  41. GType dbus_g_message_get_g_type (void) G_GNUC_CONST;
  42. DBusGConnection* dbus_g_connection_ref (DBusGConnection *connection);
  43. void dbus_g_connection_unref (DBusGConnection *connection);
  44. DBusGMessage* dbus_g_message_ref (DBusGMessage *message);
  45. void dbus_g_message_unref (DBusGMessage *message);
  46. void dbus_g_connection_flush (DBusGConnection *connection);
  47. GQuark dbus_g_error_quark (void);
  48. #define DBUS_GERROR dbus_g_error_quark ()
  49. typedef enum
  50. {
  51. DBUS_GERROR_FAILED,
  52. DBUS_GERROR_NO_MEMORY,
  53. DBUS_GERROR_SERVICE_UNKNOWN,
  54. DBUS_GERROR_NAME_HAS_NO_OWNER,
  55. DBUS_GERROR_NO_REPLY,
  56. DBUS_GERROR_IO_ERROR,
  57. DBUS_GERROR_BAD_ADDRESS,
  58. DBUS_GERROR_NOT_SUPPORTED,
  59. DBUS_GERROR_LIMITS_EXCEEDED,
  60. DBUS_GERROR_ACCESS_DENIED,
  61. DBUS_GERROR_AUTH_FAILED,
  62. DBUS_GERROR_NO_SERVER,
  63. DBUS_GERROR_TIMEOUT,
  64. DBUS_GERROR_NO_NETWORK,
  65. DBUS_GERROR_ADDRESS_IN_USE,
  66. DBUS_GERROR_DISCONNECTED,
  67. DBUS_GERROR_INVALID_ARGS,
  68. DBUS_GERROR_FILE_NOT_FOUND,
  69. DBUS_GERROR_FILE_EXISTS,
  70. DBUS_GERROR_UNKNOWN_METHOD,
  71. DBUS_GERROR_TIMED_OUT,
  72. DBUS_GERROR_MATCH_RULE_NOT_FOUND,
  73. DBUS_GERROR_MATCH_RULE_INVALID,
  74. DBUS_GERROR_SPAWN_EXEC_FAILED,
  75. DBUS_GERROR_SPAWN_FORK_FAILED,
  76. DBUS_GERROR_SPAWN_CHILD_EXITED,
  77. DBUS_GERROR_SPAWN_CHILD_SIGNALED,
  78. DBUS_GERROR_SPAWN_FAILED,
  79. DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN,
  80. DBUS_GERROR_INVALID_SIGNATURE,
  81. DBUS_GERROR_INVALID_FILE_CONTENT,
  82. DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN,
  83. DBUS_GERROR_REMOTE_EXCEPTION
  84. } DBusGError;
  85. gboolean dbus_g_error_has_name (GError *error,
  86. const char *name);
  87. const char * dbus_g_error_get_name (GError *error);
  88. void dbus_g_thread_init (void);
  89. DBusGConnection* dbus_g_connection_open (const gchar *address,
  90. GError **error);
  91. DBusGConnection* dbus_g_connection_open_private (const gchar *address,
  92. GMainContext *context,
  93. GError **error);
  94. DBusGConnection* dbus_g_bus_get (DBusBusType type,
  95. GError **error);
  96. DBusGConnection* dbus_g_bus_get_private (DBusBusType type,
  97. GMainContext *context,
  98. GError **error);
  99. typedef struct _DBusGObjectInfo DBusGObjectInfo;
  100. typedef struct _DBusGMethodInfo DBusGMethodInfo;
  101. /**
  102. * DBusGMethodInfo:
  103. * @function: C method to invoke
  104. * @marshaller: Marshaller to invoke method
  105. * @data_offset: Offset into the introspection data
  106. *
  107. * Object typically generated by #dbus-binding-tool that
  108. * stores a mapping from introspection data to a
  109. * function pointer for a C method to be invoked.
  110. */
  111. struct _DBusGMethodInfo
  112. {
  113. GCallback function;
  114. GClosureMarshal marshaller;
  115. int data_offset;
  116. };
  117. /**
  118. * DBusGObjectInfo:
  119. * @format_version: Allows us to change the rest of this struct
  120. * by adding DBusGObjectInfo2, DBusGObjectInfo3, etc.
  121. * @method_infos: Array of method pointers
  122. * @n_method_infos: Length of the infos array
  123. * @data: Introspection data
  124. * @exported_signals: Exported signals
  125. * @exported_properties: Exported properties
  126. *
  127. * Introspection data for a #GObject, normally autogenerated by
  128. * a tool such as #dbus-binding-tool.
  129. */
  130. struct _DBusGObjectInfo
  131. {
  132. int format_version;
  133. const DBusGMethodInfo *method_infos;
  134. int n_method_infos;
  135. const char *data;
  136. const char *exported_signals;
  137. const char *exported_properties;
  138. };
  139. void dbus_glib_global_set_disable_legacy_property_access (void);
  140. void dbus_g_object_type_install_info (GType object_type,
  141. const DBusGObjectInfo *info);
  142. void dbus_g_object_type_register_shadow_property (GType iface_type,
  143. const char *dbus_prop_name,
  144. const char *shadow_prop_name);
  145. void dbus_g_error_domain_register (GQuark domain,
  146. const char * default_iface,
  147. GType code_enum);
  148. void dbus_g_connection_register_g_object (DBusGConnection *connection,
  149. const char *at_path,
  150. GObject *object);
  151. void dbus_g_connection_unregister_g_object (DBusGConnection *connection,
  152. GObject *object);
  153. GObject * dbus_g_connection_lookup_g_object (DBusGConnection *connection,
  154. const char *at_path);
  155. #ifdef DBUS_COMPILATION
  156. #include "dbus/dbus-gtype-specialized.h"
  157. #else
  158. #include <dbus/dbus-gtype-specialized.h>
  159. #endif
  160. /* definitions for some basic array types */
  161. #define DBUS_TYPE_G_BOOLEAN_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN))
  162. #define DBUS_TYPE_G_UCHAR_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR))
  163. #define DBUS_TYPE_G_UINT_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
  164. #define DBUS_TYPE_G_INT_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_INT))
  165. #define DBUS_TYPE_G_UINT64_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UINT64))
  166. #define DBUS_TYPE_G_INT64_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_INT64))
  167. #define DBUS_TYPE_G_OBJECT_ARRAY (dbus_g_type_get_collection ("GPtrArray", G_TYPE_OBJECT))
  168. #define DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
  169. typedef gchar DBusGObjectPath;
  170. GType dbus_g_object_path_get_g_type (void) G_GNUC_CONST;
  171. #define DBUS_TYPE_G_OBJECT_PATH (dbus_g_object_path_get_g_type ())
  172. typedef gchar DBusGSignature;
  173. GType dbus_g_signature_get_g_type (void) G_GNUC_CONST;
  174. #define DBUS_TYPE_G_SIGNATURE (dbus_g_signature_get_g_type ())
  175. void dbus_g_object_register_marshaller (GClosureMarshal marshaller,
  176. GType rettype,
  177. ...);
  178. void dbus_g_object_register_marshaller_array(GClosureMarshal marshaller,
  179. GType rettype,
  180. guint n_types,
  181. const GType* types);
  182. typedef struct _DBusGProxy DBusGProxy;
  183. typedef struct _DBusGProxyClass DBusGProxyClass;
  184. #define DBUS_TYPE_G_PROXY (dbus_g_proxy_get_type ())
  185. #define DBUS_G_PROXY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_G_PROXY, DBusGProxy))
  186. #define DBUS_G_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_G_PROXY, DBusGProxyClass))
  187. #define DBUS_IS_G_PROXY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_G_PROXY))
  188. #define DBUS_IS_G_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_G_PROXY))
  189. #define DBUS_G_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_G_PROXY, DBusGProxyClass))
  190. struct _DBusGProxy
  191. {
  192. /*< private >*/
  193. GObject parent;
  194. };
  195. struct _DBusGProxyClass
  196. {
  197. /*< private >*/
  198. GObjectClass parent_class; /**< Parent class */
  199. };
  200. typedef struct _DBusGProxyCall DBusGProxyCall;
  201. typedef void (* DBusGProxyCallNotify) (DBusGProxy *proxy,
  202. DBusGProxyCall *call_id,
  203. void *user_data);
  204. GType dbus_g_proxy_get_type (void) G_GNUC_CONST;
  205. DBusGProxy* dbus_g_proxy_new_for_name (DBusGConnection *connection,
  206. const char *name,
  207. const char *path,
  208. const char *iface);
  209. DBusGProxy* dbus_g_proxy_new_for_name_owner (DBusGConnection *connection,
  210. const char *name,
  211. const char *path,
  212. const char *iface,
  213. GError **error);
  214. DBusGProxy* dbus_g_proxy_new_from_proxy (DBusGProxy *proxy,
  215. const char *iface,
  216. const char *path);
  217. DBusGProxy* dbus_g_proxy_new_for_peer (DBusGConnection *connection,
  218. const char *path,
  219. const char *iface);
  220. void dbus_g_proxy_set_interface (DBusGProxy *proxy,
  221. const char *interface_name);
  222. void dbus_g_proxy_add_signal (DBusGProxy *proxy,
  223. const char *signal_name,
  224. GType first_type,
  225. ...);
  226. void dbus_g_proxy_connect_signal (DBusGProxy *proxy,
  227. const char *signal_name,
  228. GCallback handler,
  229. void *data,
  230. GClosureNotify free_data_func);
  231. void dbus_g_proxy_disconnect_signal (DBusGProxy *proxy,
  232. const char *signal_name,
  233. GCallback handler,
  234. void *data);
  235. gboolean dbus_g_proxy_call (DBusGProxy *proxy,
  236. const char *method,
  237. GError **error,
  238. GType first_arg_type,
  239. ...);
  240. gboolean dbus_g_proxy_call_with_timeout (DBusGProxy *proxy,
  241. const char *method,
  242. int timeout,
  243. GError **error,
  244. GType first_arg_type,
  245. ...);
  246. void dbus_g_proxy_call_no_reply (DBusGProxy *proxy,
  247. const char *method,
  248. GType first_arg_type,
  249. ...);
  250. DBusGProxyCall * dbus_g_proxy_begin_call (DBusGProxy *proxy,
  251. const char *method,
  252. DBusGProxyCallNotify notify,
  253. gpointer user_data,
  254. GDestroyNotify destroy,
  255. GType first_arg_type,
  256. ...);
  257. DBusGProxyCall * dbus_g_proxy_begin_call_with_timeout (DBusGProxy *proxy,
  258. const char *method,
  259. DBusGProxyCallNotify notify,
  260. gpointer user_data,
  261. GDestroyNotify destroy,
  262. int timeout,
  263. GType first_arg_type,
  264. ...);
  265. void dbus_g_proxy_set_default_timeout (DBusGProxy *proxy,
  266. int timeout);
  267. gboolean dbus_g_proxy_end_call (DBusGProxy *proxy,
  268. DBusGProxyCall *call,
  269. GError **error,
  270. GType first_arg_type,
  271. ...);
  272. void dbus_g_proxy_cancel_call (DBusGProxy *proxy,
  273. DBusGProxyCall *call);
  274. const char* dbus_g_proxy_get_path (DBusGProxy *proxy);
  275. const char* dbus_g_proxy_get_bus_name (DBusGProxy *proxy);
  276. const char* dbus_g_proxy_get_interface (DBusGProxy *proxy);
  277. typedef struct _DBusGMethodInvocation DBusGMethodInvocation;
  278. void dbus_g_method_return (DBusGMethodInvocation *context, ...);
  279. void dbus_g_method_return_error (DBusGMethodInvocation *context, const GError *error);
  280. DBusGConnection * dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context);
  281. /* Probably possible to replace this with a closure */
  282. typedef struct {
  283. GCallback cb;
  284. gpointer userdata;
  285. } DBusGAsyncData;
  286. #undef DBUS_INSIDE_DBUS_GLIB_H
  287. #include <dbus/dbus-gvalue-parse-variant.h>
  288. G_END_DECLS
  289. #endif /* DBUS_GLIB_H */