Skip to content

Commit

Permalink
Merge pull request #4129: Allow ChannelListener in same channel
Browse files Browse the repository at this point in the history
Before you weren't able to place a listener proxy (ChannelListener) into
the same channel that you're currently in and if you joined a channel
that you were listening to before, your listener proxy would be removed
from that channel.

It was brought to my attention though that there are cases in which a
person wants to hear what's going on in several channels and thus places
listener proxies into them. However if that same person needs to
constantly hop between these listened channels (e.g. to talk to the
folks in there), it gets very annoying as that person constantly has to
think about re-adding the listener proxy into the channel it just left.
  • Loading branch information
Krzmbrzl authored May 7, 2020
2 parents a56e57c + e839bb2 commit e6f9883
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
16 changes: 9 additions & 7 deletions src/mumble/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1993,16 +1993,18 @@ void MainWindow::qmChannel_aboutToShow() {
if (c && c->iId != ClientUser::get(g.uiSession)->cChannel->iId) {
qmChannel->addAction(qaChannelJoin);

if (g.sh->uiVersion >= 0x010400) {
// If the server's version is less than 1.4, the listening feature is not supported yet
// and thus it doesn't make sense to show the action for it
qmChannel->addAction(qaChannelListen);
qaChannelListen->setChecked(ChannelListener::isListening(g.uiSession, c->iId));
}

qmChannel->addSeparator();
}

if (c && g.sh && g.sh->uiVersion >= 0x010400) {
// If the server's version is less than 1.4, the listening feature is not supported yet
// and thus it doesn't make sense to show the action for it
qmChannel->addAction(qaChannelListen);
qaChannelListen->setChecked(ChannelListener::isListening(g.uiSession, c->iId));
}

qmChannel->addSeparator();

qmChannel->addAction(qaChannelAdd);
qmChannel->addAction(qaChannelACL);
qmChannel->addAction(qaChannelRemove);
Expand Down
11 changes: 9 additions & 2 deletions src/mumble/UserModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ int ModelItem::insertIndex(ClientUser *p, bool isListener) const {
QString ModelItem::hash() const {
if (pUser) {
if (! pUser->qsHash.isEmpty())
return pUser->qsHash;
return pUser->qsHash + (isListener ? QLatin1String("l"): QString());
else
return QLatin1String(sha1(pUser->qsName).toHex());
return QLatin1String(sha1(pUser->qsName + (isListener ? QLatin1String("l") : QString())).toHex());
} else {
QCryptographicHash chash(QCryptographicHash::Sha1);

Expand Down Expand Up @@ -1444,6 +1444,13 @@ void UserModel::removeAll() {
iChannelDescription = -1;
bClicked = false;

// in order to avoid complications, we remove all ChannelListeners first
foreach(i, item->qlChildren) {
if (i->pUser && i->isListener) {
removeChannelListener(i, item);
}
}

foreach(i, item->qlChildren) {
if (i->pUser)
removeUser(i->pUser);
Expand Down
6 changes: 0 additions & 6 deletions src/murmur/Messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,12 +907,6 @@ void Server::msgUserState(ServerUser *uSource, MumbleProto::UserState &msg) {
userEnterChannel(pDstServerUser, c, msg);
log(uSource, QString("Moved %1 to %2").arg(QString(*pDstServerUser), QString(*c)));
bBroadcast = true;

if (ChannelListener::isListening(pDstServerUser, c)) {
// If a user joins a channel (s)he has been listening to before, it means that this user will no
// longer listen into that channel (as joining it can be viewed as promoting the listening to a join)
msg.add_listening_channel_remove(c->iId);
}
}

// Handle channel listening
Expand Down
22 changes: 15 additions & 7 deletions src/murmur/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,12 +1092,6 @@ void Server::processMsg(ServerUser *u, const char *data, int len) {

buffer[0] = static_cast<char>(type | SpeechFlags::Normal);

// Send audio to all users in the same channel
foreach(User *p, c->qlUsers) {
ServerUser *pDst = static_cast<ServerUser *>(p);
SENDTO;
}

// Send audio to all users that are listening to the channel
foreach(unsigned int currentSession, ChannelListener::getListenersForChannel(c)) {
ServerUser *pDst = static_cast<ServerUser *>(qhUsers.value(currentSession));
Expand All @@ -1106,6 +1100,16 @@ void Server::processMsg(ServerUser *u, const char *data, int len) {
}
}

// Send audio to all users in the same channel
foreach(User *p, c->qlUsers) {
ServerUser *pDst = static_cast<ServerUser *>(p);

// As we send the audio to this particular user here, we want to make sure to not send it again due to a listener proxy
listeningUsers -= pDst;

SENDTO;
}

// Send audio to all linked channels the user has speak-permission
if (! c->qhLinks.isEmpty()) {
QSet<Channel *> chans = c->allLinks();
Expand All @@ -1131,6 +1135,10 @@ void Server::processMsg(ServerUser *u, const char *data, int len) {
foreach(User *p, l->qlUsers) {
if (!ChannelListener::isListening(p->uiSession, c->iId)) {
ServerUser *pDst = static_cast<ServerUser *>(p);

// As we send the audio to this particular user here, we want to make sure to not send it again due to a listener proxy
listeningUsers -= pDst;

SENDTO;
}
}
Expand Down Expand Up @@ -1205,7 +1213,7 @@ void Server::processMsg(ServerUser *u, const char *data, int len) {
}
}

// If a user receives the audio thorugh this shout anyways, we won't send it through the
// If a user receives the audio through this shout anyways, we won't send it through the
// listening channel again (and thus sending the audio twice)
listener -= channel;
}
Expand Down

0 comments on commit e6f9883

Please sign in to comment.