From 3790b16299efb29843d4a221c41047d094616b5e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 18 Oct 2014 01:07:25 +0100 Subject: [PATCH] Add output for when both role and affiliation changed at same time --- TODO_045 | 1 + src/server_events.c | 12 +++++++++--- src/ui/core.c | 8 ++++++++ src/ui/ui.h | 2 ++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/TODO_045 b/TODO_045 index f962f9a4..4e844147 100644 --- a/TODO_045 +++ b/TODO_045 @@ -1,5 +1,6 @@ Show own role affilaition changes (including actor/reason) Show occupants role and affiliation changes (including actor/reason) +Add config option to not show role/affilation messages and changes Check all commands from private conversations Test all freetext args Make form editing commands less verbose diff --git a/src/server_events.c b/src/server_events.c index 3916fc41..631a190d 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -719,10 +719,16 @@ handle_muc_self_online(const char * const room, const char * const nick, gboolea // check for change in role/affiliation } else { - if (g_strcmp0(role, old_role) != 0) { + // both changed + if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) { + ui_room_role_and_affiliation_change(room, role, affiliation); + + // role changed + } else if (g_strcmp0(role, old_role) != 0) { ui_room_role_change(room, role); - } - if (g_strcmp0(affiliation, old_affiliation) != 0) { + + // affiliation changed + } else if (g_strcmp0(affiliation, old_affiliation) != 0) { ui_room_affiliation_change(room, affiliation); } } diff --git a/src/ui/core.c b/src/ui/core.c index eed865bb..5331e91f 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1351,6 +1351,13 @@ _ui_room_affiliation_change(const char * const room, const char * const affiliat win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation); } +static void +_ui_room_role_and_affiliation_change(const char * const room, const char * const role, const char * const affiliation) +{ + ProfWin *window = wins_get_by_recipient(room); + win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); +} + static void _ui_handle_room_info_error(const char * const room, const char * const error) { @@ -3076,5 +3083,6 @@ ui_init_module(void) ui_room_role_change = _ui_room_role_change; ui_room_affiliation_change = _ui_room_affiliation_change; ui_switch_to_room = _ui_switch_to_room; + ui_room_role_and_affiliation_change = _ui_room_role_and_affiliation_change; } diff --git a/src/ui/ui.h b/src/ui/ui.h index 46582549..ed0f5764 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -133,6 +133,8 @@ void (*ui_room_join)(const char * const room, gboolean focus); void (*ui_switch_to_room)(const char * const room); 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_role_and_affiliation_change)(const char * const room, const char * const role, + 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);