| 75 "Purple::Connection"))); |
84 "Purple::Connection"))); |
| 76 else |
85 else |
| 77 XPUSHs(&PL_sv_undef); |
86 XPUSHs(&PL_sv_undef); |
| 78 PUTBACK; |
87 PUTBACK; |
| 79 |
88 |
| 80 count = call_pv(gps->plugin_action_sub, G_ARRAY); |
89 count = call_pv(gps->plugin_action_sub, G_EVAL | G_ARRAY); |
| 81 |
90 |
| 82 SPAGAIN; |
91 SPAGAIN; |
| |
92 |
| |
93 if (SvTRUE(ERRSV)) { |
| |
94 purple_debug_error("perl", |
| |
95 "Perl plugin actions lookup exited abnormally: %s\n", |
| |
96 SvPV(ERRSV, na)); |
| |
97 } |
| 83 |
98 |
| 84 if (count == 0) |
99 if (count == 0) |
| 85 croak("The plugin_actions sub didn't return anything.\n"); |
100 croak("The plugin_actions sub didn't return anything.\n"); |
| 86 |
101 |
| 87 for (i = 0; i < count; i++) { |
102 for (i = 0; i < count; i++) { |
| 111 SV * sv; |
126 SV * sv; |
| 112 int count; |
127 int count; |
| 113 MAGIC *mg; |
128 MAGIC *mg; |
| 114 GtkWidget *ret; |
129 GtkWidget *ret; |
| 115 PurplePerlScript *gps; |
130 PurplePerlScript *gps; |
| |
131 STRLEN na; |
| 116 dSP; |
132 dSP; |
| 117 |
133 |
| 118 gps = (PurplePerlScript *)plugin->info->extra_info; |
134 gps = (PurplePerlScript *)plugin->info->extra_info; |
| 119 |
135 |
| 120 ENTER; |
136 ENTER; |
| 121 SAVETMPS; |
137 SAVETMPS; |
| 122 |
138 |
| 123 count = call_pv(gps->gtk_prefs_sub, G_SCALAR | G_NOARGS); |
139 count = call_pv(gps->gtk_prefs_sub, G_EVAL | G_SCALAR | G_NOARGS); |
| 124 if (count != 1) |
140 if (count != 1) |
| 125 croak("call_pv: Did not return the correct number of values.\n"); |
141 croak("call_pv: Did not return the correct number of values.\n"); |
| 126 |
142 |
| 127 /* the frame was created in a perl sub and is returned */ |
143 /* the frame was created in a perl sub and is returned */ |
| 128 SPAGAIN; |
144 SPAGAIN; |
| |
145 |
| |
146 if (SvTRUE(ERRSV)) { |
| |
147 purple_debug_error("perl", |
| |
148 "Perl gtk plugin frame init exited abnormally: %s\n", |
| |
149 SvPV(ERRSV, na)); |
| |
150 } |
| 129 |
151 |
| 130 /* We have a Gtk2::Frame on top of the stack */ |
152 /* We have a Gtk2::Frame on top of the stack */ |
| 131 sv = POPs; |
153 sv = POPs; |
| 132 |
154 |
| 133 /* The magic field hides the pointer to the actual GtkWidget */ |
155 /* The magic field hides the pointer to the actual GtkWidget */ |
| 148 /* Sets up the Perl Stack for our call back into the script to run the |
170 /* Sets up the Perl Stack for our call back into the script to run the |
| 149 * plugin_pref... sub */ |
171 * plugin_pref... sub */ |
| 150 int count; |
172 int count; |
| 151 PurplePerlScript *gps; |
173 PurplePerlScript *gps; |
| 152 PurplePluginPrefFrame *ret_frame; |
174 PurplePluginPrefFrame *ret_frame; |
| |
175 STRLEN na; |
| 153 dSP; |
176 dSP; |
| 154 |
177 |
| 155 gps = (PurplePerlScript *)plugin->info->extra_info; |
178 gps = (PurplePerlScript *)plugin->info->extra_info; |
| 156 |
179 |
| 157 ENTER; |
180 ENTER; |
| 159 /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and |
182 /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and |
| 160 * return the frame */ |
183 * return the frame */ |
| 161 PUSHMARK(SP); |
184 PUSHMARK(SP); |
| 162 PUTBACK; |
185 PUTBACK; |
| 163 |
186 |
| 164 count = call_pv(gps->prefs_sub, G_SCALAR | G_NOARGS); |
187 count = call_pv(gps->prefs_sub, G_EVAL | G_SCALAR | G_NOARGS); |
| 165 |
188 |
| 166 SPAGAIN; |
189 SPAGAIN; |
| |
190 |
| |
191 if (SvTRUE(ERRSV)) { |
| |
192 purple_debug_error("perl", |
| |
193 "Perl plugin prefs frame init exited abnormally: %s\n", |
| |
194 SvPV(ERRSV, na)); |
| |
195 } |
| 167 |
196 |
| 168 if (count != 1) |
197 if (count != 1) |
| 169 croak("call_pv: Did not return the correct number of values.\n"); |
198 croak("call_pv: Did not return the correct number of values.\n"); |
| 170 /* the frame was created in a perl sub and is returned */ |
199 /* the frame was created in a perl sub and is returned */ |
| 171 ret_frame = (PurplePluginPrefFrame *)purple_perl_ref_object(POPs); |
200 ret_frame = (PurplePluginPrefFrame *)purple_perl_ref_object(POPs); |
| 213 static gboolean |
242 static gboolean |
| 214 perl_timeout_cb(gpointer data) |
243 perl_timeout_cb(gpointer data) |
| 215 { |
244 { |
| 216 PurplePerlTimeoutHandler *handler = (PurplePerlTimeoutHandler *)data; |
245 PurplePerlTimeoutHandler *handler = (PurplePerlTimeoutHandler *)data; |
| 217 gboolean ret = FALSE; |
246 gboolean ret = FALSE; |
| |
247 STRLEN na; |
| 218 |
248 |
| 219 dSP; |
249 dSP; |
| 220 ENTER; |
250 ENTER; |
| 221 SAVETMPS; |
251 SAVETMPS; |
| 222 PUSHMARK(sp); |
252 PUSHMARK(sp); |
| 223 XPUSHs((SV *)handler->data); |
253 XPUSHs((SV *)handler->data); |
| 224 PUTBACK; |
254 PUTBACK; |
| 225 call_sv(handler->callback, G_EVAL | G_SCALAR); |
255 call_sv(handler->callback, G_EVAL | G_SCALAR); |
| 226 SPAGAIN; |
256 SPAGAIN; |
| |
257 |
| |
258 if (SvTRUE(ERRSV)) { |
| |
259 purple_debug_error("perl", |
| |
260 "Perl timeout function exited abnormally: %s\n", |
| |
261 SvPV(ERRSV, na)); |
| |
262 } |
| 227 |
263 |
| 228 ret = POPi; |
264 ret = POPi; |
| 229 |
265 |
| 230 PUTBACK; |
266 PUTBACK; |
| 231 FREETMPS; |
267 FREETMPS; |
| 499 static PurpleCmdRet |
535 static PurpleCmdRet |
| 500 perl_cmd_cb(PurpleConversation *conv, const gchar *command, |
536 perl_cmd_cb(PurpleConversation *conv, const gchar *command, |
| 501 gchar **args, gchar **error, void *data) |
537 gchar **args, gchar **error, void *data) |
| 502 { |
538 { |
| 503 int i = 0, count, ret_value = PURPLE_CMD_RET_OK; |
539 int i = 0, count, ret_value = PURPLE_CMD_RET_OK; |
| |
540 STRLEN na; |
| 504 SV *cmdSV, *tmpSV, *convSV; |
541 SV *cmdSV, *tmpSV, *convSV; |
| 505 PurplePerlCmdHandler *handler = (PurplePerlCmdHandler *)data; |
542 PurplePerlCmdHandler *handler = (PurplePerlCmdHandler *)data; |
| 506 |
543 |
| 507 dSP; |
544 dSP; |
| 508 ENTER; |
545 ENTER; |
| 530 tmpSV = sv_2mortal(tmpSV); |
567 tmpSV = sv_2mortal(tmpSV); |
| 531 XPUSHs(tmpSV); |
568 XPUSHs(tmpSV); |
| 532 } |
569 } |
| 533 |
570 |
| 534 PUTBACK; |
571 PUTBACK; |
| 535 count = call_sv(handler->callback, G_EVAL|G_SCALAR); |
572 count = call_sv(handler->callback, G_EVAL | G_SCALAR); |
| 536 |
573 |
| 537 if (count != 1) |
574 if (count != 1) |
| 538 croak("call_sv: Did not return the correct number of values.\n"); |
575 croak("call_sv: Did not return the correct number of values.\n"); |
| |
576 |
| |
577 if (SvTRUE(ERRSV)) { |
| |
578 purple_debug_error("perl", |
| |
579 "Perl plugin command function exited abnormally: %s\n", |
| |
580 SvPV(ERRSV, na)); |
| |
581 } |
| 539 |
582 |
| 540 SPAGAIN; |
583 SPAGAIN; |
| 541 |
584 |
| 542 ret_value = POPi; |
585 ret_value = POPi; |
| 543 |
586 |