Skip to content
Permalink
Browse files

Fix incorrect handling of mumble:// links

If a user is connected and authenticated on a server,
and he/she clicks a mumble:// link that connects him/her
to the current server, he/she is moved to the channel
specified in the link. Previously, this would disconnect
and reconnect the user to the server.

If a user is connected to one server and follows a
mumble:// link to another server, he/she is now
placed in the channel specified in the link.
Previously, the channel they would be moved into
would be the channel they were in on the first
server.
  • Loading branch information...
bontibon authored and mkrautz committed Mar 29, 2014
1 parent 01a7c58 commit 13c6e58256af933becab9f4cb9c3ee3c4009aba0
Showing with 23 additions and 26 deletions.
  1. +19 −1 src/Channel.cpp
  2. +1 −0 src/Channel.h
  3. +2 −25 src/mumble/MainWindow.cpp
  4. +1 −0 src/mumble/Messages.cpp
@@ -209,7 +209,6 @@ size_t Channel::getLevel() const {
return i;
}


size_t Channel::getDepth() const {
if(qlChannels.empty()) {
return 0;
@@ -222,3 +221,22 @@ size_t Channel::getDepth() const {

return result;
}

QString Channel::getPath() const {
QString out;

const Channel *tmp = this;
while (tmp->cParent) {
// Skip the root channel.
if (tmp->iId == 0) {
break;
}

out.prepend(QString::fromLatin1("/"));
out.prepend(tmp->qsName);

tmp = tmp->cParent;
}

return out;
}
@@ -88,6 +88,7 @@ class Channel : public QObject {

size_t getLevel() const;
size_t getDepth() const;
QString getPath() const;

void addChannel(Channel *c);
void removeChannel(Channel *c);
@@ -692,8 +692,9 @@ void MainWindow::openUrl(const QUrl &url) {
QString oHost, oUser, oPw;
unsigned short oport;
g.sh->getConnectionInfo(oHost, oport, oUser, oPw);
ClientUser *p = ClientUser::get(g.uiSession);

if ((user.isEmpty() || (user == oUser)) &&
if ((user.isEmpty() || (p && p->iId >= 0) || (user == oUser)) &&
(host.isEmpty() || ((host == oHost) && (port == oport)))) {
findDesiredChannel();
return;
@@ -2453,31 +2454,7 @@ void MainWindow::serverConnected() {
#endif
}

static QString getPathToChannel(Channel *c) {
QString out;

if (!c)
return out;

Channel *tmp = c;
while (tmp->cParent) {
// skip root channel
if (tmp->iId == 0)
break;

out.prepend(QString::fromLatin1("/"));
out.prepend(tmp->qsName);

tmp = tmp->cParent;
}

return out;
}

void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString reason) {
if (g.uiSession)
qsDesiredChannel = getPathToChannel(ClientUser::get(g.uiSession)->cChannel);

g.uiSession = 0;
g.pPermissions = ChanACL::None;
g.bAttenuateOthers = false;
@@ -464,6 +464,7 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {

if (pDst == pSelf) {
g.mw->updateChatBar();
qsDesiredChannel = c->getPath();
}

if (log && (pDst != pSelf) && (pDst->cChannel == pSelf->cChannel)) {

0 comments on commit 13c6e58

Please sign in to comment.
You can’t perform that action at this time.