summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-glib.h
blob: 5c002f49f702a684a04fbc1288ff0999d6698e2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-glib.h GLib integration
 *
 * Copyright (C) 2002, 2003  CodeFactory AB
 * Copyright (C) 2003, 2004 Red Hat, Inc.
 *
 * Licensed under the Academic Free License version 2.1
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
#ifndef DBUS_GLIB_H
#define DBUS_GLIB_H

#include <glib-object.h>
#include <dbus/dbus-protocol.h>
#include <dbus/dbus-shared.h>

G_BEGIN_DECLS

#define DBUS_INSIDE_DBUS_GLIB_H 1


/**
 * Convert to DBusConnection with dbus_g_connection_get_connection() in dbus-glib-lowlevel.h
 */
typedef struct DBusGConnection DBusGConnection;
/**
 * Convert to DBusMessage with dbus_g_message_get_message() in dbus-glib-lowlevel.h
 */
typedef struct DBusGMessage DBusGMessage;
/**
 * Deliberately not possible to convert to DBusPendingCall
 */
typedef struct DBusGPendingCall DBusGPendingCall;

typedef void (* DBusGPendingCallNotify) (DBusGPendingCall *pending,
                                         void             *user_data);


#define DBUS_TYPE_G_CONNECTION   (dbus_g_connection_get_g_type ())
#define DBUS_TYPE_G_MESSAGE      (dbus_g_message_get_g_type ())
#define DBUS_TYPE_G_PENDING_CALL (dbus_g_message_get_g_type ())
GType dbus_g_connection_get_g_type   (void) G_GNUC_CONST;
GType dbus_g_message_get_g_type      (void) G_GNUC_CONST;
GType dbus_g_pending_call_get_g_type (void) G_GNUC_CONST;


DBusGConnection*  dbus_g_connection_ref          (DBusGConnection        *connection);
void              dbus_g_connection_unref        (DBusGConnection        *connection);
DBusGPendingCall* dbus_g_pending_call_ref        (DBusGPendingCall       *call);
void              dbus_g_pending_call_unref      (DBusGPendingCall       *call);
DBusGMessage*     dbus_g_message_ref             (DBusGMessage           *message);
void              dbus_g_message_unref           (DBusGMessage           *message);

void              dbus_g_connection_flush        (DBusGConnection        *connection);

void              dbus_g_pending_call_set_notify (DBusGPendingCall       *call,
                                                  DBusGPendingCallNotify  callback,
                                                  void                   *callback_data,
                                                  GDestroyNotify          free_data_func);
void              dbus_g_pending_call_cancel     (DBusGPendingCall       *call);


GQuark dbus_g_error_quark (void);
#define DBUS_GERROR dbus_g_error_quark ()

typedef enum
{
#include <dbus/dbus-glib-error-enum.h>    
} DBusGError;

void             dbus_g_thread_init (void);
DBusGConnection* dbus_g_bus_get     (DBusBusType   type,
                                     GError      **error);

typedef struct DBusGObjectInfo DBusGObjectInfo;
typedef struct DBusGMethodInfo DBusGMethodInfo;

typedef DBusHandlerResult (* DBusGMethodMarshaller) (DBusGConnection    *connection,
                                                     DBusGMessage       *message,
                                                     void               *user_data);

/**
 * Object typically generated by dbus-glib-tool that
 * stores a mapping from introspection data to a
 * function pointer for a C method to be invoked.
 */
struct DBusGMethodInfo
{
  GCallback                 function;    /**< C method to invoke */
  DBusGMethodMarshaller     marshaller;  /**< Marshaller to go DBusGMessage to C method */
  int                       data_offset; /**< Offset into the introspection data */
};

/**
 * Introspection data for a GObject, normally autogenerated by
 * a tool such as dbus-glib-tool.
 */
struct DBusGObjectInfo
{
  int   format_version;         /**< Allows us to change the rest of this struct
                                 *   by adding DBusGObjectInfo2, DBusGObjectInfo3, etc.
                                 */
  const DBusGMethodInfo *infos; /**< Array of method pointers */
  const unsigned char *data;    /**< Introspection data */
};

void dbus_g_object_class_install_info    (GObjectClass          *object_class,
                                          const DBusGObjectInfo *info);
void dbus_g_connection_register_g_object (DBusGConnection       *connection,
                                          const char            *at_path,
                                          GObject               *object);


typedef struct DBusGProxy       DBusGProxy;
typedef struct DBusGProxyClass  DBusGProxyClass;

#define DBUS_TYPE_G_PROXY              (dbus_g_proxy_get_type ())
#define DBUS_G_PROXY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_G_PROXY, DBusGProxy))
#define DBUS_G_PROXY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_G_PROXY, DBusGProxyClass))
#define DBUS_IS_G_PROXY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_G_PROXY))
#define DBUS_IS_G_PROXY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_G_PROXY))
#define DBUS_G_PROXY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_G_PROXY, DBusGProxyClass))


GType             dbus_g_proxy_get_type              (void) G_GNUC_CONST;
DBusGProxy*       dbus_g_proxy_new_for_name          (DBusGConnection   *connection,
                                                      const char        *name,
                                                      const char        *path,
                                                      const char        *interface);
DBusGProxy*       dbus_g_proxy_new_for_name_owner    (DBusGConnection   *connection,
                                                      const char        *name,
                                                      const char        *path,
                                                      const char        *interface,
                                                      GError           **error);
DBusGProxy*       dbus_g_proxy_new_for_peer          (DBusGConnection   *connection,
                                                      const char        *path_name,
                                                      const char        *interface_name);
void              dbus_g_proxy_add_signal            (DBusGProxy        *proxy,
                                                      const char        *signal_name,
                                                      const char        *signature);
void              dbus_g_proxy_connect_signal        (DBusGProxy        *proxy,
                                                      const char        *signal_name,
                                                      GCallback          handler,
                                                      void              *data,
                                                      GClosureNotify     free_data_func);
void              dbus_g_proxy_disconnect_signal     (DBusGProxy        *proxy,
                                                      const char        *signal_name,
                                                      GCallback          handler,
                                                      void              *data);
DBusGPendingCall* dbus_g_proxy_begin_call            (DBusGProxy        *proxy,
                                                      const char        *method,
                                                      int                first_arg_type,
                                                      ...);
gboolean          dbus_g_proxy_end_call              (DBusGProxy        *proxy,
                                                      DBusGPendingCall  *pending,
                                                      GError           **error,
                                                      int                first_arg_type,
                                                      ...);
void              dbus_g_proxy_call_no_reply         (DBusGProxy        *proxy,
                                                      const char        *method,
                                                      int                first_arg_type,
                                                      ...);
const char*       dbus_g_proxy_get_bus_name          (DBusGProxy        *proxy);

#undef DBUS_INSIDE_DBUS_GLIB_H

G_END_DECLS

#endif /* DBUS_GLIB_H */