• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi

collectionmodifyjob.cpp

00001 /*
00002     Copyright (c) 2006 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "collectionmodifyjob.h"
00021 #include "imapparser_p.h"
00022 #include "job_p.h"
00023 #include "protocolhelper_p.h"
00024 #include "collectionstatistics.h"
00025 #include "collection_p.h"
00026 
00027 #include <akonadi/private/protocol_p.h>
00028 
00029 #include <KLocale>
00030 
00031 using namespace Akonadi;
00032 
00033 class Akonadi::CollectionModifyJobPrivate : public JobPrivate
00034 {
00035   public:
00036     CollectionModifyJobPrivate( CollectionModifyJob *parent )
00037       : JobPrivate( parent )
00038     {
00039     }
00040 
00041     Collection mCollection;
00042 };
00043 
00044 CollectionModifyJob::CollectionModifyJob( const Collection &collection, QObject * parent )
00045   : Job( new CollectionModifyJobPrivate( this ), parent )
00046 {
00047   Q_D( CollectionModifyJob );
00048   d->mCollection = collection;
00049 }
00050 
00051 CollectionModifyJob::~CollectionModifyJob()
00052 {
00053 }
00054 
00055 void CollectionModifyJob::doStart()
00056 {
00057   Q_D( CollectionModifyJob );
00058   QByteArray command = d->newTag();
00059   try {
00060     command += ProtocolHelper::entityIdToByteArray( d->mCollection, AKONADI_CMD_COLLECTIONMODIFY );
00061   } catch ( const std::exception &e ) {
00062     setError( Job::Unknown );
00063     setErrorText( QString::fromUtf8( e.what() ) );
00064     emitResult();
00065     return;
00066   }
00067 
00068   QByteArray changes;
00069   if ( d->mCollection.d_func()->contentTypesChanged ) {
00070     QList<QByteArray> bList;
00071     foreach ( const QString &s, d->mCollection.contentMimeTypes() ) bList << s.toLatin1();
00072     changes += " MIMETYPE (" + ImapParser::join( bList, " " ) + ')';
00073   }
00074   if ( d->mCollection.parentCollection().id() >= 0 )
00075     changes += " PARENT " + QByteArray::number( d->mCollection.parentCollection().id() );
00076   if ( !d->mCollection.name().isEmpty() )
00077     changes += " NAME " + ImapParser::quote( d->mCollection.name().toUtf8() );
00078   if ( !d->mCollection.remoteId().isNull() )
00079     changes += " REMOTEID " + ImapParser::quote( d->mCollection.remoteId().toUtf8() );
00080   if ( !d->mCollection.remoteRevision().isNull() )
00081     changes += " REMOTEREVISION " + ImapParser::quote( d->mCollection.remoteRevision().toUtf8() );
00082   if ( d->mCollection.d_func()->cachePolicyChanged )
00083     changes += ' ' + ProtocolHelper::cachePolicyToByteArray( d->mCollection.cachePolicy() );
00084   if ( d->mCollection.attributes().count() > 0 )
00085     changes += ' ' + ProtocolHelper::attributesToByteArray( d->mCollection );
00086   foreach ( const QByteArray &b, d->mCollection.d_func()->mDeletedAttributes )
00087     changes += " -" + b;
00088   if ( changes.isEmpty() ) {
00089     emitResult();
00090     return;
00091   }
00092   command += changes + '\n';
00093   d->writeData( command );
00094 }
00095 
00096 Collection CollectionModifyJob::collection() const
00097 {
00098   const Q_D( CollectionModifyJob );
00099   return d->mCollection;
00100 }
00101 
00102 #include "collectionmodifyjob.moc"

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal