From 3e1044b8fdad738b75e417d4c16894f6e78bdeff Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Thu, 26 Sep 2024 19:53:46 +0200 Subject: [PATCH] Adapt to libQuotient changes --- src/models/pushrulemodel.cpp | 20 ++++++++++++++++++++ src/neochatroom.cpp | 34 +++++++++++++++++++++++++++++++++- src/roommanager.cpp | 4 ++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/models/pushrulemodel.cpp b/src/models/pushrulemodel.cpp index 8551b07c4..5298039cb 100644 --- a/src/models/pushrulemodel.cpp +++ b/src/models/pushrulemodel.cpp @@ -311,8 +311,12 @@ 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(), @@ -337,7 +341,11 @@ 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(); }); @@ -345,10 +353,18 @@ 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 } }); } @@ -362,7 +378,11 @@ 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/neochatroom.cpp b/src/neochatroom.cpp index 00179dc55..ff7185dc1 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -1244,7 +1244,11 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) for (const auto &i : roomRuleArray) { QJsonObject roomRule = i.toObject(); if (roomRule["rule_id"_ls] == id()) { - connection()->callApi("global"_ls, "room"_ls, id()); +#if Quotient_VERSION_MINOR > 8 + connection()->callApi("room"_ls, id()); +#else + connection()->callApi(QLatin1String("global"), "room"_ls, id()); +#endif } } } @@ -1255,7 +1259,11 @@ 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 } } } @@ -1291,9 +1299,17 @@ 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; }); @@ -1317,9 +1333,17 @@ 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; }); @@ -1348,9 +1372,17 @@ 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; }); diff --git a/src/roommanager.cpp b/src/roommanager.cpp index ff9215bee..f9dab98f6 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -359,7 +359,11 @@ 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()