Skip to content

Commit

Permalink
Build fixes after master merging
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Apr 10, 2024
1 parent debfd4b commit 635c56b
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 346 deletions.
8 changes: 0 additions & 8 deletions src/xmpp/xmpp-im/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,14 +1140,6 @@ void Message::setForwarded(const Forwarding &frw) { MessageD()->forwarding = frw

const Forwarding &Message::forwarded() const { return d->forwarding; }

void Message::setCarbonDirection(Message::CarbonDir cd) { MessageD()->carbonDir = cd; }

Message::CarbonDir Message::carbonDirection() const { return d ? d->carbonDir : NoCarbon; }

void Message::setForwardedFrom(const Jid &jid) { MessageD()->forwardedFrom = jid; }

Jid Message::forwardedFrom() const { return d ? d->forwardedFrom : Jid(); }

bool Message::spooled() const { return d && d->spooled; }

void Message::setSpooled(bool b) { MessageD()->spooled = b; }
Expand Down
100 changes: 48 additions & 52 deletions src/xmpp/xmpp-im/xmpp_carbons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,27 @@
#include <QDomElement>

#include "xmpp_carbons.h"
#include "xmpp_xmlcommon.h"
#include "xmpp_message.h"
#include "xmpp_client.h"
#include "xmpp_forwarding.h"
#include "xmpp_message.h"
#include "xmpp_task.h"
#include "xmpp_tasks.h"
#include "xmpp_xmlcommon.h"

namespace XMPP
{
namespace XMPP {

static const QString xmlns_carbons(QStringLiteral("urn:xmpp:carbons:2"));


class CarbonsSubscriber : public JT_PushMessage::Subscriber
{
class CarbonsSubscriber : public JT_PushMessage::Subscriber {
public:
bool xmlEvent(const QDomElement &root, QDomElement &e, Client *client, int userData, bool nested) override;
bool messageEvent(Message &msg, int userData, bool nested) override;
bool xmlEvent(const QDomElement &root, QDomElement &e, Client *client, int userData, bool nested) override;
bool messageEvent(Message &msg, int userData, bool nested) override;

private:
Forwarding frw;
Forwarding frw;
};

class JT_MessageCarbons : public Task
{
class JT_MessageCarbons : public Task {
Q_OBJECT

public:
Expand All @@ -63,22 +60,19 @@ class JT_MessageCarbons : public Task
//----------------------------------------------------------------------------
// JT_MessageCarbons
//----------------------------------------------------------------------------
JT_MessageCarbons::JT_MessageCarbons(Task *parent)
: Task(parent)
{
}
JT_MessageCarbons::JT_MessageCarbons(Task *parent) : Task(parent) { }

void JT_MessageCarbons::enable()
{
iq = createIQ(doc(), QString::fromLatin1("set"), QString(), id());
iq = createIQ(doc(), QString::fromLatin1("set"), QString(), id());
QDomElement enable = doc()->createElement(QString::fromLatin1("enable"));
enable.setAttribute(QString::fromLatin1("xmlns"), xmlns_carbons);
iq.appendChild(enable);
}

void JT_MessageCarbons::disable()
{
iq = createIQ(doc(), QString::fromLatin1("set"), QString(), id());
iq = createIQ(doc(), QString::fromLatin1("set"), QString(), id());
QDomElement disable = doc()->createElement(QString::fromLatin1("disable"));
disable.setAttribute(QString::fromLatin1("xmlns"), xmlns_carbons);
iq.appendChild(disable);
Expand Down Expand Up @@ -122,8 +116,7 @@ bool CarbonsSubscriber::xmlEvent(const QDomElement &root, QDomElement &e, Client
}
child = child.nextSiblingElement();
}
}
else
} else
drop = true;
e = QDomElement();
}
Expand All @@ -146,39 +139,39 @@ bool CarbonsSubscriber::messageEvent(Message &msg, int userData, bool nested)

class CarbonsManager::Private {
public:
~Private() {
// if (sbs.get())
// unsubscribe();
~Private()
{
// if (sbs.get())
// unsubscribe();
}

void subscribe() {
push_m->subscribeXml(sbs.get(), QString::fromLatin1("received"), xmlns_carbons, Forwarding::ForwardedCarbonsReceived);
void subscribe()
{
push_m->subscribeXml(sbs.get(), QString::fromLatin1("received"), xmlns_carbons,
Forwarding::ForwardedCarbonsReceived);
push_m->subscribeXml(sbs.get(), QString::fromLatin1("sent"), xmlns_carbons, Forwarding::ForwardedCarbonsSent);
push_m->subscribeMessage(sbs.get(), 0);
}

void unsubscribe() {
void unsubscribe()
{
push_m->unsubscribeXml(sbs.get(), QString::fromLatin1("received"), xmlns_carbons);
push_m->unsubscribeXml(sbs.get(), QString::fromLatin1("sent"), xmlns_carbons);
push_m->unsubscribeMessage(sbs.get());
}

JT_PushMessage *push_m;
JT_PushMessage *push_m;
std::unique_ptr<CarbonsSubscriber> sbs;
bool enable = false;
bool enable = false;
};

CarbonsManager::CarbonsManager(JT_PushMessage *push_m)
: QObject(push_m)
, d(new Private)
CarbonsManager::CarbonsManager(JT_PushMessage *push_m) : QObject(push_m), d(new Private)
{
d->push_m = push_m;
d->sbs.reset(new CarbonsSubscriber());
}

CarbonsManager::~CarbonsManager()
{
}
CarbonsManager::~CarbonsManager() { }

QDomElement CarbonsManager::privateElement(QDomDocument &doc)
{
Expand All @@ -193,32 +186,35 @@ void CarbonsManager::setEnabled(bool enable)
if (enable) {
d->subscribe();
JT_MessageCarbons *jt = new JT_MessageCarbons(d->push_m->client()->rootTask());
connect(jt, &JT_MessageCarbons::finished, this, [=]() {
if (jt->success())
d->enable = true;
else
d->unsubscribe();
emit finished();
}, Qt::QueuedConnection);
connect(
jt, &JT_MessageCarbons::finished, this,
[=]() {
if (jt->success())
d->enable = true;
else
d->unsubscribe();
emit finished();
},
Qt::QueuedConnection);
jt->enable();
jt->go(true);
}
else {
} else {
JT_MessageCarbons *jt = new JT_MessageCarbons(d->push_m->client()->rootTask());
connect(jt, &JT_MessageCarbons::finished, this, [=]() {
d->enable = false;
d->unsubscribe();
emit finished();
}, Qt::QueuedConnection);
connect(
jt, &JT_MessageCarbons::finished, this,
[=]() {
d->enable = false;
d->unsubscribe();
emit finished();
},
Qt::QueuedConnection);
jt->disable();
jt->go(true);
}
}

bool CarbonsManager::isEnabled() const {
return d->enable;
}
bool CarbonsManager::isEnabled() const { return d->enable; }

} //namespace XMPP
} // namespace XMPP

#include "xmpp_carbons.moc"
Loading

0 comments on commit 635c56b

Please sign in to comment.