3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef _PURPLE_SIGNALS_H_
23 #define _PURPLE_SIGNALS_H_
26 * @section_id: libpurple-signals
27 * @short_description: <filename>signals.h</filename>
28 * @title: Purple-signals API
29 * @see_also: <link linkend="chapter-tut-signals">Signals tutorial</link>
33 #include <glib-object.h>
35 #define PURPLE_CALLBACK(func) ((PurpleCallback)func)
37 typedef void (*PurpleCallback
)(void);
38 typedef void (*PurpleSignalMarshalFunc
)(PurpleCallback cb
, va_list args
,
39 void *data
, void **return_val
);
43 /******************************************************************************
45 *****************************************************************************/
48 * PURPLE_SIGNAL_PRIORITY_DEFAULT:
50 * The priority of a signal connected using purple_signal_connect().
52 * See purple_signal_connect_priority()
54 #define PURPLE_SIGNAL_PRIORITY_DEFAULT 0
57 * PURPLE_SIGNAL_PRIORITY_HIGHEST:
59 * The largest signal priority; signals with this priority will be called
60 * <emphasis>last</emphasis>. (This is highest as in numerical value, not as in
61 * order of importance.)
63 * See purple_signal_connect_priority().
65 #define PURPLE_SIGNAL_PRIORITY_HIGHEST 9999
68 * PURPLE_SIGNAL_PRIORITY_LOWEST:
70 * The smallest signal priority; signals with this priority will be called
71 * <emphasis>first</emphasis>. (This is lowest as in numerical value, not as in
72 * order of importance.)
74 * See purple_signal_connect_priority().
76 #define PURPLE_SIGNAL_PRIORITY_LOWEST -9999
79 * purple_signal_register:
80 * @instance: The instance to register the signal for.
81 * @signal: The signal name.
82 * @marshal: The marshal function.
83 * @ret_type: The return type, or G_TYPE_NONE for no return type.
84 * @num_values: The number of values to be passed to the callbacks.
85 * @...: The types of the parameters for the callbacks.
87 * Registers a signal in an instance.
89 * Returns: The signal ID local to that instance, or 0 if the signal
90 * couldn't be registered.
92 gulong
purple_signal_register(void *instance
, const char *signal
,
93 PurpleSignalMarshalFunc marshal
,
94 GType ret_type
, int num_values
, ...);
97 * purple_signal_unregister:
98 * @instance: The instance to unregister the signal for.
99 * @signal: The signal name.
101 * Unregisters a signal in an instance.
103 void purple_signal_unregister(void *instance
, const char *signal
);
106 * purple_signals_unregister_by_instance:
107 * @instance: The instance to unregister the signal for.
109 * Unregisters all signals in an instance.
111 void purple_signals_unregister_by_instance(void *instance
);
114 * purple_signal_get_types:
115 * @instance: The instance the signal is registered to.
116 * @signal: The signal.
117 * @ret_type: (out): The return type.
118 * @num_values: (out): The returned number of parameters.
119 * @param_types: (out): The returned list of parameter types.
121 * Outputs a list of value types used for a signal through the @ret_type,
122 * @num_values and @param_types out parameters.
124 void purple_signal_get_types(void *instance
, const char *signal
,
125 GType
*ret_type
, int *num_values
,
126 GType
**param_types
);
129 * purple_signal_connect_priority:
130 * @instance: The instance to connect to.
131 * @signal: The name of the signal to connect.
132 * @handle: The handle of the receiver.
133 * @func: The callback function.
134 * @data: The data to pass to the callback function.
135 * @priority: The priority with which the handler should be called. Signal
136 * handlers are called in ascending numerical order of
137 * @priority from #PURPLE_SIGNAL_PRIORITY_LOWEST to
138 * #PURPLE_SIGNAL_PRIORITY_HIGHEST.
140 * Connects a signal handler to a signal for a particular object.
142 * Take care not to register a handler function twice. Purple will
143 * not correct any mistakes for you in this area.
145 * See purple_signal_disconnect()
147 * Returns: The signal handler ID.
149 gulong
purple_signal_connect_priority(void *instance
, const char *signal
,
150 void *handle
, PurpleCallback func
, void *data
, int priority
);
153 * purple_signal_connect:
154 * @instance: The instance to connect to.
155 * @signal: The name of the signal to connect.
156 * @handle: The handle of the receiver.
157 * @func: The callback function.
158 * @data: The data to pass to the callback function.
160 * Connects a signal handler to a signal for a particular object.
161 * (Its priority defaults to 0, aka #PURPLE_SIGNAL_PRIORITY_DEFAULT.)
163 * Take care not to register a handler function twice. Purple will
164 * not correct any mistakes for you in this area.
166 * See purple_signal_disconnect()
168 * Returns: The signal handler ID.
170 gulong
purple_signal_connect(void *instance
, const char *signal
,
171 void *handle
, PurpleCallback func
, void *data
);
174 * purple_signal_connect_priority_vargs:
175 * @instance: The instance to connect to.
176 * @signal: The name of the signal to connect.
177 * @handle: The handle of the receiver.
178 * @func: The callback function.
179 * @data: The data to pass to the callback function.
180 * @priority: The priority with which the handler should be called. Signal
181 * handlers are called in ascending numerical order of
182 * @priority from #PURPLE_SIGNAL_PRIORITY_LOWEST to
183 * #PURPLE_SIGNAL_PRIORITY_HIGHEST.
185 * Connects a signal handler to a signal for a particular object.
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 * See purple_signal_disconnect()
195 * Returns: The signal handler ID.
197 gulong
purple_signal_connect_priority_vargs(void *instance
, const char *signal
,
198 void *handle
, PurpleCallback func
, void *data
, int priority
);
201 * purple_signal_connect_vargs:
202 * @instance: The instance to connect to.
203 * @signal: The name of the signal to connect.
204 * @handle: The handle of the receiver.
205 * @func: The callback function.
206 * @data: The data to pass to the callback function.
208 * Connects a signal handler to a signal for a particular object.
209 * (Its priority defaults to 0, aka #PURPLE_SIGNAL_PRIORITY_DEFAULT.)
211 * The signal handler will take a va_args of arguments, instead of
212 * individual arguments.
214 * Take care not to register a handler function twice. Purple will
215 * not correct any mistakes for you in this area.
217 * See purple_signal_disconnect()
219 * Returns: The signal handler ID.
221 gulong
purple_signal_connect_vargs(void *instance
, const char *signal
,
222 void *handle
, PurpleCallback func
, void *data
);
225 * purple_signal_disconnect:
226 * @instance: The instance to disconnect from.
227 * @signal: The name of the signal to disconnect.
228 * @handle: The handle of the receiver.
229 * @func: The registered function to disconnect.
231 * Disconnects a signal handler from a signal on an object.
233 * See purple_signal_connect()
235 void purple_signal_disconnect(void *instance
, const char *signal
,
236 void *handle
, PurpleCallback func
);
239 * purple_signals_disconnect_by_handle:
240 * @handle: The receiver handle.
242 * Removes all callbacks associated with a receiver handle.
244 void purple_signals_disconnect_by_handle(void *handle
);
247 * purple_signal_emit:
248 * @instance: The instance emitting the signal.
249 * @signal: The signal being emitted.
250 * @...: The arguments to pass to the callbacks.
254 * See purple_signal_connect(), purple_signal_disconnect()
256 void purple_signal_emit(void *instance
, const char *signal
, ...);
259 * purple_signal_emit_vargs:
260 * @instance: The instance emitting the signal.
261 * @signal: The signal being emitted.
262 * @args: The arguments list.
264 * Emits a signal, using a va_list of arguments.
266 * See purple_signal_connect(), purple_signal_disconnect()
268 void purple_signal_emit_vargs(void *instance
, const char *signal
, va_list args
);
271 * purple_signal_emit_return_1:
272 * @instance: The instance emitting the signal.
273 * @signal: The signal being emitted.
274 * @...: The arguments to pass to the callbacks.
276 * Emits a signal and returns the first non-NULL return value.
278 * Further signal handlers are NOT called after a handler returns
279 * something other than NULL.
281 * Returns: The first non-NULL return value
283 void *purple_signal_emit_return_1(void *instance
, const char *signal
, ...);
286 * purple_signal_emit_vargs_return_1:
287 * @instance: The instance emitting the signal.
288 * @signal: The signal being emitted.
289 * @args: The arguments list.
291 * Emits a signal and returns the first non-NULL return value.
293 * Further signal handlers are NOT called after a handler returns
294 * something other than NULL.
296 * Returns: The first non-NULL return value
298 void *purple_signal_emit_vargs_return_1(void *instance
, const char *signal
,
302 * purple_signals_init:
304 * Initializes the signals subsystem.
306 void purple_signals_init(void);
309 * purple_signals_uninit:
311 * Uninitializes the signals subsystem.
313 void purple_signals_uninit(void);
315 /**************************************************************************/
316 /* Marshal Functions */
317 /**************************************************************************/
319 void purple_marshal_VOID(
320 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
321 void purple_marshal_VOID__INT(
322 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
323 void purple_marshal_VOID__INT_INT(
324 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
325 void purple_marshal_VOID__POINTER(
326 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
327 void purple_marshal_VOID__POINTER_UINT(
328 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
329 void purple_marshal_VOID__POINTER_INT_INT(
330 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
331 void purple_marshal_VOID__POINTER_INT_POINTER(
332 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
333 void purple_marshal_VOID__POINTER_POINTER(
334 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
335 void purple_marshal_VOID__POINTER_POINTER_UINT(
336 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
337 void purple_marshal_VOID__POINTER_POINTER_UINT_UINT(
338 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
339 void purple_marshal_VOID__POINTER_UINT_UINT(
340 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
341 void purple_marshal_VOID__POINTER_POINTER_POINTER(
342 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
343 void purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER(
344 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
345 void purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_POINTER(
346 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
347 void purple_marshal_VOID__POINTER_POINTER_POINTER_UINT(
348 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
349 void purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT(
350 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
351 void purple_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT(
352 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
354 void purple_marshal_INT__INT(
355 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
356 void purple_marshal_INT__INT_INT(
357 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
358 void purple_marshal_INT__POINTER_POINTER(
359 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
360 void purple_marshal_INT__POINTER_POINTER_POINTER(
361 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
362 void purple_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER(
363 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
365 void purple_marshal_BOOLEAN__POINTER(
366 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
367 void purple_marshal_BOOLEAN__POINTER_POINTER(
368 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
369 void purple_marshal_BOOLEAN__POINTER_BOOLEAN(
370 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
371 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER(
372 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
373 void purple_marshal_BOOLEAN__POINTER_POINTER_UINT(
374 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
375 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT(
376 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
377 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER(
378 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
379 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER(
380 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
381 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_UINT(
382 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
383 void purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER(
384 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
386 void purple_marshal_BOOLEAN__INT_POINTER(
387 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
389 void purple_marshal_POINTER__POINTER(
390 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
391 void purple_marshal_POINTER__POINTER_INT(
392 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
393 void purple_marshal_POINTER__POINTER_INT64(
394 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
395 void purple_marshal_POINTER__POINTER_INT_BOOLEAN(
396 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
397 void purple_marshal_POINTER__POINTER_INT64_BOOLEAN(
398 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
399 void purple_marshal_POINTER__POINTER_POINTER_BOOLEAN(
400 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
401 void purple_marshal_POINTER__POINTER_POINTER(
402 PurpleCallback cb
, va_list args
, void *data
, void **return_val
);
406 #endif /* _PURPLE_SIGNALS_H_ */