Client compiles again

git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@665 05730e5d-ab1b-0410-a4ac-84af385074fa
This commit is contained in:
Thorvald Natvig 2007-07-31 16:31:30 +00:00
parent 6d6bcff7c7
commit 11d9b70e56
12 changed files with 396 additions and 317 deletions

View File

@ -38,7 +38,7 @@
typedef QPair<QString,QVariant> audioDevice;
class LoopPlayer : public Player {
class LoopPlayer : public ClientPlayer {
protected:
typedef QPair<quint32, QByteArray> Packet;
QMutex qmLock;

View File

@ -174,7 +174,7 @@ int AudioInput::getMaxBandwidth() {
void AudioInput::encodeAudioFrame() {
int iArg;
float fArg;
Player *p=Player::get(g.uiSession);
ClientPlayer *p=ClientPlayer::get(g.uiSession);
short max;
double micMax;
int i;

View File

@ -92,7 +92,7 @@ AudioOutputPlayer::AudioOutputPlayer(const QString name) : qsName(name) {
fPos[0]=fPos[1]=fPos[2]=0.0;
}
AudioOutputSpeech::AudioOutputSpeech(Player *player) : AudioOutputPlayer(player->qsName) {
AudioOutputSpeech::AudioOutputSpeech(ClientPlayer *player) : AudioOutputPlayer(player->qsName) {
p = player;
dsDecState=speex_decoder_init(&speex_wb_mode);
@ -236,7 +236,7 @@ void AudioOutput::newPlayer(AudioOutputPlayer *) {
}
void AudioOutput::wipe() {
foreach(const Player *p, qmOutputs.keys())
foreach(const ClientPlayer *p, qmOutputs.keys())
removeBuffer(p);
}
@ -248,7 +248,7 @@ void AudioOutput::playSine(float hz, float i, unsigned int frames) {
qrwlOutputs.unlock();
}
void AudioOutput::addFrameToBuffer(Player *player, const QByteArray &qbaPacket, int iSeq) {
void AudioOutput::addFrameToBuffer(ClientPlayer *player, const QByteArray &qbaPacket, int iSeq) {
qrwlOutputs.lockForRead();
AudioOutputSpeech *aop = dynamic_cast<AudioOutputSpeech *>(qmOutputs.value(player));
if (! aop) {
@ -264,13 +264,13 @@ void AudioOutput::addFrameToBuffer(Player *player, const QByteArray &qbaPacket,
qrwlOutputs.unlock();
}
void AudioOutput::removeBuffer(const Player *player) {
void AudioOutput::removeBuffer(const ClientPlayer *player) {
removeBuffer(qmOutputs.value(player));
}
void AudioOutput::removeBuffer(AudioOutputPlayer *aop) {
QWriteLocker locker(&qrwlOutputs);
QMultiHash<const Player *, AudioOutputPlayer *>::iterator i=qmOutputs.begin();
QMultiHash<const ClientPlayer *, AudioOutputPlayer *>::iterator i=qmOutputs.begin();
while (i != qmOutputs.end()) {
if (i.value() == aop) {
qmOutputs.erase(i);

View File

@ -40,7 +40,7 @@
#include "Audio.h"
class AudioOutput;
class Player;
class ClientPlayer;
typedef boost::shared_ptr<AudioOutput> AudioOutputPtr;
@ -91,12 +91,12 @@ class AudioOutputSpeech : public AudioOutputPlayer {
static int speexCallback(SpeexBits *bits, void *state, void *data);
public:
int iMissedFrames;
Player *p;
ClientPlayer *p;
virtual bool decodeNextFrame();
void addFrameToBuffer(const QByteArray &, int iBaseSeq);
AudioOutputSpeech(Player * = NULL);
AudioOutputSpeech(ClientPlayer * = NULL);
~AudioOutputSpeech();
};
@ -120,7 +120,7 @@ class AudioOutput : public QThread {
bool bRunning;
int iFrameSize;
QReadWriteLock qrwlOutputs;
QMultiHash<const Player *, AudioOutputPlayer *> qmOutputs;
QMultiHash<const ClientPlayer *, AudioOutputPlayer *> qmOutputs;
virtual void newPlayer(AudioOutputPlayer *);
virtual void removeBuffer(AudioOutputPlayer *);
bool mixAudio(short *output);
@ -129,8 +129,8 @@ class AudioOutput : public QThread {
AudioOutput();
~AudioOutput();
void addFrameToBuffer(Player *, const QByteArray &, int iSeq);
void removeBuffer(const Player *);
void addFrameToBuffer(ClientPlayer *, const QByteArray &, int iSeq);
void removeBuffer(const ClientPlayer *);
void playSine(float hz, float i = 0.0, unsigned int frames = 0xffffff);
void run() = 0;
};

View File

@ -540,7 +540,7 @@ void MainWindow::on_PlayerMute_triggered() {
}
void MainWindow::on_PlayerLocalMute_triggered() {
Player *p = pmModel->getPlayer(qtvPlayers->currentIndex());
ClientPlayer *p = pmModel->getPlayer(qtvPlayers->currentIndex());
if (!p)
return;
@ -568,7 +568,7 @@ void MainWindow::on_PlayerKick_triggered() {
bool ok;
QString reason = QInputDialog::getText(this, tr("Kicking player %1").arg(p->qsName), tr("Enter reason"), QLineEdit::Normal, QString(), &ok);
p = Player::get(session);
p = ClientPlayer::get(session);
if (!p)
return;
@ -589,7 +589,7 @@ void MainWindow::on_PlayerBan_triggered() {
bool ok;
QString reason = QInputDialog::getText(this, tr("Banning player %1").arg(p->qsName), tr("Enter reason"), QLineEdit::Normal, QString(), &ok);
p = Player::get(session);
p = ClientPlayer::get(session);
if (!p)
return;
@ -611,7 +611,7 @@ void MainWindow::on_PlayerTextMessage_triggered() {
bool ok;
QString message = QInputDialog::getText(this, tr("Sending message to %1").arg(p->qsName), tr("Enter message"), QLineEdit::Normal, QString(), &ok);
p = Player::get(session);
p = ClientPlayer::get(session);
if (!p)
return;
@ -640,7 +640,7 @@ void MainWindow::on_ChannelMenu_aboutToShow() {
acl = true;
Channel *c = pmModel->getChannel(idx);
Channel *home = Player::get(g.uiSession)->cChannel;
Channel *home = ClientPlayer::get(g.uiSession)->cChannel;
if (c && c->iId != 0)
remove = true;
@ -721,7 +721,7 @@ void MainWindow::on_ChannelACL_triggered() {
}
void MainWindow::on_ChannelLink_triggered() {
Channel *c = Player::get(g.uiSession)->cChannel;
Channel *c = ClientPlayer::get(g.uiSession)->cChannel;
Channel *l = pmModel->getChannel(qtvPlayers->currentIndex());
if (! l)
l = Channel::get(0);
@ -734,7 +734,7 @@ void MainWindow::on_ChannelLink_triggered() {
}
void MainWindow::on_ChannelUnlink_triggered() {
Channel *c = Player::get(g.uiSession)->cChannel;
Channel *c = ClientPlayer::get(g.uiSession)->cChannel;
Channel *l = pmModel->getChannel(qtvPlayers->currentIndex());
if (! l)
l = Channel::get(0);
@ -747,7 +747,7 @@ void MainWindow::on_ChannelUnlink_triggered() {
}
void MainWindow::on_ChannelUnlinkAll_triggered() {
Channel *c = Player::get(g.uiSession)->cChannel;
Channel *c = ClientPlayer::get(g.uiSession)->cChannel;
MessageChannelLink mcl;
mcl.iId = c->iId;
@ -884,7 +884,7 @@ void MainWindow::pushLink(bool down) {
GlobalShortcut *gs = qobject_cast<GlobalShortcut *>(sender());
int idx = gs->data().toInt();
Channel *home = Player::get(g.uiSession)->cChannel;
Channel *home = ClientPlayer::get(g.uiSession)->cChannel;
Channel *target = NULL;
switch (idx) {
@ -1074,251 +1074,7 @@ void MainWindow::customEvent(QEvent *evt) {
Message *mMsg = Message::networkToMessage(shme->qbaMsg);
if (mMsg) {
mMsg->process(NULL);
dispatch(NULL, mMsg);
delete mMsg;
}
}
void MessageServerJoin::process(Connection *) {
Player *p = g.mw->pmModel->addPlayer(uiSession, qsPlayerName);
p->iId = iId;
g.l->log(Log::PlayerJoin, MainWindow::tr("Joined server: %1.").arg(p->qsName));
}
#define MSG_INIT \
Player *pSrc=Player::get(uiSession); \
Q_UNUSED(pSrc);
#define VICTIM_INIT \
Player *pDst=Player::get(uiVictim); \
if (! pDst) \
qFatal("MainWindow: Message for nonexistant victim %d.", uiVictim);
void MessageServerLeave::process(Connection *) {
MSG_INIT;
g.l->log(Log::PlayerLeave, MainWindow::tr("Left server: %1.").arg(pSrc->qsName));
g.mw->pmModel->removePlayer(pSrc);
}
void MessageServerBanList::process(Connection *) {
MSG_INIT;
if (g.mw->banEdit) {
g.mw->banEdit->reject();
delete g.mw->banEdit;
g.mw->banEdit = NULL;
}
g.mw->banEdit = new BanEditor(this, g.mw);
g.mw->banEdit->show();
}
void MessageSpeex::process(Connection *) {
}
void MessagePlayerSelfMuteDeaf::process(Connection *) {
MSG_INIT;
pSrc->setSelfMuteDeaf(bMute, bDeaf);
if (uiSession == g.uiSession || ! g.uiSession)
return;
if (pSrc->cChannel != Player::get(g.uiSession)->cChannel)
return;
QString name = pSrc->qsName;
if (bMute && bDeaf)
g.l->log(Log::OtherSelfMute, MainWindow::tr("%1 is now muted and deafened.").arg(name));
else if (bMute)
g.l->log(Log::OtherSelfMute, MainWindow::tr("%1 is now muted.").arg(name));
else
g.l->log(Log::OtherSelfMute, MainWindow::tr("%1 is now unmuted.").arg(name));
}
void MessagePlayerMute::process(Connection *) {
MSG_INIT;
VICTIM_INIT;
pDst->setMute(bMute);
if (!g.uiSession || pDst->cChannel != Player::get(g.uiSession)->cChannel)
return;
QString vic = pDst->qsName;
QString admin = pSrc ? pSrc->qsName : MainWindow::tr("server");
if (uiVictim == g.uiSession)
g.l->log(Log::YouMuted, bMute ? MainWindow::tr("You were muted by %1.").arg(admin) : MainWindow::tr("You were unmuted by %1.").arg(admin));
else
g.l->log((uiSession == g.uiSession) ? Log::YouMutedOther : Log::OtherMutedOther, bMute ? MainWindow::tr("%1 muted by %2.").arg(vic).arg(admin) : MainWindow::tr("%1 unmuted by %2.").arg(vic).arg(admin));
}
void MessagePlayerDeaf::process(Connection *) {
MSG_INIT;
VICTIM_INIT;
pDst->setDeaf(bDeaf);
if (!g.uiSession || pDst->cChannel != Player::get(g.uiSession)->cChannel)
return;
QString vic = pDst->qsName;
QString admin = pSrc ? pSrc->qsName : MainWindow::tr("server");
if (uiVictim == g.uiSession)
g.l->log(Log::YouMuted, bDeaf ? MainWindow::tr("You were deafened by %1.").arg(admin) : MainWindow::tr("You were undeafened by %1.").arg(admin));
else
g.l->log((uiSession == g.uiSession) ? Log::YouMutedOther : Log::OtherMutedOther, bDeaf ? MainWindow::tr("%1 deafened by %2.").arg(vic).arg(admin) : MainWindow::tr("%1 undeafened by %2.").arg(vic).arg(admin));
}
void MessagePlayerKick::process(Connection *) {
MSG_INIT;
VICTIM_INIT;
QString admin = pSrc ? pSrc->qsName : QLatin1String("server");
if (uiVictim == g.uiSession) {
g.l->log(Log::YouKicked, MainWindow::tr("You were kicked from the server by %1: %2.").arg(admin).arg(qsReason));
g.l->setIgnore(Log::ServerDisconnected, 1);
} else {
g.l->setIgnore(Log::PlayerLeave, 1);
g.l->log((uiSession == g.uiSession) ? Log::YouKicked : Log::PlayerKicked, MainWindow::tr("%3 was kicked from the server by %1: %2.").arg(admin).arg(qsReason).arg(pDst->qsName));
}
}
void MessagePlayerBan::process(Connection *) {
MSG_INIT;
VICTIM_INIT;
if (uiVictim == g.uiSession) {
g.l->log(Log::YouKicked, MainWindow::tr("You were kicked and banned from the server by %1: %2.").arg(pSrc->qsName).arg(qsReason));
g.l->setIgnore(Log::ServerDisconnected, 1);
} else {
g.l->setIgnore(Log::PlayerLeave, 1);
g.l->log((uiSession == g.uiSession) ? Log::YouKicked : Log::PlayerKicked, MainWindow::tr("%3 was kicked and banned from the server by %1: %2.").arg(pSrc->qsName).arg(qsReason).arg(pDst->qsName));
}
}
void MessagePlayerMove::process(Connection *) {
MSG_INIT;
VICTIM_INIT;
bool log = true;
if ((uiVictim == g.uiSession) && (uiSession == uiVictim))
log = false;
if (g.uiSession == 0)
log = false;
QString pname = pDst->qsName;
QString admin = pSrc ? pSrc->qsName : QLatin1String("server");
if (log && (pDst->cChannel == Player::get(g.uiSession)->cChannel)) {
if (pDst == pSrc || (!pSrc))
g.l->log(Log::ChannelJoin, MainWindow::tr("%1 left channel.").arg(pname));
else
g.l->log(Log::ChannelJoin, MainWindow::tr("%1 moved out by %2.").arg(pname).arg(admin));
}
g.mw->pmModel->movePlayer(pDst, iChannelId);
if (log && (pDst->cChannel == Player::get(g.uiSession)->cChannel)) {
if (pDst == pSrc || (!pSrc))
g.l->log(Log::ChannelLeave, MainWindow::tr("%1 entered channel.").arg(pname));
else
g.l->log(Log::ChannelLeave, MainWindow::tr("%1 moved in by %2.").arg(pname).arg(admin));
}
}
void MessagePlayerRename::process(Connection *) {
MSG_INIT;
g.mw->pmModel->renamePlayer(pSrc, qsName);
}
void MessageChannelAdd::process(Connection *) {
Channel *p = Channel::get(iParent);
if (p)
g.mw->pmModel->addChannel(iId, p, qsName);
}
void MessageChannelRemove::process(Connection *) {
Channel *c = Channel::get(iId);
if (c)
g.mw->pmModel->removeChannel(c);
}
void MessageChannelMove::process(Connection *) {
g.mw->pmModel->moveChannel(Channel::get(iId), iParent);
}
void MessageChannelLink::process(Connection *) {
Channel *c = Channel::get(iId);
QList<Channel *> qlChans;
foreach(int id, qlTargets) {
Channel *l = Channel::get(id);
qlChans << l;
}
switch (ltType) {
case Link:
g.mw->pmModel->linkChannels(c, qlChans);
break;
case Unlink:
g.mw->pmModel->unlinkChannels(c, qlChans);
break;
case UnlinkAll:
g.mw->pmModel->unlinkAll(c);
break;
default:
qFatal("Unknown link message");
}
}
void MessageServerAuthenticate::process(Connection *) {
}
void MessageServerReject::process(Connection *) {
g.mw->rtLast = rtType;
g.l->log(Log::ServerDisconnected, MainWindow::tr("Server connection rejected: %1.").arg(qsReason));
g.l->setIgnore(Log::ServerDisconnected, 1);
}
void MessagePermissionDenied::process(Connection *) {
g.l->log(Log::PermissionDenied, MainWindow::tr("Denied: %1.").arg(qsReason));
}
void MessageServerSync::process(Connection *) {
MSG_INIT;
g.iMaxBandwidth = iMaxBandwidth;
g.uiSession = uiSession;
g.l->clearIgnore();
g.l->log(Log::Information, qsWelcomeText);
g.mw->pmModel->ensureSelfVisible();
}
void MessageTextMessage::process(Connection *) {
MSG_INIT;
g.l->log(Log::TextMessage, MainWindow::tr("From %1: %2").arg(pSrc->qsName).arg(qsMessage),
MainWindow::tr("Message from %1").arg(pSrc->qsName));
}
void MessageEditACL::process(Connection *) {
if (g.mw->aclEdit) {
g.mw->aclEdit->reject();
delete g.mw->aclEdit;
g.mw->aclEdit = NULL;
}
g.mw->aclEdit = new ACLEditor(this, g.mw);
g.mw->aclEdit->show();
}
void MessageQueryUsers::process(Connection *) {
if (g.mw->aclEdit)
g.mw->aclEdit->returnQuery(this);
}
void MessagePing::process(Connection *) {
}
void MessageTexture::process(Connection *) {
if (! qbaTexture.isEmpty())
g.o->textureResponse(iPlayerId,qbaTexture);
}

View File

@ -49,7 +49,7 @@ class MessageBoxEvent : public QEvent {
MessageBoxEvent(QString msg);
};
class MainWindow : public QMainWindow {
class MainWindow : public QMainWindow, public MessageHandler {
friend class PlayerModel;
Q_OBJECT
public:
@ -135,6 +135,32 @@ class MainWindow : public QMainWindow {
void viewCertificate(bool);
public:
MainWindow(QWidget *parent);
// From msgHandler. Implementation in Messages.cpp
virtual void msgSpeex(Connection *, MessageSpeex *);
virtual void msgServerAuthenticate(Connection *, MessageServerAuthenticate *);
virtual void msgPing(Connection *, MessagePing *);
virtual void msgServerReject(Connection *, MessageServerReject *);
virtual void msgServerSync(Connection *, MessageServerSync *);
virtual void msgServerJoin(Connection *, MessageServerJoin *);
virtual void msgServerLeave(Connection *, MessageServerLeave *);
virtual void msgPlayerMute(Connection *, MessagePlayerMute *);
virtual void msgPlayerDeaf(Connection *, MessagePlayerDeaf *);
virtual void msgPlayerSelfMuteDeaf(Connection *, MessagePlayerSelfMuteDeaf *);
virtual void msgPlayerKick(Connection *, MessagePlayerKick *);
virtual void msgPlayerBan(Connection *, MessagePlayerBan *);
virtual void msgPlayerMove(Connection *, MessagePlayerMove *);
virtual void msgPlayerRename(Connection *, MessagePlayerRename *);
virtual void msgChannelAdd(Connection *, MessageChannelAdd *);
virtual void msgChannelRemove(Connection *, MessageChannelRemove *);
virtual void msgChannelMove(Connection *, MessageChannelMove *);
virtual void msgChannelLink(Connection *, MessageChannelLink *);
virtual void msgServerBanList(Connection *, MessageServerBanList *);
virtual void msgTextMessage(Connection *, MessageTextMessage *);
virtual void msgPermissionDenied(Connection *, MessagePermissionDenied *);
virtual void msgEditACL(Connection *, MessageEditACL *);
virtual void msgQueryUsers(Connection *, MessageQueryUsers *);
virtual void msgTexture(Connection *, MessageTexture *);
};
#else

296
src/mumble/Messages.cpp Normal file
View File

@ -0,0 +1,296 @@
/* Copyright (C) 2005-2007, Thorvald Natvig <thorvald@natvig.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of the Mumble Developers nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "MainWindow.h"
#include "AudioWizard.h"
#include "AudioInput.h"
#include "ConnectDialog.h"
#include "Player.h"
#include "Channel.h"
#include "ACLEditor.h"
#include "BanEditor.h"
#include "Connection.h"
#include "ServerHandler.h"
#include "About.h"
#include "GlobalShortcut.h"
#include "VersionCheck.h"
#include "PlayerModel.h"
#include "AudioStats.h"
#include "Plugins.h"
#include "Log.h"
#include "Overlay.h"
#include "Global.h"
#include "Database.h"
#include "ViewCert.h"
void MainWindow::msgServerJoin(Connection *, MessageServerJoin *msg) {
ClientPlayer *p = pmModel->addPlayer(msg->uiSession, msg->qsPlayerName);
p->iId = msg->iId;
g.l->log(Log::PlayerJoin, MainWindow::tr("Joined server: %1.").arg(p->qsName));
}
#define MSG_INIT \
ClientPlayer *pSrc=ClientPlayer::get(msg->uiSession); \
Q_UNUSED(pSrc);
#define VICTIM_INIT \
ClientPlayer *pDst=ClientPlayer::get(msg->uiVictim); \
if (! pDst) \
qFatal("MainWindow: Message for nonexistant victim %d.", msg->uiVictim);
void MainWindow::msgServerLeave(Connection *, MessageServerLeave *msg) {
MSG_INIT;
g.l->log(Log::PlayerLeave, MainWindow::tr("Left server: %1.").arg(pSrc->qsName));
pmModel->removePlayer(pSrc);
}
void MainWindow::msgServerBanList(Connection *, MessageServerBanList *msg) {
MSG_INIT;
if (banEdit) {
banEdit->reject();
delete banEdit;
banEdit = NULL;
}
banEdit = new BanEditor(msg, this);
banEdit->show();
}
void MainWindow::msgSpeex(Connection *, MessageSpeex *) {
}
void MainWindow::msgPlayerSelfMuteDeaf(Connection *, MessagePlayerSelfMuteDeaf *msg) {
MSG_INIT;
pSrc->setSelfMuteDeaf(msg->bMute, msg->bDeaf);
if (msg->uiSession == g.uiSession || ! g.uiSession)
return;
if (pSrc->cChannel != ClientPlayer::get(g.uiSession)->cChannel)
return;
QString name = pSrc->qsName;
if (msg->bMute && msg->bDeaf)
g.l->log(Log::OtherSelfMute, MainWindow::tr("%1 is now muted and deafened.").arg(name));
else if (msg->bMute)
g.l->log(Log::OtherSelfMute, MainWindow::tr("%1 is now muted.").arg(name));
else
g.l->log(Log::OtherSelfMute, MainWindow::tr("%1 is now unmuted.").arg(name));
}
void MainWindow::msgPlayerMute(Connection *, MessagePlayerMute *msg) {
MSG_INIT;
VICTIM_INIT;
pDst->setMute(msg->bMute);
if (!g.uiSession || pDst->cChannel != ClientPlayer::get(g.uiSession)->cChannel)
return;
QString vic = pDst->qsName;
QString admin = pSrc ? pSrc->qsName : MainWindow::tr("server");
if (msg->uiVictim == g.uiSession)
g.l->log(Log::YouMuted, msg->bMute ? MainWindow::tr("You were muted by %1.").arg(admin) : MainWindow::tr("You were unmuted by %1.").arg(admin));
else
g.l->log((msg->uiSession == g.uiSession) ? Log::YouMutedOther : Log::OtherMutedOther, msg->bMute ? MainWindow::tr("%1 muted by %2.").arg(vic).arg(admin) : MainWindow::tr("%1 unmuted by %2.").arg(vic).arg(admin));
}
void MainWindow::msgPlayerDeaf(Connection *, MessagePlayerDeaf *msg) {
MSG_INIT;
VICTIM_INIT;
pDst->setDeaf(msg->bDeaf);
if (!g.uiSession || pDst->cChannel != ClientPlayer::get(g.uiSession)->cChannel)
return;
QString vic = pDst->qsName;
QString admin = pSrc ? pSrc->qsName : MainWindow::tr("server");
if (msg->uiVictim == g.uiSession)
g.l->log(Log::YouMuted, msg->bDeaf ? MainWindow::tr("You were deafened by %1.").arg(admin) : MainWindow::tr("You were undeafened by %1.").arg(admin));
else
g.l->log((msg->uiSession == g.uiSession) ? Log::YouMutedOther : Log::OtherMutedOther, msg->bDeaf ? MainWindow::tr("%1 deafened by %2.").arg(vic).arg(admin) : MainWindow::tr("%1 undeafened by %2.").arg(vic).arg(admin));
}
void MainWindow::msgPlayerKick(Connection *, MessagePlayerKick *msg) {
MSG_INIT;
VICTIM_INIT;
QString admin = pSrc ? pSrc->qsName : QLatin1String("server");
if (msg->uiVictim == g.uiSession) {
g.l->log(Log::YouKicked, MainWindow::tr("You were kicked from the server by %1: %2.").arg(admin).arg(msg->qsReason));
g.l->setIgnore(Log::ServerDisconnected, 1);
} else {
g.l->setIgnore(Log::PlayerLeave, 1);
g.l->log((msg->uiSession == g.uiSession) ? Log::YouKicked : Log::PlayerKicked, MainWindow::tr("%3 was kicked from the server by %1: %2.").arg(admin).arg(msg->qsReason).arg(pDst->qsName));
}
}
void MainWindow::msgPlayerBan(Connection *, MessagePlayerBan *msg) {
MSG_INIT;
VICTIM_INIT;
if (msg->uiVictim == g.uiSession) {
g.l->log(Log::YouKicked, MainWindow::tr("You were kicked and banned from the server by %1: %2.").arg(pSrc->qsName).arg(msg->qsReason));
g.l->setIgnore(Log::ServerDisconnected, 1);
} else {
g.l->setIgnore(Log::PlayerLeave, 1);
g.l->log((msg->uiSession == g.uiSession) ? Log::YouKicked : Log::PlayerKicked, MainWindow::tr("%3 was kicked and banned from the server by %1: %2.").arg(pSrc->qsName).arg(msg->qsReason).arg(pDst->qsName));
}
}
void MainWindow::msgPlayerMove(Connection *, MessagePlayerMove *msg) {
MSG_INIT;
VICTIM_INIT;
bool log = true;
if ((msg->uiVictim == g.uiSession) && (msg->uiSession == msg->uiVictim))
log = false;
if (g.uiSession == 0)
log = false;
QString pname = pDst->qsName;
QString admin = pSrc ? pSrc->qsName : QLatin1String("server");
if (log && (pDst->cChannel == ClientPlayer::get(g.uiSession)->cChannel)) {
if (pDst == pSrc || (!pSrc))
g.l->log(Log::ChannelJoin, MainWindow::tr("%1 left channel.").arg(pname));
else
g.l->log(Log::ChannelJoin, MainWindow::tr("%1 moved out by %2.").arg(pname).arg(admin));
}
pmModel->movePlayer(pDst, msg->iChannelId);
if (log && (pDst->cChannel == ClientPlayer::get(g.uiSession)->cChannel)) {
if (pDst == pSrc || (!pSrc))
g.l->log(Log::ChannelLeave, MainWindow::tr("%1 entered channel.").arg(pname));
else
g.l->log(Log::ChannelLeave, MainWindow::tr("%1 moved in by %2.").arg(pname).arg(admin));
}
}
void MainWindow::msgPlayerRename(Connection *, MessagePlayerRename *msg) {
MSG_INIT;
pmModel->renamePlayer(pSrc, msg->qsName);
}
void MainWindow::msgChannelAdd(Connection *, MessageChannelAdd *msg) {
Channel *p = Channel::get(msg->iParent);
if (p)
pmModel->addChannel(msg->iId, p, msg->qsName);
}
void MainWindow::msgChannelRemove(Connection *, MessageChannelRemove *msg) {
Channel *c = Channel::get(msg->iId);
if (c)
pmModel->removeChannel(c);
}
void MainWindow::msgChannelMove(Connection *, MessageChannelMove *msg) {
pmModel->moveChannel(Channel::get(msg->iId), msg->iParent);
}
void MainWindow::msgChannelLink(Connection *, MessageChannelLink *msg) {
Channel *c = Channel::get(msg->iId);
QList<Channel *> qlChans;
foreach(int id, msg->qlTargets) {
Channel *l = Channel::get(id);
qlChans << l;
}
switch (msg->ltType) {
case MessageChannelLink::Link:
pmModel->linkChannels(c, qlChans);
break;
case MessageChannelLink::Unlink:
pmModel->unlinkChannels(c, qlChans);
break;
case MessageChannelLink::UnlinkAll:
pmModel->unlinkAll(c);
break;
default:
qFatal("Unknown link message");
}
}
void MainWindow::msgServerAuthenticate(Connection *, MessageServerAuthenticate *) {
}
void MainWindow::msgServerReject(Connection *, MessageServerReject *msg) {
rtLast = msg->rtType;
g.l->log(Log::ServerDisconnected, MainWindow::tr("Server connection rejected: %1.").arg(msg->qsReason));
g.l->setIgnore(Log::ServerDisconnected, 1);
}
void MainWindow::msgPermissionDenied(Connection *, MessagePermissionDenied *msg) {
g.l->log(Log::PermissionDenied, MainWindow::tr("Denied: %1.").arg(msg->qsReason));
}
void MainWindow::msgServerSync(Connection *, MessageServerSync *msg) {
MSG_INIT;
g.iMaxBandwidth = msg->iMaxBandwidth;
g.uiSession = msg->uiSession;
g.l->clearIgnore();
g.l->log(Log::Information, msg->qsWelcomeText);
pmModel->ensureSelfVisible();
}
void MainWindow::msgTextMessage(Connection *, MessageTextMessage *msg) {
MSG_INIT;
g.l->log(Log::TextMessage, MainWindow::tr("From %1: %2").arg(pSrc->qsName).arg(msg->qsMessage),
MainWindow::tr("Message from %1").arg(pSrc->qsName));
}
void MainWindow::msgEditACL(Connection *, MessageEditACL *msg) {
if (aclEdit) {
aclEdit->reject();
delete aclEdit;
aclEdit = NULL;
}
aclEdit = new ACLEditor(msg, this);
aclEdit->show();
}
void MainWindow::msgQueryUsers(Connection *, MessageQueryUsers *msg) {
if (aclEdit)
aclEdit->returnQuery(msg);
}
void MainWindow::msgPing(Connection *, MessagePing *) {
}
void MainWindow::msgTexture(Connection *, MessageTexture *msg) {
if (! msg->qbaTexture.isEmpty())
g.o->textureResponse(msg->iPlayerId,msg->qbaTexture);
}

View File

@ -507,7 +507,7 @@ void Overlay::updateOverlay() {
return;
if (g.uiSession) {
Channel *home = Player::get(g.uiSession)->cChannel;
Channel *home = ClientPlayer::get(g.uiSession)->cChannel;
foreach(Channel *c, home->allLinks()) {
if (home == c)
continue;
@ -539,8 +539,8 @@ void Overlay::updateOverlay() {
}
}
foreach(Player *p, Player::get(g.uiSession)->cChannel->qlPlayers) {
if ((g.s.osOverlay == Settings::All) || p->bTalking || ((p == Player::get(g.uiSession)) && g.s.bOverlayAlwaysSelf)) {
foreach(Player *p, ClientPlayer::get(g.uiSession)->cChannel->qlPlayers) {
if ((g.s.osOverlay == Settings::All) || p->bTalking || ((p == ClientPlayer::get(g.uiSession)) && g.s.bOverlayAlwaysSelf)) {
if (g.s.bOverlayUserTextures && (p->iId >= 0) && (! qhQueried.contains(p->iId))) {
qhQueried.insert(p->iId, p->qsName);
MessageTexture mt;

View File

@ -38,7 +38,7 @@
#include "Overlay.h"
QHash <Channel *, ModelItem *> ModelItem::c_qhChannels;
QHash <Player *, ModelItem *> ModelItem::c_qhPlayers;
QHash <ClientPlayer *, ModelItem *> ModelItem::c_qhPlayers;
bool ModelItem::bPlayersTop = false;
ModelItem::ModelItem(Channel *c) {
@ -47,7 +47,7 @@ ModelItem::ModelItem(Channel *c) {
c_qhChannels[c] = this;
}
ModelItem::ModelItem(Player *p) {
ModelItem::ModelItem(ClientPlayer *p) {
this->cChan = NULL;
this->pPlayer = p;
c_qhPlayers[p] = this;
@ -95,7 +95,7 @@ bool ModelItem::validRow(int idx) const {
return ((idx >= 0) && (idx < (qlPlayers.count() + qlChannels.count())));
}
Player *ModelItem::playerAt(int idx) const {
ClientPlayer *ModelItem::playerAt(int idx) const {
if (! bPlayersTop)
idx -= qlChannels.count();
if ((idx>= 0) && (idx < qlPlayers.count()))
@ -118,7 +118,7 @@ int ModelItem::rowOf(Channel *c) const {
return v;
}
int ModelItem::rowOf(Player *p) const {
int ModelItem::rowOf(ClientPlayer *p) const {
int v = qlPlayers.lastIndexOf(p);
if (v != -1)
v += (bPlayersTop) ? 0 : qlChannels.count();
@ -152,9 +152,9 @@ int ModelItem::insertIndex(Channel *c) const {
return qls.lastIndexOf(c->qsName) + (bPlayersTop ? qlPlayers.count() : 0);
}
int ModelItem::insertIndex(Player *p) const {
int ModelItem::insertIndex(ClientPlayer *p) const {
QList<QString> qls;
Player *pp;
ClientPlayer *pp;
foreach(pp, qlPlayers)
qls << pp->qsName;
@ -169,7 +169,7 @@ void ModelItem::insertChannel(Channel *c) {
qlChannels.insert(idx, c);
}
void ModelItem::insertPlayer(Player *p) {
void ModelItem::insertPlayer(ClientPlayer *p) {
int idx = insertIndex(p) - (bPlayersTop ? 0 : qlChannels.count());
qlPlayers.insert(idx, p);
}
@ -225,7 +225,7 @@ QModelIndex PlayerModel::index(int row, int column, const QModelIndex &p) const
return idx;
}
QModelIndex PlayerModel::index(Player *p, int column) const {
QModelIndex PlayerModel::index(ClientPlayer *p, int column) const {
ModelItem *item = ModelItem::c_qhPlayers.value(p);
Q_ASSERT(p);
Q_ASSERT(item);
@ -295,7 +295,7 @@ QVariant PlayerModel::data(const QModelIndex &idx, int role) const {
ModelItem *item = static_cast<ModelItem *>(idx.internalPointer());
Channel *c = item->cChan;
Player *p = item->pPlayer;
ClientPlayer *p = item->pPlayer;
if (!c && !p)
return QVariant();
@ -438,7 +438,7 @@ void PlayerModel::unbugHide(const QModelIndex &idx) {
}
}
void PlayerModel::hidePlayer(Player *p) {
void PlayerModel::hidePlayer(ClientPlayer *p) {
Channel *c = p->cChannel;
ModelItem *item = ModelItem::c_qhChannels.value(c);
@ -451,13 +451,13 @@ void PlayerModel::hidePlayer(Player *p) {
item->qlPlayers.removeAll(p);
endRemoveRows();
if (g.uiSession && (p->cChannel == Player::get(g.uiSession)->cChannel))
if (g.uiSession && (p->cChannel == ClientPlayer::get(g.uiSession)->cChannel))
updateOverlay();
p->cChannel = NULL;
}
void PlayerModel::showPlayer(Player *p, Channel *c) {
void PlayerModel::showPlayer(ClientPlayer *p, Channel *c) {
ModelItem *item = ModelItem::c_qhChannels.value(c);
Q_ASSERT(p);
@ -471,7 +471,7 @@ void PlayerModel::showPlayer(Player *p, Channel *c) {
item->insertPlayer(p);
endInsertRows();
if (g.uiSession && (p->cChannel == Player::get(g.uiSession)->cChannel))
if (g.uiSession && (p->cChannel == ClientPlayer::get(g.uiSession)->cChannel))
updateOverlay();
ensureSelfVisible();
@ -482,7 +482,7 @@ void PlayerModel::ensureSelfVisible() {
if (! g.uiSession)
return;
Channel *c = Player::get(g.uiSession)->cChannel;
Channel *c = ClientPlayer::get(g.uiSession)->cChannel;
while (c) {
chans.push(c);
c = c->cParent;
@ -500,7 +500,7 @@ void PlayerModel::recheckLinks() {
bool bChanged = false;
Channel *home = Player::get(g.uiSession)->cChannel;
Channel *home = ClientPlayer::get(g.uiSession)->cChannel;
QSet<Channel *> all = home->allLinks();
@ -521,8 +521,8 @@ void PlayerModel::recheckLinks() {
updateOverlay();
}
Player *PlayerModel::addPlayer(unsigned int id, QString name) {
Player *p = Player::add(id, this);
ClientPlayer *PlayerModel::addPlayer(unsigned int id, QString name) {
ClientPlayer *p = ClientPlayer::add(id, this);
p->qsName = name;
new ModelItem(p);
@ -535,23 +535,23 @@ Player *PlayerModel::addPlayer(unsigned int id, QString name) {
return p;
}
void PlayerModel::removePlayer(Player *p) {
void PlayerModel::removePlayer(ClientPlayer *p) {
ModelItem *item = ModelItem::c_qhPlayers.value(p);
hidePlayer(p);
Player::remove(p);
ClientPlayer::remove(p);
delete p;
delete item;
}
void PlayerModel::movePlayer(Player *p, int id) {
void PlayerModel::movePlayer(ClientPlayer *p, int id) {
Channel *np = Channel::get(id);
hidePlayer(p);
showPlayer(p, np);
}
void PlayerModel::renamePlayer(Player *p, QString name) {
void PlayerModel::renamePlayer(ClientPlayer *p, QString name) {
Channel *c = p->cChannel;
hidePlayer(p);
p->qsName = name;
@ -606,7 +606,7 @@ Channel *PlayerModel::addChannel(int id, Channel *p, QString name) {
void PlayerModel::removeChannel(Channel *c) {
ModelItem *item;
Player *pl;
ClientPlayer *pl;
Channel *subc;
item=ModelItem::c_qhChannels.value(c);
@ -661,7 +661,7 @@ void PlayerModel::removeAll() {
updateOverlay();
}
Player *PlayerModel::getPlayer(const QModelIndex &idx) const {
ClientPlayer *PlayerModel::getPlayer(const QModelIndex &idx) const {
if (! idx.isValid())
return NULL;
@ -693,17 +693,17 @@ Channel *PlayerModel::getSubChannel(Channel *p, int idx) const {
void PlayerModel::playerTalkingChanged(bool) {
Player *p=static_cast<Player *>(sender());
ClientPlayer *p=static_cast<ClientPlayer *>(sender());
QModelIndex idx = index(p);
emit dataChanged(idx, idx);
updateOverlay();
}
void PlayerModel::playerMuteDeafChanged() {
Player *p=static_cast<Player *>(sender());
ClientPlayer *p=static_cast<ClientPlayer *>(sender());
QModelIndex idx = index(p, 1);
emit dataChanged(idx, idx);
if (g.uiSession && (p->cChannel == Player::get(g.uiSession)->cChannel))
if (g.uiSession && (p->cChannel == ClientPlayer::get(g.uiSession)->cChannel))
updateOverlay();
}
@ -723,7 +723,7 @@ QMimeData *PlayerModel::mimeData(const QModelIndexList &idxs) const {
QDataStream ds(&qba, QIODevice::WriteOnly);
foreach(idx, idxs) {
Player *p = getPlayer(idx);
ClientPlayer *p = getPlayer(idx);
Channel *c = getChannel(idx);
if (p) {
ds << false;

View File

@ -32,6 +32,7 @@
#define _PLAYERMODEL_H
class Player;
class ClientPlayer;
class Channel;
class PlayerDelegate : public QItemDelegate {
@ -46,32 +47,32 @@ struct ModelItem {
friend class PlayerModel;
Channel *cChan;
Player *pPlayer;
ClientPlayer *pPlayer;
QList<Channel *> qlChannels;
QList<Player *> qlPlayers;
QList<ClientPlayer *> qlPlayers;
static QHash <Channel *, ModelItem *> c_qhChannels;
static QHash <Player *, ModelItem *> c_qhPlayers;
static QHash <ClientPlayer *, ModelItem *> c_qhPlayers;
static bool bPlayersTop;
ModelItem(Channel *c);
ModelItem(Player *p);
ModelItem(ClientPlayer *p);
~ModelItem();
ModelItem *parent() const;
ModelItem *child(int idx) const;
bool validRow(int idx) const;
Player *playerAt(int idx) const;
ClientPlayer *playerAt(int idx) const;
Channel *channelAt(int idx) const;
int rowOf(Channel *c) const;
int rowOf(Player *p) const;
int rowOf(ClientPlayer *p) const;
int rowOfSelf() const;
int rows() const;
int insertIndex(Channel *c) const;
int insertIndex(Player *p) const;
int insertIndex(ClientPlayer *p) const;
void insertChannel(Channel *c);
void insertPlayer(Player *p);
void insertPlayer(ClientPlayer *p);
};
class ChannelItem;
@ -87,12 +88,12 @@ class PlayerModel : public QAbstractItemModel {
ModelItem *miRoot;
QSet<Channel *> qsLinked;
QModelIndex index(Player *, int column = 0) const;
QModelIndex index(ClientPlayer *, int column = 0) const;
QModelIndex index(Channel *) const;
QModelIndex index(ChannelItem *) const;
void hidePlayer(Player *p);
void showPlayer(Player *p, Channel *c);
void hidePlayer(ClientPlayer *p);
void showPlayer(ClientPlayer *p, Channel *c);
void hideChannel(Channel *c);
void showChannel(Channel *c, Channel *p);
@ -116,20 +117,20 @@ class PlayerModel : public QAbstractItemModel {
QMimeData *mimeData(const QModelIndexList &idx) const;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex & parent);
Player *addPlayer(unsigned int id, QString name);
Player *getPlayer(const QModelIndex &idx) const;
ClientPlayer *addPlayer(unsigned int id, QString name);
ClientPlayer *getPlayer(const QModelIndex &idx) const;
Channel *addChannel(int id, Channel *p, QString name);
Channel *getChannel(const QModelIndex &idx) const;
Channel *getSubChannel(Channel *p, int idx) const;
void renamePlayer(Player *p, QString name);
void renamePlayer(ClientPlayer *p, QString name);
void movePlayer(Player *p, int id);
void movePlayer(ClientPlayer *p, int id);
void moveChannel(Channel *p, int id);
void removePlayer(Player *p);
void removePlayer(ClientPlayer *p);
void removeChannel(Channel *c);
void linkChannels(Channel *c, QList<Channel *> links);

View File

@ -106,7 +106,7 @@ void ServerHandler::udpReady() {
pds >> t;
uiUDPPing = tTimestamp.elapsed() - t;
} else if (msgType == Message::Speex) {
Player *p = Player::get(uiSession);
ClientPlayer *p = ClientPlayer::get(uiSession);
AudioOutputPtr ao = g.ao;
if (ao) {
if (p) {
@ -203,7 +203,7 @@ void ServerHandler::message(QByteArray &qbaMsg) {
if (! mMsg)
return;
Player *p = Player::get(mMsg->uiSession);
ClientPlayer *p = ClientPlayer::get(mMsg->uiSession);
AudioOutputPtr ao = g.ao;
if (mMsg->messageType() == Message::Speex) {

View File

@ -7,7 +7,7 @@ RC_FILE = mumble.rc
HEADERS +=
SOURCES +=
HEADERS = BanEditor.h ACLEditor.h Log.h AudioConfigDialog.h AudioStats.h AudioInput.h AudioOutput.h MainWindow.h ServerHandler.h About.h ConnectDialog.h GlobalShortcut.h TextToSpeech.h Settings.h Database.h VersionCheck.h Global.h PlayerModel.h Audio.h ConfigDialog.h Plugins.h LookConfig.h Overlay.h AudioWizard.h ViewCert.h
SOURCES = BanEditor.cpp ACLEditor.cpp Log.cpp AudioConfigDialog.cpp AudioStats.cpp AudioInput.cpp AudioOutput.cpp main.cpp MainWindow.cpp ServerHandler.cpp About.cpp ConnectDialog.cpp Settings.cpp Database.cpp VersionCheck.cpp Global.cpp PlayerModel.cpp Audio.cpp ConfigDialog.cpp Plugins.cpp LookConfig.cpp Overlay.cpp AudioWizard.cpp ViewCert.cpp
SOURCES = BanEditor.cpp ACLEditor.cpp Log.cpp AudioConfigDialog.cpp AudioStats.cpp AudioInput.cpp AudioOutput.cpp main.cpp MainWindow.cpp ServerHandler.cpp About.cpp ConnectDialog.cpp Settings.cpp Database.cpp VersionCheck.cpp Global.cpp PlayerModel.cpp Audio.cpp ConfigDialog.cpp Plugins.cpp LookConfig.cpp Overlay.cpp AudioWizard.cpp ViewCert.cpp Messages.cpp
HEADERS += ../ACL.h ../Group.h ../Channel.h ../Connection.h ../Player.h
SOURCES += ../ACL.cpp ../Group.cpp ../Channel.cpp ../Message.cpp ../Connection.cpp ../Player.cpp ../Timer.cpp
DIST += licenses.h mumble.ico firmumble.inc plugins/mumble_plugin.h mumble-overlay mumble.desktop