From: Martin Johansson Date: Tue, 13 Mar 2012 19:36:50 +0000 (+0100) Subject: Fix deaf/mute issues. Fix channel moves by admin and admin enter channels with password. X-Git-Url: http://git.code-monkey.de/?p=umurmur.git;a=commitdiff_plain;h=dc46deeb538be794a3cf368d5494731925f66fda Fix deaf/mute issues. Fix channel moves by admin and admin enter channels with password. --- diff --git a/src/client.c b/src/client.c index bdee0c8..30979e8 100644 --- a/src/client.c +++ b/src/client.c @@ -775,7 +775,7 @@ out: static inline void Client_send_voice(client_t *src, client_t *dst, uint8_t *data, int len, int poslen) { - if (IS_AUTH(dst) && dst != src && !dst->deaf) { + if (IS_AUTH(dst) && dst != src && (!dst->deaf || !dst->self_deaf)) { if (poslen > 0 && /* Has positional data */ src->context != NULL && dst->context != NULL && /* ...both source and destination has context */ strcmp(src->context, dst->context) == 0) /* ...and the contexts match */ diff --git a/src/client.h b/src/client.h index 5f8f2ef..853a076 100644 --- a/src/client.h +++ b/src/client.h @@ -73,7 +73,7 @@ typedef struct { int sessionId; uint64_t key; char *username; - bool_t bUDP, authenticated, deaf, mute, recording; + bool_t bUDP, authenticated, deaf, mute, self_deaf, self_mute, recording; char *os, *release, *os_version; uint32_t version; int codec_count; diff --git a/src/messagehandler.c b/src/messagehandler.c index f07e3ca..fc489fd 100644 --- a/src/messagehandler.c +++ b/src/messagehandler.c @@ -298,15 +298,22 @@ void Mh_handle_message(client_t *client, message_t *msg) sendmsg->payload.userState->has_channel_id = true; sendmsg->payload.userState->channel_id = ((channel_t *)client_itr->channel)->id; - /* Only self_mute/deaf supported */ - if (client_itr->deaf) { + if (client_itr->self_deaf) { sendmsg->payload.userState->has_self_deaf = true; sendmsg->payload.userState->self_deaf = true; } - if (client_itr->mute) { + if (client_itr->self_mute) { sendmsg->payload.userState->has_self_mute = true; sendmsg->payload.userState->self_mute = true; } + if (client_itr->deaf) { + sendmsg->payload.userState->has_deaf = true; + sendmsg->payload.userState->deaf = true; + } + if (client_itr->mute) { + sendmsg->payload.userState->has_mute = true; + sendmsg->payload.userState->mute = true; + } if (client_itr->recording) { sendmsg->payload.userState->has_recording = true; sendmsg->payload.userState->recording = true; @@ -435,18 +442,18 @@ void Mh_handle_message(client_t *client, message_t *msg) if (!target->mute) { msg->payload.userState->has_deaf = true; msg->payload.userState->deaf = false; - client->deaf = false; + target->deaf = false; } } if (msg->payload.userState->has_self_deaf) { - client->deaf = msg->payload.userState->self_deaf; + client->self_deaf = msg->payload.userState->self_deaf; } if (msg->payload.userState->has_self_mute) { - client->mute = msg->payload.userState->self_mute; - if (!client->mute) { + client->self_mute = msg->payload.userState->self_mute; + if (!client->self_mute) { msg->payload.userState->has_self_deaf = true; msg->payload.userState->self_deaf = false; - client->deaf = false; + client->self_deaf = false; } } if (msg->payload.userState->has_recording && @@ -475,16 +482,22 @@ void Mh_handle_message(client_t *client, message_t *msg) } if (msg->payload.userState->has_channel_id) { int leave_id; - channelJoinResult_t chjoin_rc = Chan_userJoin_id_test(msg->payload.userState->channel_id, client); + channelJoinResult_t chjoin_rc = Chan_userJoin_id_test(msg->payload.userState->channel_id, target); if (chjoin_rc != CHJOIN_OK) { - if (chjoin_rc == CHJOIN_WRONGPW) { + if (chjoin_rc == CHJOIN_WRONGPW && target == client && !client->isAdmin) { sendPermissionDenied(client, "Wrong channel password"); + break; } - break; + /* Tricky one: if user hasn't the password, but is moved to the channel by admin then let + * the user in. Also let admin user in regardless of pchannel password. + * Take no action on other errors. + */ + else if (!(chjoin_rc == CHJOIN_WRONGPW && (target != client || client->isAdmin))) + break; } - leave_id = Chan_userJoin_id(msg->payload.userState->channel_id, client); + leave_id = Chan_userJoin_id(msg->payload.userState->channel_id, target); if (leave_id > 0) { Log_debug("Removing channel ID %d", leave_id); sendmsg = Msg_create(ChannelRemove);