Mercurial > pidgin
annotate src/dbus-server.h @ 13955:2d6f7ac4b6f2
[gaim-migrate @ 16503]
Get rid of an assertion failure when trying to load our D-BUS example
plugin if the D-BUS subsystem is not initialized for whatever reason.
Not only that, the plugin gracefully fails to load and prints an
error message.
These error messages could be improved. If you're familiar with how
D-BUS works then go for it.
Also, do we need to be uninitializing any of the D-BUS stuff?
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 17 Jul 2006 05:50:28 +0000 |
parents | a539caf502b0 |
children | f61428cc4019 |
rev | line source |
---|---|
11055 | 1 /** |
2 * @file dbus-server.h Gaim DBUS Server | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Gaim 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 _GAIM_DBUS_SERVER_H_ | |
28 #define _GAIM_DBUS_SERVER_H_ | |
29 | |
11080 | 30 #include "value.h" |
11067 | 31 |
11171 | 32 |
11055 | 33 G_BEGIN_DECLS |
34 | |
11171 | 35 /** |
36 Types of pointers are identified by the ADDRESS of a GaimDbusType | |
37 object. This way, plugins can easily access types defined in gaim | |
38 proper as well as introduce their own types that will not conflict | |
39 with those introduced by other plugins. | |
40 | |
11501
9563b768e8e2
[gaim-migrate @ 13746]
Richard Laager <rlaager@wiktel.com>
parents:
11171
diff
changeset
|
41 The structure GaimDbusType has only one element (GaimDBusType::parent), a |
9563b768e8e2
[gaim-migrate @ 13746]
Richard Laager <rlaager@wiktel.com>
parents:
11171
diff
changeset
|
42 contains a pointer to the parent type, or @c NULL if the type has no |
9563b768e8e2
[gaim-migrate @ 13746]
Richard Laager <rlaager@wiktel.com>
parents:
11171
diff
changeset
|
43 parent. Parent means the same as the base class in object oriented |
11171 | 44 programming. |
11501
9563b768e8e2
[gaim-migrate @ 13746]
Richard Laager <rlaager@wiktel.com>
parents:
11171
diff
changeset
|
45 */ |
11171 | 46 |
47 typedef struct _GaimDBusType GaimDBusType; | |
48 | |
49 struct _GaimDBusType { | |
50 GaimDBusType *parent; | |
51 }; | |
11067 | 52 |
13783
a539caf502b0
[gaim-migrate @ 16195]
Richard Laager <rlaager@wiktel.com>
parents:
12627
diff
changeset
|
53 /* By convention, the GaimDBusType variable representing each structure |
11171 | 54 GaimSomeStructure has the name GAIM_DBUS_TYPE_GaimSomeStructure. |
55 The following macros facilitate defining such variables | |
11067 | 56 |
11171 | 57 #GAIM_DBUS_DECLARE_TYPE declares an extern variable representing a |
58 given type, for use in header files. | |
59 | |
60 #GAIM_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 #GAIM_DBUS_DEFINE_INHERITING_TYPE. | |
63 */ | |
11080 | 64 |
11171 | 65 #define GAIM_DBUS_TYPE(type) (&GAIM_DBUS_TYPE_##type) |
66 | |
67 | |
68 #define GAIM_DBUS_DECLARE_TYPE(type) \ | |
69 extern GaimDBusType GAIM_DBUS_TYPE_##type; | |
11067 | 70 |
11171 | 71 #define GAIM_DBUS_DEFINE_TYPE(type) \ |
72 GaimDBusType GAIM_DBUS_TYPE_##type = { NULL }; | |
11080 | 73 |
11171 | 74 #define GAIM_DBUS_DEFINE_INHERITING_TYPE(type, parent) \ |
75 GaimDBusType GAIM_DBUS_TYPE_##type = { GAIM_DBUS_TYPE(parent) }; | |
76 | |
11055 | 77 |
11067 | 78 /** |
79 Initializes gaim dbus pointer registration engine. | |
80 | |
81 Remote dbus applications need a way of addressing objects exposed | |
82 by gaim to the outside world. In gaim itself, these objects (such | |
83 as GaimBuddy and company) are identified by pointers. The gaim | |
84 dbus pointer registration engine converts pointers to handles and | |
85 back. | |
86 | |
87 In order for an object to participate in the scheme, it must | |
88 register itself and its type with the engine. This registration | |
89 allocates an integer id which can be resolved to the pointer and | |
90 back. | |
91 | |
92 Handles are not persistent. They are reissued every time gaim is | |
93 started. This is not good; external applications that use gaim | |
94 should work even whether gaim was restarted in the middle of the | |
95 interaction. | |
96 | |
97 Pointer registration is only a temporary solution. When GaimBuddy | |
98 and similar structures have been converted into gobjects, this | |
99 registration will be done automatically by objects themselves. | |
100 | |
101 By the way, this kind of object-handle translation should be so | |
102 common that there must be a library (maybe even glib) that | |
103 implements it. I feel a bit like reinventing the wheel here. | |
104 */ | |
105 void gaim_dbus_init_ids(void); | |
106 | |
107 /** | |
108 Registers a typed pointer. | |
109 | |
11129 | 110 @param node The pointer to register. |
111 @param type Type of that pointer. | |
11067 | 112 */ |
11171 | 113 void gaim_dbus_register_pointer(gpointer node, GaimDBusType *type); |
11067 | 114 |
115 /** | |
116 Unregisters a pointer previously registered with | |
117 gaim_dbus_register_pointer. | |
118 | |
11129 | 119 @param node The pointer to register. |
11067 | 120 */ |
121 void gaim_dbus_unregister_pointer(gpointer node); | |
122 | |
11080 | 123 |
124 | |
125 /** | |
126 Emits a dbus signal. | |
127 | |
11171 | 128 @param name The name of the signal ("bla-bla-blaa") |
11080 | 129 @param num_values The number of parameters. |
130 @param values Array of pointers to #GaimValue objects representing | |
131 the types of the parameters. | |
132 @param vargs A va_list containing the actual parameters. | |
11171 | 133 */ |
11903 | 134 void gaim_dbus_signal_emit_gaim(const char *name, int num_values, |
11171 | 135 GaimValue **values, va_list vargs); |
11080 | 136 |
11171 | 137 /** |
13955 | 138 * Returns whether Gaim's D-BUS subsystem is up and running. If it's |
139 * NOT running then gaim_dbus_dispatch_init() failed for some reason, | |
140 * and a message should have been gaim_debug_error()'ed. | |
141 * | |
142 * This function should be called by any DBUS plugin before trying | |
143 * to use the DBUS API. See plugins/dbus-example.c for usage. | |
11171 | 144 * |
13955 | 145 * @return If the D-BUS subsystem started with no problems then this |
146 * will return NULL and everything will be hunky dory. If | |
147 * there was an error initializing the D-BUS subsystem then | |
148 * this will return an error message explaining why. | |
11171 | 149 */ |
13955 | 150 const char *gaim_dbus_get_init_error(void); |
11080 | 151 |
12627 | 152 /** |
153 * Returns the dbus subsystem handle. | |
154 * | |
155 * @return The dbus subsystem handle. | |
156 */ | |
157 void *gaim_dbus_get_handle(void); | |
11080 | 158 |
11171 | 159 /** |
13955 | 160 * Starts Gaim's D-BUS server. It is responsible for handling DBUS |
161 * requests from other applications. | |
162 */ | |
163 void gaim_dbus_init(void); | |
164 | |
165 /** | |
166 * Uninitializes Gaim's D-BUS server. | |
167 */ | |
168 void gaim_dbus_uninit(void); | |
169 | |
170 /** | |
11171 | 171 |
172 Macro #DBUS_EXPORT expands to nothing. It is used to indicate to the | |
11501
9563b768e8e2
[gaim-migrate @ 13746]
Richard Laager <rlaager@wiktel.com>
parents:
11171
diff
changeset
|
173 dbus-analize-functions.py script that the given function should be |
11171 | 174 available to other applications through DBUS. If |
11501
9563b768e8e2
[gaim-migrate @ 13746]
Richard Laager <rlaager@wiktel.com>
parents:
11171
diff
changeset
|
175 dbus-analize-functions.py is run without the "--export-only" option, |
11171 | 176 this prefix is ignored. |
177 | |
178 */ | |
179 | |
180 #define DBUS_EXPORT | |
181 | |
182 /* | |
183 Here we include the list of #GAIM_DBUS_DECLARE_TYPE statements for | |
184 all structs defined in gaim. This file has been generated by the | |
185 #dbus-analize-types.py script. | |
186 */ | |
187 | |
188 #include "dbus-types.h" | |
11067 | 189 |
11055 | 190 G_END_DECLS |
191 | |
192 #endif /* _GAIM_DBUS_SERVER_H_ */ |