File indexing completed on 2024-05-12 05:22:14
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Daniel Vrátil <dvratil@redhat.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "fetchjob.h" 0010 #include "kgapicalendar_export.h" 0011 0012 #include <QDateTime> 0013 #include <QList> 0014 #include <QScopedPointer> 0015 0016 namespace KGAPI2 0017 { 0018 0019 class KGAPICALENDAR_EXPORT FreeBusyQueryJob : public KGAPI2::FetchJob 0020 { 0021 Q_OBJECT 0022 public: 0023 struct BusyRange { 0024 BusyRange() = default; 0025 BusyRange(const QDateTime &busyStart, const QDateTime &busyEnd) 0026 : busyStart(busyStart) 0027 , busyEnd(busyEnd) 0028 { 0029 } 0030 0031 bool operator==(const BusyRange &other) const 0032 { 0033 return busyStart == other.busyStart && busyEnd == other.busyEnd; 0034 } 0035 0036 QDateTime busyStart; 0037 QDateTime busyEnd; 0038 }; 0039 using BusyRangeList = QList<BusyRange>; 0040 0041 explicit FreeBusyQueryJob(const QString &id, const QDateTime &timeMin, const QDateTime &timeMax, const AccountPtr &account, QObject *parent = nullptr); 0042 ~FreeBusyQueryJob() override; 0043 0044 [[nodiscard]] QString id() const; 0045 [[nodiscard]] QDateTime timeMin() const; 0046 [[nodiscard]] QDateTime timeMax() const; 0047 0048 [[nodiscard]] BusyRangeList busy() const; 0049 0050 protected: 0051 void start() override; 0052 void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override; 0053 void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override; 0054 0055 private: 0056 class Private; 0057 QScopedPointer<Private> const d; 0058 friend class Private; 0059 }; 0060 0061 }