about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-04-19 21:03:48 +0100
committerJames Booth <boothj5@gmail.com>2012-04-19 21:03:48 +0100
commit9805b2b2b22e277ee150ddaabe8f542b267e3e4b (patch)
treec80d04bbc9d3fae1a0778ef1fdceba8502735d38
parent2514be4b78b9f13e5d7738430b988c8bec764141 (diff)
downloadprofani-tty-9805b2b2b22e277ee150ddaabe8f542b267e3e4b.tar.gz
Show different message when disconnected
Also show message in active chat windows
-rw-r--r--jabber.c7
-rw-r--r--windows.c20
-rw-r--r--windows.h1
3 files changed, 27 insertions, 1 deletions
diff --git a/jabber.c b/jabber.c
index 10d0115b..fbd0ccdd 100644
--- a/jabber.c
+++ b/jabber.c
@@ -221,7 +221,12 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
         jabber_conn.conn_status = JABBER_CONNECTED;
     }
     else {
-        cons_bad_show("Login failed.");
+        if (jabber_conn.conn_status == JABBER_CONNECTED) {
+            cons_bad_show("Lost connection.");
+            win_disconnected();
+        } else {
+            cons_bad_show("Login failed.");
+        }
         win_page_off();
         log_msg(CONN, "disconnected");
         xmpp_stop(ctx);
diff --git a/windows.c b/windows.c
index ad0c0fb1..ebafa543 100644
--- a/windows.c
+++ b/windows.c
@@ -214,6 +214,26 @@ void win_contact_offline(const char * const from, const char * const show,
         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)
 {
     cons_show("");
diff --git a/windows.h b/windows.h
index de72a23e..7996aa1a 100644
--- a/windows.h
+++ b/windows.h
@@ -63,6 +63,7 @@ void win_contact_online(const char * const from, const char * const show,
     const char * const status);
 void win_contact_offline(const char * const from, const char * const show, 
     const char * const status);
+void win_disconnected(void);
 
 // console window actions
 void cons_help(void);