File indexing completed on 2024-12-22 04:56:51

0001 /*
0002     SPDX-FileCopyrightText: 2008 Ingo Klöcker <kloecker@kde.org>
0003     SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <Akonadi/AgentBase>
0011 #include <Akonadi/Item>
0012 
0013 class OutboxQueue;
0014 class SendJob;
0015 class SentActionHandler;
0016 /**
0017  * @short This agent dispatches mail put into the outbox collection.
0018  */
0019 class MailDispatcherAgent : public Akonadi::AgentBase
0020 {
0021     Q_OBJECT
0022 
0023     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Akonadi.MailDispatcherAgent")
0024 
0025 public:
0026     explicit MailDispatcherAgent(const QString &id);
0027     ~MailDispatcherAgent() override;
0028 
0029 Q_SIGNALS:
0030     /**
0031      * Emitted when the MDA has attempted to send an item.
0032      */
0033     void itemProcessed(const Akonadi::Item &item, bool result);
0034 
0035     /**
0036      * Emitted when the MDA has begun processing an item
0037      */
0038     Q_SCRIPTABLE void itemDispatchStarted();
0039 
0040 protected:
0041     void doSetOnline(bool online) override;
0042 
0043 private Q_SLOTS:
0044     void sendPercent(KJob *job, unsigned long percent);
0045 
0046 private:
0047     // Q_SLOTS:
0048     void abort();
0049     void dispatch();
0050     void itemFetched(const Akonadi::Item &item);
0051     void queueError(const QString &message);
0052     void sendResult(KJob *job);
0053     void emitStatusReady();
0054 
0055     OutboxQueue *const mQueue;
0056     SentActionHandler *const mSentActionHandler;
0057     SendJob *mCurrentJob = nullptr;
0058     Akonadi::Item mCurrentItem;
0059     bool mAborting = false;
0060     bool mSendingInProgress = false;
0061     bool mSentAnything = false;
0062     bool mErrorOccurred = false;
0063     bool mShowSentNotification = true;
0064     qulonglong mSentItemsSize = 0;
0065 };