diff options
-rw-r--r-- | src/server_events.c | 9 | ||||
-rw-r--r-- | src/server_events.h | 2 | ||||
-rw-r--r-- | src/ui/core.c | 13 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | src/xmpp/message.c | 26 |
5 files changed, 30 insertions, 22 deletions
diff --git a/src/server_events.c b/src/server_events.c index 8400de8d..938572a0 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -53,12 +53,11 @@ handle_error_message(const char *from, const char *err_msg) } void -handle_recipient_not_found(const char *from) +handle_recipient_not_found(const char * const recipient, const char * const err_msg) { - log_info("Removing chat session for %s", from); - ui_handle_recipient_not_found(from); - if (prefs_get_boolean(PREF_STATES) && chat_session_exists(from)) { - chat_session_set_recipient_supports(from, FALSE); + ui_handle_recipient_not_found(recipient, err_msg); + if (prefs_get_boolean(PREF_STATES) && chat_session_exists(recipient)) { + chat_session_set_recipient_supports(recipient, FALSE); } } diff --git a/src/server_events.h b/src/server_events.h index 34f99c79..794d96dc 100644 --- a/src/server_events.h +++ b/src/server_events.h @@ -75,6 +75,6 @@ void handle_group_remove(const char * const contact, void handle_roster_remove(const char * const barejid); void handle_roster_add(const char * const barejid, const char * const name); void handle_autoping_cancel(void); -void handle_recipient_not_found(const char *from); +void handle_recipient_not_found(const char * const recipient, const char * const err_msg); #endif diff --git a/src/ui/core.c b/src/ui/core.c index dd27aa1a..a59225c8 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -355,14 +355,14 @@ _ui_handle_error_message(const char * const from, const char * const err_msg) } static void -_ui_handle_recipient_not_found(const char * const from) +_ui_handle_recipient_not_found(const char * const recipient, const char * const err_msg) { - ProfWin *win = wins_get_by_recipient(from); + ProfWin *win = wins_get_by_recipient(recipient); GString *msg = g_string_new(""); // no window for intended recipient, show message in current and console if (win == NULL) { - g_string_printf(msg, "Recipient %s not found at server.", from); + g_string_printf(msg, "Recipient %s not found: %s", recipient, err_msg); cons_show_error(msg->str); win = wins_get_current(); if (win->type != WIN_CONSOLE) { @@ -371,16 +371,13 @@ _ui_handle_recipient_not_found(const char * const from) // intended recipient was invalid chat room } else if (win->type == WIN_MUC) { - g_string_printf(msg, "You have not joined %s.", from); + g_string_printf(msg, "Room %s not found: %s", recipient, err_msg); cons_show_error(msg->str); win_print_line(win, '!', COLOUR_ERROR, msg->str); // unknown chat recipient } else { - if (prefs_get_boolean(PREF_STATES) && chat_session_exists(from)) { - chat_session_set_recipient_supports(from, FALSE); - } - g_string_printf(msg, "Recipient %s not found at server.", from); + g_string_printf(msg, "Recipient %s not found: %s", recipient, err_msg); cons_show_error(msg->str); win_print_line(win, '!', COLOUR_ERROR, msg->str); } diff --git a/src/ui/ui.h b/src/ui/ui.h index 11ffa765..837a8a3a 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -130,7 +130,7 @@ void (*ui_group_added)(const char * const contact, const char * const group); void (*ui_group_removed)(const char * const contact, const char * const group); void (*ui_chat_win_contact_online)(PContact contact, Resource *resource, GDateTime *last_activity); void (*ui_chat_win_contact_offline)(PContact contact, char *resource, char *status); -void (*ui_handle_recipient_not_found)(const char * const from); +void (*ui_handle_recipient_not_found)(const char * const recipient, const char * const err_msg); // contact status functions void (*ui_status_room)(const char * const contact); diff --git a/src/xmpp/message.c b/src/xmpp/message.c index d814d59d..236999b9 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -194,15 +194,28 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { // log message, function never returns NULL - char *err_msg = stanza_get_error_message(stanza); char *id = xmpp_stanza_get_id(stanza); + char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + char *err_msg = stanza_get_error_message(stanza); + + GString *log_msg = g_string_new("Error receievd"); if (id != NULL) { - log_info("Error recieved (id=%s): %s", id, err_msg); - } else { - log_info("Error received: %s", err_msg); + g_string_append(log_msg, " (id:"); + g_string_append(log_msg, id); + g_string_append(log_msg, ")"); + } + if (from != NULL) { + g_string_append(log_msg, " (from:"); + g_string_append(log_msg, from); + g_string_append(log_msg, ")"); } + g_string_append(log_msg, ", error: "); + g_string_append(log_msg, err_msg); + + log_info(log_msg->str); + + g_string_free(log_msg, TRUE); - char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); char *type = NULL; if (error_stanza != NULL) { @@ -212,8 +225,7 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, // handle recipient not found if ((from != NULL) && ((type != NULL && (strcmp(type, "cancel") == 0)))) { char *cpy = strdup(from); - log_info("Recipient %s not found.", cpy); - handle_recipient_not_found(cpy); + handle_recipient_not_found(cpy, err_msg); } return 1; |