about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c10
-rw-r--r--src/command/commands.c28
-rw-r--r--src/config/preferences.c8
-rw-r--r--src/config/preferences.h2
-rw-r--r--src/ui/rosterwin.c50
5 files changed, 96 insertions, 2 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 2b8b4d8b..4241acb4 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -274,8 +274,8 @@ static struct cmd_t command_defs[] =
         CMD_SYN(
             "/roster",
             "/roster online",
-            "/roster show [offline|resource|empty]",
-            "/roster hide [offline|resource|empty]",
+            "/roster show [offline|resource|presence|status|empty]",
+            "/roster hide [offline|resource|presence|status|empty]",
             "/roster by group|presence|none",
             "/roster size <percent>",
             "/roster add <jid> [<nick>]",
@@ -291,10 +291,14 @@ static struct cmd_t command_defs[] =
             { "show",                "Show the roster panel." },
             { "show offline",        "Show offline contacts in the roster panel." },
             { "show resource",       "Show contact's connected resources in the roster panel." },
+            { "show presence",       "Show contact's presence in the roster panel." },
+            { "show status",         "Show contact's status message in the roster panel." },
             { "show empty",          "When grouping by presence, show empty presence groups." },
             { "hide",                "Hide the roster panel." },
             { "hide offline",        "Hide offline contacts in the roster panel." },
             { "hide resource",       "Hide contact's connected resources in the roster panel." },
+            { "hide presence",       "Hide contact's presence in the roster panel." },
+            { "hide status",         "Hide contact's status message in the roster panel." },
             { "hide empty",          "When grouping by presence, hide empty presence groups." },
             { "by group",            "Group contacts in the roster panel by roster group." },
             { "by presence",         "Group contacts in the roster panel by presence." },
@@ -2015,6 +2019,8 @@ cmd_init(void)
     roster_option_ac = autocomplete_new();
     autocomplete_add(roster_option_ac, "offline");
     autocomplete_add(roster_option_ac, "resource");
+    autocomplete_add(roster_option_ac, "presence");
+    autocomplete_add(roster_option_ac, "status");
     autocomplete_add(roster_option_ac, "empty");
 
     roster_by_ac = autocomplete_new();
diff --git a/src/command/commands.c b/src/command/commands.c
index fe3c7045..40a041c9 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1773,6 +1773,20 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
                 rosterwin_roster();
             }
             return TRUE;
