mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Show occupants affiliation and role with /info in rooms
This commit is contained in:
parent
9bff9c850b
commit
7ec0dd0b83
@ -2080,7 +2080,10 @@ cmd_room(gchar **args, struct cmd_help_t help)
|
||||
if (g_strcmp0(args[0], "info") == 0) {
|
||||
char *role = muc_role_str(room);
|
||||
char *affiliation = muc_affiliation_str(room);
|
||||
ui_current_print_line("Affiliation: %s, Role: %s", affiliation, role);
|
||||
win_save_print(window, '-', NULL, 0, 0, "", "");
|
||||
win_save_vprint(window, '!', NULL, 0, 0, "", "Affiliation: %s", affiliation);
|
||||
win_save_vprint(window, '!', NULL, 0, 0, "", "Role: %s", role);
|
||||
win_save_print(window, '-', NULL, 0, 0, "", "");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
12
src/muc.c
12
src/muc.c
@ -507,6 +507,18 @@ muc_occupant_available(Occupant *occupant)
|
||||
return (occupant->presence == RESOURCE_ONLINE || occupant->presence == RESOURCE_CHAT);
|
||||
}
|
||||
|
||||
const char *
|
||||
muc_occupant_affiliation_str(Occupant *occupant)
|
||||
{
|
||||
return _affiliation_to_string(occupant->affiliation);
|
||||
}
|
||||
|
||||
const char *
|
||||
muc_occupant_role_str(Occupant *occupant)
|
||||
{
|
||||
return _role_to_string(occupant->role);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the old_nick from the roster, and flag that a pending nickname change
|
||||
* is in progress
|
||||
|
@ -95,6 +95,8 @@ Autocomplete muc_roster_ac(const char * const room);
|
||||
Occupant* muc_roster_item(const char * const room, const char * const nick);
|
||||
|
||||
gboolean muc_occupant_available(Occupant *occupant);
|
||||
const char * muc_occupant_affiliation_str(Occupant *occupant);
|
||||
const char * muc_occupant_role_str(Occupant *occupant);
|
||||
|
||||
void muc_roster_nick_change_start(const char * const room, const char * const new_nick, const char * const old_nick);
|
||||
char* muc_roster_nick_change_complete(const char * const room, const char * const nick);
|
||||
|
@ -190,19 +190,23 @@ void
|
||||
win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant)
|
||||
{
|
||||
const char *presence_str = string_from_resource_presence(occupant->presence);
|
||||
const char *occupant_affiliation = muc_occupant_affiliation_str(occupant);
|
||||
const char *occupant_role = muc_occupant_role_str(occupant);
|
||||
|
||||
int presence_colour = win_presence_colour(presence_str);
|
||||
|
||||
win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", occupant->nick);
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
|
||||
win_save_print(window, '-', NULL, 0, 0, "", "");
|
||||
win_save_print(window, '!', NULL, NO_EOL, presence_colour, "", occupant->nick);
|
||||
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
|
||||
|
||||
if (occupant->status) {
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
|
||||
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
|
||||
}
|
||||
|
||||
win_save_newline(window);
|
||||
|
||||
win_save_vprint(window, '-', NULL, NO_DATE, 0, "", "Role: %s, Affiliation: %s", occupant->role, occupant->affiliation);
|
||||
win_save_vprint(window, '!', NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation);
|
||||
win_save_vprint(window, '!', NULL, 0, 0, "", " Role: %s", occupant_role);
|
||||
|
||||
Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick);
|
||||
Capabilities *caps = caps_lookup(jidp->fulljid);
|
||||
@ -210,44 +214,46 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
|
||||
if (caps) {
|
||||
// show identity
|
||||
if ((caps->category != NULL) || (caps->type != NULL) || (caps->name != NULL)) {
|
||||
win_save_print(window, '-', NULL, NO_EOL, 0, "", " Identity: ");
|
||||
win_save_print(window, '!', NULL, NO_EOL, 0, "", " Identity: ");
|
||||
if (caps->name != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->name);
|
||||
win_save_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->name);
|
||||
if ((caps->category != NULL) || (caps->type != NULL)) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
|
||||
}
|
||||
}
|
||||
if (caps->type != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->type);
|
||||
win_save_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->type);
|
||||
if (caps->category != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
|
||||
win_save_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", " ");
|
||||
}
|
||||
}
|
||||
if (caps->category != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->category);
|
||||
win_save_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->category);
|
||||
}
|
||||
win_save_newline(window);
|
||||
}
|
||||
if (caps->software != NULL) {
|
||||
win_save_vprint(window, '-', NULL, NO_EOL, 0, "", " Software: %s", caps->software);
|
||||
win_save_vprint(window, '!', NULL, NO_EOL, 0, "", " Software: %s", caps->software);
|
||||
}
|
||||
if (caps->software_version != NULL) {
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
|
||||
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
|
||||
}
|
||||
if ((caps->software != NULL) || (caps->software_version != NULL)) {
|
||||
win_save_newline(window);
|
||||
}
|
||||
if (caps->os != NULL) {
|
||||
win_save_vprint(window, '-', NULL, NO_EOL, 0, "", " OS: %s", caps->os);
|
||||
win_save_vprint(window, '!', NULL, NO_EOL, 0, "", " OS: %s", caps->os);
|
||||
}
|
||||
if (caps->os_version != NULL) {
|
||||
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
|
||||
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
|
||||
}
|
||||
if ((caps->os != NULL) || (caps->os_version != NULL)) {
|
||||
win_save_newline(window);
|
||||
}
|
||||
caps_destroy(caps);
|
||||
}
|
||||
|
||||
win_save_print(window, '-', NULL, 0, 0, "", "");
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user