mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
mucwin_roster takes ProfMucWin
This commit is contained in:
parent
d21faa4609
commit
8b4bb1c7f1
@ -1158,7 +1158,7 @@ _who_room(ProfWin *window, const char *const command, gchar **args)
|
||||
|
||||
// no arg, show all contacts
|
||||
if ((presence == NULL) || (g_strcmp0(presence, "any") == 0)) {
|
||||
mucwin_roster(mucwin->roomjid, occupants, NULL);
|
||||
mucwin_roster(mucwin, occupants, NULL);
|
||||
|
||||
// available
|
||||
} else if (strcmp("available", presence) == 0) {
|
||||
@ -1172,7 +1172,7 @@ _who_room(ProfWin *window, const char *const command, gchar **args)
|
||||
occupants = g_list_next(occupants);
|
||||
}
|
||||
|
||||
mucwin_roster(mucwin->roomjid, filtered, "available");
|
||||
mucwin_roster(mucwin, filtered, "available");
|
||||
|
||||
// unavailable
|
||||
} else if (strcmp("unavailable", presence) == 0) {
|
||||
@ -1186,7 +1186,7 @@ _who_room(ProfWin *window, const char *const command, gchar **args)
|
||||
occupants = g_list_next(occupants);
|
||||
}
|
||||
|
||||
mucwin_roster(mucwin->roomjid, filtered, "unavailable");
|
||||
mucwin_roster(mucwin, filtered, "unavailable");
|
||||
|
||||
// show specific status
|
||||
} else {
|
||||
@ -1201,7 +1201,7 @@ _who_room(ProfWin *window, const char *const command, gchar **args)
|
||||
occupants = g_list_next(occupants);
|
||||
}
|
||||
|
||||
mucwin_roster(mucwin->roomjid, filtered, presence);
|
||||
mucwin_roster(mucwin, filtered, presence);
|
||||
}
|
||||
|
||||
g_list_free(occupants);
|
||||
|
@ -557,9 +557,10 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c
|
||||
muc_roster_set_complete(room);
|
||||
|
||||
// show roster if occupants list disabled by default
|
||||
if (!prefs_get_boolean(PREF_OCCUPANTS)) {
|
||||
ProfMucWin *mucwin = wins_get_muc(room);
|
||||
if (mucwin && !prefs_get_boolean(PREF_OCCUPANTS)) {
|
||||
GList *occupants = muc_roster(room);
|
||||
mucwin_roster(room, occupants, NULL);
|
||||
mucwin_roster(mucwin, occupants, NULL);
|
||||
g_list_free(occupants);
|
||||
}
|
||||
|
||||
|
@ -194,42 +194,40 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features)
|
||||
}
|
||||
|
||||
void
|
||||
mucwin_roster(const char *const roomjid, GList *roster, const char *const presence)
|
||||
mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence)
|
||||
{
|
||||
ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
|
||||
if (window == NULL) {
|
||||
log_error("Received room roster but no window open for %s.", roomjid);
|
||||
} else {
|
||||
if ((roster == NULL) || (g_list_length(roster) == 0)) {
|
||||
if (presence == NULL) {
|
||||
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty.");
|
||||
} else {
|
||||
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence);
|
||||
}
|
||||
assert(mucwin != NULL);
|
||||
|
||||
ProfWin *window = (ProfWin*)mucwin;
|
||||
if ((roster == NULL) || (g_list_length(roster) == 0)) {
|
||||
if (presence == NULL) {
|
||||
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty.");
|
||||
} else {
|
||||
int length = g_list_length(roster);
|
||||
if (presence == NULL) {
|
||||
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length);
|
||||
} else {
|
||||
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence);
|
||||
}
|
||||
|
||||
while (roster) {
|
||||
Occupant *occupant = roster->data;
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
|
||||
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
||||
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick);
|
||||
|
||||
if (roster->next) {
|
||||
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", ");
|
||||
}
|
||||
|
||||
roster = g_list_next(roster);
|
||||
}
|
||||
win_print(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", "");
|
||||
|
||||
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence);
|
||||
}
|
||||
} else {
|
||||
int length = g_list_length(roster);
|
||||
if (presence == NULL) {
|
||||
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length);
|
||||
} else {
|
||||
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence);
|
||||
}
|
||||
|
||||
while (roster) {
|
||||
Occupant *occupant = roster->data;
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
|
||||
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
||||
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick);
|
||||
|
||||
if (roster->next) {
|
||||
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", ");
|
||||
}
|
||||
|
||||
roster = g_list_next(roster);
|
||||
}
|
||||
win_print(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", "");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const ni
|
||||
const char *const affiliation, const char *const actor, const char *const reason);
|
||||
void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *const nick,
|
||||
const char *const role, const char *const affiliation, const char *const actor, const char *const reason);
|
||||
void mucwin_roster(const char *const roomjid, GList *occupants, const char *const presence);
|
||||
void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence);
|
||||
void mucwin_history(const char *const roomjid, const char *const nick, GDateTime *timestamp,
|
||||
const char *const message);
|
||||
void mucwin_message(const char *const roomjid, const char *const nick, const char *const message);
|
||||
|
@ -203,7 +203,7 @@ void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char * const n
|
||||
const char * const actor, const char * const reason) {}
|
||||
void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char * const nick, const char * const role,
|
||||
const char * const affiliation, const char * const actor, const char * const reason) {}
|
||||
void mucwin_roster(const char * const roomjid, GList *occupants, const char * const presence) {}
|
||||
void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char * const presence) {}
|
||||
void mucwin_history(const char * const roomjid, const char * const nick,
|
||||
GDateTime *timestamp, const char * const message) {}
|
||||
void mucwin_message(const char * const roomjid, const char * const nick,
|
||||
|
Loading…
Reference in New Issue
Block a user