mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Implemented roster grouped by presence
This commit is contained in:
parent
7e360dc35a
commit
15d0f679f6
@ -265,6 +265,26 @@ roster_barejid_from_name(const char * const name)
|
|||||||
return g_hash_table_lookup(name_to_barejid, name);
|
return g_hash_table_lookup(name_to_barejid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GSList *
|
||||||
|
roster_get_contacts_by_presence(const char * const presence)
|
||||||
|
{
|
||||||
|
GSList *result = NULL;
|
||||||
|
GHashTableIter iter;
|
||||||
|
gpointer key;
|
||||||
|
gpointer value;
|
||||||
|
|
||||||
|
g_hash_table_iter_init(&iter, contacts);
|
||||||
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||||
|
PContact contact = (PContact)value;
|
||||||
|
if (g_strcmp0(p_contact_presence(contact), presence) == 0) {
|
||||||
|
result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_contacts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// resturn all contact structs
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
roster_get_contacts(void)
|
roster_get_contacts(void)
|
||||||
{
|
{
|
||||||
|
@ -64,5 +64,6 @@ GSList * roster_get_group(const char * const group);
|
|||||||
GSList * roster_get_groups(void);
|
GSList * roster_get_groups(void);
|
||||||
char * roster_find_group(char *search_str);
|
char * roster_find_group(char *search_str);
|
||||||
char * roster_find_jid(char *search_str);
|
char * roster_find_jid(char *search_str);
|
||||||
|
GSList * roster_get_contacts_by_presence(const char * const presence);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -84,6 +84,7 @@ static void _win_handle_page(const wint_t * const ch, const int result);
|
|||||||
static void _win_show_history(WINDOW *win, int win_index,
|
static void _win_show_history(WINDOW *win, int win_index,
|
||||||
const char * const contact);
|
const char * const contact);
|
||||||
static void _ui_draw_term_title(void);
|
static void _ui_draw_term_title(void);
|
||||||
|
static void _ui_roster_contact(PContact contact);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_init(void)
|
_ui_init(void)
|
||||||
@ -2805,20 +2806,10 @@ _ui_show_lines(ProfWin *window, const gchar** lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_roster(void)
|
_ui_roster_contact(PContact contact)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_console();
|
|
||||||
if (window) {
|
|
||||||
GSList *contacts = roster_get_contacts();
|
|
||||||
if (contacts) {
|
|
||||||
werase(window->subwin);
|
|
||||||
wattron(window->subwin, COLOUR_ROOMINFO);
|
|
||||||
win_printline_nowrap(window->subwin, " -Roster");
|
|
||||||
wattroff(window->subwin, COLOUR_ROOMINFO);
|
|
||||||
GSList *curr_contact = contacts;
|
|
||||||
while (curr_contact) {
|
|
||||||
PContact contact = curr_contact->data;
|
|
||||||
if (p_contact_subscribed(contact)) {
|
if (p_contact_subscribed(contact)) {
|
||||||
|
ProfWin *window = wins_get_console();
|
||||||
const char *name = p_contact_name_or_jid(contact);
|
const char *name = p_contact_name_or_jid(contact);
|
||||||
const char *presence = p_contact_presence(contact);
|
const char *presence = p_contact_presence(contact);
|
||||||
|
|
||||||
@ -2867,11 +2858,59 @@ _ui_roster(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ui_roster_contacts_by_presence(const char * const presence, char *title)
|
||||||
|
{
|
||||||
|
ProfWin *window = wins_get_console();
|
||||||
|
GSList *contacts = roster_get_contacts_by_presence(presence);
|
||||||
|
wattron(window->subwin, COLOUR_ROOMINFO);
|
||||||
|
win_printline_nowrap(window->subwin, title);
|
||||||
|
wattroff(window->subwin, COLOUR_ROOMINFO);
|
||||||
|
if (contacts) {
|
||||||
|
GSList *curr_contact = contacts;
|
||||||
|
while (curr_contact) {
|
||||||
|
PContact contact = curr_contact->data;
|
||||||
|
_ui_roster_contact(contact);
|
||||||
curr_contact = g_slist_next(curr_contact);
|
curr_contact = g_slist_next(curr_contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_slist_free(contacts);
|
g_slist_free(contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ui_roster(void)
|
||||||
|
{
|
||||||
|
ProfWin *window = wins_get_console();
|
||||||
|
if (window) {
|
||||||
|
if (g_strcmp0(prefs_get_string(PREF_ROSTER_BY), "presence") == 0) {
|
||||||
|
werase(window->subwin);
|
||||||
|
_ui_roster_contacts_by_presence("chat", " -Available for chat");
|
||||||
|
_ui_roster_contacts_by_presence("online", " -Online");
|
||||||
|
_ui_roster_contacts_by_presence("away", " -Away");
|
||||||
|
_ui_roster_contacts_by_presence("xa", " -Extended Away");
|
||||||
|
_ui_roster_contacts_by_presence("dnd", " -Do not disturb");
|
||||||
|
if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
|
||||||
|
_ui_roster_contacts_by_presence("offline", " -Offline");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GSList *contacts = roster_get_contacts();
|
||||||
|
if (contacts) {
|
||||||
|
werase(window->subwin);
|
||||||
|
wattron(window->subwin, COLOUR_ROOMINFO);
|
||||||
|
win_printline_nowrap(window->subwin, " -Roster");
|
||||||
|
wattroff(window->subwin, COLOUR_ROOMINFO);
|
||||||
|
GSList *curr_contact = contacts;
|
||||||
|
while (curr_contact) {
|
||||||
|
PContact contact = curr_contact->data;
|
||||||
|
_ui_roster_contact(contact);
|
||||||
|
curr_contact = g_slist_next(curr_contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_slist_free(contacts);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -17,9 +17,9 @@ main.splash=red
|
|||||||
online=green
|
online=green
|
||||||
away=cyan
|
away=cyan
|
||||||
chat=white
|
chat=white
|
||||||
dnd=red
|
dnd=magenta
|
||||||
xa=cyan
|
xa=blue
|
||||||
offline=blue
|
offline=red
|
||||||
typing=yellow
|
typing=yellow
|
||||||
gone=red
|
gone=red
|
||||||
error=red
|
error=red
|
||||||
|
Loading…
Reference in New Issue
Block a user