From 28b172387605a4f2175898177334e6b8cc4c0db3 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 2 Oct 2012 01:04:53 +0100 Subject: Moved roster output handling to profanity module --- src/profanity.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/profanity.c') 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); +} + -- cgit 1.4.1-2-gfad0