diff options
-rw-r--r-- | doc/user-guide/commands.xml | 4 | ||||
-rw-r--r-- | protocols/nogaim.c | 10 | ||||
-rw-r--r-- | protocols/nogaim.h | 2 | ||||
-rw-r--r-- | root_commands.c | 67 |
4 files changed, 74 insertions, 9 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 260e6abe..56beba54 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1835,12 +1835,12 @@ </bitlbee-command> <bitlbee-command name="plugins"> - <short-description>List all the external plugins</short-description> + <short-description>List all the external plugins and protocols</short-description> <syntax>plugins</syntax> <description> <para> - This gives you a list of all the external plugins. + This gives you a list of all the external plugins and protocols. </para> </description> diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 9ed3b64b..c902258a 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -229,6 +229,16 @@ void nogaim_init() #endif } +GList *get_protocols() +{ + return protocols; +} + +GList *get_protocols_disabled() +{ + return disabled_protocols; +} + GSList *get_connections() { return connections; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index f5b1f212..e5569313 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -286,6 +286,8 @@ G_MODULE_EXPORT GList *get_plugins(); /* im_api core stuff. */ void nogaim_init(); +G_MODULE_EXPORT GList *get_protocols(); +G_MODULE_EXPORT GList *get_protocols_disabled(); G_MODULE_EXPORT GSList *get_connections(); G_MODULE_EXPORT struct prpl *find_protocol(const char *name); G_MODULE_EXPORT gboolean is_protocol_disabled(const char *name); diff --git a/root_commands.c b/root_commands.c index 25c5c49e..9acc30f0 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1106,9 +1106,48 @@ static void cmd_blist(irc_t *irc, char **cmd) } } -#ifdef WITH_PLUGINS +static gint prplcmp(gconstpointer a, gconstpointer b) +{ + const struct prpl *pa = a; + const struct prpl *pb = b; + + return g_strcasecmp(pa->name, pb->name); +} + +static void prplstr(GList *prpls, GString *gstr) +{ + const char *last = NULL; + GList *l; + struct prpl *p; + + prpls = g_list_copy(prpls); + prpls = g_list_sort(prpls, prplcmp); + + for (l = prpls; l; l = l->next) { + p = l->data; + + if (last && g_strcasecmp(p->name, last) == 0) { + /* Ignore duplicates (mainly for libpurple) */ + continue; + } + + if (gstr->len != 0) { + g_string_append(gstr, ", "); + } + + g_string_append(gstr, p->name); + last = p->name; + } + + g_list_free(prpls); +} + static void cmd_plugins(irc_t *irc, char **cmd) { + GList *prpls; + GString *gstr; + +#ifdef WITH_PLUGINS GList *l; struct plugin_info *info; @@ -1129,13 +1168,29 @@ static void cmd_plugins(irc_t *irc, char **cmd) irc_rootmsg(irc, " URL: %s", info->url); } - if (l->next) { - irc_rootmsg(irc, ""); - } + irc_rootmsg(irc, ""); } -} #endif + gstr = g_string_new(NULL); + prpls = get_protocols(); + + if (prpls) { + prplstr(prpls, gstr); + irc_rootmsg(irc, "Enabled Protocols: %s", gstr->str); + g_string_truncate(gstr, 0); + } + + prpls = get_protocols_disabled(); + + if (prpls) { + prplstr(prpls, gstr); + irc_rootmsg(irc, "Disabled Protocols: %s", gstr->str); + } + + g_string_free(gstr, TRUE); +} + static void cmd_qlist(irc_t *irc, char **cmd) { query_t *q = irc->queries; @@ -1387,9 +1442,7 @@ command_t root_commands[] = { { "info", 1, cmd_info, 0 }, { "nick", 1, cmd_nick, 0 }, { "no", 0, cmd_yesno, 0 }, -#ifdef WITH_PLUGINS { "plugins", 0, cmd_plugins, 0 }, -#endif { "qlist", 0, cmd_qlist, 0 }, { "register", 0, cmd_register, 0 }, { "remove", 1, cmd_remove, 0 }, |