From 95a2cec9532cfaec91ed8285e69419d38e9b8a17 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 24 Sep 2014 00:30:05 +0100 Subject: [PATCH] Handle errors for /disco info requests --- src/server_events.c | 10 ++++++++++ src/server_events.h | 1 + src/ui/core.c | 2 +- src/xmpp/capabilities.c | 2 +- src/xmpp/iq.c | 12 +++++++++++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/server_events.c b/src/server_events.c index e79896ca..f89385c6 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -154,6 +154,16 @@ handle_disco_info(const char *from, GSList *identities, GSList *features) cons_show_disco_info(from, identities, features); } +void +handle_disco_info_error(const char * const from, const char * const error) +{ + if (from) { + cons_show_error("Service discovery failed for %s: %s", from, error); + } else { + cons_show_error("Service discovery failed: %s", error); + } +} + void handle_room_list(GSList *rooms, const char *conference_node) { diff --git a/src/server_events.h b/src/server_events.h index acb8f94c..41506cdb 100644 --- a/src/server_events.h +++ b/src/server_events.h @@ -43,6 +43,7 @@ void handle_failed_login(void); void handle_software_version_result(const char * const jid, const char * const presence, const char * const name, const char * const version, const char * const os); void handle_disco_info(const char *from, GSList *identities, GSList *features); +void handle_disco_info_error(const char * const from, const char * const error); void handle_room_list(GSList *rooms, const char *conference_node); void handle_disco_items(GSList *items, const char *jid); void handle_room_invite(jabber_invite_t invite_type, diff --git a/src/ui/core.c b/src/ui/core.c index 22f3be93..b5c01896 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2129,7 +2129,7 @@ _ui_handle_room_config_submit_result(const char * const room) cons_show("Room configuration successfull: %s", room); } } else { - cons_show("Room configuration successful"); + cons_show("Room configuration successful"); } } diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index 2cf41226..94523a30 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -400,7 +400,7 @@ caps_create(xmpp_stanza_t *query) } if (found) { break; - } + } curr_identity = g_slist_next(curr_identity); } diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 81ba6e09..f701aa53 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -812,8 +812,18 @@ static int _disco_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { - log_debug("Received diso#info response"); + log_info("Received diso#info response"); + const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + const char *type = xmpp_stanza_get_type(stanza); + + // handle error responses + if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { + char *error_message = stanza_get_error_message(stanza); + handle_disco_info_error(from, error_message); + free(error_message); + return 0; + } xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);