Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mam in progress #59

Merged
merged 20 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ object_script.*
/bin
/lib
/plugins
*.user*
build-*
*.pro.user*
3rdparty/qca
1 change: 1 addition & 0 deletions include/iris/xmpp_carbons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_carbons.h"
1 change: 1 addition & 0 deletions include/iris/xmpp_forwarding.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_forwarding.h"
1 change: 1 addition & 0 deletions include/iris/xmpp_mammanager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "xmpp/xmpp-im/xmpp_mammanager.h"
1 change: 1 addition & 0 deletions include/iris/xmpp_mamtask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "xmpp/xmpp-im/xmpp_mamtask.h"
8 changes: 8 additions & 0 deletions src/xmpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ set(XMPP_IM_HEADERS
xmpp-im/xmpp_thumbs.h
xmpp-im/xmpp_agentitem.h
xmpp-im/xmpp_captcha.h
xmpp-im/xmpp_carbons.h
xmpp-im/xmpp_chatstate.h
xmpp-im/xmpp_discoitem.h
xmpp-im/xmpp_features.h
xmpp-im/xmpp_form.h
xmpp-im/xmpp_forwarding.h
xmpp-im/xmpp_htmlelement.h
xmpp-im/xmpp_httpauthrequest.h
xmpp-im/xmpp_liveroster.h
Expand Down Expand Up @@ -69,6 +71,8 @@ set(XMPP_IM_HEADERS
xmpp-im/xmpp_bytestream.h
xmpp-im/xmpp_client.h
xmpp-im/xmpp_discoinfotask.h
xmpp-im/xmpp_mamtask.h
xmpp-im/xmpp_mammanager.h
xmpp-im/xmpp_ibb.h
xmpp-im/xmpp_serverinfomanager.h
xmpp-im/xmpp_task.h
Expand Down Expand Up @@ -121,10 +125,14 @@ target_sources(iris PRIVATE
xmpp-im/xmpp_bitsofbinary.cpp
xmpp-im/xmpp_bytestream.cpp
xmpp-im/xmpp_caps.cpp
xmpp-im/xmpp_carbons.cpp
xmpp-im/xmpp_discoinfotask.cpp
xmpp-im/xmpp_discoitem.cpp
xmpp-im/xmpp_hash.cpp
xmpp-im/xmpp_ibb.cpp
xmpp-im/xmpp_forwarding.cpp
xmpp-im/xmpp_mamtask.cpp
xmpp-im/xmpp_mammanager.cpp
xmpp-im/xmpp_reference.cpp
xmpp-im/xmpp_serverinfomanager.cpp
xmpp-im/xmpp_subsets.cpp
Expand Down
12 changes: 10 additions & 2 deletions src/xmpp/xmpp-im/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#include "xmpp/xmpp-core/protocol.h"
#include "xmpp_bitsofbinary.h"
#include "xmpp_caps.h"
#include "xmpp_carbons.h"
#include "xmpp_externalservicediscovery.h"
#include "xmpp_hash.h"
#include "xmpp_ibb.h"
Expand Down Expand Up @@ -134,6 +135,7 @@ class Client::ClientPrivate {
LiveRoster roster;
ResourceList resourceList;
CapsManager *capsman = nullptr;
CarbonsManager *carbonsman = nullptr;
TcpPortReserver *tcpPortReserver = nullptr;
S5BManager *s5bman = nullptr;
Jingle::S5B::Manager *jingleS5BManager = nullptr;
Expand All @@ -149,6 +151,7 @@ class Client::ClientPrivate {
Jingle::Manager *jingleManager = nullptr;
QList<GroupChat> groupChatList;
EncryptionHandler *encryptionHandler = nullptr;
JT_PushMessage *pushMessage = nullptr;
};

Client::Client(QObject *par) : QObject(par)
Expand Down Expand Up @@ -237,8 +240,9 @@ void Client::start(const QString &host, const QString &user, const QString &pass
connect(pp, SIGNAL(subscription(Jid, QString, QString)), SLOT(ppSubscription(Jid, QString, QString)));
connect(pp, SIGNAL(presence(Jid, Status)), SLOT(ppPresence(Jid, Status)));

JT_PushMessage *pm = new JT_PushMessage(rootTask(), d->encryptionHandler);
connect(pm, SIGNAL(message(Message)), SLOT(pmMessage(Message)));
d->pushMessage = new JT_PushMessage(rootTask(), d->encryptionHandler);
connect(d->pushMessage, SIGNAL(message(Message)), SLOT(pmMessage(Message)));
d->carbonsman = new CarbonsManager(d->pushMessage);

JT_PushRoster *pr = new JT_PushRoster(rootTask());
connect(pr, SIGNAL(roster(Roster)), SLOT(prRoster(Roster)));
Expand Down Expand Up @@ -305,6 +309,10 @@ Jingle::Manager *Client::jingleManager() const { return d->jingleManager; }

bool Client::isActive() const { return d->active; }

CarbonsManager *Client::carbonsManager() const { return d->carbonsman; }

JT_PushMessage *Client::pushMessage() const { return d->pushMessage; }

QString Client::groupChatPassword(const QString &host, const QString &room) const
{
Jid jid(room + "@" + host);
Expand Down
56 changes: 44 additions & 12 deletions src/xmpp/xmpp-im/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include "xmpp/xmpp-core/protocol.h"
#include "xmpp_bitsofbinary.h"
#include "xmpp_captcha.h"
#include "xmpp_carbons.h"
#include "xmpp_features.h"
#include "xmpp_forwarding.h"
#include "xmpp_ibb.h"
#include "xmpp_reference.h"
#include "xmpp_xmlcommon.h"
Expand Down Expand Up @@ -732,7 +734,6 @@ class Message::Private : public QSharedData {
QMap<QString, HTMLElement> htmlElements;
QDomElement sxe;
QList<BoBData> bobDataList;
Jid forwardedFrom;

QList<int> mucStatuses;
QList<MUCInvite> mucInvites;
Expand All @@ -743,14 +744,14 @@ class Message::Private : public QSharedData {
bool spooled = false, wasEncrypted = false;

// XEP-0280 Message Carbons
bool isDisabledCarbons = false;
Message::CarbonDir carbonDir = Message::NoCarbon; // it's a forwarded message
bool carbonsPrivate = false;
Message::ProcessingHints processingHints;
QString replaceId;
QString originId; // XEP-0359
QString encryptionProtocol; // XEP-0380
Message::StanzaId stanzaId; // XEP-0359
QList<Reference> references; // XEP-0385 and XEP-0372
Forwarding forwarding; // XEP-0297
Message::Reactions reactions; // XEP-0444
QString retraction; // XEP-0424
};
Expand Down Expand Up @@ -1134,17 +1135,44 @@ QList<BoBData> Message::bobDataList() const { return d ? d->bobDataList : QList<

IBBData Message::ibbData() const { return d ? d->ibbData : IBBData(); }

void Message::setDisabledCarbons(bool disabled) { MessageD()->isDisabledCarbons = disabled; }
//! \brief Returns Jid of the remote contact
//!
//! Returns Jid of the remote contact for the original message
//! which may be wrapped using carbons. It is useful when a client
//! needs to know in which window it should display the message.
//! So it is not always just from().
Jid Message::displayJid() const
liuch marked this conversation as resolved.
Show resolved Hide resolved
{
if (!d)
return Jid();

switch (d->forwarding.type()) {
case Forwarding::ForwardedCarbonsSent:
return d->forwarding.message().to();
case Forwarding::ForwardedCarbonsReceived:
return d->forwarding.message().from();
default:
break;
}
return from();
}

//! \brief Returns either the message inside the carbons or itself.
Message Message::displayMessage() const
{
if (d && d->forwarding.isCarbons())
return d->forwarding.message();

bool Message::isDisabledCarbons() const { return d && d->isDisabledCarbons; }
return *this;
}

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

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

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

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

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

Expand Down Expand Up @@ -1400,10 +1428,10 @@ Stanza Message::toStanza(Stream *stream) const
}

// Avoiding Carbons
if (isDisabledCarbons()) {
QDomElement e = s.createElement("urn:xmpp:carbons:2", "private");
s.appendChild(e);
if (d->carbonsPrivate) {
s.appendChild(CarbonsManager::privateElement(stream->doc()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to xep 280, a private stanza also need a <no-copy/> node.

}

if (!d->replaceId.isEmpty()) {
QDomElement e = s.createElement("urn:xmpp:message-correct:0", "replace");
e.setAttribute("id", d->replaceId);
Expand Down Expand Up @@ -1440,6 +1468,10 @@ Stanza Message::toStanza(Stream *stream) const
s.appendChild(e);
}

// XEP-0297: Stanza Forwarding
if (d->forwarding.type() != Forwarding::ForwardedNone)
s.appendChild(d->forwarding.toXml(stream));

// XEP-0372 and XEP-0385
for (auto const &r : std::as_const(d->references)) {
s.appendChild(r.toXml(&s.doc()));
Expand Down
Loading
Loading