Mercurial > pidgin
annotate libpurple/plugins/perl/perl-handlers.c @ 24021:28c68cff8c8a
Stu's idea, I sort of did it the other way. I don't know if it will help
but I am going to References #1862, #3696, #6776
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sat, 30 Aug 2008 07:53:32 +0000 |
parents | 6f47135f5378 |
children | b9f7a8ca1369 |
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; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 PUSHMARK(sp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 |
15822 | 291 purple_signal_get_values(handler->instance, handler->signal, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 &ret_value, &value_count, &values); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 sv_args = g_new(SV *, value_count); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 copy_args = g_new(void **, value_count); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 for (i = 0; i < value_count; i++) { |
15822 | 298 sv_args[i] = purple_perl_sv_from_vargs(values[i], |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
299 (va_list*)&args, |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
300 ©_args[i]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 XPUSHs(sv_args[i]); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 XPUSHs((SV *)handler->data); |
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 PUTBACK; |
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 if (ret_value != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 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
|
311 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 SPAGAIN; |
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 if (count != 1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 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
|
316 else |
15822 | 317 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
|
318 } 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
|
319 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
|
320 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 SPAGAIN; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 if (SvTRUE(ERRSV)) { |
15822 | 325 purple_debug_error("perl", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 "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
|
327 SvPVutf8_nolen(ERRSV)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 /* See if any parameters changed. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 for (i = 0; i < value_count; i++) { |
15822 | 332 if (purple_value_is_outgoing(values[i])) { |
333 switch (purple_value_get_type(values[i])) { | |
334 case PURPLE_TYPE_BOOLEAN: | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 *((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
|
336 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 |
15822 | 338 case PURPLE_TYPE_INT: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 *((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
|
340 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 |
15822 | 342 case PURPLE_TYPE_UINT: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 *((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
|
344 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 |
15822 | 346 case PURPLE_TYPE_LONG: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 *((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
|
348 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 |
15822 | 350 case PURPLE_TYPE_ULONG: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 *((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
|
352 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 |
15822 | 354 case PURPLE_TYPE_INT64: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 *((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
|
356 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 |
15822 | 358 case PURPLE_TYPE_UINT64: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 *((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
|
360 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 |
15822 | 362 case PURPLE_TYPE_STRING: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 g_free(*((char **)copy_args[i])); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 *((char **)copy_args[i]) = |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
366 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
|
367 } |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
368 /* 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
|
369 sv_2mortal(sv_args[i]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 |
15822 | 372 case PURPLE_TYPE_POINTER: |
373 case PURPLE_TYPE_BOXED: | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 *((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
|
375 break; |
23040
1367fb4d56f1
applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22702
diff
changeset
|
376 case PURPLE_TYPE_SUBTYPE: |
1367fb4d56f1
applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22702
diff
changeset
|
377 *((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
|
378 break; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 break; |
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 |
23653
6f47135f5378
Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23619
diff
changeset
|
384 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 #if 0 |
15822 | 386 *((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
|
387 sv_args[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 g_free(sv_args); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 g_free(copy_args); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 |
15822 | 399 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
|
400 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 return ret_val; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 |
15822 | 404 static PurplePerlSignalHandler * |
405 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
|
406 { |
15822 | 407 PurplePerlSignalHandler *handler; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
408 GSList *l; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 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
|
411 handler = l->data; |
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 if (handler->plugin == plugin && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 handler->instance == instance && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 !strcmp(handler->signal, signal)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 return handler; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 return NULL; |
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 |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
423 guint |
15822 | 424 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
|
425 { |
15822 | 426 PurplePerlTimeoutHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 if (plugin == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 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
|
430 return 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 |
15822 | 433 handler = g_new0(PurplePerlTimeoutHandler, 1); |
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 handler->plugin = plugin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 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
|
437 ? newSVsv(callback) : NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 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
|
439 ? newSVsv(data) : NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
441 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
|
442 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
443 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
|
444 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
445 return handler->iotag; |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
446 } |
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 gboolean |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
449 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
|
450 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
451 PurplePerlTimeoutHandler *handler; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
452 GSList *l, *l_next; |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
453 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
454 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
|
455 handler = l->data; |
22702
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
456 l_next = l->next; |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
457 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
458 if (handler->iotag == handle) |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
459 return destroy_timeout_handler(handler); |
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 |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
462 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
|
463 handle); |
870a580e8fde
Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents:
19196
diff
changeset
|
464 return FALSE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 void |
15822 | 468 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
|
469 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
470 PurplePerlTimeoutHandler *handler; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
471 GSList *l, *l_next; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 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
|
474 handler = l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 l_next = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 if (handler->plugin == plugin) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 destroy_timeout_handler(handler); |
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 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 void |
15822 | 483 purple_perl_timeout_clear(void) |
15373
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 while (timeout_handlers != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 destroy_timeout_handler(timeout_handlers->data); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 void |
15822 | 490 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
|
491 const char *signal, SV *callback, SV *data, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 int priority) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 { |
15822 | 494 PurplePerlSignalHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 |
15822 | 496 handler = g_new0(PurplePerlSignalHandler, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 handler->plugin = plugin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 handler->instance = instance; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 handler->signal = g_strdup(signal); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 handler->callback = (callback != NULL && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 callback != &PL_sv_undef ? newSVsv(callback) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 : NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 handler->data = (data != NULL && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 data != &PL_sv_undef ? newSVsv(data) : NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
506 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
|
507 |
15822 | 508 purple_signal_connect_priority_vargs(instance, signal, plugin, |
509 PURPLE_CALLBACK(perl_signal_cb), | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 handler, priority); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 void |
15822 | 514 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
|
515 const char *signal) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 { |
15822 | 517 PurplePerlSignalHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 handler = find_signal_handler(plugin, instance, signal); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 if (handler == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 croak("Invalid signal handler information in " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 "disconnecting a perl signal handler.\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 destroy_signal_handler(handler); |
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 void |
15822 | 531 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
|
532 { |
15822 | 533 PurplePerlSignalHandler *handler; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
534 GSList *l, *l_next; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 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
|
537 l_next = l->next; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
538 handler = l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 if (handler->plugin == plugin) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 destroy_signal_handler(handler); |
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 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 void |
15822 | 546 purple_perl_signal_clear(void) |
15373
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 while (signal_handlers != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 destroy_signal_handler(signal_handlers->data); |
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 |
15822 | 552 static PurpleCmdRet |
553 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
|
554 gchar **args, gchar **error, void *data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 { |
15822 | 556 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
|
557 SV *cmdSV, *tmpSV, *convSV; |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
558 PurplePerlCmdHandler *handler = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 dSP; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 ENTER; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 SAVETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 PUSHMARK(SP); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 /* Push the conversation onto the perl stack */ |
15822 | 566 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
|
567 XPUSHs(convSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 /* 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
|
570 cmdSV = newSVpv(command, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 cmdSV = sv_2mortal(cmdSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 XPUSHs(cmdSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 /* Push the data onto the perl stack */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 XPUSHs((SV *)handler->data); |
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 any arguments we may have */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 for (i = 0; args[i] != NULL; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 /* 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
|
580 * 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
|
581 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 tmpSV = newSVpv(args[i], 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 tmpSV = sv_2mortal(tmpSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 XPUSHs(tmpSV); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 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
|
588 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
|
589 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 if (count != 1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 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
|
592 |
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
|
593 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
|
594 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
|
595 "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
|
596 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
|
597 } |
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 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 SPAGAIN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 ret_value = POPi; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 PUTBACK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 FREETMPS; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 LEAVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 return ret_value; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 |
15822 | 610 PurpleCmdId |
611 purple_perl_cmd_register(PurplePlugin *plugin, const gchar *command, | |
612 const gchar *args, PurpleCmdPriority priority, | |
613 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
|
614 const gchar *helpstr, SV *data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 { |
15822 | 616 PurplePerlCmdHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 |
15822 | 618 handler = g_new0(PurplePerlCmdHandler, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 handler->plugin = plugin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 handler->cmd = g_strdup(command); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 handler->prpl_id = g_strdup(prpl_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 if (callback != NULL && callback != &PL_sv_undef) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 handler->callback = newSVsv(callback); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 handler->callback = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 if (data != NULL && data != &PL_sv_undef) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 handler->data = newSVsv(data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 handler->data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
633 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
|
634 |
15822 | 635 handler->id = purple_cmd_register(command, args, priority, flag, prpl_id, |
636 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
|
637 handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 return handler->id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 } |
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 static void |
15822 | 643 destroy_cmd_handler(PurplePerlCmdHandler *handler) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
645 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
|
646 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 if (handler->callback != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 SvREFCNT_dec(handler->callback); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 if (handler->data != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 SvREFCNT_dec(handler->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 g_free(handler->cmd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 g_free(handler->prpl_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 g_free(handler); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 void |
15822 | 659 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
|
660 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
661 PurplePerlCmdHandler *handler; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
662 GSList *l, *l_next; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 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
|
665 handler = l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 l_next = l->next; |
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 if (handler->plugin == plugin) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 destroy_cmd_handler(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 } |
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 |
15822 | 673 static PurplePerlCmdHandler * |
674 find_cmd_handler(PurpleCmdId id) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
675 { |
23619
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
676 PurplePerlCmdHandler *handler; |
ece34c9599f5
Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23618
diff
changeset
|
677 GSList *l; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 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
|
680 handler = (PurplePerlCmdHandler *)l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 if (handler->id == id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 return handler; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 } |
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 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 } |
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 void |
15822 | 690 purple_perl_cmd_unregister(PurpleCmdId id) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 { |
15822 | 692 PurplePerlCmdHandler *handler; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 handler = find_cmd_handler(id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 if (handler == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 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
|
698 return; |
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 |
15822 | 701 purple_cmd_unregister(id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 destroy_cmd_handler(handler); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 } |
23618
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
704 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
705 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
|
706 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
|
707 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
|
708 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
709 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
|
710 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
711 dSP; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
712 ENTER; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
713 SAVETMPS; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
714 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
|
715 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
|
716 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
717 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
|
718 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
719 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
|
720 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
|
721 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
|
722 break; |
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_BOOLEAN: |
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((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
|
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_STRING: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
727 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
|
728 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
|
729 break; |
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_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
|
731 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
|
732 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
733 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
|
734 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
|
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 /* 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
|
737 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
|
738 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
|
739 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
|
740 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
|
741 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
742 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
|
743 } break; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
744 default: |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
745 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
|
746 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
|
747 break; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
748 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
749 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
750 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
|
751 PUTBACK; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
752 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
|
753 SPAGAIN; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
754 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
755 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
|
756 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
|
757 "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
|
758 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
|
759 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
760 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
761 PUTBACK; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
762 FREETMPS; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
763 LEAVE; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
764 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
765 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
766 guint |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
767 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
|
768 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
|
769 { |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
770 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
|
771 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
772 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
|
773 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
|
774 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
|
775 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
776 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
777 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
|
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 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
|
780 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
|
781 ? 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
|
782 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
|
783 ? 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
|
784 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
785 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
|
786 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
787 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
|
788 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
789 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
|
790 } |
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 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
|
793 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
|
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 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
|
796 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
797 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
|
798 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
|
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->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
|
801 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
|
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->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
|
804 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
|
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 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
|
807 } |
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 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
|
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 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
|
812 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
|
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 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
|
815 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
|
816 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
|
817 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
818 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
|
819 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
|
820 return; |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
821 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
822 } |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
823 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
824 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
|
825 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
|
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 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
828 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
|
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 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
|
831 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
|
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 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
|
834 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
|
835 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
|
836 |
fb86dbeb2b15
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23040
diff
changeset
|
837 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
|
838 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
|
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 } |