Commit 2fcabd02 authored by Krzysztof Nowicki's avatar Krzysztof Nowicki Committed by Laurent Montel
Browse files

Drop deprecated queued updates mechanism

This mechanism was introduced to cancel the feedback caused by
server-side notifications in response to item update or removal by the
EWS resource itself.

In the current implementation such bounced item updates are handled by
comparing the item remote revision with the change id. Bounced
deletions are ignored in case they don't exist locally any more as
when they no longer exist on the server there is really not much that
can be done to recover.
parent 8694d2b7
......@@ -384,8 +384,6 @@ void EwsResource::startFetchItemsJob(const Akonadi::Collection &col, std::functi
qCDebugNC(EWSRES_LOG) << QStringLiteral("Starting queued sync for collection ") << col;
auto fetchJob = new EwsFetchItemsJob(col, mEwsClient, getCollectionSyncState(col), mItemsToCheck.value(col.remoteId()), mTagStore, this);
fetchJob->setQueuedUpdates(mQueuedUpdates.value(col.remoteId()));
mQueuedUpdates.remove(col.remoteId());
connect(fetchJob, &EwsFetchItemsJob::result, this, [this, startFn, fetchJob](KJob *) {
startFn(fetchJob);
dequeueFetchItemsJob();
......@@ -578,13 +576,6 @@ void EwsResource::itemModifyFlagsRequestFinished(KJob *job)
emitReadyStatus();
for (const auto &item : req->items()) {
if (mSubManager) {
mSubManager->queueUpdate(EwsModifiedEvent, item.remoteId(), item.remoteRevision());
}
mQueuedUpdates[item.parentCollection().remoteId()].append({item.remoteId(), item.remoteRevision(), EwsModifiedEvent});
}
qCDebug(EWSRES_AGENTIF_LOG) << "itemsFlagsChanged: done";
changesCommitted(req->items());
}
......@@ -672,13 +663,6 @@ void EwsResource::itemMoveRequestFinished(KJob *job)
qCDebugNC(EWSRES_AGENTIF_LOG)
<< QStringLiteral("itemsMoved: succeeded for item %1 (new id: %2)").arg(ewsHash(item.remoteId()), ewsHash(resp.itemId().id()));
if (item.isValid()) {
/* Log item deletion in the source folder so that the next sync doesn't trip over
* non-existent items. Use old remote ids for that. */
if (mSubManager) {
mSubManager->queueUpdate(EwsDeletedEvent, item.remoteId(), QString());
}
mQueuedUpdates[srcCol.remoteId()].append({item.remoteId(), QString(), EwsDeletedEvent});
item.setRemoteId(resp.itemId().id());
item.setRemoteRevision(resp.itemId().changeKey());
movedItems.append(item);
......@@ -757,10 +741,6 @@ void EwsResource::itemDeleteRequestFinished(KJob *job)
Item &item = *it;
if (resp.isSuccess()) {
qCDebugNC(EWSRES_AGENTIF_LOG) << QStringLiteral("itemsRemoved: succeeded for item %1").arg(ewsHash(item.remoteId()));
if (mSubManager) {
mSubManager->queueUpdate(EwsDeletedEvent, item.remoteId(), QString());
}
mQueuedUpdates[item.parentCollection().remoteId()].append({item.remoteId(), QString(), EwsDeletedEvent});
} else {
Q_EMIT warning(QStringLiteral("Delete failed for item %1").arg(item.remoteId()));
qCWarningNC(EWSRES_AGENTIF_LOG) << QStringLiteral("itemsRemoved: failed for item %1").arg(ewsHash(item.remoteId()));
......@@ -1272,13 +1252,6 @@ void EwsResource::itemsTagChangeFinished(KJob *job)
return;
}
for (const auto &item : updJob->items()) {
if (mSubManager) {
mSubManager->queueUpdate(EwsModifiedEvent, item.remoteId(), item.remoteRevision());
}
mQueuedUpdates[item.parentCollection().remoteId()].append({item.remoteId(), item.remoteRevision(), EwsModifiedEvent});
}
changesCommitted(updJob->items());
}
......
......@@ -156,7 +156,6 @@ private:
QScopedPointer<EwsSubscriptionManager> mSubManager;
QString mFolderSyncState;
QHash<QString, EwsId::List> mItemsToCheck;
QHash<QString, EwsFetchItemsJob::QueuedUpdateList> mQueuedUpdates;
QString mPassword;
QScopedPointer<EwsAbstractAuth> mAuth;
AuthStage mAuthStage;
......
/*
SPDX-FileCopyrightText: 2015-2017 Krzysztof Nowicki <krissn@op.pl>
SPDX-FileCopyrightText: 2015-2020 Krzysztof Nowicki <krissn@op.pl>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
......@@ -238,16 +238,6 @@ void EwsSubscriptionManager::processEvents(EwsEventRequestBase *req, bool finish
Q_FOREACH (const EwsGetEventsRequest::Notification &nfy, resp.notifications()) {
Q_FOREACH (const EwsGetEventsRequest::Event &event, nfy.events()) {
bool skip = false;
EwsId id = event.itemId();
for (auto it = mQueuedUpdates.find(id.id()); it != mQueuedUpdates.end(); ++it) {
if (it->type == event.type() && (it->type == EwsDeletedEvent || it->changeKey == id.changeKey())) {
qCDebugNC(EWSRES_LOG) << QStringLiteral("Skipped queued update type %1 for item %2");
skip = true;
mQueuedUpdates.erase(it);
break;
}
}
mSettings->setEventSubscriptionWatermark(event.watermark());
if (!skip) {
switch (event.type()) {
......@@ -303,8 +293,3 @@ void EwsSubscriptionManager::processEvents(EwsEventRequestBase *req, bool finish
}
}
}
void EwsSubscriptionManager::queueUpdate(EwsEventType type, const QString &id, const QString &changeKey)
{
mQueuedUpdates.insert(id, {type, changeKey});
}
/*
SPDX-FileCopyrightText: 2015-2017 Krzysztof Nowicki <krissn@op.pl>
SPDX-FileCopyrightText: 2015-2020 Krzysztof Nowicki <krissn@op.pl>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
......@@ -44,12 +44,6 @@ class EwsSettings;
* itself are also notified back as update events. This means that when for ex. an item is deleted
* it is removed from Akonadi database, but subsequently a delete event is received which will try
* to delete an item that has already been deleted from Akonadi.
*
* To reduce such feedback loops the class implements a queued update mechanism. Each time an
* operation is performed on the mailbox the resource class is responsible for informing the
* subscription manager about it by adding an entry about the performed operation and its subject.
* The subscription manager will in turn filter out update events that refer to oprerations that
* have already been made.
*/
class EwsSubscriptionManager : public QObject
{
......@@ -58,7 +52,6 @@ public:
EwsSubscriptionManager(EwsClient &client, const EwsId &rootId, EwsSettings *settings, QObject *parent);
~EwsSubscriptionManager() override;
void start();
void queueUpdate(EwsEventType type, const QString &id, const QString &changeKey);
Q_SIGNALS:
void foldersModified(EwsId::List folders);
void folderTreeModified();
......@@ -81,11 +74,6 @@ private:
void resetSubscription();
void processEvents(EwsEventRequestBase *req, bool finished);
struct UpdateItem {
EwsEventType type;
QString changeKey;
};
EwsClient &mEwsClient;
QTimer mPollTimer;
EwsId mMsgRootId;
......@@ -93,7 +81,6 @@ private:
QSet<EwsId> mUpdatedFolderIds;
bool mFolderTreeChanged;
bool mStreamingEvents;
QMultiHash<QString, UpdateItem> mQueuedUpdates;
QTimer mStreamingTimer;
EwsEventRequestBase *mEventReq = nullptr;
EwsSettings *mSettings = nullptr;
......
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