From 7709a56204585294a8d3c6c3ff11106b95e7011d Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Sat, 23 Apr 2011 13:38:15 +0300 Subject: [PATCH 2/3] Handle RPL_WHOISOPERATOR messages in response to RequestContactInfo Fixes: https://bugs.freedesktop.org/34796 --- src/idle-contact-info.c | 18 ++++++++++++++++++ src/idle-parser.c | 1 + src/idle-parser.h | 1 + 3 files changed, 20 insertions(+), 0 deletions(-) diff --git a/src/idle-contact-info.c b/src/idle-contact-info.c index da7136b..fbafda5 100644 --- a/src/idle-contact-info.c +++ b/src/idle-contact-info.c @@ -34,6 +34,7 @@ struct _ContactInfoRequest { guint handle; const gchar *nick; gboolean is_away; + gboolean is_operator; gboolean is_reg_nick; GPtrArray *contact_info; DBusGMethodInvocation *context; @@ -102,6 +103,7 @@ static void _queue_request_contact_info(IdleConnection *conn, guint handle, cons request->handle = handle; request->nick = nick; request->is_away = FALSE; + request->is_operator = FALSE; request->is_reg_nick = FALSE; request->contact_info = NULL; request->context = context; @@ -186,6 +188,9 @@ static IdleParserHandlerResult _end_of_whois_handler(IdleParser *parser, IdlePar _insert_contact_field(request->contact_info, "x-presence-status-message", NULL, field_values); } + field_values[0] = (request->is_operator) ? "true" : "false"; + _insert_contact_field(request->contact_info, "x-irc-operator", NULL, field_values); + field_values[0] = (request->is_reg_nick) ? "true" : "false"; _insert_contact_field(request->contact_info, "x-irc-registered-nick", NULL, field_values); @@ -364,6 +369,18 @@ static IdleParserHandlerResult _whois_logged_in_handler(IdleParser *parser, Idle return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; } +static IdleParserHandlerResult _whois_operator_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { + IdleConnection *conn = IDLE_CONNECTION(user_data); + ContactInfoRequest *request = _get_matching_request(conn, args); + + if (request == NULL) + return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; + + request->is_operator = TRUE; + + return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; +} + static IdleParserHandlerResult _whois_reg_nick_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { IdleConnection *conn = IDLE_CONNECTION(user_data); ContactInfoRequest *request = _get_matching_request(conn, args); @@ -457,6 +474,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_WHOISOPERATOR, _whois_operator_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_AWAY, _away_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISHOST, _whois_host_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISREGNICK, _whois_reg_nick_handler, conn); diff --git a/src/idle-parser.c b/src/idle-parser.c index 0610416..f65108f 100644 --- a/src/idle-parser.c +++ b/src/idle-parser.c @@ -113,6 +113,7 @@ static const MessageSpec message_specs[] = { {"319", "IIIc.", IDLE_PARSER_NUMERIC_WHOISCHANNELS}, {"378", "IIIc:", IDLE_PARSER_NUMERIC_WHOISHOST}, {"330", "IIIcs:", IDLE_PARSER_NUMERIC_WHOISLOGGEDIN}, + {"313", "IIIc:", IDLE_PARSER_NUMERIC_WHOISOPERATOR}, {"307", "IIIc:", IDLE_PARSER_NUMERIC_WHOISREGNICK}, {"312", "IIIcs:", IDLE_PARSER_NUMERIC_WHOISSERVER}, {"311", "IIIcssI:", IDLE_PARSER_NUMERIC_WHOISUSER}, diff --git a/src/idle-parser.h b/src/idle-parser.h index b756224..caa2d36 100644 --- a/src/idle-parser.h +++ b/src/idle-parser.h @@ -86,6 +86,7 @@ typedef enum { IDLE_PARSER_NUMERIC_WHOISCHANNELS, IDLE_PARSER_NUMERIC_WHOISHOST, IDLE_PARSER_NUMERIC_WHOISLOGGEDIN, + IDLE_PARSER_NUMERIC_WHOISOPERATOR, IDLE_PARSER_NUMERIC_WHOISREGNICK, IDLE_PARSER_NUMERIC_WHOISSERVER, IDLE_PARSER_NUMERIC_WHOISUSER, -- 1.7.4.4