File indexing completed on 2024-11-10 04:40:31

0001 /*
0002     SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "job.h"
0010 #include "relation.h"
0011 
0012 namespace Akonadi
0013 {
0014 class Relation;
0015 class RelationFetchJobPrivate;
0016 
0017 /**
0018  * @short Job that to fetch relations from Akonadi storage.
0019  * @since 4.15
0020  */
0021 class AKONADICORE_EXPORT RelationFetchJob : public Job
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     /**
0027      * Creates a new relation fetch job.
0028      *
0029      * @param relation The relation to fetch.
0030      * @param parent The parent object.
0031      */
0032     explicit RelationFetchJob(const Relation &relation, QObject *parent = nullptr);
0033 
0034     explicit RelationFetchJob(const QList<QByteArray> &types, QObject *parent = nullptr);
0035 
0036     void setResource(const QString &identifier);
0037 
0038     /**
0039      * Returns the relations.
0040      */
0041     [[nodiscard]] Relation::List relations() const;
0042 
0043 Q_SIGNALS:
0044     /**
0045      * This signal is emitted whenever new relations have been fetched completely.
0046      *
0047      * @param relations The fetched relations.
0048      */
0049     void relationsReceived(const Akonadi::Relation::List &relations);
0050 
0051 protected:
0052     void doStart() override;
0053     bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
0054 
0055 private:
0056     Q_DECLARE_PRIVATE(RelationFetchJob)
0057 };
0058 
0059 }