about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-02-18 23:06:18 +0000
committerJames Booth <boothj5@gmail.com>2013-02-18 23:06:18 +0000
commitdc30eeacad078d82bf02d03a76d396543836e6c6 (patch)
tree3cc982e5ab59b625775fe17ae5d605d41532cf38 /src
parent502d7dc9fe93070ec6750d45ce8c224959ba0a1e (diff)
downloadprofani-tty-dc30eeacad078d82bf02d03a76d396543836e6c6.tar.gz
Only show resources for connected account
Diffstat (limited to 'src')
-rw-r--r--src/ui/windows.c136
1 files changed, 69 insertions, 67 deletions
diff --git a/src/ui/windows.c b/src/ui/windows.c
index e5670ac4..4e5bf461 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -1358,85 +1358,87 @@ cons_show_account(ProfAccount *account)
         account->priority_chat, account->priority_online, account->priority_away,
         account->priority_xa, account->priority_dnd);
 
-    GList *resources = jabber_get_available_resources();
-    GList *ordered_resources = NULL;
-
-    WINDOW *win = console->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);
-        }
-    }
+    if ((jabber_get_connection_status() == JABBER_CONNECTED) &&
+            (g_strcmp0(jabber_get_account_name(), account->name) == 0)) {
+        GList *resources = jabber_get_available_resources();
+        GList *ordered_resources = NULL;
 
-    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);
+        WINDOW *win = console->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);
+            }
         }
-        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, " ");
+        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", caps->os_version);
-                }
-                if ((caps->os != NULL) || (caps->os_version != NULL)) {
-                    wprintw(win, "\n");
                 }
             }
-        }
 
-        ordered_resources = g_list_next(ordered_resources);
+            ordered_resources = g_list_next(ordered_resources);
+        }
     }
-
 }
 
 void
:54:01 -0800 committer Kartik Agaram <vc@akkartik.com> 2018-11-30 16:54:01 -0800 4809 - subx: html with 5 colors for comments' href='/akkartik/mu/commit/html/subx/examples/ex3.subx.html?h=main&id=14a380525ed2df295463b1906b718cb26871df3b'>14a38052 ^
d1c9392a ^
695f9bf8 ^
33352536 ^



695f9bf8 ^


33352536 ^
6070c23e ^
695f9bf8 ^
33352536 ^
695f9bf8 ^
33352536 ^
695f9bf8 ^
86351aaf ^
695f9bf8 ^

a0d3cac4 ^



bb2b6ba7 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98