File indexing completed on 2024-05-12 05:22:13

0001 /*
0002  * This file is part of LibKGAPI library
0003  *
0004  * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #pragma once
0010 
0011 #include "createjob.h"
0012 #include "enums.h"
0013 #include "kgapicalendar_export.h"
0014 
0015 #include <QScopedPointer>
0016 
0017 namespace KGAPI2
0018 {
0019 
0020 /**
0021  * @brief A job to create one or more new events in given calendar
0022  *
0023  * @author Daniel Vrátil <dvratil@redhat.com>
0024  * @since 2.0
0025  */
0026 class KGAPICALENDAR_EXPORT EventCreateJob : public KGAPI2::CreateJob
0027 {
0028     Q_OBJECT
0029 
0030     Q_PROPERTY(KGAPI2::SendUpdatesPolicy sendUpdates READ sendUpdates WRITE setSendUpdates NOTIFY sendUpdatesChanged)
0031 public:
0032     /**
0033      * @brief Constructs a job that will create given @p event in a calendar
0034      *        with given @p calendarID
0035      *
0036      * @param event Event to create
0037      * @param calendarId ID of calendar in which to store the event
0038      * @param account Account to authenticate the request
0039      * @param parent
0040      */
0041     explicit EventCreateJob(const EventPtr &event, const QString &calendarId, const AccountPtr &account, QObject *parent = nullptr);
0042 
0043     /**
0044      * @brief Constructs a job that will create given @p events in a calendar
0045      *        with given @p calendarID
0046      *
0047      * @param events Events to create
0048      * @param calendarId ID of calendar in which to store the event
0049      * @param account Account to authenticate the request
0050      * @param parent
0051      */
0052     explicit EventCreateJob(const EventsList &events, const QString &calendarId, const AccountPtr &account, QObject *parent = nullptr);
0053 
0054     /**
0055      * @brief Destructor
0056      */
0057     ~EventCreateJob() override;
0058 
0059     [[nodiscard]] KGAPI2::SendUpdatesPolicy sendUpdates() const;
0060     void setSendUpdates(KGAPI2::SendUpdatesPolicy updatePolicy);
0061 
0062 Q_SIGNALS:
0063     void sendUpdatesChanged(KGAPI2::SendUpdatesPolicy policy);
0064 
0065 protected:
0066     /**
0067      * @brief KGAPI2::Job::start implementation
0068      */
0069     void start() override;
0070 
0071     /**
0072      * @brief KGAPI2::CreateJob::handleReplyWithItems implementation
0073      *
0074      * @param reply
0075      * @param rawData
0076      */
0077     ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) override;
0078 
0079 private:
0080     class Private;
0081     QScopedPointer<Private> const d;
0082     friend class Private;
0083 };
0084 
0085 } // namespace KGAPI2