File indexing completed on 2024-05-12 05:10:49
0001 /* 0002 SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <schumacher@kde.org> 0003 SPDX-FileCopyrightText: 2012 Sérgio Martins <iamsergio@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 #pragma once 0008 0009 #include "calendarbase.h" 0010 0011 #include <KCalendarCore/IncidenceBase> 0012 #include <KCalendarCore/ScheduleMessage> 0013 0014 #include <QObject> 0015 #include <QString> 0016 0017 #include <memory> 0018 0019 namespace KCalendarCore 0020 { 0021 class ICalFormat; 0022 class FreeBusyCache; 0023 } 0024 0025 namespace Akonadi 0026 { 0027 class SchedulerPrivate; 0028 0029 /** 0030 This class provides an encapsulation of iTIP transactions (RFC 2446). 0031 It is an abstract base class for inheritance by implementations of the 0032 iTIP scheme like iMIP or iRIP. 0033 */ 0034 class Scheduler : public QObject 0035 { 0036 Q_OBJECT 0037 public: 0038 enum Result { 0039 ResultSuccess, 0040 ResultAssigningDifferentTypes, 0041 ResultOutatedUpdate, 0042 ResultErrorDelete, 0043 ResultIncidenceToDeleteNotFound, 0044 ResultGenericError, 0045 ResultNoFreeBusyCache, 0046 ResultErrorSavingFreeBusy, 0047 ResultCreatingError, 0048 ResultModifyingError, 0049 ResultDeletingError, 0050 ResultUnsupported, 0051 ResultUserCancelled 0052 }; 0053 0054 /** 0055 Creates a scheduler for calendar specified as argument. 0056 */ 0057 explicit Scheduler(QObject *parent = nullptr); 0058 ~Scheduler() override; 0059 0060 void setShowDialogs(bool enable); 0061 0062 /** 0063 * Notify @p recipients about @p incidence 0064 * 0065 * @param incidence the incidence to send 0066 * @param recipients the people to send it to 0067 */ 0068 virtual void publish(const KCalendarCore::IncidenceBase::Ptr &incidence, const QString &recipients) = 0; 0069 /** 0070 Performs iTIP transaction on incidence. The method is specified as the 0071 method argument and can be any valid iTIP method. 0072 0073 @param incidence the incidence for the transaction. Must be valid. 0074 @param method the iTIP transaction method to use. 0075 @param sender email address of the identity to use for sending - if empty, the identity is chosen based on the incidence organizer. 0076 */ 0077 virtual void performTransaction(const KCalendarCore::IncidenceBase::Ptr &incidence, KCalendarCore::iTIPMethod method, const QString &sender = {}) = 0; 0078 0079 /** 0080 Performs iTIP transaction on incidence to specified recipient(s). 0081 The method is specified as the method argumanet and can be any valid iTIP method. 0082 0083 @param incidence the incidence for the transaction. Must be valid. 0084 @param method the iTIP transaction method to use. 0085 @param recipients the recipients of the transaction. 0086 @param sender email address of the identity to use for sending - if empty, the identity is chosen based on the incidence organizer. 0087 */ 0088 virtual void performTransaction(const KCalendarCore::IncidenceBase::Ptr &incidence, 0089 KCalendarCore::iTIPMethod method, 0090 const QString &recipients, 0091 const QString &sender) = 0; 0092 0093 /** 0094 Accepts the transaction. The incidence argument specifies the iCal 0095 component on which the transaction acts. The status is the result of 0096 processing a iTIP message with the current calendar and specifies the 0097 action to be taken for this incidence. 0098 0099 @param incidence the incidence for the transaction. Must be valid. 0100 @param calendar a loaded calendar. 0101 @param method iTIP transaction method to check. 0102 @param status scheduling status. 0103 @param email the email address of the person for whom this 0104 transaction is to be performed. 0105 0106 Listen to the acceptTransactionFinished() signal to know the success. 0107 */ 0108 void acceptTransaction(const KCalendarCore::IncidenceBase::Ptr &incidence, 0109 const Akonadi::CalendarBase::Ptr &calendar, 0110 KCalendarCore::iTIPMethod method, 0111 KCalendarCore::ScheduleMessage::Status status, 0112 const QString &email = QString()); 0113 0114 /** 0115 Returns the directory where the free-busy information is stored. 0116 */ 0117 virtual QString freeBusyDir() const = 0; 0118 0119 /** 0120 Sets the free/busy cache used to store free/busy information. 0121 */ 0122 void setFreeBusyCache(KCalendarCore::FreeBusyCache *c); 0123 0124 /** 0125 Returns the free/busy cache. 0126 */ 0127 KCalendarCore::FreeBusyCache *freeBusyCache() const; 0128 0129 protected: 0130 void acceptPublish(const KCalendarCore::IncidenceBase::Ptr &incidence, 0131 const Akonadi::CalendarBase::Ptr &calendar, 0132 KCalendarCore::ScheduleMessage::Status status, 0133 KCalendarCore::iTIPMethod method); 0134 0135 void acceptRequest(const KCalendarCore::IncidenceBase::Ptr &incidence, 0136 const Akonadi::CalendarBase::Ptr &calendar, 0137 KCalendarCore::ScheduleMessage::Status status, 0138 const QString &email); 0139 0140 void acceptAdd(const KCalendarCore::IncidenceBase::Ptr &incidence, KCalendarCore::ScheduleMessage::Status status); 0141 0142 void acceptCancel(const KCalendarCore::IncidenceBase::Ptr &incidence, 0143 const Akonadi::CalendarBase::Ptr &calendar, 0144 KCalendarCore::ScheduleMessage::Status status, 0145 const QString &attendee); 0146 0147 void acceptDeclineCounter(const KCalendarCore::IncidenceBase::Ptr &incidence, KCalendarCore::ScheduleMessage::Status status); 0148 0149 void acceptReply(const KCalendarCore::IncidenceBase::Ptr &incidence, 0150 const Akonadi::CalendarBase::Ptr &calendar, 0151 KCalendarCore::ScheduleMessage::Status status, 0152 KCalendarCore::iTIPMethod method); 0153 0154 void acceptRefresh(const KCalendarCore::IncidenceBase::Ptr &incidence, KCalendarCore::ScheduleMessage::Status status); 0155 0156 void acceptCounter(const KCalendarCore::IncidenceBase::Ptr &incidence, KCalendarCore::ScheduleMessage::Status status); 0157 0158 void acceptFreeBusy(const KCalendarCore::IncidenceBase::Ptr &incidence, KCalendarCore::iTIPMethod method); 0159 KCalendarCore::ICalFormat *mFormat = nullptr; 0160 0161 Q_SIGNALS: 0162 void transactionFinished(Akonadi::Scheduler::Result, const QString &errorMessage); 0163 private Q_SLOTS: 0164 void handleCreateFinished(bool success, const QString &errorMessage); 0165 void handleModifyFinished(bool success, const QString &errorMessage); 0166 void handleDeleteFinished(bool success, const QString &errorMessage); 0167 0168 private: 0169 void connectCalendar(const Akonadi::CalendarBase::Ptr &calendar); 0170 Q_DISABLE_COPY(Scheduler) 0171 std::unique_ptr<SchedulerPrivate> const d; 0172 }; 0173 }