Mercurial > pidgin
annotate libpurple/plugins/perl/perl-handlers.c @ 29018:6288bbd53f44
Pass around a va_list instead of a pointer to a va_list. Refs #7404
This gets rid of a compile warning for me on x86_64. I don't have
an i386 box to test on, but every bit of evidence I can find tells me
that it's totally fine to pass around a va_list. We do it in status.c
If this breaks compilation for you or you get a warning from perl-handlers.c
then pleaes let me know! Or just disapprove this
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 10 Feb 2010 09:04:15 +0000 |
parents | f0d103b366df |
children | 1e4781fb144b |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 #include "perl-common.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 #include "perl-handlers.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 #include "signals.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 extern PerlInterpreter *my_perl; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
8 static GSList *cmd_handlers = NULL; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
9 static GSList *signal_handlers = NULL; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
10 static GSList *timeout_handlers = NULL; |
23618
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
11 static GSList *pref_handlers = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 /* perl < 5.8.0 doesn't define PERL_MAGIC_ext */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 #ifndef PERL_MAGIC_ext |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 #define PERL_MAGIC_ext '~' |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 void |
15822 | 19 purple_perl_plugin_action_cb(PurplePluginAction *action) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 SV **callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 HV *hv = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 gchar *hvname; |
15822 | 24 PurplePlugin *plugin; |
25 PurplePerlScript *gps; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 dSP; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 plugin = action->plugin; |
15822 | 29 gps = (PurplePerlScript *)plugin->info->extra_info; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 hvname = g_strdup_printf("%s::plugin_actions", gps->package); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 hv = get_hv(hvname, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 g_free(hvname); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 if (hv == NULL) |
15822 | 35 croak("No plugin_actions hash found in \"%s\" plugin.", purple_plugin_get_name(plugin)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 callback = hv_fetch(hv, action->label, strlen(action->label), 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 if (callback == NULL || *callback == NULL) |
15822 | 43 croak("No plugin_action function named \"%s\" in \"%s\" plugin.", action->label, purple_plugin_get_name(plugin)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 PUSHMARK(sp); |
15822 | 46 XPUSHs(purple_perl_bless_object(gps->plugin, "Purple::Plugin")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
49 call_sv(*callback, G_EVAL | G_VOID | G_DISCARD); |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
50 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
53 if (SvTRUE(ERRSV)) { |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
54 purple_debug_error("perl", |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
55 "Perl plugin action function exited abnormally: %s\n", |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
56 SvPVutf8_nolen(ERRSV)); |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
57 } |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
58 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 GList * |
15822 | 65 purple_perl_plugin_actions(PurplePlugin *plugin, gpointer context) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 GList *l = NULL; |
15822 | 68 PurplePerlScript *gps; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 int i = 0, count = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 dSP; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
72 gps = plugin->info->extra_info; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 PUSHMARK(SP); |
15822 | 78 XPUSHs(sv_2mortal(purple_perl_bless_object(plugin, "Purple::Plugin"))); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 /* XXX This *will* cease working correctly if context gets changed to |
15822 | 80 * ever be able to hold anything other than a PurpleConnection */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 if (context != NULL) |
15822 | 82 XPUSHs(sv_2mortal(purple_perl_bless_object(context, |
83 "Purple::Connection"))); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 XPUSHs(&PL_sv_undef); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
88 count = call_pv(gps->plugin_action_sub, G_EVAL | G_ARRAY); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
92 if (SvTRUE(ERRSV)) { |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
93 purple_debug_error("perl", |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
94 "Perl plugin actions lookup exited abnormally: %s\n", |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
95 SvPVutf8_nolen(ERRSV)); |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
96 } |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
97 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 if (count == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 croak("The plugin_actions sub didn't return anything.\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 for (i = 0; i < count; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 SV *sv; |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
103 PurplePluginAction *act; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 sv = POPs; |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
106 act = purple_plugin_action_new(SvPVutf8_nolen(sv), purple_perl_plugin_action_cb); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 l = g_list_prepend(l, act); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 return l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 |
15822 | 117 #ifdef PURPLE_GTKPERL |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 GtkWidget * |
15822 | 119 purple_perl_gtk_get_plugin_frame(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 SV * sv; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 int count; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 MAGIC *mg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 GtkWidget *ret; |
15822 | 125 PurplePerlScript *gps; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 dSP; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
128 gps = plugin->info->extra_info; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
133 count = call_pv(gps->gtk_prefs_sub, G_EVAL | G_SCALAR | G_NOARGS); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 if (count != 1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 croak("call_pv: Did not return the correct number of values.\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 /* the frame was created in a perl sub and is returned */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
140 if (SvTRUE(ERRSV)) { |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
141 purple_debug_error("perl", |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
142 "Perl gtk plugin frame init exited abnormally: %s\n", |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
143 SvPVutf8_nolen(ERRSV)); |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
144 } |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
145 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 /* We have a Gtk2::Frame on top of the stack */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 sv = POPs; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 /* The magic field hides the pointer to the actual GtkWidget */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 mg = mg_find(SvRV(sv), PERL_MAGIC_ext); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 ret = (GtkWidget *)mg->mg_ptr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 |
15822 | 161 PurplePluginPrefFrame * |
162 purple_perl_get_plugin_frame(PurplePlugin *plugin) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 /* Sets up the Perl Stack for our call back into the script to run the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 * plugin_pref... sub */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 int count; |
15822 | 167 PurplePerlScript *gps; |
168 PurplePluginPrefFrame *ret_frame; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 dSP; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 |
15822 | 171 gps = (PurplePerlScript *)plugin->info->extra_info; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 * return the frame */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 PUSHMARK(SP); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
180 count = call_pv(gps->prefs_sub, G_EVAL | G_SCALAR | G_NOARGS); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
184 if (SvTRUE(ERRSV)) { |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
185 purple_debug_error("perl", |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
186 "Perl plugin prefs frame init exited abnormally: %s\n", |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
187 SvPVutf8_nolen(ERRSV)); |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
188 } |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
189 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 if (count != 1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 croak("call_pv: Did not return the correct number of values.\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 /* the frame was created in a perl sub and is returned */ |
15822 | 193 ret_frame = (PurplePluginPrefFrame *)purple_perl_ref_object(POPs); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 /* Tidy up the Perl stack */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 return ret_frame; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
203 static gboolean |
15822 | 204 destroy_timeout_handler(PurplePerlTimeoutHandler *handler) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 { |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
206 gboolean ret = FALSE; |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
207 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
208 timeout_handlers = g_slist_remove(timeout_handlers, handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 |
16080
ed2e53708b16
Fix Bug #125 (Perl plugins using timeouts not having timeouts unregistered when plugin unloaded)
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15822
diff
changeset
|
210 if (handler->iotag > 0) |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
211 ret = purple_timeout_remove(handler->iotag); |
16080
ed2e53708b16
Fix Bug #125 (Perl plugins using timeouts not having timeouts unregistered when plugin unloaded)
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15822
diff
changeset
|
212 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 if (handler->callback != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 SvREFCNT_dec(handler->callback); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 if (handler->data != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 SvREFCNT_dec(handler->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 g_free(handler); |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
220 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
221 return ret; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 static void |
15822 | 225 destroy_signal_handler(PurplePerlSignalHandler *handler) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
227 signal_handlers = g_slist_remove(signal_handlers, handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 if (handler->callback != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 SvREFCNT_dec(handler->callback); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 if (handler->data != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 SvREFCNT_dec(handler->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 g_free(handler->signal); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 g_free(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 |
16080
ed2e53708b16
Fix Bug #125 (Perl plugins using timeouts not having timeouts unregistered when plugin unloaded)
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15822
diff
changeset
|
239 static gboolean |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 perl_timeout_cb(gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
242 PurplePerlTimeoutHandler *handler = data; |
18092
662564beb575
Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17478
diff
changeset
|
243 gboolean ret = FALSE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 dSP; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 PUSHMARK(sp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 XPUSHs((SV *)handler->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 call_sv(handler->callback, G_EVAL | G_SCALAR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
254 if (SvTRUE(ERRSV)) { |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
255 purple_debug_error("perl", |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
256 "Perl timeout function exited abnormally: %s\n", |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
257 SvPVutf8_nolen(ERRSV)); |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
258 } |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
259 |
18092
662564beb575
Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17478
diff
changeset
|
260 ret = POPi; |
662564beb575
Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17478
diff
changeset
|
261 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 |
18092
662564beb575
Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17478
diff
changeset
|
266 if (ret == FALSE) |
662564beb575
Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17478
diff
changeset
|
267 destroy_timeout_handler(handler); |
16080
ed2e53708b16
Fix Bug #125 (Perl plugins using timeouts not having timeouts unregistered when plugin unloaded)
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15822
diff
changeset
|
268 |
18092
662564beb575
Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17478
diff
changeset
|
269 return ret; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 typedef void *DATATYPE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 static void * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 perl_signal_cb(va_list args, void *data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
277 PurplePerlSignalHandler *handler = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 void *ret_val = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 int count; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 int value_count; |
15822 | 282 PurpleValue *ret_value, **values; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 SV **sv_args; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 DATATYPE **copy_args; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 dSP; |
26880
22b87a82755b
Fix a couple of crashes in the perl plugin loader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25263
diff
changeset
|
287 PERL_SET_CONTEXT(my_perl); |
22b87a82755b
Fix a couple of crashes in the perl plugin loader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25263
diff
changeset
|
288 SPAGAIN; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 PUSHMARK(sp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 |
15822 | 293 purple_signal_get_values(handler->instance, handler->signal, |
25263
b9f7a8ca1369
Apparently our use of va_list arguments in the perl signal callbacks doesn't
Etan Reisner <pidgin@unreliablesource.net>
parents:
23653
diff
changeset
|
294 &ret_value, &value_count, &values); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 sv_args = g_new(SV *, value_count); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 copy_args = g_new(void **, value_count); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 for (i = 0; i < value_count; i++) { |
15822 | 300 sv_args[i] = purple_perl_sv_from_vargs(values[i], |
25263
b9f7a8ca1369
Apparently our use of va_list arguments in the perl signal callbacks doesn't
Etan Reisner <pidgin@unreliablesource.net>
parents:
23653
diff
changeset
|
301 args, |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
302 ©_args[i]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 XPUSHs(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 XPUSHs((SV *)handler->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 if (ret_value != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 count = call_sv(handler->callback, G_EVAL | G_SCALAR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 if (count != 1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 croak("Uh oh! call_sv returned %i != 1", i); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 else |
15822 | 319 ret_val = purple_perl_data_from_sv(ret_value, POPs); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 } else { |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
321 call_sv(handler->callback, G_EVAL | G_SCALAR); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 if (SvTRUE(ERRSV)) { |
15822 | 327 purple_debug_error("perl", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 "Perl function exited abnormally: %s\n", |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
329 SvPVutf8_nolen(ERRSV)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 /* See if any parameters changed. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 for (i = 0; i < value_count; i++) { |
15822 | 334 if (purple_value_is_outgoing(values[i])) { |
335 switch (purple_value_get_type(values[i])) { | |
336 case PURPLE_TYPE_BOOLEAN: | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 *((gboolean *)copy_args[i]) = SvIV(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 |
15822 | 340 case PURPLE_TYPE_INT: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 *((int *)copy_args[i]) = SvIV(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 |
15822 | 344 case PURPLE_TYPE_UINT: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 *((unsigned int *)copy_args[i]) = SvUV(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 |
15822 | 348 case PURPLE_TYPE_LONG: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 *((long *)copy_args[i]) = SvIV(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 |
15822 | 352 case PURPLE_TYPE_ULONG: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 *((unsigned long *)copy_args[i]) = SvUV(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 |
15822 | 356 case PURPLE_TYPE_INT64: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 *((gint64 *)copy_args[i]) = SvIV(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 |
15822 | 360 case PURPLE_TYPE_UINT64: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 *((guint64 *)copy_args[i]) = SvUV(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 |
15822 | 364 case PURPLE_TYPE_STRING: |
26880
22b87a82755b
Fix a couple of crashes in the perl plugin loader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25263
diff
changeset
|
365 if (!*((char **)copy_args[i]) || !SvPVX(sv_args[i]) || |
22b87a82755b
Fix a couple of crashes in the perl plugin loader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25263
diff
changeset
|
366 strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 g_free(*((char **)copy_args[i])); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 *((char **)copy_args[i]) = |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
369 g_strdup(SvPVutf8_nolen(sv_args[i])); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 } |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
371 /* Clean up sv_args[i] - we're done with it */ |
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
372 sv_2mortal(sv_args[i]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 |
15822 | 375 case PURPLE_TYPE_POINTER: |
376 case PURPLE_TYPE_BOXED: | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 break; |
23040
1367fb4d56f1
applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22702
diff
changeset
|
379 case PURPLE_TYPE_SUBTYPE: |
1367fb4d56f1
applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22702
diff
changeset
|
380 *((void **)copy_args[i]) = purple_perl_ref_object(sv_args[i]); |
1367fb4d56f1
applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22702
diff
changeset
|
381 break; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
387 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 #if 0 |
15822 | 389 *((void **)copy_args[i]) = purple_perl_data_from_sv(values[i], |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 g_free(sv_args); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 g_free(copy_args); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 |
15822 | 402 purple_debug_misc("perl", "ret_val = %p\n", ret_val); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 return ret_val; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 |
15822 | 407 static PurplePerlSignalHandler * |
408 find_signal_handler(PurplePlugin *plugin, void *instance, const char *signal) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 { |
15822 | 410 PurplePerlSignalHandler *handler; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
411 GSList *l; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 for (l = signal_handlers; l != NULL; l = l->next) { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
414 handler = l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 if (handler->plugin == plugin && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 handler->instance == instance && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 !strcmp(handler->signal, signal)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 return handler; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
426 guint |
15822 | 427 purple_perl_timeout_add(PurplePlugin *plugin, int seconds, SV *callback, SV *data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 { |
15822 | 429 PurplePerlTimeoutHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 if (plugin == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 croak("Invalid handle in adding perl timeout handler.\n"); |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
433 return 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 |
15822 | 436 handler = g_new0(PurplePerlTimeoutHandler, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 handler->plugin = plugin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 handler->callback = (callback != NULL && callback != &PL_sv_undef |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 ? newSVsv(callback) : NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 handler->data = (data != NULL && data != &PL_sv_undef |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 ? newSVsv(data) : NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
443 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
444 timeout_handlers = g_slist_append(timeout_handlers, handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
446 handler->iotag = purple_timeout_add_seconds(seconds, perl_timeout_cb, handler); |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
447 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
448 return handler->iotag; |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
449 } |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
450 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
451 gboolean |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
452 purple_perl_timeout_remove(guint handle) |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
453 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
454 PurplePerlTimeoutHandler *handler; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
455 GSList *l, *l_next; |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
456 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
457 for (l = timeout_handlers; l != NULL; l = l_next) { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
458 handler = l->data; |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
459 l_next = l->next; |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
460 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
461 if (handler->iotag == handle) |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
462 return destroy_timeout_handler(handler); |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
463 } |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
464 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
465 purple_debug_info("perl", "No timeout handler found with handle %u.\n", |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
466 handle); |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
467 return FALSE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 void |
15822 | 471 purple_perl_timeout_clear_for_plugin(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
473 PurplePerlTimeoutHandler *handler; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
474 GSList *l, *l_next; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 for (l = timeout_handlers; l != NULL; l = l_next) { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
477 handler = l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 l_next = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 if (handler->plugin == plugin) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 destroy_timeout_handler(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 void |
15822 | 486 purple_perl_timeout_clear(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 while (timeout_handlers != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 destroy_timeout_handler(timeout_handlers->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 void |
15822 | 493 purple_perl_signal_connect(PurplePlugin *plugin, void *instance, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 const char *signal, SV *callback, SV *data, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 int priority) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 { |
15822 | 497 PurplePerlSignalHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 |
15822 | 499 handler = g_new0(PurplePerlSignalHandler, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 handler->plugin = plugin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 handler->instance = instance; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 handler->signal = g_strdup(signal); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 handler->callback = (callback != NULL && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 callback != &PL_sv_undef ? newSVsv(callback) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 : NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 handler->data = (data != NULL && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 data != &PL_sv_undef ? newSVsv(data) : NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
509 signal_handlers = g_slist_append(signal_handlers, handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 |
15822 | 511 purple_signal_connect_priority_vargs(instance, signal, plugin, |
512 PURPLE_CALLBACK(perl_signal_cb), | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 handler, priority); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 void |
15822 | 517 purple_perl_signal_disconnect(PurplePlugin *plugin, void *instance, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 const char *signal) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 { |
15822 | 520 PurplePerlSignalHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 handler = find_signal_handler(plugin, instance, signal); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 if (handler == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 croak("Invalid signal handler information in " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 "disconnecting a perl signal handler.\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 destroy_signal_handler(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 void |
15822 | 534 purple_perl_signal_clear_for_plugin(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 { |
15822 | 536 PurplePerlSignalHandler *handler; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
537 GSList *l, *l_next; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 for (l = signal_handlers; l != NULL; l = l_next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 l_next = l->next; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
541 handler = l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 if (handler->plugin == plugin) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 destroy_signal_handler(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 void |
15822 | 549 purple_perl_signal_clear(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 while (signal_handlers != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 destroy_signal_handler(signal_handlers->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 |
15822 | 555 static PurpleCmdRet |
556 perl_cmd_cb(PurpleConversation *conv, const gchar *command, | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 gchar **args, gchar **error, void *data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 { |
15822 | 559 int i = 0, count, ret_value = PURPLE_CMD_RET_OK; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 SV *cmdSV, *tmpSV, *convSV; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
561 PurplePerlCmdHandler *handler = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 dSP; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 PUSHMARK(SP); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 /* Push the conversation onto the perl stack */ |
15822 | 569 convSV = sv_2mortal(purple_perl_bless_object(conv, "Purple::Conversation")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 XPUSHs(convSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 /* Push the command string onto the perl stack */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 cmdSV = newSVpv(command, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 cmdSV = sv_2mortal(cmdSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 XPUSHs(cmdSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 /* Push the data onto the perl stack */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 XPUSHs((SV *)handler->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 /* Push any arguments we may have */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 for (i = 0; args[i] != NULL; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 /* XXX The mortality of these created SV's should prevent |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 * memory issues, if I read/understood everything correctly... |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 tmpSV = newSVpv(args[i], 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 tmpSV = sv_2mortal(tmpSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 XPUSHs(tmpSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 PUTBACK; |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
591 count = call_sv(handler->callback, G_EVAL | G_SCALAR); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 if (count != 1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 croak("call_sv: Did not return the correct number of values.\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
596 if (SvTRUE(ERRSV)) { |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
597 purple_debug_error("perl", |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
598 "Perl plugin command function exited abnormally: %s\n", |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
599 SvPVutf8_nolen(ERRSV)); |
19196
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
600 } |
e1afc0e009d2
Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18092
diff
changeset
|
601 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 ret_value = POPi; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 return ret_value; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 |
15822 | 613 PurpleCmdId |
614 purple_perl_cmd_register(PurplePlugin *plugin, const gchar *command, | |
615 const gchar *args, PurpleCmdPriority priority, | |
616 PurpleCmdFlag flag, const gchar *prpl_id, SV *callback, | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 const gchar *helpstr, SV *data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 { |
15822 | 619 PurplePerlCmdHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 |
15822 | 621 handler = g_new0(PurplePerlCmdHandler, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 handler->plugin = plugin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 handler->cmd = g_strdup(command); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 handler->prpl_id = g_strdup(prpl_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 if (callback != NULL && callback != &PL_sv_undef) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 handler->callback = newSVsv(callback); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 handler->callback = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 if (data != NULL && data != &PL_sv_undef) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 handler->data = newSVsv(data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 handler->data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
636 cmd_handlers = g_slist_append(cmd_handlers, handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 |
15822 | 638 handler->id = purple_cmd_register(command, args, priority, flag, prpl_id, |
639 PURPLE_CMD_FUNC(perl_cmd_cb), helpstr, | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 return handler->id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 static void |
15822 | 646 destroy_cmd_handler(PurplePerlCmdHandler *handler) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 { |
28427
f0d103b366df
Unregister commands registered by a perl-plugin when unloading it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26880
diff
changeset
|
648 purple_cmd_unregister(handler->id); |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
649 cmd_handlers = g_slist_remove(cmd_handlers, handler); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 if (handler->callback != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 SvREFCNT_dec(handler->callback); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 if (handler->data != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 SvREFCNT_dec(handler->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 g_free(handler->cmd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 g_free(handler->prpl_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 g_free(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 void |
15822 | 663 purple_perl_cmd_clear_for_plugin(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
665 PurplePerlCmdHandler *handler; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
666 GSList *l, *l_next; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
667 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 for (l = cmd_handlers; l != NULL; l = l_next) { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
669 handler = l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 l_next = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
672 if (handler->plugin == plugin) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
673 destroy_cmd_handler(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
675 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 |
15822 | 677 static PurplePerlCmdHandler * |
678 find_cmd_handler(PurpleCmdId id) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
680 PurplePerlCmdHandler *handler; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
681 GSList *l; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 for (l = cmd_handlers; l != NULL; l = l->next) { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
684 handler = (PurplePerlCmdHandler *)l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
686 if (handler->id == id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 return handler; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 void |
15822 | 694 purple_perl_cmd_unregister(PurpleCmdId id) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 { |
15822 | 696 PurplePerlCmdHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 handler = find_cmd_handler(id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
700 if (handler == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 croak("Invalid command id in removing a perl command handler.\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
705 destroy_cmd_handler(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 } |
23618
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
707 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
708 static void |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
709 perl_pref_cb(const char *name, PurplePrefType type, gconstpointer value, |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
710 gpointer data) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
711 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
712 PurplePerlPrefsHandler *handler = data; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
713 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
714 dSP; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
715 ENTER; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
716 SAVETMPS; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
717 PUSHMARK(sp); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
718 XPUSHs(sv_2mortal(newSVpv(name, 0))); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
719 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
720 XPUSHs(sv_2mortal(newSViv(type))); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
721 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
722 switch(type) { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
723 case PURPLE_PREF_INT: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
724 XPUSHs(sv_2mortal(newSViv(GPOINTER_TO_INT(value)))); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
725 break; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
726 case PURPLE_PREF_BOOLEAN: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
727 XPUSHs((GPOINTER_TO_INT(value) == FALSE) ? &PL_sv_no : &PL_sv_yes); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
728 break; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
729 case PURPLE_PREF_STRING: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
730 case PURPLE_PREF_PATH: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
731 XPUSHs(sv_2mortal(newSVGChar(value))); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
732 break; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
733 case PURPLE_PREF_STRING_LIST: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
734 case PURPLE_PREF_PATH_LIST: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
735 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
736 AV* av = newAV(); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
737 const GList *l = value; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
738 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
739 /* Append stuff backward to preserve order */ |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
740 while (l && l->next) l = l->next; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
741 while (l) { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
742 av_push(av, sv_2mortal(newSVGChar(l->data))); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
743 l = l->prev; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
744 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
745 XPUSHs(sv_2mortal(newRV_noinc((SV *) av))); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
746 } break; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
747 default: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
748 case PURPLE_PREF_NONE: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
749 XPUSHs(&PL_sv_undef); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
750 break; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
751 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
752 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
753 XPUSHs((SV *)handler->data); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
754 PUTBACK; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
755 call_sv(handler->callback, G_EVAL | G_VOID | G_DISCARD); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
756 SPAGAIN; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
757 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
758 if (SvTRUE(ERRSV)) { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
759 purple_debug_error("perl", |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
760 "Perl prefs callback function exited abnormally: %s\n", |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
761 SvPVutf8_nolen(ERRSV)); |
23618
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
762 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
763 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
764 PUTBACK; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
765 FREETMPS; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
766 LEAVE; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
767 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
768 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
769 guint |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
770 purple_perl_prefs_connect_callback(PurplePlugin *plugin, const char *name, |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
771 SV *callback, SV *data) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
772 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
773 PurplePerlPrefsHandler *handler; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
774 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
775 if (plugin == NULL) { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
776 croak("Invalid handle in adding perl prefs handler.\n"); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
777 return 0; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
778 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
779 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
780 handler = g_new0(PurplePerlPrefsHandler, 1); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
781 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
782 handler->plugin = plugin; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
783 handler->callback = (callback != NULL && callback != &PL_sv_undef |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
784 ? newSVsv(callback) : NULL); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
785 handler->data = (data != NULL && data != &PL_sv_undef |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
786 ? newSVsv(data) : NULL); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
787 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
788 pref_handlers = g_slist_prepend(pref_handlers, handler); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
789 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
790 handler->iotag = purple_prefs_connect_callback(plugin, name, perl_pref_cb, handler); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
791 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
792 return handler->iotag; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
793 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
794 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
795 static void |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
796 destroy_prefs_handler(PurplePerlPrefsHandler *handler) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
797 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
798 pref_handlers = g_slist_remove(pref_handlers, handler); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
799 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
800 if (handler->iotag > 0) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
801 purple_prefs_disconnect_callback(handler->iotag); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
802 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
803 if (handler->callback != NULL) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
804 SvREFCNT_dec(handler->callback); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
805 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
806 if (handler->data != NULL) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
807 SvREFCNT_dec(handler->data); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
808 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
809 g_free(handler); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
810 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
811 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
812 void purple_perl_prefs_disconnect_callback(guint callback_id) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
813 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
814 GSList *l, *l_next; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
815 PurplePerlPrefsHandler *handler; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
816 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
817 for (l = pref_handlers; l != NULL; l = l_next) { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
818 l_next = l->next; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
819 handler = l->data; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
820 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
821 if (handler->iotag == callback_id) { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
822 destroy_prefs_handler(handler); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
823 return; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
824 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
825 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
826 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
827 purple_debug_info("perl", "No prefs handler found with handle %u.\n", |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
828 callback_id); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
829 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
830 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
831 void purple_perl_pref_cb_clear_for_plugin(PurplePlugin *plugin) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
832 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
833 GSList *l, *l_next; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
834 PurplePerlPrefsHandler *handler; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
835 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
836 for (l = pref_handlers; l != NULL; l = l_next) { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
837 l_next = l->next; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
838 handler = l->data; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
839 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
840 if (handler->plugin == plugin) |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
841 destroy_prefs_handler(handler); |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
842 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
843 } |