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

akonadi

  • 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::attributesToByteArray(const AttributeEntity & entity, bool ns )
217 {
218  QList<QByteArray> l;
219  foreach ( const Attribute *attr, entity.attributes() ) {
220  l << encodePartIdentifier( ns ? PartAttribute : PartGlobal, attr->type() );
221  l << ImapParser::quote( attr->serialized() );
222  }
223  return ImapParser::join( l, " " );
224 }
225 
226 QByteArray ProtocolHelper::encodePartIdentifier(PartNamespace ns, const QByteArray & label, int version )
227 {
228  const QByteArray versionString( version != 0 ? QByteArray(QByteArray("[") + QByteArray::number( version ) + QByteArray("]")) : "" );
229  switch ( ns ) {
230  case PartGlobal:
231  return label + versionString;
232  case PartPayload:
233  return "PLD:" + label + versionString;
234  case PartAttribute:
235  return "ATR:" + label + versionString;
236  default:
237  Q_ASSERT( false );
238  }
239  return QByteArray();
240 }
241 
242 QByteArray ProtocolHelper::decodePartIdentifier( const QByteArray &data, PartNamespace & ns )
243 {
244  if ( data.startsWith( "PLD:" ) ) { //krazy:exclude=strings
245  ns = PartPayload;
246  return data.mid( 4 );
247  } else if ( data.startsWith( "ATR:" ) ) { //krazy:exclude=strings
248  ns = PartAttribute;
249  return data.mid( 4 );
250  } else {
251  ns = PartGlobal;
252  return data;
253  }
254 }
255 
256 QByteArray ProtocolHelper::entitySetToByteArray( const QList<Item> &_objects, const QByteArray &command )
257 {
258  if ( _objects.isEmpty() )
259  throw Exception( "No objects specified" );
260 
261  Item::List objects( _objects );
262  std::sort( objects.begin(), objects.end(), boost::bind( &Item::id, _1 ) < boost::bind( &Item::id, _2 ) );
263  if ( objects.first().isValid() ) {
264  // all items have a uid set
265  return entitySetToByteArray<Item>(objects, command);
266  }
267  // check if all items have a gid
268  if ( std::find_if( objects.constBegin(), objects.constEnd(),
269  boost::bind( &QString::isEmpty, boost::bind( &Item::gid, _1 ) ) )
270  == objects.constEnd() )
271  {
272  QList<QByteArray> gids;
273  foreach ( const Item &object, objects ) {
274  gids << ImapParser::quote( object.gid().toUtf8() );
275  }
276 
277  QByteArray rv;
278  //rv += " " AKONADI_CMD_GID " ";
279  rv += " " "GID" " ";
280  if ( !command.isEmpty() ) {
281  rv += command;
282  rv += ' ';
283  }
284  rv += '(';
285  rv += ImapParser::join( gids, " " );
286  rv += ')';
287  return rv;
288  }
289  return entitySetToByteArray<Item>(objects, command);
290 }
291 
292 QByteArray ProtocolHelper::tagSetToImapSequenceSet( const Akonadi::Tag::List &_objects )
293 {
294  if ( _objects.isEmpty() )
295  throw Exception( "No objects specified" );
296 
297  Tag::List objects( _objects );
298 
299  std::sort( objects.begin(), objects.end(), boost::bind( &Tag::id, _1 ) < boost::bind( &Tag::id, _2 ) );
300  if ( !objects.first().isValid() ) {
301  throw Exception( "Not all tags have a uid" );
302  }
303  // all items have a uid set
304  QVector<Tag::Id> uids;
305  foreach ( const Tag &object, objects )
306  uids << object.id();
307  ImapSet set;
308  set.add( uids );
309  return set.toImapSequenceSet();
310 }
311 
312 QByteArray ProtocolHelper::tagSetToByteArray( const Tag::List &_objects, const QByteArray &command )
313 {
314  if ( _objects.isEmpty() )
315  throw Exception( "No objects specified" );
316 
317  Tag::List objects( _objects );
318 
319  QByteArray rv;
320  std::sort( objects.begin(), objects.end(), boost::bind( &Tag::id, _1 ) < boost::bind( &Tag::id, _2 ) );
321  if ( objects.first().isValid() ) {
322  // all items have a uid set
323  rv += " " AKONADI_CMD_UID " ";
324  if ( !command.isEmpty() ) {
325  rv += command;
326  rv += ' ';
327  }
328  QVector<Tag::Id> uids;
329  foreach ( const Tag &object, objects )
330  uids << object.id();
331  ImapSet set;
332  set.add( uids );
333  rv += set.toImapSequenceSet();
334  return rv;
335  }
336  throw Exception( "Not all tags have a uid" );
337 }
338 
339 QByteArray ProtocolHelper::hierarchicalRidToByteArray( const Collection &col )
340 {
341  if ( col == Collection::root() )
342  return QByteArray("(0 \"\")");
343  if ( col.remoteId().isEmpty() )
344  return QByteArray();
345  const QByteArray parentHrid = hierarchicalRidToByteArray( col.parentCollection() );
346  return '(' + QByteArray::number( col.id() ) + ' ' + ImapParser::quote( col.remoteId().toUtf8() ) + ") " + parentHrid;
347 }
348 
349 QByteArray ProtocolHelper::hierarchicalRidToByteArray( const Item &item )
350 {
351  const QByteArray parentHrid = hierarchicalRidToByteArray( item.parentCollection() );
352  return '(' + QByteArray::number( item.id() ) + ' ' + ImapParser::quote( item.remoteId().toUtf8() ) + ") " + parentHrid;
353 }
354 
355 QByteArray ProtocolHelper::itemFetchScopeToByteArray( const ItemFetchScope &fetchScope )
356 {
357  QByteArray command;
358 
359  if ( fetchScope.fullPayload() )
360  command += " " AKONADI_PARAM_FULLPAYLOAD;
361  if ( fetchScope.allAttributes() )
362  command += " " AKONADI_PARAM_ALLATTRIBUTES;
363  if ( fetchScope.cacheOnly() )
364  command += " " AKONADI_PARAM_CACHEONLY;
365  if ( fetchScope.checkForCachedPayloadPartsOnly() )
366  command += " " AKONADI_PARAM_CHECKCACHEDPARTSONLY;
367  if ( fetchScope.ignoreRetrievalErrors() )
368  command += " " "IGNOREERRORS";
369  if ( fetchScope.ancestorRetrieval() != ItemFetchScope::None ) {
370  switch ( fetchScope.ancestorRetrieval() ) {
371  case ItemFetchScope::Parent:
372  command += " ANCESTORS 1";
373  break;
374  case ItemFetchScope::All:
375  command += " ANCESTORS INF";
376  break;
377  default:
378  Q_ASSERT( false );
379  }
380  }
381  if ( fetchScope.fetchChangedSince().isValid() ) {
382  command += " " AKONADI_PARAM_CHANGEDSINCE " " + QByteArray::number( fetchScope.fetchChangedSince().toTime_t() );
383  }
384 
385  //TODO: detect somehow if server supports external payload attribute
386  command += " " AKONADI_PARAM_EXTERNALPAYLOAD;
387 
388  command += " (UID COLLECTIONID FLAGS SIZE";
389  if ( fetchScope.fetchRemoteIdentification() )
390  command += " " AKONADI_PARAM_REMOTEID " " AKONADI_PARAM_REMOTEREVISION;
391  if ( fetchScope.fetchGid() )
392  command += " GID";
393  if ( fetchScope.fetchTags() )
394  command += " TAGS";
395  if ( fetchScope.fetchModificationTime() )
396  command += " DATETIME";
397  foreach ( const QByteArray &part, fetchScope.payloadParts() )
398  command += ' ' + ProtocolHelper::encodePartIdentifier( ProtocolHelper::PartPayload, part );
399  foreach ( const QByteArray &part, fetchScope.attributes() )
400  command += ' ' + ProtocolHelper::encodePartIdentifier( ProtocolHelper::PartAttribute, part );
401  command += ")\n";
402 
403  return command;
404 }
405 
406 void ProtocolHelper::parseItemFetchResult( const QList<QByteArray> &lineTokens, Item &item, ProtocolHelperValuePool *valuePool )
407 {
408  // create a new item object
409  Item::Id uid = -1;
410  int rev = -1;
411  QString rid;
412  QString remoteRevision;
413  QString gid;
414  QString mimeType;
415  Entity::Id cid = -1;
416 
417  for ( int i = 0; i < lineTokens.count() - 1; i += 2 ) {
418  const QByteArray key = lineTokens.value( i );
419  const QByteArray value = lineTokens.value( i + 1 );
420 
421  if ( key == "UID" )
422  uid = value.toLongLong();
423  else if ( key == "REV" )
424  rev = value.toInt();
425  else if ( key == "REMOTEID" ) {
426  if ( !value.isEmpty() )
427  rid = QString::fromUtf8( value );
428  else
429  rid.clear();
430  } else if ( key == "REMOTEREVISION" ) {
431  remoteRevision = QString::fromUtf8( value );
432  } else if ( key == "GID" ) {
433  gid = QString::fromUtf8( value );
434  } else if ( key == "COLLECTIONID" ) {
435  cid = value.toInt();
436  } else if ( key == "MIMETYPE" ) {
437  if ( valuePool )
438  mimeType = valuePool->mimeTypePool.sharedValue( QString::fromLatin1( value ) );
439  else
440  mimeType = QString::fromLatin1( value );
441  }
442  }
443 
444  if ( uid < 0 || rev < 0 || mimeType.isEmpty() ) {
445  kWarning() << "Broken fetch response: UID, REV or MIMETYPE missing!";
446  return;
447  }
448 
449  item = Item( uid );
450  item.setRemoteId( rid );
451  item.setRevision( rev );
452  item.setRemoteRevision( remoteRevision );
453  item.setGid( gid );
454  item.setMimeType( mimeType );
455  item.setStorageCollectionId( cid );
456  if ( !item.isValid() )
457  return;
458 
459  // parse fetch response fields
460  for ( int i = 0; i < lineTokens.count() - 1; i += 2 ) {
461  const QByteArray key = lineTokens.value( i );
462  // skip stuff we dealt with already
463  if ( key == "UID" || key == "REV" || key == "REMOTEID" ||
464  key == "MIMETYPE" || key == "COLLECTIONID" || key == "REMOTEREVISION" || key == "GID" )
465  continue;
466  // flags
467  if ( key == "FLAGS" ) {
468  QList<QByteArray> flags;
469  ImapParser::parseParenthesizedList( lineTokens[i + 1], flags );
470  if ( !flags.isEmpty() ) {
471  Item::Flags convertedFlags;
472  convertedFlags.reserve( flags.size() );
473  foreach ( const QByteArray &flag, flags ) {
474  if ( valuePool )
475  convertedFlags.insert( valuePool->flagPool.sharedValue( flag ) );
476  else
477  convertedFlags.insert( flag );
478  }
479  item.setFlags( convertedFlags );
480  }
481  } else if ( key == "TAGS" ) {
482  ImapSet set;
483  ImapParser::parseSequenceSet( lineTokens[i + 1], set );
484  Tag::List tags;
485  Q_FOREACH ( const ImapInterval &interval, set.intervals() ) {
486  Q_ASSERT( interval.hasDefinedBegin() );
487  Q_ASSERT( interval.hasDefinedEnd() );
488  for ( qint64 i = interval.begin(); i <= interval.end(); i++ ) {
489  //TODO use value pool when tag is shared data
490  tags << Tag( i );
491  }
492  }
493  item.setTags( tags );
494  } else if ( key == "CACHEDPARTS" ) {
495  QSet<QByteArray> partsSet;
496  QList<QByteArray> parts;
497  ImapParser::parseParenthesizedList( lineTokens[i + 1], parts );
498  foreach ( const QByteArray &part, parts ) {
499  partsSet.insert(part.mid(4));
500  }
501  item.setCachedPayloadParts( partsSet );
502  } else if ( key == "SIZE" ) {
503  const quint64 size = lineTokens[i + 1].toLongLong();
504  item.setSize( size );
505  } else if ( key == "DATETIME" ) {
506  QDateTime datetime;
507  ImapParser::parseDateTime( lineTokens[i + 1], datetime );
508  item.setModificationTime( datetime );
509  } else if ( key == "ANCESTORS" ) {
510  ProtocolHelper::parseAncestorsCached( lineTokens[i + 1], &item, cid, valuePool );
511  } else {
512  int version = 0;
513  QByteArray plainKey( key );
514  ProtocolHelper::PartNamespace ns;
515 
516  ImapParser::splitVersionedKey( key, plainKey, version );
517  plainKey = ProtocolHelper::decodePartIdentifier( plainKey, ns );
518 
519  switch ( ns ) {
520  case ProtocolHelper::PartPayload:
521  {
522  bool isExternal = false;
523  const QByteArray fileKey = lineTokens.value( i + 1 );
524  if ( fileKey == "[FILE]" ) {
525  isExternal = true;
526  i++;
527  //kDebug() << "Payload is external: " << isExternal << " filename: " << lineTokens.value( i + 1 );
528  }
529  ItemSerializer::deserialize( item, plainKey, lineTokens.value( i + 1 ), version, isExternal );
530  break;
531  }
532  case ProtocolHelper::PartAttribute:
533  {
534  Attribute* attr = AttributeFactory::createAttribute( plainKey );
535  Q_ASSERT( attr );
536  if ( lineTokens.value( i + 1 ) == "[FILE]" ) {
537  ++i;
538  QFile file( QString::fromUtf8( lineTokens.value( i + 1 ) ) );
539  if ( file.open( QFile::ReadOnly ) )
540  attr->deserialize( file.readAll() );
541  else {
542  kWarning() << "Failed to open attribute file: " << lineTokens.value( i + 1 );
543  delete attr;
544  attr = 0;
545  }
546  } else {
547  attr->deserialize( lineTokens.value( i + 1 ) );
548  }
549  if ( attr )
550  item.addAttribute( attr );
551  break;
552  }
553  case ProtocolHelper::PartGlobal:
554  default:
555  kWarning() << "Unknown item part type:" << key;
556  }
557  }
558  }
559 
560  item.d_ptr->resetChangeLog();
561 }
562 
563 void ProtocolHelper::parseTagFetchResult( const QList<QByteArray> &lineTokens, Tag &tag )
564 {
565  for (int i = 0; i < lineTokens.count() - 1; i += 2) {
566  const QByteArray key = lineTokens.value(i);
567  const QByteArray value = lineTokens.value(i + 1);
568 
569  if (key == "UID") {
570  tag.setId(value.toLongLong());
571  } else if (key == "GID") {
572  tag.setGid(value);
573  } else if (key == "REMOTEID") {
574  tag.setRemoteId(value);
575  } else if (key == "PARENT") {
576  tag.setParent(Tag(value.toLongLong()));
577  } else {
578  Attribute *attr = AttributeFactory::createAttribute(key);
579  if (!attr) {
580  kWarning() << "Unknown tag attribute" << key;
581  continue;
582  }
583  attr->deserialize(value);
584  tag.addAttribute(attr);
585  }
586  }
587 }
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::Tag::setId
void setId(Id identifier)
Sets the unique identifier of the tag.
Definition: tag.cpp:126
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:355
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:125
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::AttributeEntity::attributes
Attribute::List attributes() const
Returns a list of all attributes of the entity.
Definition: attributeentity.cpp:99
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::Tag::id
Id id() const
Returns the unique identifier of the tag.
Definition: tag.cpp:131
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::AttributeEntity
Parent class for entities that can have attributes.
Definition: attributeentity.h:40
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::ItemFetchScope::fetchTags
bool fetchTags() const
Returns whether tags should be retrieved.
Definition: itemfetchscope.cpp:188
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:339
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:226
Akonadi::Collection::root
static Collection root()
Returns the root collection.
Definition: collection.cpp:192
Akonadi::ProtocolHelper::PartNamespace
PartNamespace
Part namespaces.
Definition: protocolhelper_p.h:62
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:136
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::Tag
An Akonadi Tag.
Definition: tag.h:44
Akonadi::ProtocolHelper::decodePartIdentifier
static QByteArray decodePartIdentifier(const QByteArray &data, PartNamespace &ns)
Decode part label and namespace.
Definition: protocolhelper.cpp:242
Akonadi::AttributeEntity::addAttribute
void addAttribute(Attribute *attribute)
Adds an attribute to the entity.
Definition: attributeentity.cpp:74
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:406
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 Mon Jul 21 2014 08:03:54 by doxygen 1.8.6 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-4.13.3 API Reference

Skip menu "kdepimlibs-4.13.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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