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