+        } else if (g_strcmp0(args[1], "presence") == 0) {
+            cons_show("Roster presence enabled");
+            prefs_set_boolean(PREF_ROSTER_PRESENCE, TRUE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
+        } else if (g_strcmp0(args[1], "status") == 0) {
+            cons_show("Roster status enabled");
+            prefs_set_boolean(PREF_ROSTER_STATUS, TRUE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
         } else if (g_strcmp0(args[1], "empty") == 0) {
             cons_show("Roster empty enabled");
             prefs_set_boolean(PREF_ROSTER_EMPTY, TRUE);
@@ -1806,6 +1820,20 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
                 rosterwin_roster();
             }
             return TRUE;
+        } else if (g_strcmp0(args[1], "presence") == 0) {
+            cons_show("Roster presence disabled");
+            prefs_set_boolean(PREF_ROSTER_PRESENCE, FALSE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
+        } else if (g_strcmp0(args[1], "status") == 0) {
+            cons_show("Roster status disabled");
+            prefs_set_boolean(PREF_ROSTER_STATUS, FALSE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
         } else if (g_strcmp0(args[1], "empty") == 0) {
             cons_show("Roster empty disabled");
             prefs_set_boolean(PREF_ROSTER_EMPTY, FALSE);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index c7196051..b8f6d607 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -597,6 +597,8 @@ _get_group(preference_t pref)
         case PREF_ROSTER:
         case PREF_ROSTER_OFFLINE:
         case PREF_ROSTER_RESOURCE:
+        case PREF_ROSTER_PRESENCE:
+        case PREF_ROSTER_STATUS:
         case PREF_ROSTER_EMPTY:
         case PREF_ROSTER_BY:
         case PREF_RESOURCE_TITLE:
@@ -768,6 +770,10 @@ _get_key(preference_t pref)
             return "roster.offline";
         case PREF_ROSTER_RESOURCE:
             return "roster.resource";
+        case PREF_ROSTER_PRESENCE:
+            return "roster.presence";
+        case PREF_ROSTER_STATUS:
+            return "roster.status";
         case PREF_ROSTER_EMPTY:
             return "roster.empty";
         case PREF_ROSTER_BY:
@@ -823,6 +829,8 @@ _get_default_boolean(preference_t pref)
         case PREF_ROSTER:
         case PREF_ROSTER_OFFLINE:
         case PREF_ROSTER_RESOURCE:
+        case PREF_ROSTER_PRESENCE:
+        case PREF_ROSTER_STATUS:
         case PREF_ROSTER_EMPTY:
         case PREF_TLS_SHOW:
         case PREF_LASTACTIVITY:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 9aa6ff72..ff830cce 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -64,6 +64,8 @@ typedef enum {
     PREF_ROSTER_SIZE,
     PREF_ROSTER_OFFLINE,
     PREF_ROSTER_RESOURCE,
+    PREF_ROSTER_PRESENCE,
+    PREF_ROSTER_STATUS,
     PREF_ROSTER_EMPTY,
     PREF_ROSTER_BY,
     PREF_MUC_PRIVILEGES,
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index d7d4012d..6201394d 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -47,6 +47,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
 {
     const char *name = p_contact_name_or_jid(contact);
     const char *presence = p_contact_presence(contact);
+    char *by = prefs_get_string(PREF_ROSTER_BY);
 
     if ((g_strcmp0(presence, "offline") != 0) || ((g_strcmp0(presence, "offline") == 0) &&
             (prefs_get_boolean(PREF_ROSTER_OFFLINE)))) {
@@ -74,9 +75,58 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
                 g_string_free(msg, TRUE);
                 wattroff(layout->subwin, theme_attrs(resource_presence_colour));
 
+                if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) {
+                    gboolean by_presence = g_strcmp0(by, "presence") == 0;
+                    gboolean has_status = resource->status != NULL;
+                    gboolean show_status = prefs_get_boolean(PREF_ROSTER_STATUS);
+                    if (!by_presence || (has_status && show_status)) {
+                        wattron(layout->subwin, theme_attrs(resource_presence_colour));
+                        GString *msg = g_string_new("       ");
+                        if (!by_presence) {
+                            g_string_append(msg, resource_presence);
+                        }
+                        if (has_status && show_status) {
+                            if (!by_presence) {
+                                g_string_append(msg, ", \"");
+                            } else {
+                                g_string_append(msg, "\"");
+                            }
+                            g_string_append(msg, resource->status);
+                            g_string_append(msg, "\"");
+                        }
+                        win_printline_nowrap(layout->subwin, msg->str);
+                        g_string_free(msg, TRUE);
+                        wattroff(layout->subwin, theme_attrs(resource_presence_colour));
+                    }
+                }
+
                 curr_resource = g_list_next(curr_resource);
             }
             g_list_free(resources);
+        } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) {
+            gboolean by_presence = g_strcmp0(by, "presence") == 0;
+            gboolean has_status = p_contact_status(contact) != NULL;
+            gboolean show_status = prefs_get_boolean(PREF_ROSTER_STATUS);
+            if (!by_presence || (has_status && show_status)) {
+                wattron(layout->subwin, theme_attrs(presence_colour));
+                GString *msg = g_string_new("     ");
+                if (!by_presence) {
+                    g_string_append(msg, presence);
+                }
+                if (has_status && show_status) {
+                    if (!by_presence) {
+                        g_string_append(msg, ", \"");
+                    } else {
+                        g_string_append(msg, "\"");
+                    }
+                    const char *status = p_contact_status(contact);
+                    g_string_append(msg, status);
+                    g_string_append(msg, "\"");
+                }
+                win_printline_nowrap(layout->subwin, msg->str);
+                g_string_free(msg, TRUE);
+                wattroff(layout->subwin, theme_attrs(presence_colour));
+            }
         }
     }
 }