about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-04-21 01:13:35 +0100
committerJames Booth <boothj5@gmail.com>2013-04-21 01:13:35 +0100
commit688eea083bd25af39d11b6f993b0d1bf02535959 (patch)
treeeab1a6bb8cb7d2ae4ff481f8bec39ce7a7aefd20 /src/ui
parentd7cc54db6302155fe7e1670b510496f8db40c9ac (diff)
downloadprofani-tty-688eea083bd25af39d11b6f993b0d1bf02535959.tar.gz
Moved cons_show_status() to console module
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c12
-rw-r--r--src/ui/window.c46
-rw-r--r--src/ui/window.h3
-rw-r--r--src/ui/windows.c68
4 files changed, 65 insertions, 64 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 41b189c2..727fb606 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -584,6 +584,18 @@ cons_show_disco_items(GSList *items, const char * const jid)
     }
 }
 
+void
+cons_show_status(const char * const contact)
+{
+    PContact pcontact = contact_list_get_contact(contact);
+
+    if (pcontact != NULL) {
+        window_show_contact(console, pcontact);
+    } else {
+        cons_show("No such contact \"%s\" in roster.", contact);
+    }
+}
+
 static void
 _cons_splash_logo(void)
 {
diff --git a/src/ui/window.c b/src/ui/window.c
index d07ce989..01eea071 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -113,3 +113,49 @@ window_presence_colour_off(ProfWin *window, const char * const presence)
     }
 }
 
+void
+window_show_contact(ProfWin *window, PContact contact)
+{
+    const char *barejid = p_contact_barejid(contact);
+    const char *name = p_contact_name(contact);
+    const char *presence = p_contact_presence(contact);
+    const char *status = p_contact_status(contact);
+    GDateTime *last_activity = p_contact_last_activity(contact);
+
+    window_show_time(window, '-');
+    window_presence_colour_on(window, presence);
+    wprintw(window->win, "%s", barejid);
+
+    if (name != NULL) {
+        wprintw(window->win, " (%s)", name);
+    }
+
+    wprintw(window->win, " is %s", presence);
+
+    if (last_activity != NULL) {
+        GDateTime *now = g_date_time_new_now_local();
+        GTimeSpan span = g_date_time_difference(now, last_activity);
+
+        wprintw(window->win, ", idle ");
+
+        int hours = span / G_TIME_SPAN_HOUR;
+        span = span - hours * G_TIME_SPAN_HOUR;
+        if (hours > 0) {
+            wprintw(window->win, "%dh", hours);
+        }
+
+        int minutes = span / G_TIME_SPAN_MINUTE;
+        span = span - minutes * G_TIME_SPAN_MINUTE;
+        wprintw(window->win, "%dm", minutes);
+
+        int seconds = span / G_TIME_SPAN_SECOND;
+        wprintw(window->win, "%ds", seconds);
+    }
+
+    if (status != NULL) {
+        wprintw(window->win, ", \"%s\"", p_contact_status(contact));
+    }
+
+    wprintw(window->win, "\n");
+    window_presence_colour_off(window, presence);
+}
diff --git a/src/ui/window.h b/src/ui/window.h
index 2793cd42..5c2e22d5 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -23,6 +23,8 @@
 #ifndef WINDOW_H
 #define WINDOW_H
 
+#include "contact.h"
+
 #define PAD_SIZE 1000
 
 typedef enum {
@@ -49,5 +51,6 @@ void window_free(ProfWin *window);
 void window_show_time(ProfWin *window, char show_char);
 void window_presence_colour_on(ProfWin *window, const char * const presence);
 void window_presence_colour_off(ProfWin *window, const char * const presence);
+void window_show_contact(ProfWin *window, PContact contact);
 
 #endif
diff --git a/src/ui/windows.c b/src/ui/windows.c
index c8252efa..9ae361f7 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -74,7 +74,6 @@ static GTimer *ui_idle_time;
 
 static void _set_current(int index);
 static void _cons_show_basic_help(void);
-static void _win_show_contact(ProfWin *window, PContact contact);
 static int _find_prof_win_index(const char * const contact);
 static int _new_prof_win(const char * const contact, win_type_t type);
 static void _current_window_refresh(void);
@@ -1107,18 +1106,6 @@ win_show_room_broadcast(const char * const room_jid, const char * const message)
 }
 
 void
