Mercurial > pidgin.yaz
annotate src/signals.c @ 9454:b6feee45f33d
[gaim-migrate @ 10278]
This should fix a harmless failed g_return_if_fail type debug warning
type thing on opening a switchboard connection to someone.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Mon, 05 Jul 2004 19:33:48 +0000 |
parents | f4d981c9c4ab |
children | 1fac0336890c |
rev | line source |
---|---|
6485 | 1 /** |
6488
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2 * @file signals.c Signal API |
6485 | 3 * @ingroup core |
4 * | |
5 * gaim | |
6 * | |
8046 | 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. | |
6485 | 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 #include "internal.h" | |
26 | |
27 #include "debug.h" | |
28 #include "signals.h" | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
29 #include "value.h" |
6485 | 30 |
9127 | 31 /* must include this to use G_VA_COPY */ |
32 #include <string.h> | |
33 | |
6485 | 34 typedef struct |
35 { | |
36 void *instance; | |
37 | |
38 GHashTable *signals; | |
39 size_t signal_count; | |
40 | |
41 gulong next_signal_id; | |
42 | |
43 } GaimInstanceData; | |
44 | |
45 typedef struct | |
46 { | |
47 gulong id; | |
48 | |
49 GaimSignalMarshalFunc marshal; | |
50 | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
51 int num_values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
52 GaimValue **values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
53 GaimValue *ret_value; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
54 |
6485 | 55 GList *handlers; |
56 size_t handler_count; | |
57 | |
58 gulong next_handler_id; | |
59 | |
60 } GaimSignalData; | |
61 | |
62 typedef struct | |
63 { | |
64 gulong id; | |
65 GaimCallback cb; | |
66 void *handle; | |
67 void *data; | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
68 gboolean use_vargs; |
6485 | 69 |
70 } GaimSignalHandlerData; | |
71 | |
72 static GHashTable *instance_table = NULL; | |
73 | |
74 static void | |
75 destroy_instance_data(GaimInstanceData *instance_data) | |
76 { | |
77 g_hash_table_destroy(instance_data->signals); | |
78 | |
79 g_free(instance_data); | |
80 } | |
81 | |
82 static void | |
83 destroy_signal_data(GaimSignalData *signal_data) | |
84 { | |
85 GaimSignalHandlerData *handler_data; | |
86 GList *l; | |
87 | |
88 for (l = signal_data->handlers; l != NULL; l = l->next) | |
89 { | |
90 handler_data = (GaimSignalHandlerData *)l->data; | |
91 | |
92 g_free(l->data); | |
93 } | |
94 | |
95 g_list_free(signal_data->handlers); | |
96 | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
97 if (signal_data->values != NULL) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
98 { |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
99 int i; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
100 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
101 for (i = 0; i < signal_data->num_values; i++) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
102 gaim_value_destroy((GaimValue *)signal_data->values[i]); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
103 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
104 g_free(signal_data->values); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
105 } |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
106 |
6485 | 107 g_free(signal_data); |
108 } | |
109 | |
110 gulong | |
111 gaim_signal_register(void *instance, const char *signal, | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
112 GaimSignalMarshalFunc marshal, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
113 GaimValue *ret_value, int num_values, ...) |
6485 | 114 { |
115 GaimInstanceData *instance_data; | |
116 GaimSignalData *signal_data; | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
117 va_list args; |
6485 | 118 |
119 g_return_val_if_fail(instance != NULL, 0); | |
120 g_return_val_if_fail(signal != NULL, 0); | |
121 g_return_val_if_fail(marshal != NULL, 0); | |
122 | |
123 instance_data = | |
124 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
125 | |
126 if (instance_data == NULL) | |
127 { | |
128 instance_data = g_new0(GaimInstanceData, 1); | |
129 | |
130 instance_data->instance = instance; | |
131 instance_data->next_signal_id = 1; | |
132 | |
133 instance_data->signals = | |
134 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, | |
135 (GDestroyNotify)destroy_signal_data); | |
136 | |
137 g_hash_table_insert(instance_table, instance, instance_data); | |
138 } | |
139 | |
140 signal_data = g_new0(GaimSignalData, 1); | |
141 signal_data->id = instance_data->next_signal_id; | |
142 signal_data->marshal = marshal; | |
143 signal_data->next_handler_id = 1; | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
144 signal_data->ret_value = ret_value; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
145 signal_data->num_values = num_values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
146 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
147 if (num_values > 0) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
148 { |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
149 int i; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
150 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
151 signal_data->values = g_new0(GaimValue *, num_values); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
152 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
153 va_start(args, num_values); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
154 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
155 for (i = 0; i < num_values; i++) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
156 signal_data->values[i] = va_arg(args, GaimValue *); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
157 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
158 va_end(args); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
159 } |
6485 | 160 |
161 g_hash_table_insert(instance_data->signals, | |
162 g_strdup(signal), signal_data); | |
163 | |
164 instance_data->next_signal_id++; | |
165 instance_data->signal_count++; | |
166 | |
167 return signal_data->id; | |
168 } | |
169 | |
170 void | |
171 gaim_signal_unregister(void *instance, const char *signal) | |
172 { | |
173 GaimInstanceData *instance_data; | |
174 | |
175 g_return_if_fail(instance != NULL); | |
176 g_return_if_fail(signal != NULL); | |
177 | |
178 instance_data = | |
179 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
180 | |
181 g_return_if_fail(instance_data != NULL); | |
182 | |
183 g_hash_table_remove(instance_data->signals, signal); | |
184 | |
185 instance_data->signal_count--; | |
186 | |
187 if (instance_data->signal_count == 0) | |
188 { | |
189 /* Unregister the instance. */ | |
190 g_hash_table_remove(instance_table, instance); | |
191 } | |
192 } | |
193 | |
194 void | |
195 gaim_signals_unregister_by_instance(void *instance) | |
196 { | |
197 gboolean found; | |
198 | |
199 g_return_if_fail(instance != NULL); | |
200 | |
201 found = g_hash_table_remove(instance_table, instance); | |
202 | |
203 /* | |
204 * Makes things easier (more annoying?) for developers who don't have | |
205 * things registering and unregistering in the right order :) | |
206 */ | |
207 g_return_if_fail(found); | |
208 } | |
209 | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
210 void |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
211 gaim_signal_get_values(void *instance, const char *signal, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
212 GaimValue **ret_value, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
213 int *num_values, GaimValue ***values) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
214 { |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
215 GaimInstanceData *instance_data; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
216 GaimSignalData *signal_data; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
217 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
218 g_return_if_fail(instance != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
219 g_return_if_fail(signal != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
220 g_return_if_fail(num_values != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
221 g_return_if_fail(values != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
222 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
223 /* Get the instance data */ |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
224 instance_data = |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
225 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
226 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
227 g_return_if_fail(instance_data != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
228 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
229 /* Get the signal data */ |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
230 signal_data = |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
231 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
232 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
233 g_return_if_fail(signal_data != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
234 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
235 *num_values = signal_data->num_values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
236 *values = signal_data->values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
237 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
238 if (ret_value != NULL) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
239 *ret_value = signal_data->ret_value; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
240 } |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
241 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
242 static gulong |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
243 signal_connect_common(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
244 GaimCallback func, void *data, gboolean use_vargs) |
6485 | 245 { |
246 GaimInstanceData *instance_data; | |
247 GaimSignalData *signal_data; | |
248 GaimSignalHandlerData *handler_data; | |
249 | |
250 g_return_val_if_fail(instance != NULL, 0); | |
251 g_return_val_if_fail(signal != NULL, 0); | |
252 g_return_val_if_fail(handle != NULL, 0); | |
253 g_return_val_if_fail(func != NULL, 0); | |
254 | |
255 /* Get the instance data */ | |
256 instance_data = | |
257 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
258 | |
259 g_return_val_if_fail(instance_data != NULL, 0); | |
260 | |
261 /* Get the signal data */ | |
262 signal_data = | |
263 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
264 | |
265 if (signal_data == NULL) | |
266 { | |
267 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
268 "Signal data for %s not found!\n", signal); | |
269 return 0; | |
270 } | |
271 | |
272 /* Create the signal handler data */ | |
273 handler_data = g_new0(GaimSignalHandlerData, 1); | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
274 handler_data->id = signal_data->next_handler_id; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
275 handler_data->cb = func; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
276 handler_data->handle = handle; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
277 handler_data->data = data; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
278 handler_data->use_vargs = use_vargs; |
6485 | 279 |
280 signal_data->handlers = g_list_append(signal_data->handlers, handler_data); | |
281 signal_data->handler_count++; | |
282 signal_data->next_handler_id++; | |
283 | |
284 return handler_data->id; | |
285 } | |
6553
9e4fa4853cfe
[gaim-migrate @ 7075]
Christian Hammond <chipx86@chipx86.com>
parents:
6547
diff
changeset
|
286 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
287 gulong |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
288 gaim_signal_connect(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
289 GaimCallback func, void *data) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
290 { |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
291 return signal_connect_common(instance, signal, handle, func, data, FALSE); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
292 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
293 |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
294 gulong |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
295 gaim_signal_connect_vargs(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
296 GaimCallback func, void *data) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
297 { |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
298 return signal_connect_common(instance, signal, handle, func, data, TRUE); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
299 } |
6485 | 300 |
301 void | |
302 gaim_signal_disconnect(void *instance, const char *signal, | |
303 void *handle, GaimCallback func) | |
304 { | |
305 GaimInstanceData *instance_data; | |
306 GaimSignalData *signal_data; | |
307 GaimSignalHandlerData *handler_data; | |
308 GList *l; | |
309 gboolean found = FALSE; | |
310 | |
311 g_return_if_fail(instance != NULL); | |
312 g_return_if_fail(signal != NULL); | |
313 g_return_if_fail(handle != NULL); | |
314 g_return_if_fail(func != NULL); | |
315 | |
316 /* Get the instance data */ | |
317 instance_data = | |
318 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
319 | |
320 g_return_if_fail(instance_data != NULL); | |
321 | |
322 /* Get the signal data */ | |
323 signal_data = | |
324 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
325 | |
326 if (signal_data == NULL) | |
327 { | |
328 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
329 "Signal data for %s not found!\n", signal); | |
330 return; | |
331 } | |
332 | |
333 /* Find the handler data. */ | |
334 for (l = signal_data->handlers; l != NULL; l = l->next) | |
335 { | |
336 handler_data = (GaimSignalHandlerData *)l->data; | |
337 | |
338 if (handler_data->handle == handle && handler_data->cb == func) | |
339 { | |
340 g_free(handler_data); | |
341 | |
342 signal_data->handlers = g_list_remove(signal_data->handlers, | |
343 handler_data); | |
344 signal_data->handler_count--; | |
345 | |
346 found = TRUE; | |
347 | |
348 break; | |
349 } | |
350 } | |
351 | |
352 /* See note somewhere about this actually helping developers.. */ | |
353 g_return_if_fail(found); | |
354 } | |
355 | |
356 /* | |
357 * TODO: Make this all more efficient by storing a list of handlers, keyed | |
358 * to a handle. | |
359 */ | |
360 static void | |
361 disconnect_handle_from_signals(const char *signal, | |
362 GaimSignalData *signal_data, void *handle) | |
363 { | |
364 GList *l, *l_next; | |
365 GaimSignalHandlerData *handler_data; | |
366 | |
367 for (l = signal_data->handlers; l != NULL; l = l_next) | |
368 { | |
369 handler_data = (GaimSignalHandlerData *)l->data; | |
370 l_next = l->next; | |
371 | |
372 if (handler_data->handle == handle) | |
373 { | |
374 g_free(handler_data); | |
375 | |
376 signal_data->handler_count--; | |
377 signal_data->handlers = g_list_remove(signal_data->handlers, | |
378 handler_data); | |
379 } | |
380 } | |
381 } | |
382 | |
383 static void | |
384 disconnect_handle_from_instance(void *instance, | |
385 GaimInstanceData *instance_data, | |
386 void *handle) | |
387 { | |
388 g_hash_table_foreach(instance_data->signals, | |
389 (GHFunc)disconnect_handle_from_signals, handle); | |
390 } | |
391 | |
392 void | |
393 gaim_signals_disconnect_by_handle(void *handle) | |
394 { | |
395 g_return_if_fail(handle != NULL); | |
396 | |
397 g_hash_table_foreach(instance_table, | |
398 (GHFunc)disconnect_handle_from_instance, handle); | |
399 } | |
400 | |
401 void | |
402 gaim_signal_emit(void *instance, const char *signal, ...) | |
403 { | |
404 va_list args; | |
405 | |
7584
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
406 g_return_if_fail(instance != NULL); |
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
407 g_return_if_fail(signal != NULL); |
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
408 |
6485 | 409 va_start(args, signal); |
410 gaim_signal_emit_vargs(instance, signal, args); | |
411 va_end(args); | |
412 } | |
413 | |
414 void | |
415 gaim_signal_emit_vargs(void *instance, const char *signal, va_list args) | |
416 { | |
417 GaimInstanceData *instance_data; | |
418 GaimSignalData *signal_data; | |
419 GaimSignalHandlerData *handler_data; | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
420 GList *l, *l_next; |
8090 | 421 va_list tmp; |
6485 | 422 |
423 g_return_if_fail(instance != NULL); | |
424 g_return_if_fail(signal != NULL); | |
425 | |
426 instance_data = | |
427 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
428 | |
429 g_return_if_fail(instance_data != NULL); | |
430 | |
431 signal_data = | |
432 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
433 | |
434 if (signal_data == NULL) | |
435 { | |
436 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
437 "Signal data for %s not found!\n", signal); | |
438 return; | |
439 } | |
440 | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
441 for (l = signal_data->handlers; l != NULL; l = l_next) |
6485 | 442 { |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
443 l_next = l->next; |
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
444 |
6485 | 445 handler_data = (GaimSignalHandlerData *)l->data; |
446 | |
8090 | 447 /* This is necessary because a va_list may only be |
448 * evaluated once */ | |
8142 | 449 G_VA_COPY(tmp, args); |
8090 | 450 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
451 if (handler_data->use_vargs) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
452 { |
8090 | 453 ((void (*)(va_list, void *))handler_data->cb)(tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
454 handler_data->data); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
455 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
456 else |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
457 { |
8090 | 458 signal_data->marshal(handler_data->cb, tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
459 handler_data->data, NULL); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
460 } |
8090 | 461 |
462 va_end(tmp); | |
6485 | 463 } |
464 } | |
465 | |
466 void * | |
467 gaim_signal_emit_return_1(void *instance, const char *signal, ...) | |
468 { | |
469 void *ret_val; | |
470 va_list args; | |
471 | |
7597
191e5b9a249b
[gaim-migrate @ 8218]
Christian Hammond <chipx86@chipx86.com>
parents:
7585
diff
changeset
|
472 g_return_val_if_fail(instance != NULL, NULL); |
191e5b9a249b
[gaim-migrate @ 8218]
Christian Hammond <chipx86@chipx86.com>
parents:
7585
diff
changeset
|
473 g_return_val_if_fail(signal != NULL, NULL); |
7585
404f4a4b81da
[gaim-migrate @ 8203]
Christian Hammond <chipx86@chipx86.com>
parents:
7584
diff
changeset
|
474 |
6485 | 475 va_start(args, signal); |
476 ret_val = gaim_signal_emit_vargs_return_1(instance, signal, args); | |
477 va_end(args); | |
478 | |
479 return ret_val; | |
480 } | |
481 | |
482 void * | |
483 gaim_signal_emit_vargs_return_1(void *instance, const char *signal, | |
484 va_list args) | |
485 { | |
486 GaimInstanceData *instance_data; | |
487 GaimSignalData *signal_data; | |
488 GaimSignalHandlerData *handler_data; | |
489 void *ret_val = NULL; | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
490 GList *l, *l_next; |
8140 | 491 va_list tmp; |
6485 | 492 |
493 g_return_val_if_fail(instance != NULL, NULL); | |
494 g_return_val_if_fail(signal != NULL, NULL); | |
495 | |
496 instance_data = | |
497 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
498 | |
499 g_return_val_if_fail(instance_data != NULL, NULL); | |
500 | |
501 signal_data = | |
502 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
503 | |
504 if (signal_data == NULL) | |
505 { | |
506 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
507 "Signal data for %s not found!\n", signal); | |
508 return 0; | |
509 } | |
510 | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
511 for (l = signal_data->handlers; l != NULL; l = l_next) |
6485 | 512 { |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
513 l_next = l->next; |
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
514 |
6485 | 515 handler_data = (GaimSignalHandlerData *)l->data; |
516 | |
8142 | 517 G_VA_COPY(tmp, args); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
518 if (handler_data->use_vargs) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
519 { |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
520 ret_val = ((void *(*)(va_list, void *))handler_data->cb)( |
8140 | 521 tmp, handler_data->data); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
522 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
523 else |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
524 { |
8140 | 525 signal_data->marshal(handler_data->cb, tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
526 handler_data->data, &ret_val); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
527 } |
8140 | 528 va_end(tmp); |
6485 | 529 } |
530 | |
531 return ret_val; | |
532 } | |
533 | |
534 void | |
535 gaim_signals_init() | |
536 { | |
537 g_return_if_fail(instance_table == NULL); | |
538 | |
539 instance_table = | |
540 g_hash_table_new_full(g_direct_hash, g_direct_equal, | |
541 NULL, (GDestroyNotify)destroy_instance_data); | |
542 } | |
543 | |
544 void | |
545 gaim_signals_uninit() | |
546 { | |
547 g_return_if_fail(instance_table != NULL); | |
548 | |
549 g_hash_table_destroy(instance_table); | |
550 instance_table = NULL; | |
551 } | |
552 | |
553 /************************************************************************** | |
554 * Marshallers | |
555 **************************************************************************/ | |
556 void | |
557 gaim_marshal_VOID(GaimCallback cb, va_list args, void *data, | |
558 void **return_val) | |
559 { | |
560 ((void (*)(void *))cb)(data); | |
561 } | |
562 | |
563 void | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
564 gaim_marshal_VOID__INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
565 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
566 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
567 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
568 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
569 ((void (*)(gint, void *))cb)(arg1, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
570 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
571 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
572 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
573 gaim_marshal_VOID__INT_INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
574 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
575 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
576 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
577 gint arg2 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
578 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
579 ((void (*)(gint, gint, void *))cb)(arg1, arg2, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
580 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
581 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
582 void |
6485 | 583 gaim_marshal_VOID__POINTER(GaimCallback cb, va_list args, void *data, |
584 void **return_val) | |
585 { | |
6505 | 586 void *arg1 = va_arg(args, void *); |
587 | |
588 ((void (*)(void *, void *))cb)(arg1, data); | |
6485 | 589 } |
590 | |
591 void | |
592 gaim_marshal_VOID__POINTER_POINTER(GaimCallback cb, va_list args, | |
593 void *data, void **return_val) | |
594 { | |
6505 | 595 void *arg1 = va_arg(args, void *); |
596 void *arg2 = va_arg(args, void *); | |
597 | |
598 ((void (*)(void *, void *, void *))cb)(arg1, arg2, data); | |
6485 | 599 } |
600 | |
601 void | |
602 gaim_marshal_VOID__POINTER_POINTER_UINT(GaimCallback cb, va_list args, | |
603 void *data, void **return_val) | |
604 { | |
6505 | 605 void *arg1 = va_arg(args, void *); |
606 void *arg2 = va_arg(args, void *); | |
607 guint arg3 = va_arg(args, guint); | |
608 | |
609 ((void (*)(void *, void *, guint, void *))cb)(arg1, arg2, arg3, data); | |
6485 | 610 } |
611 | |
612 void | |
613 gaim_marshal_VOID__POINTER_POINTER_POINTER(GaimCallback cb, va_list args, | |
614 void *data, void **return_val) | |
615 { | |
6505 | 616 void *arg1 = va_arg(args, void *); |
617 void *arg2 = va_arg(args, void *); | |
618 void *arg3 = va_arg(args, void *); | |
619 | |
620 ((void (*)(void *, void *, void *, void *))cb)(arg1, arg2, arg3, data); | |
6485 | 621 } |
622 | |
623 void | |
624 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER(GaimCallback cb, | |
625 va_list args, | |
626 void *data, | |
627 void **return_val) | |
628 { | |
6505 | 629 void *arg1 = va_arg(args, void *); |
630 void *arg2 = va_arg(args, void *); | |
631 void *arg3 = va_arg(args, void *); | |
632 void *arg4 = va_arg(args, void *); | |
633 | |
634 ((void (*)(void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, data); | |
6485 | 635 } |
6509 | 636 |
637 void | |
638 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT(GaimCallback cb, | |
639 va_list args, | |
640 void *data, | |
641 void **return_val) | |
642 { | |
643 void *arg1 = va_arg(args, void *); | |
644 void *arg2 = va_arg(args, void *); | |
645 void *arg3 = va_arg(args, void *); | |
646 guint arg4 = va_arg(args, guint); | |
647 | |
648 ((void (*)(void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, data); | |
649 } | |
650 | |
6485 | 651 void |
652 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT(GaimCallback cb, | |
653 va_list args, | |
654 void *data, | |
655 void **return_val) | |
656 { | |
6505 | 657 void *arg1 = va_arg(args, void *); |
658 void *arg2 = va_arg(args, void *); | |
659 void *arg3 = va_arg(args, void *); | |
660 guint arg4 = va_arg(args, guint); | |
661 guint arg5 = va_arg(args, guint); | |
662 | |
6485 | 663 ((void (*)(void *, void *, void *, guint, guint, void *))cb)( |
6505 | 664 arg1, arg2, arg3, arg4, arg5, data); |
6485 | 665 } |
666 | |
667 void | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
668 gaim_marshal_INT__INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
669 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
670 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
671 gint ret_val; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
672 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
673 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
674 ret_val = ((gint (*)(gint, void *))cb)(arg1, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
675 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
676 if (return_val != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
677 *return_val = GINT_TO_POINTER(ret_val); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
678 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
679 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
680 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
681 gaim_marshal_INT__INT_INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
682 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
683 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
684 gint ret_val; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
685 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
686 gint arg2 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
687 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
688 ret_val = ((gint (*)(gint, gint, void *))cb)(arg1, arg2, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
689 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
690 if (return_val != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
691 *return_val = GINT_TO_POINTER(ret_val); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
692 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
693 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
694 void |
6485 | 695 gaim_marshal_BOOLEAN__POINTER(GaimCallback cb, va_list args, void *data, |
696 void **return_val) | |
697 { | |
698 gboolean ret_val; | |
6505 | 699 void *arg1 = va_arg(args, void *); |
6485 | 700 |
6505 | 701 ret_val = ((gboolean (*)(void *, void *))cb)(arg1, data); |
6485 | 702 |
703 if (return_val != NULL) | |
704 *return_val = GINT_TO_POINTER(ret_val); | |
705 } | |
706 | |
707 void | |
708 gaim_marshal_BOOLEAN__POINTER_POINTER(GaimCallback cb, va_list args, | |
709 void *data, void **return_val) | |
710 { | |
711 gboolean ret_val; | |
6505 | 712 void *arg1 = va_arg(args, void *); |
713 void *arg2 = va_arg(args, void *); | |
6485 | 714 |
6505 | 715 ret_val = ((gboolean (*)(void *, void *, void *))cb)(arg1, arg2, data); |
6485 | 716 |
717 if (return_val != NULL) | |
718 *return_val = GINT_TO_POINTER(ret_val); | |
719 } | |
720 | |
721 void | |
6509 | 722 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER(GaimCallback cb, va_list args, |
723 void *data, void **return_val) | |
724 { | |
725 gboolean ret_val; | |
726 void *arg1 = va_arg(args, void *); | |
727 void *arg2 = va_arg(args, void *); | |
728 void *arg3 = va_arg(args, void *); | |
729 | |
730 ret_val = ((gboolean (*)(void *, void *, void *, void *))cb)(arg1, arg2, | |
731 arg3, data); | |
732 | |
733 if (return_val != NULL) | |
734 *return_val = GINT_TO_POINTER(ret_val); | |
735 } | |
736 | |
737 void | |
738 gaim_marshal_BOOLEAN__POINTER_POINTER_UINT(GaimCallback cb, | |
739 va_list args, | |
740 void *data, | |
741 void **return_val) | |
742 { | |
743 gboolean ret_val; | |
744 void *arg1 = va_arg(args, void *); | |
745 void *arg2 = va_arg(args, void *); | |
746 guint arg3 = va_arg(args, guint); | |
747 | |
748 ret_val = ((gboolean (*)(void *, void *, guint, void *))cb)( | |
749 arg1, arg2, arg3, data); | |
750 | |
751 if (return_val != NULL) | |
752 *return_val = GINT_TO_POINTER(ret_val); | |
753 } | |
754 | |
755 void | |
6485 | 756 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
757 va_list args, | |
758 void *data, | |
759 void **return_val) | |
760 { | |
761 gboolean ret_val; | |
6505 | 762 void *arg1 = va_arg(args, void *); |
763 void *arg2 = va_arg(args, void *); | |
764 void *arg3 = va_arg(args, void *); | |
765 guint arg4 = va_arg(args, guint); | |
6485 | 766 |
767 ret_val = ((gboolean (*)(void *, void *, void *, guint, void *))cb)( | |
6505 | 768 arg1, arg2, arg3, arg4, data); |
6485 | 769 |
770 if (return_val != NULL) | |
771 *return_val = GINT_TO_POINTER(ret_val); | |
772 } | |
773 | |
774 void | |
775 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER(GaimCallback cb, | |
776 va_list args, | |
777 void *data, | |
778 void **return_val) | |
779 { | |
780 gboolean ret_val; | |
6505 | 781 void *arg1 = va_arg(args, void *); |
782 void *arg2 = va_arg(args, void *); | |
783 void *arg3 = va_arg(args, void *); | |
784 void *arg4 = va_arg(args, void *); | |
6485 | 785 |
786 ret_val = ((gboolean (*)(void *, void *, void *, void *, void *))cb)( | |
6505 | 787 arg1, arg2, arg3, arg4, data); |
6485 | 788 |
789 if (return_val != NULL) | |
790 *return_val = GINT_TO_POINTER(ret_val); | |
791 } | |
792 | |
793 void | |
794 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER( | |
795 GaimCallback cb, va_list args, void *data, void **return_val) | |
796 { | |
797 gboolean ret_val; | |
6505 | 798 void *arg1 = va_arg(args, void *); |
799 void *arg2 = va_arg(args, void *); | |
800 void *arg3 = va_arg(args, void *); | |
801 void *arg4 = va_arg(args, void *); | |
802 void *arg5 = va_arg(args, void *); | |
6485 | 803 |
804 ret_val = | |
805 ((gboolean (*)(void *, void *, void *, void *, void *, void *))cb)( | |
6505 | 806 arg1, arg2, arg3, arg4, arg5, data); |
6485 | 807 |
808 if (return_val != NULL) | |
809 *return_val = GINT_TO_POINTER(ret_val); | |
810 } |