Mercurial > pidgin.yaz
annotate plugins/perl/perl-handlers.c @ 6877:1b5b0cea6915
[gaim-migrate @ 7423]
Fixed an assertion warning for buddy icons on every conversation without a
buddy icon.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 17 Sep 2003 06:46:36 +0000 |
parents | 33486b749aa9 |
children | 1aa771990188 |
rev | line source |
---|---|
6520 | 1 #include "perl-common.h" |
2 #include "perl-handlers.h" | |
3 | |
4 #include "debug.h" | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
5 #include "signals.h" |
6520 | 6 |
7 static GList *timeout_handlers = NULL; | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
8 static GList *signal_handlers = NULL; |
6520 | 9 |
10 extern PerlInterpreter *my_perl; | |
11 | |
12 static void | |
13 destroy_timeout_handler(GaimPerlTimeoutHandler *handler) | |
14 { | |
15 timeout_handlers = g_list_remove(timeout_handlers, handler); | |
16 | |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
17 if (handler->callback != NULL) |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
18 SvREFCNT_dec(handler->callback); |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
19 |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
20 if (handler->data != NULL) |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
21 SvREFCNT_dec(handler->data); |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
22 |
6520 | 23 g_free(handler); |
24 } | |
25 | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
26 static void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
27 destroy_signal_handler(GaimPerlSignalHandler *handler) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
28 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
29 signal_handlers = g_list_remove(signal_handlers, handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
30 |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
31 if (handler->callback != NULL) |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
32 SvREFCNT_dec(handler->callback); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
33 |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
34 if (handler->data != NULL) |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
35 SvREFCNT_dec(handler->data); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
36 |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
37 g_free(handler->signal); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
38 g_free(handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
39 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
40 |
6520 | 41 static int |
42 perl_timeout_cb(gpointer data) | |
43 { | |
44 GaimPerlTimeoutHandler *handler = (GaimPerlTimeoutHandler *)data; | |
45 | |
46 dSP; | |
47 ENTER; | |
48 SAVETMPS; | |
49 PUSHMARK(sp); | |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
50 XPUSHs((SV *)handler->data); |
6520 | 51 PUTBACK; |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
52 call_sv(handler->callback, G_EVAL | G_SCALAR); |
6520 | 53 SPAGAIN; |
54 | |
55 PUTBACK; | |
56 FREETMPS; | |
57 LEAVE; | |
58 | |
59 destroy_timeout_handler(handler); | |
60 | |
61 return 0; | |
62 } | |
63 | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
64 static void * |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
65 perl_signal_cb(va_list args, void *data) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
66 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
67 GaimPerlSignalHandler *handler = (GaimPerlSignalHandler *)data; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
68 void *ret_val = NULL; |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
69 int i; |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
70 int count; |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
71 int value_count; |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
72 GaimValue *ret_value, **values; |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
73 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
74 dSP; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
75 ENTER; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
76 SAVETMPS; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
77 PUSHMARK(sp); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
78 |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
79 gaim_signal_get_values(handler->instance, handler->signal, |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
80 &ret_value, &value_count, &values); |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
81 |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
82 for (i = 0; i < value_count; i++) |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
83 { |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
84 SV *sv = gaim_perl_sv_from_vargs(values[i], args); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
85 |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
86 gaim_debug(GAIM_DEBUG_INFO, "perl", "Pushing arg %p\n", sv); |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
87 |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
88 XPUSHs(sv); |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
89 } |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
90 |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
91 gaim_debug(GAIM_DEBUG_INFO, "perl", "Pushing data %p\n", handler->data); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
92 XPUSHs((SV *)handler->data); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
93 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
94 PUTBACK; |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
95 |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
96 if (ret_value != NULL) |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
97 { |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
98 count = call_sv(handler->callback, G_SCALAR); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
99 |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
100 SPAGAIN; |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
101 |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
102 if (count != 1) |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
103 croak("Uh oh! call_sv returned %i != 1", i); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
104 else |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
105 ret_val = POPs; |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
106 } |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
107 else |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
108 call_sv(handler->callback, G_SCALAR); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
109 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
110 FREETMPS; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
111 LEAVE; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
112 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
113 return ret_val; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
114 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
115 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
116 static GaimPerlSignalHandler * |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
117 find_signal_handler(GaimPlugin *plugin, void *instance, const char *signal) |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
118 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
119 GaimPerlSignalHandler *handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
120 GList *l; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
121 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
122 for (l = signal_handlers; l != NULL; l = l->next) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
123 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
124 handler = (GaimPerlSignalHandler *)l->data; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
125 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
126 if (handler->plugin == plugin && |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
127 handler->instance == instance && |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
128 !strcmp(handler->signal, signal)) |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
129 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
130 return handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
131 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
132 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
133 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
134 return NULL; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
135 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
136 |
6520 | 137 void |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
138 gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, SV *callback, SV *data) |
6520 | 139 { |
140 GaimPerlTimeoutHandler *handler; | |
141 | |
142 if (plugin == NULL) | |
143 { | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
144 croak("Invalid handle in adding perl timeout handler.\n"); |
6520 | 145 return; |
146 } | |
147 | |
148 handler = g_new0(GaimPerlTimeoutHandler, 1); | |
149 | |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
150 handler->plugin = plugin; |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
151 handler->callback = (callback != NULL && callback != &PL_sv_undef |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
152 ? newSVsv(callback) : NULL); |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
153 handler->data = (data != NULL && data != &PL_sv_undef |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
154 ? newSVsv(data) : NULL); |
6520 | 155 |
156 timeout_handlers = g_list_append(timeout_handlers, handler); | |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
157 |
6520 | 158 handler->iotag = g_timeout_add(seconds * 1000, perl_timeout_cb, handler); |
159 } | |
160 | |
161 void | |
162 gaim_perl_timeout_clear_for_plugin(GaimPlugin *plugin) | |
163 { | |
164 GaimPerlTimeoutHandler *handler; | |
165 GList *l, *l_next; | |
166 | |
167 for (l = timeout_handlers; l != NULL; l = l_next) | |
168 { | |
169 l_next = l->next; | |
170 | |
171 handler = (GaimPerlTimeoutHandler *)l->data; | |
172 | |
173 if (handler->plugin == plugin) | |
174 destroy_timeout_handler(handler); | |
175 } | |
176 } | |
177 | |
178 void | |
179 gaim_perl_timeout_clear(void) | |
180 { | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
181 while (timeout_handlers != NULL) |
6520 | 182 destroy_timeout_handler(timeout_handlers->data); |
183 } | |
184 | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
185 void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
186 gaim_perl_signal_connect(GaimPlugin *plugin, void *instance, |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
187 const char *signal, SV *callback, SV *data) |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
188 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
189 GaimPerlSignalHandler *handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
190 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
191 handler = g_new0(GaimPerlSignalHandler, 1); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
192 handler->plugin = plugin; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
193 handler->instance = instance; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
194 handler->signal = g_strdup(signal); |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
195 handler->callback = (callback != NULL && callback != &PL_sv_undef |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
196 ? newSVsv(callback) : NULL); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
197 handler->data = (data != NULL && data != &PL_sv_undef |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
198 ? newSVsv(data) : NULL); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
199 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
200 signal_handlers = g_list_append(signal_handlers, handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
201 |
6554
28b38803d0bb
[gaim-migrate @ 7076]
Christian Hammond <chipx86@chipx86.com>
parents:
6549
diff
changeset
|
202 gaim_signal_connect_vargs(instance, signal, |
28b38803d0bb
[gaim-migrate @ 7076]
Christian Hammond <chipx86@chipx86.com>
parents:
6549
diff
changeset
|
203 plugin, GAIM_CALLBACK(perl_signal_cb), handler); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
204 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
205 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
206 void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
207 gaim_perl_signal_disconnect(GaimPlugin *plugin, void *instance, |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
208 const char *signal) |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
209 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
210 GaimPerlSignalHandler *handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
211 |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
212 handler = find_signal_handler(plugin, instance, signal); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
213 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
214 if (handler == NULL) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
215 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
216 croak("Invalid signal handler information in " |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
217 "disconnecting a perl signal handler.\n"); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
218 return; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
219 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
220 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
221 destroy_signal_handler(handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
222 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
223 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
224 void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
225 gaim_perl_signal_clear_for_plugin(GaimPlugin *plugin) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
226 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
227 GaimPerlSignalHandler *handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
228 GList *l, *l_next; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
229 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
230 for (l = signal_handlers; l != NULL; l = l_next) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
231 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
232 l_next = l->next; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
233 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
234 handler = (GaimPerlSignalHandler *)l->data; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
235 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
236 if (handler->plugin == plugin) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
237 destroy_signal_handler(handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
238 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
239 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
240 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
241 void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
242 gaim_perl_signal_clear(void) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
243 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
244 while (signal_handlers != NULL) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
245 destroy_signal_handler(signal_handlers->data); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
246 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
247 |