Skip to content
Permalink
Browse files

Allow user renames via UserList without requiring a reconnect.

This commit also adds a check to Murmur's UserState handler that
discards UserState messages that come from users. Only Murmur
can send UserStates with a name.

The client-facing way of renaming is through the UserList. When
a user is renamed, Murmur will broadcast a UserState with the
given session and name to perform a live rename operation.
  • Loading branch information...
bontibon authored and mkrautz committed Apr 13, 2014
1 parent 1256386 commit 02ddd914817676c528d676c7debee67c0d43957b
Showing with 28 additions and 4 deletions.
  1. +2 −2 src/mumble/Log.cpp
  2. +1 −1 src/mumble/Log.h
  3. +7 −1 src/mumble/Messages.cpp
  4. +18 −0 src/murmur/Messages.cpp
@@ -266,7 +266,7 @@ QString Log::formatChannel(::Channel *c) {
return QString::fromLatin1("<a href='channelid://%1/%3' class='log-channel'>%2</a>").arg(c->iId).arg(Qt::escape(c->qsName)).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
}

QString Log::formatClientUser(ClientUser *cu, LogColorType t) {
QString Log::formatClientUser(ClientUser *cu, LogColorType t, const QString &displayName) {
QString className;
if (t == Log::Target) {
className = QString::fromLatin1("target");
@@ -275,7 +275,7 @@ QString Log::formatClientUser(ClientUser *cu, LogColorType t) {
}

if (cu) {
QString name = Qt::escape(cu->qsName);
QString name = Qt::escape(displayName.isNull() ? cu->qsName : displayName);
if (cu->qsHash.isEmpty()) {
return QString::fromLatin1("<a href='clientid://%2/%4' class='log-user log-%1'>%3</a>").arg(className).arg(cu->uiSession).arg(name).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
} else {
@@ -94,7 +94,7 @@ class Log : public QObject {
static QString imageToImg(const QByteArray &format, const QByteArray &image);
static QString imageToImg(QImage img);
static QString msgColor(const QString &text, LogColorType t);
static QString formatClientUser(ClientUser *cu, LogColorType t);
static QString formatClientUser(ClientUser *cu, LogColorType t, const QString &displayName=QString());
static QString formatChannel(::Channel *c);
public slots:
void log(MsgType t, const QString &console, const QString &terse=QString(), bool ownMessage = false);
@@ -479,7 +479,13 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
}
}
if (msg.has_name()) {
pmModel->renameUser(pDst, u8(msg.name()));
QString oldName = pDst->qsName;
QString newName = u8(msg.name());
pmModel->renameUser(pDst, newName);
if (! oldName.isNull() && oldName != newName) {
g.l->log(Log::Information, tr("%1 renamed to %2").arg(Log::formatClientUser(pDst, Log::Target, oldName),
Log::formatClientUser(pDst, Log::Target)));
}
}
if (msg.has_texture_hash()) {
pDst->qbaTextureHash = blob(msg.texture_hash());
@@ -492,6 +492,11 @@ void Server::msgUserState(ServerUser *uSource, MumbleProto::UserState &msg) {
msg.set_session(pDstServerUser->uiSession);
msg.set_actor(uSource->uiSession);

if (msg.has_name()) {
PERM_DENIED_TYPE(UserName);
return;
}

if (msg.has_channel_id()) {
Channel *c = qhChannels.value(msg.channel_id());
if (!c || (c == pDstServerUser->cChannel))
@@ -1477,6 +1482,19 @@ void Server::msgUserList(ServerUser *uSource, MumbleProto::UserList &msg) {
QMap<int, QString> info;
info.insert(ServerDB::User_Name, name);
setInfo(id, info);

MumbleProto::UserState mpus;
foreach(ServerUser *u, qhUsers) {
if (u->iId == id) {
u->qsName = name;
mpus.set_session(u->uiSession);
break;
}
}
if (mpus.has_session()) {
mpus.set_name(u8(name));
sendAll(mpus);
}
} else {
MumbleProto::PermissionDenied mppd;
mppd.set_type(MumbleProto::PermissionDenied_DenyType_UserName);

0 comments on commit 02ddd91

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