~ubuntu-branches/ubuntu/quantal/akonadi/quantal

« back to all changes in this revision

Viewing changes to server/src/handlerhelper.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-01-24 23:43:13 UTC
  • mfrom: (1.1.34)
  • Revision ID: package-import@ubuntu.com-20120124234313-qs50ylscxgww141i
Tags: 1.7.0-0ubuntu1
* New upstream release
* Remove x11_not_required.diff, file no longer shipped
* Disable test suite in debian/rules, it requires dbus

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
using namespace Akonadi;
32
32
 
33
 
QByteArray Akonadi::HandlerHelper::normalizeCollectionName(const QByteArray &name)
34
 
{
35
 
  QByteArray collectionByteArray = name;
36
 
  if ( collectionByteArray.startsWith( '/' )  )
37
 
    collectionByteArray = collectionByteArray.right( collectionByteArray.length() - 1 );
38
 
  if ( collectionByteArray.endsWith( '/' ) )
39
 
    collectionByteArray = collectionByteArray.left( collectionByteArray.length() - 1 );
40
 
  return collectionByteArray;
41
 
}
42
 
 
43
33
Collection HandlerHelper::collectionFromIdOrName(const QByteArray & id)
44
34
{
45
35
  // id is a number
49
39
    return Collection::retrieveById( collectionId );
50
40
 
51
41
  // id is a path
52
 
  QString path = QString::fromUtf8( normalizeCollectionName( id ) ); // ### should be UTF-7 for real IMAP compatibility
 
42
  QString path = QString::fromUtf8( id ); // ### should be UTF-7 for real IMAP compatibility
53
43
 
54
 
  const QStringList pathParts = path.split( QLatin1Char('/') );
 
44
  const QStringList pathParts = path.split( QLatin1Char('/'), QString::SkipEmptyParts );
55
45
  Collection col;
56
46
  foreach ( const QString &part, pathParts ) {
57
47
    SelectQueryBuilder<Collection> qb;
106
96
  return true;
107
97
}
108
98
 
109
 
int HandlerHelper::itemWithFlagCount(const Collection & col, const QString & flag)
110
 
{
111
 
  return itemWithFlagsCount( col, QStringList( flag ) );
112
 
}
113
 
 
114
99
int HandlerHelper::itemWithFlagsCount(const Akonadi::Collection& col, const QStringList& flags)
115
100
{
116
101
  CountQueryBuilder qb( PimItem::tableName(), PimItem::idFullColumnName(), CountQueryBuilder::Distinct );
137
122
  return qb.result();
138
123
}
139
124
 
140
 
int HandlerHelper::itemWithoutFlagCount(const Collection & col, const QString & flag)
141
 
{
142
 
  // FIXME optimize me: use only one query or reuse previously done count
143
 
  const int flagCount = itemWithFlagCount( col, flag );
144
 
  const int totalCount = itemCount( col );
145
 
  if ( totalCount < 0 || flagCount < 0 )
146
 
    return -1;
147
 
  return totalCount - flagCount;
148
 
}
149
 
 
150
125
int HandlerHelper::parseCachePolicy(const QByteArray & data, Collection & col, int start, bool *changed )
151
126
{
152
127
  bool inheritChanged = false;