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 "types.h"
0012 #include "enums.h"
0013 #include "kgapicalendar_export.h"
0014 
0015 #include <QFlags>
0016 
0017 class QNetworkRequest;
0018 
0019 namespace KGAPI2
0020 {
0021 
0022 /**
0023  * @brief Additional methods for implementing support for Google Calendar service
0024  *
0025  * You should never need to use these methods, unless implementing your own Job
0026  */
0027 namespace CalendarService
0028 {
0029     enum class EventSerializeFlag {
0030         Default     =   0,
0031         NoID        =   1 << 0
0032     };
0033     using EventSerializeFlags = QFlags<EventSerializeFlag>;
0034 
0035     /**
0036      * @brief Preparse a QNetworkRequest for given URL
0037      *
0038      * @param url
0039      */
0040     KGAPICALENDAR_EXPORT QNetworkRequest prepareRequest(const QUrl &url);
0041 
0042     /**
0043      * @brief Parses calendar JSON data into Calendar object
0044      *
0045      * @param jsonData
0046      */
0047     KGAPICALENDAR_EXPORT CalendarPtr JSONToCalendar(const QByteArray& jsonData);
0048 
0049     /**
0050      * @brief Serializes calendar into JSON
0051      *
0052      * @param calendar
0053      */
0054     KGAPICALENDAR_EXPORT QByteArray calendarToJSON(const CalendarPtr& calendar);
0055 
0056     /**
0057      * @brief Parses JSON feed into list of Calendars
0058      *
0059      * @param jsonFeed
0060      * @param feedData The structure will be filled with additional information about
0061      *                 the feed, including URL for next page (if any)
0062      */
0063     KGAPICALENDAR_EXPORT ObjectsList parseCalendarJSONFeed(const QByteArray& jsonFeed, FeedData& feedData);
0064 
0065     /**
0066      * @brief Parses event JSON into Event object
0067      *
0068      * @param jsonData
0069      */
0070     KGAPICALENDAR_EXPORT EventPtr JSONToEvent(const QByteArray& jsonData);
0071 
0072     /**
0073      * @brief Serializes Event into JSON
0074      *
0075      * @param event
0076      */
0077     KGAPICALENDAR_EXPORT QByteArray eventToJSON(const EventPtr& event, EventSerializeFlags flags = EventSerializeFlag::Default);
0078 
0079     /**
0080      * @brief Parses JSON feed into list of Events
0081      *
0082      * @param jsonFeed
0083      * @param feedData The structure will be filled with additional information about
0084      *                  the feed, including URL for next page (if any)
0085      */
0086     KGAPICALENDAR_EXPORT ObjectsList parseEventJSONFeed(const QByteArray& jsonFeed, FeedData& feedData);
0087 
0088     /**
0089      * @brief Supported API version
0090      */
0091     KGAPICALENDAR_EXPORT QString APIVersion();
0092 
0093     /**
0094      * @brief Returns URL for fetching calendars list.
0095      */
0096     KGAPICALENDAR_EXPORT QUrl fetchCalendarsUrl();
0097 
0098     /**
0099      * @brief Returns URL for fetching single calendar.
0100      *
0101      * @param calendarID calendar ID
0102      */
0103     KGAPICALENDAR_EXPORT QUrl fetchCalendarUrl(const QString &calendarID);
0104 
0105     /**
0106      * @brief Returns URL for updating existing calendar.
0107      *
0108      * @param calendarID ID of calendar to modify
0109      */
0110     KGAPICALENDAR_EXPORT QUrl updateCalendarUrl(const QString &calendarID);
0111 
0112     /**
0113      * @brief Returns URL for creating a new calendar.
0114      */
0115     KGAPICALENDAR_EXPORT QUrl createCalendarUrl();
0116 
0117     /**
0118      * @brief Returns URL for removing an existing calendar.
0119      *
0120      * @param calendarID ID of calendar to remove
0121      */
0122     KGAPICALENDAR_EXPORT QUrl removeCalendarUrl(const QString &calendarID);
0123 
0124     /**
0125      * @brief Returns URL for fetching all events from a specific calendar
0126      *
0127      * @param calendarID ID of calendar from which to fetch events
0128      */
0129     KGAPICALENDAR_EXPORT QUrl fetchEventsUrl(const QString &calendarID);
0130 
0131     /**
0132      * @brief Returns URL for fetching a single event from a specific calendar.
0133      *
0134      * @param calendarID ID of calendar from which to fetch the event
0135      * @param eventID ID of event to fetch
0136      */
0137     KGAPICALENDAR_EXPORT QUrl fetchEventUrl(const QString &calendarID, const QString &eventID);
0138 
0139     /**
0140      * @brief Returns URL for updating a single event
0141      *
0142      * @param calendarID ID of calendar in which the event is
0143      * @param eventID ID of event to update
0144      * @param updatesPolicy Whether to send notification to participants
0145      */
0146     KGAPICALENDAR_EXPORT QUrl updateEventUrl(const QString &calendarID, const QString &eventID,
0147                                              SendUpdatesPolicy updatesPolicy);
0148 
0149     /**
0150      * @brief Returns URL creating new events.
0151      *
0152      * @param calendarID ID of calendar in which to create the event
0153      * @param updatesPolicy Whether to send notification to participants
0154      */
0155     KGAPICALENDAR_EXPORT QUrl createEventUrl(const QString &calendarID, SendUpdatesPolicy updatesPolicy);
0156     
0157     /**
0158      * @brief Returns URL importing private copies of existing events.
0159      *
0160      * @param calendarID ID of calendar in which to create the event
0161      * @param updatesPolicy Whether to send notification to participants
0162      */
0163     KGAPICALENDAR_EXPORT QUrl importEventUrl(const QString &calendarID, SendUpdatesPolicy updatesPolicy);
0164 
0165     /**
0166      * @brief Returns URL for removing events
0167      *
0168      * @param calendarID ID of parent calendar
0169      * @param eventID ID of event to remove.
0170      */
0171     KGAPICALENDAR_EXPORT QUrl removeEventUrl(const QString &calendarID, const QString &eventID);
0172 
0173     /**
0174      * @brief Returns URL for moving event between calendars.
0175      *
0176      * @param sourceCalendar ID of calendar from which to remove the event
0177      * @param destCalendar ID of calendar to which to move the even
0178      * @param eventID ID of event in the \p sourceCalendar to move
0179      */
0180     KGAPICALENDAR_EXPORT QUrl moveEventUrl(const QString &sourceCalendar, const QString &destCalendar, const QString &eventID);
0181 
0182     /**
0183      * @brief Returns URL for freebusy queries.
0184      */
0185     KGAPICALENDAR_EXPORT QUrl freeBusyQueryUrl();
0186 
0187 } // namespace CalendarService
0188 
0189 } // namespace KGAPI
0190 
0191 Q_DECLARE_OPERATORS_FOR_FLAGS(KGAPI2::CalendarService::EventSerializeFlags)
0192