Akonadi

specialcollectionsdiscoveryjob.cpp
1/*
2 SPDX-FileCopyrightText: 2013 David Faure <faure@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "specialcollectionsdiscoveryjob.h"
8#include "collectionfetchjob.h"
9#include "collectionfetchscope.h"
10#include "specialcollectionattribute.h"
11#include <QStringList>
12
13#include "akonadicore_debug.h"
14
15using namespace Akonadi;
16
17/**
18 @internal
19*/
20class Akonadi::SpecialCollectionsDiscoveryJobPrivate
21{
22public:
23 SpecialCollectionsDiscoveryJobPrivate(SpecialCollections *collections, const QStringList &mimeTypes)
24 : mSpecialCollections(collections)
25 , mMimeTypes(mimeTypes)
26 {
27 }
28
29 SpecialCollections *const mSpecialCollections;
30 const QStringList mMimeTypes;
31};
32
34 : KCompositeJob(parent)
35 , d(new SpecialCollectionsDiscoveryJobPrivate(collections, mimeTypes))
36{
37}
38
40
41void Akonadi::SpecialCollectionsDiscoveryJob::start()
42{
44 job->fetchScope().setContentMimeTypes(d->mMimeTypes);
45 addSubjob(job);
46}
47
48void Akonadi::SpecialCollectionsDiscoveryJob::slotResult(KJob *job)
49{
50 if (job->error()) {
51 qCWarning(AKONADICORE_LOG) << job->errorString();
52 return;
53 }
54 auto fetchJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
55 const Akonadi::Collection::List lstCollections = fetchJob->collections();
56 for (const Akonadi::Collection &collection : lstCollections) {
57 if (collection.hasAttribute<SpecialCollectionAttribute>()) {
58 d->mSpecialCollections->registerCollection(collection.attribute<SpecialCollectionAttribute>()->collectionType(), collection);
59 }
60 }
61 emitResult();
62}
63
64#include "moc_specialcollectionsdiscoveryjob.cpp"
Job that fetches collections from the Akonadi storage.
@ Recursive
List all sub-collections.
Represents a collection of PIM items.
Definition collection.h:62
static Collection root()
Returns the root collection.
An Attribute that stores the special collection type of a collection.
QByteArray collectionType() const
Returns the special collections type of the collection.
~SpecialCollectionsDiscoveryJob() override
Destroys the special collections request job.
SpecialCollectionsDiscoveryJob(SpecialCollections *collections, const QStringList &mimeTypes, QObject *parent=nullptr)
Creates a new special collections request job.
An interface to special collections.
virtual QString errorString() const
int error() const
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.