1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added reason to role/affiliation changes

This commit is contained in:
James Booth 2014-10-18 01:37:52 +01:00
parent 3790b16299
commit 67755ca74d
6 changed files with 57 additions and 29 deletions

View File

@ -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 } } },

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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