annotate plugins/tcl/tcl_signals.c @ 6715:f362dc18f920

[gaim-migrate @ 7241] Tk fix? committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Wed, 03 Sep 2003 00:10:50 +0000
parents 57161e3abbb5
children b0913ab92893
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6694
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1 /**
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2 * @file tcl_signals.c Gaim Tcl signal API
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
3 *
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
4 * gaim
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
5 *
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
6 * Copyright (C) 2003 Ethan Blanton <eblanton@cs.purdue.edu>
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
7 *
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
12 *
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
17 *
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
21 */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
22 #include <tcl.h>
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
23 #include <stdarg.h>
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
24
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
25 #include "tcl_gaim.h"
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
26
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
27 #include "internal.h"
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
28 #include "connection.h"
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
29 #include "conversation.h"
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
30 #include "signals.h"
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
31 #include "debug.h"
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
32 #include "value.h"
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
33 #include "core.h"
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
34
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
35 static GList *tcl_callbacks;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
36
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
37 static void *tcl_signal_callback(va_list args, struct tcl_signal_handler *handler);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
38
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
39 void tcl_signal_init()
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
40 {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
41 tcl_callbacks = NULL;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
42 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
43
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
44 void tcl_signal_handler_free(struct tcl_signal_handler *handler)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
45 {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
46 if (handler == NULL)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
47 return;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
48
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
49 g_free(handler->signal);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
50 if (handler->argnames != NULL)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
51 g_free(handler->argnames);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
52 Tcl_DecrRefCount(handler->proc);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
53 g_free(handler);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
54 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
55
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
56 void tcl_signal_cleanup(Tcl_Interp *interp)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
57 {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
58 GList *cur;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
59 struct tcl_signal_handler *handler;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
60
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
61 for (cur = tcl_callbacks; cur != NULL; cur = g_list_next(cur)) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
62 handler = cur->data;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
63 if (handler->interp == interp) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
64 tcl_signal_handler_free(handler);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
65 cur->data = NULL;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
66 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
67 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
68 tcl_callbacks = g_list_remove_all(tcl_callbacks, NULL);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
69 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
70
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
71 gboolean tcl_signal_connect(struct tcl_signal_handler *handler)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
72 {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
73 gaim_signal_get_values(handler->instance, handler->signal, &handler->returntype,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
74 &handler->nargs, &handler->argtypes);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
75
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
76 if (handler->nargs != handler->nnames)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
77 return FALSE;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
78
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
79 tcl_signal_disconnect(handler->interp, handler->signal, handler->interp);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
80
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
81 if (!gaim_signal_connect_vargs(handler->instance, handler->signal, (void *)handler->interp,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
82 GAIM_CALLBACK(tcl_signal_callback), (void *)handler))
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
83 return FALSE;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
84
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
85 tcl_callbacks = g_list_append(tcl_callbacks, (gpointer)handler);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
86
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
87 return TRUE;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
88 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
89
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
90 void tcl_signal_disconnect(void *instance, const char *signal, Tcl_Interp *interp)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
91 {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
92 GList *cur;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
93 struct tcl_signal_handler *handler;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
94 gboolean found = FALSE;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
95
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
96 for (cur = tcl_callbacks; cur != NULL; cur = g_list_next(cur)) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
97 handler = cur->data;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
98 if (handler->interp == interp && handler->instance == instance
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
99 && !strcmp(signal, handler->signal)) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
100 gaim_signal_disconnect(instance, signal, handler->interp,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
101 GAIM_CALLBACK(tcl_signal_callback));
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
102 tcl_signal_handler_free(handler);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
103 cur->data = NULL;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
104 found = TRUE;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
105 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
106 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
107 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
108 if (found)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
109 tcl_callbacks = g_list_remove_all(tcl_callbacks, NULL);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
110 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
111
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
112 static void *tcl_signal_callback(va_list args, struct tcl_signal_handler *handler)
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
113 {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
114 struct var {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
115 void *val;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
116 char *str;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
117 } *vars;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
118 GString *val, *name;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
119 GaimBlistNode *node;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
120 int error, i;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
121 void *retval = NULL;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
122 Tcl_Obj *result;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
123
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
124 vars = g_new0(struct var, handler->nargs);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
125 val = g_string_sized_new(32);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
126 name = g_string_sized_new(32);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
127
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
128 for (i = 0; i < handler->nargs; i++) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
129 g_string_printf(name, "::gaim::_callback::%s", handler->argnames[i]);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
130
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
131 switch(gaim_value_get_type(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
132 default: /* Yes, at the top */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
133 case GAIM_TYPE_UNKNOWN: /* What? I guess just pass the word ... */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
134 /* treat this as a pointer, but complain first */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
135 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "unknown GaimValue type %d\n",
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
136 gaim_value_get_type(handler->argtypes[i]));
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
137 case GAIM_TYPE_POINTER:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
138 case GAIM_TYPE_OBJECT:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
139 case GAIM_TYPE_BOXED:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
140 /* These are all "pointer" types to us */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
141 if (gaim_value_is_outgoing(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
142 vars[i].val = va_arg(args, void **);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
143 Tcl_LinkVar(handler->interp, name->str, vars[i].val, TCL_LINK_INT);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
144 } else {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
145 vars[i].val = va_arg(args, void *);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
146 Tcl_LinkVar(handler->interp, name->str, (char *)&vars[i].val,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
147 TCL_LINK_INT|TCL_LINK_READ_ONLY);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
148 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
149 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
150 case GAIM_TYPE_BOOLEAN:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
151 if (gaim_value_is_outgoing(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
152 vars[i].val = va_arg(args, gboolean *);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
153 Tcl_LinkVar(handler->interp, name->str, vars[i].val, TCL_LINK_BOOLEAN);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
154 } else {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
155 vars[i].val = (void *)va_arg(args, gboolean);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
156 Tcl_LinkVar(handler->interp, name->str, (char *)&vars[i].val,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
157 TCL_LINK_BOOLEAN|TCL_LINK_READ_ONLY);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
158 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
159 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
160 case GAIM_TYPE_CHAR:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
161 case GAIM_TYPE_UCHAR:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
162 case GAIM_TYPE_SHORT:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
163 case GAIM_TYPE_USHORT:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
164 case GAIM_TYPE_INT:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
165 case GAIM_TYPE_UINT:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
166 case GAIM_TYPE_LONG:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
167 case GAIM_TYPE_ULONG:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
168 case GAIM_TYPE_ENUM:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
169 /* These next two are totally bogus */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
170 case GAIM_TYPE_INT64:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
171 case GAIM_TYPE_UINT64:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
172 /* I should really cast these individually to
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
173 * preserve as much information as possible ...
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
174 * but heh */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
175 if (gaim_value_is_outgoing(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
176 vars[i].val = (void *)va_arg(args, int *);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
177 Tcl_LinkVar(handler->interp, name->str, vars[i].val, TCL_LINK_INT);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
178 } else {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
179 vars[i].val = (void *)va_arg(args, int);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
180 Tcl_LinkVar(handler->interp, name->str, (char *)&vars[i].val,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
181 TCL_LINK_INT|TCL_LINK_READ_ONLY);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
182 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
183 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
184 case GAIM_TYPE_STRING:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
185 if (gaim_value_is_outgoing(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
186 vars[i].val = (void *)va_arg(args, char **);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
187 if (vars[i].val != NULL && *(char **)vars[i].val != NULL) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
188 vars[i].str = (char *)ckalloc(strlen(*(char **)vars[i].val) + 1);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
189 strcpy(vars[i].str, *(char **)vars[i].val);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
190 } else {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
191 vars[i].str = (char *)ckalloc(1);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
192 *vars[i].str = '\0';
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
193 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
194 Tcl_LinkVar(handler->interp, name->str, (char *)&vars[i].str, TCL_LINK_STRING);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
195 } else {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
196 vars[i].val = (void *)va_arg(args, char *);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
197 Tcl_LinkVar(handler->interp, name->str, (char *)&vars[i].val,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
198 TCL_LINK_STRING|TCL_LINK_READ_ONLY);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
199 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
200 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
201 case GAIM_TYPE_SUBTYPE:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
202 switch (gaim_value_get_subtype(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
203 default:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
204 case GAIM_SUBTYPE_UNKNOWN:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
205 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "subtype unknown\n");
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
206 case GAIM_SUBTYPE_ACCOUNT:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
207 case GAIM_SUBTYPE_CONNECTION:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
208 case GAIM_SUBTYPE_CONVERSATION:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
209 case GAIM_SUBTYPE_CONV_WINDOW:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
210 case GAIM_SUBTYPE_PLUGIN:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
211 /* pointers again */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
212 if (gaim_value_is_outgoing(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
213 vars[i].val = va_arg(args, void **);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
214 Tcl_LinkVar(handler->interp, name->str, vars[i].val, TCL_LINK_INT);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
215 } else {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
216 vars[i].val = va_arg(args, void *);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
217 Tcl_LinkVar(handler->interp, name->str, (char *)&vars[i].val,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
218 TCL_LINK_INT|TCL_LINK_READ_ONLY);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
219 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
220 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
221 case GAIM_SUBTYPE_BLIST:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
222 case GAIM_SUBTYPE_BLIST_BUDDY:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
223 case GAIM_SUBTYPE_BLIST_GROUP:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
224 case GAIM_SUBTYPE_BLIST_CHAT:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
225 /* We're going to switch again for code-deduping */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
226 if (gaim_value_is_outgoing(handler->argtypes[i]))
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
227 node = *va_arg(args, GaimBlistNode **);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
228 else
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
229 node = va_arg(args, GaimBlistNode *);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
230 switch (node->type) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
231 case GAIM_BLIST_GROUP_NODE:
6700
57161e3abbb5 [gaim-migrate @ 7226]
Ethan Blanton <elb@pidgin.im>
parents: 6694
diff changeset
232 g_string_printf(val, "group {%s}", ((GaimGroup *)node)->name);
6694
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
233 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
234 case GAIM_BLIST_BUDDY_NODE:
6700
57161e3abbb5 [gaim-migrate @ 7226]
Ethan Blanton <elb@pidgin.im>
parents: 6694
diff changeset
235 g_string_printf(val, "buddy {%s} %lu", ((GaimBuddy *)node)->name,
57161e3abbb5 [gaim-migrate @ 7226]
Ethan Blanton <elb@pidgin.im>
parents: 6694
diff changeset
236 (unsigned long)((GaimBuddy *)node)->account);
6694
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
237 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
238 case GAIM_BLIST_CHAT_NODE:
6700
57161e3abbb5 [gaim-migrate @ 7226]
Ethan Blanton <elb@pidgin.im>
parents: 6694
diff changeset
239 g_string_printf(val, "chat {%s} %lu", ((GaimBlistChat *)node)->alias,
57161e3abbb5 [gaim-migrate @ 7226]
Ethan Blanton <elb@pidgin.im>
parents: 6694
diff changeset
240 (unsigned long)((GaimBlistChat *)node)->account);
6694
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
241 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
242 case GAIM_BLIST_OTHER_NODE:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
243 g_string_printf(val, "other");
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
244 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
245 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
246 vars[i].str = g_strdup(val->str);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
247 Tcl_LinkVar(handler->interp, name->str, (char *)&vars[i].str,
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
248 TCL_LINK_STRING|TCL_LINK_READ_ONLY);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
249 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
250 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
251 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
252 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
253
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
254 /* Call the friggin' procedure already */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
255 if ((error = Tcl_EvalObjEx(handler->interp, handler->proc, TCL_EVAL_GLOBAL)) != TCL_OK) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
256 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "error evaluating callback: %s\n",
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
257 Tcl_GetString(Tcl_GetObjResult(handler->interp)));
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
258 } else {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
259 result = Tcl_GetObjResult(handler->interp);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
260 /* handle return values -- strings and words only */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
261 if (handler->returntype) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
262 if (gaim_value_get_type(handler->returntype) == GAIM_TYPE_STRING) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
263 retval = (void *)g_strdup(Tcl_GetString(result));
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
264 } else {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
265 if ((error = Tcl_GetIntFromObj(handler->interp, result, (int *)&retval)) != TCL_OK) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
266 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "Error retrieving procedure result: %s\n",
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
267 Tcl_GetString(Tcl_GetObjResult(handler->interp)));
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
268 retval = NULL;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
269 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
270 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
271 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
272 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
273
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
274 /* And finally clean up */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
275 for (i = 0; i < handler->nargs; i++) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
276 g_string_printf(name, "::gaim::_callback::%s", handler->argnames[i]);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
277 Tcl_UnlinkVar(handler->interp, name->str);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
278 /* We basically only have to deal with strings and buddies
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
279 * on the way out */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
280 switch (gaim_value_get_type(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
281 case GAIM_TYPE_STRING:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
282 if (gaim_value_is_outgoing(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
283 if (vars[i].val != NULL && *(char **)vars[i].val != NULL) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
284 g_free(*(char **)vars[i].val);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
285 *(char **)vars[i].val = g_strdup(vars[i].str);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
286 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
287 ckfree(vars[i].str);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
288 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
289 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
290 case GAIM_TYPE_SUBTYPE:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
291 switch(gaim_value_get_subtype(handler->argtypes[i])) {
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
292 case GAIM_SUBTYPE_BLIST:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
293 case GAIM_SUBTYPE_BLIST_BUDDY:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
294 case GAIM_SUBTYPE_BLIST_GROUP:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
295 case GAIM_SUBTYPE_BLIST_CHAT:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
296 g_free(vars[i].str);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
297 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
298 default:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
299 /* nothing */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
300 ;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
301 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
302 break;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
303 default:
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
304 /* nothing */
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
305 ;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
306 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
307 }
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
308
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
309 g_string_free(name, TRUE);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
310 g_string_free(val, FALSE);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
311 g_free(vars);
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
312
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
313 return retval;
2d2f04c5c7d2 [gaim-migrate @ 7220]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
314 }