X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fpeer.cpp;h=e352441c71465c6d6a8124dcd1f48f592a98f19e;hp=3785326cc106f7f61d13b0afb6d9d487854a2699;hb=c0d6dc0dec628f2e143e37ecc95cec45e636f8a5;hpb=d0e9b7a1d5e73041ade519189eea012500440ba9 diff --git a/src/common/peer.cpp b/src/common/peer.cpp index 3785326c..e352441c 100644 --- a/src/common/peer.cpp +++ b/src/common/peer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,34 +20,88 @@ #include "peer.h" -Peer::Peer(AuthHandler *authHandler, QObject *parent) +Peer::Peer(AuthHandler* authHandler, QObject* parent) : QObject(parent) , _authHandler(authHandler) +{} + +AuthHandler* Peer::authHandler() const { + return _authHandler; +} +QDateTime Peer::connectedSince() const +{ + return _connectedSince; } +void Peer::setConnectedSince(const QDateTime& connectedSince) +{ + _connectedSince = connectedSince; +} -AuthHandler *Peer::authHandler() const +QString Peer::buildDate() const { - return _authHandler; + return _buildDate; +} + +void Peer::setBuildDate(const QString& buildDate) +{ + _buildDate = buildDate; +} + +QString Peer::clientVersion() const +{ + return _clientVersion; +} + +void Peer::setClientVersion(const QString& clientVersion) +{ + _clientVersion = clientVersion; +} + +bool Peer::hasFeature(Quassel::Feature feature) const +{ + return _features.isEnabled(feature); } +Quassel::Features Peer::features() const +{ + return _features; +} + +void Peer::setFeatures(Quassel::Features features) +{ + _features = std::move(features); +} + +int Peer::id() const +{ + return _id; +} + +void Peer::setId(int id) +{ + _id = id; +} -// Note that we need to use a fixed-size integer instead of uintptr_t, in order -// to avoid issues with different architectures for client and core. -// In practice, we'll never really have to restore the real value of a PeerPtr from -// a QVariant. -QDataStream &operator<<(QDataStream &out, PeerPtr ptr) +// PeerPtr is used in RPC signatures for enabling receivers to send replies +// to a particular peer rather than broadcast to all connected ones. +// To enable this, the SignalProxy transparently replaces the bogus value +// received over the network with the actual address of the local Peer +// instance. Because the actual value isn't needed on the wire, it is +// serialized as null. +QDataStream& operator<<(QDataStream& out, PeerPtr ptr) { - out << reinterpret_cast(ptr); + Q_UNUSED(ptr); + out << static_cast(0); // 64 bit for historic reasons return out; } -QDataStream &operator>>(QDataStream &in, PeerPtr &ptr) +QDataStream& operator>>(QDataStream& in, PeerPtr& ptr) { + ptr = nullptr; quint64 value; in >> value; - ptr = reinterpret_cast(value); return in; }