Mercurial > pidgin
annotate plugins/perl/perl-handlers.c @ 12128:34deaeeb5d42
[gaim-migrate @ 14428]
Clean up the signals changelogging a bit. Mainly, I just removed the duplication of the 'see the Doxygen docs'.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 18 Nov 2005 12:23:36 +0000 |
parents | 0e9e2b923d09 |
children | f8e22fef03fc |
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 |
11170 | 7 |
6520 | 8 static GList *timeout_handlers = NULL; |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
9 static GList *signal_handlers = NULL; |
11123 | 10 static char *perl_plugin_pref_cb; |
11170 | 11 static char *perl_gtk_plugin_pref_cb; |
11123 | 12 extern PerlInterpreter *my_perl; |
6520 | 13 |
11170 | 14 /* For now a plugin can only have one action */ |
15 void gaim_perl_plugin_action_cb(GaimPluginAction * gpa) { | |
16 | |
17 dSP; | |
18 ENTER; | |
19 SAVETMPS; | |
20 PUSHMARK(sp); | |
21 | |
22 /* We put the plugin handle on the stack so it can pass it along */ | |
23 /* to anythng called from the callback. It is supposed to pass */ | |
24 /* the Action, but there is no way to access the plugin handle from */ | |
25 /* the GaimPluginAction in perl...yet. */ | |
26 | |
27 XPUSHs(gaim_perl_bless_object(gpa->plugin, "Gaim::Plugin")); | |
28 PUTBACK; | |
29 | |
30 /* gaim_perl_plugin_action_callback_sub defined in the header is set */ | |
31 /* in perl.c during plugin probe by a PLUGIN_INFO hash value limiting */ | |
32 /* us to only one action for right now even though the action member of */ | |
33 /* GaimPluginInfo can take (does take) a GList. */ | |
34 call_pv(gaim_perl_plugin_action_callback_sub, G_EVAL | G_SCALAR); | |
35 SPAGAIN; | |
36 | |
37 PUTBACK; | |
38 FREETMPS; | |
39 LEAVE; | |
40 } | |
41 | |
42 GList *gaim_perl_plugin_action(GaimPlugin *plugin, gpointer context) { | |
43 GaimPluginAction *act = NULL; | |
44 GList *gl = NULL; | |
45 | |
46 /* TODO: Fix the way we create action handlers so we can have mroe than */ | |
47 /* one action in perl. Maybe there is a clever work around, but so far */ | |
48 /* I have not figured it out. There is no way to tie the perl sub's */ | |
49 /* name to the callback function without these global variables and */ | |
50 /* there is no way to create a callback on the fly so each would have */ | |
51 /* to be hardcoded--more than one would just be arbitrary. */ | |
52 act = gaim_plugin_action_new(gaim_perl_plugin_action_label, gaim_perl_plugin_action_cb); | |
53 gl = g_list_append(gl, act); | |
54 | |
55 return gl; | |
56 } | |
57 | |
58 | |
59 GaimGtkPluginUiInfo *gaim_perl_gtk_plugin_pref(const char * frame_cb) { | |
60 | |
61 GaimGtkPluginUiInfo *ui_info; | |
62 | |
63 ui_info = g_new0(GaimGtkPluginUiInfo, 1); | |
64 perl_gtk_plugin_pref_cb = g_strdup(frame_cb); | |
65 ui_info->get_config_frame = gaim_perl_gtk_get_plugin_frame; | |
66 | |
67 return ui_info; | |
68 } | |
69 | |
70 GtkWidget *gaim_perl_gtk_get_plugin_frame(GaimPlugin *plugin) { | |
71 | |
72 SV * sv; | |
73 GtkWidget *ret; | |
74 MAGIC *mg; | |
75 dSP; | |
76 int count; | |
77 | |
78 ENTER; | |
79 SAVETMPS; | |
80 | |
81 count = call_pv(perl_gtk_plugin_pref_cb, G_SCALAR | G_NOARGS); | |
82 if (count != 1) | |
83 croak("call_pv: Did not return the correct number of values.\n"); | |
84 | |
85 /* the frame was created in a perl sub and is returned */ | |
86 SPAGAIN; | |
87 | |
88 /* We have a Gtk2::Frame on top of the stack */ | |
89 sv = POPs; | |
90 | |
91 /* The magic field hides the pointer to the actuale GtkWidget */ | |
92 mg = mg_find(SvRV(sv), PERL_MAGIC_ext); | |
93 ret = (GtkWidget *)mg->mg_ptr; | |
94 | |
95 PUTBACK; | |
96 FREETMPS; | |
97 LEAVE; | |
98 | |
99 return ret; | |
100 } | |
101 | |
102 | |
103 | |
11123 | 104 |
105 /* Called to create a pointer to GaimPluginUiInfo for the GaimPluginInfo */ | |
106 /* It will then inturn create ui_info with the C function pointer */ | |
107 /* that will eventually do a call_pv to call a perl functions so users */ | |
108 /* can create their own frames in the prefs */ | |
11170 | 109 GaimPluginUiInfo *gaim_perl_plugin_pref(const char * frame_cb) { |
11123 | 110 GaimPluginUiInfo *ui_info; |
111 | |
112 ui_info = g_new0(GaimPluginUiInfo, 1); | |
11170 | 113 perl_plugin_pref_cb = g_strdup(frame_cb); |
11123 | 114 ui_info->get_plugin_pref_frame = gaim_perl_get_plugin_frame; |
115 | |
116 return ui_info; | |
117 } | |
118 | |
119 GaimPluginPrefFrame *gaim_perl_get_plugin_frame(GaimPlugin *plugin) { | |
120 /* Sets up the Perl Stack for our call back into the script to run the */ | |
121 /* plugin_pref... sub */ | |
122 GaimPluginPrefFrame *ret_frame; | |
123 dSP; | |
124 int count; | |
125 | |
126 ENTER; | |
127 SAVETMPS; | |
128 /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and return */ | |
129 /* the frame */ | |
130 PUSHMARK(SP); | |
131 PUTBACK; | |
132 | |
133 count = call_pv(perl_plugin_pref_cb, G_SCALAR | G_NOARGS); | |
134 | |
135 SPAGAIN; | |
136 | |
137 if (count != 1) | |
138 croak("call_pv: Did not return the correct number of values.\n"); | |
139 /* the frame was created in a perl sub and is returned */ | |
140 ret_frame = (GaimPluginPrefFrame *)gaim_perl_ref_object(POPs); | |
141 | |
142 /* Tidy up the Perl stack */ | |
143 PUTBACK; | |
144 FREETMPS; | |
145 LEAVE; | |
11170 | 146 |
11123 | 147 return ret_frame; |
148 } | |
6520 | 149 |
150 static void | |
151 destroy_timeout_handler(GaimPerlTimeoutHandler *handler) | |
152 { | |
153 timeout_handlers = g_list_remove(timeout_handlers, handler); | |
154 | |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
155 if (handler->callback != NULL) |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
156 SvREFCNT_dec(handler->callback); |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
157 |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
158 if (handler->data != NULL) |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
159 SvREFCNT_dec(handler->data); |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
160 |
6520 | 161 g_free(handler); |
162 } | |
163 | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
164 static void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
165 destroy_signal_handler(GaimPerlSignalHandler *handler) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
166 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
167 signal_handlers = g_list_remove(signal_handlers, handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
168 |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
169 if (handler->callback != NULL) |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
170 SvREFCNT_dec(handler->callback); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
171 |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
172 if (handler->data != NULL) |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
173 SvREFCNT_dec(handler->data); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
174 |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
175 g_free(handler->signal); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
176 g_free(handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
177 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
178 |
6520 | 179 static int |
180 perl_timeout_cb(gpointer data) | |
181 { | |
182 GaimPerlTimeoutHandler *handler = (GaimPerlTimeoutHandler *)data; | |
183 | |
184 dSP; | |
185 ENTER; | |
186 SAVETMPS; | |
187 PUSHMARK(sp); | |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
188 XPUSHs((SV *)handler->data); |
6520 | 189 PUTBACK; |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
190 call_sv(handler->callback, G_EVAL | G_SCALAR); |
6520 | 191 SPAGAIN; |
192 | |
193 PUTBACK; | |
194 FREETMPS; | |
195 LEAVE; | |
196 | |
197 destroy_timeout_handler(handler); | |
198 | |
199 return 0; | |
200 } | |
201 | |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
202 typedef void *DATATYPE; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
203 |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
204 static void * |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
205 perl_signal_cb(va_list args, void *data) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
206 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
207 GaimPerlSignalHandler *handler = (GaimPerlSignalHandler *)data; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
208 void *ret_val = NULL; |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
209 int i; |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
210 int count; |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
211 int value_count; |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
212 GaimValue *ret_value, **values; |
6919
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
213 SV **sv_args; |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
214 DATATYPE **copy_args; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
215 STRLEN na; |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
216 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
217 dSP; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
218 ENTER; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
219 SAVETMPS; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
220 PUSHMARK(sp); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
221 |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
222 gaim_signal_get_values(handler->instance, handler->signal, |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
223 &ret_value, &value_count, &values); |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
224 |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
225 sv_args = g_new(SV *, value_count); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
226 copy_args = g_new(void **, value_count); |
6919
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
227 |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
228 for (i = 0; i < value_count; i++) |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
229 { |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
230 sv_args[i] = sv_2mortal(gaim_perl_sv_from_vargs(values[i], |
7386 | 231 (va_list*)&args, ©_args[i])); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
232 |
6920
13f78c350cd3
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
233 XPUSHs(sv_args[i]); |
6566
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
234 } |
f6c2a7b5afa7
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
235 |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
236 XPUSHs((SV *)handler->data); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
237 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
238 PUTBACK; |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
239 |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
240 if (ret_value != NULL) |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
241 { |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
242 count = call_sv(handler->callback, G_EVAL | G_SCALAR); |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
243 |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
244 SPAGAIN; |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
245 |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
246 if (count != 1) |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
247 croak("Uh oh! call_sv returned %i != 1", i); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
248 else |
6920
13f78c350cd3
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
249 ret_val = gaim_perl_data_from_sv(ret_value, POPs); |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
250 } |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
251 else |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
252 { |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
253 call_sv(handler->callback, G_SCALAR); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
254 |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
255 SPAGAIN; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
256 } |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
257 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
258 if (SvTRUE(ERRSV)) |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
259 { |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
260 gaim_debug_error("perl", "Perl function exited abnormally: %s\n", |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
261 SvPV(ERRSV, na)); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
262 } |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
263 |
6919
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
264 /* See if any parameters changed. */ |
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
265 for (i = 0; i < value_count; i++) |
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
266 { |
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
267 if (gaim_value_is_outgoing(values[i])) |
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
268 { |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
269 switch (gaim_value_get_type(values[i])) |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
270 { |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
271 case GAIM_TYPE_BOOLEAN: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
272 *((gboolean *)copy_args[i]) = SvIV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
273 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
274 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
275 case GAIM_TYPE_INT: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
276 *((int *)copy_args[i]) = SvIV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
277 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
278 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
279 case GAIM_TYPE_UINT: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
280 *((unsigned int *)copy_args[i]) = SvUV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
281 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
282 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
283 case GAIM_TYPE_LONG: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
284 *((long *)copy_args[i]) = SvIV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
285 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
286 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
287 case GAIM_TYPE_ULONG: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
288 *((unsigned long *)copy_args[i]) = SvUV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
289 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
290 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
291 case GAIM_TYPE_INT64: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
292 *((gint64 *)copy_args[i]) = SvIV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
293 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
294 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
295 case GAIM_TYPE_UINT64: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
296 *((guint64 *)copy_args[i]) = SvUV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
297 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
298 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
299 case GAIM_TYPE_STRING: |
6925
3ec6aac0ff67
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
300 if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) |
3ec6aac0ff67
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
301 { |
3ec6aac0ff67
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
302 g_free(*((char **)copy_args[i])); |
3ec6aac0ff67
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
303 *((char **)copy_args[i]) = |
3ec6aac0ff67
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
304 g_strdup(SvPV(sv_args[i], na)); |
3ec6aac0ff67
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
305 } |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
306 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
307 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
308 case GAIM_TYPE_POINTER: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
309 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
310 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
311 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
312 case GAIM_TYPE_BOXED: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
313 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]); |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
314 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
315 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
316 default: |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
317 break; |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
318 } |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
319 |
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
320 #if 0 |
6920
13f78c350cd3
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
321 *((void **)copy_args[i]) = gaim_perl_data_from_sv(values[i], |
13f78c350cd3
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
322 sv_args[i]); |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
323 #endif |
6919
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
324 } |
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
325 } |
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
326 |
6921
11d05ddf30a3
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
327 PUTBACK; |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
328 FREETMPS; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
329 LEAVE; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
330 |
6919
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
331 g_free(sv_args); |
6920
13f78c350cd3
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
332 g_free(copy_args); |
6919
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
333 |
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
334 gaim_debug_misc("perl", "ret_val = %p\n", ret_val); |
1aa771990188
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
335 |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
336 return ret_val; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
337 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
338 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
339 static GaimPerlSignalHandler * |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
340 find_signal_handler(GaimPlugin *plugin, void *instance, const char *signal) |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
341 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
342 GaimPerlSignalHandler *handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
343 GList *l; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
344 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
345 for (l = signal_handlers; l != NULL; l = l->next) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
346 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
347 handler = (GaimPerlSignalHandler *)l->data; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
348 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
349 if (handler->plugin == plugin && |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
350 handler->instance == instance && |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
351 !strcmp(handler->signal, signal)) |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
352 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
353 return handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
354 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
355 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
356 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
357 return NULL; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
358 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
359 |
6520 | 360 void |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
361 gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, SV *callback, SV *data) |
6520 | 362 { |
363 GaimPerlTimeoutHandler *handler; | |
364 | |
365 if (plugin == NULL) | |
366 { | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
367 croak("Invalid handle in adding perl timeout handler.\n"); |
6520 | 368 return; |
369 } | |
370 | |
371 handler = g_new0(GaimPerlTimeoutHandler, 1); | |
372 | |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
373 handler->plugin = plugin; |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
374 handler->callback = (callback != NULL && callback != &PL_sv_undef |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
375 ? newSVsv(callback) : NULL); |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
376 handler->data = (data != NULL && data != &PL_sv_undef |
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
377 ? newSVsv(data) : NULL); |
6520 | 378 |
379 timeout_handlers = g_list_append(timeout_handlers, handler); | |
6568
33486b749aa9
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
380 |
6520 | 381 handler->iotag = g_timeout_add(seconds * 1000, perl_timeout_cb, handler); |
382 } | |
383 | |
384 void | |
385 gaim_perl_timeout_clear_for_plugin(GaimPlugin *plugin) | |
386 { | |
387 GaimPerlTimeoutHandler *handler; | |
388 GList *l, *l_next; | |
389 | |
390 for (l = timeout_handlers; l != NULL; l = l_next) | |
391 { | |
392 l_next = l->next; | |
393 | |
394 handler = (GaimPerlTimeoutHandler *)l->data; | |
395 | |
396 if (handler->plugin == plugin) | |
397 destroy_timeout_handler(handler); | |
398 } | |
399 } | |
400 | |
401 void | |
402 gaim_perl_timeout_clear(void) | |
403 { | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
404 while (timeout_handlers != NULL) |
6520 | 405 destroy_timeout_handler(timeout_handlers->data); |
406 } | |
407 | |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
408 void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
409 gaim_perl_signal_connect(GaimPlugin *plugin, void *instance, |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
410 const char *signal, SV *callback, SV *data) |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
411 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
412 GaimPerlSignalHandler *handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
413 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
414 handler = g_new0(GaimPerlSignalHandler, 1); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
415 handler->plugin = plugin; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
416 handler->instance = instance; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
417 handler->signal = g_strdup(signal); |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
418 handler->callback = (callback != NULL && callback != &PL_sv_undef |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
419 ? newSVsv(callback) : NULL); |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
420 handler->data = (data != NULL && data != &PL_sv_undef |
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
421 ? newSVsv(data) : NULL); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
422 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
423 signal_handlers = g_list_append(signal_handlers, handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
424 |
6554
28b38803d0bb
[gaim-migrate @ 7076]
Christian Hammond <chipx86@chipx86.com>
parents:
6549
diff
changeset
|
425 gaim_signal_connect_vargs(instance, signal, |
28b38803d0bb
[gaim-migrate @ 7076]
Christian Hammond <chipx86@chipx86.com>
parents:
6549
diff
changeset
|
426 plugin, GAIM_CALLBACK(perl_signal_cb), handler); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
427 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
428 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
429 void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
430 gaim_perl_signal_disconnect(GaimPlugin *plugin, void *instance, |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
431 const char *signal) |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
432 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
433 GaimPerlSignalHandler *handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
434 |
6567
6e25e1e08ffb
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
435 handler = find_signal_handler(plugin, instance, signal); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
436 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
437 if (handler == NULL) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
438 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
439 croak("Invalid signal handler information in " |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
440 "disconnecting a perl signal handler.\n"); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
441 return; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
442 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
443 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
444 destroy_signal_handler(handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
445 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
446 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
447 void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
448 gaim_perl_signal_clear_for_plugin(GaimPlugin *plugin) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
449 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
450 GaimPerlSignalHandler *handler; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
451 GList *l, *l_next; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
452 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
453 for (l = signal_handlers; l != NULL; l = l_next) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
454 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
455 l_next = l->next; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
456 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
457 handler = (GaimPerlSignalHandler *)l->data; |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
458 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
459 if (handler->plugin == plugin) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
460 destroy_signal_handler(handler); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
461 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
462 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
463 |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
464 void |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
465 gaim_perl_signal_clear(void) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
466 { |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
467 while (signal_handlers != NULL) |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
468 destroy_signal_handler(signal_handlers->data); |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
469 } |
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
470 |