-cons_show_status(const char * const contact)
-{
-    PContact pcontact = contact_list_get_contact(contact);
-
-    if (pcontact != NULL) {
-        _win_show_contact(console, pcontact);
-    } else {
-        cons_show("No such contact \"%s\" in roster.", contact);
-    }
-}
-
-void
 cons_show_room_invite(const char * const invitor, const char * const room,
     const char * const reason)
 {
@@ -1292,7 +1279,7 @@ win_show_status(void)
     PContact pcontact = contact_list_get_contact(recipient);
 
     if (pcontact != NULL) {
-        _win_show_contact(current, pcontact);
+        window_show_contact(current, pcontact);
     } else {
         win_current_show("Error getting contact info.");
     }
@@ -1306,7 +1293,7 @@ win_private_show_status(void)
     PContact pcontact = muc_get_participant(jid->barejid, jid->resourcepart);
 
     if (pcontact != NULL) {
-        _win_show_contact(current, pcontact);
+        window_show_contact(current, pcontact);
     } else {
         win_current_show("Error getting contact info.");
     }
@@ -1320,7 +1307,7 @@ win_room_show_status(const char * const contact)
     PContact pcontact = muc_get_participant(win_current_get_recipient(), contact);
 
     if (pcontact != NULL) {
-        _win_show_contact(current, pcontact);
+        window_show_contact(current, pcontact);
     } else {
         win_current_show("No such participant \"%s\" in room.", contact);
     }
@@ -1667,7 +1654,7 @@ cons_show_contacts(GSList *list)
     while(curr) {
         PContact contact = curr->data;
         if (strcmp(p_contact_subscription(contact), "none") != 0) {
-            _win_show_contact(console, contact);
+            window_show_contact(console, contact);
         }
         curr = g_slist_next(curr);
     }
@@ -2037,53 +2024,6 @@ _cons_show_incoming_message(const char * const short_from, const int win_index)
 }
 
 static void
-_win_show_contact(ProfWin *window, PContact contact)
-{
-    const char *barejid = p_contact_barejid(contact);
-    const char *name = p_contact_name(contact);
-    const char *presence = p_contact_presence(contact);
-    const char *status = p_contact_status(contact);
-    GDateTime *last_activity = p_contact_last_activity(contact);
-
-    window_show_time(window, '-');
-    window_presence_colour_on(window, presence);
-    wprintw(window->win, "%s", barejid);
-
-    if (name != NULL) {
-        wprintw(window->win, " (%s)", name);
-    }
-
-    wprintw(window->win, " is %s", presence);
-
-    if (last_activity != NULL) {
-        GDateTime *now = g_date_time_new_now_local();
-        GTimeSpan span = g_date_time_difference(now, last_activity);
-
-        wprintw(window->win, ", idle ");
-
-        int hours = span / G_TIME_SPAN_HOUR;
-        span = span - hours * G_TIME_SPAN_HOUR;
-        if (hours > 0) {
-            wprintw(window->win, "%dh", hours);
-        }
-
-        int minutes = span / G_TIME_SPAN_MINUTE;
-        span = span - minutes * G_TIME_SPAN_MINUTE;
-        wprintw(window->win, "%dm", minutes);
-
-        int seconds = span / G_TIME_SPAN_SECOND;
-        wprintw(window->win, "%ds", seconds);
-    }
-
-    if (status != NULL) {
-        wprintw(window->win, ", \"%s\"", p_contact_status(contact));
-    }
-
-    wprintw(window->win, "\n");
-    window_presence_colour_off(window, presence);
-}
-
-static void
 _win_handle_switch(const wint_t * const ch)
 {
     if (*ch == KEY_F(1)) {