Akonadi

collectionstatsfetchhandler.cpp
1/***************************************************************************
2 * SPDX-FileCopyrightText: 2006 Ingo Kloecker <kloecker@kde.org> *
3 * *
4 * SPDX-License-Identifier: LGPL-2.0-or-later *
5 ***************************************************************************/
6
7#include "collectionstatsfetchhandler.h"
8
9#include "akonadi.h"
10#include "connection.h"
11#include "global.h"
12#include "handlerhelper.h"
13#include "storage/collectionstatistics.h"
14#include "storage/datastore.h"
15
16#include "private/scope_p.h"
17
18using namespace Akonadi;
19using namespace Akonadi::Server;
20
21CollectionStatsFetchHandler::CollectionStatsFetchHandler(AkonadiServer &akonadi)
22 : Handler(akonadi)
23{
24}
25
27{
28 const auto &cmd = Protocol::cmdCast<Protocol::FetchCollectionStatsCommand>(m_command);
29
30 const Collection col = HandlerHelper::collectionFromScope(cmd.collection(), connection()->context());
31 if (!col.isValid()) {
32 return failureResponse(QStringLiteral("No status for this folder"));
33 }
34
35 const auto stats = akonadi().collectionStatistics().statistics(col);
36 if (stats.count == -1) {
37 return failureResponse(QStringLiteral("Failed to query statistics."));
38 }
39
40 Protocol::FetchCollectionStatsResponse resp;
41 resp.setCount(stats.count);
42 resp.setUnseen(stats.count - stats.read);
43 resp.setSize(stats.size);
44 return successResponse(std::move(resp));
45}
Represents a collection of PIM items.
Definition collection.h:62
bool parseStream() override
Parse and handle the IMAP message using the streaming parser.
The handler interfaces describes an entity capable of handling an AkonadiIMAP command.
Definition handler.h:32
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:11:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.