Skip to content

Commit

Permalink
Added missed nick attribute to mut item actor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Apr 6, 2024
1 parent 37be14e commit d8b219b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
26 changes: 13 additions & 13 deletions src/xmpp/xmpp-im/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <QList>
#include <QMap>
#include <type_traits>

#define NS_XML "http://www.w3.org/XML/1998/namespace"

Expand Down Expand Up @@ -336,7 +335,7 @@ void MUCItem::setAffiliation(Affiliation a) { affiliation_ = a; }

void MUCItem::setRole(Role r) { role_ = r; }

void MUCItem::setActor(const Jid &a) { actor_ = a; }
void MUCItem::setActor(const Actor &a) { actor_ = a; }

void MUCItem::setReason(const QString &r) { reason_ = r; }

Expand All @@ -348,7 +347,7 @@ MUCItem::Affiliation MUCItem::affiliation() const { return affiliation_; }

MUCItem::Role MUCItem::role() const { return role_; }

const Jid &MUCItem::actor() const { return actor_; }
const MUCItem::Actor &MUCItem::actor() const { return actor_; }

const QString &MUCItem::reason() const { return reason_; }

Expand Down Expand Up @@ -384,14 +383,11 @@ void MUCItem::fromXml(const QDomElement &e)
role_ = NoRole;
}

for (QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) {
QDomElement i = n.toElement();
if (i.isNull())
continue;

if (i.tagName() == QLatin1String("actor"))
actor_ = Jid(i.attribute(QLatin1String("jid")));
else if (i.tagName() == QLatin1String("reason"))
for (QDomElement i = e.firstChildElement(); !i.isNull(); i = i.nextSiblingElement()) {
if (i.tagName() == QLatin1String("actor")) {
actor_.jid = Jid(i.attribute(QLatin1String("jid")));
actor_.nick = i.attribute(QLatin1String("nick"));
} else if (i.tagName() == QLatin1String("reason"))
reason_ = i.text();
}
}
Expand Down Expand Up @@ -448,11 +444,15 @@ QDomElement MUCItem::toXml(QDomDocument &d)
return e;
}

bool MUCItem::Actor::operator==(const Actor &o) const
{
return ((!jid.isValid() && !o.jid.isValid()) || jid.compare(o.jid, true)) && (nick == o.nick);
}

bool MUCItem::operator==(const MUCItem &o) const
{
return !nick_.compare(o.nick_) && ((!jid_.isValid() && !o.jid_.isValid()) || jid_.compare(o.jid_, true))
&& ((!actor_.isValid() && !o.actor_.isValid()) || actor_.compare(o.actor_, true))
&& affiliation_ == o.affiliation_ && role_ == o.role_ && !reason_.compare(o.reason_);
&& (actor_ == o.actor_) && affiliation_ == o.affiliation_ && role_ == o.role_ && !reason_.compare(o.reason_);
}

//----------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/xmpp/xmpp-im/xmpp_ibb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
#include "xmpp_stream.h"
#include "xmpp_xmlcommon.h"

#include <QTimer>
#include <QtCrypto>
#include <qtimer.h>
#include <stdlib.h>

#define IBB_PACKET_DELAY 0

Expand Down
2 changes: 1 addition & 1 deletion src/xmpp/xmpp-im/xmpp_ibb.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class IBBData {
};

// this is an IBB connection. use it much like a qsocket
class IBBConnection : public BSConnection {
class IBBConnection final : public BSConnection {
Q_OBJECT
public:
static const int PacketSize = 4096;
Expand Down
14 changes: 11 additions & 3 deletions src/xmpp/xmpp-im/xmpp_muc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,28 @@ class MUCItem {
enum Affiliation { UnknownAffiliation, Outcast, NoAffiliation, Member, Admin, Owner };
enum Role { UnknownRole, NoRole, Visitor, Participant, Moderator };

struct Actor {
Jid jid;
QString nick;

bool operator==(const Actor &o) const;
};

MUCItem(Role = UnknownRole, Affiliation = UnknownAffiliation);
MUCItem(const QDomElement &);

void setNick(const QString &);
void setJid(const Jid &);
void setAffiliation(Affiliation);
void setRole(Role);
void setActor(const Jid &);
void setActor(const Actor &);
void setReason(const QString &);

const QString &nick() const;
const Jid &jid() const; // real jid of muc participant
Affiliation affiliation() const;
Role role() const;
const Jid &actor() const;
const Actor &actor() const;
const QString &reason() const;

void fromXml(const QDomElement &);
Expand All @@ -55,7 +62,8 @@ class MUCItem {

private:
QString nick_;
Jid jid_, actor_;
Jid jid_;
Actor actor_;
Affiliation affiliation_;
Role role_;
QString reason_;
Expand Down
6 changes: 1 addition & 5 deletions src/xmpp/xmpp-im/xmpp_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,11 +753,7 @@ bool JT_PushPresence::take(const QDomElement &e)
QByteArray::fromHex(tagContent(t).toLatin1())); // if hash is empty this may mean photo removal
// else vcard.hasPhotoHash() returns false and that's mean user is not yet ready to advertise his image
} else if (i.tagName() == "x" && i.namespaceURI() == "http://jabber.org/protocol/muc#user") {
for (QDomNode muc_n = i.firstChild(); !muc_n.isNull(); muc_n = muc_n.nextSibling()) {
QDomElement muc_e = muc_n.toElement();
if (muc_e.isNull())
continue;

for (QDomElement muc_e = i.firstChildElement(); !muc_e.isNull(); muc_e = muc_e.nextSiblingElement()) {
if (muc_e.tagName() == "item")
p.setMUCItem(MUCItem(muc_e));
else if (muc_e.tagName() == "status")
Expand Down

0 comments on commit d8b219b

Please sign in to comment.