libpurple/plugins/perl/perl-handlers.c

Tue, 14 May 2013 13:07:06 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Tue, 14 May 2013 13:07:06 +0200
branch
soc.2008.masterpassword
changeset 34198
89549a1875e0
parent 34040
f5417957a1bc
child 34803
e0c884a4419a
permissions
-rw-r--r--

Fix perl handlers for password access routines

6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 #include "perl-common.h"
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 #include "perl-handlers.h"
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 #include "debug.h"
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
5 #include "signals.h"
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
7 typedef struct
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
8 {
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
9 SV *callback;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
10 SV *data;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
11 } PurplePerlAccountPasswordHandler;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
12
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
13 extern PerlInterpreter *my_perl;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
14 static GSList *cmd_handlers = NULL;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
15 static GSList *signal_handlers = NULL;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
16 static GSList *timeout_handlers = NULL;
23930
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
17 static GSList *pref_handlers = NULL;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18
12165
9f2d7e6b8707 [gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11170
diff changeset
19 /* perl < 5.8.0 doesn't define PERL_MAGIC_ext */
9f2d7e6b8707 [gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11170
diff changeset
20 #ifndef PERL_MAGIC_ext
9f2d7e6b8707 [gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11170
diff changeset
21 #define PERL_MAGIC_ext '~'
9f2d7e6b8707 [gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11170
diff changeset
22 #endif
9f2d7e6b8707 [gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11170
diff changeset
23
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
24 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
25 purple_perl_plugin_action_cb(PurplePluginAction *action)
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
26 {
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
27 SV **callback;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
28 HV *hv = NULL;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
29 gchar *hvname;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
30 PurplePlugin *plugin;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
31 PurplePerlScript *gps;
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
32 dSP;
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
33
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
34 plugin = action->plugin;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
35 gps = (PurplePerlScript *)plugin->info->extra_info;
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
36 hvname = g_strdup_printf("%s::plugin_actions", gps->package);
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
37 hv = get_hv(hvname, FALSE);
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
38 g_free(hvname);
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
39
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
40 if (hv == NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
41 croak("No plugin_actions hash found in \"%s\" plugin.", purple_plugin_get_name(plugin));
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
42
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
43 ENTER;
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
44 SAVETMPS;
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
45
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
46 callback = hv_fetch(hv, action->label, strlen(action->label), 0);
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
47
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
48 if (callback == NULL || *callback == NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
49 croak("No plugin_action function named \"%s\" in \"%s\" plugin.", action->label, purple_plugin_get_name(plugin));
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
50
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
51 PUSHMARK(sp);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
52 XPUSHs(purple_perl_bless_object(gps->plugin, "Purple::Plugin"));
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
53 PUTBACK;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
54
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
55 call_sv(*callback, G_EVAL | G_VOID | G_DISCARD);
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
56
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
57 SPAGAIN;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
58
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
59 if (SvTRUE(ERRSV)) {
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
60 purple_debug_error("perl",
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
61 "Perl plugin action function exited abnormally: %s\n",
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
62 SvPVutf8_nolen(ERRSV));
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
63 }
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
64
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
65 PUTBACK;
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
66 FREETMPS;
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
67 LEAVE;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
68 }
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
69
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
70 GList *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
71 purple_perl_plugin_actions(PurplePlugin *plugin, gpointer context)
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
72 {
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
73 GList *l = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
74 PurplePerlScript *gps;
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
75 int i = 0, count = 0;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
76 dSP;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
77
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
78 gps = plugin->info->extra_info;
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
79
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
80 ENTER;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
81 SAVETMPS;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
82
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
83 PUSHMARK(SP);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
84 XPUSHs(sv_2mortal(purple_perl_bless_object(plugin, "Purple::Plugin")));
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
85 /* XXX This *will* cease working correctly if context gets changed to
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
86 * ever be able to hold anything other than a PurpleConnection */
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
87 if (context != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
88 XPUSHs(sv_2mortal(purple_perl_bless_object(context,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
89 "Purple::Connection")));
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
90 else
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
91 XPUSHs(&PL_sv_undef);
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
92 PUTBACK;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
93
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
94 count = call_pv(gps->plugin_action_sub, G_EVAL | G_ARRAY);
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
95
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
96 SPAGAIN;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
97
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
98 if (SvTRUE(ERRSV)) {
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
99 purple_debug_error("perl",
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
100 "Perl plugin actions lookup exited abnormally: %s\n",
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
101 SvPVutf8_nolen(ERRSV));
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
102 }
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
103
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
104 if (count == 0)
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
105 croak("The plugin_actions sub didn't return anything.\n");
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
106
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
107 for (i = 0; i < count; i++) {
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
108 SV *sv;
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
109 PurplePluginAction *act;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
110
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
111 sv = POPs;
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
112 act = purple_plugin_action_new(SvPVutf8_nolen(sv), purple_perl_plugin_action_cb);
13354
eeec75e1c290 [gaim-migrate @ 15725]
Scott Wolchok
parents: 13191
diff changeset
113 l = g_list_prepend(l, act);
12988
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
114 }
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
115
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
116 PUTBACK;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
117 FREETMPS;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
118 LEAVE;
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
119
2a53945982f5 [gaim-migrate @ 15341]
Etan Reisner <deryni@pidgin.im>
parents: 12882
diff changeset
120 return l;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
121 }
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
122
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
123 #ifdef PURPLE_GTKPERL
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
124 GtkWidget *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
125 purple_perl_gtk_get_plugin_frame(PurplePlugin *plugin)
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
126 {
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
127 SV * sv;
12874
9874953fdb62 [gaim-migrate @ 15226]
Etan Reisner <deryni@pidgin.im>
parents: 12872
diff changeset
128 int count;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
129 MAGIC *mg;
12874
9874953fdb62 [gaim-migrate @ 15226]
Etan Reisner <deryni@pidgin.im>
parents: 12872
diff changeset
130 GtkWidget *ret;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
131 PurplePerlScript *gps;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
132 dSP;
12874
9874953fdb62 [gaim-migrate @ 15226]
Etan Reisner <deryni@pidgin.im>
parents: 12872
diff changeset
133
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
134 gps = plugin->info->extra_info;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
135
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
136 ENTER;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
137 SAVETMPS;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
138
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
139 count = call_pv(gps->gtk_prefs_sub, G_EVAL | G_SCALAR | G_NOARGS);
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
140 if (count != 1)
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
141 croak("call_pv: Did not return the correct number of values.\n");
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
142
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
143 /* the frame was created in a perl sub and is returned */
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
144 SPAGAIN;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
145
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
146 if (SvTRUE(ERRSV)) {
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
147 purple_debug_error("perl",
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
148 "Perl gtk plugin frame init exited abnormally: %s\n",
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
149 SvPVutf8_nolen(ERRSV));
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
150 }
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
151
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
152 /* We have a Gtk2::Frame on top of the stack */
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
153 sv = POPs;
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
154
12874
9874953fdb62 [gaim-migrate @ 15226]
Etan Reisner <deryni@pidgin.im>
parents: 12872
diff changeset
155 /* The magic field hides the pointer to the actual GtkWidget */
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
156 mg = mg_find(SvRV(sv), PERL_MAGIC_ext);
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
157 ret = (GtkWidget *)mg->mg_ptr;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
158
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
159 PUTBACK;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
160 FREETMPS;
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
161 LEAVE;
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
162
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
163 return ret;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
164 }
14426
8d4f164c4979 [gaim-migrate @ 17070]
Daniel Atallah <datallah@pidgin.im>
parents: 14254
diff changeset
165 #endif
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
166
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
167 PurplePluginPrefFrame *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
168 purple_perl_get_plugin_frame(PurplePlugin *plugin)
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
169 {
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
170 /* Sets up the Perl Stack for our call back into the script to run the
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
171 * plugin_pref... sub */
12872
b3d38f1b9bd7 [gaim-migrate @ 15224]
Etan Reisner <deryni@pidgin.im>
parents: 12871
diff changeset
172 int count;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
173 PurplePerlScript *gps;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
174 PurplePluginPrefFrame *ret_frame;
11123
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
175 dSP;
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
176
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
177 gps = (PurplePerlScript *)plugin->info->extra_info;
12872
b3d38f1b9bd7 [gaim-migrate @ 15224]
Etan Reisner <deryni@pidgin.im>
parents: 12871
diff changeset
178
11123
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
179 ENTER;
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
180 SAVETMPS;
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
181 /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
182 * return the frame */
11123
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
183 PUSHMARK(SP);
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
184 PUTBACK;
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
185
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
186 count = call_pv(gps->prefs_sub, G_EVAL | G_SCALAR | G_NOARGS);
11123
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
187
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
188 SPAGAIN;
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
189
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
190 if (SvTRUE(ERRSV)) {
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
191 purple_debug_error("perl",
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
192 "Perl plugin prefs frame init exited abnormally: %s\n",
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
193 SvPVutf8_nolen(ERRSV));
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
194 }
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
195
11123
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
196 if (count != 1)
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
197 croak("call_pv: Did not return the correct number of values.\n");
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
198 /* the frame was created in a perl sub and is returned */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
199 ret_frame = (PurplePluginPrefFrame *)purple_perl_ref_object(POPs);
11123
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
200
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
201 /* Tidy up the Perl stack */
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
202 PUTBACK;
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
203 FREETMPS;
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
204 LEAVE;
12871
3584d93ae63c [gaim-migrate @ 15223]
Etan Reisner <deryni@pidgin.im>
parents: 12804
diff changeset
205
11123
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
206 return ret_frame;
098f5c57f2bb [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
207 }
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
209 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
210 destroy_timeout_handler(PurplePerlTimeoutHandler *handler)
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 {
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
212 gboolean ret = FALSE;
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
213
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
214 timeout_handlers = g_slist_remove(timeout_handlers, handler);
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215
16140
362e0ca15d3a Fix Bug #125 (Perl plugins using timeouts not having timeouts unregistered when plugin unloaded)
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
216 if (handler->iotag > 0)
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
217 ret = purple_timeout_remove(handler->iotag);
16140
362e0ca15d3a Fix Bug #125 (Perl plugins using timeouts not having timeouts unregistered when plugin unloaded)
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
218
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
219 if (handler->callback != NULL)
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
220 SvREFCNT_dec(handler->callback);
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
221
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
222 if (handler->data != NULL)
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
223 SvREFCNT_dec(handler->data);
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
224
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 g_free(handler);
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
226
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
227 return ret;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
230 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
231 destroy_signal_handler(PurplePerlSignalHandler *handler)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
232 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
233 signal_handlers = g_slist_remove(signal_handlers, handler);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
234
6567
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
235 if (handler->callback != NULL)
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
236 SvREFCNT_dec(handler->callback);
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
237
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
238 if (handler->data != NULL)
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
239 SvREFCNT_dec(handler->data);
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
240
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
241 g_free(handler->signal);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
242 g_free(handler);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
243 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
244
16140
362e0ca15d3a Fix Bug #125 (Perl plugins using timeouts not having timeouts unregistered when plugin unloaded)
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
245 static gboolean
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 perl_timeout_cb(gpointer data)
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
248 PurplePerlTimeoutHandler *handler = data;
18165
fb6f9d0130aa Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17570
diff changeset
249 gboolean ret = FALSE;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 dSP;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 ENTER;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 SAVETMPS;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 PUSHMARK(sp);
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
255 XPUSHs((SV *)handler->data);
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 PUTBACK;
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
257 call_sv(handler->callback, G_EVAL | G_SCALAR);
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 SPAGAIN;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
260 if (SvTRUE(ERRSV)) {
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
261 purple_debug_error("perl",
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
262 "Perl timeout function exited abnormally: %s\n",
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
263 SvPVutf8_nolen(ERRSV));
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
264 }
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
265
18165
fb6f9d0130aa Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17570
diff changeset
266 ret = POPi;
fb6f9d0130aa Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17570
diff changeset
267
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 PUTBACK;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 FREETMPS;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 LEAVE;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271
18165
fb6f9d0130aa Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17570
diff changeset
272 if (ret == FALSE)
fb6f9d0130aa Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17570
diff changeset
273 destroy_timeout_handler(handler);
16140
362e0ca15d3a Fix Bug #125 (Perl plugins using timeouts not having timeouts unregistered when plugin unloaded)
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
274
18165
fb6f9d0130aa Make timeout-callbacks behave like they would in C plugins (ie. the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17570
diff changeset
275 return ret;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
278 typedef void *DATATYPE;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
279
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
280 static void *
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
281 perl_signal_cb(va_list args, void *data)
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
282 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
283 PurplePerlSignalHandler *handler = data;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
284 void *ret_val = NULL;
6566
61eb35202526 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
285 int i;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
286 int count;
6566
61eb35202526 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
287 int value_count;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
288 PurpleValue *ret_value, **values;
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
289 SV **sv_args;
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
290 DATATYPE **copy_args;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
291
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
292 dSP;
27120
d7503d775939 Fix a couple of crashes in the perl plugin loader.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25381
diff changeset
293 PERL_SET_CONTEXT(my_perl);
d7503d775939 Fix a couple of crashes in the perl plugin loader.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25381
diff changeset
294 SPAGAIN;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
295 ENTER;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
296 SAVETMPS;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
297 PUSHMARK(sp);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
298
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
299 purple_signal_get_values(handler->instance, handler->signal,
25381
9a510397bf31 Apparently our use of va_list arguments in the perl signal callbacks doesn't
Etan Reisner <deryni@pidgin.im>
parents: 23980
diff changeset
300 &ret_value, &value_count, &values);
6566
61eb35202526 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
301
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
302 sv_args = g_new(SV *, value_count);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
303 copy_args = g_new(void **, value_count);
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
304
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
305 for (i = 0; i < value_count; i++) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
306 sv_args[i] = purple_perl_sv_from_vargs(values[i],
29341
8df545432476 disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents: 29340
diff changeset
307 #ifdef VA_COPY_AS_ARRAY
29813
4918a5928b93 Add a cast to silence this warning.
Mark Doliner <markdoliner@pidgin.im>
parents: 29341
diff changeset
308 (va_list*)args,
29341
8df545432476 disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents: 29340
diff changeset
309 #else
8df545432476 disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents: 29340
diff changeset
310 (va_list*)&args,
8df545432476 disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents: 29340
diff changeset
311 #endif
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
312 &copy_args[i]);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
313
6920
4f4931b005cb [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
314 XPUSHs(sv_args[i]);
6566
61eb35202526 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
315 }
61eb35202526 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
316
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
317 XPUSHs((SV *)handler->data);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
318
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
319 PUTBACK;
6567
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
320
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
321 if (ret_value != NULL) {
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
322 count = call_sv(handler->callback, G_EVAL | G_SCALAR);
6567
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
323
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
324 SPAGAIN;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
325
6567
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
326 if (count != 1)
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
327 croak("Uh oh! call_sv returned %i != 1", i);
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
328 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
329 ret_val = purple_perl_data_from_sv(ret_value, POPs);
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
330 } else {
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
331 call_sv(handler->callback, G_EVAL | G_SCALAR);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
332
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
333 SPAGAIN;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
334 }
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
335
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
336 if (SvTRUE(ERRSV)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
337 purple_debug_error("perl",
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
338 "Perl function exited abnormally: %s\n",
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
339 SvPVutf8_nolen(ERRSV));
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
340 }
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
341
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
342 /* See if any parameters changed. */
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
343 for (i = 0; i < value_count; i++) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
344 if (purple_value_is_outgoing(values[i])) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
345 switch (purple_value_get_type(values[i])) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
346 case PURPLE_TYPE_BOOLEAN:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
347 *((gboolean *)copy_args[i]) = SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
348 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
349
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
350 case PURPLE_TYPE_INT:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
351 *((int *)copy_args[i]) = SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
352 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
353
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
354 case PURPLE_TYPE_UINT:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
355 *((unsigned int *)copy_args[i]) = SvUV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
356 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
357
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
358 case PURPLE_TYPE_LONG:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
359 *((long *)copy_args[i]) = SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
360 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
361
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
362 case PURPLE_TYPE_ULONG:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
363 *((unsigned long *)copy_args[i]) = SvUV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
364 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
365
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
366 case PURPLE_TYPE_INT64:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
367 *((gint64 *)copy_args[i]) = SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
368 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
369
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
370 case PURPLE_TYPE_UINT64:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
371 *((guint64 *)copy_args[i]) = SvUV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
372 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
373
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
374 case PURPLE_TYPE_STRING:
27120
d7503d775939 Fix a couple of crashes in the perl plugin loader.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25381
diff changeset
375 if (!*((char **)copy_args[i]) || !SvPVX(sv_args[i]) ||
d7503d775939 Fix a couple of crashes in the perl plugin loader.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25381
diff changeset
376 strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) {
6925
ace22b159921 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
377 g_free(*((char **)copy_args[i]));
ace22b159921 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
378 *((char **)copy_args[i]) =
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
379 g_strdup(SvPVutf8_nolen(sv_args[i]));
6925
ace22b159921 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
380 }
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
381 /* Clean up sv_args[i] - we're done with it */
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
382 sv_2mortal(sv_args[i]);
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
383 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
384
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
385 case PURPLE_TYPE_POINTER:
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
386 case PURPLE_TYPE_BOXED:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
387 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
388 break;
23182
e32645a28cad applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <datallah@pidgin.im>
parents: 22845
diff changeset
389 case PURPLE_TYPE_SUBTYPE:
e32645a28cad applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <datallah@pidgin.im>
parents: 22845
diff changeset
390 *((void **)copy_args[i]) = purple_perl_ref_object(sv_args[i]);
e32645a28cad applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <datallah@pidgin.im>
parents: 22845
diff changeset
391 break;
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
392
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
393 default:
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
394 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
395 }
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
396
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
397
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
398 #if 0
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
399 *((void **)copy_args[i]) = purple_perl_data_from_sv(values[i],
6920
4f4931b005cb [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
400 sv_args[i]);
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
401 #endif
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
402 }
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
403 }
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
404
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
405 PUTBACK;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
406 FREETMPS;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
407 LEAVE;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
408
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
409 g_free(sv_args);
6920
4f4931b005cb [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
410 g_free(copy_args);
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
411
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
412 purple_debug_misc("perl", "ret_val = %p\n", ret_val);
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
413
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
414 return ret_val;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
415 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
416
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
417 static PurplePerlSignalHandler *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
418 find_signal_handler(PurplePlugin *plugin, void *instance, const char *signal)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
419 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
420 PurplePerlSignalHandler *handler;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
421 GSList *l;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
422
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
423 for (l = signal_handlers; l != NULL; l = l->next) {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
424 handler = l->data;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
425
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
426 if (handler->plugin == plugin &&
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
427 handler->instance == instance &&
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
428 !strcmp(handler->signal, signal)) {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
429 return handler;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
430 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
431 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
432
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
433 return NULL;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
434 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
435
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
436 guint
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
437 purple_perl_timeout_add(PurplePlugin *plugin, int seconds, SV *callback, SV *data)
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
439 PurplePerlTimeoutHandler *handler;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
441 if (plugin == NULL) {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
442 croak("Invalid handle in adding perl timeout handler.\n");
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
443 return 0;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
446 handler = g_new0(PurplePerlTimeoutHandler, 1);
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
448 handler->plugin = plugin;
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
449 handler->callback = (callback != NULL && callback != &PL_sv_undef
13017
d3bcadbf3094 [gaim-migrate @ 15370]
Etan Reisner <deryni@pidgin.im>
parents: 12988
diff changeset
450 ? newSVsv(callback) : NULL);
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
451 handler->data = (data != NULL && data != &PL_sv_undef
13017
d3bcadbf3094 [gaim-migrate @ 15370]
Etan Reisner <deryni@pidgin.im>
parents: 12988
diff changeset
452 ? newSVsv(data) : NULL);
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
454 timeout_handlers = g_slist_append(timeout_handlers, handler);
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
455
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
456 handler->iotag = purple_timeout_add_seconds(seconds, perl_timeout_cb, handler);
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
457
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
458 return handler->iotag;
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
459 }
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
460
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
461 gboolean
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
462 purple_perl_timeout_remove(guint handle)
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
463 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
464 PurplePerlTimeoutHandler *handler;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
465 GSList *l, *l_next;
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
466
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
467 for (l = timeout_handlers; l != NULL; l = l_next) {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
468 handler = l->data;
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
469 l_next = l->next;
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
470
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
471 if (handler->iotag == handle)
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
472 return destroy_timeout_handler(handler);
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
473 }
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
474
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
475 purple_debug_info("perl", "No timeout handler found with handle %u.\n",
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
476 handle);
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
477 return FALSE;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
478 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
479
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
481 purple_perl_timeout_clear_for_plugin(PurplePlugin *plugin)
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
483 PurplePerlTimeoutHandler *handler;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
484 GSList *l, *l_next;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
485
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
486 for (l = timeout_handlers; l != NULL; l = l_next) {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
487 handler = l->data;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488 l_next = l->next;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
489
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 if (handler->plugin == plugin)
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491 destroy_timeout_handler(handler);
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
494
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
495 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
496 purple_perl_timeout_clear(void)
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
498 while (timeout_handlers != NULL)
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499 destroy_timeout_handler(timeout_handlers->data);
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
502 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
503 purple_perl_signal_connect(PurplePlugin *plugin, void *instance,
13191
6c98c6130701 [gaim-migrate @ 15553]
Etan Reisner <deryni@pidgin.im>
parents: 13017
diff changeset
504 const char *signal, SV *callback, SV *data,
6c98c6130701 [gaim-migrate @ 15553]
Etan Reisner <deryni@pidgin.im>
parents: 13017
diff changeset
505 int priority)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
506 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
507 PurplePerlSignalHandler *handler;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
508
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
509 handler = g_new0(PurplePerlSignalHandler, 1);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
510 handler->plugin = plugin;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
511 handler->instance = instance;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
512 handler->signal = g_strdup(signal);
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
513 handler->callback = (callback != NULL &&
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
514 callback != &PL_sv_undef ? newSVsv(callback)
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
515 : NULL);
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
516 handler->data = (data != NULL &&
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
517 data != &PL_sv_undef ? newSVsv(data) : NULL);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
518
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
519 signal_handlers = g_slist_append(signal_handlers, handler);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
520
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
521 purple_signal_connect_priority_vargs(instance, signal, plugin,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
522 PURPLE_CALLBACK(perl_signal_cb),
13191
6c98c6130701 [gaim-migrate @ 15553]
Etan Reisner <deryni@pidgin.im>
parents: 13017
diff changeset
523 handler, priority);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
524 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
525
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
526 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
527 purple_perl_signal_disconnect(PurplePlugin *plugin, void *instance,
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
528 const char *signal)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
529 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
530 PurplePerlSignalHandler *handler;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
531
6567
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
532 handler = find_signal_handler(plugin, instance, signal);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
533
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
534 if (handler == NULL) {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
535 croak("Invalid signal handler information in "
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
536 "disconnecting a perl signal handler.\n");
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
537 return;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
538 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
539
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
540 destroy_signal_handler(handler);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
541 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
542
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
543 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
544 purple_perl_signal_clear_for_plugin(PurplePlugin *plugin)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
545 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
546 PurplePerlSignalHandler *handler;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
547 GSList *l, *l_next;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
548
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
549 for (l = signal_handlers; l != NULL; l = l_next) {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
550 l_next = l->next;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
551 handler = l->data;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
552
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
553 if (handler->plugin == plugin)
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
554 destroy_signal_handler(handler);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
555 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
556 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
557
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
558 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
559 purple_perl_signal_clear(void)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
560 {
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
561 while (signal_handlers != NULL)
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
562 destroy_signal_handler(signal_handlers->data);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
563 }
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
564
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
565 static PurpleCmdRet
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
566 perl_cmd_cb(PurpleConversation *conv, const gchar *command,
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
567 gchar **args, gchar **error, void *data)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
568 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
569 int i = 0, count, ret_value = PURPLE_CMD_RET_OK;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
570 SV *cmdSV, *tmpSV, *convSV;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
571 PurplePerlCmdHandler *handler = data;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
572
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
573 dSP;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
574 ENTER;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
575 SAVETMPS;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
576 PUSHMARK(SP);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
577
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
578 /* Push the conversation onto the perl stack */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
579 convSV = sv_2mortal(purple_perl_bless_object(conv, "Purple::Conversation"));
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
580 XPUSHs(convSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
581
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
582 /* Push the command string onto the perl stack */
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
583 cmdSV = newSVpv(command, 0);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
584 cmdSV = sv_2mortal(cmdSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
585 XPUSHs(cmdSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
586
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
587 /* Push the data onto the perl stack */
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
588 XPUSHs((SV *)handler->data);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
589
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
590 /* Push any arguments we may have */
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
591 for (i = 0; args[i] != NULL; i++) {
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
592 /* XXX The mortality of these created SV's should prevent
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
593 * memory issues, if I read/understood everything correctly...
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
594 */
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
595 tmpSV = newSVpv(args[i], 0);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
596 tmpSV = sv_2mortal(tmpSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
597 XPUSHs(tmpSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
598 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
599
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
600 PUTBACK;
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
601 count = call_sv(handler->callback, G_EVAL | G_SCALAR);
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
602
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
603 if (count != 1)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
604 croak("call_sv: Did not return the correct number of values.\n");
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
605
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
606 if (SvTRUE(ERRSV)) {
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
607 purple_debug_error("perl",
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
608 "Perl plugin command function exited abnormally: %s\n",
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
609 SvPVutf8_nolen(ERRSV));
19336
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
610 }
065a79d2d0e5 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 <datallah@pidgin.im>
parents: 18165
diff changeset
611
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
612 SPAGAIN;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
613
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
614 ret_value = POPi;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
615
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
616 PUTBACK;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
617 FREETMPS;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
618 LEAVE;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
619
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
620 return ret_value;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
621 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
622
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
623 PurpleCmdId
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
624 purple_perl_cmd_register(PurplePlugin *plugin, const gchar *command,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
625 const gchar *args, PurpleCmdPriority priority,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
626 PurpleCmdFlag flag, const gchar *prpl_id, SV *callback,
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
627 const gchar *helpstr, SV *data)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
628 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
629 PurplePerlCmdHandler *handler;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
630
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
631 handler = g_new0(PurplePerlCmdHandler, 1);
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
632 handler->plugin = plugin;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
633 handler->cmd = g_strdup(command);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
634 handler->prpl_id = g_strdup(prpl_id);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
635
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
636 if (callback != NULL && callback != &PL_sv_undef)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
637 handler->callback = newSVsv(callback);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
638 else
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
639 handler->callback = NULL;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
640
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
641 if (data != NULL && data != &PL_sv_undef)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
642 handler->data = newSVsv(data);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
643 else
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
644 handler->data = NULL;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
645
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
646 cmd_handlers = g_slist_append(cmd_handlers, handler);
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
647
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
648 handler->id = purple_cmd_register(command, args, priority, flag, prpl_id,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
649 PURPLE_CMD_FUNC(perl_cmd_cb), helpstr,
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
650 handler);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
651
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
652 return handler->id;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
653 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
654
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
655 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
656 destroy_cmd_handler(PurplePerlCmdHandler *handler)
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
657 {
28740
6861934437a3 Unregister commands registered by a perl-plugin when unloading it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 27120
diff changeset
658 purple_cmd_unregister(handler->id);
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
659 cmd_handlers = g_slist_remove(cmd_handlers, handler);
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
660
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
661 if (handler->callback != NULL)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
662 SvREFCNT_dec(handler->callback);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
663
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
664 if (handler->data != NULL)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
665 SvREFCNT_dec(handler->data);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
666
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
667 g_free(handler->cmd);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
668 g_free(handler->prpl_id);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
669 g_free(handler);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
670 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
671
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
672 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
673 purple_perl_cmd_clear_for_plugin(PurplePlugin *plugin)
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
674 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
675 PurplePerlCmdHandler *handler;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
676 GSList *l, *l_next;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
677
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
678 for (l = cmd_handlers; l != NULL; l = l_next) {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
679 handler = l->data;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
680 l_next = l->next;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
681
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
682 if (handler->plugin == plugin)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
683 destroy_cmd_handler(handler);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
684 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
685 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
686
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
687 static PurplePerlCmdHandler *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
688 find_cmd_handler(PurpleCmdId id)
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
689 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
690 PurplePerlCmdHandler *handler;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
691 GSList *l;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
692
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
693 for (l = cmd_handlers; l != NULL; l = l->next) {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
694 handler = (PurplePerlCmdHandler *)l->data;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
695
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
696 if (handler->id == id)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
697 return handler;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
698 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
699
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
700 return NULL;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
701 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
702
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
703 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
704 purple_perl_cmd_unregister(PurpleCmdId id)
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
705 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
706 PurplePerlCmdHandler *handler;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
707
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
708 handler = find_cmd_handler(id);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
709
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
710 if (handler == NULL) {
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
711 croak("Invalid command id in removing a perl command handler.\n");
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
712 return;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
713 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
714
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
715 destroy_cmd_handler(handler);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
716 }
23930
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
717
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
718 static void
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
719 perl_pref_cb(const char *name, PurplePrefType type, gconstpointer value,
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
720 gpointer data)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
721 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
722 PurplePerlPrefsHandler *handler = data;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
723
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
724 dSP;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
725 ENTER;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
726 SAVETMPS;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
727 PUSHMARK(sp);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
728 XPUSHs(sv_2mortal(newSVpv(name, 0)));
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
729
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
730 XPUSHs(sv_2mortal(newSViv(type)));
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
731
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
732 switch(type) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
733 case PURPLE_PREF_INT:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
734 XPUSHs(sv_2mortal(newSViv(GPOINTER_TO_INT(value))));
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
735 break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
736 case PURPLE_PREF_BOOLEAN:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
737 XPUSHs((GPOINTER_TO_INT(value) == FALSE) ? &PL_sv_no : &PL_sv_yes);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
738 break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
739 case PURPLE_PREF_STRING:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
740 case PURPLE_PREF_PATH:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
741 XPUSHs(sv_2mortal(newSVGChar(value)));
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
742 break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
743 case PURPLE_PREF_STRING_LIST:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
744 case PURPLE_PREF_PATH_LIST:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
745 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
746 AV* av = newAV();
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
747 const GList *l = value;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
748
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
749 /* Append stuff backward to preserve order */
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
750 while (l && l->next) l = l->next;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
751 while (l) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
752 av_push(av, sv_2mortal(newSVGChar(l->data)));
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
753 l = l->prev;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
754 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
755 XPUSHs(sv_2mortal(newRV_noinc((SV *) av)));
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
756 } break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
757 default:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
758 case PURPLE_PREF_NONE:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
759 XPUSHs(&PL_sv_undef);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
760 break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
761 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
762
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
763 XPUSHs((SV *)handler->data);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
764 PUTBACK;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
765 call_sv(handler->callback, G_EVAL | G_VOID | G_DISCARD);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
766 SPAGAIN;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
767
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
768 if (SvTRUE(ERRSV)) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
769 purple_debug_error("perl",
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
770 "Perl prefs callback function exited abnormally: %s\n",
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
771 SvPVutf8_nolen(ERRSV));
23930
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
772 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
773
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
774 PUTBACK;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
775 FREETMPS;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
776 LEAVE;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
777 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
778
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
779 guint
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
780 purple_perl_prefs_connect_callback(PurplePlugin *plugin, const char *name,
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
781 SV *callback, SV *data)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
782 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
783 PurplePerlPrefsHandler *handler;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
784
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
785 if (plugin == NULL) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
786 croak("Invalid handle in adding perl prefs handler.\n");
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
787 return 0;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
788 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
789
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
790 handler = g_new0(PurplePerlPrefsHandler, 1);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
791
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
792 handler->plugin = plugin;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
793 handler->callback = (callback != NULL && callback != &PL_sv_undef
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
794 ? newSVsv(callback) : NULL);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
795 handler->data = (data != NULL && data != &PL_sv_undef
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
796 ? newSVsv(data) : NULL);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
797
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
798 pref_handlers = g_slist_prepend(pref_handlers, handler);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
799
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
800 handler->iotag = purple_prefs_connect_callback(plugin, name, perl_pref_cb, handler);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
801
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
802 return handler->iotag;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
803 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
804
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
805 static void
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
806 destroy_prefs_handler(PurplePerlPrefsHandler *handler)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
807 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
808 pref_handlers = g_slist_remove(pref_handlers, handler);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
809
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
810 if (handler->iotag > 0)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
811 purple_prefs_disconnect_callback(handler->iotag);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
812
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
813 if (handler->callback != NULL)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
814 SvREFCNT_dec(handler->callback);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
815
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
816 if (handler->data != NULL)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
817 SvREFCNT_dec(handler->data);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
818
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
819 g_free(handler);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
820 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
821
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
822 void purple_perl_prefs_disconnect_callback(guint callback_id)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
823 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
824 GSList *l, *l_next;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
825 PurplePerlPrefsHandler *handler;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
826
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
827 for (l = pref_handlers; l != NULL; l = l_next) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
828 l_next = l->next;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
829 handler = l->data;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
830
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
831 if (handler->iotag == callback_id) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
832 destroy_prefs_handler(handler);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
833 return;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
834 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
835 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
836
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
837 purple_debug_info("perl", "No prefs handler found with handle %u.\n",
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
838 callback_id);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
839 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
840
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
841 void purple_perl_pref_cb_clear_for_plugin(PurplePlugin *plugin)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
842 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
843 GSList *l, *l_next;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
844 PurplePerlPrefsHandler *handler;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
845
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
846 for (l = pref_handlers; l != NULL; l = l_next) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
847 l_next = l->next;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
848 handler = l->data;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
849
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
850 if (handler->plugin == plugin)
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
851 destroy_prefs_handler(handler);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
852 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
853 }
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
854
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
855 static void
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
856 perl_account_save_cb(PurpleAccount *account, GError *error, gpointer _handler)
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
857 {
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
858 PurplePerlAccountPasswordHandler *handler = _handler;
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
859 SV *accountSV, *errorSV;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
860
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
861 dSP;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
862 ENTER;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
863 SAVETMPS;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
864 PUSHMARK(SP);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
865
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
866 accountSV = sv_2mortal(purple_perl_bless_object(account,
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
867 "Purple::Account"));
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
868 XPUSHs(accountSV);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
869
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
870 errorSV = sv_2mortal(purple_perl_bless_object(error, "GLib::Error"));
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
871 XPUSHs(errorSV);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
872
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
873 XPUSHs((SV *)handler->data);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
874
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
875 PUTBACK;
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
876 call_sv(handler->callback, G_EVAL | G_SCALAR);
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
877 SPAGAIN;
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
878
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
879 if (SvTRUE(ERRSV)) {
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
880 purple_debug_error("perl", "Perl plugin command function "
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
881 "exited abnormally: %s\n", SvPVutf8_nolen(ERRSV));
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
882 }
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
883
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
884 PUTBACK;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
885 FREETMPS;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
886 LEAVE;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
887
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
888 g_free(handler);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
889 }
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
890
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
891 static void
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
892 perl_account_read_cb(PurpleAccount *account, const gchar *password,
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
893 GError *error, gpointer _handler)
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
894 {
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
895 PurplePerlAccountPasswordHandler *handler = _handler;
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
896 SV *accountSV, *passwordSV, *errorSV;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
897
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
898 dSP;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
899 ENTER;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
900 SAVETMPS;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
901 PUSHMARK(SP);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
902
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
903 accountSV = sv_2mortal(purple_perl_bless_object(account,
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
904 "Purple::Account"));
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
905 XPUSHs(accountSV);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
906
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
907 passwordSV = sv_2mortal(newSVpv(password, 0));
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
908 XPUSHs(passwordSV);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
909
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
910 errorSV = sv_2mortal(purple_perl_bless_object(error, "GLib::Error"));
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
911 XPUSHs(errorSV);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
912
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
913 XPUSHs((SV *)handler->data);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
914
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
915 PUTBACK;
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
916 call_sv(handler->callback, G_EVAL | G_SCALAR);
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
917 SPAGAIN;
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
918
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
919 if (SvTRUE(ERRSV)) {
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
920 purple_debug_error("perl", "Perl plugin command function "
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
921 "exited abnormally: %s\n", SvPVutf8_nolen(ERRSV));
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
922 }
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
923
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
924 PUTBACK;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
925 FREETMPS;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
926 LEAVE;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
927
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
928 g_free(handler);
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
929 }
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
930
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
931 void
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
932 purple_perl_account_get_password(PurpleAccount *account, SV *func, SV *data)
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
933 {
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
934 PurplePerlAccountPasswordHandler *handler;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
935
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
936 if (func == &PL_sv_undef)
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
937 func = NULL;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
938 if (data == &PL_sv_undef)
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
939 data = NULL;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
940
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
941 handler = g_new0(PurplePerlAccountPasswordHandler, 1);
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
942 handler->callback = (func != NULL ? newSVsv(func) : NULL);
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
943 handler->data = (data != NULL ? newSVsv(data) : NULL);
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
944
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
945 purple_account_get_password(account, perl_account_read_cb, handler);
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
946 }
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
947
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
948 void
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
949 purple_perl_account_set_password(PurpleAccount *account, const gchar *password,
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
950 SV *func, SV *data)
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
951 {
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
952 PurplePerlAccountPasswordHandler *handler;
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
953
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
954 if (func == &PL_sv_undef)
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
955 func = NULL;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
956 if (data == &PL_sv_undef)
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
957 data = NULL;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
958
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
959 handler = g_new0(PurplePerlAccountPasswordHandler, 1);
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
960 handler->callback = (func != NULL ? newSVsv(func) : NULL);
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
961 handler->data = (data != NULL ? newSVsv(data) : NULL);
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
962
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
963 purple_account_set_password(account, password, perl_account_save_cb,
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
964 handler);
34040
f5417957a1bc Fix Perl compile. This probably doesn't work. I just copy and pasted
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29813
diff changeset
965 }

mercurial