File indexing completed on 2024-05-12 05:10:48

0001 /*
0002   SPDX-FileCopyrightText: 2001, 2004 Cornelius Schumacher <schumacher@kde.org>
0003   SPDX-FileCopyrightText: 2010, 2012 Sérgio Martins <iamsergio@gmail.com>
0004 
0005   SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 #pragma once
0008 
0009 #include "mailclient_p.h"
0010 #include "scheduler_p.h"
0011 
0012 #include <Akonadi/Item>
0013 #include <KCalendarCore/Incidence>
0014 
0015 #include <memory>
0016 
0017 namespace Akonadi
0018 {
0019 class MailSchedulerPrivate;
0020 
0021 /*
0022   This class implements the iTIP interface using the email interface specified
0023   as Mail.
0024 */
0025 class MailScheduler : public Akonadi::Scheduler
0026 {
0027     Q_OBJECT
0028 public:
0029     /**
0030      * @param calendar Must be a valid and loaded calendar.
0031      */
0032     explicit MailScheduler(ITIPHandlerComponentFactory *factory, QObject *parent = nullptr);
0033     ~MailScheduler() override;
0034 
0035     void setEncrypt(bool encrypt);
0036 
0037     void setSign(bool sign);
0038 
0039     void publish(const KCalendarCore::IncidenceBase::Ptr &incidence, const QString &recipients) override;
0040 
0041     void performTransaction(const KCalendarCore::IncidenceBase::Ptr &incidence, KCalendarCore::iTIPMethod method, const QString &sender = {}) override;
0042 
0043     void performTransaction(const KCalendarCore::IncidenceBase::Ptr &incidence,
0044                             KCalendarCore::iTIPMethod method,
0045                             const QString &recipients,
0046                             const QString &sender) override;
0047 
0048     /** Returns the directory where the free-busy information is stored */
0049     [[nodiscard]] QString freeBusyDir() const override;
0050 
0051     /**
0052      * Accepts a counter proposal.
0053      * @param incidence A non-null incidence.
0054      * @param calendar A loaded calendar. Try not to use an ETMCalendar here, due to it's
0055      *                 async loading.
0056      */
0057     void acceptCounterProposal(const KCalendarCore::Incidence::Ptr &incidence, const Akonadi::CalendarBase::Ptr &calendar);
0058 
0059 private:
0060     /**
0061      * @brief onMailerFinished Handles the result of the MailClient operation.
0062      * @param result Error code.
0063      * @param errorMsg Error message if @p result is not success.
0064      */
0065     void onMailerFinished(Akonadi::MailClient::Result result, const QString &errorMsg);
0066 
0067 private:
0068     //@cond PRIVATE
0069     Q_DISABLE_COPY(MailScheduler)
0070     std::unique_ptr<MailSchedulerPrivate> const d;
0071     //@endcond
0072 };
0073 }