Akonadi

collectionstatisticsjob.cpp
1 /*
2  SPDX-FileCopyrightText: 2006-2007 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "collectionstatisticsjob.h"
8 
9 #include "collection.h"
10 #include "collectionstatistics.h"
11 #include "job_p.h"
12 #include "private/protocol_p.h"
13 #include "protocolhelper_p.h"
14 
15 using namespace Akonadi;
16 
17 class Akonadi::CollectionStatisticsJobPrivate : public JobPrivate
18 {
19 public:
20  explicit CollectionStatisticsJobPrivate(CollectionStatisticsJob *parent)
21  : JobPrivate(parent)
22  {
23  }
24 
25  QString jobDebuggingString() const override
26  {
27  return QStringLiteral("Collection Statistic from collection Id %1").arg(mCollection.id());
28  }
29 
30  Collection mCollection;
31  CollectionStatistics mStatistics;
32 };
33 
35  : Job(new CollectionStatisticsJobPrivate(this), parent)
36 {
38 
39  d->mCollection = collection;
40 }
41 
43 {
44 }
45 
47 {
49 
50  try {
51  d->sendCommand(Protocol::FetchCollectionStatsCommandPtr::create(ProtocolHelper::entityToScope(d->mCollection)));
52  } catch (const std::exception &e) {
55  emitResult();
56  return;
57  }
58 }
59 
61 {
63 
64  if (!response->isResponse() || response->type() != Protocol::Command::FetchCollectionStats) {
65  return Job::doHandleResponse(tag, response);
66  }
67 
68  d->mStatistics = ProtocolHelper::parseCollectionStatistics(Protocol::cmdCast<Protocol::FetchCollectionStatsResponse>(response));
69  return true;
70 }
71 
73 {
75 
76  return d->mCollection;
77 }
78 
80 {
82 
83  return d->mStatistics;
84 }
Provides statistics information of a Collection.
void doStart() override
This method must be reimplemented in the concrete jobs.
QString fromUtf8(const char *str, int size)
@ Unknown
Unknown error.
Definition: job.h:102
void setErrorText(const QString &errorText)
Represents a collection of PIM items.
Definition: collection.h:61
~CollectionStatisticsJob() override
Destroys the collection statistics job.
CollectionStatisticsJob(const Collection &collection, QObject *parent=nullptr)
Creates a new collection statistics job.
Collection collection() const
Returns the corresponding collection, if the job was executed successfully, the collection is already...
bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
Base class for all actions in the Akonadi storage.
Definition: job.h:80
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
virtual bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response)
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
Definition: job.cpp:381
Job that fetches collection statistics from the Akonadi storage.
void emitResult()
CollectionStatistics statistics() const
Returns the fetched collection statistics.
void setError(int errorCode)
Q_D(Todo)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.