Updated Bengali translation, a month and a half after it was submitted. Fixes #12141.
[pidgin-git.git] / libpurple / signals.c
blobff1984b4e7a95b85543759346983bb4362c8bb4a
1 /**
2 * @file signals.c Signal API
3 * @ingroup core
4 */
6 /* purple
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #include "internal.h"
28 #include "dbus-maybe.h"
29 #include "debug.h"
30 #include "signals.h"
31 #include "value.h"
33 /* must include this to use G_VA_COPY */
34 #include <string.h>
36 typedef struct
38 void *instance;
40 GHashTable *signals;
41 size_t signal_count;
43 gulong next_signal_id;
45 } PurpleInstanceData;
47 typedef struct
49 gulong id;
51 PurpleSignalMarshalFunc marshal;
53 int num_values;
54 PurpleValue **values;
55 PurpleValue *ret_value;
57 GList *handlers;
58 size_t handler_count;
60 gulong next_handler_id;
61 } PurpleSignalData;
63 typedef struct
65 gulong id;
66 PurpleCallback cb;
67 void *handle;
68 void *data;
69 gboolean use_vargs;
70 int priority;
72 } PurpleSignalHandlerData;
74 static GHashTable *instance_table = NULL;
76 static void
77 destroy_instance_data(PurpleInstanceData *instance_data)
79 g_hash_table_destroy(instance_data->signals);
81 g_free(instance_data);
84 static void
85 destroy_signal_data(PurpleSignalData *signal_data)
87 g_list_foreach(signal_data->handlers, (GFunc)g_free, NULL);
88 g_list_free(signal_data->handlers);
90 if (signal_data->values != NULL)
92 int i;
94 for (i = 0; i < signal_data->num_values; i++)
95 purple_value_destroy((PurpleValue *)signal_data->values[i]);
97 g_free(signal_data->values);
100 if (signal_data->ret_value != NULL)
101 purple_value_destroy(signal_data->ret_value);
102 g_free(signal_data);
105 gulong
106 purple_signal_register(void *instance, const char *signal,
107 PurpleSignalMarshalFunc marshal,
108 PurpleValue *ret_value, int num_values, ...)
110 PurpleInstanceData *instance_data;
111 PurpleSignalData *signal_data;
112 va_list args;
114 g_return_val_if_fail(instance != NULL, 0);
115 g_return_val_if_fail(signal != NULL, 0);
116 g_return_val_if_fail(marshal != NULL, 0);
118 instance_data =
119 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
121 if (instance_data == NULL)
123 instance_data = g_new0(PurpleInstanceData, 1);
125 instance_data->instance = instance;
126 instance_data->next_signal_id = 1;
128 instance_data->signals =
129 g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
130 (GDestroyNotify)destroy_signal_data);
132 g_hash_table_insert(instance_table, instance, instance_data);
135 signal_data = g_new0(PurpleSignalData, 1);
136 signal_data->id = instance_data->next_signal_id;
137 signal_data->marshal = marshal;
138 signal_data->next_handler_id = 1;
139 signal_data->ret_value = ret_value;
140 signal_data->num_values = num_values;
142 if (num_values > 0)
144 int i;
146 signal_data->values = g_new0(PurpleValue *, num_values);
148 va_start(args, num_values);
150 for (i = 0; i < num_values; i++)
151 signal_data->values[i] = va_arg(args, PurpleValue *);
153 va_end(args);
156 g_hash_table_insert(instance_data->signals,
157 g_strdup(signal), signal_data);
159 instance_data->next_signal_id++;
160 instance_data->signal_count++;
162 return signal_data->id;
165 void
166 purple_signal_unregister(void *instance, const char *signal)
168 PurpleInstanceData *instance_data;
170 g_return_if_fail(instance != NULL);
171 g_return_if_fail(signal != NULL);
173 instance_data =
174 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
176 g_return_if_fail(instance_data != NULL);
178 g_hash_table_remove(instance_data->signals, signal);
180 instance_data->signal_count--;
182 if (instance_data->signal_count == 0)
184 /* Unregister the instance. */
185 g_hash_table_remove(instance_table, instance);
189 void
190 purple_signals_unregister_by_instance(void *instance)
192 gboolean found;
194 g_return_if_fail(instance != NULL);
196 found = g_hash_table_remove(instance_table, instance);
199 * Makes things easier (more annoying?) for developers who don't have
200 * things registering and unregistering in the right order :)
202 g_return_if_fail(found);
205 void
206 purple_signal_get_values(void *instance, const char *signal,
207 PurpleValue **ret_value,
208 int *num_values, PurpleValue ***values)
210 PurpleInstanceData *instance_data;
211 PurpleSignalData *signal_data;
213 g_return_if_fail(instance != NULL);
214 g_return_if_fail(signal != NULL);
215 g_return_if_fail(num_values != NULL);
216 g_return_if_fail(values != NULL);
218 /* Get the instance data */
219 instance_data =
220 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
222 g_return_if_fail(instance_data != NULL);
224 /* Get the signal data */
225 signal_data =
226 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
228 g_return_if_fail(signal_data != NULL);
230 *num_values = signal_data->num_values;
231 *values = signal_data->values;
233 if (ret_value != NULL)
234 *ret_value = signal_data->ret_value;
237 static gint handler_priority(void * a, void * b) {
238 PurpleSignalHandlerData *ah = (PurpleSignalHandlerData*)a;
239 PurpleSignalHandlerData *bh = (PurpleSignalHandlerData*)b;
240 if (ah->priority > bh->priority) return 1;
241 if (ah->priority < bh->priority) return -1;
242 return 0;
245 static gulong
246 signal_connect_common(void *instance, const char *signal, void *handle,
247 PurpleCallback func, void *data, int priority, gboolean use_vargs)
249 PurpleInstanceData *instance_data;
250 PurpleSignalData *signal_data;
251 PurpleSignalHandlerData *handler_data;
253 g_return_val_if_fail(instance != NULL, 0);
254 g_return_val_if_fail(signal != NULL, 0);
255 g_return_val_if_fail(handle != NULL, 0);
256 g_return_val_if_fail(func != NULL, 0);
258 /* Get the instance data */
259 instance_data =
260 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
262 if (instance_data == NULL)
264 purple_debug_warning("signals", "Something tried to register a callback "
265 "for the '%s' signal, but we do not have any signals "
266 "registered with the given handle\n", signal);
267 g_return_val_if_reached(0);
270 /* Get the signal data */
271 signal_data =
272 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
274 if (signal_data == NULL)
276 purple_debug(PURPLE_DEBUG_ERROR, "signals",
277 "Signal data for %s not found!\n", signal);
278 return 0;
281 /* Create the signal handler data */
282 handler_data = g_new0(PurpleSignalHandlerData, 1);
283 handler_data->id = signal_data->next_handler_id;
284 handler_data->cb = func;
285 handler_data->handle = handle;
286 handler_data->data = data;
287 handler_data->use_vargs = use_vargs;
288 handler_data->priority = priority;
290 signal_data->handlers = g_list_insert_sorted(signal_data->handlers, handler_data, (GCompareFunc)handler_priority);
291 signal_data->handler_count++;
292 signal_data->next_handler_id++;
294 return handler_data->id;
297 gulong
298 purple_signal_connect_priority(void *instance, const char *signal, void *handle,
299 PurpleCallback func, void *data, int priority)
301 return signal_connect_common(instance, signal, handle, func, data, priority, FALSE);
304 gulong
305 purple_signal_connect(void *instance, const char *signal, void *handle,
306 PurpleCallback func, void *data)
308 return signal_connect_common(instance, signal, handle, func, data, PURPLE_SIGNAL_PRIORITY_DEFAULT, FALSE);
311 gulong
312 purple_signal_connect_priority_vargs(void *instance, const char *signal, void *handle,
313 PurpleCallback func, void *data, int priority)
315 return signal_connect_common(instance, signal, handle, func, data, priority, TRUE);
318 gulong
319 purple_signal_connect_vargs(void *instance, const char *signal, void *handle,
320 PurpleCallback func, void *data)
322 return signal_connect_common(instance, signal, handle, func, data, PURPLE_SIGNAL_PRIORITY_DEFAULT, TRUE);
325 void
326 purple_signal_disconnect(void *instance, const char *signal,
327 void *handle, PurpleCallback func)
329 PurpleInstanceData *instance_data;
330 PurpleSignalData *signal_data;
331 PurpleSignalHandlerData *handler_data;
332 GList *l;
333 gboolean found = FALSE;
335 g_return_if_fail(instance != NULL);
336 g_return_if_fail(signal != NULL);
337 g_return_if_fail(handle != NULL);
338 g_return_if_fail(func != NULL);
340 /* Get the instance data */
341 instance_data =
342 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
344 g_return_if_fail(instance_data != NULL);
346 /* Get the signal data */
347 signal_data =
348 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
350 if (signal_data == NULL)
352 purple_debug(PURPLE_DEBUG_ERROR, "signals",
353 "Signal data for %s not found!\n", signal);
354 return;
357 /* Find the handler data. */
358 for (l = signal_data->handlers; l != NULL; l = l->next)
360 handler_data = (PurpleSignalHandlerData *)l->data;
362 if (handler_data->handle == handle && handler_data->cb == func)
364 g_free(handler_data);
366 signal_data->handlers = g_list_delete_link(signal_data->handlers,
368 signal_data->handler_count--;
370 found = TRUE;
372 break;
376 /* See note somewhere about this actually helping developers.. */
377 g_return_if_fail(found);
381 * TODO: Make this all more efficient by storing a list of handlers, keyed
382 * to a handle.
384 static void
385 disconnect_handle_from_signals(const char *signal,
386 PurpleSignalData *signal_data, void *handle)
388 GList *l, *l_next;
389 PurpleSignalHandlerData *handler_data;
391 for (l = signal_data->handlers; l != NULL; l = l_next)
393 handler_data = (PurpleSignalHandlerData *)l->data;
394 l_next = l->next;
396 if (handler_data->handle == handle)
398 g_free(handler_data);
400 signal_data->handler_count--;
401 signal_data->handlers = g_list_delete_link(signal_data->handlers,
407 static void
408 disconnect_handle_from_instance(void *instance,
409 PurpleInstanceData *instance_data,
410 void *handle)
412 g_hash_table_foreach(instance_data->signals,
413 (GHFunc)disconnect_handle_from_signals, handle);
416 void
417 purple_signals_disconnect_by_handle(void *handle)
419 g_return_if_fail(handle != NULL);
421 g_hash_table_foreach(instance_table,
422 (GHFunc)disconnect_handle_from_instance, handle);
425 void
426 purple_signal_emit(void *instance, const char *signal, ...)
428 va_list args;
430 g_return_if_fail(instance != NULL);
431 g_return_if_fail(signal != NULL);
433 va_start(args, signal);
434 purple_signal_emit_vargs(instance, signal, args);
435 va_end(args);
438 void
439 purple_signal_emit_vargs(void *instance, const char *signal, va_list args)
441 PurpleInstanceData *instance_data;
442 PurpleSignalData *signal_data;
443 PurpleSignalHandlerData *handler_data;
444 GList *l, *l_next;
445 va_list tmp;
447 g_return_if_fail(instance != NULL);
448 g_return_if_fail(signal != NULL);
450 instance_data =
451 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
453 g_return_if_fail(instance_data != NULL);
455 signal_data =
456 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
458 if (signal_data == NULL)
460 purple_debug(PURPLE_DEBUG_ERROR, "signals",
461 "Signal data for %s not found!\n", signal);
462 return;
465 for (l = signal_data->handlers; l != NULL; l = l_next)
467 l_next = l->next;
469 handler_data = (PurpleSignalHandlerData *)l->data;
471 /* This is necessary because a va_list may only be
472 * evaluated once */
473 G_VA_COPY(tmp, args);
475 if (handler_data->use_vargs)
477 ((void (*)(va_list, void *))handler_data->cb)(tmp,
478 handler_data->data);
480 else
482 signal_data->marshal(handler_data->cb, tmp,
483 handler_data->data, NULL);
486 va_end(tmp);
489 #ifdef HAVE_DBUS
490 purple_dbus_signal_emit_purple(signal, signal_data->num_values,
491 signal_data->values, args);
492 #endif /* HAVE_DBUS */
496 void *
497 purple_signal_emit_return_1(void *instance, const char *signal, ...)
499 void *ret_val;
500 va_list args;
502 g_return_val_if_fail(instance != NULL, NULL);
503 g_return_val_if_fail(signal != NULL, NULL);
505 va_start(args, signal);
506 ret_val = purple_signal_emit_vargs_return_1(instance, signal, args);
507 va_end(args);
509 return ret_val;
512 void *
513 purple_signal_emit_vargs_return_1(void *instance, const char *signal,
514 va_list args)
516 PurpleInstanceData *instance_data;
517 PurpleSignalData *signal_data;
518 PurpleSignalHandlerData *handler_data;
519 GList *l, *l_next;
520 va_list tmp;
522 g_return_val_if_fail(instance != NULL, NULL);
523 g_return_val_if_fail(signal != NULL, NULL);
525 instance_data =
526 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
528 g_return_val_if_fail(instance_data != NULL, NULL);
530 signal_data =
531 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
533 if (signal_data == NULL)
535 purple_debug(PURPLE_DEBUG_ERROR, "signals",
536 "Signal data for %s not found!\n", signal);
537 return 0;
540 #ifdef HAVE_DBUS
541 G_VA_COPY(tmp, args);
542 purple_dbus_signal_emit_purple(signal, signal_data->num_values,
543 signal_data->values, tmp);
544 va_end(tmp);
545 #endif /* HAVE_DBUS */
547 for (l = signal_data->handlers; l != NULL; l = l_next)
549 void *ret_val = NULL;
551 l_next = l->next;
553 handler_data = (PurpleSignalHandlerData *)l->data;
555 G_VA_COPY(tmp, args);
556 if (handler_data->use_vargs)
558 ret_val = ((void *(*)(va_list, void *))handler_data->cb)(
559 tmp, handler_data->data);
561 else
563 signal_data->marshal(handler_data->cb, tmp,
564 handler_data->data, &ret_val);
566 va_end(tmp);
568 if (ret_val != NULL)
569 return ret_val;
572 return NULL;
575 void
576 purple_signals_init()
578 g_return_if_fail(instance_table == NULL);
580 instance_table =
581 g_hash_table_new_full(g_direct_hash, g_direct_equal,
582 NULL, (GDestroyNotify)destroy_instance_data);
585 void
586 purple_signals_uninit()
588 g_return_if_fail(instance_table != NULL);
590 g_hash_table_destroy(instance_table);
591 instance_table = NULL;
594 /**************************************************************************
595 * Marshallers
596 **************************************************************************/
597 void
598 purple_marshal_VOID(PurpleCallback cb, va_list args, void *data,
599 void **return_val)
601 ((void (*)(void *))cb)(data);
604 void
605 purple_marshal_VOID__INT(PurpleCallback cb, va_list args, void *data,
606 void **return_val)
608 gint arg1 = va_arg(args, gint);
610 ((void (*)(gint, void *))cb)(arg1, data);
613 void
614 purple_marshal_VOID__INT_INT(PurpleCallback cb, va_list args, void *data,
615 void **return_val)
617 gint arg1 = va_arg(args, gint);
618 gint arg2 = va_arg(args, gint);
620 ((void (*)(gint, gint, void *))cb)(arg1, arg2, data);
623 void
624 purple_marshal_VOID__POINTER(PurpleCallback cb, va_list args, void *data,
625 void **return_val)
627 void *arg1 = va_arg(args, void *);
629 ((void (*)(void *, void *))cb)(arg1, data);
632 void
633 purple_marshal_VOID__POINTER_UINT(PurpleCallback cb, va_list args,
634 void *data, void **return_val)
636 void *arg1 = va_arg(args, void *);
637 guint arg2 = va_arg(args, guint);
639 ((void (*)(void *, guint, void *))cb)(arg1, arg2, data);
642 void purple_marshal_VOID__POINTER_INT_INT(PurpleCallback cb, va_list args,
643 void *data, void **return_val)
645 void *arg1 = va_arg(args, void *);
646 gint arg2 = va_arg(args, gint);
647 gint arg3 = va_arg(args, gint);
649 ((void (*)(void *, gint, gint, void *))cb)(arg1, arg2, arg3, data);
652 void purple_marshal_VOID__POINTER_INT_POINTER(PurpleCallback cb, va_list args,
653 void *data, void **return_val)
655 void *arg1 = va_arg(args, void *);
656 gint arg2 = va_arg(args, gint);
657 void *arg3 = va_arg(args, void *);
659 ((void (*)(void *, gint, void *, void *))cb)(arg1, arg2, arg3, data);
662 void
663 purple_marshal_VOID__POINTER_POINTER(PurpleCallback cb, va_list args,
664 void *data, void **return_val)
666 void *arg1 = va_arg(args, void *);
667 void *arg2 = va_arg(args, void *);
669 ((void (*)(void *, void *, void *))cb)(arg1, arg2, data);
672 void
673 purple_marshal_VOID__POINTER_POINTER_UINT(PurpleCallback cb, va_list args,
674 void *data, void **return_val)
676 void *arg1 = va_arg(args, void *);
677 void *arg2 = va_arg(args, void *);
678 guint arg3 = va_arg(args, guint);
680 ((void (*)(void *, void *, guint, void *))cb)(arg1, arg2, arg3, data);
683 void
684 purple_marshal_VOID__POINTER_POINTER_UINT_UINT(PurpleCallback cb, va_list args,
685 void *data, void **return_val)
687 void *arg1 = va_arg(args, void *);
688 void *arg2 = va_arg(args, void *);
689 guint arg3 = va_arg(args, guint);
690 guint arg4 = va_arg(args, guint);
692 ((void (*)(void *, void *, guint, guint, void *))cb)(arg1, arg2, arg3, arg4, data);
695 void
696 purple_marshal_VOID__POINTER_POINTER_POINTER(PurpleCallback cb, va_list args,
697 void *data, void **return_val)
699 void *arg1 = va_arg(args, void *);
700 void *arg2 = va_arg(args, void *);
701 void *arg3 = va_arg(args, void *);
703 ((void (*)(void *, void *, void *, void *))cb)(arg1, arg2, arg3, data);
706 void
707 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER(PurpleCallback cb,
708 va_list args,
709 void *data,
710 void **return_val)
712 void *arg1 = va_arg(args, void *);
713 void *arg2 = va_arg(args, void *);
714 void *arg3 = va_arg(args, void *);
715 void *arg4 = va_arg(args, void *);
717 ((void (*)(void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, data);
720 void
721 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_POINTER(PurpleCallback cb,
722 va_list args,
723 void *data,
724 void **return_val)
726 void *arg1 = va_arg(args, void *);
727 void *arg2 = va_arg(args, void *);
728 void *arg3 = va_arg(args, void *);
729 void *arg4 = va_arg(args, void *);
730 void *arg5 = va_arg(args, void *);
732 ((void (*)(void *, void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, arg5, data);
735 void
736 purple_marshal_VOID__POINTER_POINTER_POINTER_UINT(PurpleCallback cb,
737 va_list args,
738 void *data,
739 void **return_val)
741 void *arg1 = va_arg(args, void *);
742 void *arg2 = va_arg(args, void *);
743 void *arg3 = va_arg(args, void *);
744 guint arg4 = va_arg(args, guint);
746 ((void (*)(void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, data);
749 void
750 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT(PurpleCallback cb,
751 va_list args,
752 void *data,
753 void **return_val)
755 void *arg1 = va_arg(args, void *);
756 void *arg2 = va_arg(args, void *);
757 void *arg3 = va_arg(args, void *);
758 void *arg4 = va_arg(args, void *);
759 guint arg5 = va_arg(args, guint);
761 ((void (*)(void *, void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, arg5, data);
764 void
765 purple_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT(PurpleCallback cb,
766 va_list args,
767 void *data,
768 void **return_val)
770 void *arg1 = va_arg(args, void *);
771 void *arg2 = va_arg(args, void *);
772 void *arg3 = va_arg(args, void *);
773 guint arg4 = va_arg(args, guint);
774 guint arg5 = va_arg(args, guint);
776 ((void (*)(void *, void *, void *, guint, guint, void *))cb)(
777 arg1, arg2, arg3, arg4, arg5, data);
780 void
781 purple_marshal_INT__INT(PurpleCallback cb, va_list args, void *data,
782 void **return_val)
784 gint ret_val;
785 gint arg1 = va_arg(args, gint);
787 ret_val = ((gint (*)(gint, void *))cb)(arg1, data);
789 if (return_val != NULL)
790 *return_val = GINT_TO_POINTER(ret_val);
793 void
794 purple_marshal_INT__INT_INT(PurpleCallback cb, va_list args, void *data,
795 void **return_val)
797 gint ret_val;
798 gint arg1 = va_arg(args, gint);
799 gint arg2 = va_arg(args, gint);
801 ret_val = ((gint (*)(gint, gint, void *))cb)(arg1, arg2, data);
803 if (return_val != NULL)
804 *return_val = GINT_TO_POINTER(ret_val);
807 void
808 purple_marshal_INT__POINTER_POINTER(PurpleCallback cb, va_list args, void *data,
809 void **return_val)
811 gint ret_val;
812 void *arg1 = va_arg(args, void *);
813 void *arg2 = va_arg(args, void *);
815 ret_val = ((gint (*)(void *, void *, void *))cb)(arg1, arg2, data);
817 if (return_val != NULL)
818 *return_val = GINT_TO_POINTER(ret_val);
821 void
822 purple_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER(
823 PurpleCallback cb, va_list args, void *data, void **return_val)
825 gint ret_val;
826 void *arg1 = va_arg(args, void *);
827 void *arg2 = va_arg(args, void *);
828 void *arg3 = va_arg(args, void *);
829 void *arg4 = va_arg(args, void *);
830 void *arg5 = va_arg(args, void *);
832 ret_val =
833 ((gint (*)(void *, void *, void *, void *, void *, void *))cb)(
834 arg1, arg2, arg3, arg4, arg5, data);
836 if (return_val != NULL)
837 *return_val = GINT_TO_POINTER(ret_val);
840 void
841 purple_marshal_BOOLEAN__POINTER(PurpleCallback cb, va_list args, void *data,
842 void **return_val)
844 gboolean ret_val;
845 void *arg1 = va_arg(args, void *);
847 ret_val = ((gboolean (*)(void *, void *))cb)(arg1, data);
849 if (return_val != NULL)
850 *return_val = GINT_TO_POINTER(ret_val);
853 void
854 purple_marshal_BOOLEAN__POINTER_POINTER(PurpleCallback cb, va_list args,
855 void *data, void **return_val)
857 gboolean ret_val;
858 void *arg1 = va_arg(args, void *);
859 void *arg2 = va_arg(args, void *);
861 ret_val = ((gboolean (*)(void *, void *, void *))cb)(arg1, arg2, data);
863 if (return_val != NULL)
864 *return_val = GINT_TO_POINTER(ret_val);
867 void
868 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER(PurpleCallback cb, va_list args,
869 void *data, void **return_val)
871 gboolean ret_val;
872 void *arg1 = va_arg(args, void *);
873 void *arg2 = va_arg(args, void *);
874 void *arg3 = va_arg(args, void *);
876 ret_val = ((gboolean (*)(void *, void *, void *, void *))cb)(arg1, arg2,
877 arg3, data);
879 if (return_val != NULL)
880 *return_val = GINT_TO_POINTER(ret_val);
883 void
884 purple_marshal_BOOLEAN__POINTER_POINTER_UINT(PurpleCallback cb,
885 va_list args,
886 void *data,
887 void **return_val)
889 gboolean ret_val;
890 void *arg1 = va_arg(args, void *);
891 void *arg2 = va_arg(args, void *);
892 guint arg3 = va_arg(args, guint);
894 ret_val = ((gboolean (*)(void *, void *, guint, void *))cb)(
895 arg1, arg2, arg3, data);
897 if (return_val != NULL)
898 *return_val = GINT_TO_POINTER(ret_val);
901 void
902 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT(PurpleCallback cb,
903 va_list args,
904 void *data,
905 void **return_val)
907 gboolean ret_val;
908 void *arg1 = va_arg(args, void *);
909 void *arg2 = va_arg(args, void *);
910 void *arg3 = va_arg(args, void *);
911 guint arg4 = va_arg(args, guint);
913 ret_val = ((gboolean (*)(void *, void *, void *, guint, void *))cb)(
914 arg1, arg2, arg3, arg4, data);
916 if (return_val != NULL)
917 *return_val = GINT_TO_POINTER(ret_val);
920 void
921 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER(PurpleCallback cb,
922 va_list args,
923 void *data,
924 void **return_val)
926 gboolean ret_val;
927 void *arg1 = va_arg(args, void *);
928 void *arg2 = va_arg(args, void *);
929 void *arg3 = va_arg(args, void *);
930 void *arg4 = va_arg(args, void *);
932 ret_val = ((gboolean (*)(void *, void *, void *, void *, void *))cb)(
933 arg1, arg2, arg3, arg4, data);
935 if (return_val != NULL)
936 *return_val = GINT_TO_POINTER(ret_val);
939 void
940 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER(
941 PurpleCallback cb, va_list args, void *data, void **return_val)
943 gboolean ret_val;
944 void *arg1 = va_arg(args, void *);
945 void *arg2 = va_arg(args, void *);
946 void *arg3 = va_arg(args, void *);
947 void *arg4 = va_arg(args, void *);
948 void *arg5 = va_arg(args, void *);
950 ret_val =
951 ((gboolean (*)(void *, void *, void *, void *, void *, void *))cb)(
952 arg1, arg2, arg3, arg4, arg5, data);
954 if (return_val != NULL)
955 *return_val = GINT_TO_POINTER(ret_val);
958 void
959 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_UINT(
960 PurpleCallback cb, va_list args, void *data, void **return_val)
962 gboolean ret_val;
963 void *arg1 = va_arg(args, void *);
964 void *arg2 = va_arg(args, void *);
965 void *arg3 = va_arg(args, void *);
966 void *arg4 = va_arg(args, void *);
967 guint arg5 = va_arg(args, guint);
969 ret_val =
970 ((gboolean (*)(void *, void *, void *, void *, guint, void *))cb)(
971 arg1, arg2, arg3, arg4, arg5, data);
973 if (return_val != NULL)
974 *return_val = GINT_TO_POINTER(ret_val);
977 void
978 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER(
979 PurpleCallback cb, va_list args, void *data, void **return_val)
981 gboolean ret_val;
982 void *arg1 = va_arg(args, void *);
983 void *arg2 = va_arg(args, void *);
984 void *arg3 = va_arg(args, void *);
985 void *arg4 = va_arg(args, void *);
986 void *arg5 = va_arg(args, void *);
987 void *arg6 = va_arg(args, void *);
989 ret_val =
990 ((gboolean (*)(void *, void *, void *, void *, void *, void *, void *))cb)(
991 arg1, arg2, arg3, arg4, arg5, arg6, data);
993 if (return_val != NULL)
994 *return_val = GINT_TO_POINTER(ret_val);
997 void
998 purple_marshal_BOOLEAN__INT_POINTER(PurpleCallback cb, va_list args, void *data,
999 void **return_val)
1001 gboolean ret_val;
1002 gint arg1 = va_arg(args, gint);
1003 void *arg2 = va_arg(args, void *);
1005 ret_val = ((gboolean (*)(gint, void *, void *))cb)(arg1, arg2, data);
1007 if (return_val != NULL)
1008 *return_val = GINT_TO_POINTER(ret_val);
1011 void
1012 purple_marshal_POINTER__POINTER(
1013 PurpleCallback cb, va_list args, void *data,
1014 void **return_val)
1016 gpointer ret_val;
1017 void *arg1 = va_arg(args, void *);
1019 ret_val = ((gpointer(*)(void *, void *))cb)(arg1, data);
1021 if (return_val != NULL)
1022 *return_val = ret_val;
1026 void
1027 purple_marshal_POINTER__POINTER_INT(
1028 PurpleCallback cb, va_list args, void *data,
1029 void **return_val)
1031 gpointer ret_val;
1032 void *arg1 = va_arg(args, void *);
1033 gint arg2 = va_arg(args, gint);
1035 ret_val = ((gpointer(*)(void *, gint, void *))cb)(arg1, arg2, data);
1037 if (return_val != NULL)
1038 *return_val = ret_val;
1041 void
1042 purple_marshal_POINTER__POINTER_INT64(
1043 PurpleCallback cb, va_list args, void *data,
1044 void **return_val)
1046 gpointer ret_val;
1047 void *arg1 = va_arg(args, void *);
1048 gint64 arg2 = va_arg(args, gint64);
1050 ret_val = ((gpointer(*)(void *, gint64, void *))cb)(arg1, arg2, data);
1052 if (return_val != NULL)
1053 *return_val = ret_val;
1056 void
1057 purple_marshal_POINTER__POINTER_INT_BOOLEAN(
1058 PurpleCallback cb, va_list args, void *data,
1059 void **return_val)
1061 gpointer ret_val;
1062 void *arg1 = va_arg(args, void *);
1063 gint arg2 = va_arg(args, gint);
1064 gboolean arg3 = va_arg(args, gboolean);
1066 ret_val = ((gpointer(*)(void *, gint, gboolean, void *))cb)(arg1, arg2, arg3, data);
1068 if (return_val != NULL)
1069 *return_val = ret_val;
1072 void
1073 purple_marshal_POINTER__POINTER_INT64_BOOLEAN(
1074 PurpleCallback cb, va_list args, void *data,
1075 void **return_val)
1077 gpointer ret_val;
1078 void *arg1 = va_arg(args, void *);
1079 gint64 arg2 = va_arg(args, gint64);
1080 gboolean arg3 = va_arg(args, gboolean);
1082 ret_val = ((gpointer(*)(void *, gint64, gboolean, void *))cb)(arg1, arg2, arg3, data);
1084 if (return_val != NULL)
1085 *return_val = ret_val;
1088 void
1089 purple_marshal_POINTER__POINTER_POINTER(PurpleCallback cb, va_list args, void *data,
1090 void **return_val)
1092 gpointer ret_val;
1093 void *arg1 = va_arg(args, void *);
1094 void *arg2 = va_arg(args, void *);
1096 ret_val = ((gpointer (*)(void *, void *, void *))cb)(arg1, arg2, data);
1098 if (return_val != NULL)
1099 *return_val = ret_val;