X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoresession.cpp;h=518246a9e06c6fcb39d01c07e10beea095f38cac;hp=5c377c85cbe0a2bf8130e6202e8ecc55eb12eb56;hb=b1b970e71618cb2d2cf372ba55234000c6324d7f;hpb=be04b68a0f10891b81c07cdda204a9abc0ac56a7 diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 5c377c85..518246a9 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -105,6 +105,9 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) p->attachSlot(SIGNAL(changePassword(PeerPtr,QString,QString,QString)), this, SLOT(changePassword(PeerPtr,QString,QString,QString))); p->attachSignal(this, SIGNAL(passwordChanged(PeerPtr,bool))); + p->attachSlot(SIGNAL(kickClient(int)), this, SLOT(kickClient(int))); + p->attachSignal(this, SIGNAL(disconnectFromCore())); + loadSettings(); initScriptEngine(); @@ -366,7 +369,8 @@ void CoreSession::processMessages() Q_ASSERT(!createBuffer); bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, BufferInfo::StatusBuffer, ""); } - Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags); + Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, + senderPrefixes(rawMsg.sender, bufferInfo), rawMsg.flags); if(Core::storeMessage(msg)) emit displayMsg(msg); } @@ -390,7 +394,8 @@ void CoreSession::processMessages() } bufferInfoCache[rawMsg.networkId][rawMsg.target] = bufferInfo; } - Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags); + Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, + senderPrefixes(rawMsg.sender, bufferInfo), rawMsg.flags); messages << msg; } @@ -406,7 +411,8 @@ void CoreSession::processMessages() // add the StatusBuffer to the Cache in case there are more Messages for the original target bufferInfoCache[rawMsg.networkId][rawMsg.target] = bufferInfo; } - Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags); + Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, + senderPrefixes(rawMsg.sender, bufferInfo), rawMsg.flags); messages << msg; } @@ -421,6 +427,25 @@ void CoreSession::processMessages() _messageQueue.clear(); } +QString CoreSession::senderPrefixes(const QString &sender, const BufferInfo &bufferInfo) const +{ + CoreNetwork *currentNetwork = network(bufferInfo.networkId()); + if (!currentNetwork) { + return {}; + } + + if (bufferInfo.type() != BufferInfo::ChannelBuffer) { + return {}; + } + + IrcChannel *currentChannel = currentNetwork->ircChannel(bufferInfo.bufferName()); + if (!currentChannel) { + return {}; + } + + const QString modes = currentChannel->userModes(nickFromMask(sender).toLower()); + return currentNetwork->modesToPrefixes(modes); +} Protocol::SessionState CoreSession::sessionState() const { @@ -664,13 +689,14 @@ void CoreSession::clientsDisconnected() if (!identity->detachAwayReason().isEmpty()) awayReason = identity->detachAwayReason(); net->setAutoAwayActive(true); + // Allow handleAway() to format the current date/time in the string. net->userInputHandler()->handleAway(BufferInfo(), awayReason); } } } -void CoreSession::globalAway(const QString &msg) +void CoreSession::globalAway(const QString &msg, const bool skipFormatting) { QHash::iterator netIter = _networks.begin(); CoreNetwork *net = 0; @@ -681,7 +707,7 @@ void CoreSession::globalAway(const QString &msg) if (!net->isConnected()) continue; - net->userInputHandler()->issueAway(msg, false /* no force away */); + net->userInputHandler()->issueAway(msg, false /* no force away */, skipFormatting); } } @@ -692,5 +718,18 @@ void CoreSession::changePassword(PeerPtr peer, const QString &userName, const QS if (uid.isValid() && uid == user()) success = Core::changeUserPassword(uid, newPassword); - emit passwordChanged(peer, success); + signalProxy()->restrictTargetPeers({signalProxy()->sourcePeer()}, [&]{ + emit passwordChanged(nullptr, success); + }); +} + +void CoreSession::kickClient(int peerId) { + auto peer = signalProxy()->peerById(peerId); + if (peer == nullptr) { + qWarning() << "Invalid peer Id: " << peerId; + return; + } + signalProxy()->restrictTargetPeers({peer}, [&]{ + emit disconnectFromCore(); + }); }