diff options
author | Marius Halden <marius.h@lden.org> | 2016-12-26 16:04:14 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-12-26 16:04:14 +0100 |
commit | 184c46d3507a0ff9fc68a4409f690add96cd183d (patch) | |
tree | 6fc6a92212d7e8f68107e418db50073ed8c0f88c | |
parent | 979082a36fe648b81711373c62311bcd7d9d3b54 (diff) | |
parent | 59ccef5cc9f1ed67112248c20649ce8005188173 (diff) |
Merge branch 'master' into patched-master
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | doc/README | 3 | ||||
-rw-r--r-- | doc/bitlbee.8 | 3 | ||||
-rw-r--r-- | doc/user-guide/Installation.xml | 2 | ||||
-rw-r--r-- | doc/user-guide/commands.xml | 53 | ||||
-rw-r--r-- | doc/user-guide/genhelp.py | 6 | ||||
-rw-r--r-- | doc/user-guide/help.xml | 4 | ||||
-rw-r--r-- | doc/user-guide/misc.xml | 39 | ||||
-rw-r--r-- | doc/user-guide/quickstart.xml | 10 | ||||
-rw-r--r-- | irc.c | 3 | ||||
-rw-r--r-- | irc_channel.c | 2 | ||||
-rw-r--r-- | irc_im.c | 4 | ||||
-rw-r--r-- | nick.c | 20 | ||||
-rw-r--r-- | protocols/msn/msn_util.c | 2 | ||||
-rw-r--r-- | protocols/msn/soap.c | 4 | ||||
-rw-r--r-- | protocols/nogaim.c | 90 | ||||
-rw-r--r-- | protocols/purple/bpurple.h | 4 | ||||
-rw-r--r-- | protocols/purple/purple.c | 75 | ||||
-rw-r--r-- | root_commands.c | 72 | ||||
-rw-r--r-- | unix.c | 23 |
21 files changed, 316 insertions, 109 deletions
@@ -195,7 +195,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 @@ -40,7 +40,7 @@ purple=0 doc=1 debug=0 -strip=1 +strip=0 gcov=0 asan=0 plugins=1 @@ -288,7 +288,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 [ "$devel" = "1" ]; then @@ -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 <http://libyahoo2.sf.net/>, -also licensed under the GPL. - BitlBee - An IRC to other chat networks gateway <http://www.bitlbee.org/> 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 <listitem><para>config - The place where BitlBee will save all the per-user settings and buddy information. <filename>/var/lib/bitlbee/</filename> is the default value.</para></listitem> -<listitem><para>msn, jabber, oscar, yahoo - By default, support for all +<listitem><para>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.</para></listitem> diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index ee361b0f..7190f024 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -20,7 +20,7 @@ <description> <para> - 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 <emphasis>help account add <protocol></emphasis>. + 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 <emphasis>plugins</emphasis> command. For more information about adding an account, see <emphasis>help account add <protocol></emphasis>. </para> <para> @@ -337,7 +337,7 @@ <description> <para> - 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. </para> </description> @@ -1036,17 +1036,6 @@ </bitlbee-setting> - <bitlbee-setting name="lcnicks" type="boolean" scope="global"> - <default>true</default> - - <description> - <para> - Hereby you can change whether you want all lower case nick names or leave the case as it intended by your peer. - </para> - </description> - - </bitlbee-setting> - <bitlbee-setting name="local_display_name" type="boolean" scope="account"> <default>false</default> @@ -1063,7 +1052,7 @@ <description> <para> - 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. </para> </description> @@ -1213,6 +1202,36 @@ </description> </bitlbee-setting> + <bitlbee-setting name="nick_lowercase" type="boolean" scope="global"> + <default>true</default> + + <description> + <para> + If enabled, all nicknames are turned into lower case. + </para> + + <para> + See also the <emphasis>nick_underscores</emphasis> setting. This setting was previously known as <emphasis>lcnicks</emphasis>. + </para> + </description> + + </bitlbee-setting> + + <bitlbee-setting name="nick_underscores" type="boolean" scope="global"> + <default>true</default> + + <description> + <para> + If enabled, spaces in nicknames are turned into underscores instead of being stripped. + </para> + + <para> + See also the <emphasis>nick_lowercase</emphasis> setting. + </para> + </description> + + </bitlbee-setting> + <bitlbee-setting name="oauth" type="boolean" scope="account"> <default>true</default> @@ -1849,12 +1868,16 @@ <bitlbee-command name="plugins"> <short-description>List all the external plugins and protocols</short-description> - <syntax>plugins</syntax> + <syntax>plugins [info <name>]</syntax> <description> <para> This gives you a list of all the external plugins and protocols. </para> + + <para> + Use the <emphasis>info</emphasis> subcommand to get more details about a plugin. + </para> </description> </bitlbee-command> 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) 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: <varlistentry><term>away</term><listitem><para>About setting away states</para></listitem></varlistentry> <varlistentry><term>groupchats</term><listitem><para>How to work with groupchats on BitlBee</para></listitem></varlistentry> <varlistentry><term>nick_changes</term><listitem><para>Changing your nickname without losing any settings</para></listitem></varlistentry> - <varlistentry><term>smileys</term><listitem><para>A summary of some non-standard smileys you might find and fail to understand</para></listitem></varlistentry> + <varlistentry><term>identify_methods</term><listitem><para>A list of ways to (auto-)identify to your account</para></listitem></varlistentry> </variablelist> <para> @@ -48,7 +48,7 @@ These are the available help subjects: <varlistentry><term>away</term><listitem><para>About setting away states</para></listitem></varlistentry> <varlistentry><term>groupchats</term><listitem><para>How to work with groupchats on BitlBee</para></listitem></varlistentry> <varlistentry><term>nick_changes</term><listitem><para>Changing your nickname without losing any settings</para></listitem></varlistentry> - <varlistentry><term>smileys</term><listitem><para>A summary of some non-standard smileys you might find and fail to understand</para></listitem></varlistentry> + <varlistentry><term>identify_methods</term><listitem><para>A list of ways to (auto-)identify to your account</para></listitem></varlistentry> </variablelist> <para> 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 <emphasis>/invite</emphasis> command to invite m </para> <para> -Some protocols (like Jabber) also support named groupchats. BitlBee now supports these too. You can use the <emphasis>chat add</emphasis> command to join them. See <emphasis>help chat add</emphasis> for more information. +Some protocols (like Jabber) also support named groupchats. BitlBee supports these too. You can use the <emphasis>chat add</emphasis> command to join them. See <emphasis>help chat add</emphasis> for more information. </para> +<para> +If you don't know the name of a named groupchat, you can try the <emphasis>chat list</emphasis> command to get a list of chatrooms from a server. See <emphasis>help chat list</emphasis> for usage instructions. +</para> </sect1> <sect1 id="away"> @@ -267,6 +270,40 @@ everything in the handle up to the first @. </sect1> +<sect1 id="identify_methods"> +<title>Identifying to your BitlBee account</title> + +<para>There are several methods to identify (log in) to your registered BitlBee account. All of these are equivalent:</para> + +<variablelist> + <varlistentry> + <term>The 'identify' command</term> + <listitem><para>sent to &bitlbee or root. See <emphasis>help identify</emphasis> for details.</para></listitem> + </varlistentry> + <varlistentry> + <term>/msg nickserv identify</term> + <listitem><para>Same as above, but sent to NickServ. Useful with some auto-identify scripts.</para></listitem> + </varlistentry> + <varlistentry> + <term>/nickserv or /ns</term> + <listitem><para>Same as above, but using the command aliases to NickServ.</para></listitem> + </varlistentry> + <varlistentry> + <term>Server password</term> + <listitem><para>A field in the server connection settings of your irc client.</para></listitem> + </varlistentry> + <varlistentry> + <term>SASL PLAIN</term> + <listitem><para>A newer method, good choice if your client supports it. (Note: "SASL" is <emphasis>not</emphasis> related to "SSL")</para></listitem> + </varlistentry> +</variablelist> + +<para>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.</para> + +<para>Note: If you changed bitlbee.conf to have <emphasis>AuthMode = Closed</emphasis>, 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.</para> + +</sect1> + <sect1 id="whatsnew010206"> <title>New stuff in BitlBee 1.2.6</title> 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 @@ <title>Quickstart</title> <para> -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. </para> <para> @@ -42,7 +42,11 @@ For instance, suppose you have a Jabber account at jabber.org with handle <empha </ircexample> <para> -Other available IM protocols are msn, oscar, yahoo and twitter. OSCAR is the protocol used by ICQ and AOL. For more information about the <emphasis>account add</emphasis> command, see <emphasis>help account add</emphasis>. +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. +</para> + +<para> +For a list of currently supported protocols, use the <emphasis>plugins</emphasis> command. For more information about the <emphasis>account add</emphasis> command, see <emphasis>help account add</emphasis>. </para> <para> @@ -135,7 +139,7 @@ For more subjects (like groupchats and away states), please type <emphasis>help </para> <para> -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! </para> </sect1> @@ -116,8 +116,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, "ops_mode", "@", set_eval_irc_channel_ops_mode, irc); diff --git a/irc_channel.c b/irc_channel.c index 7adc1893..ee81a597 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -642,7 +642,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); } @@ -646,10 +646,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"); @@ -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++; 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 5035a156..fad6976f 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; - struct plugin_info *info; + 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(); 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 edd1e9c3..2515f07e 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); @@ -379,6 +402,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")) { @@ -916,17 +943,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) { @@ -1400,16 +1432,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); @@ -1418,7 +1464,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); } @@ -1640,6 +1686,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 +1790,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 +1825,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 b1ca8296..edc17855 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1207,36 +1207,80 @@ 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 (strchr(irc->umode, 'b') != NULL) { + format = "%s\t%s"; + } else { + format = "%-30s %s"; + } - if (info->description) { - irc_rootmsg(irc, " Description: %s", info->description); - } + irc_rootmsg(irc, format, "Plugin", "Version"); - if (info->author) { - irc_rootmsg(irc, " Author: %s", info->author); - } + for (l = get_plugins(); l; l = l->next) { + char *c; + info = l->data; - if (info->url) { - irc_rootmsg(irc, " URL: %s", info->url); + /* 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); } - - irc_rootmsg(irc, ""); } #endif + irc_rootmsg(irc, ""); + gstr = g_string_new(NULL); prpls = get_protocols(); @@ -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); |