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

akonadi

itemdeletejob.cpp

00001 /*
00002     Copyright (c) 2006 - 2007 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 "itemdeletejob.h"
00021 
00022 #include "collection.h"
00023 #include "collectionselectjob_p.h"
00024 #include "item.h"
00025 #include "job_p.h"
00026 #include "protocolhelper_p.h"
00027 
00028 #include <akonadi/private/imapparser_p.h>
00029 #include <akonadi/private/imapset_p.h>
00030 #include <akonadi/private/protocol_p.h>
00031 
00032 #include <KLocale>
00033 
00034 using namespace Akonadi;
00035 
00036 class Akonadi::ItemDeleteJobPrivate : public JobPrivate
00037 {
00038   public:
00039     ItemDeleteJobPrivate( ItemDeleteJob *parent )
00040       : JobPrivate( parent )
00041     {
00042     }
00043 
00044     void selectResult( KJob *job );
00045 
00046     Q_DECLARE_PUBLIC( ItemDeleteJob )
00047 
00048     Item::List mItems;
00049     Collection mCollection;
00050 };
00051 
00052 void ItemDeleteJobPrivate::selectResult( KJob *job )
00053 {
00054   if ( job->error() )
00055     return; // KCompositeJob takes care of errors
00056 
00057   const QByteArray command = newTag() + " " AKONADI_CMD_ITEMDELETE " 1:*\n";
00058   writeData( command );
00059 }
00060 
00061 ItemDeleteJob::ItemDeleteJob( const Item & item, QObject * parent )
00062   : Job( new ItemDeleteJobPrivate( this ), parent )
00063 {
00064   Q_D( ItemDeleteJob );
00065 
00066   d->mItems << item;
00067 }
00068 
00069 ItemDeleteJob::ItemDeleteJob(const Item::List& items, QObject* parent)
00070   : Job( new ItemDeleteJobPrivate( this ), parent )
00071 {
00072   Q_D( ItemDeleteJob );
00073   d->mItems = items;
00074 }
00075 
00076 ItemDeleteJob::ItemDeleteJob(const Collection& collection, QObject* parent)
00077   : Job( new ItemDeleteJobPrivate( this ), parent )
00078 {
00079   Q_D( ItemDeleteJob );
00080   d->mCollection = collection;
00081 }
00082 
00083 ItemDeleteJob::~ItemDeleteJob()
00084 {
00085 }
00086 
00087 void ItemDeleteJob::doStart()
00088 {
00089   Q_D( ItemDeleteJob );
00090 
00091   if ( !d->mItems.isEmpty() ) {
00092     QByteArray command = d->newTag();
00093     try {
00094       command += ProtocolHelper::itemSetToByteArray( d->mItems, AKONADI_CMD_ITEMDELETE );
00095     } catch ( const std::exception &e ) {
00096       setError( Unknown );
00097       setErrorText( QString::fromUtf8( e.what() ) );
00098       emitResult();
00099       return;
00100     }
00101     command += '\n';
00102     d->writeData( command );
00103   } else {
00104     CollectionSelectJob *job = new CollectionSelectJob( d->mCollection, this );
00105     connect( job, SIGNAL(result(KJob*)), SLOT(selectResult(KJob*)) );
00106     addSubjob( job );
00107   }
00108 }
00109 
00110 #include "itemdeletejob.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