| 92 SPAGAIN; |
90 SPAGAIN; |
| 93 |
91 |
| 94 if (SvTRUE(ERRSV)) { |
92 if (SvTRUE(ERRSV)) { |
| 95 purple_debug_error("perl", |
93 purple_debug_error("perl", |
| 96 "Perl plugin actions lookup exited abnormally: %s\n", |
94 "Perl plugin actions lookup exited abnormally: %s\n", |
| 97 SvPV(ERRSV, na)); |
95 SvPVutf8_nolen(ERRSV)); |
| 98 } |
96 } |
| 99 |
97 |
| 100 if (count == 0) |
98 if (count == 0) |
| 101 croak("The plugin_actions sub didn't return anything.\n"); |
99 croak("The plugin_actions sub didn't return anything.\n"); |
| 102 |
100 |
| 103 for (i = 0; i < count; i++) { |
101 for (i = 0; i < count; i++) { |
| 104 SV *sv; |
102 SV *sv; |
| 105 gchar *label; |
103 PurplePluginAction *act; |
| 106 PurplePluginAction *act = NULL; |
|
| 107 |
104 |
| 108 sv = POPs; |
105 sv = POPs; |
| 109 label = SvPV_nolen(sv); |
106 act = purple_plugin_action_new(SvPVutf8_nolen(sv), purple_perl_plugin_action_cb); |
| 110 /* XXX I think this leaks, but doing it without the strdup |
|
| 111 * just showed garbage */ |
|
| 112 act = purple_plugin_action_new(g_strdup(label), purple_perl_plugin_action_cb); |
|
| 113 l = g_list_prepend(l, act); |
107 l = g_list_prepend(l, act); |
| 114 } |
108 } |
| 115 |
109 |
| 116 PUTBACK; |
110 PUTBACK; |
| 117 FREETMPS; |
111 FREETMPS; |
| 171 /* Sets up the Perl Stack for our call back into the script to run the |
164 /* Sets up the Perl Stack for our call back into the script to run the |
| 172 * plugin_pref... sub */ |
165 * plugin_pref... sub */ |
| 173 int count; |
166 int count; |
| 174 PurplePerlScript *gps; |
167 PurplePerlScript *gps; |
| 175 PurplePluginPrefFrame *ret_frame; |
168 PurplePluginPrefFrame *ret_frame; |
| 176 STRLEN na; |
|
| 177 dSP; |
169 dSP; |
| 178 |
170 |
| 179 gps = (PurplePerlScript *)plugin->info->extra_info; |
171 gps = (PurplePerlScript *)plugin->info->extra_info; |
| 180 |
172 |
| 181 ENTER; |
173 ENTER; |
| 190 SPAGAIN; |
182 SPAGAIN; |
| 191 |
183 |
| 192 if (SvTRUE(ERRSV)) { |
184 if (SvTRUE(ERRSV)) { |
| 193 purple_debug_error("perl", |
185 purple_debug_error("perl", |
| 194 "Perl plugin prefs frame init exited abnormally: %s\n", |
186 "Perl plugin prefs frame init exited abnormally: %s\n", |
| 195 SvPV(ERRSV, na)); |
187 SvPVutf8_nolen(ERRSV)); |
| 196 } |
188 } |
| 197 |
189 |
| 198 if (count != 1) |
190 if (count != 1) |
| 199 croak("call_pv: Did not return the correct number of values.\n"); |
191 croak("call_pv: Did not return the correct number of values.\n"); |
| 200 /* the frame was created in a perl sub and is returned */ |
192 /* the frame was created in a perl sub and is returned */ |
| 332 } |
322 } |
| 333 |
323 |
| 334 if (SvTRUE(ERRSV)) { |
324 if (SvTRUE(ERRSV)) { |
| 335 purple_debug_error("perl", |
325 purple_debug_error("perl", |
| 336 "Perl function exited abnormally: %s\n", |
326 "Perl function exited abnormally: %s\n", |
| 337 SvPV(ERRSV, na)); |
327 SvPVutf8_nolen(ERRSV)); |
| 338 } |
328 } |
| 339 |
329 |
| 340 /* See if any parameters changed. */ |
330 /* See if any parameters changed. */ |
| 341 for (i = 0; i < value_count; i++) { |
331 for (i = 0; i < value_count; i++) { |
| 342 if (purple_value_is_outgoing(values[i])) { |
332 if (purple_value_is_outgoing(values[i])) { |
| 371 |
361 |
| 372 case PURPLE_TYPE_STRING: |
362 case PURPLE_TYPE_STRING: |
| 373 if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) { |
363 if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) { |
| 374 g_free(*((char **)copy_args[i])); |
364 g_free(*((char **)copy_args[i])); |
| 375 *((char **)copy_args[i]) = |
365 *((char **)copy_args[i]) = |
| 376 g_strdup(SvPV(sv_args[i], na)); |
366 g_strdup(SvPVutf8_nolen(sv_args[i])); |
| 377 } |
367 } |
| |
368 /* Clean up sv_args[i] - we're done with it */ |
| |
369 sv_2mortal(sv_args[i]); |
| 378 break; |
370 break; |
| 379 |
371 |
| 380 case PURPLE_TYPE_POINTER: |
372 case PURPLE_TYPE_POINTER: |
| 381 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]); |
|
| 382 break; |
|
| 383 |
|
| 384 case PURPLE_TYPE_BOXED: |
373 case PURPLE_TYPE_BOXED: |
| 385 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]); |
374 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]); |
| 386 break; |
375 break; |
| 387 case PURPLE_TYPE_SUBTYPE: |
376 case PURPLE_TYPE_SUBTYPE: |
| 388 *((void **)copy_args[i]) = purple_perl_ref_object(sv_args[i]); |
377 *((void **)copy_args[i]) = purple_perl_ref_object(sv_args[i]); |
| 389 break; |
378 break; |
| 390 |
379 |
| 391 default: |
380 default: |
| 392 break; |
381 break; |
| 393 } |
382 } |
| |
383 |
| 394 |
384 |
| 395 #if 0 |
385 #if 0 |
| 396 *((void **)copy_args[i]) = purple_perl_data_from_sv(values[i], |
386 *((void **)copy_args[i]) = purple_perl_data_from_sv(values[i], |
| 397 sv_args[i]); |
387 sv_args[i]); |
| 398 #endif |
388 #endif |
| 562 static PurpleCmdRet |
552 static PurpleCmdRet |
| 563 perl_cmd_cb(PurpleConversation *conv, const gchar *command, |
553 perl_cmd_cb(PurpleConversation *conv, const gchar *command, |
| 564 gchar **args, gchar **error, void *data) |
554 gchar **args, gchar **error, void *data) |
| 565 { |
555 { |
| 566 int i = 0, count, ret_value = PURPLE_CMD_RET_OK; |
556 int i = 0, count, ret_value = PURPLE_CMD_RET_OK; |
| 567 STRLEN na; |
|
| 568 SV *cmdSV, *tmpSV, *convSV; |
557 SV *cmdSV, *tmpSV, *convSV; |
| 569 PurplePerlCmdHandler *handler = data; |
558 PurplePerlCmdHandler *handler = data; |
| 570 |
559 |
| 571 dSP; |
560 dSP; |
| 572 ENTER; |
561 ENTER; |