about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-04-27 23:13:52 +0100
committerJames Booth <boothj5@gmail.com>2013-04-27 23:13:52 +0100
commit04c6f2d7b0b29cff753eb08b33bb81ce2d27a60b (patch)
tree1a4c4605d9248b5f8fe35e7cee76a3f47fa64306
parente02ab52a4e48832a97af77ec402a67dc5d7fbf17 (diff)
downloadprofani-tty-04c6f2d7b0b29cff753eb08b33bb81ce2d27a60b.tar.gz
Moved display logic for subscriptions to console module
-rw-r--r--src/command/command.c29
-rw-r--r--src/ui/console.c35
-rw-r--r--src/ui/ui.h2
3 files changed, 39 insertions, 27 deletions
diff --git a/src/command/command.c b/src/command/command.c
index d9207763..46e56d4a 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1397,37 +1397,12 @@ _cmd_sub(gchar **args, struct cmd_help_t help)
     }
 
     if (strcmp(subcmd, "sent") == 0) {
-        if (contact_list_has_pending_subscriptions()) {
-            cons_show("Awaiting subscription responses from:");
-            GSList *contacts = get_contact_list();
-            while (contacts != NULL) {
-                PContact contact = (PContact) contacts->data;
-                if (p_contact_pending_out(contact)) {
-                    cons_show(p_contact_barejid(contact));
-                }
-                contacts = g_slist_next(contacts);
-            }
-        } else {
-            cons_show("No pending requests sent.");
-        }
-
+        cons_show_sent_subs();
         return TRUE;
     }
 
     if (strcmp(subcmd, "received") == 0) {
-        GList *received = presence_get_subscription_requests();
-
-        if (received == NULL) {
-            cons_show("No outstanding subscription requests.");
-        } else {
-            cons_show("Outstanding subscription requests from:",
-                g_list_length(received));
-            while (received != NULL) {
-                cons_show(received->data);
-                received = g_list_next(received);
-            }
-        }
-
+        cons_show_received_subs();
         return TRUE;
     }
 
diff --git a/src/ui/console.c b/src/ui/console.c
index ef94f58c..c6b50e38 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -564,6 +564,41 @@ cons_show_software_version(const char * const jid, const char * const  presence,
 }
 
 void
+cons_show_received_subs(void)
+{
+    GList *received = presence_get_subscription_requests();
+    if (received == NULL) {
+        cons_show("No outstanding subscription requests.");
+    } else {
+        cons_show("Outstanding subscription requests from:",
+            g_list_length(received));
+        while (received != NULL) {
+            cons_show("  %s", received->data);
+            received = g_list_next(received);
+        }
+    }
+}
+
+void
+cons_show_sent_subs(void)
+{
+   if (contact_list_has_pending_subscriptions()) {
+        GSList *contacts = get_contact_list();
+        PContact contact = NULL;
+        cons_show("Awaiting subscription responses from:");
+        while (contacts != NULL) {
+            contact = (PContact) contacts->data;
+            if (p_contact_pending_out(contact)) {
+                cons_show("  %s", p_contact_barejid(contact));
+            }
+            contacts = g_slist_next(contacts);
+        }
+    } else {
+        cons_show("No pending requests sent.");
+    }
+}
+
+void
 cons_show_room_list(GSList *rooms, const char * const conference_node)
 {
     if ((rooms != NULL) && (g_slist_length(rooms) > 0)) {
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 36e0fd56..ac100588 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -167,6 +167,8 @@ void cons_check_version(gboolean not_available_msg);
 void cons_show_typing(const char * const short_from);
 void cons_show_incoming_message(const char * const short_from, const int win_index);
 void cons_show_room_invites(GSList *invites);
+void cons_show_received_subs(void);
+void cons_show_sent_subs(void);
 
 // status bar actions
 void status_bar_refresh(void);