diff --git a/core/account.cpp b/core/account.cpp index c27f2ea..a0b7311 100644 --- a/core/account.cpp +++ b/core/account.cpp @@ -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(); } diff --git a/core/account.h b/core/account.h index e18966d..58ff9b5 100644 --- a/core/account.h +++ b/core/account.h @@ -32,7 +32,11 @@ #include #include +#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0) +#include +#else #include +#endif #include #include #include @@ -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; diff --git a/core/handlers/discoveryhandler.cpp b/core/handlers/discoveryhandler.cpp index 977dda2..6ed06c6 100644 --- a/core/handlers/discoveryhandler.cpp +++ b/core/handlers/discoveryhandler.cpp @@ -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); diff --git a/core/handlers/messagehandler.cpp b/core/handlers/messagehandler.cpp index b11ea2a..2c5b16d 100644 --- a/core/handlers/messagehandler.cpp +++ b/core/handlers/messagehandler.cpp @@ -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 Core::MessageHandler::getOriginalPendingMessageId(const QString& id) { diff --git a/core/handlers/messagehandler.h b/core/handlers/messagehandler.h index 1ab2d0d..a08fee8 100644 --- a/core/handlers/messagehandler.h +++ b/core/handlers/messagehandler.h @@ -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);