20 #include "collectionmodifyjob.h"
22 #include "changemediator_p.h"
23 #include "collection_p.h"
24 #include "collectionstatistics.h"
25 #include "imapparser_p.h"
27 #include "protocolhelper_p.h"
29 #include <akonadi/private/protocol_p.h>
33 using namespace Akonadi;
35 class Akonadi::CollectionModifyJobPrivate :
public JobPrivate
47 :
Job( new CollectionModifyJobPrivate( this ), parent )
60 QByteArray command = d->newTag();
63 }
catch (
const std::exception &e ) {
65 setErrorText( QString::fromUtf8( e.what() ) );
71 if ( d->mCollection.d_func()->contentTypesChanged ) {
72 QList<QByteArray> bList;
73 foreach (
const QString &s, d->mCollection.contentMimeTypes() ) {
74 bList << s.toLatin1();
76 changes +=
" MIMETYPE (" + ImapParser::join( bList,
" " ) +
')';
78 if ( d->mCollection.parentCollection().id() >= 0 ) {
79 changes +=
" PARENT " + QByteArray::number( d->mCollection.parentCollection().id() );
81 if ( !d->mCollection.name().isEmpty() ) {
82 changes +=
" NAME " + ImapParser::quote( d->mCollection.name().toUtf8() );
84 if ( !d->mCollection.remoteId().isNull() ) {
85 changes +=
" REMOTEID " + ImapParser::quote( d->mCollection.remoteId().toUtf8() );
87 if ( !d->mCollection.remoteRevision().isNull() ) {
88 changes +=
" REMOTEREVISION " + ImapParser::quote( d->mCollection.remoteRevision().toUtf8() );
90 if ( d->mCollection.d_func()->cachePolicyChanged ) {
93 if ( d->mCollection.attributes().count() > 0 ) {
96 foreach (
const QByteArray &b, d->mCollection.d_func()->mDeletedAttributes ) {
99 if ( changes.isEmpty() ) {
103 command += changes +
'\n';
104 d->writeData( command );
106 ChangeMediator::invalidateCollection( d->mCollection );
112 return d->mCollection;