Mercurial > pidgin.yaz
annotate src/signals.h @ 6615:a3602428ff53
[gaim-migrate @ 7139]
Grr.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 24 Aug 2003 20:36:41 +0000 |
parents | 800ef4a51096 |
children | 41120df7ed94 |
rev | line source |
---|---|
6485 | 1 /** |
6488
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2 * @file signals.h Signal API |
6485 | 3 * @ingroup core |
4 * | |
5 * gaim | |
6 * | |
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
8 * | |
9 * This program is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 #ifndef _GAIM_SIGNAL_H_ | |
24 #define _GAIM_SIGNAL_H_ | |
25 | |
26 #include <glib.h> | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
27 #include "value.h" |
6485 | 28 |
29 #define GAIM_CALLBACK(func) ((GaimCallback)func) | |
30 | |
31 typedef void (*GaimCallback)(void); | |
32 typedef void (*GaimSignalMarshalFunc)(GaimCallback cb, va_list args, | |
33 void *data, void **return_val); | |
34 | |
35 #ifdef __cplusplus | |
36 extern "C" { | |
37 #endif | |
38 | |
39 /**************************************************************************/ | |
40 /** @name Signal API */ | |
41 /**************************************************************************/ | |
42 /*@{*/ | |
43 | |
44 /** | |
45 * Registers a signal in an instance. | |
46 * | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
47 * @param instance The instance to register the signal for. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
48 * @param signal The signal name. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
49 * @param marshal The marshal function. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
50 * @param ret_value The return value type, or NULL for no return value. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
51 * @param num_types The number of values to be passed to the callbacks. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
52 * @param ... The values to pass to the callbacks. |
6485 | 53 * |
54 * @return The signal ID local to that instance, or 0 if the signal | |
55 * couldn't be registered. | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
56 * |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
57 * @see GaimValue |
6485 | 58 */ |
59 gulong gaim_signal_register(void *instance, const char *signal, | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
60 GaimSignalMarshalFunc marshal, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
61 GaimValue *ret_value, int num_values, ...); |
6485 | 62 |
63 /** | |
64 * Unregisters a signal in an instance. | |
65 * | |
66 * @param instance The instance to unregister the signal for. | |
67 * @param signal The signal name. | |
68 */ | |
69 void gaim_signal_unregister(void *instance, const char *signal); | |
70 | |
71 /** | |
72 * Unregisters all signals in an instance. | |
73 * | |
74 * @param instance The instance to unregister the signal for. | |
75 */ | |
76 void gaim_signals_unregister_by_instance(void *instance); | |
77 | |
78 /** | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
79 * Returns a list of value types used for a signal. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
80 * |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
81 * @param instance The instance the signal is registered to. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
82 * @param signal The signal. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
83 * @param num_values The returned number of values. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
84 * @param values The returned list of values. |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
85 */ |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
86 void gaim_signal_get_values(void *instance, const char *signal, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
87 GaimValue **ret_value, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
88 int *num_values, GaimValue ***values); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
89 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
90 /** |
6485 | 91 * Connects a signal handler to a signal for a particular object. |
92 * | |
93 * Take care not to register a handler function twice. Gaim will | |
94 * not correct any mistakes for you in this area. | |
95 * | |
96 * @param instance The instance to connect to. | |
97 * @param signal The name of the signal to connect. | |
98 * @param handle The handle of the receiver. | |
99 * @param func The callback function. | |
100 * @param data The data to pass to the callback function. | |
101 * | |
102 * @return The signal handler ID. | |
103 * | |
104 * @see gaim_signal_disconnect() | |
105 */ | |
106 gulong gaim_signal_connect(void *instance, const char *signal, | |
107 void *handle, GaimCallback func, void *data); | |
108 | |
109 /** | |
6548
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
110 * Connects a signal handler to a signal for a particular object. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
111 * |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
112 * The signal handler will take a va_args of arguments, instead of |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
113 * individual arguments. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
114 * |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
115 * Take care not to register a handler function twice. Gaim will |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
116 * not correct any mistakes for you in this area. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
117 * |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
118 * @param instance The instance to connect to. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
119 * @param signal The name of the signal to connect. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
120 * @param handle The handle of the receiver. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
121 * @param func The callback function. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
122 * @param data The data to pass to the callback function. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
123 * |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
124 * @return The signal handler ID. |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
125 * |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
126 * @see gaim_signal_disconnect() |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
127 */ |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
128 gulong gaim_signal_connect_vargs(void *instance, const char *signal, |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
129 void *handle, GaimCallback func, void *data); |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
130 |
d01ba50e3f3e
[gaim-migrate @ 7070]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
131 /** |
6485 | 132 * Disconnects a signal handler from a signal on an object. |
133 * | |
134 * @param instance The instance to disconnect from. | |
135 * @param signal The name of the signal to disconnect. | |
136 * @param handle The handle of the receiver. | |
137 * @param func The registered function to disconnect. | |
138 * | |
139 * @see gaim_signal_connect() | |
140 */ | |
141 void gaim_signal_disconnect(void *instance, const char *signal, | |
142 void *handle, GaimCallback func); | |
143 | |
144 /** | |
145 * Removes all callbacks associated with a receiver handle. | |
146 * | |
147 * @param handle The receiver handle. | |
148 */ | |
149 void gaim_signals_disconnect_by_handle(void *handle); | |
150 | |
151 /** | |
152 * Emits a signal. | |
153 * | |
154 * @param instance The instance emitting the signal. | |
155 * @param signal The signal being emitted. | |
156 * | |
157 * @see gaim_signal_connect() | |
158 * @see gaim_signal_disconnect() | |
159 */ | |
160 void gaim_signal_emit(void *instance, const char *signal, ...); | |
161 | |
162 /** | |
163 * Emits a signal, using a va_list of arguments. | |
164 * | |
165 * @param instance The instance emitting the signal. | |
166 * @param signal The signal being emitted. | |
167 * @param args The arguments list. | |
168 * | |
169 * @see gaim_signal_connect() | |
170 * @see gaim_signal_disconnect() | |
171 */ | |
172 void gaim_signal_emit_vargs(void *instance, const char *signal, va_list args); | |
173 | |
174 /** | |
175 * Emits a signal and returns the return value from the last handler. | |
176 * | |
177 * @param instance The instance emitting the signal. | |
178 * @param signal The signal being emitted. | |
179 * | |
180 * @return The return value from the last handler. | |
181 */ | |
182 void *gaim_signal_emit_return_1(void *instance, const char *signal, ...); | |
183 | |
184 /** | |
185 * Emits a signal and returns the return value from the last handler. | |
186 * | |
187 * @param instance The instance emitting the signal. | |
188 * @param signal The signal being emitted. | |
189 * @param args The arguments list. | |
190 * | |
191 * @return The return value from the last handler. | |
192 */ | |
193 void *gaim_signal_emit_vargs_return_1(void *instance, const char *signal, | |
194 va_list args); | |
195 | |
196 /** | |
197 * Initializes the signals subsystem. | |
198 */ | |
199 void gaim_signals_init(); | |
200 | |
201 /** | |
202 * Uninitializes the signals subsystem. | |
203 */ | |
204 void gaim_signals_uninit(); | |
205 | |
206 /*@}*/ | |
207 | |
208 /**************************************************************************/ | |
209 /** @name Marshal Functions */ | |
210 /**************************************************************************/ | |
211 /*@{*/ | |
212 | |
213 void gaim_marshal_VOID( | |
214 GaimCallback cb, va_list args, void *data, void **return_val); | |
215 void gaim_marshal_VOID__POINTER( | |
216 GaimCallback cb, va_list args, void *data, void **return_val); | |
217 void gaim_marshal_VOID__POINTER_POINTER( | |
218 GaimCallback cb, va_list args, void *data, void **return_val); | |
219 void gaim_marshal_VOID__POINTER_POINTER_UINT( | |
220 GaimCallback cb, va_list args, void *data, void **return_val); | |
221 void gaim_marshal_VOID__POINTER_POINTER_POINTER( | |
222 GaimCallback cb, va_list args, void *data, void **return_val); | |
223 void gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER( | |
224 GaimCallback cb, va_list args, void *data, void **return_val); | |
6509 | 225 void gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT( |
226 GaimCallback cb, va_list args, void *data, void **return_val); | |
6485 | 227 void gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT( |
228 GaimCallback cb, va_list args, void *data, void **return_val); | |
229 | |
230 void gaim_marshal_BOOLEAN__POINTER( | |
231 GaimCallback cb, va_list args, void *data, void **return_val); | |
232 void gaim_marshal_BOOLEAN__POINTER_POINTER( | |
233 GaimCallback cb, va_list args, void *data, void **return_val); | |
6509 | 234 void gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER( |
235 GaimCallback cb, va_list args, void *data, void **return_val); | |
236 void gaim_marshal_BOOLEAN__POINTER_POINTER_UINT( | |
237 GaimCallback cb, va_list args, void *data, void **return_val); | |
6485 | 238 void gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT( |
239 GaimCallback cb, va_list args, void *data, void **return_val); | |
240 void gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER( | |
241 GaimCallback cb, va_list args, void *data, void **return_val); | |
242 void gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER( | |
243 GaimCallback cb, va_list args, void *data, void **return_val); | |
244 | |
245 /*@}*/ | |
246 | |
247 #ifdef __cplusplus | |
248 } | |
249 #endif | |
250 | |
251 #endif /* _GAIM_SIGNAL_H_ */ |