libpurple/plugins/perl/perl-handlers.c

Mon, 03 Feb 2014 22:40:31 +0530

author
Ankit Vani <a@nevitus.org>
date
Mon, 03 Feb 2014 22:40:31 +0530
branch
gtkdoc-conversion
changeset 35436
a69d2e5604c5
parent 34803
e0c884a4419a
child 36545
23b59a16c808
permissions
-rw-r--r--

Swap @title and @short_description roles

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;
34803
e0c884a4419a Refactored perl-handlers.c to use GType instead of PurpleValue.
Ankit Vani <a@nevitus.org>
parents: 34198
diff changeset
288 GType ret_type, *value_types;
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
34803
e0c884a4419a Refactored perl-handlers.c to use GType instead of PurpleValue.
Ankit Vani <a@nevitus.org>
parents: 34198
diff changeset
299 purple_signal_get_types(handler->instance, handler->signal,
e0c884a4419a Refactored perl-handlers.c to use GType instead of PurpleValue.
Ankit Vani <a@nevitus.org>
parents: 34198
diff changeset
300 &ret_type, &value_count, &value_types);
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++) {
34803
e0c884a4419a Refactored perl-handlers.c to use GType instead of PurpleValue.
Ankit Vani <a@nevitus.org>
parents: 34198
diff changeset
306 sv_args[i] = purple_perl_sv_from_vargs(value_types[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
34803
e0c884a4419a Refactored perl-handlers.c to use GType instead of PurpleValue.
Ankit Vani <a@nevitus.org>
parents: 34198
diff changeset
321 if (ret_type != G_TYPE_NONE) {
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
34803
e0c884a4419a Refactored perl-handlers.c to use GType instead of PurpleValue.
Ankit Vani <a@nevitus.org>
parents: 34198
diff changeset
329 ret_val = purple_perl_data_from_sv(ret_type, 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
34803
e0c884a4419a Refactored perl-handlers.c to use GType instead of PurpleValue.
Ankit Vani <a@nevitus.org>
parents: 34198
diff changeset
342 #if 0
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
343 /* See if any parameters changed. */
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
344 for (i = 0; i < value_count; i++) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
345 if (purple_value_is_outgoing(values[i])) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
346 switch (purple_value_get_type(values[i])) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
347 case PURPLE_TYPE_BOOLEAN:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
348 *((gboolean *)copy_args[i]) = SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
349 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
350
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
351 case PURPLE_TYPE_INT:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
352 *((int *)copy_args[i]) = SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
353 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
354
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
355 case PURPLE_TYPE_UINT:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
356 *((unsigned int *)copy_args[i]) = SvUV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
357 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
358
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
359 case PURPLE_TYPE_LONG:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
360 *((long *)copy_args[i]) = SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
361 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
362
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
363 case PURPLE_TYPE_ULONG:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
364 *((unsigned long *)copy_args[i]) = SvUV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
365 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
366
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
367 case PURPLE_TYPE_INT64:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
368 *((gint64 *)copy_args[i]) = SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
369 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
370
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
371 case PURPLE_TYPE_UINT64:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
372 *((guint64 *)copy_args[i]) = SvUV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
373 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
374
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
375 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
376 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
377 strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) {
6925
ace22b159921 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
378 g_free(*((char **)copy_args[i]));
ace22b159921 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
379 *((char **)copy_args[i]) =
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
380 g_strdup(SvPVutf8_nolen(sv_args[i]));
6925
ace22b159921 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
381 }
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
382 /* 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
383 sv_2mortal(sv_args[i]);
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
384 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
385
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
386 case PURPLE_TYPE_POINTER:
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
387 case PURPLE_TYPE_BOXED:
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
388 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]);
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
389 break;
23182
e32645a28cad applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <datallah@pidgin.im>
parents: 22845
diff changeset
390 case PURPLE_TYPE_SUBTYPE:
e32645a28cad applied changes from 2072edddff2333b97848681a9a464e9722b5f059
Daniel Atallah <datallah@pidgin.im>
parents: 22845
diff changeset
391 *((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
392 break;
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
393
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
394 default:
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
395 break;
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
396 }
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
397
23980
a38cbb35eecf Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 23931
diff changeset
398
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
399 #if 0
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
400 *((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
401 sv_args[i]);
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
402 #endif
6919
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 }
34803
e0c884a4419a Refactored perl-handlers.c to use GType instead of PurpleValue.
Ankit Vani <a@nevitus.org>
parents: 34198
diff changeset
405 #endif
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
406
6921
3d49b89fc920 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
407 PUTBACK;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
408 FREETMPS;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
409 LEAVE;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
410
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
411 g_free(sv_args);
6920
4f4931b005cb [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
412 g_free(copy_args);
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
413
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
414 purple_debug_misc("perl", "ret_val = %p\n", ret_val);
6919
2fd7ce2393f7 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
415
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
416 return ret_val;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
417 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
418
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
419 static PurplePerlSignalHandler *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
420 find_signal_handler(PurplePlugin *plugin, void *instance, const char *signal)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
421 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
422 PurplePerlSignalHandler *handler;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
423 GSList *l;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
424
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
425 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
426 handler = l->data;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
427
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
428 if (handler->plugin == plugin &&
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
429 handler->instance == instance &&
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
430 !strcmp(handler->signal, signal)) {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
431 return handler;
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 }
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 return NULL;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
436 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
437
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
438 guint
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
439 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
440 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
441 PurplePerlTimeoutHandler *handler;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
443 if (plugin == NULL) {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
444 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
445 return 0;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
448 handler = g_new0(PurplePerlTimeoutHandler, 1);
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
449
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
450 handler->plugin = plugin;
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
451 handler->callback = (callback != NULL && callback != &PL_sv_undef
13017
d3bcadbf3094 [gaim-migrate @ 15370]
Etan Reisner <deryni@pidgin.im>
parents: 12988
diff changeset
452 ? newSVsv(callback) : NULL);
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
453 handler->data = (data != NULL && data != &PL_sv_undef
13017
d3bcadbf3094 [gaim-migrate @ 15370]
Etan Reisner <deryni@pidgin.im>
parents: 12988
diff changeset
454 ? newSVsv(data) : NULL);
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
456 timeout_handlers = g_slist_append(timeout_handlers, handler);
6568
5c8c70b63dc3 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
457
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
458 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
459
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
460 return handler->iotag;
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
461 }
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
462
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
463 gboolean
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
464 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
465 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
466 PurplePerlTimeoutHandler *handler;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
467 GSList *l, *l_next;
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
468
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
469 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
470 handler = l->data;
22845
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
471 l_next = l->next;
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
472
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
473 if (handler->iotag == handle)
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
474 return destroy_timeout_handler(handler);
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
475 }
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
476
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
477 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
478 handle);
7ccb529edf3f Add the recent perl callback changes to ChangeLog.API.
Etan Reisner <deryni@pidgin.im>
parents: 19336
diff changeset
479 return FALSE;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
481
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
483 purple_perl_timeout_clear_for_plugin(PurplePlugin *plugin)
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
484 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
485 PurplePerlTimeoutHandler *handler;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
486 GSList *l, *l_next;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
487
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
488 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
489 handler = l->data;
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 l_next = l->next;
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 if (handler->plugin == plugin)
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493 destroy_timeout_handler(handler);
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 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
496
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
498 purple_perl_timeout_clear(void)
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499 {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
500 while (timeout_handlers != NULL)
6520
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501 destroy_timeout_handler(timeout_handlers->data);
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 }
5386692555c9 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
504 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
505 purple_perl_signal_connect(PurplePlugin *plugin, void *instance,
13191
6c98c6130701 [gaim-migrate @ 15553]
Etan Reisner <deryni@pidgin.im>
parents: 13017
diff changeset
506 const char *signal, SV *callback, SV *data,
6c98c6130701 [gaim-migrate @ 15553]
Etan Reisner <deryni@pidgin.im>
parents: 13017
diff changeset
507 int priority)
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 PurplePerlSignalHandler *handler;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
510
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
511 handler = g_new0(PurplePerlSignalHandler, 1);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
512 handler->plugin = plugin;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
513 handler->instance = instance;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
514 handler->signal = g_strdup(signal);
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
515 handler->callback = (callback != NULL &&
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
516 callback != &PL_sv_undef ? newSVsv(callback)
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
517 : NULL);
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
518 handler->data = (data != NULL &&
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
519 data != &PL_sv_undef ? newSVsv(data) : NULL);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
520
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
521 signal_handlers = g_slist_append(signal_handlers, handler);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
522
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
523 purple_signal_connect_priority_vargs(instance, signal, plugin,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
524 PURPLE_CALLBACK(perl_signal_cb),
13191
6c98c6130701 [gaim-migrate @ 15553]
Etan Reisner <deryni@pidgin.im>
parents: 13017
diff changeset
525 handler, priority);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
526 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
527
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
528 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
529 purple_perl_signal_disconnect(PurplePlugin *plugin, void *instance,
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
530 const char *signal)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
531 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
532 PurplePerlSignalHandler *handler;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
533
6567
761a1feb5561 [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
534 handler = find_signal_handler(plugin, instance, signal);
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
535
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
536 if (handler == NULL) {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
537 croak("Invalid signal handler information in "
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
538 "disconnecting a perl signal handler.\n");
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
539 return;
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
540 }
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 destroy_signal_handler(handler);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
543 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
544
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
545 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
546 purple_perl_signal_clear_for_plugin(PurplePlugin *plugin)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
547 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
548 PurplePerlSignalHandler *handler;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
549 GSList *l, *l_next;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
550
12803
14d095d68300 [gaim-migrate @ 15150]
Etan Reisner <deryni@pidgin.im>
parents: 12165
diff changeset
551 for (l = signal_handlers; l != NULL; l = l_next) {
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
552 l_next = l->next;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
553 handler = l->data;
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
554
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
555 if (handler->plugin == plugin)
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
556 destroy_signal_handler(handler);
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 }
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
559
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
560 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
561 purple_perl_signal_clear(void)
6549
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
562 {
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
563 while (signal_handlers != NULL)
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
564 destroy_signal_handler(signal_handlers->data);
8e6ba2a45698 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
565 }
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
566
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
567 static PurpleCmdRet
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
568 perl_cmd_cb(PurpleConversation *conv, const gchar *command,
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
569 gchar **args, gchar **error, void *data)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
570 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
571 int i = 0, count, ret_value = PURPLE_CMD_RET_OK;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
572 SV *cmdSV, *tmpSV, *convSV;
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
573 PurplePerlCmdHandler *handler = data;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
574
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
575 dSP;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
576 ENTER;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
577 SAVETMPS;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
578 PUSHMARK(SP);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
579
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
580 /* Push the conversation onto the perl stack */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
581 convSV = sv_2mortal(purple_perl_bless_object(conv, "Purple::Conversation"));
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
582 XPUSHs(convSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
583
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
584 /* Push the command string onto the perl stack */
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
585 cmdSV = newSVpv(command, 0);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
586 cmdSV = sv_2mortal(cmdSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
587 XPUSHs(cmdSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
588
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
589 /* Push the data onto the perl stack */
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
590 XPUSHs((SV *)handler->data);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
591
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
592 /* Push any arguments we may have */
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
593 for (i = 0; args[i] != NULL; i++) {
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
594 /* XXX The mortality of these created SV's should prevent
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
595 * memory issues, if I read/understood everything correctly...
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
596 */
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
597 tmpSV = newSVpv(args[i], 0);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
598 tmpSV = sv_2mortal(tmpSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
599 XPUSHs(tmpSV);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
600 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
601
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
602 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
603 count = call_sv(handler->callback, G_EVAL | G_SCALAR);
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
604
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
605 if (count != 1)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
606 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
607
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
608 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
609 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
610 "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
611 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
612 }
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
613
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
614 SPAGAIN;
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 ret_value = POPi;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
617
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
618 PUTBACK;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
619 FREETMPS;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
620 LEAVE;
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 return ret_value;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
623 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
624
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
625 PurpleCmdId
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
626 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
627 const gchar *args, PurpleCmdPriority priority,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
628 PurpleCmdFlag flag, const gchar *prpl_id, SV *callback,
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
629 const gchar *helpstr, SV *data)
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 PurplePerlCmdHandler *handler;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
632
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
633 handler = g_new0(PurplePerlCmdHandler, 1);
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
634 handler->plugin = plugin;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
635 handler->cmd = g_strdup(command);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
636 handler->prpl_id = g_strdup(prpl_id);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
637
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
638 if (callback != NULL && callback != &PL_sv_undef)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
639 handler->callback = newSVsv(callback);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
640 else
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
641 handler->callback = NULL;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
642
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
643 if (data != NULL && data != &PL_sv_undef)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
644 handler->data = newSVsv(data);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
645 else
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
646 handler->data = NULL;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
647
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
648 cmd_handlers = g_slist_append(cmd_handlers, handler);
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
649
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
650 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
651 PURPLE_CMD_FUNC(perl_cmd_cb), helpstr,
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
652 handler);
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 return handler->id;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
655 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
656
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
657 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
658 destroy_cmd_handler(PurplePerlCmdHandler *handler)
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
659 {
28740
6861934437a3 Unregister commands registered by a perl-plugin when unloading it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 27120
diff changeset
660 purple_cmd_unregister(handler->id);
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
661 cmd_handlers = g_slist_remove(cmd_handlers, handler);
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
662
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
663 if (handler->callback != NULL)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
664 SvREFCNT_dec(handler->callback);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
665
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
666 if (handler->data != NULL)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
667 SvREFCNT_dec(handler->data);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
668
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
669 g_free(handler->cmd);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
670 g_free(handler->prpl_id);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
671 g_free(handler);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
672 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
673
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
674 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
675 purple_perl_cmd_clear_for_plugin(PurplePlugin *plugin)
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
676 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
677 PurplePerlCmdHandler *handler;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
678 GSList *l, *l_next;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
679
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
680 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
681 handler = l->data;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
682 l_next = l->next;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
683
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
684 if (handler->plugin == plugin)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
685 destroy_cmd_handler(handler);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
686 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
687 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
688
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
689 static PurplePerlCmdHandler *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
690 find_cmd_handler(PurpleCmdId id)
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
691 {
23931
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
692 PurplePerlCmdHandler *handler;
8975bb78b51a Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents: 23930
diff changeset
693 GSList *l;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
694
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
695 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
696 handler = (PurplePerlCmdHandler *)l->data;
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
697
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
698 if (handler->id == id)
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
699 return handler;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
700 }
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 return NULL;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
703 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
704
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
705 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
706 purple_perl_cmd_unregister(PurpleCmdId id)
12882
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
707 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
708 PurplePerlCmdHandler *handler;
12882
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 handler = find_cmd_handler(id);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
711
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
712 if (handler == NULL) {
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
713 croak("Invalid command id in removing a perl command handler.\n");
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
714 return;
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
715 }
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
716
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
717 destroy_cmd_handler(handler);
44dfc6467081 [gaim-migrate @ 15234]
Etan Reisner <deryni@pidgin.im>
parents: 12874
diff changeset
718 }
23930
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
719
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
720 static void
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
721 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
722 gpointer 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 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
725
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
726 dSP;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
727 ENTER;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
728 SAVETMPS;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
729 PUSHMARK(sp);
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(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
731
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
732 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
733
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
734 switch(type) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
735 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
736 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
737 break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
738 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
739 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
740 break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
741 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
742 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
743 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
744 break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
745 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
746 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
747 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
748 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
749 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
750
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
751 /* 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
752 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
753 while (l) {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
754 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
755 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
756 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
757 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
758 } break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
759 default:
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
760 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
761 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
762 break;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
763 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
764
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
765 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
766 PUTBACK;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
767 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
768 SPAGAIN;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
769
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
770 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
771 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
772 "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
773 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
774 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
775
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
776 PUTBACK;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
777 FREETMPS;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
778 LEAVE;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
779 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
780
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
781 guint
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
782 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
783 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
784 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
785 PurplePerlPrefsHandler *handler;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
786
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
787 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
788 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
789 return 0;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
790 }
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 = 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
793
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
794 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
795 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
796 ? 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
797 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
798 ? 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
799
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
800 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
801
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
802 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
803
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
804 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
805 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
806
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
807 static void
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
808 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
809 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
810 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
811
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
812 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
813 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
814
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
815 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
816 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
817
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
818 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
819 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
820
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
821 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
822 }
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 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
825 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
826 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
827 PurplePerlPrefsHandler *handler;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
828
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
829 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
830 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
831 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
832
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
833 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
834 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
835 return;
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 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
838
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
839 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
840 callback_id);
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
841 }
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 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
844 {
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
845 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
846 PurplePerlPrefsHandler *handler;
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
847
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
848 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
849 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
850 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
851
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
852 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
853 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
854 }
c1c3d7cab338 Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents: 23182
diff changeset
855 }
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
856
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 static void
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
858 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
859 {
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
860 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
861 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
862
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 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
864 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
865 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
866 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
867
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
868 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
869 "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
870 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
871
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
872 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
873 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
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 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
876
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
877 PUTBACK;
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
878 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
879 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
880
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
881 if (SvTRUE(ERRSV)) {
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
882 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
883 "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
884 }
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
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 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
887 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
888 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
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 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
891 }
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
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
893 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
894 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
895 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
896 {
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
897 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
898 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
899
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 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
901 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
902 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
903 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
904
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
905 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
906 "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
907 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
908
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
909 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
910 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
911
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
912 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
913 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
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 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
916
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
917 PUTBACK;
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
918 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
919 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
920
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
921 if (SvTRUE(ERRSV)) {
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
922 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
923 "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
924 }
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
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 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
927 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
928 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
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 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
931 }
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
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 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
934 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
935 {
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
936 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
937
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
938 if (func == &PL_sv_undef)
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
939 func = NULL;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
940 if (data == &PL_sv_undef)
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
941 data = NULL;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
942
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
943 handler = g_new0(PurplePerlAccountPasswordHandler, 1);
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
944 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
945 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
946
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
947 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
948 }
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
949
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
950 void
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
951 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
952 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
953 {
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
954 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
955
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
956 if (func == &PL_sv_undef)
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
957 func = NULL;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
958 if (data == &PL_sv_undef)
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
959 data = NULL;
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
960
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
961 handler = g_new0(PurplePerlAccountPasswordHandler, 1);
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
962 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
963 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
964
34198
89549a1875e0 Fix perl handlers for password access routines
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34040
diff changeset
965 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
966 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
967 }

mercurial