From d7d9d29c1d5138c59d819f725d578e151fd48241 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sun, 3 Nov 2024 18:42:31 +0100 Subject: [PATCH] Remove no longer needed ifdefs --- src/controller.cpp | 12 ----- src/eventhandler.cpp | 58 ---------------------- src/eventhandler.h | 4 -- src/foreigntypes.h | 7 +-- src/models/accountemoticonmodel.cpp | 8 --- src/models/actionsmodel.cpp | 9 ---- src/models/devicesmodel.cpp | 4 -- src/models/messagecontentmodel.cpp | 13 ----- src/models/messageeventmodel.cpp | 4 -- src/models/pushrulemodel.cpp | 21 -------- src/models/spacechildrenmodel.cpp | 4 -- src/models/spacechildrenmodel.h | 4 -- src/models/userlistmodel.cpp | 8 --- src/neochatconnection.cpp | 2 - src/neochatconnection.h | 4 -- src/neochatroom.cpp | 76 ----------------------------- src/neochatroom.h | 8 --- src/neochatroommember.cpp | 24 --------- src/notificationsmanager.cpp | 8 --- src/roommanager.cpp | 20 -------- 20 files changed, 1 insertion(+), 297 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 83fbcd7c9..3ec93b6cf 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -63,11 +63,7 @@ Controller::Controller(QObject *parent) }); } else { auto c = new NeoChatConnection(this); -#if Quotient_VERSION_MINOR > 8 c->assumeIdentity(QStringLiteral("@user:localhost:1234"), QStringLiteral("device_1234"), QStringLiteral("token_1234")); -#else - c->assumeIdentity(QStringLiteral("@user:localhost:1234"), QStringLiteral("token_1234")); -#endif connect(c, &Connection::connected, this, [c, this]() { m_accountRegistry.add(c); c->syncLoop(); @@ -230,11 +226,7 @@ void Controller::invokeLogin() Qt::SingleShotConnection); } }); -#if Quotient_VERSION_MINOR > 8 connection->assumeIdentity(account.userId(), account.deviceId(), accessToken); -#else - connection->assumeIdentity(account.userId(), accessToken); -#endif }); } } @@ -441,11 +433,7 @@ void Controller::removeConnection(const QString &userId) bool Controller::csSupported() const { -#if Quotient_VERSION_MINOR > 8 return true; -#else - return false; -#endif } void Controller::revertToDefaultConfig() diff --git a/src/eventhandler.cpp b/src/eventhandler.cpp index bf6d3c4c7..59c0183e3 100644 --- a/src/eventhandler.cpp +++ b/src/eventhandler.cpp @@ -225,18 +225,10 @@ QString EventHandler::rawMessageBody(const Quotient::RoomMessageEvent &event) { QString body; -#if Quotient_VERSION_MINOR > 8 if (event.has()) { -#else - if (event.hasFileContent()) { -#endif // if filename is given or body is equal to filename, // then body is a caption -#if Quotient_VERSION_MINOR > 8 QString filename = event.get()->originalName; -#else - QString filename = event.content()->fileInfo()->originalName; -#endif QString body = event.plainBody(); if (filename.isEmpty() || filename == body) { return QString(); @@ -244,13 +236,8 @@ QString EventHandler::rawMessageBody(const Quotient::RoomMessageEvent &event) return body; } -#if Quotient_VERSION_MINOR > 8 if (event.has() && event.content()) { body = event.get()->body; -#else - if (event.hasTextContent() && event.content()) { - body = static_cast(event.content())->body; -#endif } else { body = event.plainBody(); } @@ -477,13 +464,8 @@ QString EventHandler::getMessageBody(const NeoChatRoom *room, const RoomMessageE { TextHandler textHandler; -#if Quotient_VERSION_MINOR > 8 if (event.has()) { QString fileCaption = event.get()->originalName; -#else - if (event.hasFileContent()) { - QString fileCaption = event.content()->fileInfo()->originalName; -#endif if (fileCaption.isEmpty()) { fileCaption = event.plainBody(); } else if (fileCaption != event.plainBody()) { @@ -494,13 +476,8 @@ QString EventHandler::getMessageBody(const NeoChatRoom *room, const RoomMessageE } QString body; -#if Quotient_VERSION_MINOR > 8 if (event.has() && event.content()) { body = event.get()->body; -#else - if (event.hasTextContent() && event.content()) { - body = static_cast(event.content())->body; -#endif } else { body = event.plainBody(); } @@ -715,28 +692,15 @@ QVariantMap EventHandler::getMediaInfoForEvent(const NeoChatRoom *room, const Qu // Get the file info for the event. if (event->is()) { auto roomMessageEvent = eventCast(event); -#if Quotient_VERSION_MINOR > 8 if (!roomMessageEvent->has()) { -#else - if (!roomMessageEvent->hasFileContent()) { -#endif return {}; } -#if Quotient_VERSION_MINOR > 8 const auto content = roomMessageEvent->get(); QVariantMap mediaInfo = getMediaInfoFromFileInfo(room, content.get(), eventId, false, false); -#else - const auto content = static_cast(roomMessageEvent->content()); - QVariantMap mediaInfo = getMediaInfoFromFileInfo(room, content, eventId, false, false); -#endif // if filename isn't specifically given, it is in body // https://spec.matrix.org/latest/client-server-api/#mfile -#if Quotient_VERSION_MINOR > 8 mediaInfo["filename"_ls] = content->commonInfo().originalName.isEmpty() ? roomMessageEvent->plainBody() : content->commonInfo().originalName; -#else - mediaInfo["filename"_ls] = (content->fileInfo()->originalName.isEmpty()) ? roomMessageEvent->plainBody() : content->fileInfo()->originalName; -#endif return mediaInfo; } else if (event->is()) { @@ -750,11 +714,7 @@ QVariantMap EventHandler::getMediaInfoForEvent(const NeoChatRoom *room, const Qu } QVariantMap EventHandler::getMediaInfoFromFileInfo(const NeoChatRoom *room, -#if Quotient_VERSION_MINOR > 8 const Quotient::EventContent::FileContentBase *fileContent, -#else - const Quotient::EventContent::TypedBase *fileContent, -#endif const QString &eventId, bool isThumbnail, bool isSticker) @@ -762,18 +722,10 @@ QVariantMap EventHandler::getMediaInfoFromFileInfo(const NeoChatRoom *room, QVariantMap mediaInfo; // Get the mxc URL for the media. -#if Quotient_VERSION_MINOR > 8 if (!fileContent->url().isValid() || fileContent->url().scheme() != QStringLiteral("mxc") || eventId.isEmpty()) { -#else - if (!fileContent->fileInfo()->url().isValid() || fileContent->fileInfo()->url().scheme() != QStringLiteral("mxc") || eventId.isEmpty()) { -#endif mediaInfo["source"_ls] = QUrl(); } else { -#if Quotient_VERSION_MINOR > 8 QUrl source = room->makeMediaUrl(eventId, fileContent->url()); -#else - QUrl source = room->makeMediaUrl(eventId, fileContent->fileInfo()->url()); -#endif if (source.isValid()) { mediaInfo["source"_ls] = source; @@ -790,25 +742,15 @@ QVariantMap EventHandler::getMediaInfoFromFileInfo(const NeoChatRoom *room, mediaInfo["mimeIcon"_ls] = mimeType.iconName(); // Add media size if available. -#if Quotient_VERSION_MINOR > 8 mediaInfo["size"_ls] = fileContent->commonInfo().payloadSize; -#else - mediaInfo["size"_ls] = static_cast(fileContent)->fileInfo()->payloadSize; -#endif mediaInfo["isSticker"_ls] = isSticker; // Add parameter depending on media type. if (mimeType.name().contains(QStringLiteral("image"))) { if (auto castInfo = static_cast(fileContent)) { -#if Quotient_VERSION_MINOR > 8 mediaInfo["width"_ls] = castInfo->imageSize.width(); mediaInfo["height"_ls] = castInfo->imageSize.height(); -#else - const auto imageInfo = static_cast(castInfo->fileInfo()); - mediaInfo["width"_ls] = imageInfo->imageSize.width(); - mediaInfo["height"_ls] = imageInfo->imageSize.height(); -#endif // TODO: Images in certain formats (e.g. WebP) will be erroneously marked as animated, even if they are static. mediaInfo["animated"_ls] = QMovie::supportedFormats().contains(mimeType.preferredSuffix().toUtf8()); diff --git a/src/eventhandler.h b/src/eventhandler.h index 430d063ed..350d850af 100644 --- a/src/eventhandler.h +++ b/src/eventhandler.h @@ -290,11 +290,7 @@ private: static QVariantMap getMediaInfoForEvent(const NeoChatRoom *room, const Quotient::RoomEvent *event); QVariantMap static getMediaInfoFromFileInfo(const NeoChatRoom *room, -#if Quotient_VERSION_MINOR > 8 const Quotient::EventContent::FileContentBase *fileContent, -#else - const Quotient::EventContent::TypedBase *fileContent, -#endif const QString &eventId, bool isThumbnail = false, bool isSticker = false); diff --git a/src/foreigntypes.h b/src/foreigntypes.h index c86c3d3c9..ecc625795 100644 --- a/src/foreigntypes.h +++ b/src/foreigntypes.h @@ -7,13 +7,10 @@ #include #include +#include #include #include -#if Quotient_VERSION_MINOR > 8 -#include -#endif - #include "controller.h" #include "neochatconfig.h" @@ -43,11 +40,9 @@ struct ForeignSSSSHandler { QML_NAMED_ELEMENT(SSSSHandler) }; -#if Quotient_VERSION_MINOR > 8 struct ForeignKeyImport { Q_GADGET QML_SINGLETON QML_FOREIGN(Quotient::KeyImport) QML_NAMED_ELEMENT(KeyImport) }; -#endif diff --git a/src/models/accountemoticonmodel.cpp b/src/models/accountemoticonmodel.cpp index 0a595e481..2486b63c1 100644 --- a/src/models/accountemoticonmodel.cpp +++ b/src/models/accountemoticonmodel.cpp @@ -163,11 +163,7 @@ void AccountEmoticonModel::setEmoticonImage(int index, const QUrl &source) QCoro::Task AccountEmoticonModel::doSetEmoticonImage(int index, QUrl source) { auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString()); -#if Quotient_VERSION_MINOR > 8 co_await qCoro(job.get(), &BaseJob::finished); -#else - co_await qCoro(job, &BaseJob::finished); -#endif if (job->error() != BaseJob::NoError) { co_return; } @@ -189,11 +185,7 @@ QCoro::Task AccountEmoticonModel::doSetEmoticonImage(int index, QUrl sourc QCoro::Task AccountEmoticonModel::doAddEmoticon(QUrl source, QString shortcode, QString description, QString type) { auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString()); -#if Quotient_VERSION_MINOR > 8 co_await qCoro(job.get(), &BaseJob::finished); -#else - co_await qCoro(job, &BaseJob::finished); -#endif if (job->error() != BaseJob::NoError) { co_return; } diff --git a/src/models/actionsmodel.cpp b/src/models/actionsmodel.cpp index 94368abba..81674ceb7 100644 --- a/src/models/actionsmodel.cpp +++ b/src/models/actionsmodel.cpp @@ -593,19 +593,10 @@ bool ActionsModel::handleQuickEditAction(NeoChatRoom *room, const QString &messa for (auto it = room->messageEvents().crbegin(); it != room->messageEvents().crend(); it++) { if (const auto event = eventCast(&**it)) { -#if Quotient_VERSION_MINOR > 8 if (event->senderId() == room->localMember().id() && event->has()) { -#else - if (event->senderId() == room->localMember().id() && event->hasTextContent()) { -#endif - QString originalString; if (event->content()) { -#if Quotient_VERSION_MINOR > 8 originalString = static_cast(event->content().get())->body; -#else - originalString = static_cast(event->content())->body; -#endif } else { originalString = event->plainBody(); } diff --git a/src/models/devicesmodel.cpp b/src/models/devicesmodel.cpp index bf71e6819..71a7a1860 100644 --- a/src/models/devicesmodel.cpp +++ b/src/models/devicesmodel.cpp @@ -129,11 +129,7 @@ void DevicesModel::logout(const QString &deviceId, const QString &password) QJsonObject identifier = {{"type"_ls, "m.id.user"_ls}, {"user"_ls, m_connection->user()->id()}}; authData["identifier"_ls] = identifier; auto innerJob = m_connection->callApi(m_devices[index].deviceId, authData); -#if Quotient_VERSION_MINOR > 8 connect(innerJob.get(), &BaseJob::success, this, onSuccess); -#else - connect(innerJob, &BaseJob::success, this, onSuccess); -#endif } else { onSuccess(); } diff --git a/src/models/messagecontentmodel.cpp b/src/models/messagecontentmodel.cpp index 67ffde9ca..6edd05569 100644 --- a/src/models/messagecontentmodel.cpp +++ b/src/models/messagecontentmodel.cpp @@ -522,19 +522,10 @@ QList MessageContentModel::componentsForType(MessageComponentT auto fileTransferInfo = m_room->cachedFileTransferInfo(event); #ifndef Q_OS_ANDROID -#if Quotient_VERSION_MINOR > 8 Q_ASSERT(roomMessageEvent->content() != nullptr && roomMessageEvent->has()); const QMimeType mimeType = roomMessageEvent->get()->mimeType; -#else - Q_ASSERT(roomMessageEvent->content() != nullptr && roomMessageEvent->hasFileContent()); - const QMimeType mimeType = roomMessageEvent->content()->fileInfo()->mimeType; -#endif if (mimeType.name() == QStringLiteral("text/plain") || mimeType.parentMimeTypes().contains(QStringLiteral("text/plain"))) { -#if Quotient_VERSION_MINOR > 8 QString originalName = roomMessageEvent->get()->originalName; -#else - QString originalName = roomMessageEvent->content()->fileInfo()->originalName; -#endif if (originalName.isEmpty()) { originalName = roomMessageEvent->plainBody(); } @@ -666,11 +657,7 @@ void MessageContentModel::updateItineraryModel() } if (auto roomMessageEvent = eventCast(event)) { -#if Quotient_VERSION_MINOR > 8 if (roomMessageEvent->has()) { -#else - if (roomMessageEvent->hasFileContent()) { -#endif auto filePath = m_room->cachedFileTransferInfo(event).localPath; if (filePath.isEmpty() && m_itineraryModel != nullptr) { delete m_itineraryModel; diff --git a/src/models/messageeventmodel.cpp b/src/models/messageeventmodel.cpp index 0e8f95f2d..d06869f27 100644 --- a/src/models/messageeventmodel.cpp +++ b/src/models/messageeventmodel.cpp @@ -505,11 +505,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const if (role == ProgressInfoRole) { if (auto e = eventCast(&evt)) { -#if Quotient_VERSION_MINOR > 8 if (e->has()) { -#else - if (e->hasFileContent()) { -#endif return QVariant::fromValue(m_currentRoom->cachedFileTransferInfo(&evt)); } } diff --git a/src/models/pushrulemodel.cpp b/src/models/pushrulemodel.cpp index 5298039cb..ba9b7e39a 100644 --- a/src/models/pushrulemodel.cpp +++ b/src/models/pushrulemodel.cpp @@ -311,12 +311,7 @@ void PushRuleModel::addKeyword(const QString &keyword, const QString &roomId) pushConditions.append(keywordCondition); } -#if Quotient_VERSION_MINOR > 8 auto job = m_connection->callApi(PushRuleKind::kindString(kind), -#else - auto job = m_connection->callApi(QLatin1String("global"), - PushRuleKind::kindString(kind), -#endif keyword, actions, QString(), @@ -341,11 +336,7 @@ void PushRuleModel::removeKeyword(const QString &keyword) } auto kind = PushRuleKind::kindString(m_rules[index].kind); -#if Quotient_VERSION_MINOR > 8 auto job = m_connection->callApi(kind, m_rules[index].id); -#else - auto job = m_connection->callApi(QStringLiteral("global"), kind, m_rules[index].id); -#endif connect(job, &Quotient::BaseJob::failure, this, [this, job, index]() { qWarning() << QLatin1String("Unable to remove push rule for keyword %1: ").arg(m_rules[index].id) << job->errorString(); }); @@ -353,18 +344,10 @@ void PushRuleModel::removeKeyword(const QString &keyword) void PushRuleModel::setNotificationRuleEnabled(const QString &kind, const QString &ruleId, bool enabled) { -#if Quotient_VERSION_MINOR > 8 auto job = m_connection->callApi(kind, ruleId); -#else - auto job = m_connection->callApi(QStringLiteral("global"), kind, ruleId); -#endif connect(job, &Quotient::BaseJob::success, this, [job, kind, ruleId, enabled, this]() { if (job->enabled() != enabled) { -#if Quotient_VERSION_MINOR > 8 m_connection->callApi(kind, ruleId, enabled); -#else - m_connection->callApi(QStringLiteral("global"), kind, ruleId, enabled); -#endif } }); } @@ -378,11 +361,7 @@ void PushRuleModel::setNotificationRuleActions(const QString &kind, const QStrin actions = actionToVariant(action); } -#if Quotient_VERSION_MINOR > 8 m_connection->callApi(kind, ruleId, actions); -#else - m_connection->callApi(QStringLiteral("global"), kind, ruleId, actions); -#endif } PushRuleAction::Action PushRuleModel::variantToAction(const QList &actions, bool enabled) diff --git a/src/models/spacechildrenmodel.cpp b/src/models/spacechildrenmodel.cpp index 3ce334ebb..0cf829828 100644 --- a/src/models/spacechildrenmodel.cpp +++ b/src/models/spacechildrenmodel.cpp @@ -93,11 +93,7 @@ void SpaceChildrenModel::refreshModel() }); } -#if Quotient_VERSION_MINOR >= 9 void SpaceChildrenModel::insertChildren(std::vector children, const QModelIndex &parent) -#else -void SpaceChildrenModel::insertChildren(std::vector children, const QModelIndex &parent) -#endif { SpaceTreeItem *parentItem = getItem(parent); diff --git a/src/models/spacechildrenmodel.h b/src/models/spacechildrenmodel.h index 75eb86f6d..119de756a 100644 --- a/src/models/spacechildrenmodel.h +++ b/src/models/spacechildrenmodel.h @@ -144,9 +144,5 @@ private: void refreshModel(); -#if Quotient_VERSION_MINOR >= 9 void insertChildren(std::vector children, const QModelIndex &parent = QModelIndex()); -#else - void insertChildren(std::vector children, const QModelIndex &parent = QModelIndex()); -#endif }; diff --git a/src/models/userlistmodel.cpp b/src/models/userlistmodel.cpp index 58a8a20ef..b271be579 100644 --- a/src/models/userlistmodel.cpp +++ b/src/models/userlistmodel.cpp @@ -87,11 +87,7 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const return memberId; } if (role == AvatarRole) { -#if Quotient_VERSION_MINOR > 8 return m_currentRoom->member(memberId).avatarUrl(); -#else - return m_currentRoom->memberAvatar(memberId).url(); -#endif } if (role == ObjectRole) { return QVariant::fromValue(memberId); @@ -176,11 +172,7 @@ void UserListModel::refreshAllMembers() if (m_currentRoom != nullptr) { m_members = m_currentRoom->joinedMemberIds(); -#if Quotient_VERSION_MINOR > 8 MemberSorter sorter; -#else - MemberSorter sorter(m_currentRoom); -#endif std::sort(m_members.begin(), m_members.end(), [&sorter, this](const auto &left, const auto &right) { const auto leftPl = m_currentRoom->getUserPowerLevel(left); const auto rightPl = m_currentRoom->getUserPowerLevel(right); diff --git a/src/neochatconnection.cpp b/src/neochatconnection.cpp index b15b4ff67..74dd8a4e2 100644 --- a/src/neochatconnection.cpp +++ b/src/neochatconnection.cpp @@ -533,7 +533,6 @@ LinkPreviewer *NeoChatConnection::previewerForLink(const QUrl &link) return previewer; } -#if Quotient_VERSION_MINOR > 8 KeyImport::Error NeoChatConnection::exportMegolmSessions(const QString &passphrase, const QString &path) { KeyImport keyImport; @@ -548,6 +547,5 @@ KeyImport::Error NeoChatConnection::exportMegolmSessions(const QString &passphra file.close(); return KeyImport::Success; } -#endif #include "moc_neochatconnection.cpp" diff --git a/src/neochatconnection.h b/src/neochatconnection.h index a217923cf..79054994c 100644 --- a/src/neochatconnection.h +++ b/src/neochatconnection.h @@ -10,9 +10,7 @@ #include #include -#if Quotient_VERSION_MINOR > 8 #include -#endif #include "enums/messagetype.h" #include "linkpreviewer.h" @@ -160,9 +158,7 @@ public: */ Q_INVOKABLE QString accountDataJsonString(const QString &type) const; -#if Quotient_VERSION_MINOR > 8 Q_INVOKABLE Quotient::KeyImport::Error exportMegolmSessions(const QString &passphrase, const QString &path); -#endif qsizetype directChatNotifications() const; bool directChatsHaveHighlightNotifications() const; diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index 0c118aa42..3d4343069 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -74,13 +74,8 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS const auto m_event = evtIt->viewAs(); QString mxcUrl; if (auto event = eventCast(m_event)) { -#if Quotient_VERSION_MINOR > 8 if (event->has()) { mxcUrl = event->get()->url().toString(); -#else - if (event->hasFileContent()) { - mxcUrl = event->content()->fileInfo()->url().toString(); -#endif } } else if (auto event = eventCast(m_event)) { mxcUrl = event->image().url().toString(); @@ -221,11 +216,7 @@ QCoro::Task NeoChatRoom::doUploadFile(QUrl url, QString body) auto mime = QMimeDatabase().mimeTypeForUrl(url); url.setScheme("file"_ls); QFileInfo fileInfo(url.isLocalFile() ? url.toLocalFile() : url.toString()); -#if Quotient_VERSION_MINOR > 8 EventContent::FileContentBase *content; -#else - EventContent::TypedBase *content; -#endif if (mime.name().startsWith("image/"_ls)) { QImage image(url.toLocalFile()); content = new EventContent::ImageContent(url, fileInfo.size(), mime, image.size(), fileInfo.fileName()); @@ -240,11 +231,7 @@ QCoro::Task NeoChatRoom::doUploadFile(QUrl url, QString body) } else { content = new EventContent::FileContent(url, fileInfo.size(), mime, fileInfo.fileName()); } -#if Quotient_VERSION_MINOR > 8 QString txnId = postFile(body.isEmpty() ? url.fileName() : body, std::unique_ptr(content)); -#else - QString txnId = postFile(body.isEmpty() ? url.fileName() : body, content); -#endif setHasFileUploading(true); connect(this, &Room::fileTransferCompleted, [this, txnId](const QString &id, FileSourceInfo) { if (id == txnId) { @@ -376,13 +363,8 @@ bool NeoChatRoom::lastEventIsSpoiler() const { if (auto event = lastEvent()) { if (auto e = eventCast(event)) { -#if Quotient_VERSION_MINOR > 8 if (e->has() && e->content() && e->mimeType().name() == "text/html"_ls) { auto htmlBody = e->get()->body; -#else - if (e->hasTextContent() && e->content() && e->mimeType().name() == "text/html"_ls) { - auto htmlBody = static_cast(e->content())->body; -#endif return htmlBody.contains("data-mx-spoiler"_ls); } } @@ -914,11 +896,7 @@ QCoro::Task NeoChatRoom::doDeleteMessagesByUser(const QString &user, QStri } for (const auto &e : events) { auto job = connection()->callApi(id(), QString::fromLatin1(QUrl::toPercentEncoding(e)), connection()->generateTxnId(), reason); -#if Quotient_VERSION_MINOR > 8 co_await qCoro(job.get(), &BaseJob::finished); -#else - co_await qCoro(job, &BaseJob::finished); -#endif if (job->error() != BaseJob::Success) { qWarning() << "Error: \"" << job->error() << "\" while deleting messages. Aborting"; break; @@ -1217,11 +1195,7 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) for (const auto &i : roomRuleArray) { QJsonObject roomRule = i.toObject(); if (roomRule["rule_id"_ls] == id()) { -#if Quotient_VERSION_MINOR > 8 connection()->callApi("room"_ls, id()); -#else - connection()->callApi(QLatin1String("global"), "room"_ls, id()); -#endif } } } @@ -1232,11 +1206,7 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) for (const auto &i : overrideRuleArray) { QJsonObject overrideRule = i.toObject(); if (overrideRule["rule_id"_ls] == id()) { -#if Quotient_VERSION_MINOR > 8 connection()->callApi("override"_ls, id()); -#else - connection()->callApi("global"_ls, "override"_ls, id()); -#endif } } } @@ -1272,17 +1242,9 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) const QList conditions = {pushCondition}; // Add new override rule and make sure it's enabled -#if Quotient_VERSION_MINOR > 8 auto job = connection()->callApi("override"_ls, id(), actions, QString(), QString(), conditions, QString()); -#else - auto job = connection()->callApi("global"_ls, "override"_ls, id(), actions, QString(), QString(), conditions, QString()); -#endif connect(job, &BaseJob::success, this, [this]() { -#if Quotient_VERSION_MINOR > 8 auto enableJob = connection()->callApi("override"_ls, id(), true); -#else - auto enableJob = connection()->callApi("global"_ls, "override"_ls, id(), true); -#endif connect(enableJob, &BaseJob::success, this, [this]() { m_pushNotificationStateUpdating = false; }); @@ -1306,17 +1268,9 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) // No conditions for a room rule const QList conditions; -#if Quotient_VERSION_MINOR > 8 auto setJob = connection()->callApi("room"_ls, id(), actions, QString(), QString(), conditions, QString()); -#else - auto setJob = connection()->callApi("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString()); -#endif connect(setJob, &BaseJob::success, this, [this]() { -#if Quotient_VERSION_MINOR > 8 auto enableJob = connection()->callApi("room"_ls, id(), true); -#else - auto enableJob = connection()->callApi("global"_ls, "room"_ls, id(), true); -#endif connect(enableJob, &BaseJob::success, this, [this]() { m_pushNotificationStateUpdating = false; }); @@ -1345,17 +1299,9 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) const QList conditions; // Add new room rule and make sure enabled -#if Quotient_VERSION_MINOR > 8 auto setJob = connection()->callApi("room"_ls, id(), actions, QString(), QString(), conditions, QString()); -#else - auto setJob = connection()->callApi("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString()); -#endif connect(setJob, &BaseJob::success, this, [this]() { -#if Quotient_VERSION_MINOR > 8 auto enableJob = connection()->callApi("room"_ls, id(), true); -#else - auto enableJob = connection()->callApi("global"_ls, "room"_ls, id(), true); -#endif connect(enableJob, &BaseJob::success, this, [this]() { m_pushNotificationStateUpdating = false; }); @@ -1446,11 +1392,7 @@ void NeoChatRoom::openEventMediaExternally(const QString &eventId) const auto evtIt = findInTimeline(eventId); if (evtIt != messageEvents().rend() && is(**evtIt)) { const auto event = evtIt->viewAs(); -#if Quotient_VERSION_MINOR > 8 if (event->has()) { -#else - if (event->hasFileContent()) { -#endif const auto transferInfo = cachedFileTransferInfo(event); if (transferInfo.completed()) { UrlHelper helper; @@ -1483,11 +1425,7 @@ void NeoChatRoom::copyEventMedia(const QString &eventId) const auto evtIt = findInTimeline(eventId); if (evtIt != messageEvents().rend() && is(**evtIt)) { const auto event = evtIt->viewAs(); -#if Quotient_VERSION_MINOR > 8 if (event->has()) { -#else - if (event->hasFileContent()) { -#endif const auto transferInfo = fileTransferInfo(eventId); if (transferInfo.completed()) { Clipboard clipboard; @@ -1520,13 +1458,8 @@ FileTransferInfo NeoChatRoom::cachedFileTransferInfo(const Quotient::RoomEvent * QString mxcUrl; int total = 0; if (auto evt = eventCast(event)) { -#if Quotient_VERSION_MINOR > 8 if (evt->has()) { const auto fileContent = evt->get(); -#else - if (evt->hasFileContent()) { - const auto fileContent = evt->content()->fileInfo(); -#endif mxcUrl = fileContent->url().toString(); total = fileContent->payloadSize; @@ -1884,13 +1817,4 @@ void NeoChatRoom::setRoomState(const QString &type, const QString &stateKey, con setState(type, stateKey, QJsonDocument::fromJson(content).object()); } -#if Quotient_VERSION_MINOR == 8 -QList NeoChatRoom::otherMembersTyping() const -{ - auto memberTyping = membersTyping(); - memberTyping.removeAll(localMember()); - return memberTyping; -} -#endif - #include "moc_neochatroom.cpp" diff --git a/src/neochatroom.h b/src/neochatroom.h index 17e79891b..cfbacecd7 100644 --- a/src/neochatroom.h +++ b/src/neochatroom.h @@ -208,10 +208,6 @@ class NeoChatRoom : public Quotient::Room */ Q_PROPERTY(ChatBarCache *threadCache READ threadCache CONSTANT) -#if Quotient_VERSION_MINOR == 8 - Q_PROPERTY(QList otherMembersTyping READ otherMembersTyping NOTIFY typingChanged) -#endif - public: explicit NeoChatRoom(Quotient::Connection *connection, QString roomId, Quotient::JoinState joinState = {}); @@ -623,10 +619,6 @@ private: void cleanupExtraEventRange(Quotient::RoomEventsRange events); void cleanupExtraEvent(const QString &eventId); -#if Quotient_VERSION_MINOR == 8 - QList otherMembersTyping() const; -#endif - private Q_SLOTS: void updatePushNotificationState(QString type); diff --git a/src/neochatroommember.cpp b/src/neochatroommember.cpp index fdf109249..4c822a979 100644 --- a/src/neochatroommember.cpp +++ b/src/neochatroommember.cpp @@ -73,11 +73,7 @@ QString NeochatRoomMember::displayName() const } const auto memberObject = m_room->member(m_memberId); -#if Quotient_VERSION_MINOR > 8 return memberObject.isEmpty() ? id() : memberObject.displayName(); -#else - return memberObject.id().isEmpty() ? id() : memberObject.displayName(); -#endif } QString NeochatRoomMember::htmlSafeDisplayName() const @@ -87,11 +83,7 @@ QString NeochatRoomMember::htmlSafeDisplayName() const } const auto memberObject = m_room->member(m_memberId); -#if Quotient_VERSION_MINOR > 8 return memberObject.isEmpty() ? id() : memberObject.htmlSafeDisplayName(); -#else - return memberObject.id().isEmpty() ? id() : memberObject.htmlSafeDisplayName(); -#endif } QString NeochatRoomMember::fullName() const @@ -101,11 +93,7 @@ QString NeochatRoomMember::fullName() const } const auto memberObject = m_room->member(m_memberId); -#if Quotient_VERSION_MINOR > 8 return memberObject.isEmpty() ? id() : memberObject.fullName(); -#else - return memberObject.id().isEmpty() ? id() : memberObject.fullName(); -#endif } QString NeochatRoomMember::htmlSafeFullName() const @@ -115,11 +103,7 @@ QString NeochatRoomMember::htmlSafeFullName() const } const auto memberObject = m_room->member(m_memberId); -#if Quotient_VERSION_MINOR > 8 return memberObject.isEmpty() ? id() : memberObject.htmlSafeFullName(); -#else - return memberObject.id().isEmpty() ? id() : memberObject.htmlSafeFullName(); -#endif } QString NeochatRoomMember::disambiguatedName() const @@ -129,11 +113,7 @@ QString NeochatRoomMember::disambiguatedName() const } const auto memberObject = m_room->member(m_memberId); -#if Quotient_VERSION_MINOR > 8 return memberObject.isEmpty() ? id() : memberObject.disambiguatedName(); -#else - return memberObject.id().isEmpty() ? id() : memberObject.disambiguatedName(); -#endif } QString NeochatRoomMember::htmlSafeDisambiguatedName() const @@ -143,11 +123,7 @@ QString NeochatRoomMember::htmlSafeDisambiguatedName() const } const auto memberObject = m_room->member(m_memberId); -#if Quotient_VERSION_MINOR > 8 return memberObject.isEmpty() ? id() : memberObject.htmlSafeDisambiguatedName(); -#else - return memberObject.id().isEmpty() ? id() : memberObject.htmlSafeDisambiguatedName(); -#endif } int NeochatRoomMember::hue() const diff --git a/src/notificationsmanager.cpp b/src/notificationsmanager.cpp index f2f9931b6..ebe17f2a4 100644 --- a/src/notificationsmanager.cpp +++ b/src/notificationsmanager.cpp @@ -148,11 +148,7 @@ void NotificationsManager::processNotificationJob(QPointer co QImage avatar_image; if (!sender.avatarUrl().isEmpty()) { -#if Quotient_VERSION_MINOR > 8 avatar_image = room->member(sender.id()).avatar(128, 128, {}); -#else - avatar_image = room->memberAvatar(sender.id()).get(connection, 128, {}); -#endif } else { avatar_image = room->avatar(128); } @@ -298,11 +294,7 @@ void NotificationsManager::doPostInviteNotification(QPointer room) QImage avatar_image; if (roomMemberEvent && !room->member(roomMemberEvent->senderId()).avatarUrl().isEmpty()) { -#if Quotient_VERSION_MINOR > 8 avatar_image = room->member(roomMemberEvent->senderId()).avatar(128, 128, {}); -#else - avatar_image = room->memberAvatar(roomMemberEvent->senderId()).get(room->connection(), 128, [] {}); -#endif } else { qWarning() << "using this room's avatar"; avatar_image = room->avatar(128); diff --git a/src/roommanager.cpp b/src/roommanager.cpp index 2cb0ce511..b94142a8f 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -324,19 +324,11 @@ void RoomManager::visitRoom(Room *r, const QString &eventId) void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers) { auto job = account->joinRoom(roomAliasOrId, viaServers); -#if Quotient_VERSION_MINOR > 8 connect( job.get(), &Quotient::BaseJob::finished, this, [this, account](Quotient::BaseJob *finish) { -#else - connect( - job, - &Quotient::BaseJob::finished, - this, - [this, account](Quotient::BaseJob *finish) { -#endif if (finish->status() == Quotient::BaseJob::Success) { connect( account, @@ -355,28 +347,16 @@ void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAli void RoomManager::knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers) { -#if Quotient_VERSION_MINOR > 8 auto job = account->callApi(roomAliasOrId, viaServers, viaServers, reason); -#else - auto job = account->callApi(roomAliasOrId, viaServers, reason); -#endif // Upon completion, ensure a room object is created in case it hasn't come // with a sync yet. If the room object is not there, provideRoom() will // create it in Join state. finished() is used here instead of success() // to overtake clients that may add their own slots to finished(). -#if Quotient_VERSION_MINOR > 8 connect( job.get(), &BaseJob::finished, this, [this, job, account] { -#else - connect( - job, - &BaseJob::finished, - this, - [this, job, account] { -#endif if (job->status() == Quotient::BaseJob::Success) { connect( account,