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