Wed, 17 Jul 2013 04:31:46 +0530
Refactored perl-handlers.c to use GType instead of PurpleValue.
Here, an assumption is made for purple_value_is_outgoing() to be FALSE.
| 6520 | 1 | #include "perl-common.h" |
| 2 | #include "perl-handlers.h" | |
| 3 | ||
| 4 | #include "debug.h" | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
5 | #include "signals.h" |
| 6520 | 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 | 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 | 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 | 24 | void |
| 15884 | 25 | purple_perl_plugin_action_cb(PurplePluginAction *action) |
| 12803 | 26 | { |
| 12988 | 27 | SV **callback; |
| 28 | HV *hv = NULL; | |
| 29 | gchar *hvname; | |
| 15884 | 30 | PurplePlugin *plugin; |
| 31 | PurplePerlScript *gps; | |
| 12803 | 32 | dSP; |
| 12988 | 33 | |
| 34 | plugin = action->plugin; | |
| 15884 | 35 | gps = (PurplePerlScript *)plugin->info->extra_info; |
| 12988 | 36 | hvname = g_strdup_printf("%s::plugin_actions", gps->package); |
| 37 | hv = get_hv(hvname, FALSE); | |
| 38 | g_free(hvname); | |
| 39 | ||
| 40 | if (hv == NULL) | |
| 15884 | 41 | croak("No plugin_actions hash found in \"%s\" plugin.", purple_plugin_get_name(plugin)); |
| 12988 | 42 | |
| 12803 | 43 | ENTER; |
| 44 | SAVETMPS; | |
| 12988 | 45 | |
| 46 | callback = hv_fetch(hv, action->label, strlen(action->label), 0); | |
| 11170 | 47 | |
| 12988 | 48 | if (callback == NULL || *callback == NULL) |
| 15884 | 49 | croak("No plugin_action function named \"%s\" in \"%s\" plugin.", action->label, purple_plugin_get_name(plugin)); |
| 11170 | 50 | |
| 12988 | 51 | PUSHMARK(sp); |
| 15884 | 52 | XPUSHs(purple_perl_bless_object(gps->plugin, "Purple::Plugin")); |
| 12803 | 53 | PUTBACK; |
| 11170 | 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 | 57 | SPAGAIN; |
| 11170 | 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 | 65 | PUTBACK; |
| 66 | FREETMPS; | |
| 67 | LEAVE; | |
| 11170 | 68 | } |
| 69 | ||
| 12803 | 70 | GList * |
| 15884 | 71 | purple_perl_plugin_actions(PurplePlugin *plugin, gpointer context) |
| 12803 | 72 | { |
| 12988 | 73 | GList *l = NULL; |
| 15884 | 74 | PurplePerlScript *gps; |
| 12988 | 75 | int i = 0, count = 0; |
| 76 | dSP; | |
| 77 | ||
|
23931
8975bb78b51a
Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents:
23930
diff
changeset
|
78 | gps = plugin->info->extra_info; |
| 12988 | 79 | |
| 80 | ENTER; | |
| 81 | SAVETMPS; | |
| 82 | ||
| 83 | PUSHMARK(SP); | |
| 15884 | 84 | XPUSHs(sv_2mortal(purple_perl_bless_object(plugin, "Purple::Plugin"))); |
| 12988 | 85 | /* XXX This *will* cease working correctly if context gets changed to |
| 15884 | 86 | * ever be able to hold anything other than a PurpleConnection */ |
| 12988 | 87 | if (context != NULL) |
| 15884 | 88 | XPUSHs(sv_2mortal(purple_perl_bless_object(context, |
| 89 | "Purple::Connection"))); | |
| 12988 | 90 | else |
| 91 | XPUSHs(&PL_sv_undef); | |
| 92 | PUTBACK; | |
| 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 | 95 | |
| 12988 | 96 | SPAGAIN; |
| 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 | 104 | if (count == 0) |
| 105 | croak("The plugin_actions sub didn't return anything.\n"); | |
| 106 | ||
| 107 | for (i = 0; i < count; i++) { | |
| 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 | 110 | |
| 12988 | 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 | 113 | l = g_list_prepend(l, act); |
| 12988 | 114 | } |
| 115 | ||
| 116 | PUTBACK; | |
| 117 | FREETMPS; | |
| 118 | LEAVE; | |
| 119 | ||
| 120 | return l; | |
| 11170 | 121 | } |
| 122 | ||
| 15884 | 123 | #ifdef PURPLE_GTKPERL |
| 12803 | 124 | GtkWidget * |
| 15884 | 125 | purple_perl_gtk_get_plugin_frame(PurplePlugin *plugin) |
| 12803 | 126 | { |
| 11170 | 127 | SV * sv; |
| 12874 | 128 | int count; |
| 11170 | 129 | MAGIC *mg; |
| 12874 | 130 | GtkWidget *ret; |
| 15884 | 131 | PurplePerlScript *gps; |
| 11170 | 132 | dSP; |
| 12874 | 133 | |
|
23931
8975bb78b51a
Cleanup unnecessary casts and etc.
Daniel Atallah <datallah@pidgin.im>
parents:
23930
diff
changeset
|
134 | gps = plugin->info->extra_info; |
| 11170 | 135 | |
| 136 | ENTER; | |
| 137 | SAVETMPS; | |
| 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 | 140 | if (count != 1) |
| 141 | croak("call_pv: Did not return the correct number of values.\n"); | |
| 12803 | 142 | |
| 11170 | 143 | /* the frame was created in a perl sub and is returned */ |
| 144 | SPAGAIN; | |
| 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 | 152 | /* We have a Gtk2::Frame on top of the stack */ |
| 12803 | 153 | sv = POPs; |
| 11170 | 154 | |
| 12874 | 155 | /* The magic field hides the pointer to the actual GtkWidget */ |
| 11170 | 156 | mg = mg_find(SvRV(sv), PERL_MAGIC_ext); |
| 157 | ret = (GtkWidget *)mg->mg_ptr; | |
| 158 | ||
| 159 | PUTBACK; | |
| 160 | FREETMPS; | |
| 12803 | 161 | LEAVE; |
| 162 | ||
| 11170 | 163 | return ret; |
| 164 | } | |
|
14426
8d4f164c4979
[gaim-migrate @ 17070]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
165 | #endif |
| 11170 | 166 | |
| 15884 | 167 | PurplePluginPrefFrame * |
| 168 | purple_perl_get_plugin_frame(PurplePlugin *plugin) | |
| 12803 | 169 | { |
| 170 | /* Sets up the Perl Stack for our call back into the script to run the | |
| 171 | * plugin_pref... sub */ | |
| 12872 | 172 | int count; |
| 15884 | 173 | PurplePerlScript *gps; |
| 174 | PurplePluginPrefFrame *ret_frame; | |
| 11123 | 175 | dSP; |
| 176 | ||
| 15884 | 177 | gps = (PurplePerlScript *)plugin->info->extra_info; |
| 12872 | 178 | |
| 11123 | 179 | ENTER; |
| 180 | SAVETMPS; | |
| 12803 | 181 | /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and |
| 182 | * return the frame */ | |
| 11123 | 183 | PUSHMARK(SP); |
| 184 | PUTBACK; | |
| 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 | 187 | |
| 188 | SPAGAIN; | |
| 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 | 196 | if (count != 1) |
| 197 | croak("call_pv: Did not return the correct number of values.\n"); | |
| 198 | /* the frame was created in a perl sub and is returned */ | |
| 15884 | 199 | ret_frame = (PurplePluginPrefFrame *)purple_perl_ref_object(POPs); |
| 11123 | 200 | |
| 201 | /* Tidy up the Perl stack */ | |
| 202 | PUTBACK; | |
| 203 | FREETMPS; | |
| 204 | LEAVE; | |
| 12871 | 205 | |
| 11123 | 206 | return ret_frame; |
| 207 | } | |
| 6520 | 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 | 210 | destroy_timeout_handler(PurplePerlTimeoutHandler *handler) |
| 6520 | 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 | 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 | 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 | 228 | } |
| 229 | ||
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
230 | static void |
| 15884 | 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 | 246 | perl_timeout_cb(gpointer data) |
| 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 | 250 | |
| 251 | dSP; | |
| 252 | ENTER; | |
| 253 | SAVETMPS; | |
| 254 | PUSHMARK(sp); | |
|
6568
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
255 | XPUSHs((SV *)handler->data); |
| 6520 | 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 | 258 | SPAGAIN; |
| 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 | 268 | PUTBACK; |
| 269 | FREETMPS; | |
| 270 | LEAVE; | |
| 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 | 276 | } |
| 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 | 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 | ©_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 | 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 | 336 | if (SvTRUE(ERRSV)) { |
| 15884 | 337 | purple_debug_error("perl", |
| 12803 | 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 | 344 | for (i = 0; i < value_count; i++) { |
| 15884 | 345 | if (purple_value_is_outgoing(values[i])) { |
| 346 | switch (purple_value_get_type(values[i])) { | |
| 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 386 | case PURPLE_TYPE_POINTER: |
| 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 | 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 | 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 | 419 | static PurplePerlSignalHandler * |
| 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 | 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 | 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 | 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 | 439 | purple_perl_timeout_add(PurplePlugin *plugin, int seconds, SV *callback, SV *data) |
| 6520 | 440 | { |
| 15884 | 441 | PurplePerlTimeoutHandler *handler; |
| 6520 | 442 | |
| 12803 | 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 | 446 | } |
| 447 | ||
| 15884 | 448 | handler = g_new0(PurplePerlTimeoutHandler, 1); |
| 6520 | 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 | 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 | 454 | ? newSVsv(data) : NULL); |
| 6520 | 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 | 480 | } |
| 481 | ||
| 482 | void | |
| 15884 | 483 | purple_perl_timeout_clear_for_plugin(PurplePlugin *plugin) |
| 6520 | 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 | 487 | |
| 12803 | 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 | 490 | l_next = l->next; |
| 491 | ||
| 492 | if (handler->plugin == plugin) | |
| 493 | destroy_timeout_handler(handler); | |
| 494 | } | |
| 495 | } | |
| 496 | ||
| 497 | void | |
| 15884 | 498 | purple_perl_timeout_clear(void) |
| 6520 | 499 | { |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
500 | while (timeout_handlers != NULL) |
| 6520 | 501 | destroy_timeout_handler(timeout_handlers->data); |
| 502 | } | |
| 503 | ||
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
504 | void |
| 15884 | 505 | purple_perl_signal_connect(PurplePlugin *plugin, void *instance, |
| 13191 | 506 | const char *signal, SV *callback, SV *data, |
| 507 | int priority) | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
508 | { |
| 15884 | 509 | PurplePerlSignalHandler *handler; |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
510 | |
| 15884 | 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 | 515 | handler->callback = (callback != NULL && |
| 516 | callback != &PL_sv_undef ? newSVsv(callback) | |
| 517 | : NULL); | |
| 518 | handler->data = (data != NULL && | |
| 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 | 523 | purple_signal_connect_priority_vargs(instance, signal, plugin, |
| 524 | PURPLE_CALLBACK(perl_signal_cb), | |
| 13191 | 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 | 529 | purple_perl_signal_disconnect(PurplePlugin *plugin, void *instance, |
| 12803 | 530 | const char *signal) |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
531 | { |
| 15884 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 566 | |
| 15884 | 567 | static PurpleCmdRet |
| 568 | perl_cmd_cb(PurpleConversation *conv, const gchar *command, | |
| 12882 | 569 | gchar **args, gchar **error, void *data) |
| 570 | { | |
| 15884 | 571 | int i = 0, count, ret_value = PURPLE_CMD_RET_OK; |
| 12882 | 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 | 574 | |
| 575 | dSP; | |
| 576 | ENTER; | |
| 577 | SAVETMPS; | |
| 578 | PUSHMARK(SP); | |
| 579 | ||
| 580 | /* Push the conversation onto the perl stack */ | |
| 15884 | 581 | convSV = sv_2mortal(purple_perl_bless_object(conv, "Purple::Conversation")); |
| 12882 | 582 | XPUSHs(convSV); |
| 583 | ||
| 584 | /* Push the command string onto the perl stack */ | |
| 585 | cmdSV = newSVpv(command, 0); | |
| 586 | cmdSV = sv_2mortal(cmdSV); | |
| 587 | XPUSHs(cmdSV); | |
| 588 | ||
| 589 | /* Push the data onto the perl stack */ | |
| 590 | XPUSHs((SV *)handler->data); | |
| 591 | ||
| 592 | /* Push any arguments we may have */ | |
| 593 | for (i = 0; args[i] != NULL; i++) { | |
| 594 | /* XXX The mortality of these created SV's should prevent | |
| 595 | * memory issues, if I read/understood everything correctly... | |
| 596 | */ | |
| 597 | tmpSV = newSVpv(args[i], 0); | |
| 598 | tmpSV = sv_2mortal(tmpSV); | |
| 599 | XPUSHs(tmpSV); | |
| 600 | } | |
| 601 | ||
| 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 | 604 | |
| 605 | if (count != 1) | |
| 606 | croak("call_sv: Did not return the correct number of values.\n"); | |
| 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 | 614 | SPAGAIN; |
| 615 | ||
| 616 | ret_value = POPi; | |
| 617 | ||
| 618 | PUTBACK; | |
| 619 | FREETMPS; | |
| 620 | LEAVE; | |
| 621 | ||
| 622 | return ret_value; | |
| 623 | } | |
| 624 | ||
| 15884 | 625 | PurpleCmdId |
| 626 | purple_perl_cmd_register(PurplePlugin *plugin, const gchar *command, | |
| 627 | const gchar *args, PurpleCmdPriority priority, | |
| 628 | PurpleCmdFlag flag, const gchar *prpl_id, SV *callback, | |
| 12882 | 629 | const gchar *helpstr, SV *data) |
| 630 | { | |
| 15884 | 631 | PurplePerlCmdHandler *handler; |
| 12882 | 632 | |
| 15884 | 633 | handler = g_new0(PurplePerlCmdHandler, 1); |
| 12882 | 634 | handler->plugin = plugin; |
| 635 | handler->cmd = g_strdup(command); | |
| 636 | handler->prpl_id = g_strdup(prpl_id); | |
| 637 | ||
| 638 | if (callback != NULL && callback != &PL_sv_undef) | |
| 639 | handler->callback = newSVsv(callback); | |
| 640 | else | |
| 641 | handler->callback = NULL; | |
| 642 | ||
| 643 | if (data != NULL && data != &PL_sv_undef) | |
| 644 | handler->data = newSVsv(data); | |
| 645 | else | |
| 646 | handler->data = NULL; | |
| 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 | 649 | |
| 15884 | 650 | handler->id = purple_cmd_register(command, args, priority, flag, prpl_id, |
| 651 | PURPLE_CMD_FUNC(perl_cmd_cb), helpstr, | |
| 12882 | 652 | handler); |
| 653 | ||
| 654 | return handler->id; | |
| 655 | } | |
| 656 | ||
| 657 | static void | |
| 15884 | 658 | destroy_cmd_handler(PurplePerlCmdHandler *handler) |
| 12882 | 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 | 662 | |
| 663 | if (handler->callback != NULL) | |
| 664 | SvREFCNT_dec(handler->callback); | |
| 665 | ||
| 666 | if (handler->data != NULL) | |
| 667 | SvREFCNT_dec(handler->data); | |
| 668 | ||
| 669 | g_free(handler->cmd); | |
| 670 | g_free(handler->prpl_id); | |
| 671 | g_free(handler); | |
| 672 | } | |
| 673 | ||
| 674 | void | |
| 15884 | 675 | purple_perl_cmd_clear_for_plugin(PurplePlugin *plugin) |
| 12882 | 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 | 679 | |
| 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 | 682 | l_next = l->next; |
| 683 | ||
| 684 | if (handler->plugin == plugin) | |
| 685 | destroy_cmd_handler(handler); | |
| 686 | } | |
| 687 | } | |
| 688 | ||
| 15884 | 689 | static PurplePerlCmdHandler * |
| 690 | find_cmd_handler(PurpleCmdId id) | |
| 12882 | 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 | 694 | |
| 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 | 697 | |
| 698 | if (handler->id == id) | |
| 699 | return handler; | |
| 700 | } | |
| 701 | ||
| 702 | return NULL; | |
| 703 | } | |
| 704 | ||
| 705 | void | |
| 15884 | 706 | purple_perl_cmd_unregister(PurpleCmdId id) |
| 12882 | 707 | { |
| 15884 | 708 | PurplePerlCmdHandler *handler; |
| 12882 | 709 | |
| 710 | handler = find_cmd_handler(id); | |
| 711 | ||
| 712 | if (handler == NULL) { | |
| 713 | croak("Invalid command id in removing a perl command handler.\n"); | |
| 714 | return; | |
| 715 | } | |
| 716 | ||
| 717 | destroy_cmd_handler(handler); | |
| 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 | } |