libpurple/plugins/perl/perl.c

changeset 33906
dc870eacc2d0
parent 28642
b23df5d1387e
child 34477
86f6c431da7b
child 36367
891eea799578
equal deleted inserted replaced
33905:eb212da4069d 33906:dc870eacc2d0
101 101
102 #define PERL_PLUGIN_ID "core-perl" 102 #define PERL_PLUGIN_ID "core-perl"
103 103
104 PerlInterpreter *my_perl = NULL; 104 PerlInterpreter *my_perl = NULL;
105 105
106 struct _PurplePerlInfoStrings
107 {
108 char *name;
109 char *id;
110 char *homepage;
111 char *author;
112 char *summary;
113 char *description;
114 char *version;
115 };
116
106 static PurplePluginUiInfo ui_info = 117 static PurplePluginUiInfo ui_info =
107 { 118 {
108 purple_perl_get_plugin_frame, 119 purple_perl_get_plugin_frame,
109 0, /* page_num (Reserved) */ 120 0, /* page_num (Reserved) */
110 NULL, /* frame (Reserved) */ 121 NULL, /* frame (Reserved) */
120 { 131 {
121 purple_perl_gtk_get_plugin_frame, 132 purple_perl_gtk_get_plugin_frame,
122 0 /* page_num (Reserved) */ 133 0 /* page_num (Reserved) */
123 }; 134 };
124 #endif 135 #endif
136
137 static void perl_infostrings_free(PurplePerlInfoStrings *info_strings)
138 {
139 if (info_strings == NULL)
140 return;
141
142 g_free(info_strings->name);
143 g_free(info_strings->id);
144 g_free(info_strings->homepage);
145 g_free(info_strings->author);
146 g_free(info_strings->summary);
147 g_free(info_strings->description);
148 g_free(info_strings->version);
149 g_free(info_strings);
150 }
125 151
126 static void 152 static void
127 #ifdef OLD_PERL 153 #ifdef OLD_PERL
128 xs_init() 154 xs_init()
129 #else 155 #else
348 PurplePerlScript *gps; 374 PurplePerlScript *gps;
349 char *basename; 375 char *basename;
350 376
351 info = g_new0(PurplePluginInfo, 1); 377 info = g_new0(PurplePluginInfo, 1);
352 gps = g_new0(PurplePerlScript, 1); 378 gps = g_new0(PurplePerlScript, 1);
379 gps->info_strings = g_new0(PurplePerlInfoStrings, 1);
353 380
354 info->magic = PURPLE_PLUGIN_MAGIC; 381 info->magic = PURPLE_PLUGIN_MAGIC;
355 info->major_version = PURPLE_MAJOR_VERSION; 382 info->major_version = PURPLE_MAJOR_VERSION;
356 info->minor_version = PURPLE_MINOR_VERSION; 383 info->minor_version = PURPLE_MINOR_VERSION;
357 info->type = PURPLE_PLUGIN_STANDARD; 384 info->type = PURPLE_PLUGIN_STANDARD;
367 basename); 394 basename);
368 g_free(basename); 395 g_free(basename);
369 396
370 /* We know this one exists. */ 397 /* We know this one exists. */
371 key = hv_fetch(plugin_info, "name", strlen("name"), 0); 398 key = hv_fetch(plugin_info, "name", strlen("name"), 0);
372 info->name = g_strdup(SvPVutf8_nolen(*key)); 399 info->name = gps->info_strings->name = g_strdup(SvPVutf8_nolen(*key));
373 /* Set id here in case we don't find one later. */ 400 /* Set id here in case we don't find one later. */
374 info->id = g_strdup(info->name); 401 info->id = gps->info_strings->id = g_strdup(info->name);
375 402
376 #ifdef PURPLE_GTKPERL 403 #ifdef PURPLE_GTKPERL
377 if ((key = hv_fetch(plugin_info, "GTK_UI", 404 if ((key = hv_fetch(plugin_info, "GTK_UI",
378 strlen("GTK_UI"), 0))) 405 strlen("GTK_UI"), 0)))
379 info->ui_requirement = PURPLE_GTK_PLUGIN_TYPE; 406 info->ui_requirement = PURPLE_GTK_PLUGIN_TYPE;
380 #endif 407 #endif
381 408
382 if ((key = hv_fetch(plugin_info, "url", 409 if ((key = hv_fetch(plugin_info, "url",
383 strlen("url"), 0))) 410 strlen("url"), 0)))
384 info->homepage = g_strdup(SvPVutf8_nolen(*key)); 411 info->homepage = gps->info_strings->homepage = g_strdup(SvPVutf8_nolen(*key));
385 412
386 if ((key = hv_fetch(plugin_info, "author", 413 if ((key = hv_fetch(plugin_info, "author",
387 strlen("author"), 0))) 414 strlen("author"), 0)))
388 info->author = g_strdup(SvPVutf8_nolen(*key)); 415 info->author = gps->info_strings->author = g_strdup(SvPVutf8_nolen(*key));
389 416
390 if ((key = hv_fetch(plugin_info, "summary", 417 if ((key = hv_fetch(plugin_info, "summary",
391 strlen("summary"), 0))) 418 strlen("summary"), 0)))
392 info->summary = g_strdup(SvPVutf8_nolen(*key)); 419 info->summary = gps->info_strings->summary = g_strdup(SvPVutf8_nolen(*key));
393 420
394 if ((key = hv_fetch(plugin_info, "description", 421 if ((key = hv_fetch(plugin_info, "description",
395 strlen("description"), 0))) 422 strlen("description"), 0)))
396 info->description = g_strdup(SvPVutf8_nolen(*key)); 423 info->description = gps->info_strings->description = g_strdup(SvPVutf8_nolen(*key));
397 424
398 if ((key = hv_fetch(plugin_info, "version", 425 if ((key = hv_fetch(plugin_info, "version",
399 strlen("version"), 0))) 426 strlen("version"), 0)))
400 info->version = g_strdup(SvPVutf8_nolen(*key)); 427 info->version = gps->info_strings->version = g_strdup(SvPVutf8_nolen(*key));
401 428
402 /* We know this one exists. */ 429 /* We know this one exists. */
403 key = hv_fetch(plugin_info, "load", strlen("load"), 0); 430 key = hv_fetch(plugin_info, "load", strlen("load"), 0);
404 gps->load_sub = g_strdup_printf("%s::%s", gps->package, 431 gps->load_sub = g_strdup_printf("%s::%s", gps->package,
405 SvPVutf8_nolen(*key)); 432 SvPVutf8_nolen(*key));
410 gps->package, 437 gps->package,
411 SvPVutf8_nolen(*key)); 438 SvPVutf8_nolen(*key));
412 439
413 if ((key = hv_fetch(plugin_info, "id", 440 if ((key = hv_fetch(plugin_info, "id",
414 strlen("id"), 0))) { 441 strlen("id"), 0))) {
415 g_free(info->id); 442 g_free(gps->info_strings->id);
416 info->id = g_strdup_printf("perl-%s", 443 info->id = gps->info_strings->id = g_strdup_printf("perl-%s",
417 SvPVutf8_nolen(*key)); 444 SvPVutf8_nolen(*key));
418 } 445 }
419 446
420 /********************************************************/ 447 /********************************************************/
421 /* Only one of the next two options should be present */ 448 /* Only one of the next two options should be present */
598 destroy_perl_plugin(PurplePlugin *plugin) 625 destroy_perl_plugin(PurplePlugin *plugin)
599 { 626 {
600 if (plugin->info != NULL) { 627 if (plugin->info != NULL) {
601 PurplePerlScript *gps; 628 PurplePerlScript *gps;
602 629
603 g_free(plugin->info->name);
604 g_free(plugin->info->id);
605 g_free(plugin->info->homepage);
606 g_free(plugin->info->author);
607 g_free(plugin->info->summary);
608 g_free(plugin->info->description);
609 g_free(plugin->info->version);
610
611 gps = (PurplePerlScript *)plugin->info->extra_info; 630 gps = (PurplePerlScript *)plugin->info->extra_info;
612 if (gps != NULL) { 631 if (gps != NULL) {
632 perl_infostrings_free(gps->info_strings);
633 gps->info_strings = NULL;
634
613 g_free(gps->package); 635 g_free(gps->package);
614 g_free(gps->load_sub); 636 g_free(gps->load_sub);
615 g_free(gps->unload_sub); 637 g_free(gps->unload_sub);
616 g_free(gps->prefs_sub); 638 g_free(gps->prefs_sub);
617 #ifdef PURPLE_GTKPERL 639 #ifdef PURPLE_GTKPERL

mercurial