From 55fe2b4b730ba3c891f35689b006fc855c865dae Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Sat, 23 Apr 2011 13:38:15 +0300 Subject: [PATCH] Handle RPL_WHOISSERVER messages in response to RequestContactInfo Fixes: https://bugs.freedesktop.org/34796 --- src/idle-contact-info.c | 25 +++++++++++++++++++++++++ src/idle-parser.c | 1 + src/idle-parser.h | 1 + 3 files changed, 27 insertions(+), 0 deletions(-) diff --git a/src/idle-contact-info.c b/src/idle-contact-info.c index e064b83..809d8cf 100644 --- a/src/idle-contact-info.c +++ b/src/idle-contact-info.c @@ -313,6 +313,30 @@ static IdleParserHandlerResult _whois_logged_in_handler(IdleParser *parser, Idle return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; } +static IdleParserHandlerResult _whois_server_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { + IdleConnection *conn = IDLE_CONNECTION(user_data); + ContactInfoRequest *request; + const gchar *server; + const gchar *server_info; + const gchar *field_values[3] = {NULL, 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); + + server = g_value_get_string(g_value_array_get_nth(args, 1)); + server_info = g_value_get_string(g_value_array_get_nth(args, 2)); + field_values[0] = server; + field_values[1] = server_info; + _insert_contact_field(request->contact_info, "x-irc-server", 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; @@ -379,6 +403,7 @@ void idle_contact_info_init (IdleConnection *conn) { idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISUSER, _whois_user_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISCHANNELS, _whois_channels_handler, conn); + idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISSERVER, _whois_server_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); diff --git a/src/idle-parser.c b/src/idle-parser.c index 2886016..68a6bcb 100644 --- a/src/idle-parser.c +++ b/src/idle-parser.c @@ -111,6 +111,7 @@ static const MessageSpec message_specs[] = { {"001", "IIc", IDLE_PARSER_NUMERIC_WELCOME}, {"319", "IIIc.", IDLE_PARSER_NUMERIC_WHOISCHANNELS}, {"330", "IIIcs:", IDLE_PARSER_NUMERIC_WHOISLOGGEDIN}, + {"312", "IIIcs:", IDLE_PARSER_NUMERIC_WHOISSERVER}, {"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 f5053cb..3cbb9d3 100644 --- a/src/idle-parser.h +++ b/src/idle-parser.h @@ -84,6 +84,7 @@ typedef enum { IDLE_PARSER_NUMERIC_WELCOME, IDLE_PARSER_NUMERIC_WHOISCHANNELS, IDLE_PARSER_NUMERIC_WHOISLOGGEDIN, + IDLE_PARSER_NUMERIC_WHOISSERVER, IDLE_PARSER_NUMERIC_WHOISUSER, IDLE_PARSER_NUMERIC_WHOISIDLE, -- 1.7.4.4