Mercurial > pidgin.yaz
annotate src/signals.c @ 12718:b5fb60cb3bad
[gaim-migrate @ 15062]
On second thought, let's go with Thomas Huriaux's plan. Almost everything in the PRPL called that status 'away', and it makes more sense to have away and not busy than busy and not away.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 04 Jan 2006 18:52:34 +0000 |
parents | 5bc3d67ceb24 |
children | a1e241dd50b6 |
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 | |
270 g_return_val_if_fail(instance_data != NULL, 0); | |
271 | |
272 /* Get the signal data */ | |
273 signal_data = | |
274 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
275 | |
276 if (signal_data == NULL) | |
277 { | |
278 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
279 "Signal data for %s not found!\n", signal); | |
280 return 0; | |
281 } | |
282 | |
283 /* Create the signal handler data */ | |
284 handler_data = g_new0(GaimSignalHandlerData, 1); | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
285 handler_data->id = signal_data->next_handler_id; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
286 handler_data->cb = func; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
287 handler_data->handle = handle; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
288 handler_data->data = data; |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
289 handler_data->use_vargs = use_vargs; |
10656 | 290 handler_data->priority = priority; |
10758 | 291 |
10656 | 292 signal_data->handlers = g_list_insert_sorted(signal_data->handlers, handler_data, (GCompareFunc)handler_priority); |
6485 | 293 signal_data->handler_count++; |
294 signal_data->next_handler_id++; | |
295 | |
296 return handler_data->id; | |
297 } | |
6553
9e4fa4853cfe
[gaim-migrate @ 7075]
Christian Hammond <chipx86@chipx86.com>
parents:
6547
diff
changeset
|
298 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
299 gulong |
10656 | 300 gaim_signal_connect_priority(void *instance, const char *signal, void *handle, |
301 GaimCallback func, void *data, int priority) | |
302 { | |
303 return signal_connect_common(instance, signal, handle, func, data, priority, FALSE); | |
304 } | |
305 | |
306 gulong | |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
307 gaim_signal_connect(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
308 GaimCallback func, void *data) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
309 { |
10656 | 310 return signal_connect_common(instance, signal, handle, func, data, GAIM_SIGNAL_PRIORITY_DEFAULT, FALSE); |
311 } | |
312 | |
313 gulong | |
314 gaim_signal_connect_priority_vargs(void *instance, const char *signal, void *handle, | |
315 GaimCallback func, void *data, int priority) | |
316 { | |
317 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
|
318 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
319 |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
320 gulong |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
321 gaim_signal_connect_vargs(void *instance, const char *signal, void *handle, |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
322 GaimCallback func, void *data) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
323 { |
10656 | 324 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
|
325 } |
6485 | 326 |
327 void | |
328 gaim_signal_disconnect(void *instance, const char *signal, | |
329 void *handle, GaimCallback func) | |
330 { | |
331 GaimInstanceData *instance_data; | |
332 GaimSignalData *signal_data; | |
333 GaimSignalHandlerData *handler_data; | |
334 GList *l; | |
335 gboolean found = FALSE; | |
336 | |
337 g_return_if_fail(instance != NULL); | |
338 g_return_if_fail(signal != NULL); | |
339 g_return_if_fail(handle != NULL); | |
340 g_return_if_fail(func != NULL); | |
341 | |
342 /* Get the instance data */ | |
343 instance_data = | |
344 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
345 | |
346 g_return_if_fail(instance_data != NULL); | |
347 | |
348 /* Get the signal data */ | |
349 signal_data = | |
350 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
351 | |
352 if (signal_data == NULL) | |
353 { | |
354 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
355 "Signal data for %s not found!\n", signal); | |
356 return; | |
357 } | |
358 | |
359 /* Find the handler data. */ | |
360 for (l = signal_data->handlers; l != NULL; l = l->next) | |
361 { | |
362 handler_data = (GaimSignalHandlerData *)l->data; | |
363 | |
364 if (handler_data->handle == handle && handler_data->cb == func) | |
365 { | |
366 g_free(handler_data); | |
367 | |
368 signal_data->handlers = g_list_remove(signal_data->handlers, | |
369 handler_data); | |
370 signal_data->handler_count--; | |
371 | |
372 found = TRUE; | |
373 | |
374 break; | |
375 } | |
376 } | |
377 | |
378 /* See note somewhere about this actually helping developers.. */ | |
379 g_return_if_fail(found); | |
380 } | |
381 | |
382 /* | |
383 * TODO: Make this all more efficient by storing a list of handlers, keyed | |
384 * to a handle. | |
385 */ | |
386 static void | |
387 disconnect_handle_from_signals(const char *signal, | |
388 GaimSignalData *signal_data, void *handle) | |
389 { | |
390 GList *l, *l_next; | |
391 GaimSignalHandlerData *handler_data; | |
392 | |
393 for (l = signal_data->handlers; l != NULL; l = l_next) | |
394 { | |
395 handler_data = (GaimSignalHandlerData *)l->data; | |
396 l_next = l->next; | |
397 | |
398 if (handler_data->handle == handle) | |
399 { | |
400 g_free(handler_data); | |
401 | |
402 signal_data->handler_count--; | |
403 signal_data->handlers = g_list_remove(signal_data->handlers, | |
404 handler_data); | |
405 } | |
406 } | |
407 } | |
408 | |
409 static void | |
410 disconnect_handle_from_instance(void *instance, | |
411 GaimInstanceData *instance_data, | |
412 void *handle) | |
413 { | |
414 g_hash_table_foreach(instance_data->signals, | |
415 (GHFunc)disconnect_handle_from_signals, handle); | |
416 } | |
417 | |
418 void | |
419 gaim_signals_disconnect_by_handle(void *handle) | |
420 { | |
421 g_return_if_fail(handle != NULL); | |
422 | |
423 g_hash_table_foreach(instance_table, | |
424 (GHFunc)disconnect_handle_from_instance, handle); | |
425 } | |
426 | |
427 void | |
428 gaim_signal_emit(void *instance, const char *signal, ...) | |
429 { | |
430 va_list args; | |
431 | |
7584
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
432 g_return_if_fail(instance != NULL); |
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
433 g_return_if_fail(signal != NULL); |
9e93a4bf1934
[gaim-migrate @ 8202]
Christian Hammond <chipx86@chipx86.com>
parents:
6822
diff
changeset
|
434 |
6485 | 435 va_start(args, signal); |
436 gaim_signal_emit_vargs(instance, signal, args); | |
437 va_end(args); | |
438 } | |
439 | |
440 void | |
441 gaim_signal_emit_vargs(void *instance, const char *signal, va_list args) | |
442 { | |
443 GaimInstanceData *instance_data; | |
444 GaimSignalData *signal_data; | |
445 GaimSignalHandlerData *handler_data; | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
446 GList *l, *l_next; |
8090 | 447 va_list tmp; |
6485 | 448 |
449 g_return_if_fail(instance != NULL); | |
450 g_return_if_fail(signal != NULL); | |
451 | |
452 instance_data = | |
453 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
454 | |
455 g_return_if_fail(instance_data != NULL); | |
456 | |
457 signal_data = | |
458 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
459 | |
460 if (signal_data == NULL) | |
461 { | |
462 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
463 "Signal data for %s not found!\n", signal); | |
464 return; | |
465 } | |
466 | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
467 for (l = signal_data->handlers; l != NULL; l = l_next) |
6485 | 468 { |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
469 l_next = l->next; |
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
470 |
6485 | 471 handler_data = (GaimSignalHandlerData *)l->data; |
472 | |
8090 | 473 /* This is necessary because a va_list may only be |
474 * evaluated once */ | |
8142 | 475 G_VA_COPY(tmp, args); |
8090 | 476 |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
477 if (handler_data->use_vargs) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
478 { |
8090 | 479 ((void (*)(va_list, void *))handler_data->cb)(tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
480 handler_data->data); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
481 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
482 else |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
483 { |
8090 | 484 signal_data->marshal(handler_data->cb, tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
485 handler_data->data, NULL); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
486 } |
8090 | 487 |
488 va_end(tmp); | |
6485 | 489 } |
11080 | 490 |
491 #ifdef HAVE_DBUS | |
11171 | 492 gaim_dbus_signal_emit_gaim(signal, signal_data->num_values, |
11080 | 493 signal_data->values, args); |
494 #endif /* HAVE_DBUS */ | |
495 | |
6485 | 496 } |
497 | |
498 void * | |
499 gaim_signal_emit_return_1(void *instance, const char *signal, ...) | |
500 { | |
501 void *ret_val; | |
502 va_list args; | |
503 | |
7597
191e5b9a249b
[gaim-migrate @ 8218]
Christian Hammond <chipx86@chipx86.com>
parents:
7585
diff
changeset
|
504 g_return_val_if_fail(instance != NULL, NULL); |
191e5b9a249b
[gaim-migrate @ 8218]
Christian Hammond <chipx86@chipx86.com>
parents:
7585
diff
changeset
|
505 g_return_val_if_fail(signal != NULL, NULL); |
7585
404f4a4b81da
[gaim-migrate @ 8203]
Christian Hammond <chipx86@chipx86.com>
parents:
7584
diff
changeset
|
506 |
6485 | 507 va_start(args, signal); |
508 ret_val = gaim_signal_emit_vargs_return_1(instance, signal, args); | |
509 va_end(args); | |
510 | |
511 return ret_val; | |
512 } | |
513 | |
514 void * | |
515 gaim_signal_emit_vargs_return_1(void *instance, const char *signal, | |
516 va_list args) | |
517 { | |
518 GaimInstanceData *instance_data; | |
519 GaimSignalData *signal_data; | |
520 GaimSignalHandlerData *handler_data; | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
521 GList *l, *l_next; |
8140 | 522 va_list tmp; |
6485 | 523 |
524 g_return_val_if_fail(instance != NULL, NULL); | |
525 g_return_val_if_fail(signal != NULL, NULL); | |
526 | |
527 instance_data = | |
528 (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); | |
529 | |
530 g_return_val_if_fail(instance_data != NULL, NULL); | |
531 | |
532 signal_data = | |
533 (GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal); | |
534 | |
535 if (signal_data == NULL) | |
536 { | |
537 gaim_debug(GAIM_DEBUG_ERROR, "signals", | |
538 "Signal data for %s not found!\n", signal); | |
539 return 0; | |
540 } | |
541 | |
11080 | 542 #ifdef HAVE_DBUS |
11171 | 543 gaim_dbus_signal_emit_gaim(signal, signal_data->num_values, |
11080 | 544 signal_data->values, args); |
545 #endif /* HAVE_DBUS */ | |
546 | |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
547 for (l = signal_data->handlers; l != NULL; l = l_next) |
6485 | 548 { |
10789
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
549 void *ret_val = NULL; |
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
550 |
8004
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
551 l_next = l->next; |
07dc83303503
[gaim-migrate @ 8681]
Christian Hammond <chipx86@chipx86.com>
parents:
7597
diff
changeset
|
552 |
6485 | 553 handler_data = (GaimSignalHandlerData *)l->data; |
554 | |
8142 | 555 G_VA_COPY(tmp, args); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
556 if (handler_data->use_vargs) |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
557 { |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
558 ret_val = ((void *(*)(va_list, void *))handler_data->cb)( |
8140 | 559 tmp, handler_data->data); |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
560 } |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
561 else |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
562 { |
8140 | 563 signal_data->marshal(handler_data->cb, tmp, |
6547
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
564 handler_data->data, &ret_val); |
adf168f002ad
[gaim-migrate @ 7069]
Christian Hammond <chipx86@chipx86.com>
parents:
6509
diff
changeset
|
565 } |
8140 | 566 va_end(tmp); |
10789
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
567 |
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
568 if (ret_val != NULL) |
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
569 return ret_val; |
6485 | 570 } |
571 | |
10789
0caa9827edf5
[gaim-migrate @ 12431]
Luke Schierer <lschiere@pidgin.im>
parents:
10758
diff
changeset
|
572 return NULL; |
6485 | 573 } |
574 | |
575 void | |
576 gaim_signals_init() | |
577 { | |
578 g_return_if_fail(instance_table == NULL); | |
579 | |
580 instance_table = | |
581 g_hash_table_new_full(g_direct_hash, g_direct_equal, | |
582 NULL, (GDestroyNotify)destroy_instance_data); | |
583 } | |
584 | |
585 void | |
586 gaim_signals_uninit() | |
587 { | |
588 g_return_if_fail(instance_table != NULL); | |
589 | |
590 g_hash_table_destroy(instance_table); | |
591 instance_table = NULL; | |
592 } | |
593 | |
594 /************************************************************************** | |
595 * Marshallers | |
596 **************************************************************************/ | |
597 void | |
598 gaim_marshal_VOID(GaimCallback cb, va_list args, void *data, | |
599 void **return_val) | |
600 { | |
601 ((void (*)(void *))cb)(data); | |
602 } | |
603 | |
604 void | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
605 gaim_marshal_VOID__INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
606 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
607 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
608 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
609 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
610 ((void (*)(gint, void *))cb)(arg1, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
611 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
612 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
613 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
614 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
|
615 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
616 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
617 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
618 gint arg2 = va_arg(args, gint); |
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 ((void (*)(gint, gint, void *))cb)(arg1, arg2, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
621 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
622 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
623 void |
6485 | 624 gaim_marshal_VOID__POINTER(GaimCallback cb, va_list args, void *data, |
625 void **return_val) | |
626 { | |
6505 | 627 void *arg1 = va_arg(args, void *); |
628 | |
629 ((void (*)(void *, void *))cb)(arg1, data); | |
6485 | 630 } |
631 | |
632 void | |
9734 | 633 gaim_marshal_VOID__POINTER_UINT(GaimCallback cb, va_list args, |
634 void *data, void **return_val) | |
635 { | |
636 void *arg1 = va_arg(args, void *); | |
637 guint arg2 = va_arg(args, guint); | |
638 | |
639 ((void (*)(void *, guint, void *))cb)(arg1, arg2, data); | |
640 } | |
641 | |
11935
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
642 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
|
643 void *data, void **return_val) |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
644 { |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
645 void *arg1 = va_arg(args, void *); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
646 gint arg2 = va_arg(args, gint); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
647 gint arg3 = va_arg(args, gint); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
648 |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
649 ((void (*)(void *, gint, gint, void *))cb)(arg1, arg2, arg3, data); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
650 } |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11256
diff
changeset
|
651 |
9734 | 652 void |
6485 | 653 gaim_marshal_VOID__POINTER_POINTER(GaimCallback cb, va_list args, |
654 void *data, void **return_val) | |
655 { | |
6505 | 656 void *arg1 = va_arg(args, void *); |
657 void *arg2 = va_arg(args, void *); | |
658 | |
659 ((void (*)(void *, void *, void *))cb)(arg1, arg2, data); | |
6485 | 660 } |
661 | |
662 void | |
663 gaim_marshal_VOID__POINTER_POINTER_UINT(GaimCallback cb, va_list args, | |
664 void *data, void **return_val) | |
665 { | |
6505 | 666 void *arg1 = va_arg(args, void *); |
667 void *arg2 = va_arg(args, void *); | |
668 guint arg3 = va_arg(args, guint); | |
669 | |
670 ((void (*)(void *, void *, guint, void *))cb)(arg1, arg2, arg3, data); | |
6485 | 671 } |
672 | |
673 void | |
9554 | 674 gaim_marshal_VOID__POINTER_POINTER_UINT_UINT(GaimCallback cb, va_list args, |
675 void *data, void **return_val) | |
676 { | |
677 void *arg1 = va_arg(args, void *); | |
678 void *arg2 = va_arg(args, void *); | |
679 guint arg3 = va_arg(args, guint); | |
680 guint arg4 = va_arg(args, guint); | |
681 | |
682 ((void (*)(void *, void *, guint, guint, void *))cb)(arg1, arg2, arg3, arg4, data); | |
683 } | |
684 | |
685 void | |
6485 | 686 gaim_marshal_VOID__POINTER_POINTER_POINTER(GaimCallback cb, va_list args, |
687 void *data, void **return_val) | |
688 { | |
6505 | 689 void *arg1 = va_arg(args, void *); |
690 void *arg2 = va_arg(args, void *); | |
691 void *arg3 = va_arg(args, void *); | |
692 | |
693 ((void (*)(void *, void *, void *, void *))cb)(arg1, arg2, arg3, data); | |
6485 | 694 } |
695 | |
696 void | |
697 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER(GaimCallback cb, | |
698 va_list args, | |
699 void *data, | |
700 void **return_val) | |
701 { | |
6505 | 702 void *arg1 = va_arg(args, void *); |
703 void *arg2 = va_arg(args, void *); | |
704 void *arg3 = va_arg(args, void *); | |
705 void *arg4 = va_arg(args, void *); | |
706 | |
707 ((void (*)(void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, data); | |
6485 | 708 } |
6509 | 709 |
710 void | |
9514 | 711 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_POINTER(GaimCallback cb, |
712 va_list args, | |
713 void *data, | |
714 void **return_val) | |
715 { | |
716 void *arg1 = va_arg(args, void *); | |
717 void *arg2 = va_arg(args, void *); | |
718 void *arg3 = va_arg(args, void *); | |
719 void *arg4 = va_arg(args, void *); | |
720 void *arg5 = va_arg(args, void *); | |
721 | |
722 ((void (*)(void *, void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, arg5, data); | |
723 } | |
724 | |
725 void | |
6509 | 726 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
727 va_list args, | |
728 void *data, | |
729 void **return_val) | |
730 { | |
731 void *arg1 = va_arg(args, void *); | |
732 void *arg2 = va_arg(args, void *); | |
733 void *arg3 = va_arg(args, void *); | |
734 guint arg4 = va_arg(args, guint); | |
735 | |
736 ((void (*)(void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, data); | |
737 } | |
738 | |
6485 | 739 void |
10104 | 740 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
741 va_list args, | |
742 void *data, | |
743 void **return_val) | |
744 { | |
745 void *arg1 = va_arg(args, void *); | |
746 void *arg2 = va_arg(args, void *); | |
747 void *arg3 = va_arg(args, void *); | |
748 void *arg4 = va_arg(args, void *); | |
749 guint arg5 = va_arg(args, guint); | |
750 | |
751 ((void (*)(void *, void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, arg5, data); | |
752 } | |
753 | |
754 void | |
6485 | 755 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT(GaimCallback cb, |
756 va_list args, | |
757 void *data, | |
758 void **return_val) | |
759 { | |
6505 | 760 void *arg1 = va_arg(args, void *); |
761 void *arg2 = va_arg(args, void *); | |
762 void *arg3 = va_arg(args, void *); | |
763 guint arg4 = va_arg(args, guint); | |
764 guint arg5 = va_arg(args, guint); | |
765 | |
6485 | 766 ((void (*)(void *, void *, void *, guint, guint, void *))cb)( |
6505 | 767 arg1, arg2, arg3, arg4, arg5, data); |
6485 | 768 } |
769 | |
770 void | |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
771 gaim_marshal_INT__INT(GaimCallback cb, va_list args, void *data, |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
772 void **return_val) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
773 { |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
774 gint ret_val; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
775 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
776 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
777 ret_val = ((gint (*)(gint, void *))cb)(arg1, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
778 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
779 if (return_val != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
780 *return_val = GINT_TO_POINTER(ret_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 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
783 void |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
784 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
|
785 void **return_val) |
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 gint ret_val; |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
788 gint arg1 = va_arg(args, gint); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
789 gint arg2 = va_arg(args, gint); |
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 ret_val = ((gint (*)(gint, gint, void *))cb)(arg1, arg2, data); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
792 |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
793 if (return_val != NULL) |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
794 *return_val = GINT_TO_POINTER(ret_val); |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
795 } |
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
796 |
11064
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
797 |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
798 void |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
799 gaim_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER( |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
800 GaimCallback cb, va_list args, void *data, void **return_val) |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
801 { |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
802 gint ret_val; |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
803 void *arg1 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
804 void *arg2 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
805 void *arg3 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
806 void *arg4 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
807 void *arg5 = va_arg(args, void *); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
808 |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
809 ret_val = |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
810 ((gint (*)(void *, void *, void *, void *, void *, void *))cb)( |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
811 arg1, arg2, arg3, arg4, arg5, data); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
812 |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
813 if (return_val != NULL) |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
814 *return_val = GINT_TO_POINTER(ret_val); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
815 } |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
816 |
6822
7dba3e17cb21
[gaim-migrate @ 7366]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
817 void |
6485 | 818 gaim_marshal_BOOLEAN__POINTER(GaimCallback cb, va_list args, void *data, |
819 void **return_val) | |
820 { | |
821 gboolean ret_val; | |
6505 | 822 void *arg1 = va_arg(args, void *); |
6485 | 823 |
6505 | 824 ret_val = ((gboolean (*)(void *, void *))cb)(arg1, data); |
6485 | 825 |
826 if (return_val != NULL) | |
827 *return_val = GINT_TO_POINTER(ret_val); | |
828 } | |
829 | |
830 void | |
831 gaim_marshal_BOOLEAN__POINTER_POINTER(GaimCallback cb, va_list args, | |
832 void *data, void **return_val) | |
833 { | |
834 gboolean ret_val; | |
6505 | 835 void *arg1 = va_arg(args, void *); |
836 void *arg2 = va_arg(args, void *); | |
6485 | 837 |
6505 | 838 ret_val = ((gboolean (*)(void *, void *, void *))cb)(arg1, arg2, data); |
6485 | 839 |
840 if (return_val != NULL) | |
841 *return_val = GINT_TO_POINTER(ret_val); | |
842 } | |
843 | |
844 void | |
6509 | 845 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER(GaimCallback cb, va_list args, |
846 void *data, void **return_val) | |
847 { | |
848 gboolean ret_val; | |
849 void *arg1 = va_arg(args, void *); | |
850 void *arg2 = va_arg(args, void *); | |
851 void *arg3 = va_arg(args, void *); | |
852 | |
853 ret_val = ((gboolean (*)(void *, void *, void *, void *))cb)(arg1, arg2, | |
854 arg3, data); | |
855 | |
856 if (return_val != NULL) | |
857 *return_val = GINT_TO_POINTER(ret_val); | |
858 } | |
859 | |
860 void | |
861 gaim_marshal_BOOLEAN__POINTER_POINTER_UINT(GaimCallback cb, | |
862 va_list args, | |
863 void *data, | |
864 void **return_val) | |
865 { | |
866 gboolean ret_val; | |
867 void *arg1 = va_arg(args, void *); | |
868 void *arg2 = va_arg(args, void *); | |
869 guint arg3 = va_arg(args, guint); | |
870 | |
871 ret_val = ((gboolean (*)(void *, void *, guint, void *))cb)( | |
872 arg1, arg2, arg3, data); | |
873 | |
874 if (return_val != NULL) | |
875 *return_val = GINT_TO_POINTER(ret_val); | |
876 } | |
877 | |
878 void | |
6485 | 879 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT(GaimCallback cb, |
880 va_list args, | |
881 void *data, | |
882 void **return_val) | |
883 { | |
884 gboolean ret_val; | |
6505 | 885 void *arg1 = va_arg(args, void *); |
886 void *arg2 = va_arg(args, void *); | |
887 void *arg3 = va_arg(args, void *); | |
888 guint arg4 = va_arg(args, guint); | |
6485 | 889 |
890 ret_val = ((gboolean (*)(void *, void *, void *, guint, void *))cb)( | |
6505 | 891 arg1, arg2, arg3, arg4, data); |
6485 | 892 |
893 if (return_val != NULL) | |
894 *return_val = GINT_TO_POINTER(ret_val); | |
895 } | |
896 | |
897 void | |
898 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER(GaimCallback cb, | |
899 va_list args, | |
900 void *data, | |
901 void **return_val) | |
902 { | |
903 gboolean ret_val; | |
6505 | 904 void *arg1 = va_arg(args, void *); |
905 void *arg2 = va_arg(args, void *); | |
906 void *arg3 = va_arg(args, void *); | |
907 void *arg4 = va_arg(args, void *); | |
6485 | 908 |
909 ret_val = ((gboolean (*)(void *, void *, void *, void *, void *))cb)( | |
6505 | 910 arg1, arg2, arg3, arg4, data); |
6485 | 911 |
912 if (return_val != NULL) | |
913 *return_val = GINT_TO_POINTER(ret_val); | |
914 } | |
915 | |
916 void | |
917 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER( | |
918 GaimCallback cb, va_list args, void *data, void **return_val) | |
919 { | |
920 gboolean ret_val; | |
6505 | 921 void *arg1 = va_arg(args, void *); |
922 void *arg2 = va_arg(args, void *); | |
923 void *arg3 = va_arg(args, void *); | |
924 void *arg4 = va_arg(args, void *); | |
925 void *arg5 = va_arg(args, void *); | |
6485 | 926 |
927 ret_val = | |
928 ((gboolean (*)(void *, void *, void *, void *, void *, void *))cb)( | |
6505 | 929 arg1, arg2, arg3, arg4, arg5, data); |
6485 | 930 |
931 if (return_val != NULL) | |
932 *return_val = GINT_TO_POINTER(ret_val); | |
933 } | |
12291
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
934 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
935 void |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
936 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
|
937 void **return_val) |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
938 { |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
939 gboolean ret_val; |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
940 gint arg1 = va_arg(args, gint); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
941 void *arg2 = va_arg(args, void *); |
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 ret_val = ((gboolean (*)(gint, void *, void *))cb)(arg1, arg2, data); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
944 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
945 if (return_val != NULL) |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
946 *return_val = GINT_TO_POINTER(ret_val); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11935
diff
changeset
|
947 } |