Mercurial > pidgin.yaz
annotate src/signals.c @ 10606:1a65fc2d7978
[gaim-migrate @ 12039]
So I'd intended to take care of the stuff in the comments at the top before committing this, but the window raising stuff came up again so I'll just commit and deal with the rest later.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Wed, 16 Feb 2005 22:14:51 +0000 |
parents | def1c69ae8af |
children | 9b223bf37ca0 |
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 |
10542 | 107 if (signal_data->ret_value != NULL) |
108 gaim_value_destroy(signal_data->ret_value); | |
6485 | 109 g_free(signal_data); |
110 } | |
111 | |
112 gulong | |
113 gaim_signal_register(void *instance, const char *signal, | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
114 GaimSignalMarshalFunc marshal, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
115 GaimValue *ret_value, int num_values, ...) |
6485 | 116 { |
117 GaimInstanceData *instance_data; | |
118 GaimSignalData *signal_data; | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
119 va_list args; |
6485 | 120 |
121 g_return_val_if_fail(instance != NULL, 0); | |
122 g_return_val_if_fail(signal != NULL, 0); | |
123 g_return_val_if_fail(marshal != NULL, 0); | |
124 | |
125 instance_data = | |
126 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
127 | |
128 if (instance_data == NULL) | |
129 { | |
130 instance_data = g_new0(GaimInstanceData, 1); | |
131 | |
132 instance_data->instance = instance; | |
133 instance_data->next_signal_id = 1; | |
134 | |
135 instance_data->signals = | |
136 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, | |
137 (GDestroyNotify)destroy_signal_data); | |
138 | |
139 g_hash_table_insert(instance_table, instance, instance_data); | |
140 } | |
141 | |
142 signal_data = g_new0(GaimSignalData, 1); | |
143 signal_data->id = instance_data->next_signal_id; | |
144 signal_data->marshal = marshal; | |
145 signal_data->next_handler_id = 1; | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
146 signal_data->ret_value = ret_value; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
147 signal_data->num_values = num_values; |
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 if (num_values > 0) |
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 int i; |
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 signal_data->values = g_new0(GaimValue *, 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 va_start(args, num_values); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
156 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
157 for (i = 0; i < num_values; i++) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
158 signal_data->values[i] = va_arg(args, GaimValue *); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
159 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
160 va_end(args); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
161 } |
6485 | 162 |
163 g_hash_table_insert(instance_data->signals, | |
164 g_strdup(signal), signal_data); | |
165 | |
166 instance_data->next_signal_id++; | |
167 instance_data->signal_count++; | |
168 | |
169 return signal_data->id; | |
170 } | |
171 | |
172 void | |
173 gaim_signal_unregister(void *instance, const char *signal) | |
174 { | |
175 GaimInstanceData *instance_data; | |
176 | |
177 g_return_if_fail(instance != NULL); | |
178 g_return_if_fail(signal != NULL); | |
179 | |
180 instance_data = | |
181 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
182 | |
183 g_return_if_fail(instance_data != NULL); | |
184 | |
185 g_hash_table_remove(instance_data->signals, signal); | |
186 | |
187 instance_data->signal_count--; | |
188 | |
189 if (instance_data->signal_count == 0) | |
190 { | |
191 /* Unregister the instance. */ | |
192 g_hash_table_remove(instance_table, instance); | |
193 } | |
194 } | |
195 | |
196 void | |
197 gaim_signals_unregister_by_instance(void *instance) | |
198 { | |
199 gboolean found; | |
200 | |
201 g_return_if_fail(instance != NULL); | |
202 | |
203 found = g_hash_table_remove(instance_table, instance); | |
204 | |
205 /* | |
206 * Makes things easier (more annoying?) for developers who don't have | |
207 * things registering and unregistering in the right order :) | |
208 */ | |
209 g_return_if_fail(found); | |
210 } | |
211 | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
212 void |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
213 gaim_signal_get_values(void *instance, const char *signal, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
214 GaimValue **ret_value, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
215 int *num_values, GaimValue ***values) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
216 { |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
217 GaimInstanceData *instance_data; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
218 GaimSignalData *signal_data; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
219 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
220 g_return_if_fail(instance != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
221 g_return_if_fail(signal != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
222 g_return_if_fail(num_values != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
223 g_return_if_fail(values != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
224 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
225 /* Get the instance data */ |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
226 instance_data = |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
227 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); |
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 g_return_if_fail(instance_data != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
230 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
231 /* Get the signal data */ |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
232 signal_data = |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
233 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); |
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 g_return_if_fail(signal_data != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
236 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
237 *num_values = signal_data->num_values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
238 *values = signal_data->values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
239 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
240 if (ret_value != NULL) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
241 *ret_value = signal_data->ret_value; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
242 } |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
243 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
244 static gulong |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
245 signal_connect_common(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
246 GaimCallback func, void *data, gboolean use_vargs) |
6485 | 247 { |
248 GaimInstanceData *instance_data; | |
249 GaimSignalData *signal_data; | |
250 GaimSignalHandlerData *handler_data; | |
251 | |
252 g_return_val_if_fail(instance != NULL, 0); | |
253 g_return_val_if_fail(signal != NULL, 0); | |
254 g_return_val_if_fail(handle != NULL, 0); | |
255 g_return_val_if_fail(func != NULL, 0); | |
256 | |
257 /* Get the instance data */ | |
258 instance_data = | |
259 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
260 | |
261 g_return_val_if_fail(instance_data != NULL, 0); | |
262 | |
263 /* Get the signal data */ | |
264 signal_data = | |
265 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
266 | |
267 if (signal_data == NULL) | |
268 { | |
269 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
270 "Signal data for %s not found!\n", signal); | |
271 return 0; | |
272 } | |
273 | |
274 /* Create the signal handler data */ | |
275 handler_data = g_new0(GaimSignalHandlerData, 1); | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
276 handler_data->id = signal_data->next_handler_id; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
277 handler_data->cb = func; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
278 handler_data->handle = handle; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
279 handler_data->data = data; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
280 handler_data->use_vargs = use_vargs; |
6485 | 281 |
282 signal_data->handlers = g_list_append(signal_data->handlers, handler_data); | |
283 signal_data->handler_count++; | |
284 signal_data->next_handler_id++; | |
285 | |
286 return handler_data->id; | |
287 } | |
6553
9e4fa4853cfe
[gaim-migrate @ 7075]
Christian Hammond <chipx86@chipx86.com>
parents:
6547
diff
changeset
|
288 |
6547
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(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, FALSE); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
294 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
295 |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
296 gulong |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
297 gaim_signal_connect_vargs(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
298 GaimCallback func, void *data) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
299 { |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
300 return signal_connect_common(instance, signal, handle, func, data, TRUE); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
301 } |
6485 | 302 |
303 void | |
304 gaim_signal_disconnect(void *instance, const char *signal, | |
305 void *handle, GaimCallback func) | |
306 { | |
307 GaimInstanceData *instance_data; | |
308 GaimSignalData *signal_data; | |
309 GaimSignalHandlerData *handler_data; | |
310 GList *l; | |
311 gboolean found = FALSE; | |
312 | |
313 g_return_if_fail(instance != NULL); | |
314 g_return_if_fail(signal != NULL); | |
315 g_return_if_fail(handle != NULL); | |
316 g_return_if_fail(func != NULL); | |
317 | |
318 /* Get the instance data */ | |
319 instance_data = | |
320 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
321 | |
322 g_return_if_fail(instance_data != NULL); | |
323 | |
324 /* Get the signal data */ | |
325 signal_data = | |
326 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
327 | |
328 if (signal_data == NULL) | |
329 { | |
330 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
331 "Signal data for %s not found!\n", signal); | |
332 return; | |
333 } | |
334 | |
335 /* Find the handler data. */ | |
336 for (l = signal_data->handlers; l != NULL; l = l->next) | |
337 { | |
338 handler_data = (GaimSignalHandlerData *)l->data; | |
339 | |
340 if (handler_data->handle == handle && handler_data->cb == func) | |
341 { | |
342 g_free(handler_data); | |
343 | |
344 signal_data->handlers = g_list_remove(signal_data->handlers, | |
345 handler_data); | |
346 signal_data->handler_count--; | |
347 | |
348 found = TRUE; | |
349 | |
350 break; | |
351 } | |
352 } | |
353 | |
354 /* See note somewhere about this actually helping developers.. */ | |
355 g_return_if_fail(found); | |
356 } | |
357 | |
358 /* | |
359 * TODO: Make this all more efficient by storing a list of handlers, keyed | |
360 * to a handle. | |
361 */ | |
362 static void | |
363 disconnect_handle_from_signals(const char *signal, | |
364 GaimSignalData *signal_data, void *handle) | |
365 { | |
366 GList *l, *l_next; | |
367 GaimSignalHandlerData *handler_data; | |
368 | |
369 for (l = signal_data->handlers; l != NULL; l = l_next) | |
370 { | |
371 handler_data = (GaimSignalHandlerData *)l->data; | |
372 l_next = l->next; | |
373 | |
374 if (handler_data->handle == handle) | |
375 { | |
376 g_free(handler_data); | |
377 | |
378 signal_data->handler_count--; | |
379 signal_data->handlers = g_list_remove(signal_data->handlers, | |
380 handler_data); | |
381 } | |
382 } | |
383 } | |
384 | |
385 static void | |
386 disconnect_handle_from_instance(void *instance, | |
387 GaimInstanceData *instance_data, | |
388 void *handle) | |
389 { | |
390 g_hash_table_foreach(instance_data->signals, | |
391 (GHFunc)disconnect_handle_from_signals, handle); | |
392 } | |
393 | |
394 void | |
395 gaim_signals_disconnect_by_handle(void *handle) | |
396 { | |
397 g_return_if_fail(handle != NULL); | |
398 | |
399 g_hash_table_foreach(instance_table, | |
400 (GHFunc)disconnect_handle_from_instance, handle); | |
401 } | |
402 | |
403 void | |
404 gaim_signal_emit(void *instance, const char *signal, ...) | |
405 { | |
406 va_list args; | |
407 | |
7584
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
408 g_return_if_fail(instance != NULL); |
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
409 g_return_if_fail(signal != NULL); |
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
410 |
6485 | 411 va_start(args, signal); |
412 gaim_signal_emit_vargs(instance, signal, args); | |
413 va_end(args); | |
414 } | |
415 | |
416 void | |
417 gaim_signal_emit_vargs(void *instance, const char *signal, va_list args) | |
418 { | |
419 GaimInstanceData *instance_data; | |
420 GaimSignalData *signal_data; | |
421 GaimSignalHandlerData *handler_data; | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
422 GList *l, *l_next; |
8090 | 423 va_list tmp; |
6485 | 424 |
425 g_return_if_fail(instance != NULL); | |
426 g_return_if_fail(signal != NULL); | |
427 | |
428 instance_data = | |
429 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
430 | |
431 g_return_if_fail(instance_data != NULL); | |
432 | |
433 signal_data = | |
434 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
435 | |
436 if (signal_data == NULL) | |
437 { | |
438 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
439 "Signal data for %s not found!\n", signal); | |
440 return; | |
441 } | |
442 | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
443 for (l = signal_data->handlers; l != NULL; l = l_next) |
6485 | 444 { |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
445 l_next = l->next; |
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
446 |
6485 | 447 handler_data = (GaimSignalHandlerData *)l->data; |
448 | |
8090 | 449 /* This is necessary because a va_list may only be |
450 * evaluated once */ | |
8142 | 451 G_VA_COPY(tmp, args); |
8090 | 452 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
453 if (handler_data->use_vargs) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
454 { |
8090 | 455 ((void (*)(va_list, void *))handler_data->cb)(tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
456 handler_data->data); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
457 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
458 else |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
459 { |
8090 | 460 signal_data->marshal(handler_data->cb, tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
461 handler_data->data, NULL); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
462 } |
8090 | 463 |
464 va_end(tmp); | |
6485 | 465 } |
466 } | |
467 | |
468 void * | |
469 gaim_signal_emit_return_1(void *instance, const char *signal, ...) | |
470 { | |
471 void *ret_val; | |
472 va_list args; | |
473 | |
7597
191e5b9a249b
[gaim-migrate @ 8218]
Christian Hammond <chipx86@chipx86.com>
parents:
7585
diff
changeset
|
474 g_return_val_if_fail(instance != NULL, NULL); |
191e5b9a249b
[gaim-migrate @ 8218]
Christian Hammond <chipx86@chipx86.com>
parents:
7585
diff
changeset
|
475 g_return_val_if_fail(signal != NULL, NULL); |
7585
404f4a4b81da
[gaim-migrate @ 8203]
Christian Hammond <chipx86@chipx86.com>
parents:
7584
diff
changeset
|
476 |
6485 | 477 va_start(args, signal); |
478 ret_val = gaim_signal_emit_vargs_return_1(instance, signal, args); | |
479 va_end(args); | |
480 | |
481 return ret_val; | |
482 } | |
483 | |
484 void * | |
485 gaim_signal_emit_vargs_return_1(void *instance, const char *signal, | |
486 va_list args) | |
487 { | |
488 GaimInstanceData *instance_data; | |
489 GaimSignalData *signal_data; | |
490 GaimSignalHandlerData *handler_data; | |
491 void *ret_val = NULL; | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
492 GList *l, *l_next; |
8140 | 493 va_list tmp; |
6485 | 494 |
495 g_return_val_if_fail(instance != NULL, NULL); | |
496 g_return_val_if_fail(signal != NULL, NULL); | |
497 | |
498 instance_data = | |
499 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
500 | |
501 g_return_val_if_fail(instance_data != NULL, NULL); | |
502 | |
503 signal_data = | |
504 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
505 | |
506 if (signal_data == NULL) | |
507 { | |
508 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
509 "Signal data for %s not found!\n", signal); | |
510 return 0; | |
511 } | |
512 | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
513 for (l = signal_data->handlers; l != NULL; l = l_next) |
6485 | 514 { |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
515 l_next = l->next; |
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
516 |
6485 | 517 handler_data = (GaimSignalHandlerData *)l->data; |
518 | |
8142 | 519 G_VA_COPY(tmp, args); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
520 if (handler_data->use_vargs) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
521 { |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
522 ret_val = ((void *(*)(va_list, void *))handler_data->cb)( |
8140 | 523 tmp, handler_data->data); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
524 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
525 else |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
526 { |
8140 | 527 signal_data->marshal(handler_data->cb, tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
528 handler_data->data, &ret_val); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
529 } |
8140 | 530 va_end(tmp); |
6485 | 531 } |
532 | |
533 return ret_val; | |
534 } | |
535 | |
536 void | |
537 gaim_signals_init() | |
538 { | |
539 g_return_if_fail(instance_table == NULL); | |
540 | |
541 instance_table = | |
542 g_hash_table_new_full(g_direct_hash, g_direct_equal, | |
543 NULL, (GDestroyNotify)destroy_instance_data); | |
544 } | |
545 | |
546 void | |
547 gaim_signals_uninit() | |
548 { | |
549 g_return_if_fail(instance_table != NULL); | |
550 | |
551 g_hash_table_destroy(instance_table); | |
552 instance_table = NULL; | |
553 } | |
554 | |
555 /************************************************************************** | |
556 * Marshallers | |
557 **************************************************************************/ | |
558 void | |
559 gaim_marshal_VOID(GaimCallback cb, va_list args, void *data, | |
560 void **return_val) | |
561 { | |
562 ((void (*)(void *))cb)(data); | |
563 } | |
564 | |
565 void | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
566 gaim_marshal_VOID__INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
567 void **return_val) |
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 gint arg1 = va_arg(args, gint); |
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 ((void (*)(gint, void *))cb)(arg1, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
572 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
573 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
574 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
575 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
|
576 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
577 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
578 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
579 gint arg2 = va_arg(args, gint); |
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 ((void (*)(gint, gint, void *))cb)(arg1, arg2, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
582 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
583 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
584 void |
6485 | 585 gaim_marshal_VOID__POINTER(GaimCallback cb, va_list args, void *data, |
586 void **return_val) | |
587 { | |
6505 | 588 void *arg1 = va_arg(args, void *); |
589 | |
590 ((void (*)(void *, void *))cb)(arg1, data); | |
6485 | 591 } |
592 | |
593 void | |
9734 | 594 gaim_marshal_VOID__POINTER_UINT(GaimCallback cb, va_list args, |
595 void *data, void **return_val) | |
596 { | |
597 void *arg1 = va_arg(args, void *); | |
598 guint arg2 = va_arg(args, guint); | |
599 | |
600 ((void (*)(void *, guint, void *))cb)(arg1, arg2, data); | |
601 } | |
602 | |
603 void | |
6485 | 604 gaim_marshal_VOID__POINTER_POINTER(GaimCallback cb, va_list args, |
605 void *data, void **return_val) | |
606 { | |
6505 | 607 void *arg1 = va_arg(args, void *); |
608 void *arg2 = va_arg(args, void *); | |
609 | |
610 ((void (*)(void *, void *, void *))cb)(arg1, arg2, data); | |
6485 | 611 } |
612 | |
613 void | |
614 gaim_marshal_VOID__POINTER_POINTER_UINT(GaimCallback cb, va_list args, | |
615 void *data, void **return_val) | |
616 { | |
6505 | 617 void *arg1 = va_arg(args, void *); |
618 void *arg2 = va_arg(args, void *); | |
619 guint arg3 = va_arg(args, guint); | |
620 | |
621 ((void (*)(void *, void *, guint, void *))cb)(arg1, arg2, arg3, data); | |
6485 | 622 } |
623 | |
624 void | |
9554 | 625 gaim_marshal_VOID__POINTER_POINTER_UINT_UINT(GaimCallback cb, va_list args, |
626 void *data, void **return_val) | |
627 { | |
628 void *arg1 = va_arg(args, void *); | |
629 void *arg2 = va_arg(args, void *); | |
630 guint arg3 = va_arg(args, guint); | |
631 guint arg4 = va_arg(args, guint); | |
632 | |
633 ((void (*)(void *, void *, guint, guint, void *))cb)(arg1, arg2, arg3, arg4, data); | |
634 } | |
635 | |
636 void | |
6485 | 637 gaim_marshal_VOID__POINTER_POINTER_POINTER(GaimCallback cb, va_list args, |
638 void *data, void **return_val) | |
639 { | |
6505 | 640 void *arg1 = va_arg(args, void *); |
641 void *arg2 = va_arg(args, void *); | |
642 void *arg3 = va_arg(args, void *); | |
643 | |
644 ((void (*)(void *, void *, void *, void *))cb)(arg1, arg2, arg3, data); | |
6485 | 645 } |
646 | |
647 void | |
648 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER(GaimCallback cb, | |
649 va_list args, | |
650 void *data, | |
651 void **return_val) | |
652 { | |
6505 | 653 void *arg1 = va_arg(args, void *); |
654 void *arg2 = va_arg(args, void *); | |
655 void *arg3 = va_arg(args, void *); | |
656 void *arg4 = va_arg(args, void *); | |
657 | |
658 ((void (*)(void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, data); | |
6485 | 659 } |
6509 | 660 |
661 void | |
9514 | 662 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_POINTER(GaimCallback cb, |
663 va_list args, | |
664 void *data, | |
665 void **return_val) | |
666 { | |
667 void *arg1 = va_arg(args, void *); | |
668 void *arg2 = va_arg(args, void *); | |
669 void *arg3 = va_arg(args, void *); | |
670 void *arg4 = va_arg(args, void *); | |
671 void *arg5 = va_arg(args, void *); | |
672 | |
673 ((void (*)(void *, void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, arg5, data); | |
674 } | |
675 | |
676 void | |
6509 | 677 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
678 va_list args, | |
679 void *data, | |
680 void **return_val) | |
681 { | |
682 void *arg1 = va_arg(args, void *); | |
683 void *arg2 = va_arg(args, void *); | |
684 void *arg3 = va_arg(args, void *); | |
685 guint arg4 = va_arg(args, guint); | |
686 | |
687 ((void (*)(void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, data); | |
688 } | |
689 | |
6485 | 690 void |
10104 | 691 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
692 va_list args, | |
693 void *data, | |
694 void **return_val) | |
695 { | |
696 void *arg1 = va_arg(args, void *); | |
697 void *arg2 = va_arg(args, void *); | |
698 void *arg3 = va_arg(args, void *); | |
699 void *arg4 = va_arg(args, void *); | |
700 guint arg5 = va_arg(args, guint); | |
701 | |
702 ((void (*)(void *, void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, arg5, data); | |
703 } | |
704 | |
705 void | |
6485 | 706 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT(GaimCallback cb, |
707 va_list args, | |
708 void *data, | |
709 void **return_val) | |
710 { | |
6505 | 711 void *arg1 = va_arg(args, void *); |
712 void *arg2 = va_arg(args, void *); | |
713 void *arg3 = va_arg(args, void *); | |
714 guint arg4 = va_arg(args, guint); | |
715 guint arg5 = va_arg(args, guint); | |
716 | |
6485 | 717 ((void (*)(void *, void *, void *, guint, guint, void *))cb)( |
6505 | 718 arg1, arg2, arg3, arg4, arg5, data); |
6485 | 719 } |
720 | |
721 void | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
722 gaim_marshal_INT__INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
723 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
724 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
725 gint ret_val; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
726 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
727 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
728 ret_val = ((gint (*)(gint, void *))cb)(arg1, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
729 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
730 if (return_val != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
731 *return_val = GINT_TO_POINTER(ret_val); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
732 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
733 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
734 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
735 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
|
736 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
737 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
738 gint ret_val; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
739 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
740 gint arg2 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
741 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
742 ret_val = ((gint (*)(gint, gint, void *))cb)(arg1, arg2, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
743 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
744 if (return_val != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
745 *return_val = GINT_TO_POINTER(ret_val); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
746 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
747 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
748 void |
6485 | 749 gaim_marshal_BOOLEAN__POINTER(GaimCallback cb, va_list args, void *data, |
750 void **return_val) | |
751 { | |
752 gboolean ret_val; | |
6505 | 753 void *arg1 = va_arg(args, void *); |
6485 | 754 |
6505 | 755 ret_val = ((gboolean (*)(void *, void *))cb)(arg1, data); |
6485 | 756 |
757 if (return_val != NULL) | |
758 *return_val = GINT_TO_POINTER(ret_val); | |
759 } | |
760 | |
761 void | |
762 gaim_marshal_BOOLEAN__POINTER_POINTER(GaimCallback cb, va_list args, | |
763 void *data, void **return_val) | |
764 { | |
765 gboolean ret_val; | |
6505 | 766 void *arg1 = va_arg(args, void *); |
767 void *arg2 = va_arg(args, void *); | |
6485 | 768 |
6505 | 769 ret_val = ((gboolean (*)(void *, void *, void *))cb)(arg1, arg2, data); |
6485 | 770 |
771 if (return_val != NULL) | |
772 *return_val = GINT_TO_POINTER(ret_val); | |
773 } | |
774 | |
775 void | |
6509 | 776 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER(GaimCallback cb, va_list args, |
777 void *data, void **return_val) | |
778 { | |
779 gboolean ret_val; | |
780 void *arg1 = va_arg(args, void *); | |
781 void *arg2 = va_arg(args, void *); | |
782 void *arg3 = va_arg(args, void *); | |
783 | |
784 ret_val = ((gboolean (*)(void *, void *, void *, void *))cb)(arg1, arg2, | |
785 arg3, data); | |
786 | |
787 if (return_val != NULL) | |
788 *return_val = GINT_TO_POINTER(ret_val); | |
789 } | |
790 | |
791 void | |
792 gaim_marshal_BOOLEAN__POINTER_POINTER_UINT(GaimCallback cb, | |
793 va_list args, | |
794 void *data, | |
795 void **return_val) | |
796 { | |
797 gboolean ret_val; | |
798 void *arg1 = va_arg(args, void *); | |
799 void *arg2 = va_arg(args, void *); | |
800 guint arg3 = va_arg(args, guint); | |
801 | |
802 ret_val = ((gboolean (*)(void *, void *, guint, void *))cb)( | |
803 arg1, arg2, arg3, data); | |
804 | |
805 if (return_val != NULL) | |
806 *return_val = GINT_TO_POINTER(ret_val); | |
807 } | |
808 | |
809 void | |
6485 | 810 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
811 va_list args, | |
812 void *data, | |
813 void **return_val) | |
814 { | |
815 gboolean ret_val; | |
6505 | 816 void *arg1 = va_arg(args, void *); |
817 void *arg2 = va_arg(args, void *); | |
818 void *arg3 = va_arg(args, void *); | |
819 guint arg4 = va_arg(args, guint); | |
6485 | 820 |
821 ret_val = ((gboolean (*)(void *, void *, void *, guint, void *))cb)( | |
6505 | 822 arg1, arg2, arg3, arg4, data); |
6485 | 823 |
824 if (return_val != NULL) | |
825 *return_val = GINT_TO_POINTER(ret_val); | |
826 } | |
827 | |
828 void | |
829 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER(GaimCallback cb, | |
830 va_list args, | |
831 void *data, | |
832 void **return_val) | |
833 { | |
834 gboolean ret_val; | |
6505 | 835 void *arg1 = va_arg(args, void *); |
836 void *arg2 = va_arg(args, void *); | |
837 void *arg3 = va_arg(args, void *); | |
838 void *arg4 = va_arg(args, void *); | |
6485 | 839 |
840 ret_val = ((gboolean (*)(void *, void *, void *, void *, void *))cb)( | |
6505 | 841 arg1, arg2, arg3, arg4, data); |
6485 | 842 |
843 if (return_val != NULL) | |
844 *return_val = GINT_TO_POINTER(ret_val); | |
845 } | |
846 | |
847 void | |
848 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER( | |
849 GaimCallback cb, va_list args, void *data, void **return_val) | |
850 { | |
851 gboolean ret_val; | |
6505 | 852 void *arg1 = va_arg(args, void *); |
853 void *arg2 = va_arg(args, void *); | |
854 void *arg3 = va_arg(args, void *); | |
855 void *arg4 = va_arg(args, void *); | |
856 void *arg5 = va_arg(args, void *); | |
6485 | 857 |
858 ret_val = | |
859 ((gboolean (*)(void *, void *, void *, void *, void *, void *))cb)( | |
6505 | 860 arg1, arg2, arg3, arg4, arg5, data); |
6485 | 861 |
862 if (return_val != NULL) | |
863 *return_val = GINT_TO_POINTER(ret_val); | |
864 } |