Add links to the log window

This commit is contained in:
Benjamin Jemlich 2009-12-21 16:45:59 +01:00
parent 06f3542ac4
commit 902fe5841c
7 changed files with 218 additions and 79 deletions

View File

@ -52,6 +52,30 @@ ClientUser *ClientUser::get(unsigned int uiSession) {
return p;
}
ClientUser *ClientUser::getByHash(QString _qsHash) {
QReadLocker lock(&c_qrwlUsers);
ClientUser *cu;
foreach (cu, c_qmUsers) {
if (cu->qsHash == _qsHash)
return cu;
}
return NULL;
}
unsigned int ClientUser::getUiSession(ClientUser *cu) {
QReadLocker lock(&c_qrwlUsers);
return c_qmUsers.key(cu);
}
bool ClientUser::isValid(unsigned int uiSession) {
QReadLocker lock(&c_qrwlUsers);
return c_qmUsers.contains(uiSession);
}
ClientUser *ClientUser::add(unsigned int uiSession, QObject *po) {
QWriteLocker lock(&c_qrwlUsers);

View File

@ -66,6 +66,9 @@ class ClientUser : public QObject, public User {
static QHash<unsigned int, ClientUser *> c_qmUsers;
static QReadWriteLock c_qrwlUsers;
static ClientUser *get(unsigned int);
static ClientUser *getByHash(QString _qsHash);
static unsigned int getUiSession(ClientUser *cu);
static bool isValid(unsigned int);
static ClientUser *add(unsigned int, QObject *p = NULL);
static ClientUser *match(const ClientUser *p, bool matchname = false);
static void remove(unsigned int);

View File

@ -32,6 +32,8 @@
#include "Log.h"
#include "TextToSpeech.h"
#include "MainWindow.h"
#include "Channel.h"
#include "ServerHandler.h"
#include "Global.h"
#ifdef Q_OS_MAC
@ -241,9 +243,6 @@ QString Log::msgName(MsgType t) const {
const char *Log::colorClasses[] = {
"time",
"server",
"channel",
"source",
"target",
"privilege"
};
@ -253,6 +252,29 @@ QString Log::msgColor(const QString &text, LogColorType t) {
return QString::fromLatin1("<span class='log-%1'>%2</span>").arg(QString::fromLatin1(colorClasses[t])).arg(text);
}
QString Log::formatChannel(::Channel *c) {
return QString::fromLatin1("<a href='channelid://%1/%3' class='log-channel'>\"%2\"</a>").arg(c->iId).arg(c->qsName).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
}
QString Log::formatClientUser(ClientUser *cu, LogColorType t) {
QString className;
if (t == Log::Target) {
className = QString::fromLatin1("-target");
} else if (t == Log::Source) {
className = QString::fromLatin1("-source");
}
if (cu) {
if (cu->qsHash.isEmpty()) {
return QString::fromLatin1("<a href='clientid://%2/%4' class='log-u6ser%1'>*%3*</a>").arg(className).arg(cu->uiSession).arg(cu->qsName).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
} else {
return QString::fromLatin1("<a href='clientid://%2' class='log-user%1'>*%3*</a>").arg(className).arg(cu->qsHash).arg(cu->qsName);
}
} else {
return QString::fromLatin1("<span class='log-server%1'>%2</span>").arg(className).arg(tr("the server"));
}
}
void Log::setIgnore(MsgType t, int ignore) {
qmIgnore.insert(t, ignore);
}
@ -330,6 +352,8 @@ QString Log::validHtml(const QString &html, bool allowReplacement) {
qslValid << QLatin1String("http");
qslValid << QLatin1String("https");
qslValid << QLatin1String("ftp");
qslValid << QLatin1String("clientid");
qslValid << QLatin1String("channelid");
QRectF qr = dw.availableGeometry(dw.screenNumber(g.mw));
qtd.setTextWidth(qr.width() / 2);

View File

@ -60,6 +60,9 @@ class LogConfig : public ConfigWidget, public Ui::LogConfig {
void browseForAudioFile();
};
class ClientUser;
class Channel;
class Log : public QObject {
friend class LogConfig;
private:
@ -67,7 +70,7 @@ class Log : public QObject {
Q_DISABLE_COPY(Log)
public:
enum MsgType { DebugInfo, CriticalError, Warning, Information, ServerConnected, ServerDisconnected, UserJoin, UserLeave, YouKicked, UserKicked, SelfMute, OtherSelfMute, YouMuted, YouMutedOther, OtherMutedOther, ChannelJoin, ChannelLeave, PermissionDenied, TextMessage };
enum LogColorType { Time, Server, Channel, Source, Target, Privilege };
enum LogColorType { Time, Server, Privilege, Source, Target };
static const MsgType firstMsgType = DebugInfo;
static const MsgType lastMsgType = TextMessage;
protected:
@ -86,6 +89,8 @@ 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 = Log::Time);
static QString formatChannel(::Channel *c);
public slots:
void log(MsgType t, const QString &console, const QString &terse=QString());
};

View File

@ -142,6 +142,9 @@ MainWindow::MainWindow(QWidget *p) : QMainWindow(p) {
tokenEdit = NULL;
bNoHide = false;
cmUid = -1;
cmCid = -1;
qtReconnect = new QTimer(this);
qtReconnect->setInterval(10000);
qtReconnect->setSingleShot(true);
@ -385,7 +388,69 @@ void MainWindow::updateTrayIcon() {
}
}
Channel *MainWindow::getContextMenuChannel() {
if (cmCid >= 0)
return Channel::get(cmCid);
return pmModel->getChannel(qtvUsers->currentIndex());
}
ClientUser *MainWindow::getContextMenuUser() {
if (cmUid >= 0)
return ClientUser::get(cmUid);
return pmModel->getUser(qtvUsers->currentIndex());
}
bool MainWindow::handleSpecialContextMenu(const QUrl &url, const QPoint &_pos, bool focus) {
if (url.scheme() == QString::fromLatin1("clientid")) {
bool ok = false;
QString x(url.host());
if (x.length() == 40) {
ClientUser *cu = ClientUser::getByHash(x);
if (cu) {
cmUid = ClientUser::getUiSession(cu);
ok = true;
}
} else {
QByteArray qbaServerDigest = QByteArray::fromBase64(url.path().remove(0, 1).toLatin1());
cmUid = url.host().toInt(&ok, 10);
ok = ok && (qbaServerDigest == g.sh->qbaDigest);
}
if (ok && ClientUser::isValid(cmUid)) {
if (focus)
qtvUsers->setCurrentIndex(pmModel->index(ClientUser::get(cmUid)));
else
qmUser->exec(_pos, NULL);
}
cmUid = -1;
} else if (url.scheme() == QString::fromLatin1("channelid")) {
bool ok;
QByteArray qbaServerDigest = QByteArray::fromBase64(url.path().remove(0, 1).toLatin1());
cmCid = url.host().toInt(&ok, 10);
ok = ok && (qbaServerDigest == g.sh->qbaDigest);
if (ok) {
if (focus)
qtvUsers->setCurrentIndex(pmModel->index(Channel::get(cmCid)));
else
qmChannel->exec(_pos, NULL);
}
cmCid = -1;
} else {
return false;
}
return true;
}
void MainWindow::on_qteLog_customContextMenuRequested(const QPoint &mpos) {
QString link = qteLog->anchorAt(mpos);
if (! link.isEmpty()) {
QUrl l(link);
if (handleSpecialContextMenu(l, qteLog->mapToGlobal(mpos)))
return;
}
#if QT_VERSION >= 0x040400
QMenu *menu = qteLog->createStandardContextMenu(mpos);
#else
@ -815,7 +880,8 @@ void MainWindow::on_qaServerTokens_triggered() {
}
void MainWindow::on_qmUser_aboutToShow() {
ClientUser *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
bool self = p && (p->uiSession == g.uiSession);
qmUser->clear();
@ -898,7 +964,7 @@ void MainWindow::on_qmUser_aboutToShow() {
}
void MainWindow::on_qaUserMute_triggered() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -916,7 +982,7 @@ void MainWindow::on_qaUserMute_triggered() {
}
void MainWindow::on_qaUserLocalMute_triggered() {
ClientUser *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -928,7 +994,7 @@ void MainWindow::on_qaUserLocalMute_triggered() {
}
void MainWindow::on_qaUserDeaf_triggered() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -939,7 +1005,7 @@ void MainWindow::on_qaUserDeaf_triggered() {
}
void MainWindow::on_qaUserRegister_triggered() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -964,7 +1030,7 @@ void MainWindow::on_qaUserRegister_triggered() {
}
void MainWindow::on_qaUserFriendAdd_triggered() {
ClientUser *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -977,7 +1043,7 @@ void MainWindow::on_qaUserFriendUpdate_triggered() {
}
void MainWindow::on_qaUserFriendRemove_triggered() {
ClientUser *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -986,7 +1052,7 @@ void MainWindow::on_qaUserFriendRemove_triggered() {
}
void MainWindow::on_qaUserKick_triggered() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -1008,7 +1074,7 @@ void MainWindow::on_qaUserKick_triggered() {
}
void MainWindow::on_qaUserBan_triggered() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -1030,7 +1096,7 @@ void MainWindow::on_qaUserBan_triggered() {
}
void MainWindow::on_qaUserTextMessage_triggered() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -1057,7 +1123,7 @@ void MainWindow::on_qaUserTextMessage_triggered() {
}
void MainWindow::on_qaUserComment_triggered() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -1081,7 +1147,7 @@ void MainWindow::on_qaUserComment_triggered() {
}
void MainWindow::on_qaUserCommentReset_triggered() {
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = getContextMenuUser();
if (!p)
return;
@ -1107,7 +1173,7 @@ void MainWindow::on_qaQuit_triggered() {
void MainWindow::on_qleChat_returnPressed() {
if (qleChat->text().isEmpty() || g.uiSession == 0) return; // Check if text & connection is available
User *p = pmModel->getUser(qtvUsers->currentIndex());
ClientUser *p = pmModel->getUser(qtvUsers->currentIndex());
Channel *c = pmModel->getChannel(qtvUsers->currentIndex());
MumbleProto::TextMessage mptm;
@ -1126,11 +1192,11 @@ void MainWindow::on_qleChat_returnPressed() {
c = ClientUser::get(g.uiSession)->cChannel;
mptm.add_channel_id(c->iId);
g.l->log(Log::TextMessage, tr("To channel %1: %2").arg(Log::msgColor(c->qsName, Log::Channel)).arg(qsText), tr("Message to channel %1").arg(c->qsName));
g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c)).arg(qsText), tr("Message to channel %1").arg(c->qsName));
} else {
// User message
mptm.add_session(p->uiSession);
g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::msgColor(p->qsName, Log::Target)).arg(qsText), tr("Message to %1").arg(p->qsName));
g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatClientUser(p, Log::Target)).arg(qsText), tr("Message to %1").arg(p->qsName));
}
g.sh->sendMessage(mptm);
@ -1161,8 +1227,6 @@ void MainWindow::on_qmConfig_aboutToShow() {
}
void MainWindow::on_qmChannel_aboutToShow() {
QModelIndex idx = qtvUsers->currentIndex();
qmChannel->clear();
qmChannel->addAction(qaChannelAdd);
qmChannel->addAction(qaChannelACL);
@ -1198,7 +1262,7 @@ void MainWindow::on_qmChannel_aboutToShow() {
msg = true;
descUpdate = true;
Channel *c = pmModel->getChannel(idx);
Channel *c = getContextMenuChannel();
Channel *home = ClientUser::get(g.uiSession)->cChannel;
if (c && c->bTemporary)
@ -1230,7 +1294,7 @@ void MainWindow::on_qmChannel_aboutToShow() {
}
void MainWindow::on_qaChannelAdd_triggered() {
Channel *c = pmModel->getChannel(qtvUsers->currentIndex());
Channel *c = getContextMenuChannel();
if (aclEdit) {
aclEdit->reject();
delete aclEdit;
@ -1248,7 +1312,7 @@ void MainWindow::on_qaChannelAdd_triggered() {
void MainWindow::on_qaChannelRemove_triggered() {
int ret;
Channel *c = pmModel->getChannel(qtvUsers->currentIndex());
Channel *c = getContextMenuChannel();
if (! c)
return;
@ -1268,7 +1332,7 @@ void MainWindow::on_qaChannelRemove_triggered() {
}
void MainWindow::on_qaChannelACL_triggered() {
Channel *c = pmModel->getChannel(qtvUsers->currentIndex());
Channel *c = getContextMenuChannel();
int id = c ? c->iId : 0;
MumbleProto::ACL mpacl;
@ -1286,7 +1350,7 @@ void MainWindow::on_qaChannelACL_triggered() {
void MainWindow::on_qaChannelLink_triggered() {
Channel *c = ClientUser::get(g.uiSession)->cChannel;
Channel *l = pmModel->getChannel(qtvUsers->currentIndex());
Channel *l = getContextMenuChannel();
if (! l)
l = Channel::get(0);
@ -1298,7 +1362,7 @@ void MainWindow::on_qaChannelLink_triggered() {
void MainWindow::on_qaChannelUnlink_triggered() {
Channel *c = ClientUser::get(g.uiSession)->cChannel;
Channel *l = pmModel->getChannel(qtvUsers->currentIndex());
Channel *l = getContextMenuChannel();
if (! l)
l = Channel::get(0);
@ -1319,7 +1383,7 @@ void MainWindow::on_qaChannelUnlinkAll_triggered() {
}
void MainWindow::on_qaChannelSendMessage_triggered() {
Channel *c = pmModel->getChannel(qtvUsers->currentIndex());
Channel *c = getContextMenuChannel();
if (!c)
return;
@ -1341,15 +1405,16 @@ void MainWindow::on_qaChannelSendMessage_triggered() {
g.sh->sendMessage(mptm);
if (texm->bTreeMessage)
g.l->log(Log::TextMessage, tr("To tree %1: %2").arg(Log::msgColor(c->qsName, Log::Channel)).arg(texm->message()), tr("Message to tree %1").arg(c->qsName));
g.l->log(Log::TextMessage, tr("(Tree) %1: %2").arg(Log::formatChannel(c)).arg(texm->message()), tr("Message to tree %1").arg(c->qsName));
else
g.l->log(Log::TextMessage, tr("To channel %1: %2").arg(Log::msgColor(c->qsName, Log::Channel)).arg(texm->message()), tr("Message to channel %1").arg(c->qsName));
g.l->log(Log::TextMessage, tr("%1: %2").arg(Log::formatChannel(c)).arg(texm->message()), tr("Message to channel %1").arg(c->qsName));
}
delete texm;
}
void MainWindow::updateMenuPermissions() {
Channel *c = g.uiSession ? pmModel->getChannel(qtvUsers->currentIndex()) : NULL;
ClientUser *cu = getContextMenuUser();
Channel *c = g.uiSession ? (cu ? cu->cChannel : getContextMenuChannel()) : NULL;
ChanACL::Permissions p = static_cast<ChanACL::Permissions>(c ? c->uiPermissions : ChanACL::None);
if (c && ! p) {
@ -2088,11 +2153,20 @@ void MainWindow::customEvent(QEvent *evt) {
#undef MUMBLE_MH_MSG
}
void MainWindow::on_qteLog_anchorClicked(const QUrl &url) {
QDesktopServices::openUrl(url);
if (!handleSpecialContextMenu(url, QCursor::pos(), true)) {
if (url.scheme() != QLatin1String("file")
&& url.scheme() != QLatin1String("qrc")
&& !url.isRelative())
QDesktopServices::openUrl(url);
}
}
void MainWindow::on_qteLog_highlighted(const QUrl &url) {
if (url.scheme() == QString::fromLatin1("clientid") || url.scheme() == QString::fromLatin1("channelid"))
return;
if (! url.isValid())
QToolTip::hideText();
else

View File

@ -128,6 +128,14 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
bool bNoHide;
virtual void closeEvent(QCloseEvent *e);
virtual void hideEvent(QHideEvent *e);
private:
qint32 cmUid;
qint32 cmCid;
bool handleSpecialContextMenu(const QUrl &url, const QPoint &_pos, bool focus = false);
Channel* getContextMenuChannel();
ClientUser* getContextMenuUser();
public slots:
void on_qmServer_aboutToShow();
void on_qaServerConnect_triggered();

View File

@ -133,9 +133,9 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) {
return;
QString pname = ChanACL::permName(static_cast<ChanACL::Permissions>(msg.permission()));
if (pDst == pSelf)
g.l->log(Log::PermissionDenied, tr("You were denied %1 privileges in %2.").arg(Log::msgColor(pname, Log::Privilege)).arg(Log::msgColor(c->qsName, Log::Channel)));
g.l->log(Log::PermissionDenied, tr("You were denied %1 privileges in %2.").arg(Log::msgColor(pname, Log::Privilege)).arg(Log::formatChannel(c)));
else
g.l->log(Log::PermissionDenied, tr("%3 was denied %1 privileges in %2.").arg(Log::msgColor(pname, Log::Privilege)).arg(Log::msgColor(c->qsName, Log::Channel)).arg(Log::msgColor(pDst->qsName, Log::Target)));
g.l->log(Log::PermissionDenied, tr("%3 was denied %1 privileges in %2.").arg(Log::msgColor(pname, Log::Privilege)).arg(Log::formatChannel(c)).arg(Log::formatClientUser(pDst, Log::Target)));
}
break;
case MumbleProto::PermissionDenied_DenyType_SuperUser: {
@ -176,7 +176,7 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) {
if (pDst == pSelf)
g.l->log(Log::PermissionDenied, tr("You need a certificate to perform this operation."));
else
g.l->log(Log::PermissionDenied, tr("%1 does not have a certificate.").arg(Log::msgColor(pDst->qsName, Log::Target)));
g.l->log(Log::PermissionDenied, tr("%1 does not have a certificate.").arg(Log::formatClientUser(pDst)));
}
break;
default:
@ -200,7 +200,7 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (! pDst) {
if (msg.has_name()) {
pDst = pmModel->addUser(msg.session(), u8(msg.name()));
g.l->log(Log::UserJoin, tr("Joined server: %1.").arg(Log::msgColor(pDst->qsName, Log::Target)));
g.l->log(Log::UserJoin, tr("Joined server: %1.").arg(Log::formatClientUser(pDst, Log::Source)));
if (! msg.has_texture())
g.o->verifyTexture(pDst);
} else {
@ -229,11 +229,11 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (pSelf && pDst != pSelf && (pDst->cChannel == pSelf->cChannel)) {
QString name = pDst->qsName;
if (pDst->bSelfMute && pDst->bSelfDeaf)
g.l->log(Log::OtherSelfMute, tr("%1 is now muted and deafened.").arg(Log::msgColor(name, Log::Target)));
g.l->log(Log::OtherSelfMute, tr("%1 is now muted and deafened.").arg(Log::formatClientUser(pDst, Log::Target)));
else if (pDst->bSelfMute)
g.l->log(Log::OtherSelfMute, tr("%1 is now muted.").arg(Log::msgColor(name, Log::Target)));
g.l->log(Log::OtherSelfMute, tr("%1 is now muted.").arg(Log::formatClientUser(pDst, Log::Target)));
else
g.l->log(Log::OtherSelfMute, tr("%1 is now unmuted.").arg(Log::msgColor(name, Log::Target)));
g.l->log(Log::OtherSelfMute, tr("%1 is now unmuted.").arg(Log::formatClientUser(pDst, Log::Target)));
}
}
@ -246,85 +246,82 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
pDst->setSuppress(msg.suppress());
if (pSelf && ((pDst->cChannel == pSelf->cChannel) || (pSrc == pSelf))) {
QString vic = pDst->qsName;
QString admin = pSrc ? pSrc->qsName : tr("the server");
if (pDst == pSelf) {
if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) {
g.l->log(Log::YouMuted, tr("You were muted and deafened by %1.").arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::YouMuted, tr("You were muted and deafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
} else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) {
g.l->log(Log::YouMuted, tr("You were unmuted and undeafened by %1.").arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::YouMuted, tr("You were unmuted and undeafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
} else {
if (msg.has_mute()) {
if (pDst->bMute)
g.l->log(Log::YouMuted, tr("You were muted by %1.").arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::YouMuted, tr("You were muted by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
else
g.l->log(Log::YouMuted, tr("You were unmuted by %1.").arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::YouMuted, tr("You were unmuted by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
}
if (msg.has_deaf()) {
if (!pDst->bDeaf)
g.l->log(Log::YouMuted, tr("You were undeafened by %1.").arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::YouMuted, tr("You were undeafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
}
}
if (msg.has_suppress()) {
if (pDst->bSuppress)
g.l->log(Log::YouMuted, tr("You were suppressed by %1.").arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::YouMuted, tr("You were suppressed by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
else
g.l->log(Log::YouMuted, tr("You were unsuppressed by %1.").arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::YouMuted, tr("You were unsuppressed by %1.").arg(Log::formatClientUser(pSrc, Log::Source)));
}
updateTrayIcon();
} else if (pSrc == pSelf) {
if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) {
g.l->log(Log::YouMutedOther, tr("You muted and deafened %1.").arg(Log::msgColor(vic, Log::Target)));
g.l->log(Log::YouMutedOther, tr("You muted and deafened %1.").arg(Log::formatClientUser(pDst, Log::Target)));
} else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) {
g.l->log(Log::YouMutedOther, tr("You unmuted and undeafened %1.").arg(Log::msgColor(vic, Log::Target)));
g.l->log(Log::YouMutedOther, tr("You unmuted and undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target)));
} else {
if (msg.has_mute()) {
if (pDst->bMute)
g.l->log(Log::YouMutedOther, tr("You muted %1.").arg(Log::msgColor(vic, Log::Target)));
g.l->log(Log::YouMutedOther, tr("You muted %1.").arg(Log::formatClientUser(pDst, Log::Target)));
else
g.l->log(Log::YouMutedOther, tr("You unmuted %1.").arg(Log::msgColor(vic, Log::Target)));
g.l->log(Log::YouMutedOther, tr("You unmuted %1.").arg(Log::formatClientUser(pDst, Log::Target)));
}
if (msg.has_deaf()) {
if (!pDst->bDeaf)
g.l->log(Log::YouMutedOther, tr("You undeafened %1.").arg(Log::msgColor(vic, Log::Target)));
g.l->log(Log::YouMutedOther, tr("You undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target)));
}
}
if (msg.has_suppress()) {
if (pDst->bSuppress)
g.l->log(Log::YouMutedOther, tr("You suppressed %1.").arg(Log::msgColor(vic, Log::Target)));
g.l->log(Log::YouMutedOther, tr("You suppressed %1.").arg(Log::formatClientUser(pDst, Log::Target)));
else
g.l->log(Log::YouMutedOther, tr("You unsuppressed %1.").arg(Log::msgColor(vic, Log::Target)));
g.l->log(Log::YouMutedOther, tr("You unsuppressed %1.").arg(Log::formatClientUser(pDst, Log::Target)));
}
} else {
if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) {
g.l->log(Log::OtherMutedOther, tr("%1 muted and deafened by %2.").arg(Log::msgColor(vic, Log::Target), Log::msgColor(admin, Log::Source)));
g.l->log(Log::OtherMutedOther, tr("%1 muted and deafened by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source)));
} else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) {
g.l->log(Log::OtherMutedOther, tr("%1 unmuted and undeafened by %2.").arg(Log::msgColor(vic, Log::Target), Log::msgColor(admin, Log::Source)));
g.l->log(Log::OtherMutedOther, tr("%1 unmuted and undeafened by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc)));
} else {
if (msg.has_mute()) {
if (pDst->bMute)
g.l->log(Log::OtherMutedOther, tr("%1 muted by %2.").arg(Log::msgColor(vic, Log::Target), Log::msgColor(admin, Log::Source)));
g.l->log(Log::OtherMutedOther, tr("%1 muted by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source)));
else
g.l->log(Log::OtherMutedOther, tr("%1 unmuted by %2.").arg(Log::msgColor(vic, Log::Target), Log::msgColor(admin, Log::Source)));
g.l->log(Log::OtherMutedOther, tr("%1 unmuted by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source)));
}
if (msg.has_deaf()) {
if (!pDst->bDeaf)
g.l->log(Log::OtherMutedOther, tr("%1 undeafened by %2.").arg(Log::msgColor(vic, Log::Target), Log::msgColor(admin, Log::Source)));
g.l->log(Log::OtherMutedOther, tr("%1 undeafened by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source)));
}
}
if (msg.has_suppress()) {
if (pDst->bSuppress)
g.l->log(Log::OtherMutedOther, tr("%1 suppressed by %2.").arg(Log::msgColor(vic, Log::Target), Log::msgColor(admin, Log::Source)));
g.l->log(Log::OtherMutedOther, tr("%1 suppressed by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source)));
else
g.l->log(Log::OtherMutedOther, tr("%1 unsuppressed by %2.").arg(Log::msgColor(vic, Log::Target), Log::msgColor(admin, Log::Source)));
g.l->log(Log::OtherMutedOther, tr("%1 unsuppressed by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source)));
}
}
}
@ -341,17 +338,14 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (c != old) {
bool log = pSelf && !((pDst == pSelf) && (pSrc == pSelf));
QString pname = pDst->qsName;
QString admin = pSrc ? pSrc->qsName : tr("the server");
if (log) {
if (pDst == pSelf) {
g.l->log(Log::ChannelJoin, tr("You were moved to %1 by %2.").arg(Log::msgColor(c->qsName, Log::Channel)).arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::ChannelJoin, tr("You were moved to %1 by %2.").arg(Log::formatChannel(c)).arg(Log::formatClientUser(pSrc, Log::Source)));
} else if (pDst->cChannel == ClientUser::get(g.uiSession)->cChannel) {
if (pDst == pSrc)
g.l->log(Log::ChannelLeave, tr("%1 moved to %2.").arg(Log::msgColor(pname, Log::Target)).arg(Log::msgColor(c->qsName, Log::Channel)));
g.l->log(Log::ChannelLeave, tr("%1 moved to %2.").arg(Log::formatClientUser(pDst, Log::Target)).arg(Log::formatChannel(c)));
else
g.l->log(Log::ChannelLeave, tr("%1 moved to %2 by %3.").arg(Log::msgColor(pname, Log::Target)).arg(Log::msgColor(c->qsName, Log::Channel)).arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::ChannelLeave, tr("%1 moved to %2 by %3.").arg(Log::formatClientUser(pDst, Log::Target)).arg(Log::formatChannel(c)).arg(Log::formatClientUser(pSrc, Log::Source)));
}
}
@ -359,9 +353,9 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (log && (pDst != pSelf) && (pDst->cChannel == pSelf->cChannel)) {
if (pDst == pSrc)
g.l->log(Log::ChannelJoin, tr("%1 entered channel.").arg(Log::msgColor(pname, Log::Target)));
g.l->log(Log::ChannelJoin, tr("%1 entered channel.").arg(Log::formatClientUser(pDst, Log::Target)));
else
g.l->log(Log::ChannelJoin, tr("%1 moved in from %2 by %3.").arg(Log::msgColor(pname, Log::Target)).arg(Log::msgColor(old->qsName, Log::Channel)).arg(Log::msgColor(admin, Log::Source)));
g.l->log(Log::ChannelJoin, tr("%1 moved in from %2 by %3.").arg(Log::formatClientUser(pDst, Log::Target)).arg(Log::formatChannel(old)).arg(Log::formatClientUser(pSrc, Log::Source)));
}
}
}
@ -382,21 +376,20 @@ void MainWindow::msgUserRemove(const MumbleProto::UserRemove &msg) {
ACTOR_INIT;
SELF_INIT;
QString admin = pSrc ? pSrc->qsName : tr("the server");
QString reason = u8(msg.reason());
if (pDst == pSelf) {
if (msg.ban())
g.l->log(Log::YouKicked, tr("You were kicked and banned from the server by %1: %2.").arg(Log::msgColor(admin, Log::Source)).arg(reason));
g.l->log(Log::YouKicked, tr("You were kicked and banned from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason));
else
g.l->log(Log::YouKicked, tr("You were kicked from the server by %1: %2.").arg(Log::msgColor(admin, Log::Source)).arg(reason));
g.l->log(Log::YouKicked, tr("You were kicked from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason));
} else if (pSrc) {
if (msg.ban())
g.l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked, tr("%3 was kicked and banned from the server by %1: %2.").arg(Log::msgColor(admin, Log::Source)).arg(reason).arg(Log::msgColor(pDst->qsName, Log::Target)));
g.l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked, tr("%3 was kicked and banned from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason).arg(Log::formatClientUser(pDst, Log::Target)));
else
g.l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked, tr("%3 was kicked from the server by %1: %2.").arg(Log::msgColor(admin, Log::Source)).arg(reason).arg(Log::msgColor(pDst->qsName, Log::Target)));
g.l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked, tr("%3 was kicked from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason).arg(Log::formatClientUser(pDst, Log::Target)));
} else {
g.l->log(Log::UserLeave, tr("Left server: %1.").arg(Log::msgColor(pDst->qsName, Log::Target)));
g.l->log(Log::UserLeave, tr("Left server: %1.").arg(Log::formatClientUser(pDst, Log::Source)));
}
if (pDst != pSelf)
pmModel->removeUser(pDst);
@ -480,8 +473,16 @@ void MainWindow::msgChannelRemove(const MumbleProto::ChannelRemove &msg) {
void MainWindow::msgTextMessage(const MumbleProto::TextMessage &msg) {
ACTOR_INIT;
const QString &name = pSrc ? pSrc->qsName : tr("the server", "message from");
g.l->log(Log::TextMessage, tr("From %1: %2").arg(Log::msgColor(name, Log::Source)).arg(u8(msg.message())),
QString target;
const QString &name = pSrc ? Log::formatClientUser(pSrc) : tr("Server", "message from");
if (msg.tree_id_size() > 0) {
target += tr("(Tree) ");
} else if (msg.channel_id_size() > 0) {
target += tr("(Channel) ");
}
g.l->log(Log::TextMessage, tr("%2%1: %3").arg(name).arg(target).arg(u8(msg.message())),
tr("Message from %1").arg(name));
}