20 #ifndef AKONADI_PROTOCOLHELPER_P_H 21 #define AKONADI_PROTOCOLHELPER_P_H 23 #include <akonadi/cachepolicy.h> 24 #include <akonadi/collection.h> 25 #include <akonadi/collectionutils_p.h> 26 #include <akonadi/item.h> 27 #include <akonadi/itemfetchscope.h> 28 #include <akonadi/sharedvaluepool_p.h> 29 #include <akonadi/attributeentity.h> 30 #include <akonadi/tag.h> 32 #include <akonadi/private/imapparser_p.h> 33 #include <akonadi/private/protocol_p.h> 35 #include <boost/bind.hpp> 40 struct ProtocolHelperValuePool
42 typedef Internal::SharedValuePool<QByteArray, QVector> FlagPool;
43 typedef Internal::SharedValuePool<QString, QVector> MimeTypePool;
46 MimeTypePool mimeTypePool;
47 QHash<Collection::Id, Collection> ancestorCollections;
75 static int parseCachePolicy(
const QByteArray &data,
CachePolicy &policy,
int start = 0);
80 static QByteArray cachePolicyToByteArray(
const CachePolicy &policy);
85 static void parseAncestors(
const QByteArray &data,
Entity *entity,
int start = 0);
93 static void parseAncestorsCached(
const QByteArray &data,
Entity *entity,
Collection::Id parentCollection, ProtocolHelperValuePool *valuePool = 0,
int start = 0);
102 static int parseCollection(
const QByteArray &data,
Collection &collection,
int start = 0);
107 static QByteArray attributesToByteArray(
const Entity &entity,
bool ns =
false);
108 static QByteArray attributesToByteArray(
const AttributeEntity &entity,
bool ns =
false);
113 static QByteArray encodePartIdentifier(
PartNamespace ns,
const QByteArray &label,
int version = 0);
118 static QByteArray decodePartIdentifier(
const QByteArray &data,
PartNamespace &ns);
124 template <
typename T>
127 if (_objects.isEmpty()) {
131 typename T::List objects(_objects);
134 std::sort(objects.begin(), objects.end(), boost::bind(&T::id, _1) < boost::bind(&T::id, _2));
135 if (objects.first().isValid()) {
137 rv +=
" " AKONADI_CMD_UID
" ";
138 if (!command.isEmpty()) {
142 QVector<typename T::Id> uids;
143 foreach (
const T &
object, objects) {
148 rv +=
set.toImapSequenceSet();
153 if (std::find_if(objects.constBegin(), objects.constEnd(),
154 boost::bind(&QString::isEmpty, boost::bind(&T::remoteId, _1)))
155 != objects.constEnd()) {
156 throw Exception(
"No remote identifier specified");
160 if (std::find_if(objects.constBegin(), objects.constEnd(),
161 !boost::bind(
static_cast<bool (*)(
const T &)
>(&CollectionUtils::hasValidHierarchicalRID), _1))
162 == objects.constEnd() && objects.size() == 1) {
164 rv +=
" " AKONADI_CMD_HRID
" ";
165 if (!command.isEmpty()) {
169 rv +=
'(' + hierarchicalRidToByteArray(objects.first()) +
')';
174 QList<QByteArray> rids;
175 foreach (
const T &
object, objects) {
176 rids << ImapParser::quote(
object.remoteId().toUtf8());
179 rv +=
" " AKONADI_CMD_RID
" ";
180 if (!command.isEmpty()) {
185 rv += ImapParser::join(rids,
" ");
190 static QByteArray entitySetToByteArray(
const QList<Akonadi::Item> &_objects,
const QByteArray &command);
192 static QByteArray tagSetToImapSequenceSet(
const Akonadi::Tag::List &_objects);
193 static QByteArray tagSetToByteArray(
const Akonadi::Tag::List &_objects,
const QByteArray &command);
197 const Item::List &requestedItems,
const QByteArray &command);
203 template <
typename T>
206 return entitySetToByteArray(
typename T::List() <<
object, command);
213 static QByteArray hierarchicalRidToByteArray(
const Collection &col);
219 static QByteArray hierarchicalRidToByteArray(
const Item &item);
224 static QByteArray itemFetchScopeToByteArray(
const ItemFetchScope &fetchScope);
229 static QByteArray tagFetchScopeToByteArray(
const TagFetchScope &fetchScope );
234 static void parseItemFetchResult(
const QList<QByteArray> &lineTokens, Item &item, ProtocolHelperValuePool *valuePool = 0);
235 static void parseTagFetchResult(
const QList<QByteArray> &lineTokens,
Tag &tag);
237 static QString akonadiStoragePath();
238 static QString absolutePayloadFilePath(
const QString &fileName);
240 static bool streamPayloadToFile(
const QByteArray &command,
const QByteArray &data, QByteArray &error);
243 static QByteArray enabled(
bool);
244 static QByteArray referenced(
bool);
ListPreference
Describes the list preference value.
Specifies which parts of a tag should be fetched from the Akonadi storage.
static QByteArray entitySetToByteArray(const QList< T > &_objects, const QByteArray &command)
Converts the given set of items into a protocol representation.
Represents a collection of PIM items.
qint64 Id
Describes the unique id type.
Parent class for entities that can have attributes.
ListPurpose
Describes the purpose of the listing.
PartNamespace
Part namespaces.
Represents the caching policy for a collection.
Specifies which parts of an item should be fetched from the Akonadi storage.
The base class for Item and Collection.
FreeBusyManager::Singleton.
Base class for exceptions used by the Akonadi library.
static QByteArray entityIdToByteArray(const T &object, const QByteArray &command)
Converts the given object identifier into a protocol representation.