diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2007-08-06 23:17:29 +0400 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2007-08-06 23:17:29 +0400 |
commit | 93e427c1a88e20249d7aef1b45d31132ccb574a5 (patch) | |
tree | 566585f0846e2171881a040ed3b5e2f5372ba1ad /src | |
parent | b6b99c2b1836ccbd229415530a29685ad21cb028 (diff) |
Rename channel
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@700 05730e5d-ab1b-0410-a4ac-84af385074fa
Diffstat (limited to 'src')
-rw-r--r-- | src/CryptState.cpp | 10 | ||||
-rw-r--r-- | src/Message.cpp | 14 | ||||
-rw-r--r-- | src/Message.h | 17 | ||||
-rw-r--r-- | src/mumble/AudioInput.cpp | 2 | ||||
-rw-r--r-- | src/mumble/MainWindow.cpp | 37 | ||||
-rw-r--r-- | src/mumble/MainWindow.h | 4 | ||||
-rw-r--r-- | src/mumble/Messages.cpp | 44 | ||||
-rw-r--r-- | src/mumble/PlayerModel.cpp | 21 | ||||
-rw-r--r-- | src/mumble/PlayerModel.h | 11 | ||||
-rw-r--r-- | src/murmur/Messages.cpp | 19 | ||||
-rw-r--r-- | src/murmur/Server.h | 1 | ||||
-rw-r--r-- | src/tests/Benchmark.cpp | 11 |
12 files changed, 152 insertions, 39 deletions
diff --git a/src/CryptState.cpp b/src/CryptState.cpp index 4f4a41f5b..e66c94eb6 100644 --- a/src/CryptState.cpp +++ b/src/CryptState.cpp @@ -154,15 +154,15 @@ static void inline XOR(subblock *dst, const subblock *a, const subblock *b) { static void inline S2(subblock *block) { subblock carry = SWAPPED(block[0]) >> SHIFTBITS; for (int i=0;i<BLOCKSIZE-1;i++) - block[i] = SWAPPED( (SWAPPED(block[i]) << 1) | (SWAPPED(block[i+1]) >> SHIFTBITS)); - block[BLOCKSIZE-1] = SWAPPED((SWAPPED(block[BLOCKSIZE-1]) << 1) ^ (carry * 0x87)); + block[i] = SWAPPED((SWAPPED(block[i]) << 1) | (SWAPPED(block[i+1]) >> SHIFTBITS)); + block[BLOCKSIZE-1] = SWAPPED((SWAPPED(block[BLOCKSIZE-1]) << 1) ^(carry * 0x87)); } static void inline S3(subblock *block) { subblock carry = SWAPPED(block[0]) >> SHIFTBITS; for (int i=0;i<BLOCKSIZE-1;i++) - block[i] ^= SWAPPED( (SWAPPED(block[i]) << 1) | (SWAPPED(block[i+1]) >> SHIFTBITS)); - block[BLOCKSIZE-1] ^= SWAPPED((SWAPPED(block[BLOCKSIZE-1]) << 1) ^ (carry * 0x87)); + block[i] ^= SWAPPED((SWAPPED(block[i]) << 1) | (SWAPPED(block[i+1]) >> SHIFTBITS)); + block[BLOCKSIZE-1] ^= SWAPPED((SWAPPED(block[BLOCKSIZE-1]) << 1) ^(carry * 0x87)); } static void inline ZERO(keyblock &block) { @@ -179,7 +179,7 @@ void CryptState::ocb_encrypt(const unsigned char *plain, unsigned char *encrypte // Initialize AESencrypt(nonce, delta, &encrypt_key); ZERO(checksum); - + while (len > AES_BLOCK_SIZE) { S2(delta); XOR(tmp, delta, reinterpret_cast<const subblock *>(plain)); diff --git a/src/Message.cpp b/src/Message.cpp index 80c14a90f..bc0c23960 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -121,6 +121,9 @@ Message *Message::networkToMessage(PacketDataStream &qdsIn) { case ChannelLink: mMsg = new MessageChannelLink(); break; + case ChannelRename: + mMsg = new MessageChannelRename(); + break; case TextMessage: mMsg = new MessageTextMessage(); break; @@ -225,6 +228,9 @@ void MessageHandler::dispatch(Connection *cCon, Message *msg) { case Message::ChannelLink: msgChannelLink(cCon, static_cast<MessageChannelLink *>(msg)); break; + case Message::ChannelRename: + msgChannelRename(cCon, static_cast<MessageChannelRename *>(msg)); + break; case Message::TextMessage: msgTextMessage(cCon, static_cast<MessageTextMessage *>(msg)); break; @@ -468,6 +474,14 @@ void MessageChannelMove::restoreStream(PacketDataStream &qdsIn) { qdsIn >> iParent; } +void MessageChannelRename::saveStream(PacketDataStream &qdsOut) const { + qdsOut << iId << qsName; +} + +void MessageChannelRename::restoreStream(PacketDataStream &qdsIn) { + qdsIn >> iId >> qsName; +} + void MessageTextMessage::saveStream(PacketDataStream &qdsOut) const { qdsOut << uiVictim; qdsOut << qsMessage; diff --git a/src/Message.h b/src/Message.h index aae09fc95..887634cea 100644 --- a/src/Message.h +++ b/src/Message.h @@ -31,7 +31,7 @@ #ifndef _MESSAGE_H #define _MESSAGE_H -#define MESSAGE_STREAM_VERSION 2 +#define MESSAGE_STREAM_VERSION 3 #include "ACL.h" @@ -43,7 +43,7 @@ class Message { virtual void saveStream(PacketDataStream &) const; virtual void restoreStream(PacketDataStream &); public: - enum MessageType { ServerReject, ServerAuthenticate, Speex, ServerSync, ServerJoin, ServerLeave, ServerBanList, PlayerMute, PlayerDeaf, PlayerKick, PlayerRename, PlayerBan, PlayerMove, PlayerSelfMuteDeaf, ChannelAdd, ChannelRemove, ChannelMove, ChannelLink, PermissionDenied, EditACL, QueryUsers, Ping, TextMessage, PlayerTexture, CryptSetup, CryptSync }; + enum MessageType { ServerReject, ServerAuthenticate, Speex, ServerSync, ServerJoin, ServerLeave, ServerBanList, PlayerMute, PlayerDeaf, PlayerKick, PlayerRename, PlayerBan, PlayerMove, PlayerSelfMuteDeaf, ChannelAdd, ChannelRemove, ChannelMove, ChannelLink, ChannelRename, PermissionDenied, EditACL, QueryUsers, Ping, TextMessage, PlayerTexture, CryptSetup, CryptSync }; unsigned int uiSession; Message(); @@ -277,6 +277,18 @@ class MessageChannelLink : public Message { }; }; +class MessageChannelRename : public Message { + protected: + void saveStream(PacketDataStream &) const; + void restoreStream(PacketDataStream &); + public: + int iId; + QString qsName; + Message::MessageType messageType() const { + return ChannelRename; + }; +}; + class MessageServerBanList : public Message { protected: void saveStream(PacketDataStream &) const; @@ -421,6 +433,7 @@ class MessageHandler { virtual void msgChannelRemove(Connection *, MessageChannelRemove *) = 0; virtual void msgChannelMove(Connection *, MessageChannelMove *) = 0; virtual void msgChannelLink(Connection *, MessageChannelLink *) = 0; + virtual void msgChannelRename(Connection *, MessageChannelRename *) = 0; virtual void msgServerBanList(Connection *, MessageServerBanList *) = 0; virtual void msgTextMessage(Connection *, MessageTextMessage *) = 0; virtual void msgPermissionDenied(Connection *, MessagePermissionDenied *) = 0; diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp index 1f9996aeb..2ed30c9ee 100644 --- a/src/mumble/AudioInput.cpp +++ b/src/mumble/AudioInput.cpp @@ -161,7 +161,7 @@ int AudioInput::getMaxBandwidth() { if (g.s.bTransmitPosition) audiorate += 12; - + if (g.s.bTCPCompat) audiorate += 12; diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index b49129628..b660591db 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -141,6 +141,10 @@ void MainWindow::createActions() { qaChannelACL->setObjectName(QLatin1String("ChannelACL")); qaChannelACL->setToolTip(tr("Edit Groups and ACL for channel")); qaChannelACL->setWhatsThis(tr("This opens the Group and ACL dialog for the channel, to control permissions.")); + qaChannelRename=new QAction(tr("&Rename channel"), this); + qaChannelRename->setObjectName(QLatin1String("ChannelRename")); + qaChannelRename->setToolTip(tr("Renames the channel")); + qaChannelRename->setWhatsThis(tr("This renames a channel.")); qaChannelLink=new QAction(tr("&Link"), this); qaChannelLink->setObjectName(QLatin1String("ChannelLink")); qaChannelLink->setToolTip(tr("Link your channel to another channel")); @@ -278,6 +282,8 @@ void MainWindow::setupGui() { qmChannel->addAction(qaChannelAdd); qmChannel->addAction(qaChannelRemove); qmChannel->addAction(qaChannelACL); + qmChannel->addAction(qaChannelRename); + qmChannel->addSeparator(); qmChannel->addAction(qaChannelLink); qmChannel->addAction(qaChannelUnlink); qmChannel->addAction(qaChannelUnlinkAll); @@ -665,9 +671,9 @@ void MainWindow::on_Quit_triggered() { void MainWindow::on_ChannelMenu_aboutToShow() { QModelIndex idx = qtvPlayers->currentIndex(); - bool add, remove, acl, link, unlink, unlinkall; + bool add, remove, acl, rename, link, unlink, unlinkall; - add = remove = acl = link = unlink = unlinkall = false; + add = remove = acl = rename = link = unlink = unlinkall = false; if (g.uiSession != 0) { add = true; @@ -676,8 +682,10 @@ void MainWindow::on_ChannelMenu_aboutToShow() { Channel *c = pmModel->getChannel(idx); Channel *home = ClientPlayer::get(g.uiSession)->cChannel; - if (c && c->iId != 0) + if (c && c->iId != 0) { + rename = true; remove = true; + } if (! c) c = Channel::get(0); @@ -694,6 +702,7 @@ void MainWindow::on_ChannelMenu_aboutToShow() { qaChannelAdd->setEnabled(add); qaChannelRemove->setEnabled(remove); qaChannelACL->setEnabled(acl); + qaChannelRename->setEnabled(rename); qaChannelLink->setEnabled(link); qaChannelUnlink->setEnabled(unlink); qaChannelUnlinkAll->setEnabled(unlinkall); @@ -738,6 +747,28 @@ void MainWindow::on_ChannelRemove_triggered() { } } +void MainWindow::on_ChannelRename_triggered() { + bool ok; + Channel *c = pmModel->getChannel(qtvPlayers->currentIndex()); + if (! c) + return; + + int id = c->iId; + + QString name = QInputDialog::getText(this, tr("Mumble"), tr("Channel Name"), QLineEdit::Normal, c->qsName, &ok); + + c = Channel::get(id); + if (! c) + return; + + if (ok) { + MessageChannelRename mcr; + mcr.iId = id; + mcr.qsName = name; + g.sh->sendMessage(&mcr); + } +} + void MainWindow::on_ChannelACL_triggered() { Channel *c = pmModel->getChannel(qtvPlayers->currentIndex()); int id = c ? c->iId : 0; diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index a9483ed73..07c307747 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -62,7 +62,7 @@ class MainWindow : public QMainWindow, public MessageHandler { QAction *qaAudioReset, *qaAudioMute, *qaAudioDeaf, *qaAudioTTS, *qaAudioStats, *qaAudioUnlink; QAction *qaConfigDialog, *qaAudioWizard; QAction *qaHelpWhatsThis, *qaHelpAbout, *qaHelpAboutSpeex, *qaHelpAboutQt, *qaHelpVersionCheck; - QAction *qaChannelAdd, *qaChannelRemove, *qaChannelACL, *qaChannelLink, *qaChannelUnlink, *qaChannelUnlinkAll; + QAction *qaChannelAdd, *qaChannelRemove, *qaChannelACL, *qaChannelRename, *qaChannelLink, *qaChannelUnlink, *qaChannelUnlinkAll; QSplitter *qsSplit; QSystemTrayIcon *qstiIcon; QTextEdit *qteLog; @@ -107,6 +107,7 @@ class MainWindow : public QMainWindow, public MessageHandler { void on_ChannelAdd_triggered(); void on_ChannelRemove_triggered(); void on_ChannelACL_triggered(); + void on_ChannelRename_triggered(); void on_ChannelLink_triggered(); void on_ChannelUnlink_triggered(); void on_ChannelUnlinkAll_triggered(); @@ -157,6 +158,7 @@ class MainWindow : public QMainWindow, public MessageHandler { virtual void msgChannelRemove(Connection *, MessageChannelRemove *); virtual void msgChannelMove(Connection *, MessageChannelMove *); virtual void msgChannelLink(Connection *, MessageChannelLink *); + virtual void msgChannelRename(Connection *, MessageChannelRename *); virtual void msgServerBanList(Connection *, MessageServerBanList *); virtual void msgTextMessage(Connection *, MessageTextMessage *); virtual void msgPermissionDenied(Connection *, MessagePermissionDenied *); diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 54d6a6b38..d618e8f49 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -64,18 +64,20 @@ void MainWindow::msgServerJoin(Connection *, MessageServerJoin *msg) { #define VICTIM_INIT \ ClientPlayer *pDst=ClientPlayer::get(msg->uiVictim); \ if (! pDst) \ - qFatal("MainWindow: Message for nonexistant victim %d.", msg->uiVictim); + qWarning("MainWindow: Message for nonexistant victim %d.", msg->uiVictim); \ + return; void MainWindow::msgServerLeave(Connection *, MessageServerLeave *msg) { MSG_INIT; + if (! pSrc) + return; + 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; @@ -92,6 +94,9 @@ void MainWindow::msgSpeex(Connection *, MessageSpeex *) { void MainWindow::msgPlayerSelfMuteDeaf(Connection *, MessagePlayerSelfMuteDeaf *msg) { MSG_INIT; + if (! pSrc) + return; + pSrc->setSelfMuteDeaf(msg->bMute, msg->bDeaf); if (msg->uiSession == g.uiSession || ! g.uiSession) @@ -161,12 +166,13 @@ void MainWindow::msgPlayerKick(Connection *, MessagePlayerKick *msg) { void MainWindow::msgPlayerBan(Connection *, MessagePlayerBan *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 and banned from the server by %1: %2.").arg(pSrc->qsName).arg(msg->qsReason)); + g.l->log(Log::YouKicked, MainWindow::tr("You were kicked and banned 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 and banned from the server by %1: %2.").arg(pSrc->qsName).arg(msg->qsReason).arg(pDst->qsName)); + 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(admin).arg(msg->qsReason).arg(pDst->qsName)); } } @@ -190,7 +196,11 @@ void MainWindow::msgPlayerMove(Connection *, MessagePlayerMove *msg) { g.l->log(Log::ChannelJoin, MainWindow::tr("%1 moved out by %2.").arg(pname).arg(admin)); } - pmModel->movePlayer(pDst, msg->iChannelId); + Channel *c = Channel::get(msg->iChannelId); + if (!c) + c = Channel::get(0); + + pmModel->movePlayer(pDst, c); if (log && (pDst->cChannel == ClientPlayer::get(g.uiSession)->cChannel)) { if (pDst == pSrc || (!pSrc)) @@ -202,7 +212,8 @@ void MainWindow::msgPlayerMove(Connection *, MessagePlayerMove *msg) { void MainWindow::msgPlayerRename(Connection *, MessagePlayerRename *msg) { MSG_INIT; - pmModel->renamePlayer(pSrc, msg->qsName); + if (pSrc) + pmModel->renamePlayer(pSrc, msg->qsName); } void MainWindow::msgChannelAdd(Connection *, MessageChannelAdd *msg) { @@ -218,15 +229,28 @@ void MainWindow::msgChannelRemove(Connection *, MessageChannelRemove *msg) { } void MainWindow::msgChannelMove(Connection *, MessageChannelMove *msg) { - pmModel->moveChannel(Channel::get(msg->iId), msg->iParent); + Channel *c = Channel::get(msg->iId); + Channel *p = Channel::get(msg->iParent); + if (c && p) + pmModel->moveChannel(c, p); +} + +void MainWindow::msgChannelRename(Connection *, MessageChannelRename *msg) { + Channel *c = Channel::get(msg->iId); + if (c && c->cParent) + pmModel->renameChannel(c, msg->qsName); } void MainWindow::msgChannelLink(Connection *, MessageChannelLink *msg) { Channel *c = Channel::get(msg->iId); + if (!c) + return; + QList<Channel *> qlChans; foreach(int id, msg->qlTargets) { Channel *l = Channel::get(id); - qlChans << l; + if (l) + qlChans << l; } switch (msg->ltType) { @@ -290,6 +314,8 @@ void MainWindow::msgServerSync(Connection *, MessageServerSync *msg) { void MainWindow::msgTextMessage(Connection *, MessageTextMessage *msg) { MSG_INIT; + if (! pSrc) + return; g.l->log(Log::TextMessage, MainWindow::tr("From %1: %2").arg(pSrc->qsName).arg(msg->qsMessage), MainWindow::tr("Message from %1").arg(pSrc->qsName)); } diff --git a/src/mumble/PlayerModel.cpp b/src/mumble/PlayerModel.cpp index 67a87404d..dce658d23 100644 --- a/src/mumble/PlayerModel.cpp +++ b/src/mumble/PlayerModel.cpp @@ -521,7 +521,7 @@ void PlayerModel::recheckLinks() { updateOverlay(); } -ClientPlayer *PlayerModel::addPlayer(unsigned int id, QString name) { +ClientPlayer *PlayerModel::addPlayer(unsigned int id, const QString &name) { ClientPlayer *p = ClientPlayer::add(id, this); p->qsName = name; @@ -545,19 +545,25 @@ void PlayerModel::removePlayer(ClientPlayer *p) { delete item; } -void PlayerModel::movePlayer(ClientPlayer *p, int id) { - Channel *np = Channel::get(id); +void PlayerModel::movePlayer(ClientPlayer *p, Channel *np) { hidePlayer(p); showPlayer(p, np); } -void PlayerModel::renamePlayer(ClientPlayer *p, QString name) { +void PlayerModel::renamePlayer(ClientPlayer *p, const QString &name) { Channel *c = p->cChannel; hidePlayer(p); p->qsName = name; showPlayer(p, c); } +void PlayerModel::renameChannel(Channel *c, const QString &name) { + Channel *pc = c->cParent; + hideChannel(c); + c->qsName = name; + showChannel(c, pc); +} + void PlayerModel::showChannel(Channel *c, Channel *p) { ModelItem *item = ModelItem::c_qhChannels.value(p); @@ -595,7 +601,7 @@ void PlayerModel::hideChannel(Channel *c) { item = ModelItem::c_qhChannels.value(c); } -Channel *PlayerModel::addChannel(int id, Channel *p, QString name) { +Channel *PlayerModel::addChannel(int id, Channel *p, const QString &name) { Channel *c = Channel::add(id, name, NULL); new ModelItem(c); @@ -624,10 +630,9 @@ void PlayerModel::removeChannel(Channel *c) { delete c; } -void PlayerModel::moveChannel(Channel *c, int id) { - Channel *np = Channel::get(id); +void PlayerModel::moveChannel(Channel *c, Channel *p) { hideChannel(c); - showChannel(c, np); + showChannel(c, p); } void PlayerModel::linkChannels(Channel *c, QList<Channel *> links) { diff --git a/src/mumble/PlayerModel.h b/src/mumble/PlayerModel.h index 877fffb36..dd39aeacd 100644 --- a/src/mumble/PlayerModel.h +++ b/src/mumble/PlayerModel.h @@ -117,18 +117,19 @@ 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); - ClientPlayer *addPlayer(unsigned int id, QString name); + ClientPlayer *addPlayer(unsigned int id, const QString &name); ClientPlayer *getPlayer(const QModelIndex &idx) const; - Channel *addChannel(int id, Channel *p, QString name); + Channel *addChannel(int id, Channel *p, const QString &name); Channel *getChannel(const QModelIndex &idx) const; Channel *getSubChannel(Channel *p, int idx) const; - void renamePlayer(ClientPlayer *p, QString name); + void renamePlayer(ClientPlayer *p, const QString &name); + void renameChannel(Channel *c, const QString &name); - void movePlayer(ClientPlayer *p, int id); - void moveChannel(Channel *p, int id); + void movePlayer(ClientPlayer *p, Channel *c); + void moveChannel(Channel *c, Channel *p); void removePlayer(ClientPlayer *p); void removeChannel(Channel *c); diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp index 880474cd9..16b90148b 100644 --- a/src/murmur/Messages.cpp +++ b/src/murmur/Messages.cpp @@ -502,6 +502,25 @@ void Server::msgChannelRemove(Connection *cCon, MessageChannelRemove *msg) { removeChannel(c, uSource); } +void Server::msgChannelRename(Connection *cCon, MessageChannelRename *msg) { + MSG_SETUP(Player::Authenticated); + Channel *c = qhChannels.value(msg->iId); + + if (!c) + return; + + if (! hasPermission(uSource, c, ChanACL::Write)) { + PERM_DENIED(uSource, c, ChanACL::Write); + return; + } + + log(uSource, "Renamed channel %s to %s", qPrintable(c->qsName), qPrintable(msg->qsName)); + c->qsName = msg->qsName; + updateChannel(c); + dbus->channelStateChanged(c); + sendAll(msg); +} + void Server::msgChannelMove(Connection *cCon, MessageChannelMove *msg) { MSG_SETUP(Player::Authenticated); diff --git a/src/murmur/Server.h b/src/murmur/Server.h index dbfa4cbba..91659876c 100644 --- a/src/murmur/Server.h +++ b/src/murmur/Server.h @@ -236,6 +236,7 @@ class Server : public QThread, public MessageHandler { virtual void msgChannelRemove(Connection *, MessageChannelRemove *); virtual void msgChannelMove(Connection *, MessageChannelMove *); virtual void msgChannelLink(Connection *, MessageChannelLink *); + virtual void msgChannelRename(Connection *, MessageChannelRename *); virtual void msgServerBanList(Connection *, MessageServerBanList *); virtual void msgTextMessage(Connection *, MessageTextMessage *); virtual void msgPermissionDenied(Connection *, MessagePermissionDenied *); diff --git a/src/tests/Benchmark.cpp b/src/tests/Benchmark.cpp index 5a85fee37..e2c748150 100644 --- a/src/tests/Benchmark.cpp +++ b/src/tests/Benchmark.cpp @@ -138,9 +138,9 @@ void Client::sendVoice() { void Client::doUdp(const unsigned char *buffer, int size) { if (! udp || ! crypt.isValid()) return; - + unsigned char crypted[size+4]; - + crypt.encrypt(reinterpret_cast<const unsigned char *>(buffer), crypted, size); ::sendto(socket, crypted, size+4, 0, reinterpret_cast<struct sockaddr *>(&srv), sizeof(srv)); } @@ -158,9 +158,9 @@ void Client::run() { forever { sz = sizeof(addr); len = ::recvfrom(socket, reinterpret_cast<char *>(buffer), 1000, 0, reinterpret_cast<struct sockaddr *>(&addr), &sz); - if ( len <= 0) + if (len <= 0) break; - if ( len >= 40) + if (len >= 40) rcvd++; } } @@ -195,7 +195,8 @@ void Client::readyRead() { } else if (ptype == Message::CryptSync) { qWarning("Crypt desync!"); QCoreApplication::instance()->quit(); - }if (ptype == Message::ServerSync) { + } + if (ptype == Message::ServerSync) { uiSession = sess; } else if (ptype == Message::Speex) { rcvd++; |