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

Show different message when disconnected

Also show message in active chat windows
This commit is contained in:
James Booth 2012-04-19 21:03:48 +01:00
parent 2514be4b78
commit 9805b2b2b2
3 changed files with 27 additions and 1 deletions

View File

@ -221,7 +221,12 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
jabber_conn.conn_status = JABBER_CONNECTED; jabber_conn.conn_status = JABBER_CONNECTED;
} }
else { else {
if (jabber_conn.conn_status == JABBER_CONNECTED) {
cons_bad_show("Lost connection.");
win_disconnected();
} else {
cons_bad_show("Login failed."); cons_bad_show("Login failed.");
}
win_page_off(); win_page_off();
log_msg(CONN, "disconnected"); log_msg(CONN, "disconnected");
xmpp_stop(ctx); xmpp_stop(ctx);

View File

@ -214,6 +214,26 @@ void win_contact_offline(const char * const from, const char * const show,
dirty = TRUE; dirty = TRUE;
} }
void win_disconnected(void)
{
int i;
// show message in all active chats
for (i = 1; i < NUM_WINS; i++) {
if (strcmp(_wins[i].from, "") != 0) {
WINDOW *win = _wins[_curr_prof_win].win;
_win_show_time(win);
wattron(win, COLOR_PAIR(6));
wprintw(win, "%s\n", "Lost connection.");
wattroff(win, COLOR_PAIR(6));
// if current win, set dirty
if (i == _curr_prof_win) {
dirty = TRUE;
}
}
}
}
void cons_help(void) void cons_help(void)
{ {
cons_show(""); cons_show("");

View File

@ -63,6 +63,7 @@ void win_contact_online(const char * const from, const char * const show,
const char * const status); const char * const status);
void win_contact_offline(const char * const from, const char * const show, void win_contact_offline(const char * const from, const char * const show,
const char * const status); const char * const status);
void win_disconnected(void);
// console window actions // console window actions
void cons_help(void); void cons_help(void);