Adds the possibility to show a list of connected clients, and allow
to kick other (or your own) clients of the same user.
p->attachSignal(this, SIGNAL(requestPasswordChange(PeerPtr,QString,QString,QString)), SIGNAL(changePassword(PeerPtr,QString,QString,QString)));
p->attachSlot(SIGNAL(passwordChanged(PeerPtr,bool)), this, SLOT(corePasswordChanged(PeerPtr,bool)));
p->attachSignal(this, SIGNAL(requestPasswordChange(PeerPtr,QString,QString,QString)), SIGNAL(changePassword(PeerPtr,QString,QString,QString)));
p->attachSlot(SIGNAL(passwordChanged(PeerPtr,bool)), this, SLOT(corePasswordChanged(PeerPtr,bool)));
+ p->attachSignal(this, SIGNAL(requestKickClient(int)), SIGNAL(kickClient(int)));
+
//connect(mainUi(), SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &)));
connect(mainUi(), SIGNAL(disconnectFromCore()), this, SLOT(disconnectFromCore()));
connect(this, SIGNAL(connected()), mainUi(), SLOT(connectedToCore()));
//connect(mainUi(), SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &)));
connect(mainUi(), SIGNAL(disconnectFromCore()), this, SLOT(disconnectFromCore()));
connect(this, SIGNAL(connected()), mainUi(), SLOT(connectedToCore()));
+void Client::kickClient(int peerId) {
+ emit instance()->requestKickClient(peerId);
+}
+
+
void Client::corePasswordChanged(PeerPtr, bool success)
{
if (success)
void Client::corePasswordChanged(PeerPtr, bool success)
{
if (success)
static void purgeKnownBufferIds();
static void changePassword(const QString &oldPassword, const QString &newPassword);
static void purgeKnownBufferIds();
static void changePassword(const QString &oldPassword, const QString &newPassword);
+ static void kickClient(int peerId);
#if QT_VERSION < 0x050000
static void logMessage(QtMsgType type, const char *msg);
#if QT_VERSION < 0x050000
static void logMessage(QtMsgType type, const char *msg);
//! Requests a password change (user name must match the currently logged in user)
void requestPasswordChange(PeerPtr peer, const QString &userName, const QString &oldPassword, const QString &newPassword);
//! Requests a password change (user name must match the currently logged in user)
void requestPasswordChange(PeerPtr peer, const QString &userName, const QString &oldPassword, const QString &newPassword);
+
+ void requestKickClient(int peerId);
void passwordChanged(bool success);
public slots:
void passwordChanged(bool success);
public slots:
virtual int lag() const = 0;
virtual int lag() const = 0;
+ int _id = -1;
+
+ QString _buildDate;
+ QString _clientVersion;
+
public slots:
/* Handshake messages */
virtual void dispatch(const Protocol::RegisterClient &) = 0;
public slots:
/* Handshake messages */
virtual void dispatch(const Protocol::RegisterClient &) = 0;
if (!peer->parent())
peer->setParent(this);
if (!peer->parent())
peer->setParent(this);
+ if (peer->_id < 0) {
+ peer->_id = nextPeerId();
+ }
+
+ _peerMap[peer->_id] = peer;
peer->setSignalProxy(this);
peer->setSignalProxy(this);
disconnect(peer, 0, this, 0);
peer->setSignalProxy(0);
disconnect(peer, 0, this, 0);
peer->setSignalProxy(0);
+ _peerMap.remove(peer->_id);
_peers.remove(peer);
emit peerRemoved(peer);
_peers.remove(peer);
emit peerRemoved(peer);
emit secureStateChanged(_secure);
}
emit secureStateChanged(_secure);
}
+QVariantList SignalProxy::peerData() {
+ QVariantList result;
+ for (auto peer : _peers) {
+ QVariantMap data;
+ data["id"] = peer->_id;
+ data["buildData"] = peer->_buildDate;
+ data["clientVersion"] = peer->_clientVersion;
+ data["description"] = peer->description();
+ data["secure"] = peer->isSecure();
+ result << data;
+ }
+ return result;
+}
+
+Peer *SignalProxy::peerById(int peerId) {
+ return _peerMap[peerId];
+}
+
// ==================================================
// ExtendedMetaObject
// ==================================================
// ExtendedMetaObject
void dumpProxyStats();
void dumpSyncMap(SyncableObject *object);
inline int peerCount() const { return _peers.size(); }
void dumpProxyStats();
void dumpSyncMap(SyncableObject *object);
inline int peerCount() const { return _peers.size(); }
+ QVariantList peerData();
+
+ Peer *peerById(int peerId);
public slots:
void detachObject(QObject *obj);
public slots:
void detachObject(QObject *obj);
void removePeer(Peer *peer);
void removeAllPeers();
void removePeer(Peer *peer);
void removeAllPeers();
+ int nextPeerId() {
+ return _lastPeerId++;
+ }
+
template<class T>
void dispatch(const T &protoMessage);
template<class T>
template<class T>
void dispatch(const T &protoMessage);
template<class T>
static void disconnectDevice(QIODevice *dev, const QString &reason = QString());
QSet<Peer *> _peers;
static void disconnectDevice(QIODevice *dev, const QString &reason = QString());
QSet<Peer *> _peers;
+ QHash<int, Peer*> _peerMap;
// containg a list of argtypes for fast access
QHash<const QMetaObject *, ExtendedMetaObject *> _extendedMetaObjects;
// containg a list of argtypes for fast access
QHash<const QMetaObject *, ExtendedMetaObject *> _extendedMetaObjects;
bool _secure; // determines if all connections are in a secured state (using ssl or internal connections)
bool _secure; // determines if all connections are in a secured state (using ssl or internal connections)
friend class SignalRelay;
friend class SyncableObject;
friend class Peer;
friend class SignalRelay;
friend class SyncableObject;
friend class Peer;
// XXX: FIXME: use client features here: we cannot pass authenticators if the client is too old!
_peer->dispatch(ClientRegistered(Quassel::features(), configured, backends, useSsl, authenticators));
// XXX: FIXME: use client features here: we cannot pass authenticators if the client is too old!
_peer->dispatch(ClientRegistered(Quassel::features(), configured, backends, useSsl, authenticators));
+ _peer->_buildDate = msg.buildDate;
+ _peer->_clientVersion = msg.clientVersion;
+
if (_legacy && useSsl)
startSsl();
if (_legacy && useSsl)
startSsl();
data["quasselBuildDate"] = Quassel::buildInfo().commitDate; // "BuildDate" for compatibility
data["startTime"] = Core::instance()->startTime();
data["sessionConnectedClients"] = _coreSession->signalProxy()->peerCount();
data["quasselBuildDate"] = Quassel::buildInfo().commitDate; // "BuildDate" for compatibility
data["startTime"] = Core::instance()->startTime();
data["sessionConnectedClients"] = _coreSession->signalProxy()->peerCount();
+ data["sessionConnectedClientData"] = _coreSession->signalProxy()->peerData();
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(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)));
+
loadSettings();
initScriptEngine();
loadSettings();
initScriptEngine();
emit passwordChanged(peer, success);
}
emit passwordChanged(peer, success);
}
+
+void CoreSession::kickClient(int peerId) {
+ auto peer = signalProxy()->peerById(peerId);
+ if (!peer) {
+ qWarning() << "Invalid peer Id: " << peerId;
+ }
+ peer->close("Terminated by user action");
+}
void changePassword(PeerPtr peer, const QString &userName, const QString &oldPassword, const QString &newPassword);
void changePassword(PeerPtr peer, const QString &userName, const QString &oldPassword, const QString &newPassword);
+ void kickClient(int peerId);
+
QHash<QString, QString> persistentChannels(NetworkId) const;
/**
QHash<QString, QString> persistentChannels(NetworkId) const;
/**
ui.labelCoreVersion->setText(_coreInfo["quasselVersion"].toString());
ui.labelCoreVersionDate->setText(_coreInfo["quasselBuildDate"].toString()); // "BuildDate" for compatibility
ui.labelClientCount->setNum(_coreInfo["sessionConnectedClients"].toInt());
ui.labelCoreVersion->setText(_coreInfo["quasselVersion"].toString());
ui.labelCoreVersionDate->setText(_coreInfo["quasselBuildDate"].toString()); // "BuildDate" for compatibility
ui.labelClientCount->setNum(_coreInfo["sessionConnectedClients"].toInt());
+
+ /*
+ qWarning() << _coreInfo["sessionConnectedClientData"];
+
+ int lastPeerId = -1;
+ QMap<QString, QVariant> lastPeerData;
+ for (const auto &peerData : _coreInfo["sessionConnectedClientData"].toList()) {
+ lastPeerData = peerData.toMap();
+ lastPeerId = lastPeerData["id"].toInt();
+ }
+
+ if (lastPeerId != -1) {
+ qWarning() << "Kicking client " << lastPeerId;
+ Client::kickClient(lastPeerId);
+ }
+ */
+
updateUptime();
startTimer(1000);
}
updateUptime();
startTimer(1000);
}