/*
 * SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org>
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#pragma once

#include "akonadicore_export.h"

#include <KJob>

#include <memory>

namespace Akonadi
{
class Collection;
class CollectionAttributesSynchronizationJobPrivate;

/*!
 * \brief Job that synchronizes the attributes of a collection.
 *
 * This job will trigger a resource to synchronize the attributes of
 * a collection based on what the backend is reporting to store them in the
 * Akonadi storage.
 *
 * \class Akonadi::CollectionAttributesSynchronizationJob
 * \inheaderfile Akonadi/CollectionAttributesSynchronizationJob
 * \inmodule AkonadiCore
 *
 * Example:
 *
 * \code
 * using namespace Akonadi;
 *
 * const Collection collection = ...;
 *
 * auto job = new CollectionAttributesSynchronizationJob(collection);
 * connect(job, &KJob::result, this, &MyClass::synchronizationFinished);
 * \endcode
 *
 * \note This is a KJob not an Akonadi::Job, so it won't auto-start!
 *
 * \author Volker Krause <vkrause@kde.org>
 * \since 4.6
 */
class AKONADICORE_EXPORT CollectionAttributesSynchronizationJob : public KJob
{
    Q_OBJECT

public:
    /*!
     * Creates a new synchronization job for the given collection.
     *
     * \a collection The collection to synchronize.
     */
    explicit CollectionAttributesSynchronizationJob(const Collection &collection, QObject *parent = nullptr);

    /*!
     * Destroys the synchronization job.
     */
    ~CollectionAttributesSynchronizationJob() override;

    /* reimpl */
    void start() override;

private:
    friend class CollectionAttributesSynchronizationJobPrivate;
    std::unique_ptr<CollectionAttributesSynchronizationJobPrivate> const d;
};

}
