• Skip to content
  • Skip to link menu
KDE 4.3 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 using namespace Akonadi;
00028 
00029 class Akonadi::CollectionModifyJobPrivate : public JobPrivate
00030 {
00031   public:
00032     CollectionModifyJobPrivate( CollectionModifyJob *parent )
00033       : JobPrivate( parent )
00034     {
00035     }
00036 
00037     Collection mCollection;
00038 };
00039 
00040 CollectionModifyJob::CollectionModifyJob( const Collection &collection, QObject * parent )
00041   : Job( new CollectionModifyJobPrivate( this ), parent )
00042 {
00043   Q_D( CollectionModifyJob );
00044   d->mCollection = collection;
00045 }
00046 
00047 CollectionModifyJob::~CollectionModifyJob()
00048 {
00049 }
00050 
00051 void CollectionModifyJob::doStart()
00052 {
00053   Q_D( CollectionModifyJob );
00054   if ( !d->mCollection.isValid() && d->mCollection.remoteId().isEmpty() ) {
00055     setError( Unknown );
00056     setErrorText( QLatin1String( "Invalid collection" ) );
00057     emitResult();
00058     return;
00059   }
00060 
00061   QByteArray command = d->newTag();
00062   if ( d->mCollection.isValid() )
00063     command += " MODIFY " + QByteArray::number( d->mCollection.id() );
00064   else
00065     command += " RID MODIFY " + ImapParser::quote( d->mCollection.remoteId().toUtf8() );
00066   QByteArray changes;
00067   if ( d->mCollection.d_func()->contentTypesChanged ) {
00068     QList<QByteArray> bList;
00069     foreach( const QString &s, d->mCollection.contentMimeTypes() ) bList << s.toLatin1();
00070     changes += " MIMETYPE (" + ImapParser::join( bList, " " ) + ')';
00071   }
00072   if ( d->mCollection.parent() >= 0 )
00073     changes += " PARENT " + QByteArray::number( d->mCollection.parent() );
00074   if ( !d->mCollection.name().isEmpty() )
00075     changes += " NAME " + ImapParser::quote( d->mCollection.name().toUtf8() );
00076   if ( !d->mCollection.remoteId().isNull() )
00077     changes += " REMOTEID " + ImapParser::quote( d->mCollection.remoteId().toUtf8() );
00078   if ( d->mCollection.d_func()->cachePolicyChanged )
00079     changes += ' ' + ProtocolHelper::cachePolicyToByteArray( d->mCollection.cachePolicy() );
00080   if ( d->mCollection.attributes().count() > 0 )
00081     changes += ' ' + ProtocolHelper::attributesToByteArray( d->mCollection );
00082   foreach ( const QByteArray &b, d->mCollection.d_func()->mDeletedAttributes )
00083     changes += " -" + b;
00084   if ( changes.isEmpty() ) {
00085     emitResult();
00086     return;
00087   }
00088   command += changes + '\n';
00089   d->writeData( command );
00090 }
00091 
00092 #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
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.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