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

KIMAP Library

idlejob.cpp

00001 /*
00002     Copyright (c) 2009 Kevin Ottens <ervin@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 "idlejob.h"
00021 
00022 #include <QtCore/QTimer>
00023 #include <KDE/KLocale>
00024 
00025 #include "job_p.h"
00026 #include "message_p.h"
00027 #include "session_p.h"
00028 
00029 namespace KIMAP
00030 {
00031   class IdleJobPrivate : public JobPrivate
00032   {
00033     public:
00034       IdleJobPrivate( IdleJob *job, Session *session, const QString& name )
00035         : JobPrivate( session, name ), q(job),
00036           messageCount( -1 ), recentCount( -1 ),
00037           lastMessageCount( -1 ), lastRecentCount( -1 ) { }
00038       ~IdleJobPrivate() { }
00039 
00040       IdleJob * const q;
00041 
00042       int messageCount;
00043       int recentCount;
00044 
00045       int lastMessageCount;
00046       int lastRecentCount;
00047   };
00048 }
00049 
00050 using namespace KIMAP;
00051 
00052 IdleJob::IdleJob( Session *session )
00053   : Job( *new IdleJobPrivate(this, session, i18nc("name of the idle job", "Idle")) )
00054 {
00055 }
00056 
00057 IdleJob::~IdleJob()
00058 {
00059 }
00060 
00061 void KIMAP::IdleJob::stop()
00062 {
00063   Q_D(IdleJob);
00064   d->sessionInternal()->sendData( "DONE" );
00065 }
00066 
00067 void IdleJob::doStart()
00068 {
00069   Q_D(IdleJob);
00070   d->tags << d->sessionInternal()->sendCommand( "IDLE" );
00071 }
00072 
00073 void IdleJob::handleResponse( const Message &response )
00074 {
00075   Q_D(IdleJob);
00076 
00077   if (handleErrorReplies(response) == NotHandled ) {
00078     if ( response.content.size() > 0 && response.content[0].toString()=="+" ) {
00079       // Got the continuation all is fine
00080       return;
00081 
00082     } else if ( response.content[2].toString()=="EXISTS" ) {
00083       d->messageCount = response.content[1].toString().toInt();
00084     } else if ( response.content[2].toString()=="RECENT" ) {
00085       d->recentCount = response.content[1].toString().toInt();
00086     }
00087 
00088     if ( d->messageCount>=0 && d->recentCount>=0 ) {
00089       emit mailBoxStats(this, d->sessionInternal()->selectedMailBox(),
00090                         d->messageCount, d->recentCount);
00091 
00092       d->lastMessageCount = d->messageCount;
00093       d->lastRecentCount = d->recentCount;
00094 
00095       d->messageCount = -1;
00096       d->recentCount = -1;
00097     }
00098   }
00099 }
00100 
00101 QString KIMAP::IdleJob::lastMailBox() const
00102 {
00103   Q_D(const IdleJob);
00104   return d->sessionInternal()->selectedMailBox();
00105 }
00106 
00107 int KIMAP::IdleJob::lastMessageCount() const
00108 {
00109   Q_D(const IdleJob);
00110   return d->lastMessageCount;
00111 }
00112 
00113 int KIMAP::IdleJob::lastRecentCount() const
00114 {
00115   Q_D(const IdleJob);
00116   return d->lastRecentCount;
00117 }
00118 
00119 #include "idlejob.moc"

KIMAP Library

Skip menu "KIMAP Library"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • 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.6.2-20100208
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