Fix deaf/mute issues. Fix channel moves by admin and admin enter channels with password.
authorMartin Johansson <martin@fatbob.nu>
Tue, 13 Mar 2012 19:36:50 +0000 (20:36 +0100)
committerMartin Johansson <martin@fatbob.nu>
Tue, 13 Mar 2012 19:36:50 +0000 (20:36 +0100)
src/client.c
src/client.h
src/messagehandler.c

index bdee0c89ac1ff74d6b902b1f162f7274a18da275..30979e8a11b76aa69d7e8d9af3dd37a06cce5430 100644 (file)
@@ -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 */
index 5f8f2ef4873bdac82891835595b26e19a73113d3..853a076d6252189dfd859e621c3433f97ce091ed 100644 (file)
@@ -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;
index f07e3ca186de5099adfdb2cee5869e43508c22c3..fc489fd392e7e1eba7fe4ef011327b2331f5d25c 100644 (file)
@@ -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);