Branch 'kolab/integration/4.13.0' - akonadi/protocolhelper.cpp akonadi/protocolhelper_p.h
Christian Mollekopf
mollekopf at kolabsys.com
Mon Aug 11 18:16:30 CEST 2014
akonadi/protocolhelper.cpp | 36 ++++++++++++++++--------------------
akonadi/protocolhelper_p.h | 3 ++-
2 files changed, 18 insertions(+), 21 deletions(-)
New commits:
commit 4e4cf26b1e865080f64e7584012c6321cfe3e82a
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date: Mon Aug 11 18:10:27 2014 +0200
Read collection ancestor parents as regular collections.
diff --git a/akonadi/protocolhelper.cpp b/akonadi/protocolhelper.cpp
index 82b70d5..8aacdf5 100644
--- a/akonadi/protocolhelper.cpp
+++ b/akonadi/protocolhelper.cpp
@@ -109,7 +109,8 @@ void ProtocolHelper::parseAncestors( const QByteArray &data, Entity *entity, int
static const Collection::Id rootCollectionId = Collection::root().id();
QVarLengthArray<QByteArray, 16> ancestors;
- QVarLengthArray<QByteArray, 16> parentIds;
+ // QVarLengthArray<QByteArray, 16> parentIds;
+ QList<QByteArray> parentIds;
ImapParser::parseParenthesizedList( data, ancestors );
Entity* current = entity;
@@ -125,16 +126,9 @@ void ProtocolHelper::parseAncestors( const QByteArray &data, Entity *entity, int
break;
}
- current->parentCollection().setId( uid );
- current->parentCollection().setRemoteId( QString::fromUtf8( parentIds[ 1 ] ) );
- for ( int q = 2; q < parentIds.count(); q += 2 ) {
- const QByteArray &attrType = parentIds[q];
- const QByteArray &attrValue = parentIds[q + 1];
- Attribute* attr = AttributeFactory::createAttribute( attrType );
- Q_ASSERT( attr );
- attr->deserialize( attrValue );
- current->parentCollection().addAttribute( attr );
- }
+ Akonadi::Collection parentCollection;
+ parseCollection( ImapParser::join(parentIds, " "), parentCollection, 0, false );
+ current->setParentCollection(parentCollection);
current = ¤t->parentCollection();
}
@@ -151,7 +145,7 @@ static Collection::ListPreference parsePreference( const QByteArray &value )
return Collection::ListDefault;
}
-int ProtocolHelper::parseCollection(const QByteArray & data, Collection & collection, int start)
+int ProtocolHelper::parseCollection(const QByteArray & data, Collection & collection, int start, bool requireParent)
{
int pos = start;
@@ -164,15 +158,17 @@ int ProtocolHelper::parseCollection(const QByteArray & data, Collection & collec
return start;
}
- Collection::Id parentId = -1;
- pos = ImapParser::parseNumber( data, parentId, &ok, pos );
- if ( !ok || parentId < 0 ) {
- kDebug() << "Could not parse parent id from response:" << data;
- return start;
- }
-
collection = Collection( colId );
- collection.setParentCollection( Collection( parentId ) );
+
+ if (requireParent) {
+ Collection::Id parentId = -1;
+ pos = ImapParser::parseNumber( data, parentId, &ok, pos );
+ if ( !ok || parentId < 0 ) {
+ kDebug() << "Could not parse parent id from response:" << data;
+ return start;
+ }
+ collection.setParentCollection( Collection( parentId ) );
+ }
// attributes
QVarLengthArray<QByteArray,16> attributes;
diff --git a/akonadi/protocolhelper_p.h b/akonadi/protocolhelper_p.h
index b25a0e3..f3612f6 100644
--- a/akonadi/protocolhelper_p.h
+++ b/akonadi/protocolhelper_p.h
@@ -97,9 +97,10 @@ public:
@param data The input data.
@param collection The parsed collection.
@param start Start of the data.
+ @param requireParent Wether or not we require a parent as part of the data.
@returns Position in data after the collection description.
*/
- static int parseCollection(const QByteArray &data, Collection &collection, int start = 0);
+ static int parseCollection(const QByteArray &data, Collection &collection, int start = 0, bool requireParent = true);
/**
Convert attributes to their protocol representation.
More information about the commits
mailing list