Mercurial > pidgin
changeset 12871:2422097a7a5e
[gaim-migrate @ 15223]
Whitespace in some .c and .h files that I hadn't had a reason to touch before,
this is it's own commit mostly to show how easy it was to get perl plugins to
support individual plugin pref frames, as opposed to just one for all the
loaded perl plugins.
And some whitespace that I missed in Conversation.xs.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Sat, 14 Jan 2006 07:12:46 +0000 |
parents | a9cd674078b1 |
children | 59ff3e1c874e |
files | plugins/perl/common/Conversation.xs plugins/perl/perl-common.c plugins/perl/perl-common.h plugins/perl/perl-handlers.c plugins/perl/perl.c |
diffstat | 5 files changed, 144 insertions(+), 154 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/perl/common/Conversation.xs Sat Jan 14 06:28:58 2006 +0000 +++ b/plugins/perl/common/Conversation.xs Sat Jan 14 07:12:46 2006 +0000 @@ -102,7 +102,6 @@ gaim_conversation_is_logging(conv) Gaim::Conversation conv - Gaim::Conversation::IM gaim_conversation_get_im_data(conv) Gaim::Conversation conv @@ -201,12 +200,10 @@ gaim_conv_im_get_type_again_timeout(im) Gaim::Conversation::IM im - void gaim_conv_im_update_typing(im) Gaim::Conversation::IM im - void gaim_conv_im_send(im, message) Gaim::Conversation::IM im @@ -220,7 +217,6 @@ Gaim::MessageFlags flags time_t mtime - MODULE = Gaim::Conversation PACKAGE = Gaim::Conversation PREFIX = gaim_conv_ PROTOTYPES: ENABLE @@ -367,7 +363,6 @@ gaim_conv_chat_add_users(chat, t_GL_users, t_GL_extra_msgs, t_GL_flags, new_arrivals); - gboolean gaim_conv_chat_find_user(chat, user) Gaim::Conversation::Chat chat
--- a/plugins/perl/perl-common.c Sat Jan 14 06:28:58 2006 +0000 +++ b/plugins/perl/perl-common.c Sat Jan 14 07:12:46 2006 +0000 @@ -9,21 +9,19 @@ void gaim_perl_normalize_script_name(char *name) { - char *c; + char *c; - c = strrchr(name, '.'); - - if (c != NULL) - *c = '\0'; + c = strrchr(name, '.'); - for (c = name; *c != '\0'; c++) - { - if (*c != '_' && !g_ascii_isalnum(*c)) - *c = '_'; - } + if (c != NULL) + *c = '\0'; + + for (c = name; *c != '\0'; c++) { + if (*c != '_' && !g_ascii_isalnum(*c)) + *c = '_'; + } } - static int magic_free_object(pTHX_ SV *sv, MAGIC *mg) { @@ -75,8 +73,7 @@ if (object == NULL) return NULL; - if (object_stashes == NULL) - { + if (object_stashes == NULL) { object_stashes = g_hash_table_new(g_direct_hash, g_direct_equal); } @@ -96,8 +93,7 @@ hv = hvref(o); - if (hv != NULL) - { + if (hv != NULL) { sv = hv_fetch(hv, "_gaim", 5, 0); if (sv != NULL) @@ -197,7 +193,7 @@ } PUTBACK; - PERL_SET_CONTEXT(my_perl); + PERL_SET_CONTEXT(my_perl); count = call_pv(function, G_EVAL | G_SCALAR); SPAGAIN; @@ -210,8 +206,7 @@ "Perl function %s exited abnormally: %s\n", function, SvPV(ERRSV, na)); POPs; - } - else if (count != 1) { + } else if (count != 1) { /* * This should NEVER happen. G_SCALAR ensures that we WILL * have 1 parameter. @@ -219,8 +214,7 @@ gaim_debug(GAIM_DEBUG_ERROR, "perl", "Perl error from %s: expected 1 return value, " "but got %d\n", function, count); - } - else + } else ret_value = POPi; /* Check for changed arguments */ @@ -386,8 +380,7 @@ { STRLEN na; - switch (gaim_value_get_type(value)) - { + switch (gaim_value_get_type(value)) { case GAIM_TYPE_BOOLEAN: return (void *)SvIV(sv); case GAIM_TYPE_INT: return (void *)SvIV(sv); case GAIM_TYPE_UINT: return (void *)SvUV(sv); @@ -411,16 +404,31 @@ { const char *stash = NULL; - switch (gaim_value_get_subtype(value)) - { - case GAIM_SUBTYPE_ACCOUNT: stash = "Gaim::Account"; break; - case GAIM_SUBTYPE_BLIST: stash = "Gaim::BuddyList"; break; - case GAIM_SUBTYPE_BLIST_BUDDY: stash = "Gaim::BuddyList::Buddy"; break; - case GAIM_SUBTYPE_BLIST_GROUP: stash = "Gaim::BuddyList::Group"; break; - case GAIM_SUBTYPE_BLIST_CHAT: stash = "Gaim::BuddyList::Chat"; break; - case GAIM_SUBTYPE_CONNECTION: stash = "Gaim::Connection"; break; - case GAIM_SUBTYPE_CONVERSATION: stash = "Gaim::Conversation"; break; - case GAIM_SUBTYPE_PLUGIN: stash = "Gaim::Plugin"; break; + switch (gaim_value_get_subtype(value)) { + case GAIM_SUBTYPE_ACCOUNT: + stash = "Gaim::Account"; + break; + case GAIM_SUBTYPE_BLIST: + stash = "Gaim::BuddyList"; + break; + case GAIM_SUBTYPE_BLIST_BUDDY: + stash = "Gaim::BuddyList::Buddy"; + break; + case GAIM_SUBTYPE_BLIST_GROUP: + stash = "Gaim::BuddyList::Group"; + break; + case GAIM_SUBTYPE_BLIST_CHAT: + stash = "Gaim::BuddyList::Chat"; + break; + case GAIM_SUBTYPE_CONNECTION: + stash = "Gaim::Connection"; + break; + case GAIM_SUBTYPE_CONVERSATION: + stash = "Gaim::Conversation"; + break; + case GAIM_SUBTYPE_PLUGIN: + stash = "Gaim::Plugin"; + break; default: stash = "Gaim"; /* ? */ @@ -430,13 +438,10 @@ } SV * -gaim_perl_sv_from_vargs(const GaimValue *value, va_list *args, - void ***copy_arg) +gaim_perl_sv_from_vargs(const GaimValue *value, va_list *args, void ***copy_arg) { - if (gaim_value_is_outgoing(value)) - { - switch (gaim_value_get_type(value)) - { + if (gaim_value_is_outgoing(value)) { + switch (gaim_value_get_type(value)) { case GAIM_TYPE_SUBTYPE: if ((*copy_arg = va_arg(*args, void **)) == NULL) return &PL_sv_undef; @@ -511,11 +516,8 @@ /* If this happens, things are going to get screwed up... */ return NULL; } - } - else - { - switch (gaim_value_get_type(value)) - { + } else { + switch (gaim_value_get_type(value)) { case GAIM_TYPE_SUBTYPE: if ((*copy_arg = va_arg(*args, void *)) == NULL) return &PL_sv_undef;
--- a/plugins/perl/perl-common.h Sat Jan 14 06:28:58 2006 +0000 +++ b/plugins/perl/perl-common.h Sat Jan 14 07:12:46 2006 +0000 @@ -25,7 +25,6 @@ void gaim_perl_normalize_script_name(char *name); - SV *newSVGChar(const char *str); void gaim_perl_callXS(void (*subaddr)(pTHX_ CV *cv), CV *cv, SV **mark); @@ -43,6 +42,6 @@ void *gaim_perl_data_from_sv(GaimValue *value, SV *sv); SV *gaim_perl_sv_from_vargs(const GaimValue *value, va_list *args, - void ***copy_arg); + void ***copy_arg); #endif /* _GAIM_PERL_COMMON_H_ */
--- a/plugins/perl/perl-handlers.c Sat Jan 14 06:28:58 2006 +0000 +++ b/plugins/perl/perl-handlers.c Sat Jan 14 07:12:46 2006 +0000 @@ -131,8 +131,8 @@ /* Sets up the Perl Stack for our call back into the script to run the * plugin_pref... sub */ GaimPluginPrefFrame *ret_frame; + int count; dSP; - int count; ENTER; SAVETMPS; @@ -154,7 +154,7 @@ PUTBACK; FREETMPS; LEAVE; - + return ret_frame; }
--- a/plugins/perl/perl.c Sat Jan 14 06:28:58 2006 +0000 +++ b/plugins/perl/perl.c Sat Jan 14 07:12:46 2006 +0000 @@ -103,7 +103,6 @@ char *unload_sub; } GaimPerlScript; - PerlInterpreter *my_perl = NULL; static void @@ -120,14 +119,13 @@ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); } - static void perl_init(void) { /* changed the name of the variable from load_file to perl_definitions since now it does much more than defining the load_file sub. Moreover, deplaced the initialisation to - the xs_init function. (TheHobbit)*/ + the xs_init function. (TheHobbit) */ char *perl_args[] = { "", "-e", "0", "-w" }; char perl_definitions[] = { @@ -174,7 +172,7 @@ }; my_perl = perl_alloc(); - PERL_SET_CONTEXT(my_perl); + PERL_SET_CONTEXT(my_perl); PL_perl_destruct_level = 1; perl_construct(my_perl); #ifdef DEBUG @@ -195,7 +193,7 @@ { if (my_perl == NULL) return; - + PL_perl_destruct_level = 1; PERL_SET_CONTEXT(my_perl); perl_eval_pv( @@ -208,7 +206,7 @@ TRUE); PL_perl_destruct_level = 1; - PERL_SET_CONTEXT(my_perl); + PERL_SET_CONTEXT(my_perl); perl_destruct(my_perl); perl_free(my_perl); my_perl = NULL; @@ -230,12 +228,12 @@ { /* XXX This would be much faster if I didn't create a new * PerlInterpreter every time I probed a plugin */ - + PerlInterpreter *prober = perl_alloc(); char *argv[] = {"", plugin->path }; gboolean status = TRUE; HV *plugin_info; - PERL_SET_CONTEXT(prober); + PERL_SET_CONTEXT(prober); PL_perl_destruct_level = 1; perl_construct(prober); @@ -248,16 +246,13 @@ if (plugin_info == NULL) status = FALSE; else if (!hv_exists(plugin_info, "perl_api_version", - strlen("perl_api_version")) || - !hv_exists(plugin_info, "name", strlen("name")) || - !hv_exists(plugin_info, "load", strlen("load"))) - { + strlen("perl_api_version")) || + !hv_exists(plugin_info, "name", strlen("name")) || + !hv_exists(plugin_info, "load", strlen("load"))) { /* Not a valid plugin. */ status = FALSE; - } - else - { + } else { SV **key; int perl_api_ver; @@ -268,14 +263,14 @@ if (perl_api_ver != 2) status = FALSE; - else - { + else { GaimPluginInfo *info; GaimPerlScript *gps; char *basename; STRLEN len; - gaim_debug(GAIM_DEBUG_INFO, "perl", "Found plugin info\n"); + gaim_debug(GAIM_DEBUG_INFO, "perl", + "Found plugin info\n"); info = g_new0(GaimPluginInfo, 1); gps = g_new0(GaimPerlScript, 1); @@ -286,88 +281,105 @@ info->type = GAIM_PLUGIN_STANDARD; info->dependencies = g_list_append(info->dependencies, - PERL_PLUGIN_ID); + PERL_PLUGIN_ID); gps->plugin = plugin; basename = g_path_get_basename(plugin->path); gaim_perl_normalize_script_name(basename); - gps->package = g_strdup_printf("Gaim::Script::%s", basename); + gps->package = g_strdup_printf("Gaim::Script::%s", + basename); g_free(basename); /* We know this one exists. */ key = hv_fetch(plugin_info, "name", strlen("name"), 0); info->name = g_strdup(SvPV(*key, len)); - if ((key = hv_fetch(plugin_info, "GTK_UI", strlen("GTK_UI"), 0))) + if ((key = hv_fetch(plugin_info, "GTK_UI", + strlen("GTK_UI"), 0))) info->ui_requirement = GAIM_GTK_PLUGIN_TYPE; - if ((key = hv_fetch(plugin_info, "url", strlen("url"), 0))) + if ((key = hv_fetch(plugin_info, "url", + strlen("url"), 0))) info->homepage = g_strdup(SvPV(*key, len)); - if ((key = hv_fetch(plugin_info, "author", strlen("author"), 0))) + if ((key = hv_fetch(plugin_info, "author", + strlen("author"), 0))) info->author = g_strdup(SvPV(*key, len)); if ((key = hv_fetch(plugin_info, "summary", - strlen("summary"), 0))) + strlen("summary"), 0))) info->summary = g_strdup(SvPV(*key, len)); if ((key = hv_fetch(plugin_info, "description", - strlen("description"), 0))) + strlen("description"), 0))) info->description = g_strdup(SvPV(*key, len)); - if ((key = hv_fetch(plugin_info, "version", strlen("version"), 0))) + if ((key = hv_fetch(plugin_info, "version", + strlen("version"), 0))) info->version = g_strdup(SvPV(*key, len)); - if ((key = hv_fetch(plugin_info, "load", strlen("load"), 0))) - gps->load_sub = g_strdup_printf("%s::%s", gps->package, - SvPV(*key, len)); + if ((key = hv_fetch(plugin_info, "load", + strlen("load"), 0))) + gps->load_sub = g_strdup_printf("%s::%s", + gps->package, + SvPV(*key, len)); - if ((key = hv_fetch(plugin_info, "unload", strlen("unload"), 0))) - gps->unload_sub = g_strdup_printf("%s::%s", gps->package, - SvPV(*key, len)); + if ((key = hv_fetch(plugin_info, "unload", + strlen("unload"), 0))) + gps->unload_sub = g_strdup_printf("%s::%s", + gps->package, + SvPV(*key, len)); - /********************************************************/ - /* Only one of the next two options should be present */ - /* */ - /* prefs_info - Uses non-GUI (read GTK) gaim API calls */ - /* and creates a GaimPluginPrefInfo type. */ - /* */ - /* gtk_prefs_info - Requires gtk2-perl be installed by */ - /* the user and he must create a GtkWidget */ - /* representing the plugin preferences */ - /* page. */ - /********************************************************/ - if ((key = hv_fetch(plugin_info, "prefs_info", strlen("prefs_info"), 0))) { + /********************************************************/ + /* Only one of the next two options should be present */ + /* */ + /* prefs_info - Uses non-GUI (read GTK) gaim API calls */ + /* and creates a GaimPluginPrefInfo type. */ + /* */ + /* gtk_prefs_info - Requires gtk2-perl be installed by */ + /* the user and he must create a GtkWidget */ + /* representing the plugin preferences */ + /* page. */ + /********************************************************/ + if ((key = hv_fetch(plugin_info, "prefs_info", + strlen("prefs_info"), 0))) { char *tmp = g_strdup_printf("%s::%s", gps->package, SvPV(*key, len)); - /* key now is the name of the Perl sub that will create a frame for us */ + /* key now is the name of the Perl sub that + * will create a frame for us */ info->prefs_info = gaim_perl_plugin_pref(tmp); g_free(tmp); } - if ((key = hv_fetch(plugin_info, "gtk_prefs_info", strlen("gtk_prefs_info"), 0))) { + if ((key = hv_fetch(plugin_info, "gtk_prefs_info", + strlen("gtk_prefs_info"), 0))) { char *tmp = g_strdup_printf("%s::%s", gps->package, SvPV(*key, len)); - /* key now is the name of the Perl sub that will create a frame for us */ + /* key now is the name of the Perl sub that + * will create a frame for us */ info->ui_info = gaim_perl_gtk_plugin_pref(tmp); g_free(tmp); } - /********************************************************/ - /* */ - /* plugin_action - This is given to the plugin info */ - /* as the action GList. There are two parts */ - /* so the user can set the title as it will appear */ - /* in the plugin action menu. The name is */ - /* extracted and then the callback perl sub's name */ - /* both of which then are handled by an internal */ - /* gaim_perl function that sets up the single cb */ - /* function which is then inserted into 'info'. */ - /********************************************************/ - if ((key = hv_fetch(plugin_info, "plugin_action_label", strlen("plugin_action_label"), 0))) { + /********************************************************/ + /* */ + /* plugin_action - This is given to the plugin info */ + /* as the action GList. There are two */ + /* parts so the user can set the title */ + /* as it will appear in the plugin */ + /* action menu. The name is extracted */ + /* and then the callback perl sub's */ + /* name both of which then are handled */ + /* by an internal gaim_perl function */ + /* that sets up the single cb function */ + /* which is then inserted into 'info'. */ + /********************************************************/ + if ((key = hv_fetch(plugin_info, "plugin_action_label", + strlen("plugin_action_label"), 0))) { gaim_perl_plugin_action_label = g_strdup(SvPV(*key, len)); } - if ((key = hv_fetch(plugin_info, "plugin_action", strlen("plugin_action"), 0))) { + if ((key = hv_fetch(plugin_info, "plugin_action", + strlen("plugin_action"), 0))) { gaim_perl_plugin_action_callback_sub = g_strdup_printf("%s::%s", gps->package, SvPV(*key, len)); info->actions = gaim_perl_plugin_action; } @@ -378,9 +390,9 @@ status = gaim_plugin_register(plugin); } } - + PL_perl_destruct_level = 1; - PERL_SET_CONTEXT(prober); + PERL_SET_CONTEXT(prober); perl_destruct(prober); perl_free(prober); return status; @@ -403,8 +415,8 @@ plugin->handle = gps; atmp[1] = gps->package; - - PERL_SET_CONTEXT(my_perl); + + PERL_SET_CONTEXT(my_perl); execute_perl("Gaim::PerlLoader::load_n_eval", 2, atmp); { @@ -414,7 +426,8 @@ ENTER; SAVETMPS; PUSHMARK(sp); - XPUSHs(sv_2mortal(gaim_perl_bless_object(plugin, "Gaim::Plugin"))); + XPUSHs(sv_2mortal(gaim_perl_bless_object(plugin, + "Gaim::Plugin"))); PUTBACK; perl_call_pv(gps->load_sub, G_EVAL | G_SCALAR); @@ -424,8 +437,8 @@ STRLEN len; gaim_debug(GAIM_DEBUG_ERROR, "perl", - "Perl function %s exited abnormally: %s\n", - gps->load_sub, SvPV(ERRSV, len)); + "Perl function %s exited abnormally: %s\n", + gps->load_sub, SvPV(ERRSV, len)); } PUTBACK; @@ -451,7 +464,7 @@ PUTBACK; perl_call_pv("Gaim::PerlLoader::destroy_package", - G_VOID | G_EVAL | G_DISCARD); + G_VOID | G_EVAL | G_DISCARD); SPAGAIN; @@ -470,15 +483,15 @@ gaim_debug(GAIM_DEBUG_INFO, "perl", "Unloading perl script\n"); - if (gps->unload_sub != NULL) - { + if (gps->unload_sub != NULL) { dSP; PERL_SET_CONTEXT(my_perl); SPAGAIN; ENTER; SAVETMPS; PUSHMARK(sp); - XPUSHs(sv_2mortal(gaim_perl_bless_object(plugin, "Gaim::Plugin"))); + XPUSHs(sv_2mortal(gaim_perl_bless_object(plugin, + "Gaim::Plugin"))); PUTBACK; perl_call_pv(gps->unload_sub, G_EVAL | G_SCALAR); @@ -488,8 +501,8 @@ STRLEN len; gaim_debug(GAIM_DEBUG_ERROR, "perl", - "Perl function %s exited abnormally: %s\n", - gps->load_sub, SvPV(ERRSV, len)); + "Perl function %s exited abnormally: %s\n", + gps->load_sub, SvPV(ERRSV, len)); } PUTBACK; @@ -512,37 +525,18 @@ { GaimPerlScript *gps; - if (plugin->info->name != NULL) - g_free(plugin->info->name); - - if (plugin->info->version != NULL) - g_free(plugin->info->version); - - if (plugin->info->summary != NULL) - g_free(plugin->info->summary); - - if (plugin->info->description != NULL) - g_free(plugin->info->description); - - if (plugin->info->author != NULL) - g_free(plugin->info->author); - - if (plugin->info->homepage != NULL) - g_free(plugin->info->homepage); + g_free(plugin->info->name); + g_free(plugin->info->version); + g_free(plugin->info->summary); + g_free(plugin->info->description); + g_free(plugin->info->author); + g_free(plugin->info->homepage); gps = (GaimPerlScript *)plugin->info->extra_info; - - if (gps != NULL) - { - if (gps->load_sub != NULL) - g_free(gps->load_sub); - - if (gps->unload_sub != NULL) - g_free(gps->unload_sub); - - if (gps->package != NULL) - g_free(gps->package); - + if (gps != NULL) { + g_free(gps->load_sub); + g_free(gps->unload_sub); + g_free(gps->package); g_free(gps); plugin->info->extra_info = NULL; }