diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command/command.c | 24 | ||||
-rw-r--r-- | src/server_events.c | 10 | ||||
-rw-r--r-- | src/server_events.h | 4 | ||||
-rw-r--r-- | src/ui/core.c | 36 | ||||
-rw-r--r-- | src/ui/ui.h | 8 | ||||
-rw-r--r-- | src/xmpp/presence.c | 4 |
6 files changed, 57 insertions, 29 deletions
diff --git a/src/command/command.c b/src/command/command.c index 1579fe79..1954e927 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -348,22 +348,22 @@ static struct cmd_t command_defs[] = NULL } } }, { "/affiliation", - cmd_affiliation, parse_args, 1, 3, NULL, - { "/affiliation set|list [affiliation] [jid]", "Manage room affiliations.", - { "/affiliation set|list [affiliation] [jid]", - "-----------------------------------------", - "set affiliation jid - Set the affiliation of user with jid.", - "list [affiliation] - List all users with the specified affiliation, or all if none specified.", + cmd_affiliation, parse_args_with_freetext, 1, 4, NULL, + { "/affiliation set|list [affiliation] [jid] [reason]", "Manage room affiliations.", + { "/affiliation set|list [affiliation] [jid] [reason]", + "--------------------------------------------------", + "set affiliation jid [reason]- Set the affiliation of user with jid, with an optional reason.", + "list [affiliation] - List all users with the specified affiliation, or all if none specified.", "The affiliation may be one of owner, admin, member, outcast or none.", NULL } } }, { "/role", - cmd_role, parse_args, 1, 3, NULL, - { "/role set|list [role] [nick]", "Manage room roles.", - { "/role set|list [role] [nick]", - "----------------------------", - "set role nick - Set the role of occupant with nick.", - "list [role] - List all occupants with the specified role, or all if none specified.", + cmd_role, parse_args_with_freetext, 1, 4, NULL, + { "/role set|list [role] [nick] [reason]", "Manage room roles.", + { "/role set|list [role] [nick] [reason]", + "-------------------------------------", + "set role nick [reason] - Set the role of occupant with nick, with an optional reason.", + "list [role] - List all occupants with the specified role, or all if none specified.", "The role may be one of moderator, participant, visitor or none.", NULL } } }, diff --git a/src/server_events.c b/src/server_events.c index 631a190d..0086bd7f 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -667,8 +667,8 @@ handle_ping_error_result(const char * const from, const char * const error) void handle_muc_self_online(const char * const room, const char * const nick, gboolean config_required, - const char * const role, const char * const affiliation, const char * const jid, const char * const show, - const char * const status) + const char * const role, const char * const affiliation, const char * const actor, const char * const reason, + const char * const jid, const char * const show, const char * const status) { muc_roster_add(room, nick, jid, role, affiliation, show, status); char *old_role = muc_role_str(room); @@ -721,15 +721,15 @@ handle_muc_self_online(const char * const room, const char * const nick, gboolea } else { // both changed if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) { - ui_room_role_and_affiliation_change(room, role, affiliation); + ui_room_role_and_affiliation_change(room, role, affiliation, actor, reason); // role changed } else if (g_strcmp0(role, old_role) != 0) { - ui_room_role_change(room, role); + ui_room_role_change(room, role, actor, reason); // affiliation changed } else if (g_strcmp0(affiliation, old_affiliation) != 0) { - ui_room_affiliation_change(room, affiliation); + ui_room_affiliation_change(room, affiliation, actor, reason); } } diff --git a/src/server_events.h b/src/server_events.h index 333543fb..992c68cc 100644 --- a/src/server_events.h +++ b/src/server_events.h @@ -111,8 +111,8 @@ void handle_room_configuration_form_error(const char * const from, const char * void handle_room_config_submit_result(const char * const room); void handle_room_config_submit_result_error(const char * const room, const char * const message); void handle_muc_self_online(const char * const room, const char * const nick, gboolean config_required, - const char * const role, const char * const affiliation, const char * const jid, const char * const show, - const char * const status); + const char * const role, const char * const affiliation, const char * const actor, const char * const reason, + const char * const jid, const char * const show, const char * const status); 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 show_str, const char * const status_str); diff --git a/src/ui/core.c b/src/ui/core.c index 5331e91f..2f8b3670 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1338,24 +1338,48 @@ _ui_switch_to_room(const char * const room) } static void -_ui_room_role_change(const char * const room, const char * const role) +_ui_room_role_change(const char * const room, const char * const role, const char * const actor, + const char * const reason) { ProfWin *window = wins_get_by_recipient(room); - win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your role has been changed to: %s", role); + win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your role has been changed to: %s", role); + if (actor) { + win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); + } + if (reason) { + win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); + } + win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); } static void -_ui_room_affiliation_change(const char * const room, const char * const affiliation) +_ui_room_affiliation_change(const char * const room, const char * const affiliation, const char * const actor, + const char * const reason) { ProfWin *window = wins_get_by_recipient(room); - win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation); + win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation); + if (actor) { + win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); + } + if (reason) { + win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); + } + win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); } static void -_ui_room_role_and_affiliation_change(const char * const room, const char * const role, const char * const affiliation) +_ui_room_role_and_affiliation_change(const char * const room, const char * const role, const char * const affiliation, + const char * const actor, const char * const reason) { 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); + win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); + if (actor) { + win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); + } + if (reason) { + win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); + } + win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); } static void diff --git a/src/ui/ui.h b/src/ui/ui.h index ed0f5764..044ea6e9 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -131,10 +131,12 @@ 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_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_change)(const char * const room, const char * const role, const char * const actor, + const char * const reason); +void (*ui_room_affiliation_change)(const char * const room, const char * const affiliation, const char * const actor, + const char * const reason); void (*ui_room_role_and_affiliation_change)(const char * const room, const char * const role, - const char * const affiliation); + const char * const affiliation, const char * const actor, const char * const reason); 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); diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index ea382523..80377703 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -759,7 +759,9 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * // self online } else { gboolean config_required = stanza_muc_requires_config(stanza); - handle_muc_self_online(room, nick, config_required, role, affiliation, jid, show_str, status_str); + char *actor = stanza_get_kickban_actor(stanza); + char *reason = stanza_get_kickban_reason(stanza); + handle_muc_self_online(room, nick, config_required, role, affiliation, actor, reason, jid, show_str, status_str); } // handle presence from room members |