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 DBUS_GERROR_FAILED,
00064 DBUS_GERROR_NO_MEMORY,
00065 DBUS_GERROR_SERVICE_UNKNOWN,
00066 DBUS_GERROR_NAME_HAS_NO_OWNER,
00067 DBUS_GERROR_NO_REPLY,
00068 DBUS_GERROR_IO_ERROR,
00069 DBUS_GERROR_BAD_ADDRESS,
00070 DBUS_GERROR_NOT_SUPPORTED,
00071 DBUS_GERROR_LIMITS_EXCEEDED,
00072 DBUS_GERROR_ACCESS_DENIED,
00073 DBUS_GERROR_AUTH_FAILED,
00074 DBUS_GERROR_NO_SERVER,
00075 DBUS_GERROR_TIMEOUT,
00076 DBUS_GERROR_NO_NETWORK,
00077 DBUS_GERROR_ADDRESS_IN_USE,
00078 DBUS_GERROR_DISCONNECTED,
00079 DBUS_GERROR_INVALID_ARGS,
00080 DBUS_GERROR_FILE_NOT_FOUND,
00081 DBUS_GERROR_FILE_EXISTS,
00082 DBUS_GERROR_UNKNOWN_METHOD,
00083 DBUS_GERROR_TIMED_OUT,
00084 DBUS_GERROR_MATCH_RULE_NOT_FOUND,
00085 DBUS_GERROR_MATCH_RULE_INVALID,
00086 DBUS_GERROR_SPAWN_EXEC_FAILED,
00087 DBUS_GERROR_SPAWN_FORK_FAILED,
00088 DBUS_GERROR_SPAWN_CHILD_EXITED,
00089 DBUS_GERROR_SPAWN_CHILD_SIGNALED,
00090 DBUS_GERROR_SPAWN_FAILED,
00091 DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN,
00092 DBUS_GERROR_INVALID_SIGNATURE,
00093 DBUS_GERROR_INVALID_FILE_CONTENT,
00094 DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN,
00095 DBUS_GERROR_REMOTE_EXCEPTION
00096 } DBusGError;
00097 
00098 gboolean         dbus_g_error_has_name    (GError      *error,
00099                                            const char  *name);
00100 const char *     dbus_g_error_get_name    (GError      *error);
00101 
00102 void             dbus_g_thread_init (void);
00103 
00104 DBusGConnection* dbus_g_connection_open (const gchar  *address,
00105                                          GError      **error);
00106 DBusGConnection* dbus_g_bus_get         (DBusBusType   type,
00107                                          GError      **error);
00108 
00109 typedef struct _DBusGObjectInfo DBusGObjectInfo;
00110 typedef struct _DBusGMethodInfo DBusGMethodInfo;
00111 
00122 struct _DBusGMethodInfo
00123 {
00124   GCallback                 function;    
00125   GClosureMarshal           marshaller;  
00126   int                       data_offset; 
00127 };
00128 
00142 struct _DBusGObjectInfo
00143 {
00144   int   format_version;
00145                        
00146   const DBusGMethodInfo *method_infos;
00147   int   n_method_infos;                
00148   const char *data; 
00149   const char *exported_signals;  
00150   const char *exported_properties; 
00151 };
00152 
00153 void       dbus_g_object_type_install_info     (GType                 object_type,
00154                                                 const DBusGObjectInfo *info);
00155 
00156 void       dbus_g_error_domain_register        (GQuark                domain,
00157                                                 const char *          default_iface,
00158                                                 GType                 code_enum);
00159 
00160 void       dbus_g_connection_register_g_object (DBusGConnection       *connection,
00161                                                 const char            *at_path,
00162                                                 GObject               *object);
00163 GObject *  dbus_g_connection_lookup_g_object   (DBusGConnection       *connection,
00164                                                 const char            *at_path);
00165 
00166 #ifdef DBUS_COMPILATION
00167 #include "dbus/dbus-gtype-specialized.h"
00168 #else
00169 #include <dbus/dbus-gtype-specialized.h>
00170 #endif
00171 
00172 /* definitions for some basic array types */
00173 #define DBUS_TYPE_G_BOOLEAN_ARRAY  (dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN))
00174 #define DBUS_TYPE_G_UCHAR_ARRAY    (dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR))
00175 #define DBUS_TYPE_G_UINT_ARRAY     (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
00176 #define DBUS_TYPE_G_INT_ARRAY      (dbus_g_type_get_collection ("GArray", G_TYPE_INT))
00177 #define DBUS_TYPE_G_UINT64_ARRAY   (dbus_g_type_get_collection ("GArray", G_TYPE_UINT64))
00178 #define DBUS_TYPE_G_INT64_ARRAY    (dbus_g_type_get_collection ("GArray", G_TYPE_INT64))
00179 #define DBUS_TYPE_G_OBJECT_ARRAY   (dbus_g_type_get_collection ("GPtrArray", G_TYPE_OBJECT))
00180 
00181 #define DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
00182 
00183 GType        dbus_g_object_path_get_g_type         (void) G_GNUC_CONST;
00184 #define DBUS_TYPE_G_OBJECT_PATH (dbus_g_object_path_get_g_type ())
00185 
00186 GType        dbus_g_signature_get_g_type           (void) G_GNUC_CONST;
00187 #define DBUS_TYPE_G_SIGNATURE (dbus_g_signature_get_g_type ())
00188 
00189 void         dbus_g_object_register_marshaller      (GClosureMarshal  marshaller,
00190                                                      GType            rettype,
00191                                                      ...);
00192 void         dbus_g_object_register_marshaller_array(GClosureMarshal  marshaller,
00193                                                      GType            rettype,
00194                                                      guint            n_types,
00195                                                      const GType*     types);
00196 
00197 typedef struct _DBusGProxy       DBusGProxy;
00198 typedef struct _DBusGProxyClass  DBusGProxyClass;
00199 
00200 #define DBUS_TYPE_G_PROXY              (dbus_g_proxy_get_type ())
00201 #define DBUS_G_PROXY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_G_PROXY, DBusGProxy))
00202 #define DBUS_G_PROXY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_G_PROXY, DBusGProxyClass))
00203 #define DBUS_IS_G_PROXY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_G_PROXY))
00204 #define DBUS_IS_G_PROXY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_G_PROXY))
00205 #define DBUS_G_PROXY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_G_PROXY, DBusGProxyClass))
00206 
00207 struct _DBusGProxy
00208 {
00209   GObject parent;
00210 };
00211 
00212 struct _DBusGProxyClass
00213 {
00214   GObjectClass parent_class;  
00215 };
00216 
00217 typedef struct _DBusGProxyCall DBusGProxyCall;
00218 typedef void (* DBusGProxyCallNotify) (DBusGProxy       *proxy,
00219                                        DBusGProxyCall   *call_id,
00220                                        void             *user_data);
00221 
00222 GType             dbus_g_proxy_get_type              (void) G_GNUC_CONST;
00223 DBusGProxy*       dbus_g_proxy_new_for_name          (DBusGConnection   *connection,
00224                                                       const char        *name,
00225                                                       const char        *path,
00226                                                       const char        *interface);
00227 DBusGProxy*       dbus_g_proxy_new_for_name_owner    (DBusGConnection   *connection,
00228                                                       const char        *name,
00229                                                       const char        *path,
00230                                                       const char        *interface,
00231                                                       GError           **error);
00232 DBusGProxy*       dbus_g_proxy_new_from_proxy        (DBusGProxy        *proxy,
00233                                                       const char        *interface,
00234                                                       const char        *path_name);
00235 DBusGProxy*       dbus_g_proxy_new_for_peer          (DBusGConnection   *connection,
00236                                                       const char        *path_name,
00237                                                       const char        *interface_name);
00238 
00239 void              dbus_g_proxy_set_interface         (DBusGProxy        *proxy,
00240                                                       const char        *interface_name);
00241 void              dbus_g_proxy_add_signal            (DBusGProxy        *proxy,
00242                                                       const char        *signal_name,
00243                                                       GType              first_type, 
00244                                                       ...);
00245 
00246 void              dbus_g_proxy_connect_signal        (DBusGProxy        *proxy,
00247                                                       const char        *signal_name,
00248                                                       GCallback          handler,
00249                                                       void              *data,
00250                                                       GClosureNotify     free_data_func);
00251 void              dbus_g_proxy_disconnect_signal     (DBusGProxy        *proxy,
00252                                                       const char        *signal_name,
00253                                                       GCallback          handler,
00254                                                       void              *data);
00255 
00256 gboolean          dbus_g_proxy_call                  (DBusGProxy        *proxy,
00257                                                       const char        *method,
00258                                                       GError           **error,
00259                                                       GType              first_arg_type,
00260                                                       ...);
00261 
00262 gboolean          dbus_g_proxy_call_with_timeout     (DBusGProxy        *proxy,
00263                                                       const char       *method,
00264                                                       int timeout,
00265                                                       GError           **error,
00266                                                       GType              first_arg_type,
00267                                                       ...);
00268 
00269 void              dbus_g_proxy_call_no_reply         (DBusGProxy        *proxy,
00270                                                       const char        *method,
00271                                                       GType              first_arg_type,
00272                                                       ...);
00273 
00274 DBusGProxyCall *  dbus_g_proxy_begin_call            (DBusGProxy        *proxy,
00275                                                       const char        *method,
00276                                                       DBusGProxyCallNotify notify,
00277                                                       gpointer           data,
00278                                                       GDestroyNotify     destroy,
00279                                                       GType              first_arg_type,
00280                                                       ...);
00281 DBusGProxyCall * dbus_g_proxy_begin_call_with_timeout (DBusGProxy        *proxy,
00282                                                        const char       *method,
00283                                                        DBusGProxyCallNotify notify,
00284                                                        gpointer       user_data,
00285                                                        GDestroyNotify   destroy,
00286                                                        int timeout,
00287                                                        GType             first_arg_type,
00288                                                        ...);
00289 
00290 void              dbus_g_proxy_set_default_timeout   (DBusGProxy        *proxy,
00291                                                       int                timeout);
00292 
00293 gboolean          dbus_g_proxy_end_call              (DBusGProxy        *proxy,
00294                                                       DBusGProxyCall    *call,
00295                                                       GError           **error,
00296                                                       GType              first_arg_type,
00297                                                       ...);
00298 void              dbus_g_proxy_cancel_call           (DBusGProxy        *proxy,
00299                                                       DBusGProxyCall    *call);
00300 
00301 const char*       dbus_g_proxy_get_path              (DBusGProxy        *proxy);
00302 
00303 const char*       dbus_g_proxy_get_bus_name          (DBusGProxy        *proxy);
00304 
00305 const char*       dbus_g_proxy_get_interface         (DBusGProxy        *proxy);
00306 
00307 typedef struct _DBusGMethodInvocation DBusGMethodInvocation;
00308 
00309 void              dbus_g_method_return               (DBusGMethodInvocation *context, ...);
00310 
00311 void              dbus_g_method_return_error         (DBusGMethodInvocation *context, GError *error);
00312 
00313 /* Probably possible to replace this with a closure */
00314 typedef struct {
00315   GCallback cb;
00316   gpointer userdata;
00317 } DBusGAsyncData;
00318 
00319 #undef DBUS_INSIDE_DBUS_GLIB_H
00320 
00321 G_END_DECLS
00322 
00323 #endif /* DBUS_GLIB_H */

Generated on Tue Feb 24 16:47:59 2009 for D-BUSGLibBindings by  doxygen 1.5.1