2005-01-26 Havoc Pennington <hp@redhat.com>
[platform/upstream/dbus.git] / dbus / dbus-glib.h
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  */
24 #ifndef DBUS_GLIB_H
25 #define DBUS_GLIB_H
26
27 #include <glib-object.h>
28 #include <dbus/dbus-protocol.h>
29 #include <dbus/dbus-shared.h>
30
31 G_BEGIN_DECLS
32
33 #define DBUS_INSIDE_DBUS_GLIB_H 1
34
35
36 /**
37  * Convert to DBusConnection with dbus_g_connection_get_connection()
38  */
39 typedef struct DBusGConnection DBusGConnection;
40 /**
41  * Convert to DBusMessage with dbus_g_message_get_message()
42  */
43 typedef struct DBusGMessage DBusGMessage;
44 /**
45  * Deliberately not possible to convert to DBusPendingCall
46  */
47 typedef struct DBusGPendingCall DBusGPendingCall;
48
49 void dbus_g_connection_flush (DBusGConnection *connection);
50
51 GQuark dbus_g_error_quark (void);
52 #define DBUS_GERROR dbus_g_error_quark ()
53
54 typedef enum
55 {
56 #include <dbus/dbus-glib-error-enum.h>    
57 } DBusGError;
58
59 void             dbus_g_thread_init (void);
60 DBusGConnection* dbus_g_bus_get     (DBusBusType   type,
61                                      GError      **error);
62
63 typedef struct DBusGObjectInfo DBusGObjectInfo;
64 typedef struct DBusGMethodInfo DBusGMethodInfo;
65
66 typedef DBusHandlerResult (* DBusGMethodMarshaller) (DBusGConnection    *connection,
67                                                      DBusGMessage       *message,
68                                                      void               *user_data);
69
70 /**
71  * Object typically generated by dbus-glib-tool that
72  * stores a mapping from introspection data to a
73  * function pointer for a C method to be invoked.
74  */
75 struct DBusGMethodInfo
76 {
77   GCallback                 function;    /**< C method to invoke */
78   DBusGMethodMarshaller     marshaller;  /**< Marshaller to go DBusGMessage to C method */
79   int                       data_offset; /**< Offset into the introspection data */
80 };
81
82 /**
83  * Introspection data for a GObject, normally autogenerated by
84  * a tool such as dbus-glib-tool.
85  */
86 struct DBusGObjectInfo
87 {
88   int   format_version;         /**< Allows us to change the rest of this struct
89                                  *   by adding DBusGObjectInfo2, DBusGObjectInfo3, etc.
90                                  */
91   const DBusGMethodInfo *infos; /**< Array of method pointers */
92   const unsigned char *data;    /**< Introspection data */
93 };
94
95 void dbus_g_object_class_install_info    (GObjectClass          *object_class,
96                                           const DBusGObjectInfo *info);
97 void dbus_g_connection_register_g_object (DBusGConnection       *connection,
98                                           const char            *at_path,
99                                           GObject               *object);
100
101
102 typedef struct DBusGProxy       DBusGProxy;
103 typedef struct DBusGProxyClass  DBusGProxyClass;
104
105 #define DBUS_TYPE_G_PROXY              (dbus_g_proxy_get_type ())
106 #define DBUS_G_PROXY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_G_PROXY, DBusGProxy))
107 #define DBUS_G_PROXY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_G_PROXY, DBusGProxyClass))
108 #define DBUS_IS_G_PROXY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_G_PROXY))
109 #define DBUS_IS_G_PROXY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_G_PROXY))
110 #define DBUS_G_PROXY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_G_PROXY, DBusGProxyClass))
111
112
113 GType             dbus_g_proxy_get_type              (void) G_GNUC_CONST;
114 DBusGProxy*       dbus_g_proxy_new_for_name          (DBusGConnection   *connection,
115                                                       const char        *name,
116                                                       const char        *path,
117                                                       const char        *interface);
118 DBusGProxy*       dbus_g_proxy_new_for_name_owner    (DBusGConnection   *connection,
119                                                       const char        *name,
120                                                       const char        *path,
121                                                       const char        *interface,
122                                                       GError           **error);
123 DBusGProxy*       dbus_g_proxy_new_for_peer          (DBusGConnection   *connection,
124                                                       const char        *path_name,
125                                                       const char        *interface_name);
126 void              dbus_g_proxy_connect_signal        (DBusGProxy        *proxy,
127                                                       const char        *signal_name,
128                                                       GCallback          handler,
129                                                       void              *data,
130                                                       GClosureNotify     free_data_func);
131 void              dbus_g_proxy_disconnect_signal     (DBusGProxy        *proxy,
132                                                       const char        *signal_name,
133                                                       GCallback          handler,
134                                                       void              *data);
135 DBusGPendingCall* dbus_g_proxy_begin_call            (DBusGProxy        *proxy,
136                                                       const char        *method,
137                                                       int                first_arg_type,
138                                                       ...);
139 gboolean          dbus_g_proxy_end_call              (DBusGProxy        *proxy,
140                                                       DBusGPendingCall  *pending,
141                                                       GError           **error,
142                                                       int                first_arg_type,
143                                                       ...);
144 void              dbus_g_proxy_call_no_reply         (DBusGProxy        *proxy,
145                                                       const char        *method,
146                                                       int                first_arg_type,
147                                                       ...);
148
149
150 #undef DBUS_INSIDE_DBUS_GLIB_H
151
152 G_END_DECLS
153
154 #endif /* DBUS_GLIB_H */
155
156
157