Changeset d28fe1c4 for root_commands.c


Ignore:
Timestamp:
2016-05-26T02:48:08Z (3 years ago)
Author:
jgeboski <jgeboski@…>
Branches:
master
Children:
808825e
Parents:
0e48e54
git-author:
jgeboski <jgeboski@…> (15-05-16 18:17:34)
git-committer:
jgeboski <jgeboski@…> (26-05-16 02:48:08)
Message:

Implemented plugin information for external plugins

As of now, bitlbee will load any plugin regardless of the ABI it was
built against. This is really problematic when structures or symbols
are changed within bitlbee. This often leads to the plugin not loading
or the plugin acting in an undefined way. Typically a simple rebuild of
the plugin will resolve such issues, but many users have no idea that
this is required after they have updated bitlbee.

Furthermore, it is often times impossible to determine the version of
a plugin, without relying on the package manager of the system. This is
quite a problem when users are reporting bugs for external plugins, and
they have no idea what version of the plugin they are running. This is
also an opportunity to provide additional metadata for each plugin that
can then be displayed to the user.

Solving these issues is done by adding a new required function to each
plugin. The init_plugin_info() function must now be implemented along
with the init_plugin() function. This function then returns a static
structure, which retains all of the metadata for the plugin. Then this
is used by bitlbee to check the ABI version and provide information to
the user.

The introduction of the new function is required as bitlbee needs to
obtain the ABI version before calling init_plugin().

The boiler-plate implementation of init_plugin_info():

#ifdef BITLBEE_ABI_VERSION_CODE
struct plugin_info *init_plugin_info(void)
{

static struct plugin_info info = {

BITLBEE_ABI_VERSION_CODE, /* Required */
"plugin-name", /* Required */
"1.3.3.7", /* Required */
"A short description of the plugin", /* Optional */
"First Last <alias@…>", /* Optional */
"http://www.domain.tld" /* Optional */

};

return &info;

}
#endif

The example wraps the function declaration in an if block for backwards
compatibility with older bitlbee versions.

Displaying the plugin metadata is done via the newly added "plugins"
command, which simply dumps formatted data to the root channel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • root_commands.c

    r0e48e54 rd28fe1c4  
    11061106        }
    11071107}
     1108
     1109#ifdef WITH_PLUGINS
     1110static void cmd_plugins(irc_t *irc, char **cmd)
     1111{
     1112        GList *l;
     1113        struct plugin_info *info;
     1114
     1115        for (l = get_plugins(); l; l = l->next) {
     1116                info = l->data;
     1117                irc_rootmsg(irc, "%s:", info->name);
     1118                irc_rootmsg(irc, "  Version: %s", info->version);
     1119
     1120                if (info->description) {
     1121                        irc_rootmsg(irc, "  Description: %s", info->description);
     1122                }
     1123
     1124                if (info->author) {
     1125                        irc_rootmsg(irc, "  Author: %s", info->author);
     1126                }
     1127
     1128                if (info->url) {
     1129                        irc_rootmsg(irc, "  URL: %s", info->url);
     1130                }
     1131
     1132                if (l->next) {
     1133                        irc_rootmsg(irc, "");
     1134                }
     1135        }
     1136}
     1137#endif
    11081138
    11091139static void cmd_qlist(irc_t *irc, char **cmd)
     
    13581388        { "nick",           1, cmd_nick,           0 },
    13591389        { "no",             0, cmd_yesno,          0 },
     1390#ifdef WITH_PLUGINS
     1391        { "plugins",        0, cmd_plugins,        0 },
     1392#endif
    13601393        { "qlist",          0, cmd_qlist,          0 },
    13611394        { "register",       0, cmd_register,       0 },
Note: See TracChangeset for help on using the changeset viewer.