1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Handle errors for /disco info requests

This commit is contained in:
James Booth 2014-09-24 00:30:05 +01:00
parent 999525c6aa
commit 95a2cec953
5 changed files with 24 additions and 3 deletions

View File

@ -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)
{

View File

@ -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,

View File

@ -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);