• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
collectionstatisticsjob.cpp
1 /*
2  Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "collectionstatisticsjob.h"
21 
22 #include "collection.h"
23 #include "collectionstatistics.h"
24 #include "imapparser_p.h"
25 #include "job_p.h"
26 
27 #include <kdebug.h>
28 
29 using namespace Akonadi;
30 
31 class Akonadi::CollectionStatisticsJobPrivate : public JobPrivate
32 {
33  public:
34  CollectionStatisticsJobPrivate( CollectionStatisticsJob *parent )
35  : JobPrivate( parent )
36  {
37  }
38 
39  Collection mCollection;
40  CollectionStatistics mStatistics;
41 };
42 
43 CollectionStatisticsJob::CollectionStatisticsJob( const Collection &collection, QObject * parent )
44  : Job( new CollectionStatisticsJobPrivate( this ), parent )
45 {
46  Q_D( CollectionStatisticsJob );
47 
48  d->mCollection = collection;
49 }
50 
51 CollectionStatisticsJob::~CollectionStatisticsJob()
52 {
53 }
54 
55 void CollectionStatisticsJob::doStart( )
56 {
57  Q_D( CollectionStatisticsJob );
58 
59  d->writeData( d->newTag() + " STATUS " + QByteArray::number( d->mCollection.id() ) + " (MESSAGES UNSEEN SIZE)\n" );
60 }
61 
62 void CollectionStatisticsJob::doHandleResponse( const QByteArray & tag, const QByteArray & data )
63 {
64  Q_D( CollectionStatisticsJob );
65 
66  if ( tag == "*" ) {
67  QByteArray token;
68  int current = ImapParser::parseString( data, token );
69  if ( token == "STATUS" ) {
70  // folder path
71  current = ImapParser::parseString( data, token, current );
72  // result list
73  QList<QByteArray> list;
74  current = ImapParser::parseParenthesizedList( data, list, current );
75  for ( int i = 0; i < list.count() - 1; i += 2 ) {
76  if ( list[i] == "MESSAGES" ) {
77  d->mStatistics.setCount( list[i+1].toLongLong() );
78  } else if ( list[i] == "UNSEEN" ) {
79  d->mStatistics.setUnreadCount( list[i+1].toLongLong() );
80  } else if ( list[i] == "SIZE" ) {
81  d->mStatistics.setSize( list[i+1].toLongLong() );
82  } else {
83  kDebug() << "Unknown STATUS response: " << list[i];
84  }
85  }
86 
87  d->mCollection.setStatistics( d->mStatistics );
88  return;
89  }
90  }
91  kDebug() << "Unhandled response: " << tag << data;
92 }
93 
94 Collection CollectionStatisticsJob::collection() const
95 {
96  Q_D( const CollectionStatisticsJob );
97 
98  return d->mCollection;
99 }
100 
101 CollectionStatistics Akonadi::CollectionStatisticsJob::statistics() const
102 {
103  Q_D( const CollectionStatisticsJob );
104 
105  return d->mStatistics;
106 }
107 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:33 by doxygen 1.8.3.1 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.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • 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