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 "kgapicalendar_export.h"
0012 #include "modifyjob.h"
0013 
0014 #include <QScopedPointer>
0015 
0016 namespace KGAPI2
0017 {
0018 
0019 /**
0020  * @brief A job that moves events between given calendars
0021  *
0022  * @author Daniel Vrátil <dvratil@redhat.com>
0023  * @since 2.0
0024  */
0025 class KGAPICALENDAR_EXPORT EventMoveJob : public KGAPI2::ModifyJob
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     /**
0031      * @brief Constructs a job that will move given \p event from a calendar
0032      *        with \p sourceCalendarId to calendar with \p destinationCalendarId
0033      *
0034      * @param event Event to move
0035      * @param sourceCalendarId ID of calendar where the event is currently stored
0036      * @param destinationCalendarId ID of calendar where to move the event
0037      * @param account Account to authenticate the request
0038      * @param parent
0039      */
0040     explicit EventMoveJob(const EventPtr &event,
0041                           const QString &sourceCalendarId,
0042                           const QString &destinationCalendarId,
0043                           const AccountPtr &account,
0044                           QObject *parent = nullptr);
0045 
0046     /**
0047      * @brief Constructs a job that will move given \p events from a calendar
0048      *        with \p sourceCalendarId to calendar with \p destinationCalendarId
0049      *
0050      * @param events Events to move
0051      * @param sourceCalendarId ID of calendar where the events are currently stored
0052      * @param destinationCalendarId ID of calendar where to move the events
0053      * @param account Account to authenticate the request
0054      * @param parent
0055      */
0056     explicit EventMoveJob(const EventsList &events,
0057                           const QString &sourceCalendarId,
0058                           const QString &destinationCalendarId,
0059                           const AccountPtr &account,
0060                           QObject *parent = nullptr);
0061 
0062     /**
0063      * @brief Constructs a job that will move event with given \p eventId from a
0064      *        calendar with \p sourceCalendarId to calendar
0065      *        with \p destinationCalendarId
0066      *
0067      * @param eventId ID of event to move
0068      * @param sourceCalendarId ID of calendar where the event is currently stored
0069      * @param destinationCalendarId ID of calendar where to move the event
0070      * @param account Account to authenticate the request
0071      * @param parent
0072      */
0073     explicit EventMoveJob(const QString &eventId,
0074                           const QString &sourceCalendarId,
0075                           const QString &destinationCalendarId,
0076                           const AccountPtr &account,
0077                           QObject *parent = nullptr);
0078 
0079     /**
0080      * @brief Constructs a job that will move events with given \p eventsIds
0081      *        from a calendar with \p sourceCalendarId to calendar
0082      *        with \p destinationCalendarId
0083      *
0084      * @param eventsIds IDs of events to move
0085      * @param sourceCalendarId ID of calendar where the events are currently stored
0086      * @param destinationCalendarId ID of calendar where to move the events
0087      * @param account Account to authenticate the request
0088      * @param parent
0089      */
0090     explicit EventMoveJob(const QStringList &eventsIds,
0091                           const QString &sourceCalendarId,
0092                           const QString &destinationCalendarId,
0093                           const AccountPtr &account,
0094                           QObject *parent = nullptr);
0095 
0096     /**
0097      * @brief Destructor
0098      */
0099     ~EventMoveJob() override;
0100 
0101 protected:
0102     /**
0103      * @brief KGAPI2::Job::start implementation
0104      */
0105     void start() override;
0106 
0107     /**
0108      * @brief KGAPI2::Job::dispatchRequest implementation
0109      *
0110      * @param accessManager
0111      * @param request
0112      * @param data
0113      * @param contentType
0114      */
0115     void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override;
0116 
0117     /**
0118      * @brief KGAPI2::Job::handleReplyWithItems implementation
0119      *
0120      * @param reply
0121      * @param rawData
0122      */
0123     KGAPI2::ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) override;
0124 
0125 private:
0126     class Private;
0127     QScopedPointer<Private> const d;
0128     friend class Private;
0129 };
0130 
0131 } // namespace KGAPI2