Akonadi

cachepolicy.h
1/*
2 SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10
11#include <QSharedDataPointer>
12#include <QStringList>
13
14namespace Akonadi
15{
16class CachePolicyPrivate;
17
18/**
19 * @short Represents the caching policy for a collection.
20 *
21 * There is one cache policy per collection. It can either specify that all
22 * properties of the policy of the parent collection will be inherited (the
23 * default) or specify the following values:
24 *
25 * - The item parts that should be permanently kept locally and are downloaded
26 * during a collection sync (e.g. full mail vs. just the headers).
27 * - A minimum time for which non-permanently cached item parts have to be kept
28 * (0 - infinity).
29 * - Whether or not a collection sync is triggered on demand, i.e. as soon
30 * as it is accessed by a client.
31 * - An optional time interval for regular collection sync (aka interval
32 * mail check).
33 *
34 * Syncing means fetching updates from the Akonadi database. The cache policy
35 * does not affect updates of the Akonadi database from the backend, since
36 * backend updates will normally immediately trigger the resource to update the
37 * Akonadi database.
38 *
39 * The cache policy applies only to reading from the collection. Writing to the
40 * collection is independent of cache policy - all updates are written to the
41 * backend as soon as the resource can schedule this.
42 *
43 * @code
44 *
45 * Akonadi::CachePolicy policy;
46 * policy.setCacheTimeout( 30 );
47 * policy.setIntervalCheckTime( 20 );
48 *
49 * Akonadi::Collection collection = ...
50 * collection.setCachePolicy( policy );
51 *
52 * @endcode
53 *
54 * @todo Do we also need a size limit for the cache as well?
55 * @todo on a POP3 account, is should not be possible to change locally cached parts, find a solution for that
56 *
57 * @author Volker Krause <vkrause@kde.org>
58 */
59class AKONADICORE_EXPORT CachePolicy
60{
61public:
62 /**
63 * Creates an empty cache policy.
64 */
66
67 /**
68 * Creates a cache policy from an @p other cache policy.
69 */
70 CachePolicy(const CachePolicy &other);
71
72 /**
73 * Destroys the cache policy.
74 */
76
77 /**
78 * Returns whether it inherits cache policy from the parent collection.
79 */
80 bool inheritFromParent() const;
81
82 /**
83 * Sets whether the cache policy should be inherited from the parent collection.
84 */
85 void setInheritFromParent(bool inherit);
86
87 /**
88 * Returns the parts to permanently cache locally.
89 */
90 [[nodiscard]] QStringList localParts() const;
91
92 /**
93 * Specifies the parts to permanently cache locally.
94 */
95 void setLocalParts(const QStringList &parts);
96
97 /**
98 * Returns the cache timeout for non-permanently cached parts in minutes;
99 * -1 means indefinitely.
100 */
101 [[nodiscard]] int cacheTimeout() const;
102
103 /**
104 * Sets cache timeout for non-permanently cached parts.
105 * @param timeout Timeout in minutes, -1 for indefinitely.
106 */
107 void setCacheTimeout(int timeout);
108
109 /**
110 * Returns the interval check time in minutes, -1 for never.
111 */
112 [[nodiscard]] int intervalCheckTime() const;
113
114 /**
115 * Sets interval check time.
116 * @param time Check time interval in minutes, -1 for never.
117 */
118 void setIntervalCheckTime(int time);
119
120 /**
121 * Returns whether the collection will be synced automatically when necessary,
122 * i.e. as soon as it is accessed by a client.
123 */
124 [[nodiscard]] bool syncOnDemand() const;
125
126 /**
127 * Sets whether the collection shall be synced automatically when necessary,
128 * i.e. as soon as it is accessed by a client.
129 * @param enable If @c true the collection is synced.
130 */
131 void setSyncOnDemand(bool enable);
132
133 /**
134 * @internal.
135 * @param other other cache policy
136 */
137 CachePolicy &operator=(const CachePolicy &other);
138
139 /**
140 * @internal
141 * @param other other cache policy
142 */
143 [[nodiscard]] bool operator==(const CachePolicy &other) const;
144
145private:
146 /// @cond PRIVATE
148 /// @endcond
149};
150
151}
152
153/**
154 * Allows a cache policy to be output for debugging purposes.
155 */
156AKONADICORE_EXPORT QDebug operator<<(QDebug, const Akonadi::CachePolicy &);
Represents the caching policy for a collection.
Definition cachepolicy.h:60
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.