• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.8.3 API Reference
  • KDE Home
  • 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 
00022 #include "changemediator_p.h"
00023 #include "collection_p.h"
00024 #include "collectionstatistics.h"
00025 #include "imapparser_p.h"
00026 #include "job_p.h"
00027 #include "protocolhelper_p.h"
00028 
00029 #include <akonadi/private/protocol_p.h>
00030 
00031 #include <KLocale>
00032 
00033 using namespace Akonadi;
00034 
00035 class Akonadi::CollectionModifyJobPrivate : public JobPrivate
00036 {
00037   public:
00038     CollectionModifyJobPrivate( CollectionModifyJob *parent )
00039       : JobPrivate( parent )
00040     {
00041     }
00042 
00043     Collection mCollection;
00044 };
00045 
00046 CollectionModifyJob::CollectionModifyJob( const Collection &collection, QObject * parent )
00047   : Job( new CollectionModifyJobPrivate( this ), parent )
00048 {
00049   Q_D( CollectionModifyJob );
00050   d->mCollection = collection;
00051 }
00052 
00053 CollectionModifyJob::~CollectionModifyJob()
00054 {
00055 }
00056 
00057 void CollectionModifyJob::doStart()
00058 {
00059   Q_D( CollectionModifyJob );
00060   QByteArray command = d->newTag();
00061   try {
00062     command += ProtocolHelper::entityIdToByteArray( d->mCollection, AKONADI_CMD_COLLECTIONMODIFY );
00063   } catch ( const std::exception &e ) {
00064     setError( Job::Unknown );
00065     setErrorText( QString::fromUtf8( e.what() ) );
00066     emitResult();
00067     return;
00068   }
00069 
00070   QByteArray changes;
00071   if ( d->mCollection.d_func()->contentTypesChanged ) {
00072     QList<QByteArray> bList;
00073     foreach ( const QString &s, d->mCollection.contentMimeTypes() ) bList << s.toLatin1();
00074     changes += " MIMETYPE (" + ImapParser::join( bList, " " ) + ')';
00075   }
00076   if ( d->mCollection.parentCollection().id() >= 0 )
00077     changes += " PARENT " + QByteArray::number( d->mCollection.parentCollection().id() );
00078   if ( !d->mCollection.name().isEmpty() )
00079     changes += " NAME " + ImapParser::quote( d->mCollection.name().toUtf8() );
00080   if ( !d->mCollection.remoteId().isNull() )
00081     changes += " REMOTEID " + ImapParser::quote( d->mCollection.remoteId().toUtf8() );
00082   if ( !d->mCollection.remoteRevision().isNull() )
00083     changes += " REMOTEREVISION " + ImapParser::quote( d->mCollection.remoteRevision().toUtf8() );
00084   if ( d->mCollection.d_func()->cachePolicyChanged )
00085     changes += ' ' + ProtocolHelper::cachePolicyToByteArray( d->mCollection.cachePolicy() );
00086   if ( d->mCollection.attributes().count() > 0 )
00087     changes += ' ' + ProtocolHelper::attributesToByteArray( d->mCollection );
00088   foreach ( const QByteArray &b, d->mCollection.d_func()->mDeletedAttributes )
00089     changes += " -" + b;
00090   if ( changes.isEmpty() ) {
00091     emitResult();
00092     return;
00093   }
00094   command += changes + '\n';
00095   d->writeData( command );
00096 
00097   ChangeMediator::invalidateCollection( d->mCollection );
00098 }
00099 
00100 Collection CollectionModifyJob::collection() const
00101 {
00102   const Q_D( CollectionModifyJob );
00103   return d->mCollection;
00104 }
00105 
00106 #include "collectionmodifyjob.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:49:15 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

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

kdepimlibs-4.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal