transition to QXMppCarbonManagerV2 if QXmpp version is heigher than 1.5.0

This commit is contained in:
Blue 2023-03-12 01:38:54 +03:00
parent 4b68da458f
commit 8ec0af3205
Signed by: blue
GPG Key ID: 9B203B252A63EE38
5 changed files with 28 additions and 2 deletions

View File

@ -42,7 +42,11 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
tm(new QXmppTrustManager(th)),
om(new QXmppOmemoManager(oh)),
#endif
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0)
cm(new QXmppCarbonManagerV2()),
#else
cm(new QXmppCarbonManager()),
#endif
am(new QXmppMamManager()),
mm(new QXmppMucManager()),
bm(new QXmppBookmarkManager()),
@ -86,8 +90,10 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
client.addExtension(cm);
#if (QXMPP_VERSION) < QT_VERSION_CHECK(1, 5, 0)
QObject::connect(cm, &QXmppCarbonManager::messageReceived, mh, &MessageHandler::onCarbonMessageReceived);
QObject::connect(cm, &QXmppCarbonManager::messageSent, mh, &MessageHandler::onCarbonMessageSent);
#endif
client.addExtension(am);
@ -653,7 +659,9 @@ void Core::Account::setPepSupport(Shared::Support support) {
void Core::Account::handleDisconnection() {
setPepSupport(Shared::Support::unknown);
delay->disconnected();
#if (QXMPP_VERSION) < QT_VERSION_CHECK(1, 5, 0)
cm->setCarbonsEnabled(false);
#endif
rh->handleOffline();
archiveQueries.clear();
}

View File

@ -32,7 +32,11 @@
#include <list>
#include <QXmppRosterManager.h>
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0)
#include <QXmppCarbonManagerV2.h>
#else
#include <QXmppCarbonManager.h>
#endif
#include <QXmppDiscoveryManager.h>
#include <QXmppMamManager.h>
#include <QXmppMucManager.h>
@ -193,7 +197,11 @@ private:
QXmppTrustManager* tm;
QXmppOmemoManager* om;
#endif
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0)
QXmppCarbonManagerV2* cm;
#else
QXmppCarbonManager* cm;
#endif
QXmppMamManager* am;
QXmppMucManager* mm;
QXmppBookmarkManager* bm;

View File

@ -79,7 +79,9 @@ void Core::DiscoveryHandler::onInfoReceived(const QXmppDiscoveryIq& info)
if (enableCC) {
qDebug() << "Enabling carbon copies for account" << accName;
#if (QXMPP_VERSION) < QT_VERSION_CHECK(1, 5, 0)
acc->cm->setCarbonsEnabled(true);
#endif
#ifdef WITH_OMEMO
if (!omemoToCarbonsConnected && acc->oh->hasOwnDevice()) {
// connect(this, &QXmppCarbonManager::messageSent, acc->om, &QXmppOmemoManager::handleMessage);

View File

@ -64,7 +64,11 @@ void Core::MessageHandler::onMessageReceived(const QXmppMessage& msg)
qDebug() << "received a message with type \"Normal\", not sure what to do with it now, skipping";
break;
case QXmppMessage::Chat:
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0)
handled = handleChatMessage(msg, false, msg.isCarbonForwarded(), true);
#else
handled = handleChatMessage(msg);
#endif
break;
case QXmppMessage::GroupChat:
handled = handleGroupMessage(msg);
@ -109,8 +113,8 @@ bool Core::MessageHandler::handleChatMessage(const QXmppMessage& msg, bool outgo
cnt = acc->rh->addOutOfRosterContact(jid);
qDebug() << "appending message" << sMsg.getId() << "to an out of roster contact";
}
if (outgoing) {
if (forwarded) {
if (sMsg.getOutgoing()) {
if (sMsg.getForwarded()) {
sMsg.setState(Shared::Message::State::sent);
}
} else {
@ -242,6 +246,7 @@ void Core::MessageHandler::logMessage(const QXmppMessage& msg, const QString& re
qDebug() << "==============================";
}
#if (QXMPP_VERSION) < QT_VERSION_CHECK(1, 5, 0)
void Core::MessageHandler::onCarbonMessageReceived(const QXmppMessage& msg)
{
handleChatMessage(msg, false, true);
@ -251,6 +256,7 @@ void Core::MessageHandler::onCarbonMessageSent(const QXmppMessage& msg)
{
handleChatMessage(msg, true, true);
}
#endif
std::tuple<bool, QString, QString> Core::MessageHandler::getOriginalPendingMessageId(const QString& id)
{

View File

@ -52,8 +52,10 @@ public:
public slots:
void onMessageReceived(const QXmppMessage& message);
#if (QXMPP_VERSION) < QT_VERSION_CHECK(1, 5, 0)
void onCarbonMessageReceived(const QXmppMessage& message);
void onCarbonMessageSent(const QXmppMessage& message);
#endif
void onReceiptReceived(const QString& jid, const QString& id);
void onUploadSlotReceived(const QXmppHttpUploadSlotIq& slot);
void onUploadSlotRequestFailed(const QXmppHttpUploadRequestIq& request);