[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi/coding-style] server/src: Coding Style
From:       Guy Maurel <guy.maurel () kde ! org>
Date:       2014-06-06 17:18:12
Message-ID: E1WsxmO-00013V-8N () scm ! kde ! org
[Download RAW message or body]

Git commit dc953fe637443ffaebf0add04c420f6fa88d940c by Guy Maurel.
Committed on 06/06/2014 at 17:17.
Pushed by guymaurel into branch 'coding-style'.

Coding Style

REVIEWS: 118568 118569

M  +21   -21   server/src/filetracer.cpp
M  +110  -110  server/src/handler.cpp
M  +269  -270  server/src/handlerhelper.cpp
M  +651  -651  server/src/imapstreamparser.cpp
M  +43   -43   server/src/intervalcheck.cpp
M  +58   -58   server/src/storage/itemretrievaljob.cpp
M  +148  -148  server/src/storage/itemretrievalmanager.cpp
M  +7    -7    server/src/storage/itemretrievalthread.cpp
M  +190  -190  server/src/storage/itemretriever.cpp
M  +210  -211  server/src/storage/notificationcollector.cpp

http://commits.kde.org/akonadi/dc953fe637443ffaebf0add04c420f6fa88d940c

diff --git a/server/src/filetracer.cpp b/server/src/filetracer.cpp
index 5a89478..1794adc 100644
--- a/server/src/filetracer.cpp
+++ b/server/src/filetracer.cpp
@@ -23,54 +23,54 @@
 
 using namespace Akonadi::Server;
 
-FileTracer::FileTracer( const QString &fileName )
+FileTracer::FileTracer(const QString &fileName)
 {
-  m_file = new QFile( fileName );
-  m_file->open( QIODevice::WriteOnly | QIODevice::Unbuffered );
+    m_file = new QFile(fileName);
+    m_file->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
 }
 
 FileTracer::~FileTracer()
 {
-  delete m_file;
+    delete m_file;
 }
 
-void FileTracer::beginConnection( const QString &identifier, const QString &msg )
+void FileTracer::beginConnection(const QString &identifier, const QString &msg)
 {
-  output( identifier, QString::fromLatin1( "begin_connection: %1" ).arg( msg ) );
+    output(identifier, QString::fromLatin1("begin_connection: %1").arg(msg));
 }
 
-void FileTracer::endConnection( const QString &identifier, const QString &msg )
+void FileTracer::endConnection(const QString &identifier, const QString &msg)
 {
-  output( identifier, QString::fromLatin1( "end_connection: %1" ).arg( msg ) );
+    output(identifier, QString::fromLatin1("end_connection: %1").arg(msg));
 }
 
-void FileTracer::connectionInput( const QString &identifier, const QByteArray &msg )
+void FileTracer::connectionInput(const QString &identifier, const QByteArray &msg)
 {
-  output( identifier, QString::fromLatin1( "input: %1" ).arg( QString::fromUtf8( msg \
) ) ); +    output(identifier, QString::fromLatin1("input: \
%1").arg(QString::fromUtf8(msg)));  }
 
-void FileTracer::connectionOutput( const QString &identifier, const QByteArray &msg \
) +void FileTracer::connectionOutput(const QString &identifier, const QByteArray \
&msg)  {
-  output( identifier, QString::fromLatin1( "output: %1" ).arg( QString::fromUtf8( \
msg ) ) ); +    output(identifier, QString::fromLatin1("output: \
%1").arg(QString::fromUtf8(msg)));  }
 
-void FileTracer::signal( const QString &signalName, const QString &msg )
+void FileTracer::signal(const QString &signalName, const QString &msg)
 {
-  output( QLatin1String( "signal" ), QString::fromLatin1( "<%1> %2" ).arg( \
signalName, msg ) ); +    output(QLatin1String("signal"), QString::fromLatin1("<%1> \
%2").arg(signalName, msg));  }
 
-void FileTracer::warning( const QString &componentName, const QString &msg )
+void FileTracer::warning(const QString &componentName, const QString &msg)
 {
-  output( QLatin1String( "warning" ), QString::fromLatin1( "<%1> %2" ).arg( \
componentName, msg ) ); +    output(QLatin1String("warning"), \
QString::fromLatin1("<%1> %2").arg(componentName, msg));  }
 
-void FileTracer::error( const QString &componentName, const QString &msg )
+void FileTracer::error(const QString &componentName, const QString &msg)
 {
-  output( QLatin1String( "error" ), QString::fromLatin1( "<%1> %2" ).arg( \
componentName, msg ) ); +    output(QLatin1String("error"), QString::fromLatin1("<%1> \
%2").arg(componentName, msg));  }
 
-void FileTracer::output( const QString &id, const QString &msg )
+void FileTracer::output(const QString &id, const QString &msg)
 {
-  QString output = QString::fromLatin1( "%1: %2: %3\r\n" ).arg( \
QTime::currentTime().toString( QLatin1String( "HH:mm:ss.zzz" ) ), id, msg.left( \
                msg.indexOf( QLatin1String( "\n" ) ) ) );
-  m_file->write( output.toUtf8() );
+    QString output = QString::fromLatin1("%1: %2: \
%3\r\n").arg(QTime::currentTime().toString(QLatin1String("HH:mm:ss.zzz")), id, \
msg.left(msg.indexOf(QLatin1String("\n")))); +    m_file->write(output.toUtf8());
 }
diff --git a/server/src/handler.cpp b/server/src/handler.cpp
index 7e95067..e72451a 100644
--- a/server/src/handler.cpp
+++ b/server/src/handler.cpp
@@ -66,8 +66,8 @@ using namespace Akonadi::Server;
 
 Handler::Handler()
     : QObject()
-    , m_connection( 0 )
-    , m_streamParser( 0 )
+    , m_connection(0)
+    , m_streamParser(0)
 {
 }
 
@@ -75,29 +75,29 @@ Handler::~Handler()
 {
 }
 
