about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c11
-rw-r--r--src/ui/titlebar.c55
-rw-r--r--src/ui/ui.h1
3 files changed, 67 insertions, 0 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 885dd19d..2b5dec8a 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -841,6 +841,15 @@ _cons_beep_setting(void)
 }
 
 static void
+_cons_presence_setting(void)
+{
+    if (prefs_get_boolean(PREF_PRESENCE))
+        cons_show("Contact presence (/presence)  : ON");
+    else
+        cons_show("Contact presence (/presence)  : OFF");
+}
+
+static void
 _cons_flash_setting(void)
 {
     if (prefs_get_boolean(PREF_FLASH))
@@ -938,6 +947,7 @@ _cons_show_ui_prefs(void)
     cons_occupants_setting();
     cons_privileges_setting();
     cons_titlebar_setting();
+    cons_presence_setting();
 
     cons_alert();
 }
@@ -1547,6 +1557,7 @@ console_init_module(void)
     cons_theme_setting = _cons_theme_setting;
     cons_privileges_setting = _cons_privileges_setting;
     cons_beep_setting = _cons_beep_setting;
+    cons_presence_setting = _cons_presence_setting;
     cons_flash_setting = _cons_flash_setting;
     cons_splash_setting = _cons_splash_setting;
     cons_autoconnect_setting = _cons_autoconnect_setting;
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index 811ac2c2..256f8e57 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -174,6 +174,49 @@ _title_bar_draw(void)
         waddch(win, ' ');
     mvwprintw(win, 0, 0, " %s", current_title);
 
+    // show presence
+    if (prefs_get_boolean(PREF_PRESENCE) && current_recipient) {
+        char *recipient_jid = NULL;
+        char *found_contact = roster_find_contact(current_recipient);
+        if (found_contact) {
+            recipient_jid = roster_barejid_from_name(current_recipient);
+            free(found_contact);
+        } else {
+            recipient_jid = current_recipient;
+        }
+        ProfWin *current = wins_get_by_recipient(recipient_jid);
+        if (current) {
+            if (current->type == WIN_CHAT) {
+                PContact contact = roster_get_contact(recipient_jid);
+                const char *presence = p_contact_presence(contact);
+
+                int presence_colour = COLOUR_TITLE_ONLINE;
+                if (g_strcmp0(presence, "offline") == 0) {
+                    presence_colour = COLOUR_TITLE_OFFLINE;
+                } else if (g_strcmp0(presence, "away") == 0) {
+                    presence_colour = COLOUR_TITLE_AWAY;
+                } else if (g_strcmp0(presence, "xa") == 0) {
+                    presence_colour = COLOUR_TITLE_XA;
+                } else if (g_strcmp0(presence, "chat") == 0) {
+                    presence_colour = COLOUR_TITLE_CHAT;
+                } else if (g_strcmp0(presence, "dnd") == 0) {
+                    presence_colour = COLOUR_TITLE_DND;
+                }
+
+                wprintw(win, " ");
+                wattron(win, COLOUR_TITLE_BRACKET);
+                wprintw(win, "[");
+                wattroff(win, COLOUR_TITLE_BRACKET);
+                wattron(win, presence_colour);
+                wprintw(win, presence);
+                wattroff(win, presence_colour);
+                wattron(win, COLOUR_TITLE_BRACKET);
+                wprintw(win, "]");
+                wattroff(win, COLOUR_TITLE_BRACKET);
+            }
+        }
+    }
+
 #ifdef HAVE_LIBOTR
     // show privacy
     if (current_recipient != NULL) {
@@ -264,22 +307,34 @@ _title_bar_draw(void)
     switch (current_presence)
     {
         case CONTACT_ONLINE:
+            wattron(win, COLOUR_TITLE_ONLINE);
             mvwprintw(win, 0, cols - 13, " ...online ");
+            wattroff(win, COLOUR_TITLE_ONLINE);
             break;
         case CONTACT_AWAY:
+            wattron(win, COLOUR_TITLE_AWAY);
             mvwprintw(win, 0, cols - 13, " .....away ");
+            wattroff(win, COLOUR_TITLE_AWAY);
             break;
         case CONTACT_DND:
+            wattron(win, COLOUR_TITLE_DND);
             mvwprintw(win, 0, cols - 13, " ......dnd ");
+            wattroff(win, COLOUR_TITLE_DND);
             break;
         case CONTACT_CHAT:
+            wattron(win, COLOUR_TITLE_CHAT);
             mvwprintw(win, 0, cols - 13, " .....chat ");
+            wattroff(win, COLOUR_TITLE_CHAT);
             break;
         case CONTACT_XA:
+            wattron(win, COLOUR_TITLE_XA);
             mvwprintw(win, 0, cols - 13, " .......xa ");
+            wattroff(win, COLOUR_TITLE_XA);
             break;
         case CONTACT_OFFLINE:
+            wattron(win, COLOUR_TITLE_OFFLINE);
             mvwprintw(win, 0, cols - 13, " ..offline ");
+            wattroff(win, COLOUR_TITLE_OFFLINE);
             break;
     }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index b3c5be1f..f5c9b621 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -299,6 +299,7 @@ void (*cons_flash_setting)(void);
 void (*cons_splash_setting)(void);
 void (*cons_vercheck_setting)(void);
 void (*cons_occupants_setting)(void);
+void (*cons_presence_setting)(void);
 void (*cons_mouse_setting)(void);
 void (*cons_statuses_setting)(void);
 void (*cons_titlebar_setting)(void);
ommon.h?id=5505387c37f594db0368317a2349c429c8ddedfe'>^
b6f36673 ^
a48b48b7 ^
f2638e00 ^
a48b48b7 ^

f2638e00 ^
a48b48b7 ^
e6749d66 ^
e9225687 ^














e6749d66 ^
0ef52901 ^
8c68fa0b ^
b3d49f2a ^
b1da6d1b ^
6dbcc035 ^
b1da6d1b ^
6f498d1f ^

6bad38c2 ^
0fe70ce7 ^
4c6cfcdc ^
e7e1688d ^
ba892973 ^
9ecdb394 ^
2630c111 ^
06ecfef1 ^
c7100203 ^
66647546 ^

8c68fa0b ^
e9225687 ^




92837ec1 ^
1c62d7fd ^
d5e9ca64 ^
42c3a1c1 ^
b5eb0958 ^
42c3a1c1 ^
be7c4f5a ^
44c5b34a ^
be7c4f5a ^
8c68fa0b ^
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137