File indexing completed on 2024-10-27 04:50:48

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <Akonadi/AgentBase>
0010 
0011 #include <MessageComposer/SendLaterInfo>
0012 
0013 class SendLaterManager;
0014 
0015 class SendLaterAgent : public Akonadi::AgentBase, public Akonadi::AgentBase::ObserverV3
0016 {
0017     Q_OBJECT
0018 public:
0019     explicit SendLaterAgent(const QString &id);
0020     ~SendLaterAgent() override;
0021 
0022     [[nodiscard]] QString printDebugInfo() const;
0023 
0024     void setEnableAgent(bool b);
0025     [[nodiscard]] bool enabledAgent() const;
0026 
0027 Q_SIGNALS:
0028     void needUpdateConfigDialogBox();
0029 
0030 public Q_SLOTS:
0031     void reload();
0032     void configure(WId windowId) override;
0033     void removeItem(qint64 item);
0034     void
0035     addItem(qint64 timestamp, bool recurrence, int recurrenceValue, int recurrenceUnit, Akonadi::Item::Id itemId, const QString &subject, const QString &to);
0036 
0037 protected:
0038     void itemsRemoved(const Akonadi::Item::List &item) override;
0039     void itemsMoved(const Akonadi::Item::List &items, const Akonadi::Collection &sourceCollection, const Akonadi::Collection &destinationCollection) override;
0040     void doSetOnline(bool online) override;
0041 
0042 private:
0043     void slotSendNow(Akonadi::Item::Id id);
0044     void slotStartAgent();
0045     bool mAgentInitialized = false;
0046     SendLaterManager *const mManager;
0047 };