Oops, I forgot this. This is done internally in libgadu, and not doing it
[pidgin-git.git] / libpurple / signals.h
blob57bb7e90f3ca0e83723f6bf9a7d6d059a92beb1d
1 /**
2 * @file signals.h Signal API
3 * @ingroup core
4 */
6 /* purple
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #ifndef _PURPLE_SIGNALS_H_
27 #define _PURPLE_SIGNALS_H_
29 #include <glib.h>
30 #include "value.h"
32 #define PURPLE_CALLBACK(func) ((PurpleCallback)func)
34 typedef void (*PurpleCallback)(void);
35 typedef void (*PurpleSignalMarshalFunc)(PurpleCallback cb, va_list args,
36 void *data, void **return_val);
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 /**************************************************************************/
43 /** @name Signal API */
44 /**************************************************************************/
45 /*@{*/
47 /** The priority of a signal connected using purple_signal_connect().
49 * @see purple_signal_connect_priority()
51 #define PURPLE_SIGNAL_PRIORITY_DEFAULT 0
52 /** The largest signal priority; signals with this priority will be called
53 * <em>last</em>. (This is highest as in numerical value, not as in order of
54 * importance.)
56 * @see purple_signal_connect_priority().
58 #define PURPLE_SIGNAL_PRIORITY_HIGHEST 9999
59 /** The smallest signal priority; signals with this priority will be called
60 * <em>first</em>. (This is lowest as in numerical value, not as in order of
61 * importance.)
63 * @see purple_signal_connect_priority().
65 #define PURPLE_SIGNAL_PRIORITY_LOWEST -9999
67 /**
68 * Registers a signal in an instance.
70 * @param instance The instance to register the signal for.
71 * @param signal The signal name.
72 * @param marshal The marshal function.
73 * @param ret_value The return value type, or NULL for no return value.
74 * @param num_values The number of values to be passed to the callbacks.
75 * @param ... The values to pass to the callbacks.
77 * @return The signal ID local to that instance, or 0 if the signal
78 * couldn't be registered.
80 * @see PurpleValue
82 gulong purple_signal_register(void *instance, const char *signal,
83 PurpleSignalMarshalFunc marshal,
84 PurpleValue *ret_value, int num_values, ...);
86 /**
87 * Unregisters a signal in an instance.
89 * @param instance The instance to unregister the signal for.
90 * @param signal The signal name.
92 void purple_signal_unregister(void *instance, const char *signal);
94 /**
95 * Unregisters all signals in an instance.
97 * @param instance The instance to unregister the signal for.
99 void purple_signals_unregister_by_instance(void *instance);
102 * Returns a list of value types used for a signal.
104 * @param instance The instance the signal is registered to.
105 * @param signal The signal.
106 * @param ret_value The return value from the last signal handler.
107 * @param num_values The returned number of values.
108 * @param values The returned list of values.
110 void purple_signal_get_values(void *instance, const char *signal,
111 PurpleValue **ret_value,
112 int *num_values, PurpleValue ***values);
115 * Connects a signal handler to a signal for a particular object.
117 * Take care not to register a handler function twice. Purple will
118 * not correct any mistakes for you in this area.
120 * @param instance The instance to connect to.
121 * @param signal The name of the signal to connect.
122 * @param handle The handle of the receiver.
123 * @param func The callback function.
124 * @param data The data to pass to the callback function.
125 * @param priority The priority with which the handler should be called. Signal
126 * handlers are called in ascending numerical order of @a
127 * priority from #PURPLE_SIGNAL_PRIORITY_LOWEST to
128 * #PURPLE_SIGNAL_PRIORITY_HIGHEST.
130 * @return The signal handler ID.
132 * @see purple_signal_disconnect()
134 gulong purple_signal_connect_priority(void *instance, const char *signal,
135 void *handle, PurpleCallback func, void *data, int priority);
138 * Connects a signal handler to a signal for a particular object.
139 * (Its priority defaults to 0, aka #PURPLE_SIGNAL_PRIORITY_DEFAULT.)
141 * Take care not to register a handler function twice. Purple will
142 * not correct any mistakes for you in this area.
144 * @param instance The instance to connect to.
145 * @param signal The name of the signal to connect.
146 * @param handle The handle of the receiver.
147 * @param func The callback function.
148 * @param data The data to pass to the callback function.
150 * @return The signal handler ID.
152 * @see purple_signal_disconnect()
154 gulong purple_signal_connect(void *instance, const char *signal,
155 void *handle, PurpleCallback func, void *data);
158 * Connects a signal handler to a signal for a particular object.
160 * The signal handler will take a va_args of arguments, instead of
161 * individual arguments.
163 * Take care not to register a handler function twice. Purple will
164 * not correct any mistakes for you in this area.
166 * @param instance The instance to connect to.
167 * @param signal The name of the signal to connect.
168 * @param handle The handle of the receiver.
169 * @param func The callback function.
170 * @param data The data to pass to the callback function.
171 * @param priority The priority with which the handler should be called. Signal
172 * handlers are called in ascending numerical order of @a
173 * priority from #PURPLE_SIGNAL_PRIORITY_LOWEST to
174 * #PURPLE_SIGNAL_PRIORITY_HIGHEST.
176 * @return The signal handler ID.
178 * @see purple_signal_disconnect()
180 gulong purple_signal_connect_priority_vargs(void *instance, const char *signal,
181 void *handle, PurpleCallback func, void *data, int priority);
184 * Connects a signal handler to a signal for a particular object.
185 * (Its priority defaults to 0, aka #PURPLE_SIGNAL_PRIORITY_DEFAULT.)
187 * The signal handler will take a va_args of arguments, instead of
188 * individual arguments.
190 * Take care not to register a handler function twice. Purple will
191 * not correct any mistakes for you in this area.
193 * @param instance The instance to connect to.
194 * @param signal The name of the signal to connect.
195 * @param handle The handle of the receiver.
196 * @param func The callback function.
197 * @param data The data to pass to the callback function.
199 * @return The signal handler ID.
201 * @see purple_signal_disconnect()
203 gulong purple_signal_connect_vargs(void *instance, const char *signal,
204 void *handle, PurpleCallback func, void *data);
207 * Disconnects a signal handler from a signal on an object.
209 * @param instance The instance to disconnect from.
210 * @param signal The name of the signal to disconnect.
211 * @param handle The handle of the receiver.
212 * @param func The registered function to disconnect.
214 * @see purple_signal_connect()
216 void purple_signal_disconnect(void *instance, const char *signal,
217 void *handle, PurpleCallback func);
220 * Removes all callbacks associated with a receiver handle.
222 * @param handle The receiver handle.
224 void purple_signals_disconnect_by_handle(void *handle);
227 * Emits a signal.
229 * @param instance The instance emitting the signal.
230 * @param signal The signal being emitted.
232 * @see purple_signal_connect()
233 * @see purple_signal_disconnect()
235 void purple_signal_emit(void *instance, const char *signal, ...);
238 * Emits a signal, using a va_list of arguments.
240 * @param instance The instance emitting the signal.
241 * @param signal The signal being emitted.
242 * @param args The arguments list.
244 * @see purple_signal_connect()
245 * @see purple_signal_disconnect()
247 void purple_signal_emit_vargs(void *instance, const char *signal, va_list args);
250 * Emits a signal and returns the first non-NULL return value.
252 * Further signal handlers are NOT called after a handler returns
253 * something other than NULL.
255 * @param instance The instance emitting the signal.
256 * @param signal The signal being emitted.
258 * @return The first non-NULL return value
260 void *purple_signal_emit_return_1(void *instance, const char *signal, ...);
263 * Emits a signal and returns the first non-NULL return value.
265 * Further signal handlers are NOT called after a handler returns
266 * something other than NULL.
268 * @param instance The instance emitting the signal.
269 * @param signal The signal being emitted.
270 * @param args The arguments list.
272 * @return The first non-NULL return value
274 void *purple_signal_emit_vargs_return_1(void *instance, const char *signal,
275 va_list args);
278 * Initializes the signals subsystem.
280 void purple_signals_init(void);
283 * Uninitializes the signals subsystem.
285 void purple_signals_uninit(void);
287 /*@}*/
289 /**************************************************************************/
290 /** @name Marshal Functions */
291 /**************************************************************************/
292 /*@{*/
294 void purple_marshal_VOID(
295 PurpleCallback cb, va_list args, void *data, void **return_val);
296 void purple_marshal_VOID__INT(
297 PurpleCallback cb, va_list args, void *data, void **return_val);
298 void purple_marshal_VOID__INT_INT(
299 PurpleCallback cb, va_list args, void *data, void **return_val);
300 void purple_marshal_VOID__POINTER(
301 PurpleCallback cb, va_list args, void *data, void **return_val);
302 void purple_marshal_VOID__POINTER_UINT(
303 PurpleCallback cb, va_list args, void *data, void **return_val);
304 void purple_marshal_VOID__POINTER_INT_INT(
305 PurpleCallback cb, va_list args, void *data, void **return_val);
306 void purple_marshal_VOID__POINTER_INT_POINTER(
307 PurpleCallback cb, va_list args, void *data, void **return_val);
308 void purple_marshal_VOID__POINTER_POINTER(
309 PurpleCallback cb, va_list args, void *data, void **return_val);
310 void purple_marshal_VOID__POINTER_POINTER_UINT(
311 PurpleCallback cb, va_list args, void *data, void **return_val);
312 void purple_marshal_VOID__POINTER_POINTER_UINT_UINT(
313 PurpleCallback cb, va_list args, void *data, void **return_val);
314 void purple_marshal_VOID__POINTER_POINTER_POINTER(
315 PurpleCallback cb, va_list args, void *data, void **return_val);
316 void purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER(
317 PurpleCallback cb, va_list args, void *data, void **return_val);
318 void purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_POINTER(
319 PurpleCallback cb, va_list args, void *data, void **return_val);
320 void purple_marshal_VOID__POINTER_POINTER_POINTER_UINT(
321 PurpleCallback cb, va_list args, void *data, void **return_val);
322 void purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT(
323 PurpleCallback cb, va_list args, void *data, void **return_val);
324 void purple_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT(
325 PurpleCallback cb, va_list args, void *data, void **return_val);
327 void purple_marshal_INT__INT(
328 PurpleCallback cb, va_list args, void *data, void **return_val);
329 void purple_marshal_INT__INT_INT(
330 PurpleCallback cb, va_list args, void *data, void **return_val);
331 void purple_marshal_INT__POINTER_POINTER(
332 PurpleCallback cb, va_list args, void *data, void **return_val);
333 void purple_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER(
334 PurpleCallback cb, va_list args, void *data, void **return_val);
336 void purple_marshal_BOOLEAN__POINTER(
337 PurpleCallback cb, va_list args, void *data, void **return_val);
338 void purple_marshal_BOOLEAN__POINTER_POINTER(
339 PurpleCallback cb, va_list args, void *data, void **return_val);
340 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER(
341 PurpleCallback cb, va_list args, void *data, void **return_val);
342 void purple_marshal_BOOLEAN__POINTER_POINTER_UINT(
343 PurpleCallback cb, va_list args, void *data, void **return_val);
344 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT(
345 PurpleCallback cb, va_list args, void *data, void **return_val);
346 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER(
347 PurpleCallback cb, va_list args, void *data, void **return_val);
348 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER(
349 PurpleCallback cb, va_list args, void *data, void **return_val);
350 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_UINT(
351 PurpleCallback cb, va_list args, void *data, void **return_val);
352 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER(
353 PurpleCallback cb, va_list args, void *data, void **return_val);
355 void purple_marshal_BOOLEAN__INT_POINTER(
356 PurpleCallback cb, va_list args, void *data, void **return_val);
358 void purple_marshal_POINTER__POINTER_INT(
359 PurpleCallback cb, va_list args, void *data, void **return_val);
360 void purple_marshal_POINTER__POINTER_INT64(
361 PurpleCallback cb, va_list args, void *data, void **return_val);
362 void purple_marshal_POINTER__POINTER_INT_BOOLEAN(
363 PurpleCallback cb, va_list args, void *data, void **return_val);
364 void purple_marshal_POINTER__POINTER_INT64_BOOLEAN(
365 PurpleCallback cb, va_list args, void *data, void **return_val);
366 void purple_marshal_POINTER__POINTER_POINTER(
367 PurpleCallback cb, va_list args, void *data, void **return_val);
368 /*@}*/
370 #ifdef __cplusplus
372 #endif
374 #endif /* _PURPLE_SIGNALS_H_ */