dbus-glib.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* dbus-glib.h GLib integration
00003  *
00004  * Copyright (C) 2002, 2003  CodeFactory AB
00005  * Copyright (C) 2003, 2004 Red Hat, Inc.
00006  *
00007  * Licensed under the Academic Free License version 2.1
00008  * 
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  */
00024 #ifndef DBUS_GLIB_H
00025 #define DBUS_GLIB_H
00026 
00027 #include <glib-object.h>
00028 #include <dbus/dbus-shared.h>
00029 
00030 G_BEGIN_DECLS
00031 
00032 #define DBUS_INSIDE_DBUS_GLIB_H 1
00033 
00034 
00038 typedef struct _DBusGConnection DBusGConnection;
00042 typedef struct _DBusGMessage DBusGMessage;
00043 
00044 
00045 #define DBUS_TYPE_G_CONNECTION   (dbus_g_connection_get_g_type ())
00046 #define DBUS_TYPE_G_MESSAGE      (dbus_g_message_get_g_type ())
00047 GType dbus_g_connection_get_g_type   (void) G_GNUC_CONST;
00048 GType dbus_g_message_get_g_type      (void) G_GNUC_CONST;
00049 
00050 
00051 DBusGConnection*  dbus_g_connection_ref          (DBusGConnection        *connection);
00052 void              dbus_g_connection_unref        (DBusGConnection        *connection);
00053 DBusGMessage*     dbus_g_message_ref             (DBusGMessage           *message);
00054 void              dbus_g_message_unref           (DBusGMessage           *message);
00055 
00056 void              dbus_g_connection_flush        (DBusGConnection        *connection);
00057 
00058 GQuark dbus_g_error_quark (void);
00059 #define DBUS_GERROR dbus_g_error_quark ()
00060 
00061 typedef enum
00062 {
00063 #include <dbus/dbus-glib-error-enum.h>    
00064 } DBusGError;
00065 
00066 gboolean         dbus_g_error_has_name    (GError      *error,
00067                                            const char  *name);
00068 const char *     dbus_g_error_get_name    (GError      *error);
00069 
00070 void             dbus_g_thread_init (void);
00071 DBusGConnection* dbus_g_bus_get     (DBusBusType   type,
00072                                      GError      **error);
00073 
00074 typedef struct _DBusGObjectInfo DBusGObjectInfo;
00075 typedef struct _DBusGMethodInfo DBusGMethodInfo;
00076 
00082 struct _DBusGMethodInfo
00083 {
00084   GCallback                 function;    
00085   GClosureMarshal           marshaller;  
00086   int                       data_offset; 
00087 };
00088 
00093 struct _DBusGObjectInfo
00094 {
00095   int   format_version;         
00098   const DBusGMethodInfo *method_infos; 
00099   int   n_method_infos;                
00100   const char *data;             
00101   const char *exported_signals;  
00102   const char *exported_properties;  
00103 };
00104 
00105 void       dbus_g_object_type_install_info     (GType                 object_type,
00106                                                 const DBusGObjectInfo *info);
00107 
00108 void       dbus_g_error_domain_register        (GQuark                domain,
00109                                                 const char *          default_iface,
00110                                                 GType                 code_enum);
00111 
00112 void       dbus_g_connection_register_g_object (DBusGConnection       *connection,
00113                                                 const char            *at_path,
00114                                                 GObject               *object);
00115 GObject *  dbus_g_connection_lookup_g_object   (DBusGConnection       *connection,
00116                                                 const char            *at_path);
00117 
00118 #ifdef DBUS_COMPILATION
00119 #include "glib/dbus-gtype-specialized.h"
00120 #else
00121 #include <dbus/dbus-gtype-specialized.h>
00122 #endif
00123 
00124 /* definitions for some basic array types */
00125 #define DBUS_TYPE_G_BOOLEAN_ARRAY  (dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN))
00126 #define DBUS_TYPE_G_UCHAR_ARRAY    (dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR))
00127 #define DBUS_TYPE_G_UINT_ARRAY     (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
00128 #define DBUS_TYPE_G_INT_ARRAY      (dbus_g_type_get_collection ("GArray", G_TYPE_INT))
00129 #define DBUS_TYPE_G_UINT64_ARRAY   (dbus_g_type_get_collection ("GArray", G_TYPE_UINT64))
00130 #define DBUS_TYPE_G_INT64_ARRAY    (dbus_g_type_get_collection ("GArray", G_TYPE_INT64))
00131 #define DBUS_TYPE_G_OBJECT_ARRAY   (dbus_g_type_get_collection ("GPtrArray", G_TYPE_OBJECT))
00132 
00133 #define DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
00134 
00135 GType        dbus_g_object_path_get_g_type         (void) G_GNUC_CONST;
00136 #define DBUS_TYPE_G_OBJECT_PATH (dbus_g_object_path_get_g_type ())
00137 
00138 void         dbus_g_object_register_marshaller      (GClosureMarshal  marshaller,
00139                                                      GType            rettype,
00140                                                      ...);
00141 void         dbus_g_object_register_marshaller_array(GClosureMarshal  marshaller,
00142                                                      GType            rettype,
00143                                                      guint            n_types,
00144                                                      const GType*     types);
00145 
00146 typedef struct _DBusGProxy       DBusGProxy;
00147 typedef struct _DBusGProxyClass  DBusGProxyClass;
00148 
00149 #define DBUS_TYPE_G_PROXY              (dbus_g_proxy_get_type ())
00150 #define DBUS_G_PROXY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_G_PROXY, DBusGProxy))
00151 #define DBUS_G_PROXY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_G_PROXY, DBusGProxyClass))
00152 #define DBUS_IS_G_PROXY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_G_PROXY))
00153 #define DBUS_IS_G_PROXY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_G_PROXY))
00154 #define DBUS_G_PROXY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_G_PROXY, DBusGProxyClass))
00155 
00156 
00157 typedef struct _DBusGProxyCall DBusGProxyCall;
00158 typedef void (* DBusGProxyCallNotify) (DBusGProxy       *proxy,
00159                                        DBusGProxyCall   *call_id,
00160                                        void             *user_data);
00161 
00162 GType             dbus_g_proxy_get_type              (void) G_GNUC_CONST;
00163 DBusGProxy*       dbus_g_proxy_new_for_name          (DBusGConnection   *connection,
00164                                                       const char        *name,
00165                                                       const char        *path,
00166                                                       const char        *interface);
00167 DBusGProxy*       dbus_g_proxy_new_for_name_owner    (DBusGConnection   *connection,
00168                                                       const char        *name,
00169                                                       const char        *path,
00170                                                       const char        *interface,
00171                                                       GError           **error);
00172 DBusGProxy*       dbus_g_proxy_new_from_proxy        (DBusGProxy        *proxy,
00173                                                       const char        *interface,
00174                                                       const char        *path_name);
00175 DBusGProxy*       dbus_g_proxy_new_for_peer          (DBusGConnection   *connection,
00176                                                       const char        *path_name,
00177                                                       const char        *interface_name);
00178 
00179 void              dbus_g_proxy_set_interface         (DBusGProxy        *proxy,
00180                                                       const char        *interface_name);
00181 void              dbus_g_proxy_add_signal            (DBusGProxy        *proxy,
00182                                                       const char        *signal_name,
00183                                                       GType              first_type, 
00184                                                       ...);
00185 
00186 void              dbus_g_proxy_connect_signal        (DBusGProxy        *proxy,
00187                                                       const char        *signal_name,
00188                                                       GCallback          handler,
00189                                                       void              *data,
00190                                                       GClosureNotify     free_data_func);
00191 void              dbus_g_proxy_disconnect_signal     (DBusGProxy        *proxy,
00192                                                       const char        *signal_name,
00193                                                       GCallback          handler,
00194                                                       void              *data);
00195 
00196 gboolean          dbus_g_proxy_call                  (DBusGProxy        *proxy,
00197                                                       const char        *method,
00198                                                       GError           **error,
00199                                                       GType              first_arg_type,
00200                                                       ...);
00201 
00202 void              dbus_g_proxy_call_no_reply         (DBusGProxy        *proxy,
00203                                                       const char        *method,
00204                                                       GType              first_arg_type,
00205                                                       ...);
00206 
00207 DBusGProxyCall *  dbus_g_proxy_begin_call            (DBusGProxy        *proxy,
00208                                                       const char        *method,
00209                                                       DBusGProxyCallNotify notify,
00210                                                       gpointer           data,
00211                                                       GDestroyNotify     destroy,
00212                                                       GType              first_arg_type,
00213                                                       ...);
00214 gboolean          dbus_g_proxy_end_call              (DBusGProxy        *proxy,
00215                                                       DBusGProxyCall    *call,
00216                                                       GError           **error,
00217                                                       GType              first_arg_type,
00218                                                       ...);
00219 void              dbus_g_proxy_cancel_call           (DBusGProxy        *proxy,
00220                                                       DBusGProxyCall    *call);
00221 
00222 const char*       dbus_g_proxy_get_path              (DBusGProxy        *proxy);
00223 
00224 const char*       dbus_g_proxy_get_bus_name          (DBusGProxy        *proxy);
00225 
00226 const char*       dbus_g_proxy_get_interface         (DBusGProxy        *proxy);
00227 
00228 typedef struct _DBusGMethodInvocation DBusGMethodInvocation;
00229 
00230 void              dbus_g_method_return               (DBusGMethodInvocation *context, ...);
00231 
00232 void              dbus_g_method_return_error         (DBusGMethodInvocation *context, GError *error);
00233 
00234 /* Probably possible to replace this with a closure */
00235 typedef struct {
00236   GCallback cb;
00237   gpointer userdata;
00238 } DBusGAsyncData;
00239 
00240 #undef DBUS_INSIDE_DBUS_GLIB_H
00241 
00242 G_END_DECLS
00243 
00244 #endif /* DBUS_GLIB_H */

Generated on Tue Jul 7 15:13:58 2009 for D-BUS by  doxygen 1.4.6