mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Use stanza_get_error_message for pong errors
This commit is contained in:
parent
273cddd661
commit
3417f25dd1
@ -261,7 +261,16 @@ static int
|
||||
_manual_pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza,
|
||||
void * const userdata)
|
||||
{
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
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_ping_error_result(from, error_message);
|
||||
free(error_message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GDateTime *sent = (GDateTime *)userdata;
|
||||
GDateTime *now = g_date_time_new_now_local();
|
||||
@ -272,46 +281,6 @@ _manual_pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza,
|
||||
g_date_time_unref(sent);
|
||||
g_date_time_unref(now);
|
||||
|
||||
char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
char *type = xmpp_stanza_get_type(stanza);
|
||||
|
||||
// handle error responses
|
||||
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
|
||||
xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
|
||||
|
||||
// no error stanza
|
||||
if (error == NULL) {
|
||||
handle_ping_error_result(from, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// no children of error stanza
|
||||
xmpp_stanza_t *error_child = xmpp_stanza_get_children(error);
|
||||
if (error_child == NULL) {
|
||||
handle_ping_error_result(from, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// text child found
|
||||
xmpp_stanza_t *error_text_stanza = xmpp_stanza_get_child_by_name(error, STANZA_NAME_TEXT);
|
||||
if (error_text_stanza != NULL) {
|
||||
char *error_text = xmpp_stanza_get_text(error_text_stanza);
|
||||
|
||||
// text found
|
||||
if (error_text != NULL) {
|
||||
handle_ping_error_result(from, error_text);
|
||||
xmpp_free(ctx, error_text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// no text child found
|
||||
} else {
|
||||
char *error_child_name = xmpp_stanza_get_name(error_child);
|
||||
handle_ping_error_result(from, error_child_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
handle_ping_result(from, elapsed_millis);
|
||||
|
||||
return 0;
|
||||
|
@ -968,6 +968,8 @@ stanza_get_error_message(xmpp_stanza_t *stanza)
|
||||
if (error_stanza == NULL) {
|
||||
return strdup("unknown");
|
||||
} else {
|
||||
|
||||
// check for text child
|
||||
xmpp_stanza_t *text_stanza = xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT);
|
||||
|
||||
// check for text
|
||||
|
Loading…
Reference in New Issue
Block a user