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

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • 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  QString jobDebuggingString() const /*Q_DECL_OVERRIDE*/ {
40  return QString::fromLatin1( "Collection Id %1").arg( mCollection.id() );
41  }
42 
43  Collection mCollection;
44  CollectionStatistics mStatistics;
45 };
46 
47 CollectionStatisticsJob::CollectionStatisticsJob( const Collection &collection, QObject * parent )
48  : Job( new CollectionStatisticsJobPrivate( this ), parent )
49 {
50  Q_D( CollectionStatisticsJob );
51 
52  d->mCollection = collection;
53 }
54 
55 CollectionStatisticsJob::~CollectionStatisticsJob()
56 {
57 }
58 
59 void CollectionStatisticsJob::doStart( )
60 {
61  Q_D( CollectionStatisticsJob );
62 
63  d->writeData( d->newTag() + " STATUS " + QByteArray::number( d->mCollection.id() ) + " (MESSAGES UNSEEN SIZE)\n" );
64 }
65 
66 void CollectionStatisticsJob::doHandleResponse( const QByteArray & tag, const QByteArray & data )
67 {
68  Q_D( CollectionStatisticsJob );
69 
70  if ( tag == "*" ) {
71  QByteArray token;
72  int current = ImapParser::parseString( data, token );
73  if ( token == "STATUS" ) {
74  // folder path
75  current = ImapParser::parseString( data, token, current );
76  // result list
77  QList<QByteArray> list;
78  current = ImapParser::parseParenthesizedList( data, list, current );
79  for ( int i = 0; i < list.count() - 1; i += 2 ) {
80  if ( list[i] == "MESSAGES" ) {
81  d->mStatistics.setCount( list[i+1].toLongLong() );
82  } else if ( list[i] == "UNSEEN" ) {
83  d->mStatistics.setUnreadCount( list[i+1].toLongLong() );
84  } else if ( list[i] == "SIZE" ) {
85  d->mStatistics.setSize( list[i+1].toLongLong() );
86  } else {
87  kDebug() << "Unknown STATUS response: " << list[i];
88  }
89  }
90 
91  d->mCollection.setStatistics( d->mStatistics );
92  return;
93  }
94  }
95  kDebug() << "Unhandled response: " << tag << data;
96 }
97 
98 Collection CollectionStatisticsJob::collection() const
99 {
100  Q_D( const CollectionStatisticsJob );
101 
102  return d->mCollection;
103 }
104 
105 CollectionStatistics Akonadi::CollectionStatisticsJob::statistics() const
106 {
107  Q_D( const CollectionStatisticsJob );
108 
109  return d->mStatistics;
110 }
111 
Akonadi::CollectionStatisticsJob::doStart
virtual void doStart()
This method must be reimplemented in the concrete jobs.
Definition: collectionstatisticsjob.cpp:59
Akonadi::CollectionStatistics
Provides statistics information of a Collection.
Definition: collectionstatistics.h:69
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::Job
Base class for all actions in the Akonadi storage.
Definition: job.h:86
Akonadi::CollectionStatisticsJob::doHandleResponse
virtual void doHandleResponse(const QByteArray &tag, const QByteArray &data)
This method should be reimplemented in the concrete jobs in case you want to handle incoming data...
Definition: collectionstatisticsjob.cpp:66
Akonadi::CollectionStatisticsJob::statistics
CollectionStatistics statistics() const
Returns the fetched collection statistics.
Definition: collectionstatisticsjob.cpp:105
Akonadi::CollectionStatisticsJob::~CollectionStatisticsJob
virtual ~CollectionStatisticsJob()
Destroys the collection statistics job.
Definition: collectionstatisticsjob.cpp:55
Akonadi::CollectionStatisticsJob::collection
Collection collection() const
Returns the corresponding collection, if the job was executed successfully, the collection is already...
Definition: collectionstatisticsjob.cpp:98
Akonadi::JobPrivate
Definition: job_p.h:31
Akonadi::CollectionStatisticsJob
Job that fetches collection statistics from the Akonadi storage.
Definition: collectionstatisticsjob.h:66
Akonadi::CollectionStatisticsJob::CollectionStatisticsJob
CollectionStatisticsJob(const Collection &collection, QObject *parent=0)
Creates a new collection statistics job.
Definition: collectionstatisticsjob.cpp:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:26 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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