about summary refs log tree commit diff stats
path: root/src/ui/windows.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/windows.c')
-rw-r--r--src/ui/windows.c125
1 files changed, 71 insertions, 54 deletions
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 2b269223..d23257ba 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -2405,9 +2405,9 @@ _win_show_info(WINDOW *win, PContact pcontact)
     const char *barejid = p_contact_barejid(pcontact);
     const char *name = p_contact_name(pcontact);
     const char *presence = p_contact_presence(pcontact);
-    const char *status = p_contact_status(pcontact);
     const char *sub = p_contact_subscription(pcontact);
-    const char *caps_str = p_contact_caps_str(pcontact);
+    GList *resources = p_contact_get_available_resources(pcontact);
+    GList *ordered_resources = NULL;
     GDateTime *last_activity = p_contact_last_activity(pcontact);
 
     _win_show_time(win, '-');
@@ -2418,22 +2418,12 @@ _win_show_info(WINDOW *win, PContact pcontact)
     if (name != NULL) {
         wprintw(win, " (%s)", name);
     }
-    wprintw(win, ":\n");
-    _presence_colour_off(win, presence);
-
-    _win_show_time(win, '-');
-    wprintw(win, "Presence      : ");
-    _presence_colour_on(win, presence);
-    wprintw(win, "%s", presence);
-    if (status != NULL) {
-        wprintw(win, ", \"%s\"", status);
-    }
-    wprintw(win, "\n");
     _presence_colour_off(win, presence);
+    wprintw(win, ":\n");
 
     if (sub != NULL) {
         _win_show_time(win, '-');
-        wprintw(win, "Subscription  : %s\n", sub);
+        wprintw(win, "Subscription: %s\n", sub);
     }
 
     if (last_activity != NULL) {
@@ -2441,7 +2431,7 @@ _win_show_info(WINDOW *win, PContact pcontact)
         GTimeSpan span = g_date_time_difference(now, last_activity);
 
         _win_show_time(win, '-');
-        wprintw(win, "Last activity : ");
+        wprintw(win, "Last activity: ");
 
         int hours = span / G_TIME_SPAN_HOUR;
         span = span - hours * G_TIME_SPAN_HOUR;
@@ -2461,53 +2451,80 @@ _win_show_info(WINDOW *win, PContact pcontact)
         g_date_time_unref(now);
     }
 
-    if (caps_str != NULL) {
-        Capabilities *caps = caps_get(caps_str);
-        if (caps != NULL) {
-            // show identity
-            if ((caps->category != NULL) || (caps->type != NULL) || (caps->name != NULL)) {
-                _win_show_time(win, '-');
-                wprintw(win, "Identity      : ");
-                if (caps->name != NULL) {
-                    wprintw(win, "%s", caps->name);
-                    if ((caps->category != NULL) || (caps->type != NULL)) {
-                        wprintw(win, " ");
+    if (resources != NULL) {
+        _win_show_time(win, '-');
+        wprintw(win, "Resources:\n");
+
+        // sort in order of availabiltiy
+        while (resources != NULL) {
+            Resource *resource = resources->data;
+            ordered_resources = g_list_insert_sorted(ordered_resources,
+                resource, (GCompareFunc)resource_compare_availability);
+            resources = g_list_next(resources);
+        }
+    }
+
+    while (ordered_resources != NULL) {
+        Resource *resource = ordered_resources->data;
+        const char *resource_presence = string_from_resource_presence(resource->presence);
+        _win_show_time(win, '-');
+        _presence_colour_on(win, resource_presence);
+        wprintw(win, "  %s (%d), %s", resource->name, resource->priority, resource_presence);
+        if (resource->status != NULL) {
+            wprintw(win, ", \"%s\"", resource->status);
+        }
+        wprintw(win, "\n");
+        _presence_colour_off(win, resource_presence);
+
+        if (resource->caps_str != NULL) {
+            Capabilities *caps = caps_get(resource->caps_str);
+            if (caps != NULL) {
+                // show identity
+                if ((caps->category != NULL) || (caps->type != NULL) || (caps->name != NULL)) {
+                    _win_show_time(win, '-');
+                    wprintw(win, "    Identity: ");
+                    if (caps->name != NULL) {
+                        wprintw(win, "%s", caps->name);
+                        if ((caps->category != NULL) || (caps->type != NULL)) {
+                            wprintw(win, " ");
+                        }
+                    }
+                    if (caps->type != NULL) {
+                        wprintw(win, "%s", caps->type);
+                        if (caps->category != NULL) {
+                            wprintw(win, " ");
+                        }
                     }
-                }
-                if (caps->type != NULL) {
-                    wprintw(win, "%s", caps->type);
                     if (caps->category != NULL) {
-                        wprintw(win, " ");
+                        wprintw(win, "%s", caps->category);
                     }
+                    wprintw(win, "\n");
                 }
-                if (caps->category != NULL) {
-                    wprintw(win, "%s", caps->category);
+                if (caps->software != NULL) {
+                    _win_show_time(win, '-');
+                    wprintw(win, "    Software: %s", caps->software);
+                }
+                if (caps->software_version != NULL) {
+                    wprintw(win, ", %s", caps->software_version);
+                }
+                if ((caps->software != NULL) || (caps->software_version != NULL)) {
+                    wprintw(win, "\n");
+                }
+                if (caps->os != NULL) {
+                    _win_show_time(win, '-');
+                    wprintw(win, "    OS: %s", caps->os);
+                }
+                if (caps->os_version != NULL) {
+                    wprintw(win, ", %s", caps->os_version);
+                }
+                if ((caps->os != NULL) || (caps->os_version != NULL)) {
+                    wprintw(win, "\n");
                 }
-                wprintw(win, "\n");
-            }
-            if (caps->software != NULL) {
-                _win_show_time(win, '-');
-                wprintw(win, "Software      : %s", caps->software);
-            }
-            if (caps->software_version != NULL) {
-                wprintw(win, ", %s", caps->software_version);
-            }
-            if ((caps->software != NULL) || (caps->software_version != NULL)) {
-                wprintw(win, "\n");
-            }
-            if (caps->os != NULL) {
-                _win_show_time(win, '-');
-                wprintw(win, "OS            : %s", caps->os);
-            }
-            if (caps->os_version != NULL) {
-                wprintw(win, ", %s\n", caps->os_version);
-            }
-            if ((caps->os != NULL) || (caps->os_version != NULL)) {
-                wprintw(win, "\n");
             }
         }
-    }
 
+        ordered_resources = g_list_next(ordered_resources);
+    }
 }
 
 void