mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into plugins
This commit is contained in:
commit
cc487799cd
@ -54,12 +54,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_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -358,25 +358,32 @@ _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("");
|
||||
|
||||
// Message sent to chat room which hasn't been entered yet
|
||||
if (win->type == WIN_MUC) {
|
||||
g_string_printf(msg, "You have not joined %s.", from);
|
||||
// no window for intended recipient, show message in current and console
|
||||
if (win == NULL) {
|
||||
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) {
|
||||
win_print_line(win, '!', COLOUR_ERROR, msg->str);
|
||||
}
|
||||
|
||||
// intended recipient was invalid chat room
|
||||
} else if (win->type == WIN_MUC) {
|
||||
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_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);
|
||||
}
|
||||
|
||||
wins_refresh_current();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
if (id != NULL) {
|
||||
log_info("Error recieved (id=%s): %s", id, err_msg);
|
||||
} else {
|
||||
log_info("Error received: %s", err_msg);
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
|
||||
xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
|
||||
char *type = NULL;
|
||||
if (error_stanza != NULL) {
|
||||
@ -211,8 +224,8 @@ _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)))) {
|
||||
log_info("Recipient %s not found.", from);
|
||||
handle_recipient_not_found(from);
|
||||
char *cpy = strdup(from);
|
||||
handle_recipient_not_found(cpy, err_msg);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user