Mercurial > pidgin
annotate src/signals.c @ 13961:b0e37dcb3987
[gaim-migrate @ 16514]
Fix the makefile.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 17 Jul 2006 23:57:12 +0000 |
parents | f61428cc4019 |
children | f94309c7c480 |
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 | |
11080 | 27 #include "dbus-maybe.h" |
6485 | 28 #include "debug.h" |
29 #include "signals.h" | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
30 #include "value.h" |
6485 | 31 |
9127 | 32 /* must include this to use G_VA_COPY */ |
33 #include <string.h> | |
34 | |
6485 | 35 typedef struct |
36 { | |
37 void *instance; | |
38 | |
39 GHashTable *signals; | |
40 size_t signal_count; | |
41 | |
42 gulong next_signal_id; | |
43 | |
44 } GaimInstanceData; | |
45 | |
46 typedef struct | |
47 { | |
48 gulong id; | |
49 | |
50 GaimSignalMarshalFunc marshal; | |
51 | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
52 int num_values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
53 GaimValue **values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
54 GaimValue *ret_value; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
55 |
6485 | 56 GList *handlers; |
57 size_t handler_count; | |
58 | |
59 gulong next_handler_id; | |
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; |
10656 | 69 int priority; |
6485 | 70 |
71 } GaimSignalHandlerData; | |
72 | |
73 static GHashTable *instance_table = NULL; | |
74 | |
75 static void | |
76 destroy_instance_data(GaimInstanceData *instance_data) | |
77 { | |
78 g_hash_table_destroy(instance_data->signals); | |
79 | |
80 g_free(instance_data); | |
81 } | |
82 | |
83 static void | |
84 destroy_signal_data(GaimSignalData *signal_data) | |
85 { | |
86 GaimSignalHandlerData *handler_data; | |
87 GList *l; | |
88 | |
89 for (l = signal_data->handlers; l != NULL; l = l->next) | |
90 { | |
91 handler_data = (GaimSignalHandlerData *)l->data; | |
92 | |
93 g_free(l->data); | |
94 } | |
95 | |
96 g_list_free(signal_data->handlers); | |
97 | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
98 if (signal_data->values != NULL) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
99 { |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
100 int i; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
101 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
102 for (i = 0; i < signal_data->num_values; i++) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
103 gaim_value_destroy((GaimValue *)signal_data->values[i]); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
104 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
105 g_free(signal_data->values); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
106 } |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
107 |
10542 | 108 if (signal_data->ret_value != NULL) |
109 gaim_value_destroy(signal_data->ret_value); | |
6485 | 110 g_free(signal_data); |
111 } | |
112 | |
113 gulong | |
114 gaim_signal_register(void *instance, const char *signal, | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
115 GaimSignalMarshalFunc marshal, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
116 GaimValue *ret_value, int num_values, ...) |
6485 | 117 { |
118 GaimInstanceData *instance_data; | |
119 GaimSignalData *signal_data; | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
120 va_list args; |
6485 | 121 |
122 g_return_val_if_fail(instance != NULL, 0); | |
123 g_return_val_if_fail(signal != NULL, 0); | |
124 g_return_val_if_fail(marshal != NULL, 0); | |
125 | |
126 instance_data = | |
127 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
128 | |
129 if (instance_data == NULL) | |
130 { | |
131 instance_data = g_new0(GaimInstanceData, 1); | |
132 | |
133 instance_data->instance = instance; | |
134 instance_data->next_signal_id = 1; | |
135 | |
136 instance_data->signals = | |
137 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, | |
138 (GDestroyNotify)destroy_signal_data); | |
139 | |
140 g_hash_table_insert(instance_table, instance, instance_data); | |
141 } | |
142 | |
143 signal_data = g_new0(GaimSignalData, 1); | |
144 signal_data->id = instance_data->next_signal_id; | |
145 signal_data->marshal = marshal; | |
146 signal_data->next_handler_id = 1; | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
147 signal_data->ret_value = ret_value; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
148 signal_data->num_values = 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 if (num_values > 0) |
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 int i; |
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 signal_data->values = g_new0(GaimValue *, 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 va_start(args, num_values); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
157 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
158 for (i = 0; i < num_values; i++) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
159 signal_data->values[i] = va_arg(args, GaimValue *); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
160 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
161 va_end(args); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
162 } |
6485 | 163 |
164 g_hash_table_insert(instance_data->signals, | |
165 g_strdup(signal), signal_data); | |
166 | |
167 instance_data->next_signal_id++; | |
168 instance_data->signal_count++; | |
169 | |
170 return signal_data->id; | |
171 } | |
172 | |
173 void | |
174 gaim_signal_unregister(void *instance, const char *signal) | |
175 { | |
176 GaimInstanceData *instance_data; | |
177 | |
178 g_return_if_fail(instance != NULL); | |
179 g_return_if_fail(signal != NULL); | |
180 | |
181 instance_data = | |
182 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
183 | |
184 g_return_if_fail(instance_data != NULL); | |
185 | |
186 g_hash_table_remove(instance_data->signals, signal); | |
187 | |
188 instance_data->signal_count--; | |
189 | |
190 if (instance_data->signal_count == 0) | |
191 { | |
192 /* Unregister the instance. */ | |
193 g_hash_table_remove(instance_table, instance); | |
194 } | |
195 } | |
196 | |
197 void | |
198 gaim_signals_unregister_by_instance(void *instance) | |
199 { | |
200 gboolean found; | |
201 | |
202 g_return_if_fail(instance != NULL); | |
203 | |
204 found = g_hash_table_remove(instance_table, instance); | |
205 | |
206 /* | |
207 * Makes things easier (more annoying?) for developers who don't have | |
208 * things registering and unregistering in the right order :) | |
209 */ | |
210 g_return_if_fail(found); | |
211 } | |
212 | |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
213 void |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
214 gaim_signal_get_values(void *instance, const char *signal, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
215 GaimValue **ret_value, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
216 int *num_values, GaimValue ***values) |
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 GaimInstanceData *instance_data; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
219 GaimSignalData *signal_data; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
220 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
221 g_return_if_fail(instance != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
222 g_return_if_fail(signal != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
223 g_return_if_fail(num_values != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
224 g_return_if_fail(values != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
225 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
226 /* Get the instance data */ |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
227 instance_data = |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
228 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); |
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 g_return_if_fail(instance_data != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
231 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
232 /* Get the signal data */ |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
233 signal_data = |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
234 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); |
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 g_return_if_fail(signal_data != NULL); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
237 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
238 *num_values = signal_data->num_values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
239 *values = signal_data->values; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
240 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
241 if (ret_value != NULL) |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
242 *ret_value = signal_data->ret_value; |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
243 } |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6553
diff
changeset
|
244 |
10656 | 245 static gint handler_priority(void * a, void * b) { |
246 GaimSignalHandlerData *ah = (GaimSignalHandlerData*)a; | |
247 GaimSignalHandlerData *bh = (GaimSignalHandlerData*)b; | |
248 if (ah->priority > bh->priority) return 1; | |
249 if (ah->priority < bh->priority) return -1; | |
250 return 0; | |
251 } | |
252 | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
253 static gulong |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
254 signal_connect_common(void *instance, const char *signal, void *handle, |
10656 | 255 GaimCallback func, void *data, int priority, gboolean use_vargs) |
6485 | 256 { |
257 GaimInstanceData *instance_data; | |
258 GaimSignalData *signal_data; | |
259 GaimSignalHandlerData *handler_data; | |
260 | |
261 g_return_val_if_fail(instance != NULL, 0); | |
262 g_return_val_if_fail(signal != NULL, 0); | |
263 g_return_val_if_fail(handle != NULL, 0); | |
264 g_return_val_if_fail(func != NULL, 0); | |
265 | |
266 /* Get the instance data */ | |
267 instance_data = | |
268 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
269 | |
13956 | 270 if (instance_data == NULL) |
271 { | |
272 gaim_debug_warning("signals", "Something tried to register a callback " | |
273 "for the '%s' signal, but we do not have any signals " | |
274 "registered with the given handle\n", signal); | |
275 g_return_val_if_reached(0); | |
276 } | |
6485 | 277 |
278 /* Get the signal data */ | |
279 signal_data = | |
280 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
281 | |
282 if (signal_data == NULL) | |
283 { | |
284 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
285 "Signal data for %s not found!\n", signal); | |
286 return 0; | |
287 } | |
288 | |
289 /* Create the signal handler data */ | |
290 handler_data = g_new0(GaimSignalHandlerData, 1); | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
291 handler_data->id = signal_data->next_handler_id; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
292 handler_data->cb = func; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
293 handler_data->handle = handle; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
294 handler_data->data = data; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
295 handler_data->use_vargs = use_vargs; |
10656 | 296 handler_data->priority = priority; |
10758 | 297 |
10656 | 298 signal_data->handlers = g_list_insert_sorted(signal_data->handlers, handler_data, (GCompareFunc)handler_priority); |
6485 | 299 signal_data->handler_count++; |
300 signal_data->next_handler_id++; | |
301 | |
302 return handler_data->id; | |
303 } | |
6553
9e4fa4853cfe
[gaim-migrate @ 7075]
Christian Hammond <chipx86@chipx86.com>
parents:
6547
diff
changeset
|
304 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
305 gulong |
10656 | 306 gaim_signal_connect_priority(void *instance, const char *signal, void *handle, |
307 GaimCallback func, void *data, int priority) | |
308 { | |
309 return signal_connect_common(instance, signal, handle, func, data, priority, FALSE); | |
310 } | |
311 | |
312 gulong | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
313 gaim_signal_connect(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
314 GaimCallback func, void *data) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
315 { |
10656 | 316 return signal_connect_common(instance, signal, handle, func, data, GAIM_SIGNAL_PRIORITY_DEFAULT, FALSE); |
317 } | |
318 | |
319 gulong | |
320 gaim_signal_connect_priority_vargs(void *instance, const char *signal, void *handle, | |
321 GaimCallback func, void *data, int priority) | |
322 { | |
323 return signal_connect_common(instance, signal, handle, func, data, priority, TRUE); | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
324 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
325 |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
326 gulong |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
327 gaim_signal_connect_vargs(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
328 GaimCallback func, void *data) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
329 { |
10656 | 330 return signal_connect_common(instance, signal, handle, func, data, GAIM_SIGNAL_PRIORITY_DEFAULT, TRUE); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
331 } |
6485 | 332 |
333 void | |
334 gaim_signal_disconnect(void *instance, const char *signal, | |
335 void *handle, GaimCallback func) | |
336 { | |
337 GaimInstanceData *instance_data; | |
338 GaimSignalData *signal_data; | |
339 GaimSignalHandlerData *handler_data; | |
340 GList *l; | |
341 gboolean found = FALSE; | |
342 | |
343 g_return_if_fail(instance != NULL); | |
344 g_return_if_fail(signal != NULL); | |
345 g_return_if_fail(handle != NULL); | |
346 g_return_if_fail(func != NULL); | |
347 | |
348 /* Get the instance data */ | |
349 instance_data = | |
350 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
351 | |
352 g_return_if_fail(instance_data != NULL); | |
353 | |
354 /* Get the signal data */ | |
355 signal_data = | |
356 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
357 | |
358 if (signal_data == NULL) | |
359 { | |
360 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
361 "Signal data for %s not found!\n", signal); | |
362 return; | |
363 } | |
364 | |
365 /* Find the handler data. */ | |
366 for (l = signal_data->handlers; l != NULL; l = l->next) | |
367 { | |
368 handler_data = (GaimSignalHandlerData *)l->data; | |
369 | |
370 if (handler_data->handle == handle && handler_data->cb == func) | |
371 { | |
372 g_free(handler_data); | |
373 | |
374 signal_data->handlers = g_list_remove(signal_data->handlers, | |
375 handler_data); | |
376 signal_data->handler_count--; | |
377 | |
378 found = TRUE; | |
379 | |
380 break; | |
381 } | |
382 } | |
383 | |
384 /* See note somewhere about this actually helping developers.. */ | |
385 g_return_if_fail(found); | |
386 } | |
387 | |
388 /* | |
389 * TODO: Make this all more efficient by storing a list of handlers, keyed | |
390 * to a handle. | |
391 */ | |
392 static void | |
393 disconnect_handle_from_signals(const char *signal, | |
394 GaimSignalData *signal_data, void *handle) | |
395 { | |
396 GList *l, *l_next; | |
397 GaimSignalHandlerData *handler_data; | |
398 | |
399 for (l = signal_data->handlers; l != NULL; l = l_next) | |
400 { | |
401 handler_data = (GaimSignalHandlerData *)l->data; | |
402 l_next = l->next; | |
403 | |
404 if (handler_data->handle == handle) | |
405 { | |
406 g_free(handler_data); | |
407 | |
408 signal_data->handler_count--; | |
409 signal_data->handlers = g_list_remove(signal_data->handlers, | |
410 handler_data); | |
411 } | |
412 } | |
413 } | |
414 | |
415 static void | |
416 disconnect_handle_from_instance(void *instance, | |
417 GaimInstanceData *instance_data, | |
418 void *handle) | |
419 { | |
420 g_hash_table_foreach(instance_data->signals, | |
421 (GHFunc)disconnect_handle_from_signals, handle); | |
422 } | |
423 | |
424 void | |
425 gaim_signals_disconnect_by_handle(void *handle) | |
426 { | |
427 g_return_if_fail(handle != NULL); | |
428 | |
429 g_hash_table_foreach(instance_table, | |
430 (GHFunc)disconnect_handle_from_instance, handle); | |
431 } | |
432 | |
433 void | |
434 gaim_signal_emit(void *instance, const char *signal, ...) | |
435 { | |
436 va_list args; | |
437 | |
7584
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
438 g_return_if_fail(instance != NULL); |
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
439 g_return_if_fail(signal != NULL); |
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
440 |
6485 | 441 va_start(args, signal); |
442 gaim_signal_emit_vargs(instance, signal, args); | |
443 va_end(args); | |
444 } | |
445 | |
446 void | |
447 gaim_signal_emit_vargs(void *instance, const char *signal, va_list args) | |
448 { | |
449 GaimInstanceData *instance_data; | |
450 GaimSignalData *signal_data; | |
451 GaimSignalHandlerData *handler_data; | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
452 GList *l, *l_next; |
8090 | 453 va_list tmp; |
6485 | 454 |
455 g_return_if_fail(instance != NULL); | |
456 g_return_if_fail(signal != NULL); | |
457 | |
458 instance_data = | |
459 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
460 | |
461 g_return_if_fail(instance_data != NULL); | |
462 | |
463 signal_data = | |
464 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
465 | |
466 if (signal_data == NULL) | |
467 { | |
468 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
469 "Signal data for %s not found!\n", signal); | |
470 return; | |
471 } | |
472 | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
473 for (l = signal_data->handlers; l != NULL; l = l_next) |
6485 | 474 { |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
475 l_next = l->next; |
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
476 |
6485 | 477 handler_data = (GaimSignalHandlerData *)l->data; |
478 | |
8090 | 479 /* This is necessary because a va_list may only be |
480 * evaluated once */ | |
8142 | 481 G_VA_COPY(tmp, args); |
8090 | 482 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
483 if (handler_data->use_vargs) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
484 { |
8090 | 485 ((void (*)(va_list, void *))handler_data->cb)(tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
486 handler_data->data); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
487 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
488 else |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
489 { |
8090 | 490 signal_data->marshal(handler_data->cb, tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
491 handler_data->data, NULL); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
492 } |
8090 | 493 |
494 va_end(tmp); | |
6485 | 495 } |
11080 | 496 |
497 #ifdef HAVE_DBUS | |
11171 | 498 gaim_dbus_signal_emit_gaim(signal, signal_data->num_values, |
11080 | 499 signal_data->values, args); |
500 #endif /* HAVE_DBUS */ | |
501 | |
6485 | 502 } |
503 | |
504 void * | |
505 gaim_signal_emit_return_1(void *instance, const char *signal, ...) | |
506 { | |
507 void *ret_val; | |
508 va_list args; | |
509 | |
7597
191e5b9a249b
[gaim-migrate @ 8218]
Christian Hammond <chipx86@chipx86.com>
parents:
7585
diff
changeset
|
510 g_return_val_if_fail(instance != NULL, NULL); |
191e5b9a249b
[gaim-migrate @ 8218]
Christian Hammond <chipx86@chipx86.com>
parents:
7585
diff
changeset
|
511 g_return_val_if_fail(signal != NULL, NULL); |
7585
404f4a4b81da
[gaim-migrate @ 8203]
Christian Hammond <chipx86@chipx86.com>
parents:
7584
diff
changeset
|
512 |
6485 | 513 va_start(args, signal); |
514 ret_val = gaim_signal_emit_vargs_return_1(instance, signal, args); | |
515 va_end(args); | |
516 | |
517 return ret_val; | |
518 } | |
519 | |
520 void * | |
521 gaim_signal_emit_vargs_return_1(void *instance, const char *signal, | |
522 va_list args) | |
523 { | |
524 GaimInstanceData *instance_data; | |
525 GaimSignalData *signal_data; | |
526 GaimSignalHandlerData *handler_data; | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
527 GList *l, *l_next; |
8140 | 528 va_list tmp; |
6485 | 529 |
530 g_return_val_if_fail(instance != NULL, NULL); | |
531 g_return_val_if_fail(signal != NULL, NULL); | |
532 | |
533 instance_data = | |
534 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
535 | |
536 g_return_val_if_fail(instance_data != NULL, NULL); | |
537 | |
538 signal_data = | |
539 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
540 | |
541 if (signal_data == NULL) | |
542 { | |
543 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
544 "Signal data for %s not found!\n", signal); | |
545 return 0; | |
546 } | |
547 | |
11080 | 548 #ifdef HAVE_DBUS |
13056
b00a592651b6
[gaim-migrate @ 15418]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13055
diff
changeset
|
549 G_VA_COPY(tmp, args); |
11171 | 550 gaim_dbus_signal_emit_gaim(signal, signal_data->num_values, |
13055
48a72998676c
[gaim-migrate @ 15417]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
551 signal_data->values, tmp); |
48a72998676c
[gaim-migrate @ 15417]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
552 va_end(tmp); |
11080 | 553 #endif /* HAVE_DBUS */ |
554 | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
555 for (l = signal_data->handlers; l != NULL; l = l_next) |
6485 | 556 { |
10789
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
557 void *ret_val = NULL; |
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
558 |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
559 l_next = l->next; |
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
560 |
6485 | 561 handler_data = (GaimSignalHandlerData *)l->data; |
562 | |
8142 | 563 G_VA_COPY(tmp, args); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
564 if (handler_data->use_vargs) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
565 { |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
566 ret_val = ((void *(*)(va_list, void *))handler_data->cb)( |
8140 | 567 tmp, handler_data->data); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
568 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
569 else |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
570 { |
8140 | 571 signal_data->marshal(handler_data->cb, tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
572 handler_data->data, &ret_val); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
573 } |
8140 | 574 va_end(tmp); |
10789
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
575 |
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
576 if (ret_val != NULL) |
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
577 return ret_val; |
6485 | 578 } |
579 | |
10789
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
580 return NULL; |
6485 | 581 } |
582 | |
583 void | |
584 gaim_signals_init() | |
585 { | |
586 g_return_if_fail(instance_table == NULL); | |
587 | |
588 instance_table = | |
589 g_hash_table_new_full(g_direct_hash, g_direct_equal, | |
590 NULL, (GDestroyNotify)destroy_instance_data); | |
591 } | |
592 | |
593 void | |
594 gaim_signals_uninit() | |
595 { | |
596 g_return_if_fail(instance_table != NULL); | |
597 | |
598 g_hash_table_destroy(instance_table); | |
599 instance_table = NULL; | |
600 } | |
601 | |
602 /************************************************************************** | |
603 * Marshallers | |
604 **************************************************************************/ | |
605 void | |
606 gaim_marshal_VOID(GaimCallback cb, va_list args, void *data, | |
607 void **return_val) | |
608 { | |
609 ((void (*)(void *))cb)(data); | |
610 } | |
611 | |
612 void | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
613 gaim_marshal_VOID__INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
614 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
615 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
616 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
617 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
618 ((void (*)(gint, void *))cb)(arg1, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
619 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
620 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
621 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
622 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
|
623 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
624 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
625 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
626 gint arg2 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
627 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
628 ((void (*)(gint, gint, void *))cb)(arg1, arg2, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
629 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
630 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
631 void |
6485 | 632 gaim_marshal_VOID__POINTER(GaimCallback cb, va_list args, void *data, |
633 void **return_val) | |
634 { | |
6505 | 635 void *arg1 = va_arg(args, void *); |
636 | |
637 ((void (*)(void *, void *))cb)(arg1, data); | |
6485 | 638 } |
639 | |
640 void | |
9734 | 641 gaim_marshal_VOID__POINTER_UINT(GaimCallback cb, va_list args, |
642 void *data, void **return_val) | |
643 { | |
644 void *arg1 = va_arg(args, void *); | |
645 guint arg2 = va_arg(args, guint); | |
646 | |
647 ((void (*)(void *, guint, void *))cb)(arg1, arg2, data); | |
648 } | |
649 | |
11935
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
650 void gaim_marshal_VOID__POINTER_INT_INT(GaimCallback cb, va_list args, |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
651 void *data, void **return_val) |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
652 { |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
653 void *arg1 = va_arg(args, void *); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
654 gint arg2 = va_arg(args, gint); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
655 gint arg3 = va_arg(args, gint); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
656 |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
657 ((void (*)(void *, gint, gint, void *))cb)(arg1, arg2, arg3, data); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
658 } |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
659 |
9734 | 660 void |
6485 | 661 gaim_marshal_VOID__POINTER_POINTER(GaimCallback cb, va_list args, |
662 void *data, void **return_val) | |
663 { | |
6505 | 664 void *arg1 = va_arg(args, void *); |
665 void *arg2 = va_arg(args, void *); | |
666 | |
667 ((void (*)(void *, void *, void *))cb)(arg1, arg2, data); | |
6485 | 668 } |
669 | |
670 void | |
671 gaim_marshal_VOID__POINTER_POINTER_UINT(GaimCallback cb, va_list args, | |
672 void *data, void **return_val) | |
673 { | |
6505 | 674 void *arg1 = va_arg(args, void *); |
675 void *arg2 = va_arg(args, void *); | |
676 guint arg3 = va_arg(args, guint); | |
677 | |
678 ((void (*)(void *, void *, guint, void *))cb)(arg1, arg2, arg3, data); | |
6485 | 679 } |
680 | |
681 void | |
9554 | 682 gaim_marshal_VOID__POINTER_POINTER_UINT_UINT(GaimCallback cb, va_list args, |
683 void *data, void **return_val) | |
684 { | |
685 void *arg1 = va_arg(args, void *); | |
686 void *arg2 = va_arg(args, void *); | |
687 guint arg3 = va_arg(args, guint); | |
688 guint arg4 = va_arg(args, guint); | |
689 | |
690 ((void (*)(void *, void *, guint, guint, void *))cb)(arg1, arg2, arg3, arg4, data); | |
691 } | |
692 | |
693 void | |
6485 | 694 gaim_marshal_VOID__POINTER_POINTER_POINTER(GaimCallback cb, va_list args, |
695 void *data, void **return_val) | |
696 { | |
6505 | 697 void *arg1 = va_arg(args, void *); |
698 void *arg2 = va_arg(args, void *); | |
699 void *arg3 = va_arg(args, void *); | |
700 | |
701 ((void (*)(void *, void *, void *, void *))cb)(arg1, arg2, arg3, data); | |
6485 | 702 } |
703 | |
704 void | |
705 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER(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 void *arg4 = va_arg(args, void *); | |
714 | |
715 ((void (*)(void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, data); | |
6485 | 716 } |
6509 | 717 |
718 void | |
9514 | 719 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_POINTER(GaimCallback cb, |
720 va_list args, | |
721 void *data, | |
722 void **return_val) | |
723 { | |
724 void *arg1 = va_arg(args, void *); | |
725 void *arg2 = va_arg(args, void *); | |
726 void *arg3 = va_arg(args, void *); | |
727 void *arg4 = va_arg(args, void *); | |
728 void *arg5 = va_arg(args, void *); | |
729 | |
730 ((void (*)(void *, void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, arg5, data); | |
731 } | |
732 | |
733 void | |
6509 | 734 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
735 va_list args, | |
736 void *data, | |
737 void **return_val) | |
738 { | |
739 void *arg1 = va_arg(args, void *); | |
740 void *arg2 = va_arg(args, void *); | |
741 void *arg3 = va_arg(args, void *); | |
742 guint arg4 = va_arg(args, guint); | |
743 | |
744 ((void (*)(void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, data); | |
745 } | |
746 | |
6485 | 747 void |
10104 | 748 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
749 va_list args, | |
750 void *data, | |
751 void **return_val) | |
752 { | |
753 void *arg1 = va_arg(args, void *); | |
754 void *arg2 = va_arg(args, void *); | |
755 void *arg3 = va_arg(args, void *); | |
756 void *arg4 = va_arg(args, void *); | |
757 guint arg5 = va_arg(args, guint); | |
758 | |
759 ((void (*)(void *, void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, arg5, data); | |
760 } | |
761 | |
762 void | |
6485 | 763 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT(GaimCallback cb, |
764 va_list args, | |
765 void *data, | |
766 void **return_val) | |
767 { | |
6505 | 768 void *arg1 = va_arg(args, void *); |
769 void *arg2 = va_arg(args, void *); | |
770 void *arg3 = va_arg(args, void *); | |
771 guint arg4 = va_arg(args, guint); | |
772 guint arg5 = va_arg(args, guint); | |
773 | |
6485 | 774 ((void (*)(void *, void *, void *, guint, guint, void *))cb)( |
6505 | 775 arg1, arg2, arg3, arg4, arg5, data); |
6485 | 776 } |
777 | |
778 void | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
779 gaim_marshal_INT__INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
780 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
781 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
782 gint ret_val; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
783 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
784 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
785 ret_val = ((gint (*)(gint, void *))cb)(arg1, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
786 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
787 if (return_val != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
788 *return_val = GINT_TO_POINTER(ret_val); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
789 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
790 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
791 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
792 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
|
793 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
794 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
795 gint ret_val; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
796 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
797 gint arg2 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
798 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
799 ret_val = ((gint (*)(gint, gint, void *))cb)(arg1, arg2, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
800 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
801 if (return_val != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
802 *return_val = GINT_TO_POINTER(ret_val); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
803 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
804 |
11064
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
805 |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
806 void |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
807 gaim_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER( |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
808 GaimCallback cb, va_list args, void *data, void **return_val) |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
809 { |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
810 gint ret_val; |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
811 void *arg1 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
812 void *arg2 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
813 void *arg3 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
814 void *arg4 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
815 void *arg5 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
816 |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
817 ret_val = |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
818 ((gint (*)(void *, void *, void *, void *, void *, void *))cb)( |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
819 arg1, arg2, arg3, arg4, arg5, data); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
820 |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
821 if (return_val != NULL) |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
822 *return_val = GINT_TO_POINTER(ret_val); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
823 } |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
824 |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
825 void |
6485 | 826 gaim_marshal_BOOLEAN__POINTER(GaimCallback cb, va_list args, void *data, |
827 void **return_val) | |
828 { | |
829 gboolean ret_val; | |
6505 | 830 void *arg1 = va_arg(args, void *); |
6485 | 831 |
6505 | 832 ret_val = ((gboolean (*)(void *, void *))cb)(arg1, data); |
6485 | 833 |
834 if (return_val != NULL) | |
835 *return_val = GINT_TO_POINTER(ret_val); | |
836 } | |
837 | |
838 void | |
839 gaim_marshal_BOOLEAN__POINTER_POINTER(GaimCallback cb, va_list args, | |
840 void *data, void **return_val) | |
841 { | |
842 gboolean ret_val; | |
6505 | 843 void *arg1 = va_arg(args, void *); |
844 void *arg2 = va_arg(args, void *); | |
6485 | 845 |
6505 | 846 ret_val = ((gboolean (*)(void *, void *, void *))cb)(arg1, arg2, data); |
6485 | 847 |
848 if (return_val != NULL) | |
849 *return_val = GINT_TO_POINTER(ret_val); | |
850 } | |
851 | |
852 void | |
6509 | 853 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER(GaimCallback cb, va_list args, |
854 void *data, void **return_val) | |
855 { | |
856 gboolean ret_val; | |
857 void *arg1 = va_arg(args, void *); | |
858 void *arg2 = va_arg(args, void *); | |
859 void *arg3 = va_arg(args, void *); | |
860 | |
861 ret_val = ((gboolean (*)(void *, void *, void *, void *))cb)(arg1, arg2, | |
862 arg3, data); | |
863 | |
864 if (return_val != NULL) | |
865 *return_val = GINT_TO_POINTER(ret_val); | |
866 } | |
867 | |
868 void | |
869 gaim_marshal_BOOLEAN__POINTER_POINTER_UINT(GaimCallback cb, | |
870 va_list args, | |
871 void *data, | |
872 void **return_val) | |
873 { | |
874 gboolean ret_val; | |
875 void *arg1 = va_arg(args, void *); | |
876 void *arg2 = va_arg(args, void *); | |
877 guint arg3 = va_arg(args, guint); | |
878 | |
879 ret_val = ((gboolean (*)(void *, void *, guint, void *))cb)( | |
880 arg1, arg2, arg3, data); | |
881 | |
882 if (return_val != NULL) | |
883 *return_val = GINT_TO_POINTER(ret_val); | |
884 } | |
885 | |
886 void | |
6485 | 887 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
888 va_list args, | |
889 void *data, | |
890 void **return_val) | |
891 { | |
892 gboolean ret_val; | |
6505 | 893 void *arg1 = va_arg(args, void *); |
894 void *arg2 = va_arg(args, void *); | |
895 void *arg3 = va_arg(args, void *); | |
896 guint arg4 = va_arg(args, guint); | |
6485 | 897 |
898 ret_val = ((gboolean (*)(void *, void *, void *, guint, void *))cb)( | |
6505 | 899 arg1, arg2, arg3, arg4, data); |
6485 | 900 |
901 if (return_val != NULL) | |
902 *return_val = GINT_TO_POINTER(ret_val); | |
903 } | |
904 | |
905 void | |
906 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER(GaimCallback cb, | |
907 va_list args, | |
908 void *data, | |
909 void **return_val) | |
910 { | |
911 gboolean ret_val; | |
6505 | 912 void *arg1 = va_arg(args, void *); |
913 void *arg2 = va_arg(args, void *); | |
914 void *arg3 = va_arg(args, void *); | |
915 void *arg4 = va_arg(args, void *); | |
6485 | 916 |
917 ret_val = ((gboolean (*)(void *, void *, void *, void *, void *))cb)( | |
6505 | 918 arg1, arg2, arg3, arg4, data); |
6485 | 919 |
920 if (return_val != NULL) | |
921 *return_val = GINT_TO_POINTER(ret_val); | |
922 } | |
923 | |
924 void | |
925 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER( | |
926 GaimCallback cb, va_list args, void *data, void **return_val) | |
927 { | |
928 gboolean ret_val; | |
6505 | 929 void *arg1 = va_arg(args, void *); |
930 void *arg2 = va_arg(args, void *); | |
931 void *arg3 = va_arg(args, void *); | |
932 void *arg4 = va_arg(args, void *); | |
933 void *arg5 = va_arg(args, void *); | |
6485 | 934 |
935 ret_val = | |
936 ((gboolean (*)(void *, void *, void *, void *, void *, void *))cb)( | |
6505 | 937 arg1, arg2, arg3, arg4, arg5, data); |
6485 | 938 |
939 if (return_val != NULL) | |
940 *return_val = GINT_TO_POINTER(ret_val); | |
941 } | |
12291
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
942 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
943 void |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
944 gaim_marshal_BOOLEAN__INT_POINTER(GaimCallback cb, va_list args, void *data, |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
945 void **return_val) |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
946 { |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
947 gboolean ret_val; |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
948 gint arg1 = va_arg(args, gint); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
949 void *arg2 = va_arg(args, void *); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
950 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
951 ret_val = ((gboolean (*)(gint, void *, void *))cb)(arg1, arg2, data); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
952 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
953 if (return_val != NULL) |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
954 *return_val = GINT_TO_POINTER(ret_val); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
955 } |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
956 |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
957 void |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
958 gaim_marshal_POINTER__POINTER_POINTER(GaimCallback cb, va_list args, void *data, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
959 void **return_val) |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
960 { |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
961 gpointer ret_val; |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
962 void *arg1 = va_arg(args, void *); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
963 void *arg2 = va_arg(args, void *); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
964 |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
965 ret_val = ((gpointer (*)(void *, void *, void *))cb)(arg1, arg2, data); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
966 |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
967 if (return_val != NULL) |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
968 *return_val = ret_val; |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12291
diff
changeset
|
969 } |