-Handler *Handler::findHandlerForCommandNonAuthenticated( const QByteArray &command )
+Handler *Handler::findHandlerForCommandNonAuthenticated(const QByteArray &command)
 {
     // allowed are LOGIN
-    if ( command == AKONADI_CMD_LOGIN ) {
+    if (command == AKONADI_CMD_LOGIN) {
         return new Login();
     }
 
     return 0;
 }
 
-Handler *Handler::findHandlerForCommandAlwaysAllowed( const QByteArray &command )
+Handler *Handler::findHandlerForCommandAlwaysAllowed(const QByteArray &command)
 {
     // allowed commands CAPABILITY and LOGOUT
-    if ( command == AKONADI_CMD_LOGOUT ) {
+    if (command == AKONADI_CMD_LOGOUT) {
         return new Logout();
     }
-    if ( command == AKONADI_CMD_CAPABILITY ) {
+    if (command == AKONADI_CMD_CAPABILITY) {
         return new Capability();
     }
     return 0;
 }
 
-void Handler::setTag( const QByteArray &tag )
+void Handler::setTag(const QByteArray &tag)
 {
     m_tag = tag;
 }
@@ -107,120 +107,120 @@ QByteArray Handler::tag() const
     return m_tag;
 }
 
-Handler *Handler::findHandlerForCommandAuthenticated( const QByteArray &_command, \
ImapStreamParser *streamParser ) +Handler \
*Handler::findHandlerForCommandAuthenticated(const QByteArray &_command, \
ImapStreamParser *streamParser)  {
-  QByteArray command( _command );
-  // deal with command prefixes
-  Scope::SelectionScope scope = Scope::selectionScopeFromByteArray( command );
-  if ( scope != Scope::None ) {
-    command = streamParser->readString();
-  }
+    QByteArray command(_command);
+    // deal with command prefixes
+    Scope::SelectionScope scope = Scope::selectionScopeFromByteArray(command);
+    if (scope != Scope::None) {
+        command = streamParser->readString();
+    }
 
     // allowed commands are listed below ;-).
-    if ( command == AKONADI_CMD_APPEND ) {
+    if (command == AKONADI_CMD_APPEND) {
         return new Append();
     }
-    if ( command == AKONADI_CMD_COLLECTIONCREATE ) {
-        return new Create( scope );
+    if (command == AKONADI_CMD_COLLECTIONCREATE) {
+        return new Create(scope);
     }
-    if ( command == AKONADI_CMD_LIST || command == AKONADI_CMD_X_AKLIST ) { //TODO: \
                remove X-AKLIST support in Akonadi 2.0
-        return new List( scope, false );
+    if (command == AKONADI_CMD_LIST || command == AKONADI_CMD_X_AKLIST) {   //TODO: \
remove X-AKLIST support in Akonadi 2.0 +        return new List(scope, false);
     }
-    if ( command == AKONADI_CMD_LSUB || command == AKONADI_CMD_X_AKLSUB ) { //TODO: \
                remove X-AKLSUB support in Akonadi 2.0
-        return new List( scope, true );
+    if (command == AKONADI_CMD_LSUB || command == AKONADI_CMD_X_AKLSUB) {   //TODO: \
remove X-AKLSUB support in Akonadi 2.0 +        return new List(scope, true);
     }
-    if ( command == AKONADI_CMD_SELECT ) {
-        return new Select( scope );
+    if (command == AKONADI_CMD_SELECT) {
+        return new Select(scope);
     }
-    if ( command == AKONADI_CMD_SEARCH_STORE ) {
+    if (command == AKONADI_CMD_SEARCH_STORE) {
         return new SearchPersistent();
     }
-    if ( command == AKONADI_CMD_SEARCH ) {
+    if (command == AKONADI_CMD_SEARCH) {
         return new Search();
     }
-    if ( command == AKONADI_CMD_SEARCH_RESULT ) {
-        return new SearchResult( scope );
+    if (command == AKONADI_CMD_SEARCH_RESULT) {
+        return new SearchResult(scope);
     }
-    if ( command == AKONADI_CMD_ITEMFETCH ) {
-        return new Fetch( scope );
+    if (command == AKONADI_CMD_ITEMFETCH) {
+        return new Fetch(scope);
     }
-    if ( command == AKONADI_CMD_EXPUNGE ) { //TODO: remove EXPUNGE support in \
Akonadi 2.0 +    if (command == AKONADI_CMD_EXPUNGE) {   //TODO: remove EXPUNGE \
support in Akonadi 2.0  return new Expunge();
     }
-    if ( command == AKONADI_CMD_ITEMMODIFY ) {
-        return new Store( scope );
+    if (command == AKONADI_CMD_ITEMMODIFY) {
+        return new Store(scope);
     }
-    if ( command == AKONADI_CMD_STATUS ) {
+    if (command == AKONADI_CMD_STATUS) {
         return new Status();
     }
-    if ( command == AKONADI_CMD_COLLECTIONDELETE ) {
-      return new Delete( scope );
+    if (command == AKONADI_CMD_COLLECTIONDELETE) {
+        return new Delete(scope);
     }
-    if ( command == AKONADI_CMD_COLLECTIONMODIFY ) {
-      return new Modify( scope );
+    if (command == AKONADI_CMD_COLLECTIONMODIFY) {
+        return new Modify(scope);
     }
-    if ( command == AKONADI_CMD_BEGIN ) {
-      return new TransactionHandler( TransactionHandler::Begin );
+    if (command == AKONADI_CMD_BEGIN) {
+        return new TransactionHandler(TransactionHandler::Begin);
     }
-    if ( command == AKONADI_CMD_ROLLBACK ) {
-      return new TransactionHandler( TransactionHandler::Rollback );
+    if (command == AKONADI_CMD_ROLLBACK) {
+        return new TransactionHandler(TransactionHandler::Rollback);
     }
-    if ( command == AKONADI_CMD_COMMIT ) {
-      return new TransactionHandler( TransactionHandler::Commit );
+    if (command == AKONADI_CMD_COMMIT) {
+        return new TransactionHandler(TransactionHandler::Commit);
     }
-    if ( command == AKONADI_CMD_ITEMCREATE ) {
-      return new AkAppend();
+    if (command == AKONADI_CMD_ITEMCREATE) {
+        return new AkAppend();
     }
-    if ( command == AKONADI_CMD_SUBSCRIBE ) {
-      return new Subscribe( true );
+    if (command == AKONADI_CMD_SUBSCRIBE) {
+        return new Subscribe(true);
     }
-    if ( command == AKONADI_CMD_UNSUBSCRIBE ) {
-      return new Subscribe( false );
+    if (command == AKONADI_CMD_UNSUBSCRIBE) {
+        return new Subscribe(false);
     }
-    if ( command == AKONADI_CMD_ITEMCOPY ) {
-      return new Copy();
+    if (command == AKONADI_CMD_ITEMCOPY) {
+        return new Copy();
     }
-    if ( command == AKONADI_CMD_COLLECTIONCOPY ) {
-      return new ColCopy();
+    if (command == AKONADI_CMD_COLLECTIONCOPY) {
+        return new ColCopy();
     }
-    if ( command == AKONADI_CMD_ITEMLINK ) {
-      return new Link( scope, true );
+    if (command == AKONADI_CMD_ITEMLINK) {
+        return new Link(scope, true);
     }
-    if ( command == AKONADI_CMD_ITEMUNLINK ) {
-      return new Link( scope, false );
+    if (command == AKONADI_CMD_ITEMUNLINK) {
+        return new Link(scope, false);
     }
-    if ( command == AKONADI_CMD_RESOURCESELECT ) {
-      return new ResourceSelect();
+    if (command == AKONADI_CMD_RESOURCESELECT) {
+        return new ResourceSelect();
     }
-    if ( command == AKONADI_CMD_ITEMDELETE ) {
-      return new Remove( scope );
+    if (command == AKONADI_CMD_ITEMDELETE) {
+        return new Remove(scope);
     }
-    if ( command == AKONADI_CMD_ITEMMOVE ) {
-      return new Move( scope );
+    if (command == AKONADI_CMD_ITEMMOVE) {
+        return new Move(scope);
     }
-    if ( command == AKONADI_CMD_COLLECTIONMOVE ) {
-      return new ColMove( scope );
+    if (command == AKONADI_CMD_COLLECTIONMOVE) {
+        return new ColMove(scope);
     }
-    if ( command == AKONADI_CMD_TAGAPPEND ) {
-      return new TagAppend();
+    if (command == AKONADI_CMD_TAGAPPEND) {
+        return new TagAppend();
     }
-    if ( command == AKONADI_CMD_TAGFETCH ) {
-      return new TagFetch( scope );
+    if (command == AKONADI_CMD_TAGFETCH) {
+        return new TagFetch(scope);
     }
-    if ( command == AKONADI_CMD_TAGREMOVE ) {
-      return new TagRemove( scope );
+    if (command == AKONADI_CMD_TAGREMOVE) {
+        return new TagRemove(scope);
     }
-    if ( command == AKONADI_CMD_TAGSTORE ) {
-      return new TagStore();
+    if (command == AKONADI_CMD_TAGSTORE) {
+        return new TagStore();
     }
-    if ( command == AKONADI_CMD_MERGE ) {
-      return new Merge();
+    if (command == AKONADI_CMD_MERGE) {
+        return new Merge();
     }
 
     return 0;
 }
 
-void Handler::setConnection( Connection *connection )
+void Handler::setConnection(Connection *connection)
 {
     m_connection = connection;
 }
@@ -230,58 +230,58 @@ Connection *Handler::connection() const
     return m_connection;
 }
 
-bool Handler::failureResponse( const QByteArray &failureMessage )
+bool Handler::failureResponse(const QByteArray &failureMessage)
 {
-  Response response;
-  response.setTag( tag() );
-  response.setFailure();
-  response.setString( failureMessage );
-  Q_EMIT responseAvailable( response );
-  return false;
+    Response response;
+    response.setTag(tag());
+    response.setFailure();
+    response.setString(failureMessage);
+    Q_EMIT responseAvailable(response);
+    return false;
 }
 
-bool Handler::failureResponse( const char *failureMessage )
+bool Handler::failureResponse(const char *failureMessage)
 {
-  return failureResponse( QByteArray( failureMessage ) );
+    return failureResponse(QByteArray(failureMessage));
 }
 
-bool Handler::successResponse( const QByteArray &successMessage )
+bool Handler::successResponse(const QByteArray &successMessage)
 {
-  Response response;
-  response.setTag( tag() );
-  response.setSuccess();
-  response.setString( successMessage );
-  Q_EMIT responseAvailable( response );
-  return true;
+    Response response;
+    response.setTag(tag());
+    response.setSuccess();
+    response.setString(successMessage);
+    Q_EMIT responseAvailable(response);
+    return true;
 }
 
-bool Handler::successResponse( const char *successMessage )
+bool Handler::successResponse(const char *successMessage)
 {
-  return successResponse( QByteArray( successMessage ) );
+    return successResponse(QByteArray(successMessage));
 }
 
-void Handler::setStreamParser( ImapStreamParser *parser )
+void Handler::setStreamParser(ImapStreamParser *parser)
 {
-  m_streamParser = parser;
+    m_streamParser = parser;
 }
 
-UnknownCommandHandler::UnknownCommandHandler( const QByteArray &command )
-  : mCommand( command )
+UnknownCommandHandler::UnknownCommandHandler(const QByteArray &command)
+    : mCommand(command)
 {
 }
 
 bool UnknownCommandHandler::parseStream()
 {
-  Response response;
-  response.setError();
-  response.setTag( tag() );
-  if ( mCommand.isEmpty() ) {
-    response.setString( "No command specified" );
-  } else {
-    response.setString( "Unrecognized command: " + mCommand );
-  }
-  m_streamParser->readUntilCommandEnd();
+    Response response;
+    response.setError();
+    response.setTag(tag());
+    if (mCommand.isEmpty()) {
+        response.setString("No command specified");
+    } else {
+        response.setString("Unrecognized command: " + mCommand);
+    }
+    m_streamParser->readUntilCommandEnd();
 
-  Q_EMIT responseAvailable( response );
-  return true;
+    Q_EMIT responseAvailable(response);
+    return true;
 }
diff --git a/server/src/handlerhelper.cpp b/server/src/handlerhelper.cpp
index d42f0ad..9cfa613 100644
--- a/server/src/handlerhelper.cpp
+++ b/server/src/handlerhelper.cpp
@@ -33,327 +33,326 @@
 using namespace Akonadi;
 using namespace Akonadi::Server;
 
-Collection HandlerHelper::collectionFromIdOrName( const QByteArray &id )
+Collection HandlerHelper::collectionFromIdOrName(const QByteArray &id)
 {
-  // id is a number
-  bool ok = false;
-  qint64 collectionId = id.toLongLong( &ok );
-  if ( ok ) {
-    return Collection::retrieveById( collectionId );
-  }
-
-  // id is a path
-  QString path = QString::fromUtf8( id ); // ### should be UTF-7 for real IMAP \
                compatibility
-
-  const QStringList pathParts = path.split( QLatin1Char( '/' ), \
                QString::SkipEmptyParts );
-  Collection col;
-  Q_FOREACH ( const QString &part, pathParts ) {
-    SelectQueryBuilder<Collection> qb;
-    qb.addValueCondition( Collection::nameColumn(), Query::Equals, part );
-    if ( col.isValid() ) {
-      qb.addValueCondition( Collection::parentIdColumn(), Query::Equals, col.id() );
-    } else {
-      qb.addValueCondition( Collection::parentIdColumn(), Query::Is, QVariant() );
+    // id is a number
+    bool ok = false;
+    qint64 collectionId = id.toLongLong(&ok);
+    if (ok) {
+        return Collection::retrieveById(collectionId);
     }
-    if ( !qb.exec() ) {
-      return Collection();
-    }
-    Collection::List list = qb.result();
-    if ( list.count() != 1 ) {
-      return Collection();
+
+    // id is a path
+    QString path = QString::fromUtf8(id);   // ### should be UTF-7 for real IMAP \
compatibility +
+    const QStringList pathParts = path.split(QLatin1Char('/'), \
QString::SkipEmptyParts); +    Collection col;
+    Q_FOREACH (const QString &part, pathParts) {
+        SelectQueryBuilder<Collection> qb;
+        qb.addValueCondition(Collection::nameColumn(), Query::Equals, part);
+        if (col.isValid()) {
+            qb.addValueCondition(Collection::parentIdColumn(), Query::Equals, \
col.id()); +        } else {
+            qb.addValueCondition(Collection::parentIdColumn(), Query::Is, \
QVariant()); +        }
+        if (!qb.exec()) {
+            return Collection();
+        }
+        Collection::List list = qb.result();
+        if (list.count() != 1) {
+            return Collection();
+        }
+        col = list.first();
     }
-    col = list.first();
-  }
-  return col;
+    return col;
 }
 
-QString HandlerHelper::pathForCollection( const Collection &col )
+QString HandlerHelper::pathForCollection(const Collection &col)
 {
-  QStringList parts;
-  Collection current = col;
-  while ( current.isValid() ) {
-    parts.prepend( current.name() );
-    current = current.parent();
-  }
-  return parts.join( QLatin1String( "/" ) );
+    QStringList parts;
+    Collection current = col;
+    while (current.isValid()) {
+        parts.prepend(current.name());
+        current = current.parent();
+    }
+    return parts.join(QLatin1String("/"));
 }
 
-bool HandlerHelper::itemStatistics( const Collection &col, qint64 &count, qint64 \
&size ) +bool HandlerHelper::itemStatistics(const Collection &col, qint64 &count, \
qint64 &size)  {
-  QueryBuilder qb( PimItem::tableName() );
-  qb.addAggregation( PimItem::idColumn(), QLatin1String( "count" ) );
-  qb.addAggregation( PimItem::sizeColumn(), QLatin1String( "sum" ) );
-
-  if ( col.resource().isVirtual() ) {
-    qb.addJoin( QueryBuilder::InnerJoin, CollectionPimItemRelation::tableName(),
-                CollectionPimItemRelation::rightFullColumnName(), \
                PimItem::idFullColumnName() );
-    qb.addValueCondition( CollectionPimItemRelation::leftFullColumnName(), \
                Query::Equals, col.id() );
-  } else {
-    qb.addValueCondition( PimItem::collectionIdColumn(), Query::Equals, col.id() );
-  }
+    QueryBuilder qb(PimItem::tableName());
+    qb.addAggregation(PimItem::idColumn(), QLatin1String("count"));
+    qb.addAggregation(PimItem::sizeColumn(), QLatin1String("sum"));
+
+    if (col.resource().isVirtual()) {
+        qb.addJoin(QueryBuilder::InnerJoin, CollectionPimItemRelation::tableName(),
+                   CollectionPimItemRelation::rightFullColumnName(), \
PimItem::idFullColumnName()); +        \
qb.addValueCondition(CollectionPimItemRelation::leftFullColumnName(), Query::Equals, \
col.id()); +    } else {
+        qb.addValueCondition(PimItem::collectionIdColumn(), Query::Equals, \
col.id()); +    }
 
-  if ( !qb.exec() ) {
-    return false;
-  }
-  if ( !qb.query().next() ) {
-    akError() << "Error during retrieving result of statistics query:" << \
                qb.query().lastError().text();
-    return false;
-  }
-  count = qb.query().value( 0 ).toLongLong();
-  size = qb.query().value( 1 ).toLongLong();
-  return true;
+    if (!qb.exec()) {
+        return false;
+    }
+    if (!qb.query().next()) {
+        akError() << "Error during retrieving result of statistics query:" << \
qb.query().lastError().text(); +        return false;
+    }
+    count = qb.query().value(0).toLongLong();
+    size = qb.query().value(1).toLongLong();
+    return true;
 }
 
-int HandlerHelper::itemWithFlagsCount( const Collection &col, const QStringList \
&flags ) +int HandlerHelper::itemWithFlagsCount(const Collection &col, const \
QStringList &flags)  {
-  CountQueryBuilder qb( PimItem::tableName(), PimItem::idFullColumnName(), \
                CountQueryBuilder::Distinct );
-  qb.addJoin( QueryBuilder::InnerJoin, PimItemFlagRelation::tableName(),
-              PimItem::idFullColumnName(), PimItemFlagRelation::leftFullColumnName() \
                );
-  if ( col.isVirtual() ) {
-    qb.addJoin( QueryBuilder::InnerJoin, CollectionPimItemRelation::tableName(),
-                CollectionPimItemRelation::rightFullColumnName(), \
                PimItem::idFullColumnName() );
-    qb.addValueCondition( CollectionPimItemRelation::leftFullColumnName(), \
                Query::Equals, col.id() );
-  } else {
-    qb.addValueCondition( PimItem::collectionIdFullColumnName(), Query::Equals, \
                col.id() );
-  }
-  Query::Condition cond( Query::Or );
-  // We use the below instead of an inner join in the query above because postgres \
                seems
-  // to struggle to optimize the two inner joins, despite having indices that should
-  // facilitate that. This exploits the fact that the Flag::retrieveByName is fast \
                because
-  // it hits an in-memory cache.
-  Q_FOREACH ( const QString &flag, flags ) {
-    const Flag f = Flag::retrieveByName( flag );
-    cond.addValueCondition( PimItemFlagRelation::rightFullColumnName(), \
                Query::Equals, f.id() );
-  }
-  qb.addCondition( cond );
-  if ( !qb.exec() ) {
-    return -1;
-  }
-  return qb.result();
+    CountQueryBuilder qb(PimItem::tableName(), PimItem::idFullColumnName(), \
CountQueryBuilder::Distinct); +    qb.addJoin(QueryBuilder::InnerJoin, \
PimItemFlagRelation::tableName(), +               PimItem::idFullColumnName(), \
PimItemFlagRelation::leftFullColumnName()); +    if (col.isVirtual()) {
+        qb.addJoin(QueryBuilder::InnerJoin, CollectionPimItemRelation::tableName(),
+                   CollectionPimItemRelation::rightFullColumnName(), \
PimItem::idFullColumnName()); +        \
qb.addValueCondition(CollectionPimItemRelation::leftFullColumnName(), Query::Equals, \
col.id()); +    } else {
+        qb.addValueCondition(PimItem::collectionIdFullColumnName(), Query::Equals, \
col.id()); +    }
+    Query::Condition cond(Query::Or);
+    // We use the below instead of an inner join in the query above because postgres \
seems +    // to struggle to optimize the two inner joins, despite having indices \
that should +    // facilitate that. This exploits the fact that the \
Flag::retrieveByName is fast because +    // it hits an in-memory cache.
+    Q_FOREACH (const QString &flag, flags) {
+        const Flag f = Flag::retrieveByName(flag);
+        cond.addValueCondition(PimItemFlagRelation::rightFullColumnName(), \
Query::Equals, f.id()); +    }
+    qb.addCondition(cond);
+    if (!qb.exec()) {
+        return -1;
+    }
+    return qb.result();
 }
 
-int HandlerHelper::itemCount( const Collection &col )
+int HandlerHelper::itemCount(const Collection &col)
 {
-  CountQueryBuilder qb( PimItem::tableName() );
-  qb.addValueCondition( PimItem::collectionIdColumn(), Query::Equals, col.id() );
-  if ( !qb.exec() ) {
-    return -1;
-  }
-  return qb.result();
+    CountQueryBuilder qb(PimItem::tableName());
+    qb.addValueCondition(PimItem::collectionIdColumn(), Query::Equals, col.id());
+    if (!qb.exec()) {
+        return -1;
+    }
+    return qb.result();
 }
 
-int HandlerHelper::parseCachePolicy( const QByteArray &data, Collection &col, int \
start, bool *changed ) +int HandlerHelper::parseCachePolicy(const QByteArray &data, \
Collection &col, int start, bool *changed)  {
-  bool inheritChanged = false;
-  bool somethingElseChanged = false;
-
-  QList<QByteArray> params;
-  int end = ImapParser::parseParenthesizedList( data, params, start );
-  for ( int i = 0; i < params.count() - 1; i += 2 ) {
-    const QByteArray key = params[i];
-    const QByteArray value = params[i + 1];
-
-    if ( key == AKONADI_PARAM_INHERIT ) {
-      const bool inherit = value == "true";
-      inheritChanged = col.cachePolicyInherit() != inherit;
-      col.setCachePolicyInherit( inherit );
-    } else if ( key == AKONADI_PARAM_INTERVAL ) {
-      const int interval = value.toInt();
-      somethingElseChanged = somethingElseChanged || interval != \
                col.cachePolicyCheckInterval();
-      col.setCachePolicyCheckInterval( interval );
-    } else if ( key == AKONADI_PARAM_CACHETIMEOUT ) {
-      const int timeout = value.toInt();
-      somethingElseChanged = somethingElseChanged || timeout != \
                col.cachePolicyCacheTimeout();
-      col.setCachePolicyCacheTimeout( timeout );
-    } else if ( key == AKONADI_PARAM_SYNCONDEMAND ) {
-      const bool syncOnDemand = value == "true";
-      somethingElseChanged = somethingElseChanged || syncOnDemand != \
                col.cachePolicySyncOnDemand();
-      col.setCachePolicySyncOnDemand( syncOnDemand );
-    } else if ( key == AKONADI_PARAM_LOCALPARTS ) {
-      QList<QByteArray> tmp;
-      QStringList partsList;
-      ImapParser::parseParenthesizedList( value, tmp );
-      Q_FOREACH ( const QByteArray &ba, tmp ) {
-        partsList << QString::fromLatin1( ba );
-      }
-      const QString parts = partsList.join( QLatin1String( " " ) );
-      somethingElseChanged = somethingElseChanged || col.cachePolicyLocalParts() != \
                parts;
-      col.setCachePolicyLocalParts( parts );
+    bool inheritChanged = false;
+    bool somethingElseChanged = false;
+
+    QList<QByteArray> params;
+    int end = ImapParser::parseParenthesizedList(data, params, start);
+    for (int i = 0; i < params.count() - 1; i += 2) {
+        const QByteArray key = params[i];
+        const QByteArray value = params[i + 1];
+
+        if (key == AKONADI_PARAM_INHERIT) {
+            const bool inherit = value == "true";
+            inheritChanged = col.cachePolicyInherit() != inherit;
+            col.setCachePolicyInherit(inherit);
+        } else if (key == AKONADI_PARAM_INTERVAL) {
+            const int interval = value.toInt();
+            somethingElseChanged = somethingElseChanged || interval != \
col.cachePolicyCheckInterval(); +            \
col.setCachePolicyCheckInterval(interval); +        } else if (key == \
AKONADI_PARAM_CACHETIMEOUT) { +            const int timeout = value.toInt();
+            somethingElseChanged = somethingElseChanged || timeout != \
col.cachePolicyCacheTimeout(); +            col.setCachePolicyCacheTimeout(timeout);
+        } else if (key == AKONADI_PARAM_SYNCONDEMAND) {
+            const bool syncOnDemand = value == "true";
+            somethingElseChanged = somethingElseChanged || syncOnDemand != \
col.cachePolicySyncOnDemand(); +            \
col.setCachePolicySyncOnDemand(syncOnDemand); +        } else if (key == \
AKONADI_PARAM_LOCALPARTS) { +            QList<QByteArray> tmp;
+            QStringList partsList;
+            ImapParser::parseParenthesizedList(value, tmp);
+            Q_FOREACH (const QByteArray &ba, tmp) {
+                partsList << QString::fromLatin1(ba);
+            }
+            const QString parts = partsList.join(QLatin1String(" "));
+            somethingElseChanged = somethingElseChanged || \
col.cachePolicyLocalParts() != parts; +            \
col.setCachePolicyLocalParts(parts); +        }
     }
-  }
 
-  if ( changed && ( inheritChanged || ( !col.cachePolicyInherit() && \
                somethingElseChanged ) ) ) {
-    *changed = true;
-  }
+    if (changed && (inheritChanged || (!col.cachePolicyInherit() && \
somethingElseChanged))) { +        *changed = true;
+    }
 
-  return end;
+    return end;
 }
 
-QByteArray HandlerHelper::cachePolicyToByteArray( const Collection &col )
+QByteArray HandlerHelper::cachePolicyToByteArray(const Collection &col)
 {
-  QByteArray rv = AKONADI_PARAM_CACHEPOLICY " (";
-  rv += AKONADI_PARAM_INHERIT " " + ( col.cachePolicyInherit() ? QByteArray( "true" \
                ) : QByteArray( "false" ) );
-  rv += " " AKONADI_PARAM_INTERVAL " " + QByteArray::number( \
                col.cachePolicyCheckInterval() );
-  rv += " " AKONADI_PARAM_CACHETIMEOUT " " + QByteArray::number( \
                col.cachePolicyCacheTimeout() );
-  rv += " " AKONADI_PARAM_SYNCONDEMAND " " + ( col.cachePolicySyncOnDemand() ? \
                QByteArray( "true" ) : QByteArray( "false" ) );
-  rv += " " AKONADI_PARAM_LOCALPARTS " (" + col.cachePolicyLocalParts().toLatin1() + \
                ')';
-  rv += ')';
-  return rv;
+    QByteArray rv = AKONADI_PARAM_CACHEPOLICY " (";
+    rv += AKONADI_PARAM_INHERIT " " + (col.cachePolicyInherit() ? QByteArray("true") \
: QByteArray("false")); +    rv += " " AKONADI_PARAM_INTERVAL " " + \
QByteArray::number(col.cachePolicyCheckInterval()); +    rv += " " \
AKONADI_PARAM_CACHETIMEOUT " " + QByteArray::number(col.cachePolicyCacheTimeout()); + \
rv += " " AKONADI_PARAM_SYNCONDEMAND " " + (col.cachePolicySyncOnDemand() ? \
QByteArray("true") : QByteArray("false")); +    rv += " " AKONADI_PARAM_LOCALPARTS " \
(" + col.cachePolicyLocalParts().toLatin1() + ')'; +    rv += ')';
+    return rv;
 }
 
-QByteArray HandlerHelper::collectionToByteArray( const Collection &col, bool hidden, \
                bool includeStatistics,
-                                                 int ancestorDepth, const \
QStack<Collection> &ancestors ) +QByteArray \
HandlerHelper::collectionToByteArray(const Collection &col, bool hidden, bool \
includeStatistics, +                                                int \
ancestorDepth, const QStack<Collection> &ancestors)  {
-  QByteArray b = QByteArray::number( col.id() ) + ' '
-               + QByteArray::number( col.parentId() ) + " (";
+    QByteArray b = QByteArray::number(col.id()) + ' '
+                   + QByteArray::number(col.parentId()) + " (";
 
-  b += AKONADI_PARAM_NAME " " + ImapParser::quote( col.name().toUtf8() ) + ' ';
-  if ( hidden ) {
-    b += AKONADI_PARAM_MIMETYPE " () ";
-  } else {
-    b += AKONADI_PARAM_MIMETYPE " (" + MimeType::joinByName( col.mimeTypes(), \
                QLatin1String( " " ) ).toLatin1() + ") ";
-  }
-  b += AKONADI_PARAM_REMOTEID " " + ImapParser::quote( col.remoteId().toUtf8() );
-  b += " " AKONADI_PARAM_REMOTEREVISION " " + ImapParser::quote( \
                col.remoteRevision().toUtf8() );
-  b += " " AKONADI_PARAM_RESOURCE " " + ImapParser::quote( \
                col.resource().name().toUtf8() );
-  b += " " AKONADI_PARAM_VIRTUAL " " + QByteArray::number( col.isVirtual() ) + ' ';
-
-  if ( includeStatistics ) {
-    qint64 itemCount, itemSize;
-    if ( itemStatistics( col, itemCount, itemSize ) ) {
-      b += AKONADI_ATTRIBUTE_MESSAGES " " + QByteArray::number( itemCount ) + ' ';
-      // itemWithFlagCount is twice as fast as itemWithoutFlagCount, so emulated \
                that...
-      b += AKONADI_ATTRIBUTE_UNSEEN " ";
-      b += QByteArray::number( itemCount - itemWithFlagsCount( col, QStringList() << \
                QLatin1String( AKONADI_FLAG_SEEN )
-                                                                                  << \
                QLatin1String( AKONADI_FLAG_IGNORED ) ) );
-      b += " " AKONADI_PARAM_SIZE " " + QByteArray::number( itemSize ) + ' ';
+    b += AKONADI_PARAM_NAME " " + ImapParser::quote(col.name().toUtf8()) + ' ';
+    if (hidden) {
+        b += AKONADI_PARAM_MIMETYPE " () ";
+    } else {
+        b += AKONADI_PARAM_MIMETYPE " (" + MimeType::joinByName(col.mimeTypes(), \
QLatin1String(" ")).toLatin1() + ") "; +    }
+    b += AKONADI_PARAM_REMOTEID " " + ImapParser::quote(col.remoteId().toUtf8());
+    b += " " AKONADI_PARAM_REMOTEREVISION " " + \
ImapParser::quote(col.remoteRevision().toUtf8()); +    b += " " \
AKONADI_PARAM_RESOURCE " " + ImapParser::quote(col.resource().name().toUtf8()); +    \
b += " " AKONADI_PARAM_VIRTUAL " " + QByteArray::number(col.isVirtual()) + ' '; +
+    if (includeStatistics) {
+        qint64 itemCount, itemSize;
+        if (itemStatistics(col, itemCount, itemSize)) {
+            b += AKONADI_ATTRIBUTE_MESSAGES " " + QByteArray::number(itemCount) + ' \
'; +            // itemWithFlagCount is twice as fast as itemWithoutFlagCount, so \
emulated that... +            b += AKONADI_ATTRIBUTE_UNSEEN " ";
+            b += QByteArray::number(itemCount - itemWithFlagsCount(col, \
QStringList() << QLatin1String(AKONADI_FLAG_SEEN) +                                   \
<< QLatin1String(AKONADI_FLAG_IGNORED))); +            b += " " AKONADI_PARAM_SIZE " \
" + QByteArray::number(itemSize) + ' '; +        }
     }
-  }
-
-  if ( !col.queryString().isEmpty() ) {
-    b += AKONADI_PARAM_PERSISTENTSEARCH " ";
-    QList<QByteArray> args;
-    args.append( col.queryAttributes().toLatin1() );
-    args.append( AKONADI_PARAM_PERSISTENTSEARCH_QUERYSTRING );
-    args.append( ImapParser::quote( col.queryString().toUtf8() ) );
-    args.append( AKONADI_PARAM_PERSISTENTSEARCH_QUERYCOLLECTIONS );
-    args.append( "(" + col.queryCollections().toLatin1() + ")" );
-    b += ImapParser::quote( "(" + ImapParser::join( args, " " ) + ")" );
-    b += ' ';
-  }
 
-  b += HandlerHelper::cachePolicyToByteArray( col ) + ' ';
-  if ( ancestorDepth > 0 ) {
-    b += HandlerHelper::ancestorsToByteArray( ancestorDepth, ancestors ) + ' ';
-  }
+    if (!col.queryString().isEmpty()) {
+        b += AKONADI_PARAM_PERSISTENTSEARCH " ";
+        QList<QByteArray> args;
+        args.append(col.queryAttributes().toLatin1());
+        args.append(AKONADI_PARAM_PERSISTENTSEARCH_QUERYSTRING);
+        args.append(ImapParser::quote(col.queryString().toUtf8()));
+        args.append(AKONADI_PARAM_PERSISTENTSEARCH_QUERYCOLLECTIONS);
+        args.append("(" + col.queryCollections().toLatin1() + ")");
+        b += ImapParser::quote("(" + ImapParser::join(args, " ") + ")");
+        b += ' ';
+    }
 
-  const CollectionAttribute::List attrs = col.attributes();
-  for ( int i = 0; i < attrs.size(); ++i ) {
-    const CollectionAttribute &attr = attrs[i];
-    //Workaround to skip invalid "PARENT " attributes that were accidentaly created \
                after 6e5bbf6
-    if ( attr.type() == "PARENT" ) {
-      continue;
+    b += HandlerHelper::cachePolicyToByteArray(col) + ' ';
+    if (ancestorDepth > 0) {
+        b += HandlerHelper::ancestorsToByteArray(ancestorDepth, ancestors) + ' ';
     }
-    b += attr.type() + ' ' + ImapParser::quote( attr.value() );
-    if ( i != attrs.size() - 1 ) {
-      b += ' ';
+
+    const CollectionAttribute::List attrs = col.attributes();
+    for (int i = 0; i < attrs.size(); ++i) {
+        const CollectionAttribute &attr = attrs[i];
+        //Workaround to skip invalid "PARENT " attributes that were accidentaly \
created after 6e5bbf6 +        if (attr.type() == "PARENT") {
+            continue;
+        }
+        b += attr.type() + ' ' + ImapParser::quote(attr.value());
+        if (i != attrs.size() - 1) {
+            b += ' ';
+        }
     }
-  }
-  b+= ')';
+    b += ')';
 
-  return b;
+    return b;
 }
 
-QByteArray HandlerHelper::ancestorsToByteArray( int ancestorDepth, const \
QStack<Collection> &_ancestors ) +QByteArray HandlerHelper::ancestorsToByteArray(int \
ancestorDepth, const QStack<Collection> &_ancestors)  {
-  QByteArray b;
-  if ( ancestorDepth > 0 ) {
-    b += AKONADI_PARAM_ANCESTORS " (";
-    QStack<Collection> ancestors( _ancestors );
-    for ( int i = 0; i < ancestorDepth; ++i ) {
-      if ( ancestors.isEmpty() ) {
-        b += "(0 \"\")";
-        break;
-      }
-      b += '(';
-      const Collection c = ancestors.pop();
-      b += QByteArray::number( c.id() ) + " ";
-      b += ImapParser::quote( c.remoteId().toUtf8() );
-      b += ")";
-      if ( i != ancestorDepth - 1 ) {
-        b += ' ';
-      }
+    QByteArray b;
+    if (ancestorDepth > 0) {
+        b += AKONADI_PARAM_ANCESTORS " (";
+        QStack<Collection> ancestors(_ancestors);
+        for (int i = 0; i < ancestorDepth; ++i) {
+            if (ancestors.isEmpty()) {
+                b += "(0 \"\")";
+                break;
+            }
+            b += '(';
+            const Collection c = ancestors.pop();
+            b += QByteArray::number(c.id()) + " ";
+            b += ImapParser::quote(c.remoteId().toUtf8());
+            b += ")";
+            if (i != ancestorDepth - 1) {
+                b += ' ';
+            }
+        }
+        b += ')';
     }
-    b += ')';
-  }
-  return b;
+    return b;
 }
 
-int HandlerHelper::parseDepth( const QByteArray &depth )
+int HandlerHelper::parseDepth(const QByteArray &depth)
 {
-  if ( depth.isEmpty() ) {
-    throw ImapParserException( "No depth specified" );
-  }
-  if ( depth == "INF" ) {
-    return INT_MAX;
-  }
-  bool ok = false;
-  int result = depth.toInt( &ok );
-  if ( !ok ) {
-    throw ImapParserException( "Invalid depth argument" );
-  }
-  return result;
+    if (depth.isEmpty()) {
+        throw ImapParserException("No depth specified");
+    }
+    if (depth == "INF") {
+        return INT_MAX;
+    }
+    bool ok = false;
+    int result = depth.toInt(&ok);
+    if (!ok) {
+        throw ImapParserException("Invalid depth argument");
+    }
+    return result;
 }
 
-Flag::List HandlerHelper::resolveFlags( const QVector<QByteArray> &flagNames )
+Flag::List HandlerHelper::resolveFlags(const QVector<QByteArray> &flagNames)
 {
-  Flag::List flagList;
-  Q_FOREACH ( const QByteArray &flagName, flagNames ) {
-    Flag flag = Flag::retrieveByName( QString::fromUtf8( flagName ) );
-    if ( !flag.isValid() ) {
-      flag = Flag( QString::fromUtf8( flagName ) );
-      if ( !flag.insert() ) {
-        throw HandlerException( "Unable to create flag" );
-      }
+    Flag::List flagList;
+    Q_FOREACH (const QByteArray &flagName, flagNames) {
+        Flag flag = Flag::retrieveByName(QString::fromUtf8(flagName));
+        if (!flag.isValid()) {
+            flag = Flag(QString::fromUtf8(flagName));
+            if (!flag.insert()) {
+                throw HandlerException("Unable to create flag");
+            }
+        }
+        flagList.append(flag);
     }
-    flagList.append( flag );
-  }
-  return flagList;
+    return flagList;
 }
 
-Tag::List HandlerHelper::resolveTags( const ImapSet &tags )
+Tag::List HandlerHelper::resolveTags(const ImapSet &tags)
 {
-  SelectQueryBuilder<Tag> qb;
-  QueryHelper::setToQuery( tags, Tag::idFullColumnName(), qb );
-  if ( !qb.exec() ) {
-    throw HandlerException( "Unable to resolve tags" );
-  }
-  const Tag::List result = qb.result();
-  if ( result.isEmpty() ) {
-    throw HandlerException( "No tags found" );
-  }
-  return result;
+    SelectQueryBuilder<Tag> qb;
+    QueryHelper::setToQuery(tags, Tag::idFullColumnName(), qb);
+    if (!qb.exec()) {
+        throw HandlerException("Unable to resolve tags");
+    }
+    const Tag::List result = qb.result();
+    if (result.isEmpty()) {
+        throw HandlerException("No tags found");
+    }
+    return result;
 }
 
-Tag::List HandlerHelper::resolveTags( const QVector< QByteArray > &tagNames, \
CommandContext *context ) +Tag::List HandlerHelper::resolveTags(const QVector< \
QByteArray > &tagNames, CommandContext *context)  {
-  if (tagNames.isEmpty()) {
-    return Tag::List();
-  }
-  SelectQueryBuilder<Tag> qb;
-  Query::Condition cond;
-  cond.addColumnCondition( Tag::idFullColumnName(), Query::Equals, \
                TagRemoteIdResourceRelation::tagIdFullColumnName() );
-  cond.addValueCondition( TagRemoteIdResourceRelation::resourceIdFullColumnName(), \
                Query::Equals, context->resource().id() );
-  qb.addJoin( QueryBuilder::LeftJoin, TagRemoteIdResourceRelation::tableName(), cond \
                );
-  qb.addValueCondition( TagRemoteIdResourceRelation::remoteIdFullColumnName(), \
                Query::In, QVariant::fromValue( tagNames ) );
-  if  ( !qb.exec() ) {
-    throw HandlerException( "Unable to resolve tags" );
-  }
+    if (tagNames.isEmpty()) {
+        return Tag::List();
+    }
+    SelectQueryBuilder<Tag> qb;
+    Query::Condition cond;
+    cond.addColumnCondition(Tag::idFullColumnName(), Query::Equals, \
TagRemoteIdResourceRelation::tagIdFullColumnName()); +    \
cond.addValueCondition(TagRemoteIdResourceRelation::resourceIdFullColumnName(), \
Query::Equals, context->resource().id()); +    qb.addJoin(QueryBuilder::LeftJoin, \
TagRemoteIdResourceRelation::tableName(), cond); +    \
qb.addValueCondition(TagRemoteIdResourceRelation::remoteIdFullColumnName(), \
Query::In, QVariant::fromValue(tagNames)); +    if (!qb.exec()) {
+        throw HandlerException("Unable to resolve tags");
+    }
 
-  const Tag::List result = qb.result();
-  if ( result.isEmpty() ) {
-    throw HandlerException( "No tags found" );
-  }
-  return result;
+    const Tag::List result = qb.result();
+    if (result.isEmpty()) {
+        throw HandlerException("No tags found");
+    }
+    return result;
 }
-
diff --git a/server/src/imapstreamparser.cpp b/server/src/imapstreamparser.cpp
index 1831f21..5d634dc 100644
--- a/server/src/imapstreamparser.cpp
+++ b/server/src/imapstreamparser.cpp
@@ -31,11 +31,11 @@
 using namespace Akonadi;
 using namespace Akonadi::Server;
 
-ImapStreamParser::ImapStreamParser( QIODevice *socket )
-  : m_socket( socket )
-  , m_position( 0 )
-  , m_literalSize( 0 )
-  , m_peeking( false )
+ImapStreamParser::ImapStreamParser(QIODevice *socket)
+    : m_socket(socket)
+    , m_position(0)
+    , m_literalSize(0)
+    , m_peeking(false)
 {
 }
 
@@ -45,789 +45,789 @@ ImapStreamParser::~ImapStreamParser()
 
 QString ImapStreamParser::readUtf8String()
 {
-  QByteArray tmp;
-  tmp = readString();
-  QString result = QString::fromUtf8( tmp );
-  return result;
+    QByteArray tmp;
+    tmp = readString();
+    QString result = QString::fromUtf8(tmp);
+    return result;
 }
 
 QByteArray ImapStreamParser::readString()
 {
-  QByteArray result;
-  if ( !waitForMoreData( m_data.length() == 0 ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  stripLeadingSpaces();
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-
-  // literal string
-  // TODO: error handling
-  if ( hasLiteral() ) {
-    while ( !atLiteralEnd() ) {
-      result += readLiteralPart();
+    QByteArray result;
+    if (!waitForMoreData(m_data.length() == 0)) {
+        throw ImapParserException("Unable to read more data");
+    }
+    stripLeadingSpaces();
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+
+    // literal string
+    // TODO: error handling
+    if (hasLiteral()) {
+        while (!atLiteralEnd()) {
+            result += readLiteralPart();
+        }
+        return result;
     }
-    return result;
-  }
 
-  // quoted string
-  return parseQuotedString();
+    // quoted string
+    return parseQuotedString();
 }
 
 QByteArray ImapStreamParser::peekString()
 {
-  m_peeking = true;
-  int pos = m_position;
-  const QByteArray string = readString();
-  m_position = pos;
-  m_peeking = false;
-  return string;
+    m_peeking = true;
+    int pos = m_position;
+    const QByteArray string = readString();
+    m_position = pos;
+    m_peeking = false;
+    return string;
 }
 
 bool ImapStreamParser::hasString()
 {
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  int savedPos = m_position ;
-  stripLeadingSpaces();
-  int pos = m_position;
-  m_position = savedPos;
-  if ( m_data[pos] == '{' ) {
-    return true; //literal string
-  }
-  if ( m_data[pos] == '"' ) {
-    return true; //quoted string
-  }
-  if ( m_data[pos] != ' ' &&
-       m_data[pos] != '(' &&
-       m_data[pos] != ')' &&
-       m_data[pos] != '[' &&
-       m_data[pos] != ']' &&
-       m_data[pos] != '\n' &&
-       m_data[pos] != '\r' ) {
-    return true;  //unquoted string
-  }
-
-  return false; //something else, not a string
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    int savedPos = m_position ;
+    stripLeadingSpaces();
+    int pos = m_position;
+    m_position = savedPos;
+    if (m_data[pos] == '{') {
+        return true; //literal string
+    }
+    if (m_data[pos] == '"') {
+        return true; //quoted string
+    }
+    if (m_data[pos] != ' ' &&
+        m_data[pos] != '(' &&
+        m_data[pos] != ')' &&
+        m_data[pos] != '[' &&
+        m_data[pos] != ']' &&
+        m_data[pos] != '\n' &&
+        m_data[pos] != '\r') {
+        return true;  //unquoted string
+    }
+
+    return false; //something else, not a string
 }
 
 bool ImapStreamParser::hasLiteral()
 {
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  int savedPos = m_position;
-  stripLeadingSpaces();
-  if ( m_data[m_position] == '{' ) {
-    int end = -1;
-    do {
-      end = m_data.indexOf( '}', m_position );
-      if ( !waitForMoreData( end == -1 ) ) {
-        throw ImapParserException( "Unable to read more data" );
-      }
-    } while ( end == -1 );
-    Q_ASSERT( end > m_position );
-    m_literalSize = m_data.mid( m_position + 1, end - m_position - 1 ).toInt();
-    // strip CRLF
-    m_position = end + 1;
-
-    //IMAP inconsistency. IMAP always expects CRLF, but akonadi uses only LF.
-    if ( m_position < m_data.length() && m_data[m_position] == '\n' ) {
-      ++m_position;
-    }
-
-    if ( m_literalSize >= 0 ) {
-      sendContinuationResponse( m_literalSize );
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    int savedPos = m_position;
+    stripLeadingSpaces();
+    if (m_data[m_position] == '{') {
+        int end = -1;
+        do {
+            end = m_data.indexOf('}', m_position);
+            if (!waitForMoreData(end == -1)) {
+                throw ImapParserException("Unable to read more data");
+            }
+        } while (end == -1);
+        Q_ASSERT(end > m_position);
+        m_literalSize = m_data.mid(m_position + 1, end - m_position - 1).toInt();
+        // strip CRLF
+        m_position = end + 1;
+
+        //IMAP inconsistency. IMAP always expects CRLF, but akonadi uses only LF.
+        if (m_position < m_data.length() && m_data[m_position] == '\n') {
+            ++m_position;
+        }
+
+        if (m_literalSize >= 0) {
+            sendContinuationResponse(m_literalSize);
+        }
+        return true;
+    } else {
+        m_position = savedPos;
+        return false;
     }
-    return true;
-  } else {
-    m_position = savedPos;
-    return false;
-  }
 }
 
 bool ImapStreamParser::atLiteralEnd() const
 {
-  return ( m_literalSize == 0 );
+    return (m_literalSize == 0);
 }
 
 qint64 ImapStreamParser::remainingLiteralSize()
 {
-  return m_literalSize;
+    return m_literalSize;
 }
 
 QByteArray ImapStreamParser::readLiteralPart()
 {
-  static qint64 maxLiteralPartSize = 4096;
-  int size = qMin( maxLiteralPartSize, m_literalSize );
+    static qint64 maxLiteralPartSize = 4096;
+    int size = qMin(maxLiteralPartSize, m_literalSize);
 
-  if ( !waitForMoreData( m_data.length() < m_position + size ) ) {
-       throw ImapParserException( "Unable to read more data" );
-  }
+    if (!waitForMoreData(m_data.length() < m_position + size)) {
+        throw ImapParserException("Unable to read more data");
+    }
 
-  if ( m_data.length() < m_position + size ) { // Still not enough data
-    // Take what's already there
-    size = m_data.length() - m_position;
-  }
+    if (m_data.length() < m_position + size) {   // Still not enough data
+        // Take what's already there
+        size = m_data.length() - m_position;
+    }
 
-  QByteArray result = m_data.mid( m_position, size );
-  m_position += size;
-  m_literalSize -= size;
-  Q_ASSERT( m_literalSize >= 0 );
-  if ( !m_peeking ) {
-    m_data = m_data.right( m_data.size() - m_position );
-    m_position = 0;
-  }
-  return result;
+    QByteArray result = m_data.mid(m_position, size);
+    m_position += size;
+    m_literalSize -= size;
+    Q_ASSERT(m_literalSize >= 0);
+    if (!m_peeking) {
+        m_data = m_data.right(m_data.size() - m_position);
+        m_position = 0;
+    }
+    return result;
 }
 
 bool ImapStreamParser::hasSequenceSet()
 {
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  int savedPos = m_position;
-  stripLeadingSpaces();
-  int pos = m_position;
-  m_position = savedPos;
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    int savedPos = m_position;
+    stripLeadingSpaces();
+    int pos = m_position;
+    m_position = savedPos;
 
-  if ( m_data[pos] == '*' ||  m_data[pos] == ':'|| isdigit( m_data[pos] ) ) {
-    return true;
-  }
+    if (m_data[pos] == '*' ||  m_data[pos] == ':' || isdigit(m_data[pos])) {
+        return true;
+    }
 
-  return false;
+    return false;
 }
 
 ImapSet ImapStreamParser::readSequenceSet()
 {
-  ImapSet result;
-  if ( !waitForMoreData( m_data.length() == 0 ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  stripLeadingSpaces();
-  qint64 value = -1, lower = -1, upper = -1;
-  Q_FOREVER {
-    if ( !waitForMoreData( m_data.length() <= m_position ) ) {
-      upper = value;
-      if ( lower < 0 ) {
-        lower = value;
-      }
-      if ( lower >= 0 && upper >= 0 ) {
-        result.add( ImapInterval( lower, upper ) );
-      }
-      return result;
-    }
-
-    if ( m_data[m_position] == '*' ) {
-      value = 0;
-    } else if ( m_data[m_position] == ':' ) {
-      lower = value;
-    } else if ( isdigit( m_data[m_position] ) ) {
-      bool ok = false;
-      value = readNumber( &ok );
-      Q_ASSERT( ok ); // TODO handle error
-      --m_position;
-    } else {
-      upper = value;
-      if ( lower < 0 ) {
-        lower = value;
-      }
-      result.add( ImapInterval( lower, upper ) );
-      lower = -1;
-      upper = -1;
-      value = -1;
-      if ( m_data[m_position] != ',' ) {
-        return result;
-      }
+    ImapSet result;
+    if (!waitForMoreData(m_data.length() == 0)) {
+        throw ImapParserException("Unable to read more data");
+    }
+    stripLeadingSpaces();
+    qint64 value = -1, lower = -1, upper = -1;
+    Q_FOREVER {
+        if (!waitForMoreData(m_data.length() <= m_position)) {
+            upper = value;
+            if (lower < 0) {
+                lower = value;
+            }
+            if (lower >= 0 && upper >= 0) {
+                result.add(ImapInterval(lower, upper));
+            }
+            return result;
+        }
+
+        if (m_data[m_position] == '*') {
+            value = 0;
+        } else if (m_data[m_position] == ':') {
+            lower = value;
+        } else if (isdigit(m_data[m_position])) {
+            bool ok = false;
+            value = readNumber(&ok);
+            Q_ASSERT(ok);   // TODO handle error
+            --m_position;
+        } else {
+            upper = value;
+            if (lower < 0) {
+                lower = value;
+            }
+            result.add(ImapInterval(lower, upper));
+            lower = -1;
+            upper = -1;
+            value = -1;
+            if (m_data[m_position] != ',') {
+                return result;
+            }
+        }
+        ++m_position;
     }
-    ++m_position;
-  }
 }
 
 bool ImapStreamParser::hasList()
 {
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  int savedPos = m_position;
-  stripLeadingSpaces();
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  int pos = m_position;
-  m_position = savedPos;
-  if ( m_data[pos] == '(' ) {
-    return true;
-  }
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    int savedPos = m_position;
+    stripLeadingSpaces();
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    int pos = m_position;
+    m_position = savedPos;
+    if (m_data[pos] == '(') {
+        return true;
+    }
 
-  return false;
+    return false;
 }
 
 void ImapStreamParser::beginList()
 {
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  stripLeadingSpaces();
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  if ( m_data[m_position] != '(' ) {
-    throw ImapParserException( "Stream not at a beginning of a list" );
-  }
-  ++m_position;
-  return;
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    stripLeadingSpaces();
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    if (m_data[m_position] != '(') {
+        throw ImapParserException("Stream not at a beginning of a list");
+    }
+    ++m_position;
+    return;
 }
 
 bool ImapStreamParser::atListEnd()
 {
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  int savedPos = m_position;
-  stripLeadingSpaces();
-  int pos = m_position;
-  m_position = savedPos;
-  if ( m_data[pos] == ')' ) {
-    m_position = pos + 1;
-    return true;
-  }
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    int savedPos = m_position;
+    stripLeadingSpaces();
+    int pos = m_position;
+    m_position = savedPos;
+    if (m_data[pos] == ')') {
+        m_position = pos + 1;
+        return true;
+    }
 
-  return false;
+    return false;
 }
 
 QList<QByteArray> ImapStreamParser::readParenthesizedList()
 {
-  QList<QByteArray> result;
-  if ( !waitForMoreData( m_data.length() <= m_position ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-
-  stripLeadingSpaces();
-  if ( m_data[m_position] != '(' ) {
-    return result; //no list found
-  }
-
-  bool concatToLast = false;
-  int count = 0;
-  int sublistbegin = m_position;
-  int i = m_position + 1;
-  Q_FOREVER {
-    if ( !waitForMoreData( m_data.length() <= i ) ) {
-      m_position = i;
-      throw ImapParserException( "Unable to read more data" );
-    }
-    if ( m_data[i] == '(' ) {
-      ++count;
-      if ( count == 1 ) {
-        sublistbegin = i;
-      }
-      ++i;
-      continue;
-    }
-    if ( m_data[i] == ')' ) {
-      if ( count <= 0 ) {
-        m_position = i + 1;
-        return result;
-      }
-      if ( count == 1 ) {
-        result.append( m_data.mid( sublistbegin, i - sublistbegin + 1 ) );
-      }
-      --count;
-      ++i;
-      continue;
-    }
-    if ( m_data[i] == ' ' ) {
-      ++i;
-      continue;
-    }
-    if ( m_data.at( i ) == '"' ) {
-      if ( count > 0 ) {
-        m_position = i;
-        parseQuotedString();
-        i = m_position;
-        continue;
-      }
-    }
-    if ( m_data[i] == '[' ) {
-      concatToLast = true;
-      result.last() += '[';
-      ++i;
-      continue;
-    }
-    if ( m_data[i] == ']' ) {
-      concatToLast = false;
-      result.last() += ']';
-      ++i;
-      continue;
-    }
-    if ( count == 0 ) {
-      m_position = i;
-      QByteArray ba;
-      if ( hasLiteral() ) {
-        while ( !atLiteralEnd() ) {
-          ba += readLiteralPart();
-        }
-      } else {
-        ba = readString();
-      }
-
-      // We might sometime get some unwanted CRLF, but we're still not at the end
-      // of the list, would make further string reads fail so eat the CRLFs.
-      while ( ( m_position < m_data.size() ) &&
-        ( m_data[m_position]=='\r' || m_data[m_position]=='\n' ) ) {
-        m_position++;
-      }
-
-      i = m_position - 1;
-      if ( concatToLast ) {
-        result.last() += ba;
-      } else {
-        result.append( ba );
-      }
-    }
-    ++i;
-  }
-
-  throw ImapParserException( "Something went very very wrong!" );
+    QList<QByteArray> result;
+    if (!waitForMoreData(m_data.length() <= m_position)) {
+        throw ImapParserException("Unable to read more data");
+    }
+
+    stripLeadingSpaces();
+    if (m_data[m_position] != '(') {
+        return result; //no list found
+    }
+
+    bool concatToLast = false;
+    int count = 0;
+    int sublistbegin = m_position;
+    int i = m_position + 1;
+    Q_FOREVER {
+        if (!waitForMoreData(m_data.length() <= i)) {
+            m_position = i;
+            throw ImapParserException("Unable to read more data");
+        }
+        if (m_data[i] == '(') {
+            ++count;
+            if (count == 1) {
+                sublistbegin = i;
+            }
+            ++i;
+            continue;
+        }
+        if (m_data[i] == ')') {
+            if (count <= 0) {
+                m_position = i + 1;
+                return result;
+            }
+            if (count == 1) {
+                result.append(m_data.mid(sublistbegin, i - sublistbegin + 1));
+            }
+            --count;
+            ++i;
+            continue;
+        }
+        if (m_data[i] == ' ') {
+            ++i;
+            continue;
+        }
+        if (m_data.at(i) == '"') {
+            if (count > 0) {
+                m_position = i;
+                parseQuotedString();
+                i = m_position;
+                continue;
+            }
+        }
+        if (m_data[i] == '[') {
+            concatToLast = true;
+            result.last() += '[';
+            ++i;
+            continue;
+        }
+        if (m_data[i] == ']') {
+            concatToLast = false;
+            result.last() += ']';
+            ++i;
+            continue;
+        }
+        if (count == 0) {
+            m_position = i;
+            QByteArray ba;
+            if (hasLiteral()) {
+                while (!atLiteralEnd()) {
+                    ba += readLiteralPart();
+                }
+            } else {
+                ba = readString();
+            }
+
+            // We might sometime get some unwanted CRLF, but we're still not at the \
end +            // of the list, would make further string reads fail so eat the \
CRLFs. +            while ((m_position < m_data.size()) &&
+                   (m_data[m_position] == '\r' || m_data[m_position] == '\n')) {
+                m_position++;
+            }
+
+            i = m_position - 1;
+            if (concatToLast) {
+                result.last() += ba;
+            } else {
+                result.append(ba);
+            }
+        }
+        ++i;
+    }
+
+    throw ImapParserException("Something went very very wrong!");
 }
 
 QByteRef ImapStreamParser::readChar()
 {
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  m_position++;
-  return m_data[m_position - 1];
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    m_position++;
+    return m_data[m_position - 1];
 }
 
 QDateTime ImapStreamParser::readDateTime()
 {
-  // Syntax:
-  // date-time      = DQUOTE date-day-fixed "-" date-month "-" date-year
-  //                  SP time SP zone DQUOTE
-  // date-day-fixed = (SP DIGIT) / 2DIGIT
-  //                    ; Fixed-format version of date-day
-  // date-month     = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
-  //                  "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
-  // date-year      = 4DIGIT
-  // time           = 2DIGIT ":" 2DIGIT ":" 2DIGIT
-  //                    ; Hours minutes seconds
-  // zone           = ("+" / "-") 4DIGIT
-  //                    ; Signed four-digit value of hhmm representing
-  //                    ; hours and minutes east of Greenwich (that is,
-  //                    ; the amount that the given time differs from
-  //                    ; Universal Time).  Subtracting the timezone
-  //                    ; from the given time will give the UT form.
-  //                    ; The Universal Time zone is "+0000".
-  // Example : "28-May-2006 01:03:35 +0200"
-  // Position: 0123456789012345678901234567
-  //                     1         2
-
-  int savedPos = m_position;
-  if ( !waitForMoreData( m_data.length() == 0 ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  stripLeadingSpaces();
-
-  bool quoted = false;
-  if ( m_data[m_position] == '"' ) {
-    quoted = true;
-    ++m_position;
-
-    if ( m_data.length() <= m_position + 26 ) {
-      m_position = savedPos;
-      return QDateTime();
-    }
-  } else {
-    if ( m_data.length() < m_position + 26 ) {
-      m_position = savedPos;
-      return QDateTime();
+    // Syntax:
+    // date-time      = DQUOTE date-day-fixed "-" date-month "-" date-year
+    //                  SP time SP zone DQUOTE
+    // date-day-fixed = (SP DIGIT) / 2DIGIT
+    //                    ; Fixed-format version of date-day
+    // date-month     = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
+    //                  "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
+    // date-year      = 4DIGIT
+    // time           = 2DIGIT ":" 2DIGIT ":" 2DIGIT
+    //                    ; Hours minutes seconds
+    // zone           = ("+" / "-") 4DIGIT
+    //                    ; Signed four-digit value of hhmm representing
+    //                    ; hours and minutes east of Greenwich (that is,
+    //                    ; the amount that the given time differs from
+    //                    ; Universal Time).  Subtracting the timezone
+    //                    ; from the given time will give the UT form.
+    //                    ; The Universal Time zone is "+0000".
+    // Example : "28-May-2006 01:03:35 +0200"
+    // Position: 0123456789012345678901234567
+    //                     1         2
+
+    int savedPos = m_position;
+    if (!waitForMoreData(m_data.length() == 0)) {
+        throw ImapParserException("Unable to read more data");
+    }
+    stripLeadingSpaces();
+
+    bool quoted = false;
+    if (m_data[m_position] == '"') {
+        quoted = true;
+        ++m_position;
+
+        if (m_data.length() <= m_position + 26) {
+            m_position = savedPos;
+            return QDateTime();
+        }
+    } else {
+        if (m_data.length() < m_position + 26) {
+            m_position = savedPos;
+            return QDateTime();
+        }
     }
-  }
 
-  bool ok = true;
-  const int day = ( m_data[m_position] == ' ' ? m_data[m_position + 1] - '0' // \
                single digit day
-                                              : m_data.mid( m_position, 2 ).toInt( \
                &ok ) );
-  if ( !ok ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  m_position += 3;
-  const QByteArray shortMonthNames( "janfebmaraprmayjunjulaugsepoctnovdec" );
-  int month = shortMonthNames.indexOf( m_data.mid( m_position, 3 ).toLower() );
-  if ( month == -1 ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  month = month / 3 + 1;
-  m_position += 4;
-  const int year = m_data.mid( m_position, 4 ).toInt( &ok );
-  if ( !ok ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  m_position += 5;
-  const int hours = m_data.mid( m_position, 2 ).toInt( &ok );
-  if ( !ok ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  m_position += 3;
-  const int minutes = m_data.mid( m_position, 2 ).toInt( &ok );
-  if ( !ok ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  m_position += 3;
-  const int seconds = m_data.mid( m_position, 2 ).toInt( &ok );
-  if ( !ok ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  m_position += 4;
-  const int tzhh = m_data.mid( m_position, 2 ).toInt( &ok );
-  if ( !ok ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  m_position += 2;
-  const int tzmm = m_data.mid( m_position, 2 ).toInt( &ok );
-  if ( !ok ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  int tzsecs = tzhh * 60 * 60 + tzmm * 60;
-  if ( m_data[m_position - 3] == '-' ) {
-    tzsecs = -tzsecs;
-  }
-  const QDate date( year, month, day );
-  const QTime time( hours, minutes, seconds );
-  QDateTime dateTime;
-  dateTime = QDateTime( date, time, Qt::UTC );
-  if ( !dateTime.isValid() ) {
-    m_position = savedPos;
-    return QDateTime();
-  }
-  dateTime = dateTime.addSecs( -tzsecs );
-
-  m_position += 2;
-  if ( m_data.length() <= m_position || !quoted ) {
+    bool ok = true;
+    const int day = (m_data[m_position] == ' ' ? m_data[m_position + 1] - '0'  // \
single digit day +                     : m_data.mid(m_position, 2).toInt(&ok));
+    if (!ok) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    m_position += 3;
+    const QByteArray shortMonthNames("janfebmaraprmayjunjulaugsepoctnovdec");
+    int month = shortMonthNames.indexOf(m_data.mid(m_position, 3).toLower());
+    if (month == -1) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    month = month / 3 + 1;
+    m_position += 4;
+    const int year = m_data.mid(m_position, 4).toInt(&ok);
+    if (!ok) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    m_position += 5;
+    const int hours = m_data.mid(m_position, 2).toInt(&ok);
+    if (!ok) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    m_position += 3;
+    const int minutes = m_data.mid(m_position, 2).toInt(&ok);
+    if (!ok) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    m_position += 3;
+    const int seconds = m_data.mid(m_position, 2).toInt(&ok);
+    if (!ok) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    m_position += 4;
+    const int tzhh = m_data.mid(m_position, 2).toInt(&ok);
+    if (!ok) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    m_position += 2;
+    const int tzmm = m_data.mid(m_position, 2).toInt(&ok);
+    if (!ok) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    int tzsecs = tzhh * 60 * 60 + tzmm * 60;
+    if (m_data[m_position - 3] == '-') {
+        tzsecs = -tzsecs;
+    }
+    const QDate date(year, month, day);
+    const QTime time(hours, minutes, seconds);
+    QDateTime dateTime;
+    dateTime = QDateTime(date, time, Qt::UTC);
+    if (!dateTime.isValid()) {
+        m_position = savedPos;
+        return QDateTime();
+    }
+    dateTime = dateTime.addSecs(-tzsecs);
+
+    m_position += 2;
+    if (m_data.length() <= m_position || !quoted) {
+        return dateTime;
+    }
+    if (m_data[m_position] == '"') {
+        ++m_position;
+    }
     return dateTime;
-  }
-  if ( m_data[m_position] == '"' ) {
-    ++m_position;
-  }
-  return dateTime;
 }
 
 bool ImapStreamParser::hasDateTime()
 {
-  int savedPos = m_position;
-  QDateTime dateTime = readDateTime();
-  m_position = savedPos;
-  return !dateTime.isNull();
+    int savedPos = m_position;
+    QDateTime dateTime = readDateTime();
+    m_position = savedPos;
+    return !dateTime.isNull();
 }
 
 QByteArray ImapStreamParser::parseQuotedString()
 {
-  QByteArray result;
-  if ( !waitForMoreData( m_data.length() == 0 ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  stripLeadingSpaces();
-  int end = m_position;
-  result.clear();
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-
-  bool foundSlash = false;
-  // quoted string
-  if ( m_data[m_position] == '"' ) {
-    ++m_position;
-    int i = m_position;
-    Q_FOREVER {
-      if ( !waitForMoreData( m_data.length() <= i ) ) {
-        m_position = i;
-        throw ImapParserException( "Unable to read more data" );
-      }
-
-      if ( foundSlash ) {
-        foundSlash = false;
-        if ( m_data[i] == 'r' ) {
-          result += '\r';
-        } else if ( m_data[i] == 'n' ) {
-          result += '\n';
-        } else if ( m_data[i] == '\\' ) {
-          result += '\\';
-        } else if ( m_data[i] == '\"' ) {
-          result += '\"';
-        } else {
-          throw ImapParserException( "Unexpected '\\' in quoted string" );
+    QByteArray result;
+    if (!waitForMoreData(m_data.length() == 0)) {
+        throw ImapParserException("Unable to read more data");
+    }
+    stripLeadingSpaces();
+    int end = m_position;
+    result.clear();
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+
+    bool foundSlash = false;
+    // quoted string
+    if (m_data[m_position] == '"') {
+        ++m_position;
+        int i = m_position;
+        Q_FOREVER {
+            if (!waitForMoreData(m_data.length() <= i)) {
+                m_position = i;
+                throw ImapParserException("Unable to read more data");
+            }
+
+            if (foundSlash) {
+                foundSlash = false;
+                if (m_data[i] == 'r') {
+                    result += '\r';
+                } else if (m_data[i] == 'n') {
+                    result += '\n';
+                } else if (m_data[i] == '\\') {
+                    result += '\\';
+                } else if (m_data[i] == '\"') {
+                    result += '\"';
+                } else {
+                    throw ImapParserException("Unexpected '\\' in quoted string");
+                }
+                ++i;
+                continue;
+            }
+
+            if (m_data[i] == '\\') {
+                foundSlash = true;
+                ++i;
+                continue;
+            }
+
+            if (m_data[i] == '"') {
+                end = i + 1; // skip the '"'
+                break;
+            }
+
+            result += m_data[i];
+
+            ++i;
         }
-        ++i;
-        continue;
-      }
+    }
 
-      if ( m_data[i] == '\\' ) {
-        foundSlash = true;
-        ++i;
-        continue;
-      }
+    // unquoted string
+    else {
+        bool reachedInputEnd = true;
+        int i = m_position;
+        Q_FOREVER {
+            if (!waitForMoreData(m_data.length() <= i)) {
+                m_position = i;
+                throw ImapParserException("Unable to read more data");
+            }
+            // unlike in the copy in KIMAP we do not want to consider [] brackets as \
separators, breaks payload version parsing +            // if that ever gets fixed we \
can re-add them here, see svn revision 937879 +            if (m_data[i] == ' ' || \
m_data[i] == '(' || m_data[i] == ')' || m_data[i] == '\n' || m_data[i] == '\r' || \
m_data[i] == '"') { +                end = i;
+                reachedInputEnd = false;
+                break;
+            }
+            if (m_data[i] == '\\') {
+                foundSlash = true;
+            }
+            i++;
+        }
+        if (reachedInputEnd) {   //FIXME: how can it get here?
+            end = m_data.length();
+        }
 
-      if ( m_data[i] == '"' ) {
-        end = i + 1; // skip the '"'
-        break;
-      }
+        result = m_data.mid(m_position, end - m_position);
 
-      result += m_data[i];
+        // transform unquoted NIL
+        if (result == "NIL") {
+            result.clear();
+        }
 
-      ++i;
+        // strip quotes
+        if (foundSlash) {
+            while (result.contains("\\\"")) {
+                result.replace("\\\"", "\"");
+            }
+            while (result.contains("\\\\")) {
+                result.replace("\\\\", "\\");
+            }
+        }
     }
-  }
 
-  // unquoted string
-  else {
-    bool reachedInputEnd = true;
+    m_position = end;
+    return result;
+}
+
+qint64 ImapStreamParser::readNumber(bool *ok)
+{
+    qint64  result;
+    if (ok) {
+        *ok = false;
+    }
+    if (!waitForMoreData(m_data.length() == 0)) {
+        throw ImapParserException("Unable to read more data");
+    }
+    stripLeadingSpaces();
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
+    }
+    if (m_position >= m_data.length()) {
+        throw ImapParserException("Unable to read more data");
+    }
     int i = m_position;
     Q_FOREVER {
-      if ( !waitForMoreData( m_data.length() <= i ) ) {
-        m_position = i;
-        throw ImapParserException( "Unable to read more data" );
-      }
-      // unlike in the copy in KIMAP we do not want to consider [] brackets as \
                separators, breaks payload version parsing
-      // if that ever gets fixed we can re-add them here, see svn revision 937879
-      if ( m_data[i] == ' ' || m_data[i] == '(' || m_data[i] == ')' || m_data[i] == \
                '\n' || m_data[i] == '\r' || m_data[i] == '"' ) {
-        end = i;
-        reachedInputEnd = false;
-        break;
-      }
-      if ( m_data[i] == '\\' ) {
-        foundSlash = true;
-      }
-      i++;
-    }
-    if ( reachedInputEnd ) { //FIXME: how can it get here?
-      end = m_data.length();
-    }
-
-    result = m_data.mid( m_position, end - m_position );
-
-    // transform unquoted NIL
-    if ( result == "NIL" ) {
-      result.clear();
-    }
-
-    // strip quotes
-    if ( foundSlash ) {
-      while ( result.contains( "\\\"" ) ) {
-        result.replace( "\\\"", "\"" );
-      }
-      while ( result.contains( "\\\\" ) ) {
-        result.replace( "\\\\", "\\" );
-      }
-    }
-  }
-
-  m_position = end;
-  return result;
-}
-
-qint64 ImapStreamParser::readNumber( bool *ok )
-{
-  qint64  result;
-  if ( ok ) {
-    *ok = false;
-  }
-  if ( !waitForMoreData( m_data.length() == 0 ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  stripLeadingSpaces();
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  if ( m_position >= m_data.length() ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  int i = m_position;
-  Q_FOREVER {
-    if ( !waitForMoreData( m_data.length() <= i ) ) {
-      m_position = i;
-      throw ImapParserException( "Unable to read more data" );
-    }
-    if ( !isdigit( m_data.at( i ) ) ) {
-      break;
-    }
-    ++i;
-  }
-  const QByteArray tmp = m_data.mid( m_position, i - m_position );
-  bool success = false;
-  result = tmp.toLongLong( &success );
-  if ( ok ) {
-    *ok = success;
-  } else if ( !success ) {
-    throw ImapParserException( "Unable to parse number" );
-  }
-  m_position = i;
-  return result;
+        if (!waitForMoreData(m_data.length() <= i)) {
+            m_position = i;
+            throw ImapParserException("Unable to read more data");
+        }
+        if (!isdigit(m_data.at(i))) {
+            break;
+        }
+        ++i;
+    }
+    const QByteArray tmp = m_data.mid(m_position, i - m_position);
+    bool success = false;
+    result = tmp.toLongLong(&success);
+    if (ok) {
+        *ok = success;
+    } else if (!success) {
+        throw ImapParserException("Unable to parse number");
+    }
+    m_position = i;
+    return result;
 }
 
 void ImapStreamParser::stripLeadingSpaces()
 {
-  for ( int i = m_position; i < m_data.length(); ++i ) {
-    if ( m_data[i] != ' ' ) {
-      m_position = i;
-      return;
+    for (int i = m_position; i < m_data.length(); ++i) {
+        if (m_data[i] != ' ') {
+            m_position = i;
+            return;
+        }
     }
-  }
-  m_position = m_data.length();
+    m_position = m_data.length();
 }
 
-bool ImapStreamParser::waitForMoreData( bool wait )
+bool ImapStreamParser::waitForMoreData(bool wait)
 {
-   if ( wait ) {
-     if ( m_socket->bytesAvailable() > 0 ||
-          m_socket->waitForReadyRead( 30000 ) ) {
-        m_data.append( m_socket->readAll() );
-     } else {
-       return false;
-     }
-   }
-   return true;
+    if (wait) {
+        if (m_socket->bytesAvailable() > 0 ||
+            m_socket->waitForReadyRead(30000)) {
+            m_data.append(m_socket->readAll());
+        } else {
+            return false;
+        }
+    }
+    return true;
 }
 
-void ImapStreamParser::setData( const QByteArray &data )
+void ImapStreamParser::setData(const QByteArray &data)
 {
-  m_data = data;
+    m_data = data;
 }
 
 QByteArray ImapStreamParser::readRemainingData()
 {
-  return m_data.mid( m_position );
+    return m_data.mid(m_position);
 }
 
 bool ImapStreamParser::atCommandEnd()
 {
-  if ( !waitForMoreData( m_position >= m_data.length() ) ) {
-    throw ImapParserException( "Unable to read more data" );
-  }
-  int savedPos = m_position;
-  stripLeadingSpaces();
-  if ( m_data[m_position] == '\n' || m_data[m_position] == '\r' ) {
-    if ( m_position < m_data.length() && m_data[m_position] == '\r' ) {
-      ++m_position;
+    if (!waitForMoreData(m_position >= m_data.length())) {
+        throw ImapParserException("Unable to read more data");
     }
-    if ( m_position < m_data.length() && m_data[m_position] == '\n' ) {
-      ++m_position;
-    }
-    // We'd better empty m_data from time to time before it grows out of control
-    if ( !m_peeking ) {
-      m_data = m_data.right( m_data.size() - m_position );
-      m_position = 0;
+    int savedPos = m_position;
+    stripLeadingSpaces();
+    if (m_data[m_position] == '\n' || m_data[m_position] == '\r') {
+        if (m_position < m_data.length() && m_data[m_position] == '\r') {
+            ++m_position;
+        }
+        if (m_position < m_data.length() && m_data[m_position] == '\n') {
+            ++m_position;
+        }
+        // We'd better empty m_data from time to time before it grows out of control
+        if (!m_peeking) {
+            m_data = m_data.right(m_data.size() - m_position);
+            m_position = 0;
+        }
+        return true; //command end
     }
-    return true; //command end
-  }
-  m_position = savedPos;
-  return false; //something else
+    m_position = savedPos;
+    return false; //something else
 }
 
 QByteArray ImapStreamParser::readUntilCommandEnd()
 {
-  QByteArray result;
-  int i = m_position;
-  int paranthesisBalance = 0;
-  bool inQuotedString = false;
-  Q_FOREVER {
-    if ( !waitForMoreData( m_data.length() <= i ) ) {
-      m_position = i;
-      throw ImapParserException( "Unable to read more data" );
-    }
-    if ( !inQuotedString && m_data[i] == '{' ) {
-      m_position = i;
-      hasLiteral(); //init literal size
-      result.append( m_data.mid( i - 1, m_position - i ) );
-      while ( !atLiteralEnd() ) {
-        result.append( readLiteralPart() );
-      }
-      i = m_position;
-    }
+    QByteArray result;
+    int i = m_position;
+    int paranthesisBalance = 0;
+    bool inQuotedString = false;
+    Q_FOREVER {
+        if (!waitForMoreData(m_data.length() <= i)) {
+            m_position = i;
+            throw ImapParserException("Unable to read more data");
+        }
+        if (!inQuotedString && m_data[i] == '{') {
+            m_position = i;
+            hasLiteral(); //init literal size
+            result.append(m_data.mid(i - 1, m_position - i));
+            while (!atLiteralEnd()) {
+                result.append(readLiteralPart());
+            }
+            i = m_position;
+        }
 
-    if ( !inQuotedString && m_data[i] == '(' ) {
-      paranthesisBalance++;
-    }
-    if ( !inQuotedString && m_data[i] == ')' ) {
-      paranthesisBalance--;
-    }
-    result.append( m_data[i] );
+        if (!inQuotedString && m_data[i] == '(') {
+            paranthesisBalance++;
+        }
+        if (!inQuotedString && m_data[i] == ')') {
+            paranthesisBalance--;
+        }
+        result.append(m_data[i]);
 
-    if ( m_data[i] == '"' ) {
-      if ( m_data[i - 1] != '\\' ) {
-        inQuotedString = !inQuotedString;
-      }
-    }
+        if (m_data[i] == '"') {
+            if (m_data[i - 1] != '\\') {
+                inQuotedString = !inQuotedString;
+            }
+        }
 
-    if ( ( i == m_data.length() && paranthesisBalance == 0 ) || m_data[i] == '\n'  \
                || m_data[i] == '\r' ) {
-      break; //command end
+        if ((i == m_data.length() && paranthesisBalance == 0) || m_data[i] == '\n'  \
|| m_data[i] == '\r') { +            break; //command end
+        }
+        ++i;
     }
-    ++i;
-  }
-  m_position = i + 1;
-  // We'd better empty m_data from time to time before it grows out of control
-  if ( !m_peeking ) {
-    m_data = m_data.right( m_data.size() - m_position );
-    m_position = 0;
-  }
-  return result;
+    m_position = i + 1;
+    // We'd better empty m_data from time to time before it grows out of control
+    if (!m_peeking) {
+        m_data = m_data.right(m_data.size() - m_position);
+        m_position = 0;
+    }
+    return result;
 }
 
 void ImapStreamParser::skipCurrentCommand()
 {
-  int i = m_position;
-  Q_FOREVER {
-    if ( !waitForMoreData( m_data.length() <= i ) ) {
-      m_position = i;
-      throw ImapParserException( "Unable to read more data" );
+    int i = m_position;
+    Q_FOREVER {
+        if (!waitForMoreData(m_data.length() <= i)) {
+            m_position = i;
+            throw ImapParserException("Unable to read more data");
+        }
+        if (m_data[i] == '\n'  || m_data[i] == '\r') {
+            break; //command end
+        }
+        ++i;
     }
-    if ( m_data[i] == '\n'  || m_data[i] == '\r' ) {
-      break; //command end
+    m_position = i + 1;
+    // We'd better empty m_data from time to time before it grows out of control
+    if (!m_peeking) {
+        m_data = m_data.right(m_data.size() - m_position);
+        m_position = 0;
     }
-    ++i;
-  }
-  m_position = i + 1;
-  // We'd better empty m_data from time to time before it grows out of control
-  if ( !m_peeking ) {
-    m_data = m_data.right( m_data.size() - m_position );
-    m_position = 0;
-  }
 }
 
-void ImapStreamParser::sendContinuationResponse( qint64 size )
+void ImapStreamParser::sendContinuationResponse(qint64 size)
 {
-  const QByteArray block = "+ Ready for literal data (expecting "
-                   + QByteArray::number( size ) + " bytes)\r\n";
-  m_socket->write( block );
-  m_socket->waitForBytesWritten( 30000 );
+    const QByteArray block = "+ Ready for literal data (expecting "
+                             + QByteArray::number(size) + " bytes)\r\n";
+    m_socket->write(block);
+    m_socket->waitForBytesWritten(30000);
 
-  Tracer::self()->connectionOutput( m_tracerId, block );
+    Tracer::self()->connectionOutput(m_tracerId, block);
 }
 
-void ImapStreamParser::insertData( const QByteArray &data )
+void ImapStreamParser::insertData(const QByteArray &data)
 {
-  m_data = m_data.insert( m_position, data );
+    m_data = m_data.insert(m_position, data);
 }
 
-void ImapStreamParser::appendData( const QByteArray &data )
+void ImapStreamParser::appendData(const QByteArray &data)
 {
-  m_data = m_data + data;
+    m_data = m_data + data;
 }
 
-void ImapStreamParser::setTracerIdentifier( const QString &id )
+void ImapStreamParser::setTracerIdentifier(const QString &id)
 {
-  m_tracerId = id;
+    m_tracerId = id;
 }
diff --git a/server/src/intervalcheck.cpp b/server/src/intervalcheck.cpp
index c4e0627..a43ffd2 100644
--- a/server/src/intervalcheck.cpp
+++ b/server/src/intervalcheck.cpp
@@ -29,11 +29,11 @@ static int MINIMUM_COLTREESYNC_INTERVAL = 5; // minutes
 
 IntervalCheck *IntervalCheck::s_instance = 0;
 
-IntervalCheck::IntervalCheck( QObject *parent )
-  : CollectionScheduler( parent )
+IntervalCheck::IntervalCheck(QObject *parent)
+    : CollectionScheduler(parent)
 {
-  Q_ASSERT( s_instance == 0 );
-  s_instance = this;
+    Q_ASSERT(s_instance == 0);
+    s_instance = this;
 }
 
 IntervalCheck::~ IntervalCheck()
@@ -42,62 +42,62 @@ IntervalCheck::~ IntervalCheck()
 
 IntervalCheck *IntervalCheck::self()
 {
-  Q_ASSERT( s_instance );
-  return s_instance;
+    Q_ASSERT(s_instance);
+    return s_instance;
 }
 
-void IntervalCheck::requestCollectionSync( const Collection &collection )
+void IntervalCheck::requestCollectionSync(const Collection &collection)
 {
-  QMetaObject::invokeMethod( this, "collectionExpired",
-                             Qt::QueuedConnection,
-                             Q_ARG( Collection, collection ) );
+    QMetaObject::invokeMethod(this, "collectionExpired",
+                              Qt::QueuedConnection,
+                              Q_ARG(Collection, collection));
 }
 
-int IntervalCheck::collectionScheduleInterval( const Collection &collection )
+int IntervalCheck::collectionScheduleInterval(const Collection &collection)
 {
-  return collection.cachePolicyCheckInterval();
+    return collection.cachePolicyCheckInterval();
 }
 
-bool IntervalCheck::hasChanged( const Collection &collection, const Collection \
&changed ) +bool IntervalCheck::hasChanged(const Collection &collection, const \
Collection &changed)  {
-  return collection.cachePolicyCheckInterval() != changed.cachePolicyCheckInterval()
-        || collection.subscribed() != changed.subscribed();
+    return collection.cachePolicyCheckInterval() != \
changed.cachePolicyCheckInterval() +           || collection.subscribed() != \
changed.subscribed();  }
 
-bool IntervalCheck::shouldScheduleCollection( const Collection &collection )
+bool IntervalCheck::shouldScheduleCollection(const Collection &collection)
 {
-  return collection.cachePolicyCheckInterval() > 0
-        && collection.subscribed();
+    return collection.cachePolicyCheckInterval() > 0
+           && collection.subscribed();
 }
 
-void IntervalCheck::collectionExpired( const Collection &collection )
+void IntervalCheck::collectionExpired(const Collection &collection)
 {
-  const QDateTime now( QDateTime::currentDateTime() );
+    const QDateTime now(QDateTime::currentDateTime());
 
-  if ( collection.parentId() == 0 ) {
-    const QString resourceName = collection.resource().name();
+    if (collection.parentId() == 0) {
+        const QString resourceName = collection.resource().name();
 
-    const int interval = qMax( MINIMUM_COLTREESYNC_INTERVAL, \
collection.cachePolicyCheckInterval() ); +        const int interval = \
qMax(MINIMUM_COLTREESYNC_INTERVAL, collection.cachePolicyCheckInterval());  
-    const QDateTime lastExpectedCheck = now.addSecs( interval * -60 );
-    if ( !mLastCollectionTreeSyncs.contains( resourceName ) || \
                mLastCollectionTreeSyncs.value( resourceName ) < lastExpectedCheck ) \
                {
-      mLastCollectionTreeSyncs.insert( resourceName, now );
-      QMetaObject::invokeMethod( ItemRetrievalManager::instance(), \
                "triggerCollectionTreeSync",
-                                 Qt::QueuedConnection,
-                                 Q_ARG( QString, resourceName ) );
+        const QDateTime lastExpectedCheck = now.addSecs(interval * -60);
+        if (!mLastCollectionTreeSyncs.contains(resourceName) || \
mLastCollectionTreeSyncs.value(resourceName) < lastExpectedCheck) { +            \
mLastCollectionTreeSyncs.insert(resourceName, now); +            \
QMetaObject::invokeMethod(ItemRetrievalManager::instance(), \
"triggerCollectionTreeSync", +                                      \
Qt::QueuedConnection, +                                      Q_ARG(QString, \
resourceName)); +        }
     }
-  }
-
-  // now on to the actual collection syncing
-  const int interval = qMax( MINIMUM_AUTOSYNC_INTERVAL, \
                collection.cachePolicyCheckInterval() );
-
-  const QDateTime lastExpectedCheck = now.addSecs( interval * -60 );
-  if ( mLastChecks.contains( collection.id() ) && mLastChecks.value( collection.id() \
                ) > lastExpectedCheck ) {
-    return;
-  }
-  mLastChecks.insert( collection.id(), now );
-  QMetaObject::invokeMethod( ItemRetrievalManager::instance(), \
                "triggerCollectionSync",
-                             Qt::QueuedConnection,
-                             Q_ARG( QString, collection.resource().name() ),
-                             Q_ARG( qint64, collection.id() ) );
+
+    // now on to the actual collection syncing
+    const int interval = qMax(MINIMUM_AUTOSYNC_INTERVAL, \
collection.cachePolicyCheckInterval()); +
+    const QDateTime lastExpectedCheck = now.addSecs(interval * -60);
+    if (mLastChecks.contains(collection.id()) && mLastChecks.value(collection.id()) \
> lastExpectedCheck) { +        return;
+    }
+    mLastChecks.insert(collection.id(), now);
+    QMetaObject::invokeMethod(ItemRetrievalManager::instance(), \
"triggerCollectionSync", +                              Qt::QueuedConnection,
+                              Q_ARG(QString, collection.resource().name()),
+                              Q_ARG(qint64, collection.id()));
 }
diff --git a/server/src/storage/itemretrievaljob.cpp \
b/server/src/storage/itemretrievaljob.cpp index d3727c6..4780802 100644
--- a/server/src/storage/itemretrievaljob.cpp
+++ b/server/src/storage/itemretrievaljob.cpp
@@ -28,81 +28,81 @@ using namespace Akonadi::Server;
 
 ItemRetrievalJob::~ItemRetrievalJob()
 {
-  Q_ASSERT( !m_active );
+    Q_ASSERT(!m_active);
 }
 
-void ItemRetrievalJob::start( QDBusAbstractInterface *interface )
+void ItemRetrievalJob::start(QDBusAbstractInterface *interface)
 {
-  Q_ASSERT( m_request );
-  akDebug() << "processing retrieval request for item" << m_request->id << " parts:" \
<< m_request->parts << " of resource:" << m_request->resourceId; +    \
Q_ASSERT(m_request); +    akDebug() << "processing retrieval request for item" << \
m_request->id << " parts:" << m_request->parts << " of resource:" << \
m_request->resourceId;  
-  m_interface = interface;
-  // call the resource
-  if ( interface ) {
-    m_active = true;
-    m_oldMethodCalled = false;
-    QList<QVariant> arguments;
-    arguments << m_request->id
-              << QString::fromUtf8( m_request->remoteId )
-              << QString::fromUtf8( m_request->mimeType )
-              << m_request->parts;
-    interface->callWithCallback( QLatin1String( "requestItemDeliveryV2" ), \
                arguments, this, SLOT(callFinished(QString)), \
                SLOT(callFailed(QDBusError)) );
-  } else {
-    Q_EMIT requestCompleted( m_request, QString::fromLatin1( "Unable to contact \
                resource" ) );
-    deleteLater();
-  }
+    m_interface = interface;
+    // call the resource
+    if (interface) {
+        m_active = true;
+        m_oldMethodCalled = false;
+        QList<QVariant> arguments;
+        arguments << m_request->id
+                  << QString::fromUtf8(m_request->remoteId)
+                  << QString::fromUtf8(m_request->mimeType)
+                  << m_request->parts;
+        interface->callWithCallback(QLatin1String("requestItemDeliveryV2"), \
arguments, this, SLOT(callFinished(QString)), SLOT(callFailed(QDBusError))); +    } \
else { +        Q_EMIT requestCompleted(m_request, QString::fromLatin1("Unable to \
contact resource")); +        deleteLater();
+    }
 }
 
 void ItemRetrievalJob::kill()
 {
-  m_active = false;
-  Q_EMIT requestCompleted( m_request, QLatin1String( "Request cancelled" ) );
+    m_active = false;
+    Q_EMIT requestCompleted(m_request, QLatin1String("Request cancelled"));
 }
 
-void ItemRetrievalJob::callFinished( bool returnValue )
+void ItemRetrievalJob::callFinished(bool returnValue)
 {
-  if ( m_active ) {
-    m_active = false;
-    if ( !returnValue ) {
-      Q_EMIT requestCompleted( m_request, QString::fromLatin1( "Resource was unable \
                to deliver item" ) );
-    } else {
-      Q_EMIT requestCompleted( m_request, QString() );
+    if (m_active) {
+        m_active = false;
+        if (!returnValue) {
+            Q_EMIT requestCompleted(m_request, QString::fromLatin1("Resource was \
unable to deliver item")); +        } else {
+            Q_EMIT requestCompleted(m_request, QString());
+        }
     }
-  }
-  deleteLater();
+    deleteLater();
 }
 
-void ItemRetrievalJob::callFinished( const QString &errorMsg )
+void ItemRetrievalJob::callFinished(const QString &errorMsg)
 {
-  if ( m_active ) {
-    m_active = false;
-    if ( !errorMsg.isEmpty() ) {
-      Q_EMIT requestCompleted( m_request, QString::fromLatin1( "Unable to retrieve \
                item from resource: %1" ).arg( errorMsg ) );
-    } else {
-      Q_EMIT requestCompleted( m_request, QString() );
+    if (m_active) {
+        m_active = false;
+        if (!errorMsg.isEmpty()) {
+            Q_EMIT requestCompleted(m_request, QString::fromLatin1("Unable to \
retrieve item from resource: %1").arg(errorMsg)); +        } else {
+            Q_EMIT requestCompleted(m_request, QString());
+        }
     }
-  }
-  deleteLater();
+    deleteLater();
 }
 
-void ItemRetrievalJob::callFailed( const QDBusError &error )
+void ItemRetrievalJob::callFailed(const QDBusError &error)
 {
-  if ( error.type() == QDBusError::UnknownMethod && !m_oldMethodCalled ) {
-    akDebug() << "processing retrieval request (old method) for item" << \
m_request->id << " parts:" << m_request->parts << " of resource:" << \
                m_request->resourceId;
-    Q_ASSERT( m_interface );
-    //try the old version
-    QList<QVariant> arguments;
-    arguments << m_request->id
-              << QString::fromUtf8( m_request->remoteId )
-              << QString::fromUtf8( m_request->mimeType )
-              << m_request->parts;
-    m_oldMethodCalled = true;
-    m_interface->callWithCallback( QLatin1String( "requestItemDelivery" ), \
                arguments, this, SLOT(callFinished(bool)), \
                SLOT(callFailed(QDBusError)) );
-    return;
-  }
-  if ( m_active ) {
-    m_active = false;
-    Q_EMIT requestCompleted( m_request, QString::fromLatin1( "Unable to retrieve \
                item from resource: %1" ).arg( error.message() ) );
-  }
-  deleteLater();
+    if (error.type() == QDBusError::UnknownMethod && !m_oldMethodCalled) {
+        akDebug() << "processing retrieval request (old method) for item" << \
m_request->id << " parts:" << m_request->parts << " of resource:" << \
m_request->resourceId; +        Q_ASSERT(m_interface);
+        //try the old version
+        QList<QVariant> arguments;
+        arguments << m_request->id
+                  << QString::fromUtf8(m_request->remoteId)
+                  << QString::fromUtf8(m_request->mimeType)
+                  << m_request->parts;
+        m_oldMethodCalled = true;
+        m_interface->callWithCallback(QLatin1String("requestItemDelivery"), \
arguments, this, SLOT(callFinished(bool)), SLOT(callFailed(QDBusError))); +        \
return; +    }
+    if (m_active) {
+        m_active = false;
+        Q_EMIT requestCompleted(m_request, QString::fromLatin1("Unable to retrieve \
item from resource: %1").arg(error.message())); +    }
+    deleteLater();
 }
diff --git a/server/src/storage/itemretrievalmanager.cpp \
b/server/src/storage/itemretrievalmanager.cpp index ce88410..a304f4b 100644
--- a/server/src/storage/itemretrievalmanager.cpp
+++ b/server/src/storage/itemretrievalmanager.cpp
@@ -39,203 +39,203 @@ using namespace Akonadi::Server;
 
 ItemRetrievalManager *ItemRetrievalManager::sInstance = 0;
 
-ItemRetrievalManager::ItemRetrievalManager( QObject *parent )
-  : QObject( parent ),
-    mDBusConnection( DBusConnectionPool::threadConnection() )
+ItemRetrievalManager::ItemRetrievalManager(QObject *parent)
+    : QObject(parent)
+    , mDBusConnection(DBusConnectionPool::threadConnection())
 {
-  // make sure we are created from the retrieval thread and only once
-  Q_ASSERT( QThread::currentThread() != QCoreApplication::instance()->thread() );
-  Q_ASSERT( sInstance == 0 );
-  sInstance = this;
+    // make sure we are created from the retrieval thread and only once
+    Q_ASSERT(QThread::currentThread() != QCoreApplication::instance()->thread());
+    Q_ASSERT(sInstance == 0);
+    sInstance = this;
 
-  mLock = new QReadWriteLock();
-  mWaitCondition = new QWaitCondition();
+    mLock = new QReadWriteLock();
+    mWaitCondition = new QWaitCondition();
 
-  connect( mDBusConnection.interface(), \
                SIGNAL(serviceOwnerChanged(QString,QString,QString)),
-           this, SLOT(serviceOwnerChanged(QString,QString,QString)) );
-  connect( this, SIGNAL(requestAdded()), this, SLOT(processRequest()), \
Qt::QueuedConnection ); +    connect(mDBusConnection.interface(), \
SIGNAL(serviceOwnerChanged(QString,QString,QString)), +            this, \
SLOT(serviceOwnerChanged(QString,QString,QString))); +    connect(this, \
SIGNAL(requestAdded()), this, SLOT(processRequest()), Qt::QueuedConnection);  }
 
 ItemRetrievalManager::~ItemRetrievalManager()
 {
-  delete mWaitCondition;
-  delete mLock;
+    delete mWaitCondition;
+    delete mLock;
 }
 
 ItemRetrievalManager *ItemRetrievalManager::instance()
 {
-  Q_ASSERT( sInstance );
-  return sInstance;
+    Q_ASSERT(sInstance);
+    return sInstance;
 }
 
 // called within the retrieval thread
-void ItemRetrievalManager::serviceOwnerChanged( const QString &serviceName, const \
QString &oldOwner, const QString &newOwner ) +void \
ItemRetrievalManager::serviceOwnerChanged(const QString &serviceName, const QString \
&oldOwner, const QString &newOwner)  {
-  Q_UNUSED( newOwner );
-  if ( oldOwner.isEmpty() ) {
-    return;
-  }
-  AkDBus::AgentType type = AkDBus::Unknown;
-  const QString resourceId = AkDBus::parseAgentServiceName( serviceName, type );
-  if ( resourceId.isEmpty() || type != AkDBus::Resource ) {
-    return;
-  }
-  akDebug() << "Lost connection to resource" << serviceName << ", discarding cached \
                interface";
-  mResourceInterfaces.remove( resourceId );
+    Q_UNUSED(newOwner);
+    if (oldOwner.isEmpty()) {
+        return;
+    }
+    AkDBus::AgentType type = AkDBus::Unknown;
+    const QString resourceId = AkDBus::parseAgentServiceName(serviceName, type);
+    if (resourceId.isEmpty() || type != AkDBus::Resource) {
+        return;
+    }
+    akDebug() << "Lost connection to resource" << serviceName << ", discarding \
cached interface"; +    mResourceInterfaces.remove(resourceId);
 }
 
 // called within the retrieval thread
-OrgFreedesktopAkonadiResourceInterface *ItemRetrievalManager::resourceInterface( \
const QString &id ) +OrgFreedesktopAkonadiResourceInterface \
*ItemRetrievalManager::resourceInterface(const QString &id)  {
-  if ( id.isEmpty() ) {
-    return 0;
-  }
+    if (id.isEmpty()) {
+        return 0;
+    }
+
+    OrgFreedesktopAkonadiResourceInterface *iface = mResourceInterfaces.value(id);
+    if (iface && iface->isValid()) {
+        return iface;
+    }
 
-  OrgFreedesktopAkonadiResourceInterface *iface = mResourceInterfaces.value( id );
-  if ( iface && iface->isValid() ) {
-    return iface;
-  }
-
-  delete iface;
-  iface = new OrgFreedesktopAkonadiResourceInterface( AkDBus::agentServiceName( id, \
                AkDBus::Resource ),
-                                                      QLatin1String( "/" ), \
                mDBusConnection, this );
-  if ( !iface || !iface->isValid() ) {
-    akError() << QString::fromLatin1( "Cannot connect to agent instance with \
                identifier '%1', error message: '%2'" )
-                                      .arg( id, iface ? iface->lastError().message() \
: QString() );  delete iface;
-    return 0;
-  }
+    iface = new OrgFreedesktopAkonadiResourceInterface(AkDBus::agentServiceName(id, \
AkDBus::Resource), +                                                       \
QLatin1String("/"), mDBusConnection, this); +    if (!iface || !iface->isValid()) {
+        akError() << QString::fromLatin1("Cannot connect to agent instance with \
identifier '%1', error message: '%2'") +                  .arg(id, iface ? \
iface->lastError().message() : QString()); +        delete iface;
+        return 0;
+    }
 #if QT_VERSION >= 0x040800
-  // DBus calls can take some time to reply -- e.g. if a huge local mbox has to be \
                parsed first.
-  iface->setTimeout( 5 * 60 * 1000 ); // 5 minutes, rather than 25 seconds
+    // DBus calls can take some time to reply -- e.g. if a huge local mbox has to be \
parsed first. +    iface->setTimeout(5 * 60 * 1000);   // 5 minutes, rather than 25 \
seconds  #endif
-  mResourceInterfaces.insert( id, iface );
-  return iface;
+    mResourceInterfaces.insert(id, iface);
+    return iface;
 }
 
 // called from any thread
-void ItemRetrievalManager::requestItemDelivery( qint64 uid, const QByteArray \
                &remoteId, const QByteArray &mimeType,
-                                                const QString &resource, const \
QStringList &parts ) +void ItemRetrievalManager::requestItemDelivery(qint64 uid, \
const QByteArray &remoteId, const QByteArray &mimeType, +                             \
const QString &resource, const QStringList &parts)  {
-  ItemRetrievalRequest *req = new ItemRetrievalRequest();
-  req->id = uid;
-  req->remoteId = remoteId;
-  req->mimeType = mimeType;
-  req->resourceId = resource;
-  req->parts = parts;
-
-  requestItemDelivery( req );
+    ItemRetrievalRequest *req = new ItemRetrievalRequest();
+    req->id = uid;
+    req->remoteId = remoteId;
+    req->mimeType = mimeType;
+    req->resourceId = resource;
+    req->parts = parts;
+
+    requestItemDelivery(req);
 }
 
-void ItemRetrievalManager::requestItemDelivery( ItemRetrievalRequest *req )
+void ItemRetrievalManager::requestItemDelivery(ItemRetrievalRequest *req)
 {
-  mLock->lockForWrite();
-  akDebug() << "posting retrieval request for item" << req->id << " there are "
-            << mPendingRequests.size() << " queues and "
-            << mPendingRequests[req->resourceId].size() << " items in mine";
-  mPendingRequests[req->resourceId].append( req );
-  mLock->unlock();
-
-  Q_EMIT requestAdded();
-
-  mLock->lockForRead();
-  Q_FOREVER {
-    //akDebug() << "checking if request for item" << req->id << "has been \
                processed...";
-    if ( req->processed ) {
-      boost::scoped_ptr<ItemRetrievalRequest> reqDeleter( req );
-      Q_ASSERT( !mPendingRequests[req->resourceId].contains( req ) );
-      const QString errorMsg = req->errorMsg;
-      mLock->unlock();
-      if ( errorMsg.isEmpty() ) {
-        akDebug() << "request for item" << req->id << "succeeded";
-        return;
-      } else {
-        akDebug() << "request for item" << req->id << req->remoteId << "failed:" << \
                errorMsg;
-        throw ItemRetrieverException( errorMsg );
-      }
-    } else {
-      akDebug() << "request for item" << req->id << "still pending - waiting";
-      mWaitCondition->wait( mLock );
-      akDebug() << "continuing";
+    mLock->lockForWrite();
+    akDebug() << "posting retrieval request for item" << req->id << " there are "
+              << mPendingRequests.size() << " queues and "
+              << mPendingRequests[req->resourceId].size() << " items in mine";
+    mPendingRequests[req->resourceId].append(req);
+    mLock->unlock();
+
+    Q_EMIT requestAdded();
+
+    mLock->lockForRead();
+    Q_FOREVER {
+        //akDebug() << "checking if request for item" << req->id << "has been \
processed..."; +        if (req->processed) {
+            boost::scoped_ptr<ItemRetrievalRequest> reqDeleter(req);
+            Q_ASSERT(!mPendingRequests[req->resourceId].contains(req));
+            const QString errorMsg = req->errorMsg;
+            mLock->unlock();
+            if (errorMsg.isEmpty()) {
+                akDebug() << "request for item" << req->id << "succeeded";
+                return;
+            } else {
+                akDebug() << "request for item" << req->id << req->remoteId << \
"failed:" << errorMsg; +                throw ItemRetrieverException(errorMsg);
+            }
+        } else {
+            akDebug() << "request for item" << req->id << "still pending - waiting";
+            mWaitCondition->wait(mLock);
+            akDebug() << "continuing";
+        }
     }
-  }
 
-  throw ItemRetrieverException( "WTF?" );
+    throw ItemRetrieverException("WTF?");
 }
 
 // called within the retrieval thread
 void ItemRetrievalManager::processRequest()
 {
-  QVector<QPair<ItemRetrievalJob*, QString> > newJobs;
-
-  mLock->lockForWrite();
-  // look for idle resources
-  for ( QHash< QString, QList< ItemRetrievalRequest *> >::iterator it = \
                mPendingRequests.begin(); it != mPendingRequests.end(); ) {
-    if ( it.value().isEmpty() ) {
-      it = mPendingRequests.erase( it );
-      continue;
-    }
-    if ( !mCurrentJobs.contains( it.key() ) || mCurrentJobs.value( it.key() ) == 0 ) \
                {
-      // TODO: check if there is another one for the same uid with more parts \
                requested
-      ItemRetrievalRequest *req = it.value().takeFirst();
-      Q_ASSERT( req->resourceId == it.key() );
-      ItemRetrievalJob *job = new ItemRetrievalJob( req, this );
-      connect( job, SIGNAL(requestCompleted(ItemRetrievalRequest*,QString)), \
                SLOT(retrievalJobFinished(ItemRetrievalRequest*,QString)) );
-      mCurrentJobs.insert( req->resourceId, job );
-      // delay job execution until after we unlocked the mutex, since the job can \
                emit the finished signal immediately in some cases
-      newJobs.append( qMakePair( job, req->resourceId ) );
+    QVector<QPair<ItemRetrievalJob *, QString> > newJobs;
+
+    mLock->lockForWrite();
+    // look for idle resources
+    for (QHash< QString, QList< ItemRetrievalRequest *> >::iterator it = \
mPendingRequests.begin(); it != mPendingRequests.end();) { +        if \
(it.value().isEmpty()) { +            it = mPendingRequests.erase(it);
+            continue;
+        }
+        if (!mCurrentJobs.contains(it.key()) || mCurrentJobs.value(it.key()) == 0) {
+            // TODO: check if there is another one for the same uid with more parts \
requested +            ItemRetrievalRequest *req = it.value().takeFirst();
+            Q_ASSERT(req->resourceId == it.key());
+            ItemRetrievalJob *job = new ItemRetrievalJob(req, this);
+            connect(job, SIGNAL(requestCompleted(ItemRetrievalRequest*,QString)), \
SLOT(retrievalJobFinished(ItemRetrievalRequest*,QString))); +            \
mCurrentJobs.insert(req->resourceId, job); +            // delay job execution until \
after we unlocked the mutex, since the job can emit the finished signal immediately \
in some cases +            newJobs.append(qMakePair(job, req->resourceId));
+        }
+        ++it;
     }
-    ++it;
-  }
 
-  bool nothingGoingOn = mPendingRequests.isEmpty() && mCurrentJobs.isEmpty() && \
                newJobs.isEmpty();
-  mLock->unlock();
+    bool nothingGoingOn = mPendingRequests.isEmpty() && mCurrentJobs.isEmpty() && \
newJobs.isEmpty(); +    mLock->unlock();
 
-  if ( nothingGoingOn ) { // someone asked as to process requests although \
                everything is done already, he might still be waiting
-    mWaitCondition->wakeAll();
-    return;
-  }
+    if (nothingGoingOn) {   // someone asked as to process requests although \
everything is done already, he might still be waiting +        \
mWaitCondition->wakeAll(); +        return;
+    }
 
-  for ( QVector<QPair<ItemRetrievalJob *, QString> >::const_iterator it = \
                newJobs.constBegin(); it != newJobs.constEnd(); ++it ) {
-    ( *it ).first->start( resourceInterface( ( *it ).second ) );
-  }
+    for (QVector<QPair<ItemRetrievalJob *, QString> >::const_iterator it = \
newJobs.constBegin(); it != newJobs.constEnd(); ++it) { +        \
(*it).first->start(resourceInterface((*it).second)); +    }
 }
 
-void ItemRetrievalManager::retrievalJobFinished( ItemRetrievalRequest *request, \
const QString &errorMsg ) +void \
ItemRetrievalManager::retrievalJobFinished(ItemRetrievalRequest *request, const \
QString &errorMsg)  {
-  mLock->lockForWrite();
-  request->errorMsg = errorMsg;
-  request->processed = true;
-  Q_ASSERT( mCurrentJobs.contains( request->resourceId ) );
-  mCurrentJobs.remove( request->resourceId );
-  // TODO check if (*it)->parts is a subset of currentRequest->parts
-  for ( QList<ItemRetrievalRequest *>::Iterator it = \
mPendingRequests[request->resourceId].begin(); it != \
                mPendingRequests[request->resourceId].end(); ) {
-    if ( ( *it )->id == request->id ) {
-      akDebug() << "someone else requested item" << request->id << "as well, marking \
                as processed";
-      ( *it )->errorMsg = errorMsg;
-      ( *it )->processed = true;
-      it = mPendingRequests[request->resourceId].erase( it );
-    } else {
-      ++it;
+    mLock->lockForWrite();
+    request->errorMsg = errorMsg;
+    request->processed = true;
+    Q_ASSERT(mCurrentJobs.contains(request->resourceId));
+    mCurrentJobs.remove(request->resourceId);
+    // TODO check if (*it)->parts is a subset of currentRequest->parts
+    for (QList<ItemRetrievalRequest *>::Iterator it = \
mPendingRequests[request->resourceId].begin(); it != \
mPendingRequests[request->resourceId].end();) { +        if ((*it)->id == \
request->id) { +            akDebug() << "someone else requested item" << request->id \
<< "as well, marking as processed"; +            (*it)->errorMsg = errorMsg;
+            (*it)->processed = true;
+            it = mPendingRequests[request->resourceId].erase(it);
+        } else {
+            ++it;
+        }
     }
-  }
-  mWaitCondition->wakeAll();
-  mLock->unlock();
-  Q_EMIT requestAdded(); // trigger processRequest() again, in case there is more in \
the queues +    mWaitCondition->wakeAll();
+    mLock->unlock();
+    Q_EMIT requestAdded(); // trigger processRequest() again, in case there is more \
in the queues  }
 
-void ItemRetrievalManager::triggerCollectionSync( const QString &resource, qint64 \
colId ) +void ItemRetrievalManager::triggerCollectionSync(const QString &resource, \
qint64 colId)  {
-  OrgFreedesktopAkonadiResourceInterface *interface = resourceInterface( resource );
-  if ( interface ) {
-    interface->synchronizeCollection( colId );
-  }
+    OrgFreedesktopAkonadiResourceInterface *interface = resourceInterface(resource);
+    if (interface) {
+        interface->synchronizeCollection(colId);
+    }
 }
 
-void ItemRetrievalManager::triggerCollectionTreeSync( const QString &resource )
+void ItemRetrievalManager::triggerCollectionTreeSync(const QString &resource)
 {
-  OrgFreedesktopAkonadiResourceInterface *interface = resourceInterface( resource );
-  if ( interface ) {
-    interface->synchronizeCollectionTree();
-  }
+    OrgFreedesktopAkonadiResourceInterface *interface = resourceInterface(resource);
+    if (interface) {
+        interface->synchronizeCollectionTree();
+    }
 }
diff --git a/server/src/storage/itemretrievalthread.cpp \
b/server/src/storage/itemretrievalthread.cpp index e842e83..8f3be00 100644
--- a/server/src/storage/itemretrievalthread.cpp
+++ b/server/src/storage/itemretrievalthread.cpp
@@ -24,16 +24,16 @@
 
 using namespace Akonadi::Server;
 
-ItemRetrievalThread::ItemRetrievalThread( QObject *parent )
-  : QThread( parent )
+ItemRetrievalThread::ItemRetrievalThread(QObject *parent)
+    : QThread(parent)
 {
-  // make sure we are created from the main thread, ie. before all other threads \
                start to potentially use us
-  Q_ASSERT( QThread::currentThread() == QCoreApplication::instance()->thread() );
+    // make sure we are created from the main thread, ie. before all other threads \
start to potentially use us +    Q_ASSERT(QThread::currentThread() == \
QCoreApplication::instance()->thread());  }
 
 void ItemRetrievalThread::run()
 {
-  ItemRetrievalManager *mgr = new ItemRetrievalManager();
-  exec();
-  delete mgr;
+    ItemRetrievalManager *mgr = new ItemRetrievalManager();
+    exec();
+    delete mgr;
 }
diff --git a/server/src/storage/itemretriever.cpp \
b/server/src/storage/itemretriever.cpp index b1b2a67..9148c15 100644
--- a/server/src/storage/itemretriever.cpp
+++ b/server/src/storage/itemretriever.cpp
@@ -39,11 +39,11 @@
 using namespace Akonadi;
 using namespace Akonadi::Server;
 
-ItemRetriever::ItemRetriever( Connection *connection )
-  : mScope( Scope::Invalid )
-  , mConnection( connection )
-  , mFullPayload( false )
-  , mRecursive( false )
+ItemRetriever::ItemRetriever(Connection *connection)
+    : mScope(Scope::Invalid)
+    , mConnection(connection)
+    , mFullPayload(false)
+    , mRecursive(false)
 {
 }
 
@@ -53,265 +53,265 @@ ItemRetriever::~ItemRetriever()
 
 Connection *ItemRetriever::connection() const
 {
-  return mConnection;
+    return mConnection;
 }
 
-void ItemRetriever::setRetrieveParts( const QStringList &parts )
+void ItemRetriever::setRetrieveParts(const QStringList &parts)
 {
-  mParts = parts;
-  // HACK, we need a full payload available flag in PimItem
-  if ( mFullPayload && !mParts.contains( QLatin1String( AKONADI_PARAM_PLD_RFC822 ) ) \
                ) {
-    mParts.append( QLatin1String( AKONADI_PARAM_PLD_RFC822 ) );
-  }
+    mParts = parts;
+    // HACK, we need a full payload available flag in PimItem
+    if (mFullPayload && !mParts.contains(QLatin1String(AKONADI_PARAM_PLD_RFC822))) {
+        mParts.append(QLatin1String(AKONADI_PARAM_PLD_RFC822));
+    }
 }
 
-void ItemRetriever::setItemSet( const ImapSet &set, const Collection &collection )
+void ItemRetriever::setItemSet(const ImapSet &set, const Collection &collection)
 {
-  mItemSet = set;
-  mCollection = collection;
+    mItemSet = set;
+    mCollection = collection;
 }
 
-void ItemRetriever::setItemSet( const ImapSet &set, bool isUid )
+void ItemRetriever::setItemSet(const ImapSet &set, bool isUid)
 {
-  Q_ASSERT( mConnection );
-  if ( !isUid && mConnection->context()->collectionId() >= 0 ) {
-    setItemSet( set, mConnection->context()->collection() );
-  } else {
-    setItemSet( set );
-  }
+    Q_ASSERT(mConnection);
+    if (!isUid && mConnection->context()->collectionId() >= 0) {
+        setItemSet(set, mConnection->context()->collection());
+    } else {
+        setItemSet(set);
+    }
 }
 
-void ItemRetriever::setItem( const Entity::Id &id )
+void ItemRetriever::setItem(const Entity::Id &id)
 {
-  ImapSet set;
-  set.add( ImapInterval( id, id ) );
-  mItemSet = set;
-  mCollection = Collection();
+    ImapSet set;
+    set.add(ImapInterval(id, id));
+    mItemSet = set;
+    mCollection = Collection();
 }
 
-void ItemRetriever::setRetrieveFullPayload( bool fullPayload )
+void ItemRetriever::setRetrieveFullPayload(bool fullPayload)
 {
-  mFullPayload = fullPayload;
-  // HACK, we need a full payload available flag in PimItem
-  if ( fullPayload && !mParts.contains( QLatin1String( AKONADI_PARAM_PLD_RFC822 ) ) \
                ) {
-    mParts.append( QLatin1String( AKONADI_PARAM_PLD_RFC822 ) );
-  }
+    mFullPayload = fullPayload;
+    // HACK, we need a full payload available flag in PimItem
+    if (fullPayload && !mParts.contains(QLatin1String(AKONADI_PARAM_PLD_RFC822))) {
+        mParts.append(QLatin1String(AKONADI_PARAM_PLD_RFC822));
+    }
 }
 
-void ItemRetriever::setCollection( const Collection &collection, bool recursive )
+void ItemRetriever::setCollection(const Collection &collection, bool recursive)
 {
-  mCollection = collection;
-  mItemSet = ImapSet();
-  mRecursive = recursive;
+    mCollection = collection;
+    mItemSet = ImapSet();
+    mRecursive = recursive;
 }
 
-void ItemRetriever::setScope( const Scope &scope )
+void ItemRetriever::setScope(const Scope &scope)
 {
-  mScope = scope;
+    mScope = scope;
 }
 
 Scope ItemRetriever::scope() const
 {
-  return mScope;
+    return mScope;
 }
 
-void ItemRetriever::setChangedSince( const QDateTime &changedSince )
+void ItemRetriever::setChangedSince(const QDateTime &changedSince)
 {
-  mChangedSince = changedSince;
+    mChangedSince = changedSince;
 }
 
 QStringList ItemRetriever::retrieveParts() const
 {
-  return mParts;
+    return mParts;
 }
 
 enum QueryColumns {
-  PimItemIdColumn,
-  PimItemRidColumn,
+    PimItemIdColumn,
+    PimItemRidColumn,
 
-  MimeTypeColumn,
+    MimeTypeColumn,
 
-  ResourceColumn,
+    ResourceColumn,
 
-  PartTypeNameColumn,
-  PartDatasizeColumn
+    PartTypeNameColumn,
+    PartDatasizeColumn
 };
 
 QSqlQuery ItemRetriever::buildQuery() const
 {
-  QueryBuilder qb( PimItem::tableName() );
+    QueryBuilder qb(PimItem::tableName());
 
-  qb.addJoin( QueryBuilder::InnerJoin, MimeType::tableName(), \
PimItem::mimeTypeIdFullColumnName(), MimeType::idFullColumnName() ); +    \
qb.addJoin(QueryBuilder::InnerJoin, MimeType::tableName(), \
PimItem::mimeTypeIdFullColumnName(), MimeType::idFullColumnName());  
-  qb.addJoin( QueryBuilder::InnerJoin, Collection::tableName(), \
PimItem::collectionIdFullColumnName(), Collection::idFullColumnName() ); +    \
qb.addJoin(QueryBuilder::InnerJoin, Collection::tableName(), \
PimItem::collectionIdFullColumnName(), Collection::idFullColumnName());  
-  qb.addJoin( QueryBuilder::InnerJoin, Resource::tableName(), \
Collection::resourceIdFullColumnName(), Resource::idFullColumnName() ); +    \
qb.addJoin(QueryBuilder::InnerJoin, Resource::tableName(), \
Collection::resourceIdFullColumnName(), Resource::idFullColumnName());  
-  qb.addJoin( QueryBuilder::LeftJoin, Part::tableName(), \
PimItem::idFullColumnName(), Part::pimItemIdFullColumnName() ); +    \
qb.addJoin(QueryBuilder::LeftJoin, Part::tableName(), PimItem::idFullColumnName(), \
Part::pimItemIdFullColumnName());  
-  Query::Condition partTypeJoinCondition;
-  partTypeJoinCondition.addColumnCondition( Part::partTypeIdFullColumnName(), \
                Query::Equals, PartType::idFullColumnName() );
-  if ( !mFullPayload && !mParts.isEmpty() ) {
-    partTypeJoinCondition.addCondition( PartTypeHelper::conditionFromFqNames( mParts \
                ) );
-  }
-  partTypeJoinCondition.addValueCondition( PartType::nsFullColumnName(), \
                Query::Equals, QLatin1String( "PLD" ) );
-  qb.addJoin( QueryBuilder::LeftJoin, PartType::tableName(), partTypeJoinCondition \
                );
-
-  qb.addColumn( PimItem::idFullColumnName() );
-  qb.addColumn( PimItem::remoteIdFullColumnName() );
-  qb.addColumn( MimeType::nameFullColumnName() );
-  qb.addColumn( Resource::nameFullColumnName() );
-  qb.addColumn( PartType::nameFullColumnName() );
-  qb.addColumn( Part::datasizeFullColumnName() );
-
-  if ( mScope.scope() != Scope::Invalid ) {
-    ItemQueryHelper::scopeToQuery( mScope, mConnection->context(), qb );
-  } else {
-    ItemQueryHelper::itemSetToQuery( mItemSet, qb, mCollection );
-  }
+    Query::Condition partTypeJoinCondition;
+    partTypeJoinCondition.addColumnCondition(Part::partTypeIdFullColumnName(), \
Query::Equals, PartType::idFullColumnName()); +    if (!mFullPayload && \
!mParts.isEmpty()) { +        \
partTypeJoinCondition.addCondition(PartTypeHelper::conditionFromFqNames(mParts)); +   \
} +    partTypeJoinCondition.addValueCondition(PartType::nsFullColumnName(), \
Query::Equals, QLatin1String("PLD")); +    qb.addJoin(QueryBuilder::LeftJoin, \
PartType::tableName(), partTypeJoinCondition); +
+    qb.addColumn(PimItem::idFullColumnName());
+    qb.addColumn(PimItem::remoteIdFullColumnName());
+    qb.addColumn(MimeType::nameFullColumnName());
+    qb.addColumn(Resource::nameFullColumnName());
+    qb.addColumn(PartType::nameFullColumnName());
+    qb.addColumn(Part::datasizeFullColumnName());
+
+    if (mScope.scope() != Scope::Invalid) {
+        ItemQueryHelper::scopeToQuery(mScope, mConnection->context(), qb);
+    } else {
+        ItemQueryHelper::itemSetToQuery(mItemSet, qb, mCollection);
+    }
 
-  // prevent a resource to trigger item retrieval from itself
-  if ( mConnection ) {
-    qb.addValueCondition( Resource::nameFullColumnName(), Query::NotEquals,
-                          QString::fromLatin1( mConnection->sessionId() ) );
-  }
+    // prevent a resource to trigger item retrieval from itself
+    if (mConnection) {
+        qb.addValueCondition(Resource::nameFullColumnName(), Query::NotEquals,
+                             QString::fromLatin1(mConnection->sessionId()));
+    }
 
-  if ( mChangedSince.isValid() ) {
-    qb.addValueCondition( PimItem::datetimeFullColumnName(), Query::GreaterOrEqual,
-                          mChangedSince.toUTC() );
-  }
+    if (mChangedSince.isValid()) {
+        qb.addValueCondition(PimItem::datetimeFullColumnName(), \
Query::GreaterOrEqual, +                             mChangedSince.toUTC());
+    }
 
-  qb.addSortColumn( PimItem::idFullColumnName(), Query::Ascending );
+    qb.addSortColumn(PimItem::idFullColumnName(), Query::Ascending);
 
-  if ( !qb.exec() ) {
-    mLastError = "Unable to retrieve items";
-    throw ItemRetrieverException( mLastError );
-  }
+    if (!qb.exec()) {
+        mLastError = "Unable to retrieve items";
+        throw ItemRetrieverException(mLastError);
+    }
 
-  qb.query().next();
+    qb.query().next();
 
-  return qb.query();
+    return qb.query();
 }
 
 bool ItemRetriever::exec()
 {
-  if ( mParts.isEmpty() && !mFullPayload ) {
-    return true;
-  }
+    if (mParts.isEmpty() && !mFullPayload) {
+        return true;
+    }
 
-  verifyCache();
+    verifyCache();
 
-  QSqlQuery query = buildQuery();
-  ItemRetrievalRequest *lastRequest = 0;
-  QList<ItemRetrievalRequest *> requests;
+    QSqlQuery query = buildQuery();
+    ItemRetrievalRequest *lastRequest = 0;
+    QList<ItemRetrievalRequest *> requests;
 
-  QStringList parts;
-  Q_FOREACH ( const QString &part, mParts ) {
-    if ( part.startsWith( QLatin1String( AKONADI_PARAM_PLD ) ) ) {
-      parts << part.mid( 4 );
-    }
-  }
-
-  while ( query.isValid() ) {
-    const qint64 pimItemId = query.value( PimItemIdColumn ).toLongLong();
-    if ( !lastRequest || lastRequest->id != pimItemId ) {
-      lastRequest = new ItemRetrievalRequest();
-      lastRequest->id = pimItemId;
-      lastRequest->remoteId = Utils::variantToByteArray( query.value( \
                PimItemRidColumn ) );
-      lastRequest->mimeType = Utils::variantToByteArray( query.value( MimeTypeColumn \
                ) );
-      lastRequest->resourceId = Utils::variantToString( query.value( ResourceColumn \
                ) );
-      lastRequest->parts = parts;
-      requests << lastRequest;
+    QStringList parts;
+    Q_FOREACH (const QString &part, mParts) {
+        if (part.startsWith(QLatin1String(AKONADI_PARAM_PLD))) {
+            parts << part.mid(4);
+        }
     }
 
-    if ( query.value( PartTypeNameColumn ).isNull() ) {
-      // LEFT JOIN did not find anything, retrieve all parts
-      query.next();
-      continue;
+    while (query.isValid()) {
+        const qint64 pimItemId = query.value(PimItemIdColumn).toLongLong();
+        if (!lastRequest || lastRequest->id != pimItemId) {
+            lastRequest = new ItemRetrievalRequest();
+            lastRequest->id = pimItemId;
+            lastRequest->remoteId = \
Utils::variantToByteArray(query.value(PimItemRidColumn)); +            \
lastRequest->mimeType = Utils::variantToByteArray(query.value(MimeTypeColumn)); +     \
lastRequest->resourceId = Utils::variantToString(query.value(ResourceColumn)); +      \
lastRequest->parts = parts; +            requests << lastRequest;
+        }
+
+        if (query.value(PartTypeNameColumn).isNull()) {
+            // LEFT JOIN did not find anything, retrieve all parts
+            query.next();
+            continue;
+        }
+
+        qint64 datasize = query.value(PartDatasizeColumn).toLongLong();
+        const QString partName = \
Utils::variantToString(query.value(PartTypeNameColumn)); +        \
Q_ASSERT(!partName.startsWith(QLatin1String(AKONADI_PARAM_PLD))); +
+        if (datasize <= 0) {
+            // request update for this part
+            if (mFullPayload && !lastRequest->parts.contains(partName)) {
+                lastRequest->parts << partName;
+            }
+        } else {
+            // data available, don't request update
+            lastRequest->parts.removeAll(partName);
+        }
+        query.next();
     }
 
-    qint64 datasize = query.value( PartDatasizeColumn ).toLongLong();
-    const QString partName = Utils::variantToString( query.value( PartTypeNameColumn \
                ) );
-    Q_ASSERT( !partName.startsWith( QLatin1String( AKONADI_PARAM_PLD ) ) );
-
-    if ( datasize <= 0 ) {
-      // request update for this part
-      if ( mFullPayload && !lastRequest->parts.contains( partName ) ) {
-        lastRequest->parts << partName;
-      }
-    } else {
-      // data available, don't request update
-      lastRequest->parts.removeAll( partName );
+    //akDebug() << "Closing queries and sending out requests.";
+
+    query.finish();
+
+    Q_FOREACH (ItemRetrievalRequest *request, requests) {
+        if (request->parts.isEmpty()) {
+            delete request;
+            continue;
+        }
+        // TODO: how should we handle retrieval errors here? so far they have been \
ignored, +        // which makes sense in some cases, do we need a command parameter \
for this? +        try {
+            ItemRetrievalManager::instance()->requestItemDelivery(request);
+        } catch (const ItemRetrieverException &e) {
+            akError() << e.type() << ": " << e.what();
+            mLastError = e.what();
+            return false;
+        }
     }
-    query.next();
-  }
-
-  //akDebug() << "Closing queries and sending out requests.";
-
-  query.finish();
 
-  Q_FOREACH ( ItemRetrievalRequest *request, requests ) {
-    if ( request->parts.isEmpty() ) {
-        delete request;
-        continue;
+    // retrieve items in child collections if requested
+    bool result = true;
+    if (mRecursive && mCollection.isValid()) {
+        Q_FOREACH (const Collection &col, mCollection.children()) {
+            ItemRetriever retriever(mConnection);
+            retriever.setCollection(col, mRecursive);
+            retriever.setRetrieveParts(mParts);
+            retriever.setRetrieveFullPayload(mFullPayload);
+            result = retriever.exec();
+            if (!result) {
+                break;
+            }
+        }
     }
-    // TODO: how should we handle retrieval errors here? so far they have been \
                ignored,
-    // which makes sense in some cases, do we need a command parameter for this?
-    try {
-      ItemRetrievalManager::instance()->requestItemDelivery( request );
-    } catch ( const ItemRetrieverException &e ) {
-      akError() << e.type() << ": " << e.what();
-      mLastError = e.what();
-      return false;
-    }
-  }
-
-  // retrieve items in child collections if requested
-  bool result = true;
-  if ( mRecursive && mCollection.isValid() ) {
-    Q_FOREACH ( const Collection &col, mCollection.children() ) {
-      ItemRetriever retriever( mConnection );
-      retriever.setCollection( col, mRecursive );
-      retriever.setRetrieveParts( mParts );
-      retriever.setRetrieveFullPayload( mFullPayload );
-      result = retriever.exec();
-      if ( !result ) {
-        break;
-      }
-    }
-  }
 
-  return result;
+    return result;
 }
 
 void ItemRetriever::verifyCache()
 {
-  if ( !connection()->verifyCacheOnRetrieval() ) {
-    return;
-  }
-
-  SelectQueryBuilder<Part> qb;
-  qb.addJoin( QueryBuilder::InnerJoin, PimItem::tableName(), \
                Part::pimItemIdFullColumnName(), PimItem::idFullColumnName() );
-  qb.addValueCondition( Part::externalFullColumnName(), Query::Equals, true );
-  qb.addValueCondition( Part::dataFullColumnName(), Query::IsNot, QVariant() );
-  if ( mScope.scope() != Scope::Invalid ) {
-    ItemQueryHelper::scopeToQuery( mScope, mConnection->context(), qb );
-  } else {
-    ItemQueryHelper::itemSetToQuery( mItemSet, qb, mCollection );
-  }
-
-  if ( !qb.exec() ) {
-    mLastError = "Unable to query parts.";
-    throw ItemRetrieverException( mLastError );
-  }
-
-  const Part::List externalParts = qb.result();
-  Q_FOREACH ( Part part, externalParts ) {
-    PartHelper::verify( part );
-  }
+    if (!connection()->verifyCacheOnRetrieval()) {
+        return;
+    }
+
+    SelectQueryBuilder<Part> qb;
+    qb.addJoin(QueryBuilder::InnerJoin, PimItem::tableName(), \
Part::pimItemIdFullColumnName(), PimItem::idFullColumnName()); +    \
qb.addValueCondition(Part::externalFullColumnName(), Query::Equals, true); +    \
qb.addValueCondition(Part::dataFullColumnName(), Query::IsNot, QVariant()); +    if \
(mScope.scope() != Scope::Invalid) { +        ItemQueryHelper::scopeToQuery(mScope, \
mConnection->context(), qb); +    } else {
+        ItemQueryHelper::itemSetToQuery(mItemSet, qb, mCollection);
+    }
+
+    if (!qb.exec()) {
+        mLastError = "Unable to query parts.";
+        throw ItemRetrieverException(mLastError);
+    }
+
+    const Part::List externalParts = qb.result();
+    Q_FOREACH (Part part, externalParts) {
+        PartHelper::verify(part);
+    }
 }
 
 QByteArray ItemRetriever::lastError() const
 {
-  return mLastError;
+    return mLastError;
 }
diff --git a/server/src/storage/notificationcollector.cpp \
b/server/src/storage/notificationcollector.cpp index 6c1b964..cea9eb2 100644
--- a/server/src/storage/notificationcollector.cpp
+++ b/server/src/storage/notificationcollector.cpp
@@ -31,310 +31,309 @@
 using namespace Akonadi;
 using namespace Akonadi::Server;
 
-NotificationCollector::NotificationCollector( QObject *parent )
-  : QObject( parent )
-  , mDb( 0 )
+NotificationCollector::NotificationCollector(QObject *parent)
+    : QObject(parent)
+    , mDb(0)
 {
 }
 
-NotificationCollector::NotificationCollector( DataStore *db )
-  : QObject( db )
-  , mDb( db )
+NotificationCollector::NotificationCollector(DataStore *db)
+    : QObject(db)
+    , mDb(db)
 {
-  connect( db, SIGNAL(transactionCommitted()), SLOT(transactionCommitted()) );
-  connect( db, SIGNAL(transactionRolledBack()), SLOT(transactionRolledBack()) );
+    connect(db, SIGNAL(transactionCommitted()), SLOT(transactionCommitted()));
+    connect(db, SIGNAL(transactionRolledBack()), SLOT(transactionRolledBack()));
 }
 
 NotificationCollector::~NotificationCollector()
 {
 }
 
-void NotificationCollector::itemAdded( const PimItem &item,
-                                       const Collection &collection,
-                                       const QByteArray &resource )
+void NotificationCollector::itemAdded(const PimItem &item,
+                                      const Collection &collection,
+                                      const QByteArray &resource)
 {
-  SearchManager::instance()->scheduleSearchUpdate();
-  itemNotification( NotificationMessageV2::Add, item, collection, Collection(), \
resource ); +    SearchManager::instance()->scheduleSearchUpdate();
+    itemNotification(NotificationMessageV2::Add, item, collection, Collection(), \
resource);  }
 
-void NotificationCollector::itemChanged( const PimItem &item,
-                                         const QSet<QByteArray> &changedParts,
-                                         const Collection &collection,
-                                         const QByteArray &resource )
+void NotificationCollector::itemChanged(const PimItem &item,
+                                        const QSet<QByteArray> &changedParts,
+                                        const Collection &collection,
+                                        const QByteArray &resource)
 {
-  SearchManager::instance()->scheduleSearchUpdate();
-  itemNotification( NotificationMessageV2::Modify, item, collection, Collection(), \
resource, changedParts ); +    SearchManager::instance()->scheduleSearchUpdate();
+    itemNotification(NotificationMessageV2::Modify, item, collection, Collection(), \
resource, changedParts);  }
 
-void NotificationCollector::itemsFlagsChanged( const PimItem::List &items,
-                                               const QSet< QByteArray > &addedFlags,
-                                               const QSet< QByteArray > \
                &removedFlags,
-                                               const Collection &collection,
-                                               const QByteArray &resource )
+void NotificationCollector::itemsFlagsChanged(const PimItem::List &items,
+                                              const QSet< QByteArray > &addedFlags,
+                                              const QSet< QByteArray > \
&removedFlags, +                                              const Collection \
&collection, +                                              const QByteArray \
&resource)  {
-  itemNotification( NotificationMessageV2::ModifyFlags, items, collection, \
Collection(), resource, QSet<QByteArray>(), addedFlags, removedFlags ); +    \
itemNotification(NotificationMessageV2::ModifyFlags, items, collection, Collection(), \
resource, QSet<QByteArray>(), addedFlags, removedFlags);  }
 
-void NotificationCollector::itemsTagsChanged(const PimItem::List& items,
-                                             const QSet<qint64>& addedTags,
-                                             const QSet<qint64>& removedTags,
-                                             const Collection& collection,
-                                             const QByteArray& resource)
+void NotificationCollector::itemsTagsChanged(const PimItem::List &items,
+                                             const QSet<qint64> &addedTags,
+                                             const QSet<qint64> &removedTags,
+                                             const Collection &collection,
+                                             const QByteArray &resource)
 {
-  itemNotification( NotificationMessageV2::ModifyTags, items, collection, \
Collection(), resource, QSet<QByteArray>(), QSet<QByteArray>(), QSet<QByteArray>(), \
addedTags, removedTags ); +    itemNotification(NotificationMessageV2::ModifyTags, \
items, collection, Collection(), resource, QSet<QByteArray>(), QSet<QByteArray>(), \
QSet<QByteArray>(), addedTags, removedTags);  }
 
-void NotificationCollector::itemsMoved( const PimItem::List &items,
-                                        const Collection &collectionSrc,
-                                        const Collection &collectionDest,
-                                        const QByteArray &sourceResource )
+void NotificationCollector::itemsMoved(const PimItem::List &items,
+                                       const Collection &collectionSrc,
+                                       const Collection &collectionDest,
+                                       const QByteArray &sourceResource)
 {
-  SearchManager::instance()->scheduleSearchUpdate();
-  itemNotification( NotificationMessageV2::Move, items, collectionSrc, \
collectionDest, sourceResource ); +    \
SearchManager::instance()->scheduleSearchUpdate(); +    \
itemNotification(NotificationMessageV2::Move, items, collectionSrc, collectionDest, \
sourceResource);  }
 
-void NotificationCollector::itemsRemoved( const PimItem::List &items,
-                                          const Collection &collection,
-                                          const QByteArray &resource )
+void NotificationCollector::itemsRemoved(const PimItem::List &items,
+                                         const Collection &collection,
+                                         const QByteArray &resource)
 {
-  itemNotification( NotificationMessageV2::Remove, items, collection, Collection(), \
resource ); +    itemNotification(NotificationMessageV2::Remove, items, collection, \
Collection(), resource);  }
 
-void NotificationCollector::itemsLinked( const PimItem::List &items, const \
Collection &collection ) +void NotificationCollector::itemsLinked(const PimItem::List \
&items, const Collection &collection)  {
-  itemNotification( NotificationMessageV2::Link, items, collection, Collection(), \
QByteArray() ); +    itemNotification(NotificationMessageV2::Link, items, collection, \
Collection(), QByteArray());  }
 
-void NotificationCollector::itemsUnlinked( const PimItem::List &items, const \
Collection &collection ) +void NotificationCollector::itemsUnlinked(const \
PimItem::List &items, const Collection &collection)  {
-  itemNotification( NotificationMessageV2::Unlink, items, collection, Collection(), \
QByteArray() ); +    itemNotification(NotificationMessageV2::Unlink, items, \
collection, Collection(), QByteArray());  }
 
-void NotificationCollector::collectionAdded( const Collection &collection,
-                                             const QByteArray &resource )
+void NotificationCollector::collectionAdded(const Collection &collection,
+                                            const QByteArray &resource)
 {
-  CacheCleaner::self()->collectionAdded( collection.id() );
-  IntervalCheck::self()->collectionAdded( collection.id() );
-  collectionNotification( NotificationMessageV2::Add, collection, \
collection.parentId(), -1, resource ); +    \
CacheCleaner::self()->collectionAdded(collection.id()); +    \
IntervalCheck::self()->collectionAdded(collection.id()); +    \
collectionNotification(NotificationMessageV2::Add, collection, collection.parentId(), \
-1, resource);  }
 
-void NotificationCollector::collectionChanged( const Collection &collection,
-                                               const QList<QByteArray> &changes,
-                                               const QByteArray &resource )
+void NotificationCollector::collectionChanged(const Collection &collection,
+                                              const QList<QByteArray> &changes,
+                                              const QByteArray &resource)
 {
-  CacheCleaner::self()->collectionChanged( collection.id() );
-  IntervalCheck::self()->collectionChanged( collection.id() );
-  collectionNotification( NotificationMessageV2::Modify, collection, \
collection.parentId(), -1, resource, changes.toSet() ); +    \
CacheCleaner::self()->collectionChanged(collection.id()); +    \
IntervalCheck::self()->collectionChanged(collection.id()); +    \
collectionNotification(NotificationMessageV2::Modify, collection, \
collection.parentId(), -1, resource, changes.toSet());  }
 
-void NotificationCollector::collectionMoved( const Collection &collection,
-                                             const Collection &source,
-                                             const QByteArray &resource,
-                                             const QByteArray &destResource )
+void NotificationCollector::collectionMoved(const Collection &collection,
+                                            const Collection &source,
+                                            const QByteArray &resource,
+                                            const QByteArray &destResource)
 {
-  CacheCleaner::self()->collectionChanged( collection.id() );
-  IntervalCheck::self()->collectionChanged( collection.id() );
-  collectionNotification( NotificationMessageV2::Move, collection, source.id(), \
collection.parentId(), resource, QSet<QByteArray>(), destResource ); +    \
CacheCleaner::self()->collectionChanged(collection.id()); +    \
IntervalCheck::self()->collectionChanged(collection.id()); +    \
collectionNotification(NotificationMessageV2::Move, collection, source.id(), \
collection.parentId(), resource, QSet<QByteArray>(), destResource);  }
 
-void NotificationCollector::collectionRemoved( const Collection &collection,
-                                               const QByteArray &resource )
+void NotificationCollector::collectionRemoved(const Collection &collection,
+                                              const QByteArray &resource)
 {
-  CacheCleaner::self()->collectionRemoved( collection.id() );
-  IntervalCheck::self()->collectionRemoved( collection.id() );
-  collectionNotification( NotificationMessageV2::Remove, collection, \
collection.parentId(), -1, resource ); +    \
CacheCleaner::self()->collectionRemoved(collection.id()); +    \
IntervalCheck::self()->collectionRemoved(collection.id()); +    \
collectionNotification(NotificationMessageV2::Remove, collection, \
collection.parentId(), -1, resource);  }
 
-void NotificationCollector::collectionSubscribed( const Collection &collection,
-                                                  const QByteArray &resource )
+void NotificationCollector::collectionSubscribed(const Collection &collection,
+                                                 const QByteArray &resource)
 {
-  CacheCleaner::self()->collectionAdded( collection.id() );
-  IntervalCheck::self()->collectionAdded( collection.id() );
-  collectionNotification( NotificationMessageV2::Subscribe, collection, \
collection.parentId(), -1, resource, QSet<QByteArray>() ); +    \
CacheCleaner::self()->collectionAdded(collection.id()); +    \
IntervalCheck::self()->collectionAdded(collection.id()); +    \
collectionNotification(NotificationMessageV2::Subscribe, collection, \
collection.parentId(), -1, resource, QSet<QByteArray>());  }
 
-void NotificationCollector::collectionUnsubscribed( const Collection &collection,
-                                                    const QByteArray &resource )
+void NotificationCollector::collectionUnsubscribed(const Collection &collection,
+                                                   const QByteArray &resource)
 {
-  CacheCleaner::self()->collectionRemoved( collection.id() );
-  IntervalCheck::self()->collectionRemoved( collection.id() );
-  collectionNotification( NotificationMessageV2::Unsubscribe, collection, \
collection.parentId(), -1, resource, QSet<QByteArray>() ); +    \
CacheCleaner::self()->collectionRemoved(collection.id()); +    \
IntervalCheck::self()->collectionRemoved(collection.id()); +    \
collectionNotification(NotificationMessageV2::Unsubscribe, collection, \
collection.parentId(), -1, resource, QSet<QByteArray>());  }
 
-void NotificationCollector::tagAdded(const Tag &tag )
+void NotificationCollector::tagAdded(const Tag &tag)
 {
-  tagNotification( NotificationMessageV2::Add, tag );
+    tagNotification(NotificationMessageV2::Add, tag);
 }
 
-void NotificationCollector::tagChanged( const Tag &tag )
+void NotificationCollector::tagChanged(const Tag &tag)
 {
-  tagNotification( NotificationMessageV2::Modify, tag );
+    tagNotification(NotificationMessageV2::Modify, tag);
 }
 
-void NotificationCollector::tagRemoved( const Tag &tag )
+void NotificationCollector::tagRemoved(const Tag &tag)
 {
-  tagNotification( NotificationMessageV2::Remove, tag );
+    tagNotification(NotificationMessageV2::Remove, tag);
 }
 
 void NotificationCollector::transactionCommitted()
 {
-  dispatchNotifications();
+    dispatchNotifications();
 }
 
 void NotificationCollector::transactionRolledBack()
 {
-  clear();
+    clear();
 }
 
 void NotificationCollector::clear()
 {
-  mNotifications.clear();
+    mNotifications.clear();
 }
 
-void NotificationCollector::setSessionId( const QByteArray &sessionId )
+void NotificationCollector::setSessionId(const QByteArray &sessionId)
 {
-  mSessionId = sessionId;
+    mSessionId = sessionId;
 }
 
-void NotificationCollector::itemNotification( NotificationMessageV2::Operation op,
-                                              const PimItem &item,
-                                              const Collection &collection,
-                                              const Collection &collectionDest,
-                                              const QByteArray &resource,
-                                              const QSet<QByteArray> &parts )
+void NotificationCollector::itemNotification(NotificationMessageV2::Operation op,
+                                             const PimItem &item,
+                                             const Collection &collection,
+                                             const Collection &collectionDest,
+                                             const QByteArray &resource,
+                                             const QSet<QByteArray> &parts)
 {
-  PimItem::List items;
-  items << item;
-  itemNotification( op, items, collection, collectionDest, resource, parts );
+    PimItem::List items;
+    items << item;
+    itemNotification(op, items, collection, collectionDest, resource, parts);
 }
 
-void NotificationCollector::itemNotification( NotificationMessageV2::Operation op,
-                                              const PimItem::List &items,
-                                              const Collection &collection,
-                                              const Collection &collectionDest,
-                                              const QByteArray &resource,
-                                              const QSet<QByteArray> &parts,
-                                              const QSet<QByteArray> &addedFlags,
-                                              const QSet<QByteArray> &removedFlags,
-                                              const QSet<qint64> &addedTags,
-                                              const QSet<qint64> &removedTags )
+void NotificationCollector::itemNotification(NotificationMessageV2::Operation op,
+                                             const PimItem::List &items,
+                                             const Collection &collection,
+                                             const Collection &collectionDest,
+                                             const QByteArray &resource,
+                                             const QSet<QByteArray> &parts,
+                                             const QSet<QByteArray> &addedFlags,
+                                             const QSet<QByteArray> &removedFlags,
+                                             const QSet<qint64> &addedTags,
+                                             const QSet<qint64> &removedTags)
 {
-  Collection notificationDestCollection;
-  QMap<Entity::Id, PimItem> vCollections;
-
-  if ( ( op == NotificationMessageV2::Modify ) ||
-       ( op == NotificationMessageV2::ModifyFlags ) ||
-       ( op == NotificationMessageV2::ModifyTags ) ) {
-    vCollections = DataStore::self()->virtualCollections( items );
-  }
-
-  NotificationMessageV3 msg;
-  msg.setSessionId( mSessionId );
-  msg.setType( NotificationMessageV2::Items );
-  msg.setOperation( op );
-
-  msg.setItemParts( parts );
-  msg.setAddedFlags( addedFlags );
-  msg.setRemovedFlags( removedFlags );
-  msg.setAddedTags( addedTags );
-  msg.setRemovedTags( removedTags );
-
-  if ( collectionDest.isValid() ) {
-    QByteArray destResourceName;
-    destResourceName = collectionDest.resource().name().toLatin1();
-    msg.setDestinationResource( destResourceName );
-  }
-
-  msg.setParentDestCollection( collectionDest.id() );
-
-  /* Notify all virtual collections the items are linked to. */
-  Q_FOREACH ( const Entity::Id &colId, vCollections.uniqueKeys() ) {
-    NotificationMessageV3 copy = msg;
-
-    Q_FOREACH ( const PimItem &item, vCollections.values( colId ) ) {
-      copy.addEntity( item.id(), item.remoteId(), item.remoteRevision(), \
item.mimeType().name() ); +    Collection notificationDestCollection;
+    QMap<Entity::Id, PimItem> vCollections;
+
+    if ((op == NotificationMessageV2::Modify) ||
+        (op == NotificationMessageV2::ModifyFlags) ||
+        (op == NotificationMessageV2::ModifyTags)) {
+        vCollections = DataStore::self()->virtualCollections(items);
+    }
+
+    NotificationMessageV3 msg;
+    msg.setSessionId(mSessionId);
+    msg.setType(NotificationMessageV2::Items);
+    msg.setOperation(op);
+
+    msg.setItemParts(parts);
+    msg.setAddedFlags(addedFlags);
+    msg.setRemovedFlags(removedFlags);
+    msg.setAddedTags(addedTags);
+    msg.setRemovedTags(removedTags);
+
+    if (collectionDest.isValid()) {
+        QByteArray destResourceName;
+        destResourceName = collectionDest.resource().name().toLatin1();
+        msg.setDestinationResource(destResourceName);
     }
-    copy.setParentCollection( colId );
-    copy.setResource( resource );
-
-    dispatchNotification( copy );
-  }
-
-  Q_FOREACH ( const PimItem &item, items ) {
-    msg.addEntity( item.id(), item.remoteId(), item.remoteRevision(), \
                item.mimeType().name() );
-  }
-
-  Collection col;
-  if ( !collection.isValid() ) {
-    msg.setParentCollection( items.first().collection().id() );
-    col = items.first().collection();
-  } else {
-    msg.setParentCollection( collection.id() );
-    col = collection;
-  }
-
-  QByteArray res = resource;
-  if ( res.isEmpty() ) {
-    res = col.resource().name().toLatin1();
-  }
-  msg.setResource( res );
-
-  dispatchNotification( msg );
+
+    msg.setParentDestCollection(collectionDest.id());
+
+    /* Notify all virtual collections the items are linked to. */
+    Q_FOREACH (const Entity::Id &colId, vCollections.uniqueKeys()) {
+        NotificationMessageV3 copy = msg;
+
+        Q_FOREACH (const PimItem &item, vCollections.values(colId)) {
+            copy.addEntity(item.id(), item.remoteId(), item.remoteRevision(), \
item.mimeType().name()); +        }
+        copy.setParentCollection(colId);
+        copy.setResource(resource);
+
+        dispatchNotification(copy);
+    }
+
+    Q_FOREACH (const PimItem &item, items) {
+        msg.addEntity(item.id(), item.remoteId(), item.remoteRevision(), \
item.mimeType().name()); +    }
+
+    Collection col;
+    if (!collection.isValid()) {
+        msg.setParentCollection(items.first().collection().id());
+        col = items.first().collection();
+    } else {
+        msg.setParentCollection(collection.id());
+        col = collection;
+    }
+
+    QByteArray res = resource;
+    if (res.isEmpty()) {
+        res = col.resource().name().toLatin1();
+    }
+    msg.setResource(res);
+
+    dispatchNotification(msg);
 }
 
-void NotificationCollector::collectionNotification( NotificationMessageV2::Operation \
                op,
-                                                    const Collection &collection,
-                                                    Collection::Id source,
-                                                    Collection::Id destination,
-                                                    const QByteArray &resource,
-                                                    const QSet<QByteArray> &changes,
-                                                    const QByteArray &destResource )
+void NotificationCollector::collectionNotification(NotificationMessageV2::Operation \
op, +                                                   const Collection &collection,
+                                                   Collection::Id source,
+                                                   Collection::Id destination,
+                                                   const QByteArray &resource,
+                                                   const QSet<QByteArray> &changes,
+                                                   const QByteArray &destResource)
 {
-  NotificationMessageV3 msg;
-  msg.setType( NotificationMessageV2::Collections );
-  msg.setOperation( op );
-  msg.setSessionId( mSessionId );
-  msg.addEntity( collection.id(), collection.remoteId(), collection.remoteRevision() \
                );
-  msg.setParentCollection( source );
-  msg.setParentDestCollection( destination );
-  msg.setDestinationResource( destResource );
-  msg.setItemParts( changes );
-
-  QByteArray res = resource;
-  if ( res.isEmpty() ) {
-    res = collection.resource().name().toLatin1();
-  }
-  msg.setResource( res );
-
-  dispatchNotification( msg );
+    NotificationMessageV3 msg;
+    msg.setType(NotificationMessageV2::Collections);
+    msg.setOperation(op);
+    msg.setSessionId(mSessionId);
+    msg.addEntity(collection.id(), collection.remoteId(), \
collection.remoteRevision()); +    msg.setParentCollection(source);
+    msg.setParentDestCollection(destination);
+    msg.setDestinationResource(destResource);
+    msg.setItemParts(changes);
+
+    QByteArray res = resource;
+    if (res.isEmpty()) {
+        res = collection.resource().name().toLatin1();
+    }
+    msg.setResource(res);
+
+    dispatchNotification(msg);
 }
 
-void NotificationCollector::tagNotification( NotificationMessageV2::Operation op,
-                                             const Tag &tag )
+void NotificationCollector::tagNotification(NotificationMessageV2::Operation op,
+                                            const Tag &tag)
 {
-  NotificationMessageV3 msg;
-  msg.setType( NotificationMessageV2::Tags );
-  msg.setOperation( op );
-  msg.setSessionId( mSessionId );
-  msg.addEntity( tag.id() );
+    NotificationMessageV3 msg;
+    msg.setType(NotificationMessageV2::Tags);
+    msg.setOperation(op);
+    msg.setSessionId(mSessionId);
+    msg.addEntity(tag.id());
 
-  dispatchNotification( msg );
+    dispatchNotification(msg);
 }
 
-
-void NotificationCollector::dispatchNotification( const NotificationMessageV3 &msg )
+void NotificationCollector::dispatchNotification(const NotificationMessageV3 &msg)
 {
-  if ( !mDb || mDb->inTransaction() ) {
-    NotificationMessageV3::appendAndCompress( mNotifications, msg );
-  } else {
-    NotificationMessageV3::List l;
-    l << msg;
-    Q_EMIT notify( l );
-  }
+    if (!mDb || mDb->inTransaction()) {
+        NotificationMessageV3::appendAndCompress(mNotifications, msg);
+    } else {
+        NotificationMessageV3::List l;
+        l << msg;
+        Q_EMIT notify(l);
+    }
 }
 
 void NotificationCollector::dispatchNotifications()
 {
-  Q_EMIT notify( mNotifications );
-  clear();
+    Q_EMIT notify(mNotifications);
+    clear();
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic