1
0
forked from blue/squawk

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

View File

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

View File

@ -79,7 +79,9 @@ void Core::DiscoveryHandler::onInfoReceived(const QXmppDiscoveryIq& info)
if (enableCC) { if (enableCC) {
qDebug() << "Enabling carbon copies for account" << accName; qDebug() << "Enabling carbon copies for account" << accName;
#if (QXMPP_VERSION) < QT_VERSION_CHECK(1, 5, 0)
acc->cm->setCarbonsEnabled(true); acc->cm->setCarbonsEnabled(true);
#endif
#ifdef WITH_OMEMO #ifdef WITH_OMEMO
if (!omemoToCarbonsConnected && acc->oh->hasOwnDevice()) { if (!omemoToCarbonsConnected && acc->oh->hasOwnDevice()) {
// connect(this, &QXmppCarbonManager::messageSent, acc->om, &QXmppOmemoManager::handleMessage); // 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"; qDebug() << "received a message with type \"Normal\", not sure what to do with it now, skipping";
break; break;
case QXmppMessage::Chat: case QXmppMessage::Chat:
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0)
handled = handleChatMessage(msg, false, msg.isCarbonForwarded(), true);
#else
handled = handleChatMessage(msg); handled = handleChatMessage(msg);
#endif
break; break;
case QXmppMessage::GroupChat: case QXmppMessage::GroupChat:
handled = handleGroupMessage(msg); handled = handleGroupMessage(msg);
@ -109,8 +113,8 @@ bool Core::MessageHandler::handleChatMessage(const QXmppMessage& msg, bool outgo
cnt = acc->rh->addOutOfRosterContact(jid); cnt = acc->rh->addOutOfRosterContact(jid);
qDebug() << "appending message" << sMsg.getId() << "to an out of roster contact"; qDebug() << "appending message" << sMsg.getId() << "to an out of roster contact";
} }
if (outgoing) { if (sMsg.getOutgoing()) {
if (forwarded) { if (sMsg.getForwarded()) {
sMsg.setState(Shared::Message::State::sent); sMsg.setState(Shared::Message::State::sent);
} }
} else { } else {
@ -242,6 +246,7 @@ void Core::MessageHandler::logMessage(const QXmppMessage& msg, const QString& re
qDebug() << "=============================="; qDebug() << "==============================";
} }
#if (QXMPP_VERSION) < QT_VERSION_CHECK(1, 5, 0)
void Core::MessageHandler::onCarbonMessageReceived(const QXmppMessage& msg) void Core::MessageHandler::onCarbonMessageReceived(const QXmppMessage& msg)
{ {
handleChatMessage(msg, false, true); handleChatMessage(msg, false, true);
@ -251,6 +256,7 @@ void Core::MessageHandler::onCarbonMessageSent(const QXmppMessage& msg)
{ {
handleChatMessage(msg, true, true); handleChatMessage(msg, true, true);
} }
#endif
std::tuple<bool, QString, QString> Core::MessageHandler::getOriginalPendingMessageId(const QString& id) std::tuple<bool, QString, QString> Core::MessageHandler::getOriginalPendingMessageId(const QString& id)
{ {

View File

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