From 41bafbc0bbbbc8a0fe8773920f26e39c3a8a5d1f Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Sat, 12 Mar 2011 04:33:52 +0200 Subject: [PATCH 2/2] Handle ERROR messages A new MessageSpec was added for it. Fixes: https://bugs.freedesktop.org/35239 --- src/idle-connection.c | 10 ++++++++++ src/idle-parser.c | 1 + src/idle-parser.h | 3 ++- 3 files changed, 13 insertions(+), 1 deletions(-) diff --git a/src/idle-connection.c b/src/idle-connection.c index d8fada9..1674850 100644 --- a/src/idle-connection.c +++ b/src/idle-connection.c @@ -190,6 +190,7 @@ static void _iface_disconnected(TpBaseConnection *self); static void _iface_shut_down(TpBaseConnection *self); static gboolean _iface_start_connecting(TpBaseConnection *self, GError **error); +static IdleParserHandlerResult _error_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data); static IdleParserHandlerResult _erroneous_nickname_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data); static IdleParserHandlerResult _nick_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data); static IdleParserHandlerResult _nickname_in_use_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data); @@ -636,6 +637,7 @@ static void _start_connecting_continue(IdleConnection *conn) { g_signal_connect(sconn, "received", (GCallback)(sconn_received_cb), conn); + idle_parser_add_handler(conn->parser, IDLE_PARSER_CMD_ERROR, _error_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_ERRONEOUSNICKNAME, _erroneous_nickname_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_NICKNAMEINUSE, _nickname_in_use_handler, conn); idle_parser_add_handler(conn->parser, IDLE_PARSER_NUMERIC_WELCOME, _welcome_handler, conn); @@ -851,6 +853,14 @@ idle_connection_get_max_message_length(IdleConnection *conn) return IRC_MSG_MAXLEN - 100; } +static IdleParserHandlerResult _error_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { + IdleConnection *conn = IDLE_CONNECTION(user_data); + + connection_connect_cb(conn, FALSE, TP_CONNECTION_STATUS_REASON_NETWORK_ERROR); + + return IDLE_PARSER_HANDLER_RESULT_HANDLED; +} + static IdleParserHandlerResult _erroneous_nickname_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) { IdleConnection *conn = IDLE_CONNECTION(user_data); diff --git a/src/idle-parser.c b/src/idle-parser.c index 42ffb83..f595553 100644 --- a/src/idle-parser.c +++ b/src/idle-parser.c @@ -72,6 +72,7 @@ struct _MessageSpec { * '.' - Same as ':', but optional */ static const MessageSpec message_specs[] = { + {"ERROR", "I:", IDLE_PARSER_CMD_ERROR}, {"PING", "Is", IDLE_PARSER_CMD_PING}, {"INVITE", "cIcr", IDLE_PARSER_PREFIXCMD_INVITE}, diff --git a/src/idle-parser.h b/src/idle-parser.h index c47142a..f586380 100644 --- a/src/idle-parser.h +++ b/src/idle-parser.h @@ -46,7 +46,8 @@ G_BEGIN_DECLS (G_TYPE_INSTANCE_GET_CLASS((obj), IDLE_TYPE_PARSER, IdleParserClass)) typedef enum { - IDLE_PARSER_CMD_PING = 0, + IDLE_PARSER_CMD_ERROR = 0, + IDLE_PARSER_CMD_PING, IDLE_PARSER_PREFIXCMD_INVITE, IDLE_PARSER_PREFIXCMD_JOIN, -- 1.7.4