1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "coresession.h"
28 #include "corebacklogmanager.h"
29 #include "corebuffersyncer.h"
30 #include "corebufferviewmanager.h"
31 #include "coredccconfig.h"
32 #include "coreeventmanager.h"
33 #include "coreidentity.h"
34 #include "coreignorelistmanager.h"
36 #include "coreirclisthelper.h"
37 #include "corenetwork.h"
38 #include "corenetworkconfig.h"
39 #include "coresessioneventprocessor.h"
40 #include "coretransfermanager.h"
41 #include "coreuserinputhandler.h"
42 #include "coreusersettings.h"
43 #include "ctcpparser.h"
44 #include "eventstringifier.h"
45 #include "internalpeer.h"
46 #include "ircchannel.h"
47 #include "ircparser.h"
49 #include "messageevent.h"
50 #include "remotepeer.h"
54 class ProcessMessagesEvent : public QEvent
57 ProcessMessagesEvent()
58 : QEvent(QEvent::User)
62 CoreSession::CoreSession(UserId uid, bool restoreState, bool strictIdentEnabled, QObject* parent)
65 , _strictIdentEnabled(strictIdentEnabled)
66 , _signalProxy(new SignalProxy(SignalProxy::Server, this))
68 , _bufferSyncer(new CoreBufferSyncer(this))
69 , _backlogManager(new CoreBacklogManager(this))
70 , _bufferViewManager(new CoreBufferViewManager(_signalProxy, this))
71 , _dccConfig(new CoreDccConfig(this))
72 , _ircListHelper(new CoreIrcListHelper(this))
73 , _networkConfig(new CoreNetworkConfig("GlobalNetworkConfig", this))
74 , _coreInfo(new CoreInfo(this))
75 , _transferManager(new CoreTransferManager(this))
76 , _eventManager(new CoreEventManager(this))
77 , _eventStringifier(new EventStringifier(this))
78 , _sessionEventProcessor(new CoreSessionEventProcessor(this))
79 , _ctcpParser(new CtcpParser(this))
80 , _ircParser(new IrcParser(this))
81 , scriptEngine(new QScriptEngine(this))
82 , _processMessages(false)
83 , _ignoreListManager(this)
84 , _highlightRuleManager(this)
86 SignalProxy* p = signalProxy();
87 p->setHeartBeatInterval(30);
88 p->setMaxHeartBeatCount(60); // 30 mins until we throw a dead socket out
90 connect(p, &SignalProxy::peerRemoved, this, &CoreSession::removeClient);
92 connect(p, &SignalProxy::connected, this, &CoreSession::clientsConnected);
93 connect(p, &SignalProxy::disconnected, this, &CoreSession::clientsDisconnected);
95 p->attachSlot(SIGNAL(sendInput(BufferInfo,QString)), this, &CoreSession::msgFromClient);
96 p->attachSignal(this, &CoreSession::displayMsg);
97 p->attachSignal(this, &CoreSession::displayStatusMsg);
99 p->attachSignal(this, &CoreSession::identityCreated);
100 p->attachSignal(this, &CoreSession::identityRemoved);
101 p->attachSlot(SIGNAL(createIdentity(Identity,QVariantMap)), this, selectOverload<const Identity&, const QVariantMap&>(&CoreSession::createIdentity));
102 p->attachSlot(SIGNAL(removeIdentity(IdentityId)), this, &CoreSession::removeIdentity);
104 p->attachSignal(this, &CoreSession::networkCreated);
105 p->attachSignal(this, &CoreSession::networkRemoved);
106 p->attachSlot(SIGNAL(createNetwork(NetworkInfo,QStringList)), this,&CoreSession::createNetwork);
107 p->attachSlot(SIGNAL(removeNetwork(NetworkId)), this, &CoreSession::removeNetwork);
109 p->attachSlot(SIGNAL(changePassword(PeerPtr,QString,QString,QString)), this, &CoreSession::changePassword);
110 p->attachSignal(this, &CoreSession::passwordChanged);
112 p->attachSlot(SIGNAL(kickClient(int)), this, &CoreSession::kickClient);
113 p->attachSignal(this, &CoreSession::disconnectFromCore);
116 data["quasselVersion"] = Quassel::buildInfo().fancyVersionString;
117 data["quasselBuildDate"] = Quassel::buildInfo().commitDate; // "BuildDate" for compatibility
118 data["startTime"] = Core::startTime();
119 data["sessionConnectedClients"] = 0;
120 _coreInfo->setCoreData(data);
125 eventManager()->registerObject(ircParser(), EventManager::NormalPriority);
126 eventManager()->registerObject(sessionEventProcessor(), EventManager::HighPriority); // needs to process events *before* the stringifier!
127 eventManager()->registerObject(ctcpParser(), EventManager::NormalPriority);
128 eventManager()->registerObject(eventStringifier(), EventManager::NormalPriority);
129 eventManager()->registerObject(this, EventManager::LowPriority); // for sending MessageEvents to the client
130 // some events need to be handled after msg generation
131 eventManager()->registerObject(sessionEventProcessor(), EventManager::LowPriority, "lateProcess");
132 eventManager()->registerObject(ctcpParser(), EventManager::LowPriority, "send");
134 // periodically save our session state
135 connect(Core::syncTimer(), &QTimer::timeout, this, &CoreSession::saveSessionState);
137 p->synchronize(_bufferSyncer);
138 p->synchronize(&aliasManager());
139 p->synchronize(_backlogManager);
140 p->synchronize(dccConfig());
141 p->synchronize(ircListHelper());
142 p->synchronize(networkConfig());
143 p->synchronize(_coreInfo);
144 p->synchronize(&_ignoreListManager);
145 p->synchronize(&_highlightRuleManager);
146 // Listen to network removed events
147 connect(this, &CoreSession::networkRemoved, &_highlightRuleManager, &HighlightRuleManager::networkRemoved);
148 p->synchronize(transferManager());
149 // Restore session state
151 restoreSessionState();
156 void CoreSession::shutdown()
160 // Request disconnect from all connected networks in parallel, and wait until every network
161 // has emitted the disconnected() signal before deleting the session itself
162 for (CoreNetwork* net : _networks.values()) {
163 if (net->socketState() != QAbstractSocket::UnconnectedState) {
164 _networksPendingDisconnect.insert(net->networkId());
165 connect(net, &CoreNetwork::disconnected, this, &CoreSession::onNetworkDisconnected);
170 if (_networksPendingDisconnect.isEmpty()) {
171 // Nothing to do, suicide so the core can shut down
176 void CoreSession::onNetworkDisconnected(NetworkId networkId)
178 _networksPendingDisconnect.remove(networkId);
179 if (_networksPendingDisconnect.isEmpty()) {
180 // We're done, suicide so the core can shut down
185 CoreNetwork* CoreSession::network(NetworkId id) const
187 if (_networks.contains(id))
188 return _networks[id];
192 CoreIdentity* CoreSession::identity(IdentityId id) const
194 if (_identities.contains(id))
195 return _identities[id];
199 void CoreSession::loadSettings()
201 CoreUserSettings s(user());
204 QList<IdentityId> ids = s.identityIds();
205 QList<NetworkInfo> networkInfos = Core::networks(user());
206 for (IdentityId id : ids) {
207 CoreIdentity identity(s.identity(id));
208 IdentityId newId = Core::createIdentity(user(), identity);
209 QList<NetworkInfo>::iterator networkIter = networkInfos.begin();
210 while (networkIter != networkInfos.end()) {
211 if (networkIter->identity == id) {
212 networkIter->identity = newId;
213 Core::updateNetwork(user(), *networkIter);
214 networkIter = networkInfos.erase(networkIter);
220 s.removeIdentity(id);
224 for (const CoreIdentity& identity : Core::identities(user())) {
225 createIdentity(identity);
228 for (const NetworkInfo& info : Core::networks(user())) {
233 void CoreSession::saveSessionState() const
235 _bufferSyncer->storeDirtyIds();
236 _bufferViewManager->saveBufferViews();
237 _networkConfig->save();
240 void CoreSession::restoreSessionState()
242 QList<NetworkId> nets = Core::connectedNetworks(user());
243 CoreNetwork* net = nullptr;
244 for (NetworkId id : nets) {
251 void CoreSession::addClient(RemotePeer* peer)
253 signalProxy()->setTargetPeer(peer);
255 peer->dispatch(sessionState());
256 signalProxy()->addPeer(peer);
257 _coreInfo->setConnectedClientData(signalProxy()->peerCount(), signalProxy()->peerData());
259 signalProxy()->setTargetPeer(nullptr);
262 void CoreSession::addClient(InternalPeer* peer)
264 signalProxy()->addPeer(peer);
265 emit sessionStateReceived(sessionState());
268 void CoreSession::removeClient(Peer* peer)
270 auto* p = qobject_cast<RemotePeer*>(peer);
272 qInfo() << qPrintable(tr("Client")) << p->description() << qPrintable(tr("disconnected (UserId: %1).").arg(user().toInt()));
273 _coreInfo->setConnectedClientData(signalProxy()->peerCount(), signalProxy()->peerData());
276 QHash<QString, QString> CoreSession::persistentChannels(NetworkId id) const
278 return Core::persistentChannels(user(), id);
281 QHash<QString, QByteArray> CoreSession::bufferCiphers(NetworkId id) const
283 return Core::bufferCiphers(user(), id);
286 void CoreSession::setBufferCipher(NetworkId id, const QString& bufferName, const QByteArray& cipher) const
288 Core::setBufferCipher(user(), id, bufferName, cipher);
291 // FIXME switch to BufferId
292 void CoreSession::msgFromClient(BufferInfo bufinfo, QString msg)
294 CoreNetwork* net = network(bufinfo.networkId());
296 net->userInput(bufinfo, msg);
299 qWarning() << "Trying to send to unconnected network:" << msg;
303 // ALL messages coming pass through these functions before going to the GUI.
304 // So this is the perfect place for storing the backlog and log stuff.
305 void CoreSession::recvMessageFromServer(RawMessage msg)
307 // U+FDD0 and U+FDD1 are special characters for Qt's text engine, specifically they mark the boundaries of
308 // text frames in a QTextDocument. This might lead to problems in widgets displaying QTextDocuments (such as
309 // KDE's notifications), hence we remove those just to be safe.
310 msg.text.remove(QChar(0xfdd0)).remove(QChar(0xfdd1));
312 // check for HardStrictness ignore
313 CoreNetwork* currentNetwork = network(msg.networkId);
314 QString networkName = currentNetwork ? currentNetwork->networkName() : QString("");
315 if (_ignoreListManager.match(msg, networkName) == IgnoreListManager::HardStrictness)
318 if (currentNetwork && _highlightRuleManager.match(msg, currentNetwork->myNick(), currentNetwork->identityPtr()->nicks()))
319 msg.flags |= Message::Flag::Highlight;
321 _messageQueue << std::move(msg);
322 if (!_processMessages) {
323 _processMessages = true;
324 QCoreApplication::postEvent(this, new ProcessMessagesEvent());
328 void CoreSession::recvStatusMsgFromServer(QString msg)
330 auto* net = qobject_cast<CoreNetwork*>(sender());
332 emit displayStatusMsg(net->networkName(), std::move(msg));
335 void CoreSession::processMessageEvent(MessageEvent* event)
337 recvMessageFromServer(RawMessage{
341 event->target().isNull() ? "" : event->target(),
342 event->text().isNull() ? "" : event->text(),
343 event->sender().isNull() ? "" : event->sender(),
348 QList<BufferInfo> CoreSession::buffers() const
350 return Core::requestBuffers(user());
353 void CoreSession::customEvent(QEvent* event)
355 if (event->type() != QEvent::User)
362 void CoreSession::processMessages()
364 if (_messageQueue.count() == 1) {
365 const RawMessage& rawMsg = _messageQueue.first();
366 bool createBuffer = !(rawMsg.flags & Message::Redirected);
367 BufferInfo bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, rawMsg.bufferType, rawMsg.target, createBuffer);
368 if (!bufferInfo.isValid()) {
369 Q_ASSERT(!createBuffer);
370 bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, BufferInfo::StatusBuffer, "");
372 Message msg(bufferInfo,
376 senderPrefixes(rawMsg.sender, bufferInfo),
377 realName(rawMsg.sender, rawMsg.networkId),
378 avatarUrl(rawMsg.sender, rawMsg.networkId),
380 if (Core::storeMessage(msg))
381 emit displayMsg(msg);
384 QHash<NetworkId, QHash<QString, BufferInfo>> bufferInfoCache;
385 MessageList messages;
386 QList<RawMessage> redirectedMessages; // list of Messages which don't enforce a buffer creation
387 BufferInfo bufferInfo;
388 for (int i = 0; i < _messageQueue.count(); i++) {
389 const RawMessage& rawMsg = _messageQueue.at(i);
390 if (bufferInfoCache.contains(rawMsg.networkId) && bufferInfoCache[rawMsg.networkId].contains(rawMsg.target)) {
391 bufferInfo = bufferInfoCache[rawMsg.networkId][rawMsg.target];
394 bool createBuffer = !(rawMsg.flags & Message::Redirected);
395 bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, rawMsg.bufferType, rawMsg.target, createBuffer);
396 if (!bufferInfo.isValid()) {
397 Q_ASSERT(!createBuffer);
398 redirectedMessages << rawMsg;
401 bufferInfoCache[rawMsg.networkId][rawMsg.target] = bufferInfo;
403 Message msg(bufferInfo,
407 senderPrefixes(rawMsg.sender, bufferInfo),
408 realName(rawMsg.sender, rawMsg.networkId),
409 avatarUrl(rawMsg.sender, rawMsg.networkId),
414 // recheck if there exists a buffer to store a redirected message in
415 for (int i = 0; i < redirectedMessages.count(); i++) {
416 const RawMessage& rawMsg = redirectedMessages.at(i);
417 if (bufferInfoCache.contains(rawMsg.networkId) && bufferInfoCache[rawMsg.networkId].contains(rawMsg.target)) {
418 bufferInfo = bufferInfoCache[rawMsg.networkId][rawMsg.target];
421 // no luck -> we store them in the StatusBuffer
422 bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, BufferInfo::StatusBuffer, "");
423 // add the StatusBuffer to the Cache in case there are more Messages for the original target
424 bufferInfoCache[rawMsg.networkId][rawMsg.target] = bufferInfo;
426 Message msg(bufferInfo,
430 senderPrefixes(rawMsg.sender, bufferInfo),
431 realName(rawMsg.sender, rawMsg.networkId),
432 avatarUrl(rawMsg.sender, rawMsg.networkId),
437 if (Core::storeMessages(messages)) {
438 // FIXME: extend protocol to a displayMessages(MessageList)
439 for (int i = 0; i < messages.count(); i++) {
440 emit displayMsg(messages[i]);
444 _processMessages = false;
445 _messageQueue.clear();
448 QString CoreSession::senderPrefixes(const QString& sender, const BufferInfo& bufferInfo) const
450 CoreNetwork* currentNetwork = network(bufferInfo.networkId());
451 if (!currentNetwork) {
455 if (bufferInfo.type() != BufferInfo::ChannelBuffer) {
459 IrcChannel* currentChannel = currentNetwork->ircChannel(bufferInfo.bufferName());
460 if (!currentChannel) {
464 const QString modes = currentChannel->userModes(nickFromMask(sender).toLower());
465 return currentNetwork->modesToPrefixes(modes);
468 QString CoreSession::realName(const QString& sender, NetworkId networkId) const
470 CoreNetwork* currentNetwork = network(networkId);
471 if (!currentNetwork) {
475 IrcUser* currentUser = currentNetwork->ircUser(nickFromMask(sender));
480 return currentUser->realName();
483 QString CoreSession::avatarUrl(const QString& sender, NetworkId networkId) const
487 // Currently we do not have a way to retrieve this value yet.
489 // This likely will require implementing IRCv3's METADATA spec.
490 // See https://ircv3.net/irc/
491 // And https://blog.irccloud.com/avatars/
495 Protocol::SessionState CoreSession::sessionState() const
497 QVariantList bufferInfos;
498 QVariantList networkIds;
499 QVariantList identities;
501 for (const BufferInfo& id : buffers()) {
502 bufferInfos << QVariant::fromValue(id);
504 for (const NetworkId& id : _networks.keys()) {
505 networkIds << QVariant::fromValue(id);
507 for (const Identity* i : _identities.values()) {
508 identities << QVariant::fromValue(*i);
511 return Protocol::SessionState(identities, bufferInfos, networkIds);
514 void CoreSession::initScriptEngine()
516 signalProxy()->attachSlot(SIGNAL(scriptRequest(QString)), this, &CoreSession::scriptRequest);
517 signalProxy()->attachSignal(this, &CoreSession::scriptResult);
520 // QScriptValue storage_ = scriptEngine->newQObject(storage);
521 // scriptEngine->globalObject().setProperty("storage", storage_);
524 void CoreSession::scriptRequest(QString script)
526 emit scriptResult(scriptEngine->evaluate(script).toString());
529 /*** Identity Handling ***/
530 void CoreSession::createIdentity(const Identity& identity, const QVariantMap& additional)
536 CoreIdentity coreIdentity(identity);
538 if (additional.contains("KeyPem"))
539 coreIdentity.setSslKey(additional["KeyPem"].toByteArray());
540 if (additional.contains("CertPem"))
541 coreIdentity.setSslCert(additional["CertPem"].toByteArray());
543 qDebug() << Q_FUNC_INFO;
544 IdentityId id = Core::createIdentity(user(), coreIdentity);
548 createIdentity(coreIdentity);
551 const QString CoreSession::strictCompliantIdent(const CoreIdentity* identity)
553 if (_strictIdentEnabled) {
554 // Strict mode enabled: only allow the user's Quassel username as an ident
555 return Core::instance()->strictSysIdent(_user);
558 // Strict mode disabled: allow any identity specified
559 return identity->ident();
563 void CoreSession::createIdentity(const CoreIdentity& identity)
565 auto* coreIdentity = new CoreIdentity(identity, this);
566 _identities[identity.id()] = coreIdentity;
567 // CoreIdentity has its own synchronize method since its "private" sslManager needs to be synced as well
568 coreIdentity->synchronize(signalProxy());
569 connect(coreIdentity, &SyncableObject::updated, this, &CoreSession::updateIdentityBySender);
570 emit identityCreated(*coreIdentity);
573 void CoreSession::updateIdentityBySender()
575 auto* identity = qobject_cast<CoreIdentity*>(sender());
578 Core::updateIdentity(user(), *identity);
581 void CoreSession::removeIdentity(IdentityId id)
583 CoreIdentity* identity = _identities.take(id);
585 emit identityRemoved(id);
586 Core::removeIdentity(user(), id);
587 identity->deleteLater();
591 /*** Network Handling ***/
593 void CoreSession::createNetwork(const NetworkInfo& info_, const QStringList& persistentChans)
595 NetworkInfo info = info_;
598 if (!info.networkId.isValid())
599 Core::createNetwork(user(), info);
601 if (!info.networkId.isValid()) {
602 qWarning() << qPrintable(
603 tr("CoreSession::createNetwork(): Got invalid networkId from Core when trying to create network %1!").arg(info.networkName));
607 id = info.networkId.toInt();
608 if (!_networks.contains(id)) {
609 // create persistent chans
610 QRegExp rx(R"(\s*(\S+)(?:\s*(\S+))?\s*)");
611 for (const QString& channel : persistentChans) {
612 if (!rx.exactMatch(channel)) {
613 qWarning() << QString("Invalid persistent channel declaration: %1").arg(channel);
616 Core::bufferInfo(user(), info.networkId, BufferInfo::ChannelBuffer, rx.cap(1), true);
617 Core::setChannelPersistent(user(), info.networkId, rx.cap(1), true);
618 if (!rx.cap(2).isEmpty())
619 Core::setPersistentChannelKey(user(), info.networkId, rx.cap(1), rx.cap(2));
622 CoreNetwork* net = new CoreNetwork(id, this);
623 connect(net, &CoreNetwork::displayMsg, this, &CoreSession::recvMessageFromServer);
624 connect(net, &CoreNetwork::displayStatusMsg, this, &CoreSession::recvStatusMsgFromServer);
625 connect(net, &CoreNetwork::disconnected, this, &CoreSession::networkDisconnected);
627 net->setNetworkInfo(info);
628 net->setProxy(signalProxy());
630 signalProxy()->synchronize(net);
631 emit networkCreated(id);
634 qWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!"));
635 _networks[info.networkId]->requestSetNetworkInfo(info);
639 void CoreSession::removeNetwork(NetworkId id)
641 // Make sure the network is disconnected!
642 CoreNetwork* net = network(id);
646 if (net->connectionState() != Network::Disconnected) {
647 // make sure we no longer receive data from the tcp buffer
648 disconnect(net, &CoreNetwork::displayMsg, this, nullptr);
649 disconnect(net, &CoreNetwork::displayStatusMsg, this, nullptr);
650 connect(net, &CoreNetwork::disconnected, this, &CoreSession::destroyNetwork);
651 net->disconnectFromIrc();
658 void CoreSession::destroyNetwork(NetworkId id)
660 QList<BufferId> removedBuffers = Core::requestBufferIdsForNetwork(user(), id);
661 Network* net = _networks.take(id);
662 if (net && Core::removeNetwork(user(), id)) {
663 // make sure that all unprocessed RawMessages from this network are removed
664 QList<RawMessage>::iterator messageIter = _messageQueue.begin();
665 while (messageIter != _messageQueue.end()) {
666 if (messageIter->networkId == id) {
667 messageIter = _messageQueue.erase(messageIter);
673 // remove buffers from syncer
674 for (BufferId bufferId : removedBuffers) {
675 _bufferSyncer->removeBuffer(bufferId);
677 emit networkRemoved(id);
682 void CoreSession::renameBuffer(const NetworkId& networkId, const QString& newName, const QString& oldName)
684 BufferInfo bufferInfo = Core::bufferInfo(user(), networkId, BufferInfo::QueryBuffer, oldName, false);
685 if (bufferInfo.isValid()) {
686 _bufferSyncer->renameBuffer(bufferInfo.bufferId(), newName);
690 void CoreSession::clientsConnected()
692 QHash<NetworkId, CoreNetwork*>::iterator netIter = _networks.begin();
693 Identity* identity = nullptr;
694 CoreNetwork* net = nullptr;
695 IrcUser* me = nullptr;
696 while (netIter != _networks.end()) {
700 if (!net->isConnected())
702 identity = net->identityPtr();
709 if (identity->detachAwayEnabled() && me->isAway()) {
710 net->userInputHandler()->handleAway(BufferInfo(), QString());
715 void CoreSession::clientsDisconnected()
717 QHash<NetworkId, CoreNetwork*>::iterator netIter = _networks.begin();
718 Identity* identity = nullptr;
719 CoreNetwork* net = nullptr;
720 IrcUser* me = nullptr;
722 while (netIter != _networks.end()) {
726 if (!net->isConnected())
729 identity = net->identityPtr();
736 if (identity->detachAwayEnabled() && !me->isAway()) {
737 if (!identity->detachAwayReason().isEmpty())
738 awayReason = identity->detachAwayReason();
739 net->setAutoAwayActive(true);
740 // Allow handleAway() to format the current date/time in the string.
741 net->userInputHandler()->handleAway(BufferInfo(), awayReason);
746 void CoreSession::globalAway(const QString& msg, const bool skipFormatting)
748 QHash<NetworkId, CoreNetwork*>::iterator netIter = _networks.begin();
749 CoreNetwork* net = nullptr;
750 while (netIter != _networks.end()) {
754 if (!net->isConnected())
757 net->userInputHandler()->issueAway(msg, false /* no force away */, skipFormatting);
761 void CoreSession::changePassword(PeerPtr peer, const QString& userName, const QString& oldPassword, const QString& newPassword)
765 bool success = false;
766 UserId uid = Core::validateUser(userName, oldPassword);
767 if (uid.isValid() && uid == user())
768 success = Core::changeUserPassword(uid, newPassword);
770 signalProxy()->restrictTargetPeers(signalProxy()->sourcePeer(), [&] { emit passwordChanged(nullptr, success); });
773 void CoreSession::kickClient(int peerId)
775 auto peer = signalProxy()->peerById(peerId);
776 if (peer == nullptr) {
777 qWarning() << "Invalid peer Id: " << peerId;
780 signalProxy()->restrictTargetPeers(peer, [&] { emit disconnectFromCore(); });