1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Show role/affiliation on room join and on change

This commit is contained in:
James Booth 2014-10-12 02:10:46 +01:00
parent a51fc61d27
commit 6b6ed6a93e
4 changed files with 43 additions and 5 deletions

View File

@ -1,4 +1,2 @@
Show role/affiliation on join
Show role/affiliation on update
Check all commands from private conversations
Test all freetext args

View File

@ -677,6 +677,10 @@ handle_muc_self_online(const char * const room, const char * const nick, gboolea
const char * const status)
{
muc_roster_add(room, nick, jid, role, affiliation, show, status);
char *old_role = muc_role_str(room);
char *old_affiliation = muc_affiliation_str(room);
muc_set_role(room, role);
muc_set_affiliation(room, affiliation);
// handle self nick change
if (muc_nick_change_pending(room)) {
@ -718,10 +722,16 @@ handle_muc_self_online(const char * const room, const char * const nick, gboolea
muc_set_requires_config(room, TRUE);
ui_room_requires_config(room);
}
}
muc_set_role(room, role);
muc_set_affiliation(room, affiliation);
// check for change in role/affiliation
} else {
if (g_strcmp0(role, old_role) != 0) {
ui_room_role_change(room, role);
}
if (g_strcmp0(affiliation, old_affiliation) != 0) {
ui_room_affiliation_change(room, affiliation);
}
}
ui_muc_roster(room);
}

View File

@ -1370,6 +1370,18 @@ _ui_room_join(const char * const room, gboolean focus)
window = wins_new(room, WIN_MUC);
}
char *nick = muc_nick(room);
char *role = muc_role_str(room);
char *affiliation = muc_affiliation_str(room);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "-> You have joined the room as %s", nick);
if (role) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", role: %s", role);
}
if (affiliation) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", affiliation: %s", affiliation);
}
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", "");
num = wins_get_num(window);
if (focus) {
@ -1382,6 +1394,20 @@ _ui_room_join(const char * const room, gboolean focus)
}
}
static void
_ui_room_role_change(const char * const room, const char * const role)
{
ProfWin *window = wins_get_by_recipient(room);
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your role has been changed to: %s", role);
}
static void
_ui_room_affiliation_change(const char * const room, const char * const affiliation)
{
ProfWin *window = wins_get_by_recipient(room);
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation);
}
static void
_ui_handle_room_info_error(const char * const room, const char * const error)
{
@ -3102,5 +3128,7 @@ ui_init_module(void)
ui_muc_roster = _ui_muc_roster;
ui_room_show_occupants = _ui_room_show_occupants;
ui_room_hide_occupants = _ui_room_hide_occupants;
ui_room_role_change = _ui_room_role_change;
ui_room_affiliation_change = _ui_room_affiliation_change;
}

View File

@ -130,6 +130,8 @@ void (*ui_recipient_gone)(const char * const barejid);
void (*ui_outgoing_msg)(const char * const from, const char * const to,
const char * const message);
void (*ui_room_join)(const char * const room, gboolean focus);
void (*ui_room_role_change)(const char * const room, const char * const role);
void (*ui_room_affiliation_change)(const char * const room, const char * const affiliation);
void (*ui_room_roster)(const char * const room, GList *roster, const char * const presence);
void (*ui_room_history)(const char * const room_jid, const char * const nick,
GTimeVal tv_stamp, const char * const message);