comparison plugins/perl/perl-handlers.c @ 11123:4315bb5f427b

[gaim-migrate @ 13179] Time to make perl start working again committer: Tailor Script <tailor@pidgin.im>
author John H. Kelm <johnkelm@gmail.com>
date Mon, 18 Jul 2005 16:27:53 +0000
parents 414c701ef1ff
children 0e9e2b923d09
comparison
equal deleted inserted replaced
11122:59a4bc5c24e5 11123:4315bb5f427b
4 #include "debug.h" 4 #include "debug.h"
5 #include "signals.h" 5 #include "signals.h"
6 6
7 static GList *timeout_handlers = NULL; 7 static GList *timeout_handlers = NULL;
8 static GList *signal_handlers = NULL; 8 static GList *signal_handlers = NULL;
9 9 static char *perl_plugin_pref_cb;
10 extern PerlInterpreter *my_perl; 10 extern PerlInterpreter *my_perl;
11
12
13 /* Called to create a pointer to GaimPluginUiInfo for the GaimPluginInfo */
14 /* It will then inturn create ui_info with the C function pointer */
15 /* that will eventually do a call_pv to call a perl functions so users */
16 /* can create their own frames in the prefs */
17 GaimPluginUiInfo *gaim_perl_plugin_pref(char * frame_cb) {
18 GaimPluginUiInfo *ui_info;
19
20 ui_info = g_new0(GaimPluginUiInfo, 1);
21
22 perl_plugin_pref_cb = frame_cb;
23
24 ui_info->get_plugin_pref_frame = gaim_perl_get_plugin_frame;
25
26 return ui_info;
27 }
28
29 GaimPluginPrefFrame *gaim_perl_get_plugin_frame(GaimPlugin *plugin) {
30 /* Sets up the Perl Stack for our call back into the script to run the */
31 /* plugin_pref... sub */
32 GaimPluginPrefFrame *ret_frame;
33 dSP;
34 int count;
35
36 ENTER;
37 SAVETMPS;
38 /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and return */
39 /* the frame */
40 PUSHMARK(SP);
41 PUTBACK;
42
43 count = call_pv(perl_plugin_pref_cb, G_SCALAR | G_NOARGS);
44
45 SPAGAIN;
46
47 if (count != 1)
48 croak("call_pv: Did not return the correct number of values.\n");
49 /* the frame was created in a perl sub and is returned */
50 ret_frame = (GaimPluginPrefFrame *)gaim_perl_ref_object(POPs);
51
52 /* Tidy up the Perl stack */
53 PUTBACK;
54 FREETMPS;
55 LEAVE;
56
57 return ret_frame;
58 }
11 59
12 static void 60 static void
13 destroy_timeout_handler(GaimPerlTimeoutHandler *handler) 61 destroy_timeout_handler(GaimPerlTimeoutHandler *handler)
14 { 62 {
15 timeout_handlers = g_list_remove(timeout_handlers, handler); 63 timeout_handlers = g_list_remove(timeout_handlers, handler);