From 87872c712535013cbba81653021a41091a9ed7f2 Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 28 Nov 2016 02:52:22 -0300 Subject: purple: Use roomlist_room_serialize, fixes joining jabber chats The room names in 'chat list' were missing the server part. Jabber is the only prpl which implements this method as far as I can see, and it's needed to get the full name. --- protocols/purple/purple.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index c7123798..8b3b8c7c 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -1386,16 +1386,30 @@ static void prplcb_roomlist_set_fields(PurpleRoomlist *list, GList *fields) } } +static char *prplcb_roomlist_get_room_name(PurpleRoomlist *list, PurpleRoomlistRoom *room) +{ + struct im_connection *ic = purple_ic_by_pa(list->account); + struct purple_data *pd = ic->proto_data; + PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id); + PurplePluginProtocolInfo *pi = prpl->info->extra_info; + + if (pi && pi->roomlist_room_serialize) { + return pi->roomlist_room_serialize(room); + } else { + return g_strdup(purple_roomlist_room_get_name(room)); + } +} + static void prplcb_roomlist_add_room(PurpleRoomlist *list, PurpleRoomlistRoom *room) { bee_chat_info_t *ci; - const char *title; + char *title; const char *topic; GList *fields; struct purple_roomlist_data *rld = list->ui_data; fields = purple_roomlist_room_get_fields(room); - title = purple_roomlist_room_get_name(room); + title = prplcb_roomlist_get_room_name(list, room); if (rld->topic >= 0) { topic = g_list_nth_data(fields, rld->topic); @@ -1404,7 +1418,7 @@ static void prplcb_roomlist_add_room(PurpleRoomlist *list, PurpleRoomlistRoom *r } ci = g_new(bee_chat_info_t, 1); - ci->title = g_strdup(title); + ci->title = title; ci->topic = g_strdup(topic); rld->chats = g_slist_prepend(rld->chats, ci); } -- cgit v1.2.3 From 2a1c27f7d49e5065d4af598848bb3810bcf65e93 Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 28 Nov 2016 15:20:34 -0300 Subject: Include debug symbols in non-debug builds, disable stripping by default With this commit, the difference between debug and non-debug builds is mainly the optimization level and -DDEBUG (which isn't used much) In other words: --debug=0 == CFLAGS="-g -O2 -fno-strict-aliasing" --debug=1 == CFLAGS="-g3 -DDEBUG -O0" And --strip=1 can be used to get rid of the debug symbols. This is closer to the default behavior of autotools. Should have done this forever ago, like back when bitlbee had bugs (lol) --- Makefile | 2 +- configure | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3d930f97..2c6c69ff 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,7 @@ $(objects): Makefile Makefile.settings config.h $(OUTFILE): $(objects) $(subdirs) @echo '*' Linking $(OUTFILE) @$(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LDFLAGS_BITLBEE) $(LDFLAGS) $(EFLAGS) -ifndef DEBUG +ifneq ($(firstword $(STRIP)), \#) @echo '*' Stripping $(OUTFILE) @-$(STRIP) $(OUTFILE) endif diff --git a/configure b/configure index 280408ee..1daaf26d 100755 --- a/configure +++ b/configure @@ -40,7 +40,7 @@ purple=0 doc=1 debug=0 -strip=1 +strip=0 gcov=0 asan=0 plugins=1 @@ -286,7 +286,7 @@ if [ "$debug" = "1" ]; then echo 'DEBUG=1' >> Makefile.settings CFLAGS="$CFLAGS -g3 -DDEBUG -O0" else - [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing" + [ -z "$CFLAGS" ] && CFLAGS="-g -O2 -fno-strict-aliasing" fi if [ "$pie" = "1" ]; then -- cgit v1.2.3 From 0483e1e6e3954787058aff78223cb758f0074f2d Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 28 Nov 2016 16:26:16 -0300 Subject: Fix some compiler warnings warn_unused_result on write() is particularly annoying. You can't just add (void) to ignore it due to gcc bug 66425. I replaced some of those with fwrite() and used a variable marked with the G_GNUC_UNUSED attribute for the writes from signal handlers. --- protocols/msn/msn_util.c | 2 +- protocols/msn/soap.c | 4 ++-- protocols/nogaim.c | 2 +- unix.c | 23 +++++++++++++++-------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 763b2768..af00e461 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -179,7 +179,7 @@ void msn_queue_feed(struct msn_data *h, char *bytes, int st) if (getenv("BITLBEE_DEBUG")) { fprintf(stderr, "\n\x1b[92m<<< "); - write(2, bytes , st); + fwrite(bytes, st, 1, stderr); fprintf(stderr, "\x1b[97m"); } } diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 1fa22d13..14aaed11 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -212,9 +212,9 @@ static void msn_soap_debug_print(const char *headers, const char *payload) if (headers) { if ((s = strstr(headers, "\r\n\r\n"))) { - write(2, headers, s - headers + 4); + fwrite(headers, s - headers + 4, 1, stderr); } else { - write(2, headers, strlen(headers)); + fwrite(headers, strlen(headers), 1, stderr); } } diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 2f6b3783..e4db7024 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -53,7 +53,7 @@ gboolean load_plugin(char *path) { GList *l; struct plugin_info *i; - struct plugin_info *info; + struct plugin_info *info = NULL; struct plugin_info * (*info_function) (void) = NULL; void (*init_function) (void); diff --git a/unix.c b/unix.c index dd267d8b..a41f9c3a 100644 --- a/unix.c +++ b/unix.c @@ -146,12 +146,17 @@ int main(int argc, char *argv[]) (!getuid() || !geteuid())) { struct passwd *pw = NULL; pw = getpwnam(global.conf->user); - if (pw) { - initgroups(global.conf->user, pw->pw_gid); - setgid(pw->pw_gid); - setuid(pw->pw_uid); - } else { - log_message(LOGLVL_WARNING, "Failed to look up user %s.", global.conf->user); + if (!pw) { + log_message(LOGLVL_ERROR, "Failed to look up user %s.", global.conf->user); + + } else if (initgroups(global.conf->user, pw->pw_gid) != 0) { + log_message(LOGLVL_ERROR, "initgroups: %s.", strerror(errno)); + + } else if (setgid(pw->pw_gid) != 0) { + log_message(LOGLVL_ERROR, "setgid(%d): %s.", pw->pw_gid, strerror(errno)); + + } else if (setuid(pw->pw_uid) != 0) { + log_message(LOGLVL_ERROR, "setuid(%d): %s.", pw->pw_uid, strerror(errno)); } } @@ -280,9 +285,10 @@ void sighandler_shutdown_setup() /* Signal handler for SIGTERM and SIGINT */ static void sighandler_shutdown(int signal) { + int unused G_GNUC_UNUSED; /* Write a single null byte to the pipe, just to send a message to the main loop. * This gets handled by bitlbee_shutdown (the b_input_add callback for this pipe) */ - write(shutdown_pipe.fd[1], "", 1); + unused = write(shutdown_pipe.fd[1], "", 1); } /* Signal handler for SIGSEGV @@ -291,13 +297,14 @@ static void sighandler_shutdown(int signal) static void sighandler_crash(int signal) { GSList *l; + int unused G_GNUC_UNUSED; const char *message = "ERROR :BitlBee crashed! (SIGSEGV received)\r\n"; int len = strlen(message); for (l = irc_connection_list; l; l = l->next) { irc_t *irc = l->data; sock_make_blocking(irc->fd); - write(irc->fd, message, len); + unused = write(irc->fd, message, len); } raise(signal); -- cgit v1.2.3 From 90254d0d6daa664707503f5c909198aefdc1151c Mon Sep 17 00:00:00 2001 From: dequis Date: Sat, 24 Dec 2016 01:56:45 -0300 Subject: Add nick_lowercase and nick_underscores settings --- doc/user-guide/commands.xml | 41 ++++++++++++++++++++++++++++++----------- irc.c | 3 ++- irc_channel.c | 2 +- nick.c | 20 ++++++++++++++++---- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index ee361b0f..e27356b8 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1036,17 +1036,6 @@ - - true - - - - Hereby you can change whether you want all lower case nick names or leave the case as it intended by your peer. - - - - - false @@ -1213,6 +1202,36 @@ + + true + + + + If enabled, all nicknames are turned into lower case. + + + + See also the nick_underscores setting. This setting was previously known as lcnicks. + + + + + + + true + + + + If enabled, spaces in nicknames are turned into underscores instead of being stripped. + + + + See also the nick_lowercase setting. + + + + + true diff --git a/irc.c b/irc.c index 835bffa0..c1821eac 100644 --- a/irc.c +++ b/irc.c @@ -112,8 +112,9 @@ irc_t *irc_new(int fd) s = set_add(&b->set, "handle_unknown", "add_channel", NULL, irc); s = set_add(&b->set, "last_version", "0", NULL, irc); s->flags |= SET_HIDDEN; - s = set_add(&b->set, "lcnicks", "true", set_eval_bool, irc); s = set_add(&b->set, "nick_format", "%-@nick", NULL, irc); + s = set_add(&b->set, "nick_lowercase", "false", set_eval_bool, irc); + s = set_add(&b->set, "nick_underscores", "false", set_eval_bool, irc); s = set_add(&b->set, "offline_user_quits", "true", set_eval_bool, irc); s = set_add(&b->set, "ops", "both", set_eval_irc_channel_ops, irc); s = set_add(&b->set, "paste_buffer", "false", set_eval_bool, irc); diff --git a/irc_channel.c b/irc_channel.c index 3ccbce55..e2c77fc5 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -637,7 +637,7 @@ char *irc_channel_name_gen(irc_t *irc, const char *hint) irc_channel_name_strip(name); - if (set_getbool(&irc->b->set, "lcnicks")) { + if (set_getbool(&irc->b->set, "nick_lowercase")) { nick_lc(irc, name + 1); } diff --git a/nick.c b/nick.c index 9c47c2fe..f782aea2 100644 --- a/nick.c +++ b/nick.c @@ -93,7 +93,7 @@ char *nick_get(bee_user_t *bu) } nick_strip(irc, nick); - if (set_getbool(&bu->bee->set, "lcnicks")) { + if (set_getbool(&bu->bee->set, "nick_lowercase")) { nick_lc(irc, nick); } } @@ -214,6 +214,11 @@ char *nick_gen(bee_user_t *bu) rets = g_string_free(ret, FALSE); if (ok && rets && *rets) { nick_strip(irc, rets); + + if (set_getbool(&bu->bee->set, "nick_lowercase")) { + nick_lc(irc, rets); + } + truncate_utf8(rets, MAX_NICK_LENGTH); return rets; } @@ -287,6 +292,7 @@ void nick_del(bee_user_t *bu) void nick_strip(irc_t *irc, char *nick) { int len = 0; + gboolean nick_underscores = set_getbool(&irc->b->set, "nick_underscores"); if (irc && (irc->status & IRC_UTF8_NICKS)) { gunichar c; @@ -296,8 +302,11 @@ void nick_strip(irc_t *irc, char *nick) c = g_utf8_get_char_validated(p, -1); n = g_utf8_find_next_char(p, NULL); - if ((c < 0x7f && !(strchr(nick_lc_chars, c) || - strchr(nick_uc_chars, c))) || + if (nick_underscores && c == ' ') { + *p = '_'; + p = n; + } else if ((c < 0x7f && !(strchr(nick_lc_chars, c) || + strchr(nick_uc_chars, c))) || !g_unichar_isgraph(c)) { strcpy(tmp, n); strcpy(p, tmp); @@ -312,7 +321,10 @@ void nick_strip(irc_t *irc, char *nick) int i; for (i = len = 0; nick[i] && len < MAX_NICK_LENGTH; i++) { - if (strchr(nick_lc_chars, nick[i]) || + if (nick_underscores && nick[i] == ' ') { + nick[len] = '_'; + len++; + } else if (strchr(nick_lc_chars, nick[i]) || strchr(nick_uc_chars, nick[i])) { nick[len] = nick[i]; len++; -- cgit v1.2.3 From df291a65ca8c201480eadb38633f3db70ac40294 Mon Sep 17 00:00:00 2001 From: dequis Date: Sat, 24 Dec 2016 01:59:06 -0300 Subject: Remove "Cleaning up channel, bye!" message --- irc_im.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/irc_im.c b/irc_im.c index e40a8a89..ef719d32 100644 --- a/irc_im.c +++ b/irc_im.c @@ -633,10 +633,6 @@ static gboolean bee_irc_chat_free(bee_t *bee, struct groupchat *c) return FALSE; } - if (ic->flags & IRC_CHANNEL_JOINED) { - irc_channel_printf(ic, "Cleaning up channel, bye!"); - } - ic->data = NULL; c->ui_data = NULL; irc_channel_del_user(ic, ic->irc->user, IRC_CDU_KICK, "Chatroom closed by server"); -- cgit v1.2.3 From 15a8c94f4e559bf7b9f201bd1b93e816948a5d43 Mon Sep 17 00:00:00 2001 From: dequis Date: Sat, 24 Dec 2016 13:09:43 -0300 Subject: genhelp: Slightly improve error messages on xml parse error --- doc/user-guide/genhelp.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/user-guide/genhelp.py b/doc/user-guide/genhelp.py index e9a3b2bf..15fcd455 100644 --- a/doc/user-guide/genhelp.py +++ b/doc/user-guide/genhelp.py @@ -72,7 +72,11 @@ def fix_tree(tag, debug=False, lvl=''): # Main logic def process_file(filename, parent=None): - tree = ET.parse(open(filename)).getroot() + try: + tree = ET.parse(open(filename)).getroot() + except: + sys.stderr.write("\nException while processing %s\n" % filename) + raise fix_tree(tree) return parse_tag(tree, parent) -- cgit v1.2.3 From 1999fe5eadc7c7575e33542da42b0e21b10366d9 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 25 Dec 2016 19:07:48 -0300 Subject: Misc documentation updates - Remove a bunch of mentions of yahoo - Remove 'smileys' topic from help index - Add 'identify_methods' help topic - Mention new commands like 'chat list' or 'plugins' --- doc/README | 3 --- doc/bitlbee.8 | 3 +-- doc/user-guide/Installation.xml | 2 +- doc/user-guide/commands.xml | 6 +++--- doc/user-guide/help.xml | 4 ++-- doc/user-guide/misc.xml | 39 ++++++++++++++++++++++++++++++++++++++- doc/user-guide/quickstart.xml | 10 +++++++--- 7 files changed, 52 insertions(+), 15 deletions(-) diff --git a/doc/README b/doc/README index 8abc7297..030117c5 100644 --- a/doc/README +++ b/doc/README @@ -160,9 +160,6 @@ LEGAL BitlBee is distributed under the GPL (GNU General Public License). See the file COPYING for this license. -The Yahoo! library used by BitlBee is libyahoo2 , -also licensed under the GPL. - BitlBee - An IRC to other chat networks gateway diff --git a/doc/bitlbee.8 b/doc/bitlbee.8 index b5aa7705..2170270d 100644 --- a/doc/bitlbee.8 +++ b/doc/bitlbee.8 @@ -38,8 +38,7 @@ BitlBee \- IRC gateway to IM chat networks BitlBee is an IRC daemon that can talk to instant messaging networks and acts as a gateway. Users can connect to the server with any normal IRC client and see their 'buddy list' in -&bitlbee. It currently supports Oscar (AIM and ICQ), -MSN, Jabber, Yahoo! and Twitter. +&bitlbee. \fBbitlbee\fP should be called by .BR inetd (8), diff --git a/doc/user-guide/Installation.xml b/doc/user-guide/Installation.xml index 75568936..9d555d46 100644 --- a/doc/user-guide/Installation.xml +++ b/doc/user-guide/Installation.xml @@ -35,7 +35,7 @@ specify them all separately, just specifying prefix (or keeping the default config - The place where BitlBee will save all the per-user settings and buddy information. /var/lib/bitlbee/ is the default value. -msn, jabber, oscar, yahoo - By default, support for all +msn, jabber, oscar, twitter - By default, support for all these IM-protocols (OSCAR is the protocol used by both ICQ and AIM) will be compiled in. To make the binary a bit smaller, you can use these options to leave out support for protocols you're not planning to use. diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index e27356b8..6b725156 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -20,7 +20,7 @@ - Adds an account on the given server with the specified protocol, username and password to the account list. Supported protocols right now are: Jabber, MSN, OSCAR (AIM/ICQ), Yahoo and Twitter. For more information about adding an account, see help account add <protocol>. + Adds an account on the given server with the specified protocol, username and password to the account list. For a list of supported protocols, use the plugins command. For more information about adding an account, see help account add <protocol>. @@ -337,7 +337,7 @@ - Requests IM-network-specific information about the specified user. The amount of information you'll get differs per protocol. For some protocols (ATM Yahoo! and MSN) it'll give you an URL which you can visit with a normal web browser to get the information. + Requests IM-network-specific information about the specified user. The amount of information you'll get differs per protocol. For some protocols it'll give you an URL which you can visit with a normal web browser to get the information. @@ -1052,7 +1052,7 @@ - Some protocols (MSN, Yahoo!, GTalk) can notify via IM about new e-mail. Since most people use their Hotmail/Yahoo! addresses as a spam-box, this is disabled default. If you want these notifications, you can enable this setting. + Some protocols can notify via IM about new e-mail. If you want these notifications, you can enable this setting. diff --git a/doc/user-guide/help.xml b/doc/user-guide/help.xml index e40a04d1..1b68413a 100644 --- a/doc/user-guide/help.xml +++ b/doc/user-guide/help.xml @@ -17,7 +17,7 @@ These are the available help subjects: awayAbout setting away states groupchatsHow to work with groupchats on BitlBee nick_changesChanging your nickname without losing any settings - smileysA summary of some non-standard smileys you might find and fail to understand + identify_methodsA list of ways to (auto-)identify to your account @@ -48,7 +48,7 @@ These are the available help subjects: awayAbout setting away states groupchatsHow to work with groupchats on BitlBee nick_changesChanging your nickname without losing any settings - smileysA summary of some non-standard smileys you might find and fail to understand + identify_methodsA list of ways to (auto-)identify to your account diff --git a/doc/user-guide/misc.xml b/doc/user-guide/misc.xml index 36720914..a95c5442 100644 --- a/doc/user-guide/misc.xml +++ b/doc/user-guide/misc.xml @@ -76,9 +76,12 @@ Then, just use the ordinary IRC /invite command to invite m -Some protocols (like Jabber) also support named groupchats. BitlBee now supports these too. You can use the chat add command to join them. See help chat add for more information. +Some protocols (like Jabber) also support named groupchats. BitlBee supports these too. You can use the chat add command to join them. See help chat add for more information. + +If you don't know the name of a named groupchat, you can try the chat list command to get a list of chatrooms from a server. See help chat list for usage instructions. + @@ -267,6 +270,40 @@ everything in the handle up to the first @. + +Identifying to your BitlBee account + +There are several methods to identify (log in) to your registered BitlBee account. All of these are equivalent: + + + + The 'identify' command + sent to &bitlbee or root. See help identify for details. + + + /msg nickserv identify + Same as above, but sent to NickServ. Useful with some auto-identify scripts. + + + /nickserv or /ns + Same as above, but using the command aliases to NickServ. + + + Server password + A field in the server connection settings of your irc client. + + + SASL PLAIN + A newer method, good choice if your client supports it. (Note: "SASL" is not related to "SSL") + + + +To configure your client to auto-identify, the last two methods are recommended. SASL if you have it, but server password is often the easiest. + +Note: If you changed bitlbee.conf to have AuthMode = Closed, server password will be used for that instead. If you have never heard of that setting before, you can ignore it and just use it. + + + New stuff in BitlBee 1.2.6 diff --git a/doc/user-guide/quickstart.xml b/doc/user-guide/quickstart.xml index c929cf19..2eda6be1 100644 --- a/doc/user-guide/quickstart.xml +++ b/doc/user-guide/quickstart.xml @@ -2,7 +2,7 @@ Quickstart -Welcome to BitlBee, your IRC gateway to ICQ, MSN, AOL, Jabber, Yahoo! and Twitter. +Welcome to BitlBee, your IRC gateway to other instant messaging protocols. @@ -42,7 +42,11 @@ For instance, suppose you have a Jabber account at jabber.org with handle -Other available IM protocols are msn, oscar, yahoo and twitter. OSCAR is the protocol used by ICQ and AOL. For more information about the account add command, see help account add. +Other built-in IM protocols include msn, oscar and twitter. OSCAR is the protocol used by ICQ and AOL. Some protocols may be available as plugins that you can install, such as facebook, steam, discord and omegle. And you can get even more protocols by using the libpurple variant of BitlBee. + + + +For a list of currently supported protocols, use the plugins command. For more information about the account add command, see help account add. @@ -135,7 +139,7 @@ For more subjects (like groupchats and away states), please type help -If you're still looking for something, please visit us in #bitlbee on the OFTC network (you can connect via irc.bitlbee.org), or mail us your problem/suggestion. Good luck and enjoy the Bee! +If you're still looking for something, please visit us in #bitlbee on the OFTC network (irc.oftc.net). Good luck and enjoy the Bee! -- cgit v1.2.3 From 6908ab747d1eb461c8b8e666113aed47924f5b58 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 25 Dec 2016 19:50:31 -0300 Subject: Add 'plugins info' subcommand, only show plugin details there --- doc/user-guide/commands.xml | 6 +++- root_commands.c | 67 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 6b725156..7190f024 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1868,12 +1868,16 @@ List all the external plugins and protocols - plugins + plugins [info <name>] This gives you a list of all the external plugins and protocols. + + + Use the info subcommand to get more details about a plugin. + diff --git a/root_commands.c b/root_commands.c index e0c0b7f8..6bc34fb5 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1163,36 +1163,71 @@ static void prplstr(GList *prpls, GString *gstr) g_list_free(prpls); } +static void cmd_plugins_info(irc_t *irc, char **cmd) +{ + GList *l; + struct plugin_info *info; + + MIN_ARGS(2); + + for (l = get_plugins(); l; l = l->next) { + info = l->data; + if (g_strcasecmp(cmd[2], info->name) == 0) { + break; + } + } + + if (!l) { + return; + } + + irc_rootmsg(irc, "%s:", info->name); + irc_rootmsg(irc, " Version: %s", info->version); + + if (info->description) { + irc_rootmsg(irc, " Description: %s", info->description); + } + + if (info->author) { + irc_rootmsg(irc, " Author: %s", info->author); + } + + if (info->url) { + irc_rootmsg(irc, " URL: %s", info->url); + } +} + static void cmd_plugins(irc_t *irc, char **cmd) { GList *prpls; GString *gstr; + if (cmd[1] && g_strcasecmp(cmd[1], "info") == 0) { + cmd_plugins_info(irc, cmd); + return; + } + #ifdef WITH_PLUGINS GList *l; struct plugin_info *info; + char *format; - for (l = get_plugins(); l; l = l->next) { - info = l->data; - irc_rootmsg(irc, "%s:", info->name); - irc_rootmsg(irc, " Version: %s", info->version); - - if (info->description) { - irc_rootmsg(irc, " Description: %s", info->description); - } - - if (info->author) { - irc_rootmsg(irc, " Author: %s", info->author); - } + if (strchr(irc->umode, 'b') != NULL) { + format = "%s\t%s"; + } else { + format = "%-30s %s"; + } - if (info->url) { - irc_rootmsg(irc, " URL: %s", info->url); - } + irc_rootmsg(irc, format, "Plugin", "Version"); - irc_rootmsg(irc, ""); + for (l = get_plugins(); l; l = l->next) { + info = l->data; + irc_rootmsg(irc, format, info->name, info->version); } #endif + irc_rootmsg(irc, ""); + gstr = g_string_new(NULL); prpls = get_protocols(); -- cgit v1.2.3 From 7486853ca817c0e6d0a5b3d1b702d6bd8e96bf4e Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 25 Dec 2016 20:10:58 -0300 Subject: Refactor: Split plugin info stuff from load_plugin() into two functions --- protocols/nogaim.c | 88 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/protocols/nogaim.c b/protocols/nogaim.c index e4db7024..3fed2728 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -49,16 +49,64 @@ static gint pluginscmp(gconstpointer a, gconstpointer b, gpointer data) return g_strcasecmp(ia->name, ib->name); } -gboolean load_plugin(char *path) +/* semi-private */ +gboolean plugin_info_validate(struct plugin_info *info, const char *path) { GList *l; - struct plugin_info *i; + gboolean loaded = FALSE; + + if (!path) { + path = "(null)"; + } + + if (info->abiver != BITLBEE_ABI_VERSION_CODE) { + log_message(LOGLVL_ERROR, + "`%s' uses ABI %u but %u is required\n", + path, info->abiver, + BITLBEE_ABI_VERSION_CODE); + return FALSE; + } + + if (!info->name || !info->version) { + log_message(LOGLVL_ERROR, + "Name or version missing from the " + "plugin info in `%s'\n", path); + return FALSE; + } + + for (l = plugins; l; l = l->next) { + struct plugin_info *i = l->data; + + if (g_strcasecmp(i->name, info->name) == 0) { + loaded = TRUE; + break; + } + } + + if (loaded) { + log_message(LOGLVL_WARNING, + "%s plugin already loaded\n", + info->name); + return FALSE; + } + + return TRUE; +} + +/* semi-private */ +gboolean plugin_info_add(struct plugin_info *info) +{ + plugins = g_list_insert_sorted_with_data(plugins, info, pluginscmp, NULL); + return TRUE; +} + +gboolean load_plugin(char *path) +{ struct plugin_info *info = NULL; struct plugin_info * (*info_function) (void) = NULL; void (*init_function) (void); GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY); - gboolean loaded = FALSE; if (!mod) { log_message(LOGLVL_ERROR, "Error loading plugin `%s': %s\n", path, g_module_error()); @@ -68,36 +116,7 @@ gboolean load_plugin(char *path) if (g_module_symbol(mod, "init_plugin_info", (gpointer *) &info_function)) { info = info_function(); - if (info->abiver != BITLBEE_ABI_VERSION_CODE) { - log_message(LOGLVL_ERROR, - "`%s' uses ABI %u but %u is required\n", - path, info->abiver, - BITLBEE_ABI_VERSION_CODE); - g_module_close(mod); - return FALSE; - } - - if (!info->name || !info->version) { - log_message(LOGLVL_ERROR, - "Name or version missing from the " - "plugin info in `%s'\n", path); - g_module_close(mod); - return FALSE; - } - - for (l = plugins; l; l = l->next) { - i = l->data; - - if (g_strcasecmp(i->name, info->name) == 0) { - loaded = TRUE; - break; - } - } - - if (loaded) { - log_message(LOGLVL_WARNING, - "%s plugin already loaded\n", - info->name); + if (!plugin_info_validate(info, path)) { g_module_close(mod); return FALSE; } @@ -112,8 +131,7 @@ gboolean load_plugin(char *path) } if (info_function) { - plugins = g_list_insert_sorted_with_data(plugins, info, - pluginscmp, NULL); + plugin_info_add(info); } init_function(); -- cgit v1.2.3 From 6d212f401cf7eeb3eabe315e610578f5aac74607 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 25 Dec 2016 20:41:13 -0300 Subject: purple: include purple plugins in the 'plugins' command list --- protocols/purple/purple.c | 15 +++++++++++++++ root_commands.c | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index 8b3b8c7c..49c1ee7c 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -1640,6 +1640,10 @@ static void purple_ui_init() } } +/* borrowing this semi-private function + * TODO: figure out a better interface later (famous last words) */ +gboolean plugin_info_add(struct plugin_info *info); + void purple_initmodule() { struct prpl funcs; @@ -1740,6 +1744,7 @@ void purple_initmodule() PurplePlugin *prot = prots->data; PurplePluginProtocolInfo *pi = prot->info->extra_info; struct prpl *ret; + struct plugin_info *info; /* If we already have this one (as a native module), don't add a libpurple duplicate. */ @@ -1774,6 +1779,16 @@ void purple_initmodule() ret->data = NULL; register_protocol(ret); } + + info = g_new0(struct plugin_info, 1); + info->abiver = BITLBEE_ABI_VERSION_CODE; + info->name = ret->name; + info->version = prot->info->version; + info->description = prot->info->description; + info->author = prot->info->author; + info->url = prot->info->homepage; + + plugin_info_add(info); } g_string_append(help, "\n\nFor used protocols, more information about available " diff --git a/root_commands.c b/root_commands.c index 6bc34fb5..0ea380af 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1221,8 +1221,17 @@ static void cmd_plugins(irc_t *irc, char **cmd) irc_rootmsg(irc, format, "Plugin", "Version"); for (l = get_plugins(); l; l = l->next) { + char *c; info = l->data; - irc_rootmsg(irc, format, info->name, info->version); + + /* some purple plugins like to include several versions separated by newlines... */ + if ((c = strchr(info->version, '\n'))) { + char *version = g_strndup(info->version, c - info->version); + irc_rootmsg(irc, format, info->name, version); + g_free(version); + } else { + irc_rootmsg(irc, format, info->name, info->version); + } } #endif -- cgit v1.2.3 From 59ccef5cc9f1ed67112248c20649ce8005188173 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 25 Dec 2016 21:13:57 -0300 Subject: purple: Call imcb_buddy_nick_change() on a few whitelisted plugins The whitelist includes hangouts, funyahoo and icq. These plugins tend to have numeric or meaningless usernames. With this change, users don't have to do 'ac whatever set nick_format %full_name' anymore. Just sugar. --- protocols/purple/bpurple.h | 4 ++++ protocols/purple/purple.c | 40 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/protocols/purple/bpurple.h b/protocols/purple/bpurple.h index 81be2575..9b34cdff 100644 --- a/protocols/purple/bpurple.h +++ b/protocols/purple/bpurple.h @@ -6,6 +6,8 @@ #define PURPLE_REQUEST_HANDLE "purple_request" +#define PURPLE_OPT_SHOULD_SET_NICK 1 + struct purple_data { PurpleAccount *account; @@ -14,6 +16,8 @@ struct purple_data guint next_request_id; char *chat_list_server; GSList *filetransfers; + + int flags; }; #endif /* !BPURPLE_H */ diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index 49c1ee7c..9e0dc57e 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -113,6 +113,29 @@ static char *purple_get_account_prpl_id(account_t *acc) return acc->prpl->data; } +static gboolean purple_account_should_set_nick(account_t *acc) +{ + /* whitelist of protocols that tend to have numeric or meaningless usernames, and should + * always offer the 'alias' as a nick. this is just so that users don't have to do + * 'account whatever set nick_format %full_name' + */ + char *whitelist[] = { + "prpl-hangouts", + "prpl-eionrobb-funyahoo-plusplus", + "prpl-icq", + NULL, + }; + char **p; + + for (p = whitelist; *p; p++) { + if (g_strcmp0(acc->prpl->data, *p) == 0) { + return TRUE; + } + } + + return FALSE; +} + static void purple_init(account_t *acc) { char *prpl_id = purple_get_account_prpl_id(acc); @@ -367,6 +390,10 @@ static void purple_login(account_t *acc) purple_account_set_password(pd->account, acc->pass); purple_sync_settings(acc, pd->account); + if (purple_account_should_set_nick(acc)) { + pd->flags = PURPLE_OPT_SHOULD_SET_NICK; + } + purple_account_set_enabled(pd->account, "BitlBee", TRUE); if (set_getbool(&acc->set, "mail_notifications") && set_getstr(&acc->set, "mail_notifications_handle")) { @@ -902,17 +929,22 @@ static void prplcb_blist_update(PurpleBuddyList *list, PurpleBlistNode *node) PurpleBuddy *bud = (PurpleBuddy *) node; PurpleGroup *group = purple_buddy_get_group(bud); struct im_connection *ic = purple_ic_by_pa(bud->account); + struct purple_data *pd = ic->proto_data; PurpleStatus *as; int flags = 0; + char *alias = NULL; if (ic == NULL) { return; } - if (bud->server_alias) { - imcb_rename_buddy(ic, bud->name, bud->server_alias); - } else if (bud->alias) { - imcb_rename_buddy(ic, bud->name, bud->alias); + alias = bud->server_alias ? : bud->alias; + + if (alias) { + imcb_rename_buddy(ic, bud->name, alias); + if (pd->flags & PURPLE_OPT_SHOULD_SET_NICK) { + imcb_buddy_nick_change(ic, bud->name, alias); + } } if (group) { -- cgit v1.2.3