about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--jabber.c39
-rw-r--r--windows.c38
2 files changed, 37 insertions, 40 deletions
diff --git a/jabber.c b/jabber.c
index dc2b1f18..6d4888ef 100644
--- a/jabber.c
+++ b/jabber.c
@@ -302,33 +302,24 @@ static int _jabber_presence_handler(xmpp_conn_t * const conn,
     char *short_from = strtok(from, "@");
     char *type = xmpp_stanza_get_attribute(stanza, "type");
 
+    char *show_str, *status_str;
    
+    xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show");
+    if (show != NULL)
+        show_str = xmpp_stanza_get_text(show);
+    else
+        show_str = NULL;
+
+    xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status");
+    if (status != NULL)    
+        status_str = xmpp_stanza_get_text(status);
+    else 
+        status_str = NULL;
+
     if (type == NULL) { // online
-        xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show");
-        if (show != NULL) {
-            char *show_str = xmpp_stanza_get_text(show);
-            xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status");
-            
-            if (status != NULL) {
-                char *status_str = xmpp_stanza_get_text(status);
-            
-                if (show_str != NULL)
-                    cons_show_contact_online(short_from, show_str, status_str);
-            }
-        }
+        cons_show_contact_online(short_from, show_str, status_str);
     } else { // offline
-        xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show");
-        if (show != NULL) {
-            char *show_str = xmpp_stanza_get_text(show);
-            xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status");
-            
-            if (status != NULL) {
-                char *status_str = xmpp_stanza_get_text(status);
-            
-                if (show_str != NULL)
-                    cons_show_contact_offline(short_from, show_str, status_str);
-            }
-        }
+        cons_show_contact_offline(short_from, show_str, status_str);
     }
 
     return 1;
diff --git a/windows.c b/windows.c
index f8144a39..ed4e705f 100644
--- a/windows.c
+++ b/windows.c
@@ -128,9 +128,7 @@ void win_show_outgoing_msg(char *from, char *to, char *message)
 void cons_help(void)
 {
     _win_show_time(0);
-    wattron(_wins[0].win, A_BOLD);
     wprintw(_wins[0].win, "Help:\n");
-    wattroff(_wins[0].win, A_BOLD);
 
     cons_show("  Commands:");
     cons_show("    /help                : This help.");
@@ -148,20 +146,18 @@ void cons_good_show(char *msg)
 {
     _win_show_time(0);    
     wattron(_wins[0].win, A_BOLD);
-    wattron(_wins[0].win, COLOR_PAIR(2));
     wprintw(_wins[0].win, "%s\n", msg);
     wattroff(_wins[0].win, A_BOLD);
-    wattroff(_wins[0].win, COLOR_PAIR(2));
 }
 
 void cons_bad_show(char *msg)
 {
     _win_show_time(0);
-    wattron(_wins[0].win, A_BOLD);
     wattron(_wins[0].win, COLOR_PAIR(6));
+    wattron(_wins[0].win, A_BOLD);
     wprintw(_wins[0].win, "%s\n", msg);
-    wattroff(_wins[0].win, A_BOLD);
     wattroff(_wins[0].win, COLOR_PAIR(6));
+    wattroff(_wins[0].win, A_BOLD);
 }
 
 void cons_show(char *msg)
@@ -208,26 +204,36 @@ void cons_show_contact_online(char *from, char *show, char *status)
 {
     _win_show_time(0);    
     wattron(_wins[0].win, COLOR_PAIR(2));
+    wattron(_wins[0].win, A_BOLD);
+   
+    wprintw(_wins[0].win, "++ %s", from);
+
+    if (show != NULL) 
+        wprintw(_wins[0].win, " is %s", show);
+    if (status != NULL)
+        wprintw(_wins[0].win, ", \"%s\"", status);
 
-    if (status != NULL) 
-        wprintw(_wins[0].win, "+ %s is %s, \"%s\"\n", from, show, status);
-    else 
-        wprintw(_wins[0].win, "+ %s is %s\n", from, show);
+    wprintw(_wins[0].win, "\n");
     
     wattroff(_wins[0].win, COLOR_PAIR(2));
+    wattroff(_wins[0].win, A_BOLD);
 }
 
 void cons_show_contact_offline(char *from, char *show, char *status)
 {
     _win_show_time(0);    
-    wattron(_wins[0].win, COLOR_PAIR(7));
+    wattron(_wins[0].win, COLOR_PAIR(5));
+
+    wprintw(_wins[0].win, "-- %s", from);
 
-    if (status != NULL) 
-        wprintw(_wins[0].win, "- %s is %s, \"%s\"\n", from, show, status);
-    else 
-        wprintw(_wins[0].win, "- %s is %s\n", from, show);
+    if (show != NULL) 
+        wprintw(_wins[0].win, " is %s", show);
+    if (status != NULL)
+        wprintw(_wins[0].win, ", \"%s\"", status);
+    
+    wprintw(_wins[0].win, "\n");
     
-    wattroff(_wins[0].win, COLOR_PAIR(7));
+    wattroff(_wins[0].win, COLOR_PAIR(5));
 }
 
 void win_handle_switch(int *ch)