Changeset View
Changeset View
Standalone View
Standalone View
src/core/protocolhelper.cpp
Show All 17 Lines | |||||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "protocolhelper_p.h" | 20 | #include "protocolhelper_p.h" | ||
21 | #include "akonadicore_debug.h" | 21 | #include "akonadicore_debug.h" | ||
22 | #include "attributefactory.h" | 22 | #include "attributefactory.h" | ||
23 | #include "collectionstatistics.h" | 23 | #include "collectionstatistics.h" | ||
24 | #include "item_p.h" | 24 | #include "item_p.h" | ||
25 | #include "collection_p.h" | 25 | #include "collection_p.h" | ||
26 | #include "tag_p.h" | ||||
26 | #include "exceptionbase.h" | 27 | #include "exceptionbase.h" | ||
27 | #include "itemserializer_p.h" | 28 | #include "itemserializer_p.h" | ||
28 | #include "itemserializerplugin.h" | 29 | #include "itemserializerplugin.h" | ||
29 | #include "servermanager.h" | 30 | #include "servermanager.h" | ||
30 | #include "tagfetchscope.h" | 31 | #include "tagfetchscope.h" | ||
31 | #include "persistentsearchattribute.h" | 32 | #include "persistentsearchattribute.h" | ||
32 | #include "itemfetchscope.h" | 33 | #include "itemfetchscope.h" | ||
33 | 34 | | |||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Line(s) | 200 | { | |||
200 | return attributesToProtocolImpl(collection, ns); | 201 | return attributesToProtocolImpl(collection, ns); | ||
201 | } | 202 | } | ||
202 | 203 | | |||
203 | Protocol::Attributes ProtocolHelper::attributesToProtocol(const Tag &tag, bool ns) | 204 | Protocol::Attributes ProtocolHelper::attributesToProtocol(const Tag &tag, bool ns) | ||
204 | { | 205 | { | ||
205 | return attributesToProtocolImpl(tag, ns); | 206 | return attributesToProtocolImpl(tag, ns); | ||
206 | } | 207 | } | ||
207 | 208 | | |||
209 | Protocol::Attributes ProtocolHelper::attributesToProtocol(const std::vector<Attribute *> &modifiedAttributes, bool ns) | ||||
210 | { | ||||
211 | Protocol::Attributes attributes; | ||||
212 | for (const Attribute *attr : modifiedAttributes) { | ||||
213 | attributes.insert(ProtocolHelper::encodePartIdentifier(ns ? ProtocolHelper::PartAttribute : ProtocolHelper::PartGlobal, attr->type()), | ||||
214 | attr->serialized()); | ||||
215 | } | ||||
216 | return attributes; | ||||
217 | } | ||||
218 | | ||||
208 | Collection ProtocolHelper::parseCollection(const Protocol::FetchCollectionsResponse &data, bool requireParent) | 219 | Collection ProtocolHelper::parseCollection(const Protocol::FetchCollectionsResponse &data, bool requireParent) | ||
209 | { | 220 | { | ||
210 | Collection collection(data.id()); | 221 | Collection collection(data.id()); | ||
211 | 222 | | |||
212 | if (requireParent) { | 223 | if (requireParent) { | ||
213 | collection.setParentCollection(Collection(data.parentId())); | 224 | collection.setParentCollection(Collection(data.parentId())); | ||
214 | } | 225 | } | ||
215 | 226 | | |||
Show All 33 Lines | |||||
249 | Tag ProtocolHelper::parseTag(const Protocol::FetchTagsResponse &data) | 260 | Tag ProtocolHelper::parseTag(const Protocol::FetchTagsResponse &data) | ||
250 | { | 261 | { | ||
251 | Tag tag(data.id()); | 262 | Tag tag(data.id()); | ||
252 | tag.setRemoteId(data.remoteId()); | 263 | tag.setRemoteId(data.remoteId()); | ||
253 | tag.setGid(data.gid()); | 264 | tag.setGid(data.gid()); | ||
254 | tag.setType(data.type()); | 265 | tag.setType(data.type()); | ||
255 | tag.setParent(Tag(data.parentId())); | 266 | tag.setParent(Tag(data.parentId())); | ||
256 | parseAttributes(data.attributes(), &tag); | 267 | parseAttributes(data.attributes(), &tag); | ||
268 | tag.d_ptr->resetChangeLog(); | ||||
257 | 269 | | |||
258 | return tag; | 270 | return tag; | ||
259 | } | 271 | } | ||
260 | 272 | | |||
261 | QByteArray ProtocolHelper::encodePartIdentifier(PartNamespace ns, const QByteArray &label) | 273 | QByteArray ProtocolHelper::encodePartIdentifier(PartNamespace ns, const QByteArray &label) | ||
262 | { | 274 | { | ||
263 | switch (ns) { | 275 | switch (ns) { | ||
264 | case PartGlobal: | 276 | case PartGlobal: | ||
▲ Show 20 Lines • Show All 447 Lines • ▼ Show 20 Line(s) | 723 | { | |||
712 | Tag tag; | 724 | Tag tag; | ||
713 | tag.setId(data.id()); | 725 | tag.setId(data.id()); | ||
714 | tag.setGid(data.gid()); | 726 | tag.setGid(data.gid()); | ||
715 | tag.setRemoteId(data.remoteId()); | 727 | tag.setRemoteId(data.remoteId()); | ||
716 | tag.setType(data.type()); | 728 | tag.setType(data.type()); | ||
717 | tag.setParent(data.parentId() > 0 ? Tag(data.parentId()) : Tag()); | 729 | tag.setParent(data.parentId() > 0 ? Tag(data.parentId()) : Tag()); | ||
718 | 730 | | |||
719 | parseAttributes(data.attributes(), &tag); | 731 | parseAttributes(data.attributes(), &tag); | ||
732 | tag.d_ptr->resetChangeLog(); | ||||
720 | return tag; | 733 | return tag; | ||
721 | } | 734 | } | ||
722 | 735 | | |||
723 | Relation ProtocolHelper::parseRelationFetchResult(const Protocol::FetchRelationsResponse &data) | 736 | Relation ProtocolHelper::parseRelationFetchResult(const Protocol::FetchRelationsResponse &data) | ||
724 | { | 737 | { | ||
725 | Relation relation; | 738 | Relation relation; | ||
726 | relation.setLeft(Item(data.left())); | 739 | relation.setLeft(Item(data.left())); | ||
727 | relation.setRight(Item(data.right())); | 740 | relation.setRight(Item(data.right())); | ||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |