From 7fc8fcb7c759b1996bfdc91efa90a73d1147bbcd Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 18 Mar 2011 18:56:28 +0200 Subject: [PATCH] Handle RPL_WHOISLOGGEDIN messages in response to RequestContactInfo The RPL_WHOISLOGGEDIN message indicates the account name of the nick against which the WHOIS message was sent. On Freenode, a user's account name and primary nick are one and the same. This is an extension of RFC 2812 implemented by some IRC daemons. eg., ircd-seven (http://ur1.ca/3khrh) and ShadowIRCd (http://ur1.ca/3khsr). Fixes: https://bugs.freedesktop.org/34796 --- src/idle-contact-info.c | 22 ++++++++++++++++++++++ src/idle-parser.c | 1 + src/idle-parser.h | 1 + 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/src/idle-contact-info.c b/src/idle-contact-info.c index f259428..5d055e8 100644 --- a/src/idle-contact-info.c +++ b/src/idle-contact-info.c @@ -352,6 +352,27 @@ static IdleParserHandlerResult _whois_idle_handler(IdleParser *parser, IdleParse return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; } +static IdleParserHandlerResult _whois_logged_in_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { + IdleConnection *conn = IDLE_CONNECTION(user_data); + ContactInfoRequest *request; + const gchar *nick; + const gchar *field_values[2] = {NULL, NULL}; + + if (!_is_valid_response(conn, args)) + return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; + + request = g_queue_peek_head(conn->contact_info_requests); + + if (request->contact_info == NULL) + request->contact_info = dbus_g_type_specialized_construct(TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST); + + nick = g_value_get_string(g_value_array_get_nth(args, 1)); + field_values[0] = nick; + _insert_contact_field(request->contact_info, "nickname", NULL, field_values); + + return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; +} + static IdleParserHandlerResult _whois_user_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { IdleConnection *conn = IDLE_CONNECTION(user_data); ContactInfoRequest *request; @@ -412,6 +433,7 @@ void idle_contact_info_init (IdleConnection *conn) { idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISCHANNELS, _whois_channels_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_AWAY, _away_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISIDLE, _whois_idle_handler, conn); + idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISLOGGEDIN, _whois_logged_in_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_ENDOFWHOIS, _end_of_whois_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_NOSUCHSERVER, _no_such_server_handler, conn); diff --git a/src/idle-parser.c b/src/idle-parser.c index 8110757..446d43f 100644 --- a/src/idle-parser.c +++ b/src/idle-parser.c @@ -109,6 +109,7 @@ static const MessageSpec message_specs[] = { {"305", "III", IDLE_PARSER_NUMERIC_UNAWAY}, {"001", "IIc", IDLE_PARSER_NUMERIC_WELCOME}, {"319", "IIIc.", IDLE_PARSER_NUMERIC_WHOISCHANNELS}, + {"330", "IIIcs:", IDLE_PARSER_NUMERIC_WHOISLOGGEDIN}, {"311", "IIIcssI:", IDLE_PARSER_NUMERIC_WHOISUSER}, {"317", "IIIcd", IDLE_PARSER_NUMERIC_WHOISIDLE}, diff --git a/src/idle-parser.h b/src/idle-parser.h index 8aa3a78..f5053cb 100644 --- a/src/idle-parser.h +++ b/src/idle-parser.h @@ -83,6 +83,7 @@ typedef enum { IDLE_PARSER_NUMERIC_UNAWAY, IDLE_PARSER_NUMERIC_WELCOME, IDLE_PARSER_NUMERIC_WHOISCHANNELS, + IDLE_PARSER_NUMERIC_WHOISLOGGEDIN, IDLE_PARSER_NUMERIC_WHOISUSER, IDLE_PARSER_NUMERIC_WHOISIDLE, -- 1.7.4