annotate libpurple/plugins/perl/perl-handlers.c @ 25377:0ffa511ac165

Re-combine large (multi-part) messages on MSN since we seem to say that we do support receiving chunked messages. References #393, though not the same as the patch in the ticket.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 27 Jan 2009 05:22:10 +0000
parents b9f7a8ca1369
children 22b87a82755b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
24 PurplePlugin *plugin;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
82 XPUSHs(sv_2mortal(purple_perl_bless_object(context,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
161 PurplePluginPrefFrame *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
167 PurplePerlScript *gps;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
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
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
282 PurpleValue *ret_value, **values;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 SV **sv_args;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 DATATYPE **copy_args;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 dSP;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 ENTER;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 SAVETMPS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 PUSHMARK(sp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
291 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
292 &ret_value, &value_count, &values);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 sv_args = g_new(SV *, value_count);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 copy_args = g_new(void **, value_count);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 for (i = 0; i < value_count; i++) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
298 sv_args[i] = purple_perl_sv_from_vargs(values[i],
25263
b9f7a8ca1369 Apparently our use of va_list arguments in the perl signal callbacks doesn't
Etan Reisner <pidgin@unreliablesource.net>
parents: 23653
diff changeset
299 #ifdef VA_COPY_AS_ARRAY
b9f7a8ca1369 Apparently our use of va_list arguments in the perl signal callbacks doesn't
Etan Reisner <pidgin@unreliablesource.net>
parents: 23653
diff changeset
300 args,
b9f7a8ca1369 Apparently our use of va_list arguments in the perl signal callbacks doesn't
Etan Reisner <pidgin@unreliablesource.net>
parents: 23653
diff changeset
301 #else
22702
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
302 (va_list*)&args,
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
303 #endif
22702
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
304 &copy_args[i]);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 XPUSHs(sv_args[i]);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 XPUSHs((SV *)handler->data);
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 PUTBACK;
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 if (ret_value != NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 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
315
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 SPAGAIN;
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 if (count != 1)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 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
320 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
321 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
322 } 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
323 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
324
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 SPAGAIN;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 if (SvTRUE(ERRSV)) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
329 purple_debug_error("perl",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 "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
331 SvPVutf8_nolen(ERRSV));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 /* See if any parameters changed. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 for (i = 0; i < value_count; i++) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
336 if (purple_value_is_outgoing(values[i])) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
337 switch (purple_value_get_type(values[i])) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
338 case PURPLE_TYPE_BOOLEAN:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 *((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
340 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
342 case PURPLE_TYPE_INT:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 *((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
344 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
346 case PURPLE_TYPE_UINT:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 *((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
348 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
350 case PURPLE_TYPE_LONG:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 *((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
352 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
354 case PURPLE_TYPE_ULONG:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 *((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
356 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
358 case PURPLE_TYPE_INT64:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 *((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
360 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
362 case PURPLE_TYPE_UINT64:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 *((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
364 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
366 case PURPLE_TYPE_STRING:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 g_free(*((char **)copy_args[i]));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 *((char **)copy_args[i]) =
23653
6f47135f5378 Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23619
diff changeset
370 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
371 }
23653
6f47135f5378 Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23619
diff changeset
372 /* 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
373 sv_2mortal(sv_args[i]);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
376 case PURPLE_TYPE_POINTER:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
377 case PURPLE_TYPE_BOXED:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 *((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
379 break;
23040
1367fb4d56f1 applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22702
diff changeset
380 case PURPLE_TYPE_SUBTYPE:
1367fb4d56f1 applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22702
diff changeset
381 *((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
382 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 default:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 break;
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
23653
6f47135f5378 Some cleanup and a couple leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23619
diff changeset
388
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 #if 0
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
390 *((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
391 sv_args[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 PUTBACK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 FREETMPS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 LEAVE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 g_free(sv_args);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 g_free(copy_args);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
403 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
404
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 return ret_val;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
408 static PurplePerlSignalHandler *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
409 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
410 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
411 PurplePerlSignalHandler *handler;
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
412 GSList *l;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 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
415 handler = l->data;
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 if (handler->plugin == plugin &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 handler->instance == instance &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 !strcmp(handler->signal, signal)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 return handler;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 return NULL;
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
22702
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
427 guint
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
428 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
429 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
430 PurplePerlTimeoutHandler *handler;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 if (plugin == NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 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
434 return 0;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
437 handler = g_new0(PurplePerlTimeoutHandler, 1);
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 handler->plugin = plugin;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 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
441 ? newSVsv(callback) : NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 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
443 ? newSVsv(data) : NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
445 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
446
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
447 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
448
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
449 return handler->iotag;
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
450 }
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
451
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
452 gboolean
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
453 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
454 {
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
455 PurplePerlTimeoutHandler *handler;
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
456 GSList *l, *l_next;
22702
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
457
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
458 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
459 handler = l->data;
22702
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
460 l_next = l->next;
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
461
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
462 if (handler->iotag == handle)
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
463 return destroy_timeout_handler(handler);
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
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
466 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
467 handle);
870a580e8fde Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <pidgin@unreliablesource.net>
parents: 19196
diff changeset
468 return FALSE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
472 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
473 {
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
474 PurplePerlTimeoutHandler *handler;
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
475 GSList *l, *l_next;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 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
478 handler = l->data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 l_next = l->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 if (handler->plugin == plugin)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 destroy_timeout_handler(handler);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
487 purple_perl_timeout_clear(void)
15373
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 while (timeout_handlers != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 destroy_timeout_handler(timeout_handlers->data);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
494 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
495 const char *signal, SV *callback, SV *data,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 int priority)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
498 PurplePerlSignalHandler *handler;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
500 handler = g_new0(PurplePerlSignalHandler, 1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 handler->plugin = plugin;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 handler->instance = instance;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 handler->signal = g_strdup(signal);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 handler->callback = (callback != NULL &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 callback != &PL_sv_undef ? newSVsv(callback)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 : NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 handler->data = (data != NULL &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 data != &PL_sv_undef ? newSVsv(data) : NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
510 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
511
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
512 purple_signal_connect_priority_vargs(instance, signal, plugin,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
513 PURPLE_CALLBACK(perl_signal_cb),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 handler, priority);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
518 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
519 const char *signal)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
521 PurplePerlSignalHandler *handler;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 handler = find_signal_handler(plugin, instance, signal);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 if (handler == NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 croak("Invalid signal handler information in "
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 "disconnecting a perl signal handler.\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 destroy_signal_handler(handler);
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 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
535 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
536 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
537 PurplePerlSignalHandler *handler;
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
538 GSList *l, *l_next;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 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
541 l_next = l->next;
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
542 handler = l->data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 if (handler->plugin == plugin)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 destroy_signal_handler(handler);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
550 purple_perl_signal_clear(void)
15373
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 while (signal_handlers != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 destroy_signal_handler(signal_handlers->data);
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
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
556 static PurpleCmdRet
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
557 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
558 gchar **args, gchar **error, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
560 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
561 SV *cmdSV, *tmpSV, *convSV;
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
562 PurplePerlCmdHandler *handler = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 dSP;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 ENTER;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 SAVETMPS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 PUSHMARK(SP);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 /* Push the conversation onto the perl stack */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
570 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
571 XPUSHs(convSV);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 /* 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
574 cmdSV = newSVpv(command, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 cmdSV = sv_2mortal(cmdSV);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 XPUSHs(cmdSV);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 /* Push the data onto the perl stack */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 XPUSHs((SV *)handler->data);
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 any arguments we may have */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 for (i = 0; args[i] != NULL; i++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 /* 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
584 * 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
585 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 tmpSV = newSVpv(args[i], 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 tmpSV = sv_2mortal(tmpSV);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 XPUSHs(tmpSV);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 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
592 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
593
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 if (count != 1)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 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
596
19196
e1afc0e009d2 Make perl loader more robust - use G_EVAL flag on all calls so that if the perl function dies, it doesn't cause libpurple to quit.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18092
diff changeset
597 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
598 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
599 "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
600 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
601 }
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
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603 SPAGAIN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 ret_value = POPi;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 PUTBACK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 FREETMPS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 LEAVE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 return ret_value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
614 PurpleCmdId
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
615 purple_perl_cmd_register(PurplePlugin *plugin, const gchar *command,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
616 const gchar *args, PurpleCmdPriority priority,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
617 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
618 const gchar *helpstr, SV *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
620 PurplePerlCmdHandler *handler;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
622 handler = g_new0(PurplePerlCmdHandler, 1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 handler->plugin = plugin;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 handler->cmd = g_strdup(command);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 handler->prpl_id = g_strdup(prpl_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 if (callback != NULL && callback != &PL_sv_undef)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628 handler->callback = newSVsv(callback);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 handler->callback = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 if (data != NULL && data != &PL_sv_undef)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 handler->data = newSVsv(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 handler->data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
637 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
638
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
639 handler->id = purple_cmd_register(command, args, priority, flag, prpl_id,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
640 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
641 handler);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 return handler->id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
647 destroy_cmd_handler(PurplePerlCmdHandler *handler)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 {
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
649 cmd_handlers = g_slist_remove(cmd_handlers, handler);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 if (handler->callback != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 SvREFCNT_dec(handler->callback);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 if (handler->data != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 SvREFCNT_dec(handler->data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 g_free(handler->cmd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 g_free(handler->prpl_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 g_free(handler);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
663 purple_perl_cmd_clear_for_plugin(PurplePlugin *plugin)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 {
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
665 PurplePerlCmdHandler *handler;
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
666 GSList *l, *l_next;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 for (l = cmd_handlers; l != NULL; l = l_next) {
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
669 handler = l->data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 l_next = l->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 if (handler->plugin == plugin)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 destroy_cmd_handler(handler);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
677 static PurplePerlCmdHandler *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
678 find_cmd_handler(PurpleCmdId id)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679 {
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
680 PurplePerlCmdHandler *handler;
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
681 GSList *l;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 for (l = cmd_handlers; l != NULL; l = l->next) {
23619
ece34c9599f5 Cleanup unnecessary casts and etc.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23618
diff changeset
684 handler = (PurplePerlCmdHandler *)l->data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 if (handler->id == id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 return handler;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
694 purple_perl_cmd_unregister(PurpleCmdId id)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
696 PurplePerlCmdHandler *handler;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698 handler = find_cmd_handler(id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700 if (handler == NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 croak("Invalid command id in removing a perl command handler.\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
705 purple_cmd_unregister(id);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 destroy_cmd_handler(handler);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 }
23618
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
708
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
709 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
710 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
711 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
712 {
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
713 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
714
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
715 dSP;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
716 ENTER;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
717 SAVETMPS;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
718 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
719 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
720
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
721 XPUSHs(sv_2mortal(newSViv(type)));
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
722
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
723 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
724 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
725 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
726 break;
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_BOOLEAN:
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((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
729 break;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
730 case PURPLE_PREF_STRING:
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
731 case PURPLE_PREF_PATH:
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
732 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
733 break;
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_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
735 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
736 {
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
737 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
738 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
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 /* 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
741 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
742 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
743 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
744 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
745 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
746 XPUSHs(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
747 } break;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
748 default:
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
749 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
750 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
751 break;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
752 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
753
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
754 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
755 PUTBACK;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
756 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
757 SPAGAIN;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
758
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
759 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
760 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
761 "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
762 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
763 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
764
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
765 PUTBACK;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
766 FREETMPS;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
767 LEAVE;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
768 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
769
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
770 guint
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
771 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
772 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
773 {
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
774 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
775
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
776 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
777 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
778 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
779 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
780
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
781 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
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 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
784 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
785 ? 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
786 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
787 ? 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
788
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
789 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
790
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
791 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
792
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
793 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
794 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
795
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
796 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
797 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
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 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
800
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
801 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
802 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
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->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
805 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
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->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
808 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
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 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
811 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
812
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
813 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
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 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
816 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
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 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
819 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
820 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
821
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
822 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
823 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
824 return;
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
825 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
826 }
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
827
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
828 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
829 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
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
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
832 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
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 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
835 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
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 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
838 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
839 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
840
fb86dbeb2b15 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23040
diff changeset
841 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
842 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
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 }