forked from blue/squawk
Defaulted to qt6, fix some deprecations
This commit is contained in:
parent
a8060b393c
commit
066ab487fc
7 changed files with 76 additions and 74 deletions
|
@ -164,19 +164,7 @@ bool Core::MessageHandler::handleGroupMessage(const QXmppMessage& msg, bool outg
|
|||
}
|
||||
|
||||
void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmppMessage& source, bool outgoing, bool forwarded, bool guessing) const {
|
||||
const QDateTime& time(source.stamp());
|
||||
QString id;
|
||||
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 3, 0)
|
||||
id = source.originId();
|
||||
if (id.size() == 0)
|
||||
id = source.id();
|
||||
|
||||
target.setStanzaId(source.stanzaId());
|
||||
qDebug() << "initializing message with originId:" << source.originId() << ", id:" << source.id() << ", stansaId:" << source.stanzaId();
|
||||
#else
|
||||
id = source.id();
|
||||
#endif
|
||||
target.setId(id);
|
||||
initializeIDs(target, source);
|
||||
QString messageId = target.getId();
|
||||
if (messageId.size() == 0) {
|
||||
target.generateRandomId(); //TODO out of desperation, I need at least a random ID
|
||||
|
@ -197,6 +185,7 @@ void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmp
|
|||
if (guessing)
|
||||
outgoing = target.getFromJid() == acc->getBareJid();
|
||||
|
||||
const QDateTime& time(source.stamp());
|
||||
target.setOutgoing(outgoing);
|
||||
if (time.isValid())
|
||||
target.setTime(time);
|
||||
|
@ -210,6 +199,37 @@ void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmp
|
|||
target.setOutOfBandUrl(oob);
|
||||
}
|
||||
|
||||
void Core::MessageHandler::initializeIDs(Shared::Message& target, const QXmppMessage& source) const {
|
||||
QString id;
|
||||
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 3, 0)
|
||||
id = source.originId();
|
||||
if (id.size() == 0)
|
||||
id = source.id();
|
||||
|
||||
QString stanzaID;
|
||||
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0)
|
||||
// here I'm looking preferably for id generated by myself, but if there isn't - any is better than nothing
|
||||
QVector<QXmppStanzaId> sIDs = source.stanzaIds();
|
||||
for (const QXmppStanzaId& sID : sIDs) {
|
||||
bool match = sID.by == acc->getBareJid();
|
||||
if (stanzaID.isEmpty() || match)
|
||||
stanzaID = sID.id;
|
||||
|
||||
if (match)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
stanzaID = source.stanzaId();
|
||||
#endif
|
||||
target.setStanzaId(stanzaID);
|
||||
qDebug() << "initializing message with originId:" << source.originId() << ", id:" << source.id() << ", stanzaId:" << stanzaID;
|
||||
#else
|
||||
id = source.id();
|
||||
#endif
|
||||
target.setId(id);
|
||||
}
|
||||
|
||||
|
||||
void Core::MessageHandler::logMessage(const QXmppMessage& msg, const QString& reason) {
|
||||
qDebug() << reason;
|
||||
qDebug() << "- from: " << msg.from();
|
||||
|
@ -219,9 +239,6 @@ void Core::MessageHandler::logMessage(const QXmppMessage& msg, const QString& re
|
|||
qDebug() << "- state: " << msg.state();
|
||||
qDebug() << "- stamp: " << msg.stamp();
|
||||
qDebug() << "- id: " << msg.id();
|
||||
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 3, 0)
|
||||
qDebug() << "- stanzaId: " << msg.stanzaId();
|
||||
#endif
|
||||
qDebug() << "- outOfBandUrl: " << msg.outOfBandUrl();
|
||||
qDebug() << "==============================";
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ private:
|
|||
bool handlePendingMessageError(const QString& id, const QString& errorText);
|
||||
std::pair<Shared::Message::State, QString> scheduleSending(const Shared::Message& message, const QDateTime& sendTime, const QString& originalId);
|
||||
bool adjustPendingMessage(const QString& messageId, const QMap<QString, QVariant>& data, bool final);
|
||||
void initializeIDs(Shared::Message& target, const QXmppMessage& source) const;
|
||||
|
||||
private:
|
||||
Account* acc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue