- Make Peer::_connectedSince, Peer::_buildDate, Peer::_clientVersion
private, add getters/setters
- Correct parameter naming in doxygen comment for
SignalProxy::restrictTargetPeers
- Remove SignalProxy::_peers
- Initialize SignalProxy::_sourcePeer to nullptr
- Add Q_UNUSED for peer parameter for CoreSession::changePassword
- Correct indentation in src/qtui/CMakeLists
- Use pragma in src/qtui/coresessionwidget.h
- Fix header ordering in src/qtui/coresessionwidget.h
- Fix header ordering in src/qtui/coresessionwidget.cpp
+const QDateTime &Peer::connectedSince() const {
+ return _connectedSince;
+}
+
+void Peer::setConnectedSince(const QDateTime &connectedSince) {
+ _connectedSince = connectedSince;
+}
+
+const QString &Peer::buildDate() const {
+ return _buildDate;
+}
+
+void Peer::setBuildDate(const QString &buildDate) {
+ _buildDate = buildDate;
+}
+
+const QString &Peer::clientVersion() const {
+ return _clientVersion;
+}
+
+void Peer::setClientVersion(const QString &clientVersion) {
+ _clientVersion = clientVersion;
+}
+
+int Peer::id() const {
+ return _id;
+}
+
+void Peer::setId(int id) {
+ _id = id;
+}
// PeerPtr is used in RPC signatures for enabling receivers to send replies
// to a particular peer rather than broadcast to all connected ones.
// PeerPtr is used in RPC signatures for enabling receivers to send replies
// to a particular peer rather than broadcast to all connected ones.
- Peer(AuthHandler *authHandler, QObject *parent = 0);
+ explicit Peer(AuthHandler *authHandler, QObject *parent = 0);
virtual Protocol::Type protocol() const = 0;
virtual QString description() const = 0;
virtual Protocol::Type protocol() const = 0;
virtual QString description() const = 0;
virtual SignalProxy *signalProxy() const = 0;
virtual void setSignalProxy(SignalProxy *proxy) = 0;
virtual SignalProxy *signalProxy() const = 0;
virtual void setSignalProxy(SignalProxy *proxy) = 0;
+ const QDateTime &connectedSince() const;
+ void setConnectedSince(const QDateTime &connectedSince);
+
+ const QString &buildDate() const;
+ void setBuildDate(const QString &buildDate);
+
+ const QString &clientVersion() const;
+ void setClientVersion(const QString &clientVersion);
+
+ int id() const;
+ void setId(int id);
+
AuthHandler *authHandler() const;
virtual bool isOpen() const = 0;
AuthHandler *authHandler() const;
virtual bool isOpen() const = 0;
virtual QString address() const = 0;
virtual quint16 port() const = 0;
virtual QString address() const = 0;
virtual quint16 port() const = 0;
- int _id = -1;
-
- QDateTime _connectedSince;
- 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;
private:
QPointer<AuthHandler> _authHandler;
private:
QPointer<AuthHandler> _authHandler;
+
+ QDateTime _connectedSince;
+
+ QString _buildDate;
+ QString _clientVersion;
+
+ int _id = -1;
};
// We need to special-case Peer* in attached signals/slots, so typedef it for the meta type system
};
// We need to special-case Peer* in attached signals/slots, so typedef it for the meta type system
void SignalProxy::setProxyMode(ProxyMode mode)
{
void SignalProxy::setProxyMode(ProxyMode mode)
{
+ if (!_peerMap.empty()) {
qWarning() << Q_FUNC_INFO << "Cannot change proxy mode while connected";
return;
}
qWarning() << Q_FUNC_INFO << "Cannot change proxy mode while connected";
return;
}
- if (_peers.contains(peer))
+ if (_peerMap.values().contains(peer))
return true;
if (!peer->isOpen()) {
return true;
if (!peer->isOpen()) {
}
if (proxyMode() == Client) {
}
if (proxyMode() == Client) {
- if (!_peers.isEmpty()) {
+ if (!_peerMap.isEmpty()) {
qWarning("SignalProxy: only one peer allowed in client mode!");
return false;
}
qWarning("SignalProxy: only one peer allowed in client mode!");
return false;
}
if (!peer->parent())
peer->setParent(this);
if (!peer->parent())
peer->setParent(this);
- if (peer->_id < 0) {
- peer->_id = nextPeerId();
- peer->_connectedSince = QDateTime::currentDateTimeUtc();
+ if (peer->id() < 0) {
+ peer->setId(nextPeerId());
+ peer->setConnectedSince(QDateTime::currentDateTimeUtc());
- _peers.insert(peer);
- _peerMap[peer->_id] = peer;
+ _peerMap[peer->id()] = peer;
peer->setSignalProxy(this);
peer->setSignalProxy(this);
- if (_peers.count() == 1)
emit connected();
updateSecureState();
emit connected();
updateSecureState();
void SignalProxy::removeAllPeers()
{
void SignalProxy::removeAllPeers()
{
- Q_ASSERT(proxyMode() == Server || _peers.count() <= 1);
+ Q_ASSERT(proxyMode() == Server || peerCount() <= 1);
// wee need to copy that list since we modify it in the loop
// wee need to copy that list since we modify it in the loop
- QSet<Peer *> peers = _peers;
- foreach(Peer *peer, peers) {
+ QList<Peer *> peers = _peerMap.values();
+ for (auto peer : peers) {
- if (_peers.isEmpty()) {
+ if (_peerMap.isEmpty()) {
qWarning() << "SignalProxy::removePeer(): No peers in use!";
return;
}
qWarning() << "SignalProxy::removePeer(): No peers in use!";
return;
}
- if (!_peers.contains(peer)) {
+ if (!_peerMap.values().contains(peer)) {
qWarning() << "SignalProxy: unknown Peer" << peer;
return;
}
qWarning() << "SignalProxy: unknown Peer" << peer;
return;
}
disconnect(peer, 0, this, 0);
peer->setSignalProxy(0);
disconnect(peer, 0, this, 0);
peer->setSignalProxy(0);
- _peerMap.remove(peer->_id);
- _peers.remove(peer);
+ _peerMap.remove(peer->id());
emit peerRemoved(peer);
if (peer->parent() == this)
emit peerRemoved(peer);
if (peer->parent() == this)
+ if (_peerMap.isEmpty())
template<class T>
void SignalProxy::dispatch(const T &protoMessage)
{
template<class T>
void SignalProxy::dispatch(const T &protoMessage)
{
- foreach (Peer *peer, _peers) {
+ for (auto peer : _peerMap.values()) {
if (peer->isOpen())
peer->dispatch(protoMessage);
else
if (peer->isOpen())
peer->dispatch(protoMessage);
else
{
bool wasSecure = _secure;
{
bool wasSecure = _secure;
- _secure = !_peers.isEmpty();
- foreach (const Peer *peer, _peers) {
+ _secure = !_peerMap.isEmpty();
+ for (auto peer : _peerMap.values()) {
_secure &= peer->isSecure();
}
_secure &= peer->isSecure();
}
QVariantList SignalProxy::peerData() {
QVariantList result;
QVariantList SignalProxy::peerData() {
QVariantList result;
- for (auto peer : _peers) {
+ for (auto peer : _peerMap.values()) {
- data["id"] = peer->_id;
- data["clientVersion"] = peer->_clientVersion;
+ data["id"] = peer->id();
+ data["clientVersion"] = peer->clientVersion();
// We explicitly rename this, as, due to the Debian reproducability changes, buildDate isn’t actually the build
// date anymore, but on newer clients the date of the last git commit
// We explicitly rename this, as, due to the Debian reproducability changes, buildDate isn’t actually the build
// date anymore, but on newer clients the date of the last git commit
- data["clientVersionDate"] = peer->_buildDate;
+ data["clientVersionDate"] = peer->buildDate();
data["remoteAddress"] = peer->address();
data["remoteAddress"] = peer->address();
- data["connectedSince"] = peer->_connectedSince;
+ data["connectedSince"] = peer->connectedSince();
data["secure"] = peer->isSecure();
result << data;
}
data["secure"] = peer->isSecure();
result << data;
}
/**@{*/
/**
* This method allows to send a signal only to a limited set of peers
/**@{*/
/**
* This method allows to send a signal only to a limited set of peers
- * @param peerIds A list of peers that should receive it
+ * @param peers A list of peers that should receive it
* @param closure Code you want to execute within of that restricted environment
*/
void restrictTargetPeers(QSet<Peer*> peers, std::function<void()> closure);
* @param closure Code you want to execute within of that restricted environment
*/
void restrictTargetPeers(QSet<Peer*> peers, std::function<void()> closure);
- inline int peerCount() const { return _peers.size(); }
+ inline int peerCount() const { return _peerMap.size(); }
QVariantList peerData();
Peer *peerById(int peerId);
QVariantList peerData();
Peer *peerById(int peerId);
static void disconnectDevice(QIODevice *dev, const QString &reason = QString());
static void disconnectDevice(QIODevice *dev, const QString &reason = QString());
QHash<int, Peer*> _peerMap;
// containg a list of argtypes for fast access
QHash<int, Peer*> _peerMap;
// containg a list of argtypes for fast access
QSet<Peer *> _restrictedTargets;
bool _restrictMessageTarget = false;
QSet<Peer *> _restrictedTargets;
bool _restrictMessageTarget = false;
+ Peer *_sourcePeer = nullptr;
friend class SignalRelay;
friend class SyncableObject;
friend class SignalRelay;
friend class SyncableObject;
// 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;
+ _peer->setBuildDate(msg.buildDate);
+ _peer->setClientVersion(msg.clientVersion);
if (_legacy && useSsl)
startSsl();
if (_legacy && useSsl)
startSsl();
-void CoreSession::changePassword(PeerPtr peer, const QString &userName, const QString &oldPassword, const QString &newPassword)
-{
+void CoreSession::changePassword(PeerPtr peer, const QString &userName, const QString &oldPassword, const QString &newPassword) {
+ Q_UNUSED(peer);
+
bool success = false;
UserId uid = Core::validateUser(userName, oldPassword);
if (uid.isValid() && uid == user())
bool success = false;
UserId uid = Core::validateUser(userName, oldPassword);
if (uid.isValid() && uid == user())
coreconfigwizardsyncpage.ui
coreconnectauthdlg.ui
coreconnectionstatuswidget.ui
coreconfigwizardsyncpage.ui
coreconnectauthdlg.ui
coreconnectionstatuswidget.ui
debugbufferviewoverlay.ui
debugconsole.ui
debuglogwidget.ui
debugbufferviewoverlay.ui
debugconsole.ui
debuglogwidget.ui
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
+#include <QDateTime>
+
+#include "client.h"
#include "coresessionwidget.h"
#include "coresessionwidget.h"
-#include <QtCore/QDateTime>
-#include <client.h>
CoreSessionWidget::CoreSessionWidget(QWidget *parent)
CoreSessionWidget::CoreSessionWidget(QWidget *parent)
void CoreSessionWidget::setData(QMap<QString, QVariant> map)
{
QLabel *iconSecure = ui.iconSecure;
void CoreSessionWidget::setData(QMap<QString, QVariant> map)
{
QLabel *iconSecure = ui.iconSecure;
+ // TODO: Implement "secure" icon
+ Q_UNUSED(iconSecure);
ui.labelRemoteAddress->setText(map["remoteAddress"].toString());
ui.labelLocation->setText(map["location"].toString());
ui.labelRemoteAddress->setText(map["remoteAddress"].toString());
ui.labelLocation->setText(map["location"].toString());
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef CORESESSIONWIDGET_H
-#define CORESESSIONWIDGET_H
-
-#include <QWidget>
-#include <ui_coresessionwidget.h>
+#include <QWidget>
+
+#include "ui_coresessionwidget.h"
class CoreSessionWidget: public QWidget
{
class CoreSessionWidget: public QWidget
{
Ui::CoreSessionWidget ui;
int _peerId;
};
Ui::CoreSessionWidget ui;
int _peerId;
};
-
-#endif //CORESESSIONWIDGET_H