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