KDAV 5.109.0
etagcache.h
1/*
2 SPDX-FileCopyrightText: 2010 Grégory Oestreicher <greg@kamago.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KDAV_ETAGCACHE_H
8#define KDAV_ETAGCACHE_H
9
10#include "kdav_export.h"
11
12#include <QObject>
13#include <QStringList>
14
15#include <memory>
16
17namespace KDAV
18{
19class EtagCachePrivate;
20
31class KDAV_EXPORT EtagCache : public QObject
32{
33 Q_OBJECT
34
35public:
40 explicit EtagCache(QObject *parent = nullptr);
41 ~EtagCache() override;
42
48 void setEtag(const QString &remoteId, const QString &etag);
49
53 Q_REQUIRED_RESULT bool contains(const QString &remoteId) const;
54
58 Q_REQUIRED_RESULT bool etagChanged(const QString &remoteId, const QString &refEtag) const;
59
63 void markAsChanged(const QString &remoteId);
64
69 Q_REQUIRED_RESULT bool isOutOfDate(const QString &remoteId) const;
70
74 void removeEtag(const QString &remoteId);
75
79 Q_REQUIRED_RESULT QStringList urls() const;
80
85 Q_REQUIRED_RESULT QStringList changedRemoteIds() const;
86
87protected:
91 void setEtagInternal(const QString &remoteId, const QString &etag);
92
93private:
94 const std::unique_ptr<EtagCachePrivate> d;
95
96 friend class DavItemsListJobPrivate;
97 // @internal
98 // Returns a map of remote Id and corresponding etag string key/value pairs.
99 // Only used by DavItemsListJobPrivate
100 Q_DECL_HIDDEN QMap<QString, QString> etagCacheMap() const;
101};
102}
103
104#endif
A helper class to cache ETags.
Definition etagcache.h:32
bool isOutOfDate(const QString &remoteId) const
Returns true if the remote ID is marked as changed (is contained in the return of changedRemoteIds)
EtagCache(QObject *parent=nullptr)
Creates a new ETag cache and populates it with the ETags of items found in collection.
QStringList urls() const
Returns the list of all items URLs.
bool etagChanged(const QString &remoteId, const QString &refEtag) const
Check if the known ETag for the remote ID is equal to refEtag.
QStringList changedRemoteIds() const
Returns the list of remote ids of items that have been changed in the backend.
void setEtag(const QString &remoteId, const QString &etag)
Sets the ETag for the remote ID.
void setEtagInternal(const QString &remoteId, const QString &etag)
Sets the ETag for the remote ID.
void markAsChanged(const QString &remoteId)
Mark an item as changed in the backend.
void removeEtag(const QString &remoteId)
Removes the entry for item with remote ID remoteId.
bool contains(const QString &remoteId) const
Checks if the given item is in the cache.
The KDAV namespace.
Definition davjobbase.h:17