mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Show presence in roster WIP
This commit is contained in:
parent
c5ac0f1319
commit
badbc3003f
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user