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 "modifyjob.h"
0012 #include "enums.h"
0013 #include "kgapicalendar_export.h"
0014 
0015 #include <QScopedPointer>
0016 
0017 namespace KGAPI2 {
0018 
0019 /**
0020  * @brief A job to modify events in a calendar on user's Google Calendar account.
0021  *
0022  * @author Daniel Vrátil <dvratil@redhat.com>
0023  * @since 2.0
0024  */
0025 class KGAPICALENDAR_EXPORT EventModifyJob : public KGAPI2::ModifyJob
0026 {
0027     Q_OBJECT
0028 
0029     Q_PROPERTY(KGAPI2::SendUpdatesPolicy sendUpdates
0030                READ sendUpdates
0031                WRITE setSendUpdates
0032                NOTIFY sendUpdatesChanged)
0033   public:
0034 
0035     /**
0036      * @brief Constructs a job that will write changes in given @p event to
0037      *        corresponding event in calendar with given @p calendarId
0038      *
0039      * @param event Event to modify
0040      * @param calendarId ID of calendar where the event is stored
0041      * @param account Account to authenticate the request
0042      * @param parent
0043      */
0044     explicit EventModifyJob(const EventPtr &event, const QString &calendarId,
0045                             const AccountPtr &account, QObject* parent = nullptr);
0046 
0047     /**
0048      * @brief Constructs a job that will write changes in given @p events to
0049      *        corresponding events in calendar with given @p calendarId
0050      *
0051      * @param events Events to modify
0052      * @param calendarId ID of calendar where the event is stored
0053      * @param account Account to authenticate the request
0054      * @param parent
0055      */
0056     explicit EventModifyJob(const EventsList &events, const QString &calendarId,
0057                             const AccountPtr &account, QObject* parent = nullptr);
0058 
0059     /**
0060      * @brief Destructor
0061      */
0062     ~EventModifyJob() override;
0063 
0064     [[nodiscard]] KGAPI2::SendUpdatesPolicy sendUpdates() const;
0065     void setSendUpdates(KGAPI2::SendUpdatesPolicy updatesPolicy);
0066 
0067   Q_SIGNALS:
0068     void sendUpdatesChanged(KGAPI2::SendUpdatesPolicy policy);
0069 
0070   protected:
0071 
0072     /**
0073      * @brief KGAPI2::Job::start implementation
0074      */
0075     void start() override;
0076 
0077     /**
0078      * @brief KGAPI2::ModifyJob::handleReplyWithItems implementation
0079      *
0080      * @param reply
0081      * @param rawData
0082      */
0083     ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray& rawData) override;
0084 
0085   private:
0086     class Private;
0087     QScopedPointer<Private> const d;
0088     friend class Private;
0089 
0090 };
0091 
0092 } // namespace KGAPI
0093