From a4b6d5da0c832805870edf0754bdef4ab98adcc9 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 18 Mar 2011 18:56:28 +0200 Subject: [PATCH 3/3] Handle RPL_WHOISSECURE messages in response to RequestContactInfo The RPL_WHOISSECURE message indicates whether the nick against which the WHOIS message was sent is connected securely. This is an extension of RFC 2812 implemented by some IRC daemons. eg., ircd-seven (http://ur1.ca/3khrh), ShadowIRCd (http://ur1.ca/3khsr) and UnrealIRCd (http://ur1.ca/43e4r). 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 fbafda5..1bff856 100644 --- a/src/idle-contact-info.c +++ b/src/idle-contact-info.c @@ -36,6 +36,7 @@ struct _ContactInfoRequest { gboolean is_away; gboolean is_operator; gboolean is_reg_nick; + gboolean is_secure; GPtrArray *contact_info; DBusGMethodInvocation *context; }; @@ -105,6 +106,7 @@ static void _queue_request_contact_info(IdleConnection *conn, guint handle, cons request->is_away = FALSE; request->is_operator = FALSE; request->is_reg_nick = FALSE; + request->is_secure = FALSE; request->contact_info = NULL; request->context = context; @@ -194,6 +196,9 @@ static IdleParserHandlerResult _end_of_whois_handler(IdleParser *parser, IdlePar field_values[0] = (request->is_reg_nick) ? "true" : "false"; _insert_contact_field(request->contact_info, "x-irc-registered-nick", NULL, field_values); + field_values[0] = (request->is_secure) ? "true" : "false"; + _insert_contact_field(request->contact_info, "x-irc-secure-connection", NULL, field_values); + _return_from_request_contact_info(conn); return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; } @@ -393,6 +398,18 @@ static IdleParserHandlerResult _whois_reg_nick_handler(IdleParser *parser, IdleP return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED; } +static IdleParserHandlerResult _whois_secure_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_secure = TRUE; + + 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 = _get_matching_request(conn, args); @@ -478,6 +495,7 @@ void idle_contact_info_init (IdleConnection *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); + idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WHOISSECURE, _whois_secure_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); diff --git a/src/idle-parser.c b/src/idle-parser.c index f65108f..1019b32 100644 --- a/src/idle-parser.c +++ b/src/idle-parser.c @@ -115,6 +115,7 @@ static const MessageSpec message_specs[] = { {"330", "IIIcs:", IDLE_PARSER_NUMERIC_WHOISLOGGEDIN}, {"313", "IIIc:", IDLE_PARSER_NUMERIC_WHOISOPERATOR}, {"307", "IIIc:", IDLE_PARSER_NUMERIC_WHOISREGNICK}, + {"671", "IIIc:", IDLE_PARSER_NUMERIC_WHOISSECURE}, {"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 caa2d36..51b1bc7 100644 --- a/src/idle-parser.h +++ b/src/idle-parser.h @@ -88,6 +88,7 @@ typedef enum { IDLE_PARSER_NUMERIC_WHOISLOGGEDIN, IDLE_PARSER_NUMERIC_WHOISOPERATOR, IDLE_PARSER_NUMERIC_WHOISREGNICK, + IDLE_PARSER_NUMERIC_WHOISSECURE, IDLE_PARSER_NUMERIC_WHOISSERVER, IDLE_PARSER_NUMERIC_WHOISUSER, IDLE_PARSER_NUMERIC_WHOISIDLE, -- 1.7.4.4