Client node now displays in all participants and presences, some additional checkups before querying empty clients, refactoring

This commit is contained in:
Blue 2023-03-14 22:49:58 +03:00
parent 76a9c5da0c
commit 21b40a9ccb
Signed by: blue
GPG key ID: 9B203B252A63EE38
19 changed files with 407 additions and 317 deletions

View file

@ -22,10 +22,125 @@ Shared::ClientId::ClientId():
hash()
{}
Shared::ClientId::ClientId(const QString& p_node, const QString& p_ver, const QString& p_hash):
node(p_node),
verification(p_ver),
hash(p_hash)
{}
Shared::ClientId::ClientId(const Shared::ClientId& other):
node(other.node),
verification(other.verification),
hash(other.hash)
{}
Shared::ClientId & Shared::ClientId::operator=(const Shared::ClientId& other) {
node = other.node;
verification = other.verification;
hash = other.hash;
return *this;
}
bool Shared::ClientId::operator==(const Shared::ClientId& other) const {
return hash == other.hash && verification == other.verification && node == other.node;
}
bool Shared::ClientId::operator!=(const Shared::ClientId& other) const {
return hash != other.hash && verification != other.verification && node != other.node;
}
bool Shared::ClientId::operator<(const Shared::ClientId& other) const {
if (hash < other.hash)
return true;
if (hash > other.hash)
return false;
if (verification < other.verification)
return true;
if (verification > other.verification)
return false;
if (node < other.node)
return true;
return false;
}
bool Shared::ClientId::operator>(const Shared::ClientId& other) const {
if (hash > other.hash)
return true;
if (hash < other.hash)
return false;
if (verification > other.verification)
return true;
if (verification < other.verification)
return false;
if (node > other.node)
return true;
return false;
}
bool Shared::ClientId::operator<=(const Shared::ClientId& other) const {
if (hash < other.hash)
return true;
if (hash > other.hash)
return false;
if (verification < other.verification)
return true;
if (verification > other.verification)
return false;
if (node < other.node)
return true;
if (node > other.node)
return false;
return true;
}
bool Shared::ClientId::operator>=(const Shared::ClientId& other) const {
if (hash > other.hash)
return true;
if (hash < other.hash)
return false;
if (verification > other.verification)
return true;
if (verification < other.verification)
return false;
if (node > other.node)
return true;
if (node < other.node)
return false;
return true;
}
QString Shared::ClientId::getId() const {
return node + "/" + verification;
}
bool Shared::ClientId::valid() const {
return node.size() > 0 && verification.size() > 0 && hash.size() > 0;
}
QDataStream & Shared::ClientId::operator<<(QDataStream& stream) {
stream >> node;
stream >> verification;

View file

@ -25,7 +25,18 @@ namespace Shared {
class ClientId {
public:
ClientId();
ClientId(const QString& node, const QString& verification, const QString& hash);
ClientId(const ClientId& other);
ClientId& operator = (const ClientId& other);
bool operator == (const ClientId& other) const;
bool operator != (const ClientId& other) const;
bool operator < (const ClientId& other) const;
bool operator > (const ClientId& other) const;
bool operator <= (const ClientId& other) const;
bool operator >= (const ClientId& other) const;
bool valid() const;
QString getId() const;
QDataStream& operator << (QDataStream& stream);
@ -39,6 +50,8 @@ public:
}
Q_DECLARE_METATYPE(Shared::ClientId)
QDataStream& operator << (QDataStream& stream, const Shared::ClientId& info);
QDataStream& operator >> (QDataStream& stream, Shared::ClientId& info);

View file

@ -35,11 +35,22 @@ Shared::ClientInfo::ClientInfo():
id(),
specificPresence() {}
Shared::ClientInfo::ClientInfo(const QString& p_node, const QString& p_ver, const QString& p_hash) :
identities(),
extensions(),
id(p_node, p_ver, p_hash),
specificPresence() {}
Shared::ClientInfo::ClientInfo(const Shared::ClientId& p_id) :
identities(),
extensions(),
id(p_id),
specificPresence() {}
QString Shared::ClientInfo::getId() const {
return id.getId();
}
QDataStream & Shared::ClientInfo::operator >> (QDataStream& stream) const {
stream << id;
stream << (quint8)identities.size();

View file

@ -31,6 +31,8 @@ namespace Shared {
class ClientInfo {
public:
ClientInfo();
ClientInfo(const ClientId& id);
ClientInfo(const QString& node, const QString& verification, const QString& hash);
QString getId() const;
bool valid() const;