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

akonadi

collectionselectjob.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 "collectionselectjob_p.h"
00021 
00022 #include "job_p.h"
00023 #include "protocol_p.h"
00024 
00025 #include <QtCore/QDebug>
00026 #include <KLocale>
00027 using namespace Akonadi;
00028 
00029 class Akonadi::CollectionSelectJobPrivate : public JobPrivate
00030 {
00031   public:
00032     CollectionSelectJobPrivate( CollectionSelectJob *parent )
00033       : JobPrivate( parent ),
00034         mUnseen( -1 ),
00035         mSilent( true )
00036     {
00037     }
00038 
00039     Collection mCollection;
00040     int mUnseen;
00041     bool mSilent;
00042 };
00043 
00044 CollectionSelectJob::CollectionSelectJob( const Collection &collection, QObject *parent )
00045   : Job( new CollectionSelectJobPrivate( this ), parent )
00046 {
00047   Q_D( CollectionSelectJob );
00048 
00049   d->mCollection = collection;
00050 }
00051 
00052 CollectionSelectJob::~CollectionSelectJob( )
00053 {
00054 }
00055 
00056 void CollectionSelectJob::doStart( )
00057 {
00058   Q_D( CollectionSelectJob );
00059 
00060   if ( d->mCollection.isValid() ) {
00061     QByteArray command( d->newTag() + " SELECT " );
00062     if ( d->mSilent )
00063       command += "SILENT ";
00064     d->writeData( command + QByteArray::number( d->mCollection.id() ) + '\n' );
00065   } else if ( !d->mCollection.remoteId().isEmpty() ) {
00066     QByteArray command( d->newTag() + " " AKONADI_CMD_RID " SELECT " );
00067     if ( d->mSilent )
00068       command += "SILENT ";
00069     // FIXME: Should this be quoted??
00070     d->writeData( command + d->mCollection.remoteId().toUtf8() + '\n' );
00071   } else {
00072     setError( Unknown );
00073     setErrorText( i18n( "Invalid collection specified" ) );
00074     emitResult();
00075   }
00076 }
00077 
00078 void CollectionSelectJob::doHandleResponse( const QByteArray & tag, const QByteArray & data )
00079 {
00080   Q_D( CollectionSelectJob );
00081 
00082   if ( tag == "*" ) {
00083     if ( data.startsWith( "OK [UNSEEN" ) ) { //krazy:exclude=strings
00084       int begin = data.indexOf( ' ', 4 );
00085       int end = data.indexOf( ']' );
00086       QByteArray number = data.mid( begin + 1, end - begin - 1 );
00087       d->mUnseen = number.toInt();
00088       return;
00089     }
00090   }
00091 }
00092 
00093 int CollectionSelectJob::unseen( ) const
00094 {
00095   Q_D( const CollectionSelectJob );
00096 
00097   return d->mUnseen;
00098 }
00099 
00100 void CollectionSelectJob::setRetrieveStatus(bool status)
00101 {
00102   Q_D( CollectionSelectJob );
00103 
00104   d->mSilent = !status;
00105 }
00106 
00107 
00108 #include "collectionselectjob_p.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