comparison libpurple/dbus-server.h @ 20394:4a099e4d0d09

propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328) to branch 'im.pidgin.rlaager.merging.msnp13-and-pidgin' (head 4d82c29e56bd33cd6f94302e343dfeb5d68ab3eb)
author Richard Laager <rlaager@wiktel.com>
date Sun, 15 Apr 2007 03:43:17 +0000
parents 32c366eeeb99
children 176d0fc8bc16
comparison
equal deleted inserted replaced
20393:40a04930b233 20394:4a099e4d0d09
1 /**
2 * @file dbus-server.h Purple DBUS Server
3 * @ingroup core
4 *
5 * purple
6 *
7 * Purple is the legal property of its developers, whose names are too numerous
8 * to list here. Please refer to the COPYRIGHT file distributed with this
9 * source distribution.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27 #ifndef _PURPLE_DBUS_SERVER_H_
28 #define _PURPLE_DBUS_SERVER_H_
29
30 #include "value.h"
31
32
33 G_BEGIN_DECLS
34
35 /**
36 Types of pointers are identified by the ADDRESS of a PurpleDbusType
37 object. This way, plugins can easily access types defined in purple
38 proper as well as introduce their own types that will not conflict
39 with those introduced by other plugins.
40
41 The structure PurpleDbusType has only one element (PurpleDBusType::parent), a
42 contains a pointer to the parent type, or @c NULL if the type has no
43 parent. Parent means the same as the base class in object oriented
44 programming.
45 */
46
47 typedef struct _PurpleDBusType PurpleDBusType;
48
49 struct _PurpleDBusType {
50 PurpleDBusType *parent;
51 };
52
53 /* By convention, the PurpleDBusType variable representing each structure
54 PurpleSomeStructure has the name PURPLE_DBUS_TYPE_PurpleSomeStructure.
55 The following macros facilitate defining such variables
56
57 #PURPLE_DBUS_DECLARE_TYPE declares an extern variable representing a
58 given type, for use in header files.
59
60 #PURPLE_DBUS_DEFINE_TYPE defines a variable representing a given
61 type, use in .c files. It defines a new type without a parent; for
62 types with a parent use #PURPLE_DBUS_DEFINE_INHERITING_TYPE.
63 */
64
65 #define PURPLE_DBUS_TYPE(type) (&PURPLE_DBUS_TYPE_##type)
66
67
68 #define PURPLE_DBUS_DECLARE_TYPE(type) \
69 extern PurpleDBusType PURPLE_DBUS_TYPE_##type;
70
71 #define PURPLE_DBUS_DEFINE_TYPE(type) \
72 PurpleDBusType PURPLE_DBUS_TYPE_##type = { NULL };
73
74 #define PURPLE_DBUS_DEFINE_INHERITING_TYPE(type, parent) \
75 PurpleDBusType PURPLE_DBUS_TYPE_##type = { PURPLE_DBUS_TYPE(parent) };
76
77 #define PURPLE_DBUS_RETURN_FALSE_IF_DISABLED(plugin) \
78 if (purple_dbus_get_init_error() != NULL) \
79 { \
80 gchar *title; \
81 title = g_strdup_printf("Unable to Load %s Plugin", plugin->info->name); \
82 purple_notify_error(NULL, title, \
83 _("Purple's D-BUS server is not running for the reason listed below"), \
84 _(purple_dbus_get_init_error())); \
85 g_free(title); \
86 return FALSE; \
87 }
88
89 /**
90 Initializes purple dbus pointer registration engine.
91
92 Remote dbus applications need a way of addressing objects exposed
93 by purple to the outside world. In purple itself, these objects (such
94 as PurpleBuddy and company) are identified by pointers. The purple
95 dbus pointer registration engine converts pointers to handles and
96 back.
97
98 In order for an object to participate in the scheme, it must
99 register itself and its type with the engine. This registration
100 allocates an integer id which can be resolved to the pointer and
101 back.
102
103 Handles are not persistent. They are reissued every time purple is
104 started. This is not good; external applications that use purple
105 should work even whether purple was restarted in the middle of the
106 interaction.
107
108 Pointer registration is only a temporary solution. When PurpleBuddy
109 and similar structures have been converted into gobjects, this
110 registration will be done automatically by objects themselves.
111
112 By the way, this kind of object-handle translation should be so
113 common that there must be a library (maybe even glib) that
114 implements it. I feel a bit like reinventing the wheel here.
115 */
116 void purple_dbus_init_ids(void);
117
118 /**
119 Registers a typed pointer.
120
121 @param node The pointer to register.
122 @param type Type of that pointer.
123 */
124 void purple_dbus_register_pointer(gpointer node, PurpleDBusType *type);
125
126 /**
127 Unregisters a pointer previously registered with
128 purple_dbus_register_pointer.
129
130 @param node The pointer to register.
131 */
132 void purple_dbus_unregister_pointer(gpointer node);
133
134
135
136 /**
137 Emits a dbus signal.
138
139 @param name The name of the signal ("bla-bla-blaa")
140 @param num_values The number of parameters.
141 @param values Array of pointers to #PurpleValue objects representing
142 the types of the parameters.
143 @param vargs A va_list containing the actual parameters.
144 */
145 void purple_dbus_signal_emit_purple(const char *name, int num_values,
146 PurpleValue **values, va_list vargs);
147
148 /**
149 * Returns whether Purple's D-BUS subsystem is up and running. If it's
150 * NOT running then purple_dbus_dispatch_init() failed for some reason,
151 * and a message should have been purple_debug_error()'ed.
152 *
153 * Purple plugins that use D-BUS should use the
154 * PURPLE_DBUS_RETURN_FALSE_IF_DISABLED macro to short-circuit
155 * initialization if Purple's D-BUS subsystem is not running.
156 *
157 * @return If the D-BUS subsystem started with no problems then this
158 * will return NULL and everything will be hunky dory. If
159 * there was an error initializing the D-BUS subsystem then
160 * this will return an error message explaining why.
161 */
162 const char *purple_dbus_get_init_error(void);
163
164 /**
165 * Returns the dbus subsystem handle.
166 *
167 * @return The dbus subsystem handle.
168 */
169 void *purple_dbus_get_handle(void);
170
171 /**
172 * Starts Purple's D-BUS server. It is responsible for handling DBUS
173 * requests from other applications.
174 */
175 void purple_dbus_init(void);
176
177 /**
178 * Uninitializes Purple's D-BUS server.
179 */
180 void purple_dbus_uninit(void);
181
182 /**
183
184 Macro #DBUS_EXPORT expands to nothing. It is used to indicate to the
185 dbus-analize-functions.py script that the given function should be
186 available to other applications through DBUS. If
187 dbus-analize-functions.py is run without the "--export-only" option,
188 this prefix is ignored.
189
190 */
191
192 #define DBUS_EXPORT
193
194 /*
195 Here we include the list of #PURPLE_DBUS_DECLARE_TYPE statements for
196 all structs defined in purple. This file has been generated by the
197 #dbus-analize-types.py script.
198 */
199
200 #include "dbus-types.h"
201
202 G_END_DECLS
203
204 #endif /* _PURPLE_DBUS_SERVER_H_ */