1 | /* |
2 | Copyright (c) 2008 Kevin Krammer <kevin.krammer@gmx.at> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "itemfetchscope.h" |
21 | |
22 | #include "itemfetchscope_p.h" |
23 | |
24 | #include <QtCore/QStringList> |
25 | |
26 | using namespace Akonadi; |
27 | |
28 | ItemFetchScope::ItemFetchScope() |
29 | { |
30 | d = new ItemFetchScopePrivate(); |
31 | } |
32 | |
33 | ItemFetchScope::ItemFetchScope(const ItemFetchScope &other) |
34 | : d(other.d) |
35 | { |
36 | } |
37 | |
38 | ItemFetchScope::~ItemFetchScope() |
39 | { |
40 | } |
41 | |
42 | ItemFetchScope &ItemFetchScope::operator=(const ItemFetchScope &other) |
43 | { |
44 | if (&other != this) { |
45 | d = other.d; |
46 | } |
47 | |
48 | return *this; |
49 | } |
50 | |
51 | QSet< QByteArray > ItemFetchScope::payloadParts() const |
52 | { |
53 | return d->mPayloadParts; |
54 | } |
55 | |
56 | void ItemFetchScope::fetchPayloadPart(const QByteArray &part, bool fetch) |
57 | { |
58 | if (fetch) { |
59 | d->mPayloadParts.insert(part); |
60 | } else { |
61 | d->mPayloadParts.remove(part); |
62 | } |
63 | } |
64 | |
65 | bool ItemFetchScope::fullPayload() const |
66 | { |
67 | return d->mFullPayload; |
68 | } |
69 | |
70 | void ItemFetchScope::fetchFullPayload(bool fetch) |
71 | { |
72 | d->mFullPayload = fetch; |
73 | } |
74 | |
75 | QSet< QByteArray > ItemFetchScope::attributes() const |
76 | { |
77 | return d->mAttributes; |
78 | } |
79 | |
80 | void ItemFetchScope::fetchAttribute(const QByteArray &type, bool fetch) |
81 | { |
82 | if (fetch) { |
83 | d->mAttributes.insert(type); |
84 | } else { |
85 | d->mAttributes.remove(type); |
86 | } |
87 | } |
88 | |
89 | bool ItemFetchScope::allAttributes() const |
90 | { |
91 | return d->mAllAttributes; |
92 | } |
93 | |
94 | void ItemFetchScope::fetchAllAttributes(bool fetch) |
95 | { |
96 | d->mAllAttributes = fetch; |
97 | } |
98 | |
99 | bool ItemFetchScope::isEmpty() const |
100 | { |
101 | return d->mPayloadParts.isEmpty() && d->mAttributes.isEmpty() && !d->mFullPayload && !d->mAllAttributes && !d->mFetchTags && !d->mFetchVRefs; |
102 | } |
103 | |
104 | bool ItemFetchScope::cacheOnly() const |
105 | { |
106 | return d->mCacheOnly; |
107 | } |
108 | |
109 | void ItemFetchScope::setCacheOnly(bool cacheOnly) |
110 | { |
111 | d->mCacheOnly = cacheOnly; |
112 | } |
113 | |
114 | void ItemFetchScope::setCheckForCachedPayloadPartsOnly(bool check) |
115 | { |
116 | if (check) { |
117 | setCacheOnly(true); |
118 | } |
119 | d->mCheckCachedPayloadPartsOnly = check; |
120 | } |
121 | |
122 | bool ItemFetchScope::checkForCachedPayloadPartsOnly() const |
123 | { |
124 | return d->mCheckCachedPayloadPartsOnly; |
125 | } |
126 | |
127 | ItemFetchScope::AncestorRetrieval ItemFetchScope::ancestorRetrieval() const |
128 | { |
129 | return d->mAncestorDepth; |
130 | } |
131 | |
132 | void ItemFetchScope::setAncestorRetrieval(AncestorRetrieval depth) |
133 | { |
134 | d->mAncestorDepth = depth; |
135 | } |
136 | |
137 | void ItemFetchScope::setFetchModificationTime(bool retrieveMtime) |
138 | { |
139 | d->mFetchMtime = retrieveMtime; |
140 | } |
141 | |
142 | bool ItemFetchScope::fetchModificationTime() const |
143 | { |
144 | return d->mFetchMtime; |
145 | } |
146 | |
147 | void ItemFetchScope::setFetchGid(bool retrieveGid) |
148 | { |
149 | d->mFetchGid = retrieveGid; |
150 | } |
151 | |
152 | bool ItemFetchScope::fetchGid() const |
153 | { |
154 | return d->mFetchGid; |
155 | } |
156 | |
157 | void ItemFetchScope::setIgnoreRetrievalErrors(bool ignore) |
158 | { |
159 | d->mIgnoreRetrievalErrors = ignore; |
160 | } |
161 | |
162 | bool ItemFetchScope::ignoreRetrievalErrors() const |
163 | { |
164 | return d->mIgnoreRetrievalErrors; |
165 | } |
166 | |
167 | void ItemFetchScope::setFetchChangedSince(const KDateTime &changedSince) |
168 | { |
169 | d->mChangedSince = changedSince; |
170 | } |
171 | |
172 | KDateTime ItemFetchScope::fetchChangedSince() const |
173 | { |
174 | return d->mChangedSince; |
175 | } |
176 | |
177 | void ItemFetchScope::setFetchRemoteIdentification(bool retrieveRid) |
178 | { |
179 | d->mFetchRid = retrieveRid; |
180 | } |
181 | |
182 | bool ItemFetchScope::fetchRemoteIdentification() const |
183 | { |
184 | return d->mFetchRid; |
185 | } |
186 | |
187 | void ItemFetchScope::setFetchTags(bool fetchTags) |
188 | { |
189 | d->mFetchTags = fetchTags; |
190 | } |
191 | |
192 | bool ItemFetchScope::fetchTags() const |
193 | { |
194 | return d->mFetchTags; |
195 | } |
196 | |
197 | void ItemFetchScope::setFetchVirtualReferences(bool fetchVRefs) |
198 | { |
199 | d->mFetchVRefs = fetchVRefs; |
200 | } |
201 | |
202 | bool ItemFetchScope::fetchVirtualReferences() const |
203 | { |
204 | return d->mFetchVRefs; |
205 | } |
206 | |