mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Implemented /roster by group
This commit is contained in:
parent
15d0f679f6
commit
4e429fe788
@ -332,6 +332,26 @@ roster_find_resource(char *search_str)
|
|||||||
return autocomplete_complete(fulljid_ac, search_str, TRUE);
|
return autocomplete_complete(fulljid_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GSList *
|
||||||
|
roster_get_nogroup(void)
|
||||||
|
{
|
||||||
|
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)) {
|
||||||
|
GSList *groups = p_contact_groups(value);
|
||||||
|
if (groups == NULL) {
|
||||||
|
result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_contacts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// resturn all contact structs
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
roster_get_group(const char * const group)
|
roster_get_group(const char * const group)
|
||||||
{
|
{
|
||||||
|
@ -65,5 +65,6 @@ 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);
|
GSList * roster_get_contacts_by_presence(const char * const presence);
|
||||||
|
GSList * roster_get_nogroup(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -628,6 +628,14 @@ handle_roster_add(const char * const barejid, const char * const name)
|
|||||||
ui_roster_add(barejid, name);
|
ui_roster_add(barejid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
handle_roster_update(const char * const barejid, const char * const name,
|
||||||
|
GSList *groups, const char * const subscription, gboolean pending_out)
|
||||||
|
{
|
||||||
|
roster_update(barejid, name, groups, subscription, pending_out);
|
||||||
|
ui_roster();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
handle_autoping_cancel(void)
|
handle_autoping_cancel(void)
|
||||||
{
|
{
|
||||||
|
@ -114,5 +114,7 @@ void handle_muc_self_online(const char * const room, const char * const nick, gb
|
|||||||
void handle_muc_occupant_online(const char * const room, const char * const nick, const char * const jid,
|
void handle_muc_occupant_online(const char * const room, const char * const nick, const char * const jid,
|
||||||
const char * const role, const char * const affiliation, const char * const actor, const char * const reason,
|
const char * const role, const char * const affiliation, const char * const actor, const char * const reason,
|
||||||
const char * const show_str, const char * const status_str);
|
const char * const show_str, const char * const status_str);
|
||||||
|
void handle_roster_update(const char * const barejid, const char * const name,
|
||||||
|
GSList *groups, const char * const subscription, gboolean pending_out);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -402,36 +402,42 @@ _ui_roster_add(const char * const barejid, const char * const name)
|
|||||||
} else {
|
} else {
|
||||||
cons_show("Roster item added: %s", barejid);
|
cons_show("Roster item added: %s", barejid);
|
||||||
}
|
}
|
||||||
|
ui_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_roster_remove(const char * const barejid)
|
_ui_roster_remove(const char * const barejid)
|
||||||
{
|
{
|
||||||
cons_show("Roster item removed: %s", barejid);
|
cons_show("Roster item removed: %s", barejid);
|
||||||
|
ui_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_contact_already_in_group(const char * const contact, const char * const group)
|
_ui_contact_already_in_group(const char * const contact, const char * const group)
|
||||||
{
|
{
|
||||||
cons_show("%s already in group %s", contact, group);
|
cons_show("%s already in group %s", contact, group);
|
||||||
|
ui_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_contact_not_in_group(const char * const contact, const char * const group)
|
_ui_contact_not_in_group(const char * const contact, const char * const group)
|
||||||
{
|
{
|
||||||
cons_show("%s is not currently in group %s", contact, group);
|
cons_show("%s is not currently in group %s", contact, group);
|
||||||
|
ui_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_group_added(const char * const contact, const char * const group)
|
_ui_group_added(const char * const contact, const char * const group)
|
||||||
{
|
{
|
||||||
cons_show("%s added to group %s", contact, group);
|
cons_show("%s added to group %s", contact, group);
|
||||||
|
ui_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_group_removed(const char * const contact, const char * const group)
|
_ui_group_removed(const char * const contact, const char * const group)
|
||||||
{
|
{
|
||||||
cons_show("%s removed from group %s", contact, group);
|
cons_show("%s removed from group %s", contact, group);
|
||||||
|
ui_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -577,6 +583,7 @@ _ui_disconnected(void)
|
|||||||
title_bar_set_presence(CONTACT_OFFLINE);
|
title_bar_set_presence(CONTACT_OFFLINE);
|
||||||
status_bar_clear_message();
|
status_bar_clear_message();
|
||||||
status_bar_update_virtual();
|
status_bar_update_virtual();
|
||||||
|
ui_hide_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2864,10 +2871,10 @@ static void
|
|||||||
_ui_roster_contacts_by_presence(const char * const presence, char *title)
|
_ui_roster_contacts_by_presence(const char * const presence, char *title)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_console();
|
ProfWin *window = wins_get_console();
|
||||||
GSList *contacts = roster_get_contacts_by_presence(presence);
|
|
||||||
wattron(window->subwin, COLOUR_ROOMINFO);
|
wattron(window->subwin, COLOUR_ROOMINFO);
|
||||||
win_printline_nowrap(window->subwin, title);
|
win_printline_nowrap(window->subwin, title);
|
||||||
wattroff(window->subwin, COLOUR_ROOMINFO);
|
wattroff(window->subwin, COLOUR_ROOMINFO);
|
||||||
|
GSList *contacts = roster_get_contacts_by_presence(presence);
|
||||||
if (contacts) {
|
if (contacts) {
|
||||||
GSList *curr_contact = contacts;
|
GSList *curr_contact = contacts;
|
||||||
while (curr_contact) {
|
while (curr_contact) {
|
||||||
@ -2879,6 +2886,47 @@ _ui_roster_contacts_by_presence(const char * const presence, char *title)
|
|||||||
g_slist_free(contacts);
|
g_slist_free(contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ui_roster_contacts_by_group(char *group)
|
||||||
|
{
|
||||||
|
ProfWin *window = wins_get_console();
|
||||||
|
wattron(window->subwin, COLOUR_ROOMINFO);
|
||||||
|
GString *title = g_string_new(" -");
|
||||||
|
g_string_append(title, group);
|
||||||
|
win_printline_nowrap(window->subwin, title->str);
|
||||||
|
g_string_free(title, TRUE);
|
||||||
|
wattroff(window->subwin, COLOUR_ROOMINFO);
|
||||||
|
GSList *contacts = roster_get_group(group);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_slist_free(contacts);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ui_roster_contacts_by_no_group(void)
|
||||||
|
{
|
||||||
|
ProfWin *window = wins_get_console();
|
||||||
|
GSList *contacts = roster_get_nogroup();
|
||||||
|
if (contacts) {
|
||||||
|
wattron(window->subwin, COLOUR_ROOMINFO);
|
||||||
|
win_printline_nowrap(window->subwin, " -no group");
|
||||||
|
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
|
||||||
_ui_roster(void)
|
_ui_roster(void)
|
||||||
{
|
{
|
||||||
@ -2894,6 +2942,15 @@ _ui_roster(void)
|
|||||||
if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
|
if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
|
||||||
_ui_roster_contacts_by_presence("offline", " -Offline");
|
_ui_roster_contacts_by_presence("offline", " -Offline");
|
||||||
}
|
}
|
||||||
|
} else if (g_strcmp0(prefs_get_string(PREF_ROSTER_BY), "group") == 0) {
|
||||||
|
werase(window->subwin);
|
||||||
|
GSList *groups = roster_get_groups();
|
||||||
|
GSList *curr_group = groups;
|
||||||
|
while (curr_group) {
|
||||||
|
_ui_roster_contacts_by_group(curr_group->data);
|
||||||
|
curr_group = g_slist_next(curr_group);
|
||||||
|
}
|
||||||
|
_ui_roster_contacts_by_no_group();
|
||||||
} else {
|
} else {
|
||||||
GSList *contacts = roster_get_contacts();
|
GSList *contacts = roster_get_contacts();
|
||||||
if (contacts) {
|
if (contacts) {
|
||||||
|
@ -280,7 +280,7 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
|||||||
handle_roster_add(barejid, name);
|
handle_roster_add(barejid, name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
roster_update(barejid, name, groups, sub, pending_out);
|
handle_roster_update(barejid, name, groups, sub, pending_out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user