about summary refs log tree commit diff stats
path: root/src/profanity.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-10-02 01:04:53 +0100
committerJames Booth <boothj5@gmail.com>2012-10-02 01:04:53 +0100
commit28b172387605a4f2175898177334e6b8cc4c0db3 (patch)
tree0bf0d8304961fd610de58b85cbd9b09e0419fec6 /src/profanity.c
parent02224ea7bbb89b0cbebfe1fb645f7ff1ea8f9a52 (diff)
downloadprofani-tty-28b172387605a4f2175898177334e6b8cc4c0db3.tar.gz
Moved roster output handling to profanity module
Diffstat (limited to 'src/profanity.c')
-rw-r--r--src/profanity.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/profanity.c b/src/profanity.c
index 01be4289..5da18675 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -35,11 +35,13 @@
 #include "log.h"
 #include "preferences.h"
 #include "profanity.h"
+#include "jabber.h"
 #include "ui.h"
 
 static log_level_t _get_log_level(char *log_level);
 gboolean _process_input(char *inp);
 static void _create_config_directory();
+static void _free_roster_entry(jabber_roster_entry *entry);
 
 void
 profanity_run(void)
@@ -247,6 +249,30 @@ prof_handle_contact_offline(char *contact, char *show, char *status)
     win_page_off();
 }
 
+void prof_handle_roster(GSList *roster)
+{
+    cons_show("Roster:");
+    while (roster != NULL) {
+        jabber_roster_entry *entry = roster->data;
+        if (entry->name != NULL) {
+            char line[strlen(entry->name) + 2 + strlen(entry->jid) + 1 + 1];
+            sprintf(line, "%s (%s)", entry->name, entry->jid);
+            cons_show(line);
+
+        } else {
+            char line[strlen(entry->jid) + 1];
+            sprintf(line, "%s", entry->jid);
+            cons_show(line);
+        }
+       
+        roster = g_slist_next(roster);
+
+        win_page_off();
+    }
+
+    g_slist_free_full(roster, (GDestroyNotify)_free_roster_entry); 
+}
+
 static void
 _create_config_directory()
 {
@@ -256,3 +282,13 @@ _create_config_directory()
     g_string_free(dir, TRUE);
 }
 
+static void
+_free_roster_entry(jabber_roster_entry *entry)
+{
+    if (entry->name != NULL) {
+        free(entry->name);
+        entry->name = NULL;
+    }
+    free(entry->jid);
+}
+