mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Show error text if received
This commit is contained in:
parent
a5082a54bd
commit
7799623b4a
@ -1093,6 +1093,7 @@ _cmd_close(const char * const inp, struct cmd_help_t help)
|
|||||||
if (win_in_groupchat()) {
|
if (win_in_groupchat()) {
|
||||||
char *room_jid = win_get_recipient();
|
char *room_jid = win_get_recipient();
|
||||||
jabber_leave_chat_room(room_jid);
|
jabber_leave_chat_room(room_jid);
|
||||||
|
win_close_win();
|
||||||
} else if (win_in_chat()) {
|
} else if (win_in_chat()) {
|
||||||
|
|
||||||
if (prefs_get_states()) {
|
if (prefs_get_states()) {
|
||||||
|
51
src/jabber.c
51
src/jabber.c
@ -389,27 +389,38 @@ _groupchat_message_handler(xmpp_stanza_t * const stanza)
|
|||||||
static int
|
static int
|
||||||
_error_handler(xmpp_stanza_t * const stanza)
|
_error_handler(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
char *err_msg = NULL;
|
gchar *err_msg = NULL;
|
||||||
xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
|
|
||||||
|
|
||||||
if (error == NULL) {
|
|
||||||
log_debug("error message without <error/> received");
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error);
|
|
||||||
|
|
||||||
if (err_cond == NULL) {
|
|
||||||
log_debug("error message without <defined-condition/> received");
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
err_msg = xmpp_stanza_get_name(err_cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: process 'type' attribute from <error/> [RFC6120, 8.3.2]
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||||
prof_handle_error_message(from, err_msg);
|
xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
|
||||||
|
xmpp_stanza_t *text_stanza =
|
||||||
|
xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT);
|
||||||
|
|
||||||
|
if (error_stanza == NULL) {
|
||||||
|
log_debug("error message without <error/> received");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// check for text
|
||||||
|
if (text_stanza != NULL) {
|
||||||
|
err_msg = xmpp_stanza_get_text(text_stanza);
|
||||||
|
prof_handle_error_message(from, err_msg);
|
||||||
|
|
||||||
|
// TODO : process 'type' attribute from <error/> [RFC6120, 8.3.2]
|
||||||
|
|
||||||
|
// otherwise show defined-condition
|
||||||
|
} else {
|
||||||
|
xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error_stanza);
|
||||||
|
|
||||||
|
if (err_cond == NULL) {
|
||||||
|
log_debug("error message without <defined-condition/> or <text/> received");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
err_msg = xmpp_stanza_get_name(err_cond);
|
||||||
|
prof_handle_error_message(from, err_msg);
|
||||||
|
|
||||||
|
// TODO : process 'type' attribute from <error/> [RFC6120, 8.3.2]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,6 @@ void
|
|||||||
prof_handle_leave_room(const char * const room)
|
prof_handle_leave_room(const char * const room)
|
||||||
{
|
{
|
||||||
room_leave(room);
|
room_leave(room);
|
||||||
win_close_win();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#define STANZA_NAME_DELAY "delay"
|
#define STANZA_NAME_DELAY "delay"
|
||||||
#define STANZA_NAME_ERROR "error"
|
#define STANZA_NAME_ERROR "error"
|
||||||
#define STANZA_NAME_PING "ping"
|
#define STANZA_NAME_PING "ping"
|
||||||
|
#define STANZA_NAME_TEXT "text"
|
||||||
|
|
||||||
#define STANZA_TYPE_CHAT "chat"
|
#define STANZA_TYPE_CHAT "chat"
|
||||||
#define STANZA_TYPE_GROUPCHAT "groupchat"
|
#define STANZA_TYPE_GROUPCHAT "groupchat"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user