Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit c3489249 authored by Linus Jahn's avatar Linus Jahn Committed by Jonah Brüchert

Get rid of QXmpp < 1.2 compatibility

parent 47b9cf18
Pipeline #25320 passed with stages
in 17 minutes and 12 seconds
......@@ -102,19 +102,8 @@ void MessageHandler::handleMessage(const QXmppMessage &msg)
message.setId(msg.id());
message.setBody(msg.body());
message.setMediaType(MessageType::MessageText); // default to text message without media
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 1, 0)
message.setIsSpoiler(msg.isSpoiler());
message.setSpoilerHint(msg.spoilerHint());
#else
for (const QXmppElement &extension : msg.extensions()) {
if (extension.tagName() == "spoiler" &&
extension.attribute("xmlns") == NS_SPOILERS) {
message.setIsSpoiler(true);
message.setSpoilerHint(extension.value());
break;
}
}
#endif
// check if message contains a link and also check out of band url
QStringList bodyWords = message.body().split(" ");
......@@ -188,15 +177,6 @@ void MessageHandler::handleMessage(const QXmppMessage &msg)
// * The corresponding chat is not opened while the application window is active.
if (!message.sentByMe() && !kaidan->notificationsMuted(contactJid) && (model->currentChatJid() != message.from() || !m_clientWorker->isApplicationWindowActive()))
emit m_clientWorker->showMessageNotificationRequested(contactJid, contactName, msg.body());
// TODO: Move back following call to RosterManager::handleMessage when spoiler
// messages are implemented in QXmpp
const QString lastMessage =
message.isSpoiler() ? message.spoilerHint().isEmpty() ? tr("Spoiler")
: message.spoilerHint()
: msg.body();
emit kaidan->rosterModel()->setLastMessageRequested(contactJid, lastMessage);
}
void MessageHandler::sendMessage(const QString& toJid,
......
......@@ -203,13 +203,13 @@ void RegistrationManager::handleRegistrationFailed(const QXmppStanza::Error &err
}
break;
default:
// Workaround: Catch an error which is wrongly emitted by older QXmpp versions although the registration was succesful.
#if (QXMPP_VERSION) <= QT_VERSION_CHECK(1, 2, 0)
#if QXMPP_VERSION == QT_VERSION_CHECK(1, 2, 0)
// Workaround: Catch an error which is wrongly emitted by QXmpp
// v1.2.0 although the registration was succesful.
if (error.text().isEmpty())
return;
#else
break;
#endif
break;
}
emit kaidan->registrationFailed(quint8(registrationError), error.text());
......
......@@ -206,4 +206,18 @@ void RosterManager::handleMessage(const QXmppMessage &msg)
item.setUnreadMessages(item.unreadMessages() + 1);
});
}
// Update last message of the contact
QString lastMessage;
if (msg.isSpoiler()) {
if (msg.spoilerHint().isEmpty()) {
lastMessage = tr("Spoiler");
} else {
lastMessage = msg.spoilerHint();
}
} else {
lastMessage = msg.body();
}
emit Kaidan::instance()->rosterModel()->setLastMessageRequested(contactJid, lastMessage);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment