Akonadi

collectionstatisticsjob.cpp
1/*
2 SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org>
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
15using namespace Akonadi;
16
17class Akonadi::CollectionStatisticsJobPrivate : public JobPrivate
18{
19public:
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
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
85
86#include "moc_collectionstatisticsjob.cpp"
Job that fetches collection statistics from the Akonadi storage.
CollectionStatisticsJob(const Collection &collection, QObject *parent=nullptr)
Creates a new collection statistics job.
CollectionStatistics statistics() const
Returns the fetched collection statistics.
Collection collection() const
Returns the corresponding collection, if the job was executed successfully, the collection is already...
~CollectionStatisticsJob() override
Destroys the collection statistics job.
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.
void doStart() override
This method must be reimplemented in the concrete jobs.
Provides statistics information of a Collection.
Represents a collection of PIM items.
Definition collection.h:62
Base class for all actions in the Akonadi storage.
Definition job.h:81
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
@ Unknown
Unknown error.
Definition job.h:102
void setErrorText(const QString &errorText)
void emitResult()
void setError(int errorCode)
Helper integration between Akonadi and Qt.
QString arg(Args &&... args) const const
QString fromUtf8(QByteArrayView str)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.