• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
protocolhelper.cpp
1 /*
2  Copyright (c) 2008 Volker Krause <vkrause@kde.org>
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 "protocolhelper_p.h"
21 
22 #include "attributefactory.h"
23 #include "collectionstatistics.h"
24 #include "entity_p.h"
25 #include "exception.h"
26 #include "itemserializer_p.h"
27 #include "itemserializerplugin.h"
28 
29 #include <QtCore/QDateTime>
30 #include <QtCore/QFile>
31 #include <QtCore/QVarLengthArray>
32 
33 #include <kdebug.h>
34 #include <klocalizedstring.h>
35 
36 using namespace Akonadi;
37 
38 int ProtocolHelper::parseCachePolicy(const QByteArray & data, CachePolicy & policy, int start)
39 {
40  QVarLengthArray<QByteArray,16> params;
41  int end = Akonadi::ImapParser::parseParenthesizedList( data, params, start );
42  for ( int i = 0; i < params.count() - 1; i += 2 ) {
43  const QByteArray key = params[i];
44  const QByteArray value = params[i + 1];
45 
46  if ( key == "INHERIT" )
47  policy.setInheritFromParent( value == "true" );
48  else if ( key == "INTERVAL" )
49  policy.setIntervalCheckTime( value.toInt() );
50  else if ( key == "CACHETIMEOUT" )
51  policy.setCacheTimeout( value.toInt() );
52  else if ( key == "SYNCONDEMAND" )
53  policy.setSyncOnDemand( value == "true" );
54  else if ( key == "LOCALPARTS" ) {
55  QVarLengthArray<QByteArray,16> tmp;
56  QStringList parts;
57  Akonadi::ImapParser::parseParenthesizedList( value, tmp );
58  for ( int j=0; j<tmp.size(); j++ )
59  parts << QString::fromLatin1( tmp[j] );
60  policy.setLocalParts( parts );
61  }
62  }
63  return end;
64 }
65 
66 QByteArray ProtocolHelper::cachePolicyToByteArray(const CachePolicy & policy)
67 {
68  QByteArray rv = "CACHEPOLICY (";
69  if ( policy.inheritFromParent() ) {
70  rv += "INHERIT true";
71  } else {
72  rv += "INHERIT false";
73  rv += " INTERVAL " + QByteArray::number( policy.intervalCheckTime() );
74  rv += " CACHETIMEOUT " + QByteArray::number( policy.cacheTimeout() );
75  rv += " SYNCONDEMAND " + ( policy.syncOnDemand() ? QByteArray("true") : QByteArray("false") );
76  rv += " LOCALPARTS (" + policy.localParts().join( QLatin1String(" ") ).toLatin1() + ')';
77  }
78  rv += ')';
79  return rv;
80 }
81 
82 void ProtocolHelper::parseAncestorsCached( const QByteArray &data, Entity *entity, Collection::Id parentCollection,
83  ProtocolHelperValuePool *pool, int start )
84 {
85  if ( !pool || parentCollection == -1 ) {
86  // if no pool or parent collection id is provided we can't cache anything, so continue as usual
87  parseAncestors( data, entity, start );
88  return;
89  }
90 
91  if ( pool->ancestorCollections.contains( parentCollection ) ) {
92  // ancestor chain is cached already, so use the cached value
93  entity->setParentCollection( pool->ancestorCollections.value( parentCollection ) );
94  } else {
95  // not cached yet, parse the chain
96  parseAncestors( data, entity, start );
97  pool->ancestorCollections.insert( parentCollection, entity->parentCollection() );
98  }
99 }
100 
101 void ProtocolHelper::parseAncestors( const QByteArray &data, Entity *entity, int start )
102 {
103  Q_UNUSED( start );
104 
105  static const Collection::Id rootCollectionId = Collection::root().id();
106  QVarLengthArray<QByteArray, 16> ancestors;
107  QVarLengthArray<QByteArray, 16> parentIds;
108 
109  ImapParser::parseParenthesizedList( data, ancestors );
110  Entity* current = entity;
111  for ( int i = 0; i < ancestors.count(); ++i ) {
112  parentIds.clear();
113  ImapParser::parseParenthesizedList( ancestors[ i ], parentIds );
114  if ( parentIds.size() != 2 )
115  break;
116 
117  const Collection::Id uid = parentIds[ 0 ].toLongLong();
118  if ( uid == rootCollectionId ) {
119  current->setParentCollection( Collection::root() );
120  break;
121  }
122 
123  current->parentCollection().setId( uid );
124  current->parentCollection().setRemoteId( QString::fromUtf8( parentIds[ 1 ] ) );
125  current = &current->parentCollection();
126  }
127 }
128 
129 int ProtocolHelper::parseCollection(const QByteArray & data, Collection & collection, int start)
130 {
131  int pos = start;
132 
133  // collection and parent id
134  Collection::Id colId = -1;
135  bool ok = false;
136  pos = ImapParser::parseNumber( data, colId, &ok, pos );
137  if ( !ok || colId <= 0 ) {
138  kDebug() << "Could not parse collection id from response:" << data;
139  return start;
140  }
141 
142  Collection::Id parentId = -1;
143  pos = ImapParser::parseNumber( data, parentId, &ok, pos );
144  if ( !ok || parentId < 0 ) {
145  kDebug() << "Could not parse parent id from response:" << data;
146  return start;
147  }
148 
149  collection = Collection( colId );
150  collection.setParentCollection( Collection( parentId ) );
151 
152  // attributes
153  QVarLengthArray<QByteArray,16> attributes;
154  pos = ImapParser::parseParenthesizedList( data, attributes, pos );
155 
156  for ( int i = 0; i < attributes.count() - 1; i += 2 ) {
157  const QByteArray key = attributes[i];
158  const QByteArray value = attributes[i + 1];
159 
160  if ( key == "NAME" ) {
161  collection.setName( QString::fromUtf8( value ) );
162  } else if ( key == "REMOTEID" ) {
163  collection.setRemoteId( QString::fromUtf8( value ) );
164  } else if ( key == "REMOTEREVISION" ) {
165  collection.setRemoteRevision( QString::fromUtf8( value ) );
166  } else if ( key == "RESOURCE" ) {
167  collection.setResource( QString::fromUtf8( value ) );
168  } else if ( key == "MIMETYPE" ) {
169  QVarLengthArray<QByteArray,16> ct;
170  ImapParser::parseParenthesizedList( value, ct );
171  QStringList ct2;
172  for ( int j = 0; j < ct.size(); j++ )
173  ct2 << QString::fromLatin1( ct[j] );
174  collection.setContentMimeTypes( ct2 );
175  } else if ( key == "VIRTUAL" ) {
176  collection.setVirtual( value.toUInt() != 0 );
177  } else if ( key == "MESSAGES" ) {
178  CollectionStatistics s = collection.statistics();
179  s.setCount( value.toLongLong() );
180  collection.setStatistics( s );
181  } else if ( key == "UNSEEN" ) {
182  CollectionStatistics s = collection.statistics();
183  s.setUnreadCount( value.toLongLong() );
184  collection.setStatistics( s );
185  } else if ( key == "SIZE" ) {
186  CollectionStatistics s = collection.statistics();
187  s.setSize( value.toLongLong() );
188  collection.setStatistics( s );
189  } else if ( key == "CACHEPOLICY" ) {
190  CachePolicy policy;
191  ProtocolHelper::parseCachePolicy( value, policy );
192  collection.setCachePolicy( policy );
193  } else if ( key == "ANCESTORS" ) {
194  parseAncestors( value, &collection );
195  } else {
196  Attribute* attr = AttributeFactory::createAttribute( key );
197  Q_ASSERT( attr );
198  attr->deserialize( value );
199  collection.addAttribute( attr );
200  }
201  }
202 
203  return pos;
204 }
205 
206 QByteArray ProtocolHelper::attributesToByteArray(const Entity & entity, bool ns )
207 {
208  QList<QByteArray> l;
209  foreach ( const Attribute *attr, entity.attributes() ) {
210  l << encodePartIdentifier( ns ? PartAttribute : PartGlobal, attr->type() );
211  l << ImapParser::quote( attr->serialized() );
212  }
213  return ImapParser::join( l, " " );
214 }
215 
216 QByteArray ProtocolHelper::encodePartIdentifier(PartNamespace ns, const QByteArray & label, int version )
217 {
218  const QByteArray versionString( version != 0 ? '[' + QByteArray::number( version ) + ']' : "" );
219  switch ( ns ) {
220  case PartGlobal:
221  return label + versionString;
222  case PartPayload:
223  return "PLD:" + label + versionString;
224  case PartAttribute:
225  return "ATR:" + label + versionString;
226  default:
227  Q_ASSERT( false );
228  }
229  return QByteArray();
230 }
231 
232 QByteArray ProtocolHelper::decodePartIdentifier( const QByteArray &data, PartNamespace & ns )
233 {
234  if ( data.startsWith( "PLD:" ) ) { //krazy:exclude=strings
235  ns = PartPayload;
236  return data.mid( 4 );
237  } else if ( data.startsWith( "ATR:" ) ) { //krazy:exclude=strings
238  ns = PartAttribute;
239  return data.mid( 4 );
240  } else {
241  ns = PartGlobal;
242  return data;
243  }
244 }
245 
246 QByteArray ProtocolHelper::entitySetToByteArray( const QList<Item> &_objects, const QByteArray &command )
247 {
248  if ( _objects.isEmpty() )
249  throw Exception( "No objects specified" );
250 
251  Item::List objects( _objects );
252  std::sort( objects.begin(), objects.end(), boost::bind( &Item::id, _1 ) < boost::bind( &Item::id, _2 ) );
253  if ( objects.first().isValid() ) {
254  // all items have a uid set
255  return entitySetToByteArray<Item>(objects, command);
256  }
257  // check if all items have a gid
258  if ( std::find_if( objects.constBegin(), objects.constEnd(),
259  boost::bind( &QString::isEmpty, boost::bind( &Item::gid, _1 ) ) )
260  == objects.constEnd() )
261  {
262  QList<QByteArray> gids;
263  foreach ( const Item &object, objects ) {
264  gids << ImapParser::quote( object.gid().toUtf8() );
265  }
266 
267  QByteArray rv;
268  //rv += " " AKONADI_CMD_GID " ";
269  rv += " " "GID" " ";
270  if ( !command.isEmpty() ) {
271  rv += command;
272  rv += ' ';
273  }
274  rv += '(';
275  rv += ImapParser::join( gids, " " );
276  rv += ')';
277  return rv;
278  }
279  return entitySetToByteArray<Item>(objects, command);
280 }
281 
282 QByteArray ProtocolHelper::hierarchicalRidToByteArray( const Collection &col )
283 {
284  if ( col == Collection::root() )
285  return QByteArray("(0 \"\")");
286  if ( col.remoteId().isEmpty() )
287  return QByteArray();
288  const QByteArray parentHrid = hierarchicalRidToByteArray( col.parentCollection() );
289  return '(' + QByteArray::number( col.id() ) + ' ' + ImapParser::quote( col.remoteId().toUtf8() ) + ") " + parentHrid;
290 }
291 
292 QByteArray ProtocolHelper::hierarchicalRidToByteArray( const Item &item )
293 {
294  const QByteArray parentHrid = hierarchicalRidToByteArray( item.parentCollection() );
295  return '(' + QByteArray::number( item.id() ) + ' ' + ImapParser::quote( item.remoteId().toUtf8() ) + ") " + parentHrid;
296 }
297 
298 QByteArray ProtocolHelper::itemFetchScopeToByteArray( const ItemFetchScope &fetchScope )
299 {
300  QByteArray command;
301 
302  if ( fetchScope.fullPayload() )
303  command += " " AKONADI_PARAM_FULLPAYLOAD;
304  if ( fetchScope.allAttributes() )
305  command += " " AKONADI_PARAM_ALLATTRIBUTES;
306  if ( fetchScope.cacheOnly() )
307  command += " " AKONADI_PARAM_CACHEONLY;
308  if ( fetchScope.checkForCachedPayloadPartsOnly() )
309  command += " " AKONADI_PARAM_CHECKCACHEDPARTSONLY;
310  if ( fetchScope.ignoreRetrievalErrors() )
311  command += " " "IGNOREERRORS";
312  if ( fetchScope.ancestorRetrieval() != ItemFetchScope::None ) {
313  switch ( fetchScope.ancestorRetrieval() ) {
314  case ItemFetchScope::Parent:
315  command += " ANCESTORS 1";
316  break;
317  case ItemFetchScope::All:
318  command += " ANCESTORS INF";
319  break;
320  default:
321  Q_ASSERT( false );
322  }
323  }
324  if ( fetchScope.fetchChangedSince().isValid() ) {
325  command += " " AKONADI_PARAM_CHANGEDSINCE " " + QByteArray::number( fetchScope.fetchChangedSince().toTime_t() );
326  }
327 
328  //TODO: detect somehow if server supports external payload attribute
329  command += " " AKONADI_PARAM_EXTERNALPAYLOAD;
330 
331  command += " (UID COLLECTIONID FLAGS SIZE";
332  if ( fetchScope.fetchRemoteIdentification() )
333  command += " " AKONADI_PARAM_REMOTEID " " AKONADI_PARAM_REMOTEREVISION;
334  if ( fetchScope.fetchGid() )
335  command += " GID";
336  if ( fetchScope.fetchModificationTime() )
337  command += " DATETIME";
338  foreach ( const QByteArray &part, fetchScope.payloadParts() )
339  command += ' ' + ProtocolHelper::encodePartIdentifier( ProtocolHelper::PartPayload, part );
340  foreach ( const QByteArray &part, fetchScope.attributes() )
341  command += ' ' + ProtocolHelper::encodePartIdentifier( ProtocolHelper::PartAttribute, part );
342  command += ")\n";
343 
344  return command;
345 }
346 
347 void ProtocolHelper::parseItemFetchResult( const QList<QByteArray> &lineTokens, Item &item, ProtocolHelperValuePool *valuePool )
348 {
349  // create a new item object
350  Item::Id uid = -1;
351  int rev = -1;
352  QString rid;
353  QString remoteRevision;
354  QString gid;
355  QString mimeType;
356  Entity::Id cid = -1;
357 
358  for ( int i = 0; i < lineTokens.count() - 1; i += 2 ) {
359  const QByteArray key = lineTokens.value( i );
360  const QByteArray value = lineTokens.value( i + 1 );
361 
362  if ( key == "UID" )
363  uid = value.toLongLong();
364  else if ( key == "REV" )
365  rev = value.toInt();
366  else if ( key == "REMOTEID" ) {
367  if ( !value.isEmpty() )
368  rid = QString::fromUtf8( value );
369  else
370  rid.clear();
371  } else if ( key == "REMOTEREVISION" ) {
372  remoteRevision = QString::fromUtf8( value );
373  } else if ( key == "GID" ) {
374  gid = QString::fromUtf8( value );
375  } else if ( key == "COLLECTIONID" ) {
376  cid = value.toInt();
377  } else if ( key == "MIMETYPE" ) {
378  if ( valuePool )
379  mimeType = valuePool->mimeTypePool.sharedValue( QString::fromLatin1( value ) );
380  else
381  mimeType = QString::fromLatin1( value );
382  }
383  }
384 
385  if ( uid < 0 || rev < 0 || mimeType.isEmpty() ) {
386  kWarning() << "Broken fetch response: UID, REV or MIMETYPE missing!";
387  return;
388  }
389 
390  item = Item( uid );
391  item.setRemoteId( rid );
392  item.setRevision( rev );
393  item.setRemoteRevision( remoteRevision );
394  item.setGid( gid );
395  item.setMimeType( mimeType );
396  item.setStorageCollectionId( cid );
397  if ( !item.isValid() )
398  return;
399 
400  // parse fetch response fields
401  for ( int i = 0; i < lineTokens.count() - 1; i += 2 ) {
402  const QByteArray key = lineTokens.value( i );
403  // skip stuff we dealt with already
404  if ( key == "UID" || key == "REV" || key == "REMOTEID" ||
405  key == "MIMETYPE" || key == "COLLECTIONID" || key == "REMOTEREVISION" || key == "GID" )
406  continue;
407  // flags
408  if ( key == "FLAGS" ) {
409  QList<QByteArray> flags;
410  ImapParser::parseParenthesizedList( lineTokens[i + 1], flags );
411  if ( !flags.isEmpty() ) {
412  Item::Flags convertedFlags;
413  convertedFlags.reserve( flags.size() );
414  foreach ( const QByteArray &flag, flags ) {
415  if ( valuePool )
416  convertedFlags.insert( valuePool->flagPool.sharedValue( flag ) );
417  else
418  convertedFlags.insert( flag );
419  }
420  item.setFlags( convertedFlags );
421  }
422  } else if ( key == "CACHEDPARTS" ) {
423  QSet<QByteArray> partsSet;
424  QList<QByteArray> parts;
425  ImapParser::parseParenthesizedList( lineTokens[i + 1], parts );
426  foreach ( const QByteArray &part, parts ) {
427  partsSet.insert(part.mid(4));
428  }
429  item.setCachedPayloadParts( partsSet );
430  } else if ( key == "SIZE" ) {
431  const quint64 size = lineTokens[i + 1].toLongLong();
432  item.setSize( size );
433  } else if ( key == "DATETIME" ) {
434  QDateTime datetime;
435  ImapParser::parseDateTime( lineTokens[i + 1], datetime );
436  item.setModificationTime( datetime );
437  } else if ( key == "ANCESTORS" ) {
438  ProtocolHelper::parseAncestorsCached( lineTokens[i + 1], &item, cid, valuePool );
439  } else {
440  int version = 0;
441  QByteArray plainKey( key );
442  ProtocolHelper::PartNamespace ns;
443 
444  ImapParser::splitVersionedKey( key, plainKey, version );
445  plainKey = ProtocolHelper::decodePartIdentifier( plainKey, ns );
446 
447  switch ( ns ) {
448  case ProtocolHelper::PartPayload:
449  {
450  bool isExternal = false;
451  const QByteArray fileKey = lineTokens.value( i + 1 );
452  if ( fileKey == "[FILE]" ) {
453  isExternal = true;
454  i++;
455  //kDebug() << "Payload is external: " << isExternal << " filename: " << lineTokens.value( i + 1 );
456  }
457  ItemSerializer::deserialize( item, plainKey, lineTokens.value( i + 1 ), version, isExternal );
458  break;
459  }
460  case ProtocolHelper::PartAttribute:
461  {
462  Attribute* attr = AttributeFactory::createAttribute( plainKey );
463  Q_ASSERT( attr );
464  if ( lineTokens.value( i + 1 ) == "[FILE]" ) {
465  ++i;
466  QFile file( QString::fromUtf8( lineTokens.value( i + 1 ) ) );
467  if ( file.open( QFile::ReadOnly ) )
468  attr->deserialize( file.readAll() );
469  else {
470  kWarning() << "Failed to open attribute file: " << lineTokens.value( i + 1 );
471  delete attr;
472  attr = 0;
473  }
474  } else {
475  attr->deserialize( lineTokens.value( i + 1 ) );
476  }
477  if ( attr )
478  item.addAttribute( attr );
479  break;
480  }
481  case ProtocolHelper::PartGlobal:
482  default:
483  kWarning() << "Unknown item part type:" << key;
484  }
485  }
486  }
487 
488  item.d_ptr->resetChangeLog();
489 }
Akonadi::ProtocolHelper::parseCachePolicy
static int parseCachePolicy(const QByteArray &data, CachePolicy &policy, int start=0)
Parse a cache policy definition.
Definition: protocolhelper.cpp:38
Akonadi::CachePolicy::intervalCheckTime
int intervalCheckTime() const
Returns the interval check time in minutes, -1 for never.
Definition: cachepolicy.cpp:117
Akonadi::CachePolicy::setSyncOnDemand
void setSyncOnDemand(bool enable)
Sets whether the collection shall be synced automatically when necessary, i.e.
Definition: cachepolicy.cpp:132
Akonadi::ItemFetchScope::ancestorRetrieval
AncestorRetrieval ancestorRetrieval() const
Returns the ancestor retrieval depth.
Definition: itemfetchscope.cpp:123
Akonadi::CachePolicy::inheritFromParent
bool inheritFromParent() const
Returns whether it inherits cache policy from the parent collection.
Definition: cachepolicy.cpp:87
Akonadi::ItemFetchScope::None
No ancestor retrieval at all (the default)
Definition: itemfetchscope.h:76
Akonadi::CachePolicy::setIntervalCheckTime
void setIntervalCheckTime(int time)
Sets interval check time.
Definition: cachepolicy.cpp:122
Akonadi::CachePolicy::setCacheTimeout
void setCacheTimeout(int timeout)
Sets cache timeout for non-permanently cached parts.
Definition: cachepolicy.cpp:112
Akonadi::CollectionStatistics
Provides statistics information of a Collection.
Definition: collectionstatistics.h:69
Akonadi::ProtocolHelper::itemFetchScopeToByteArray
static QByteArray itemFetchScopeToByteArray(const ItemFetchScope &fetchScope)
Converts a given ItemFetchScope object into a protocol representation.
Definition: protocolhelper.cpp:298
Akonadi::ProtocolHelper::entitySetToByteArray
static QByteArray entitySetToByteArray(const QList< T > &_objects, const QByteArray &command)
Converts the given set of items into a protocol representation.
Definition: protocolhelper_p.h:122
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::Entity::setRemoteId
void setRemoteId(const QString &id)
Sets the remote id of the entity.
Definition: entity.cpp:77
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition: entity.h:65
Akonadi::Attribute::deserialize
virtual void deserialize(const QByteArray &data)=0
Sets the data of this attribute, using the same encoding as returned by toByteArray().
Akonadi::ProtocolHelper::attributesToByteArray
static QByteArray attributesToByteArray(const Entity &entity, bool ns=false)
Convert attributes to their protocol representation.
Definition: protocolhelper.cpp:206
Akonadi::ItemFetchScope::fullPayload
bool fullPayload() const
Returns whether the full payload should be fetched.
Definition: itemfetchscope.cpp:63
Akonadi::ItemFetchScope::fetchModificationTime
bool fetchModificationTime() const
Returns whether item modification time should be retrieved.
Definition: itemfetchscope.cpp:138
Akonadi::Attribute
Provides interface for custom attributes for Entity.
Definition: attribute.h:138
Akonadi::Entity::setId
void setId(Id identifier)
Sets the unique identifier of the entity.
Definition: entity.cpp:67
Akonadi::Entity::setParentCollection
void setParentCollection(const Collection &parent)
Set the parent collection of this object.
Definition: entity.cpp:195
Akonadi::ProtocolHelper::parseCollection
static int parseCollection(const QByteArray &data, Collection &collection, int start=0)
Parse a collection description.
Definition: protocolhelper.cpp:129
Akonadi::Collection::setName
void setName(const QString &name)
Sets the i18n'ed name of the collection.
Definition: collection.cpp:93
Akonadi::Collection::setVirtual
void setVirtual(bool isVirtual)
Sets whether the collection is virtual or not.
Definition: collection.cpp:266
Akonadi::Entity::parentCollection
Collection parentCollection() const
Returns the parent collection of this object.
Definition: entity.cpp:186
Akonadi::Entity::setRemoteRevision
void setRemoteRevision(const QString &revision)
Sets the remote revision of the entity.
Definition: entity.cpp:87
Akonadi::Collection::setStatistics
void setStatistics(const CollectionStatistics &statistics)
Sets the collection statistics for the collection.
Definition: collection.cpp:243
Akonadi::Entity::addAttribute
void addAttribute(Attribute *attribute)
Adds an attribute to the entity.
Definition: entity.cpp:126
Akonadi::ItemFetchScope::attributes
QSet< QByteArray > attributes() const
Returns all explicitly fetched attributes.
Definition: itemfetchscope.cpp:73
Akonadi::ItemFetchScope::Parent
Only retrieve the immediate parent collection.
Definition: itemfetchscope.h:77
Akonadi::CollectionStatistics::setUnreadCount
void setUnreadCount(qint64 count)
Sets the number of unread items in this collection.
Definition: collectionstatistics.cpp:82
Akonadi::ItemFetchScope::fetchRemoteIdentification
bool fetchRemoteIdentification() const
Returns whether item remote identification should be retrieved.
Definition: itemfetchscope.cpp:178
Akonadi::Entity::remoteId
QString remoteId() const
Returns the remote id of the entity.
Definition: entity.cpp:82
Akonadi::ProtocolHelper::hierarchicalRidToByteArray
static QByteArray hierarchicalRidToByteArray(const Collection &col)
Converts the given collection's hierarchical RID into a protocol representation.
Definition: protocolhelper.cpp:282
Akonadi::CachePolicy::cacheTimeout
int cacheTimeout() const
Returns the cache timeout for non-permanently cached parts in minutes; -1 means indefinitely.
Definition: cachepolicy.cpp:107
Akonadi::CollectionStatistics::setSize
void setSize(qint64 size)
Sets the total size of the items in this collection.
Definition: collectionstatistics.cpp:92
Akonadi::ProtocolHelper::encodePartIdentifier
static QByteArray encodePartIdentifier(PartNamespace ns, const QByteArray &label, int version=0)
Encodes part label and namespace.
Definition: protocolhelper.cpp:216
Akonadi::Collection::root
static Collection root()
Returns the root collection.
Definition: collection.cpp:192
Akonadi::ProtocolHelper::PartNamespace
PartNamespace
Part namespaces.
Definition: protocolhelper_p.h:60
Akonadi::CachePolicy
Represents the caching policy for a collection.
Definition: cachepolicy.h:71
Akonadi::Collection::setCachePolicy
void setCachePolicy(const CachePolicy &policy)
Sets the cache policy of the collection.
Definition: collection.cpp:254
Akonadi::Entity::id
Id id() const
Returns the unique identifier of the entity.
Definition: entity.cpp:72
Akonadi::ItemSerializer::deserialize
static void deserialize(Item &item, const QByteArray &label, const QByteArray &data, int version, bool external)
throws ItemSerializerException on failure
Definition: itemserializer.cpp:84
Akonadi::ItemFetchScope::payloadParts
QSet< QByteArray > payloadParts() const
Returns the payload parts that should be fetched.
Definition: itemfetchscope.cpp:50
Akonadi::ItemFetchScope::fetchChangedSince
KDateTime fetchChangedSince() const
Returns timestamp of the oldest item to fetch.
Definition: itemfetchscope.cpp:168
Akonadi::ItemFetchScope
Specifies which parts of an item should be fetched from the Akonadi storage.
Definition: itemfetchscope.h:68
Akonadi::Entity
The base class for Item and Collection.
Definition: entity.h:59
Akonadi::CachePolicy::setLocalParts
void setLocalParts(const QStringList &parts)
Specifies the parts to permanently cache locally.
Definition: cachepolicy.cpp:102
Akonadi::ProtocolHelper::parseAncestors
static void parseAncestors(const QByteArray &data, Entity *entity, int start=0)
Convert a ancestor chain from its protocol representation into an Entity object.
Definition: protocolhelper.cpp:101
Akonadi::ItemFetchScope::fetchGid
bool fetchGid() const
Returns whether item GID should be retrieved.
Definition: itemfetchscope.cpp:148
Akonadi::ItemFetchScope::checkForCachedPayloadPartsOnly
bool checkForCachedPayloadPartsOnly() const
Returns whether payload data should be fetched or only checked for presence in the cache...
Definition: itemfetchscope.cpp:118
Akonadi::AttributeFactory::createAttribute
static Attribute * createAttribute(const QByteArray &type)
Creates an entity attribute object of the given type.
Definition: attributefactory.cpp:132
Akonadi::CollectionStatistics::setCount
void setCount(qint64 count)
Sets the number of items in this collection.
Definition: collectionstatistics.cpp:72
Akonadi::Exception
Base class for exceptions used by the Akonadi library.
Definition: exception.h:35
Akonadi::ItemFetchScope::All
Retrieve all ancestors, up to Collection::root()
Definition: itemfetchscope.h:78
Akonadi::ProtocolHelper::decodePartIdentifier
static QByteArray decodePartIdentifier(const QByteArray &data, PartNamespace &ns)
Decode part label and namespace.
Definition: protocolhelper.cpp:232
Akonadi::Attribute::serialized
virtual QByteArray serialized() const =0
Returns a QByteArray representation of the attribute which will be storaged.
Akonadi::ItemFetchScope::ignoreRetrievalErrors
bool ignoreRetrievalErrors() const
Returns whether retrieval errors should be ignored.
Definition: itemfetchscope.cpp:158
Akonadi::CachePolicy::localParts
QStringList localParts() const
Returns the parts to permanently cache locally.
Definition: cachepolicy.cpp:97
Akonadi::ItemFetchScope::allAttributes
bool allAttributes() const
Returns whether all available attributes should be fetched.
Definition: itemfetchscope.cpp:86
Akonadi::ProtocolHelper::parseAncestorsCached
static void parseAncestorsCached(const QByteArray &data, Entity *entity, Collection::Id parentCollection, ProtocolHelperValuePool *valuePool=0, int start=0)
Convert a ancestor chain from its protocol representation into an Entity object.
Definition: protocolhelper.cpp:82
Akonadi::ItemFetchScope::cacheOnly
bool cacheOnly() const
Returns whether payload data should be requested from remote sources or just from the local cache...
Definition: itemfetchscope.cpp:101
Akonadi::ProtocolHelper::parseItemFetchResult
static void parseItemFetchResult(const QList< QByteArray > &lineTokens, Item &item, ProtocolHelperValuePool *valuePool=0)
Parses a single line from an item fetch job result into an Item object.
Definition: protocolhelper.cpp:347
Akonadi::Attribute::type
virtual QByteArray type() const =0
Returns the type of the attribute.
Akonadi::Collection::statistics
CollectionStatistics statistics() const
Returns the collection statistics of the collection.
Definition: collection.cpp:238
Akonadi::Collection::setResource
void setResource(const QString &identifier)
Sets the identifier of the resource owning the collection.
Definition: collection.cpp:212
Akonadi::CachePolicy::setInheritFromParent
void setInheritFromParent(bool inherit)
Sets whether the cache policy should be inherited from the parent collection.
Definition: cachepolicy.cpp:92
Akonadi::Entity::attributes
Attribute::List attributes() const
Returns a list of all attributes of the entity.
Definition: entity.cpp:151
Akonadi::Collection::setContentMimeTypes
void setContentMimeTypes(const QStringList &types)
Sets the list of possible content mime types.
Definition: collection.cpp:120
Akonadi::CachePolicy::syncOnDemand
bool syncOnDemand() const
Returns whether the collection will be synced automatically when necessary, i.e.
Definition: cachepolicy.cpp:127
Akonadi::ProtocolHelper::cachePolicyToByteArray
static QByteArray cachePolicyToByteArray(const CachePolicy &policy)
Convert a cache policy object into its protocol representation.
Definition: protocolhelper.cpp:66
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal