about summary refs log tree commit diff stats
path: root/windows.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-02-29 23:54:48 +0000
committerJames Booth <boothj5@gmail.com>2012-02-29 23:54:48 +0000
commitdfa7c69da636889fe6130b5c1ef2d825eab1d9f9 (patch)
treed63ebb163c9de95b91f8d815aa3e7a3f76984fbb /windows.c
parent5aba98c6aaae6025699afbe8421bd532e675d5c4 (diff)
downloadprofani-tty-dfa7c69da636889fe6130b5c1ef2d825eab1d9f9.tar.gz
Simplified online/offline notifications
Diffstat (limited to 'windows.c')
-rw-r--r--windows.c207
1 files changed, 112 insertions, 95 deletions
diff --git a/windows.c b/windows.c
index fcfa9a1e..36c55484 100644
--- a/windows.c
+++ b/windows.c
@@ -36,6 +36,10 @@ static void _win_switch_if_active(int i);
 static void _win_show_time(int win);
 static void _win_show_user(int win, char *user, int colour);
 static void _win_show_message(WINDOW *win, char *message);
+static void _win_show_contact_online(char *from, char *show, char *status);
+static void _win_show_contact_offline(char *from, char *show, char *status);
+static void _cons_show_contact_online(char *from, char *show, char *status);
+static void _cons_show_contact_offline(char *from, char *show, char *status);
 
 void gui_init(void)
 {
@@ -126,63 +130,16 @@ void win_show_outgoing_msg(char *from, char *to, char *message)
     status_bar_active(win);
 }
 
-void win_show_contact_online(char *from, char *show, char *status)
+void win_contact_online(char *from, char *show, char *status)
 {
-    // find the chat window for recipient
-    int i;
-    for (i = 1; i < 10; i++)
-        if (strcmp(_wins[i].from, from) == 0)
-            break;
-
-    // if we found a window
-    if (i != 10) {
-        _win_show_time(i);    
-        wattron(_wins[i].win, COLOR_PAIR(2));
-        wprintw(_wins[i].win, "++ %s", from);
-
-        if (show != NULL) 
-            wprintw(_wins[i].win, " is %s", show);
-        else
-            wprintw(_wins[i].win, " is online");
-            
-        if (status != NULL)
-            wprintw(_wins[i].win, ", \"%s\"", status);
-
-        wprintw(_wins[i].win, "\n");
-        
-        wattroff(_wins[i].win, COLOR_PAIR(2));
-    }
+    _cons_show_contact_online(from, show, status);
+    _win_show_contact_online(from, show, status);
 }
 
-void win_show_contact_offline(char *from, char *show, char *status)
+void win_contact_offline(char *from, char *show, char *status)
 {
-    // find the chat window for recipient
-    int i;
-    for (i = 1; i < 10; i++)
-        if (strcmp(_wins[i].from, from) == 0)
-            break;
-
-    // if we found a window
-    if (i != 10) {
-        _win_show_time(i);    
-        wattron(_wins[i].win, COLOR_PAIR(5));
-        wattroff(_wins[i].win, A_BOLD);
-
-        wprintw(_wins[i].win, "-- %s", from);
-
-        if (show != NULL) 
-            wprintw(_wins[i].win, " is %s", show);
-        else
-            wprintw(_wins[i].win, " is offline");
-        
-        if (status != NULL)
-            wprintw(_wins[i].win, ", \"%s\"", status);
-        
-        wprintw(_wins[i].win, "\n");
-        
-        wattroff(_wins[i].win, COLOR_PAIR(5));
-        wattron(_wins[i].win, A_BOLD);
-    }
+    _cons_show_contact_offline(from, show, status);
+    _win_show_contact_offline(from, show, status);
 }
 
 void cons_help(void)
@@ -248,48 +205,6 @@ void cons_bad_message(void)
     cons_show("Usage: /msg user@host message");
 }
 
-void cons_show_contact_online(char *from, char *show, char *status)
-{
-    _win_show_time(0);    
-    wattron(_wins[0].win, COLOR_PAIR(2));
-   
-    wprintw(_wins[0].win, "++ %s", from);
-
-    if (show != NULL) 
-        wprintw(_wins[0].win, " is %s", show);
-    else
-        wprintw(_wins[0].win, " is online");
-        
-    if (status != NULL)
-        wprintw(_wins[0].win, ", \"%s\"", status);
-
-    wprintw(_wins[0].win, "\n");
-    
-    wattroff(_wins[0].win, COLOR_PAIR(2));
-}
-
-void cons_show_contact_offline(char *from, char *show, char *status)
-{
-    _win_show_time(0);    
-    wattron(_wins[0].win, COLOR_PAIR(5));
-    wattroff(_wins[0].win, A_BOLD);
-
-    wprintw(_wins[0].win, "-- %s", from);
-
-    if (show != NULL) 
-        wprintw(_wins[0].win, " is %s", show);
-    else
-        wprintw(_wins[0].win, " is offline");
-        
-    if (status != NULL)
-        wprintw(_wins[0].win, ", \"%s\"", status);
-    
-    wprintw(_wins[0].win, "\n");
-    
-    wattroff(_wins[0].win, COLOR_PAIR(5));
-    wattron(_wins[0].win, A_BOLD);
-}
-
 void win_handle_switch(int *ch)
 {
     if (*ch == KEY_F(1)) {
@@ -408,3 +323,105 @@ static void _current_window_refresh()
     touchwin(_wins[_curr_win].win);
     wrefresh(_wins[_curr_win].win);
 }
+
+static void _win_show_contact_online(char *from, char *show, char *status)
+{
+    // find the chat window for recipient
+    int i;
+    for (i = 1; i < 10; i++)
+        if (strcmp(_wins[i].from, from) == 0)
+            break;
+
+    // if we found a window
+    if (i != 10) {
+        _win_show_time(i);    
+        wattron(_wins[i].win, COLOR_PAIR(2));
+        wprintw(_wins[i].win, "++ %s", from);
+
+        if (show != NULL) 
+            wprintw(_wins[i].win, " is %s", show);
+        else
+            wprintw(_wins[i].win, " is online");
+            
+        if (status != NULL)
+            wprintw(_wins[i].win, ", \"%s\"", status);
+
+        wprintw(_wins[i].win, "\n");
+        
+        wattroff(_wins[i].win, COLOR_PAIR(2));
+    }
+}
+
+static void _win_show_contact_offline(char *from, char *show, char *status)
+{
+    // find the chat window for recipient
+    int i;
+    for (i = 1; i < 10; i++)
+        if (strcmp(_wins[i].from, from) == 0)
+            break;
+
+    // if we found a window
+    if (i != 10) {
+        _win_show_time(i);    
+        wattron(_wins[i].win, COLOR_PAIR(5));
+        wattroff(_wins[i].win, A_BOLD);
+
+        wprintw(_wins[i].win, "-- %s", from);
+
+        if (show != NULL) 
+            wprintw(_wins[i].win, " is %s", show);
+        else
+            wprintw(_wins[i].win, " is offline");
+        
+        if (status != NULL)
+            wprintw(_wins[i].win, ", \"%s\"", status);
+        
+        wprintw(_wins[i].win, "\n");
+        
+        wattroff(_wins[i].win, COLOR_PAIR(5));
+        wattron(_wins[i].win, A_BOLD);
+    }
+}
+
+static void _cons_show_contact_online(char *from, char *show, char *status)
+{
+    _win_show_time(0);    
+    wattron(_wins[0].win, COLOR_PAIR(2));
+   
+    wprintw(_wins[0].win, "++ %s", from);
+
+    if (show != NULL) 
+        wprintw(_wins[0].win, " is %s", show);
+    else
+        wprintw(_wins[0].win, " is online");
+        
+    if (status != NULL)
+        wprintw(_wins[0].win, ", \"%s\"", status);
+
+    wprintw(_wins[0].win, "\n");
+    
+    wattroff(_wins[0].win, COLOR_PAIR(2));
+}
+
+static void _cons_show_contact_offline(char *from, char *show, char *status)
+{
+    _win_show_time(0);    
+    wattron(_wins[0].win, COLOR_PAIR(5));
+    wattroff(_wins[0].win, A_BOLD);
+
+    wprintw(_wins[0].win, "-- %s", from);
+
+    if (show != NULL) 
+        wprintw(_wins[0].win, " is %s", show);
+    else
+        wprintw(_wins[0].win, " is offline");
+        
+    if (status != NULL)
+        wprintw(_wins[0].win, ", \"%s\"", status);
+    
+    wprintw(_wins[0].win, "\n");
+    
+    wattroff(_wins[0].win, COLOR_PAIR(5));
+    wattron(_wins[0].win, A_BOLD);
+}
+