File indexing completed on 2024-05-12 05:11:10
0001 /* 0002 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadi-mime_export.h" 0010 0011 #include <QDateTime> 0012 0013 #include <Akonadi/Attribute> 0014 0015 #include <memory> 0016 0017 namespace Akonadi 0018 { 0019 class DispatchModeAttributePrivate; 0020 0021 /** 0022 Attribute determining how and when a message from the outbox should be 0023 dispatched. Messages can be sent immediately, sent only when the user 0024 explicitly requests it, or sent automatically at a certain date and time. 0025 0026 @author Constantin Berzan <exit3219@gmail.com> 0027 @since 4.4 0028 */ 0029 class AKONADI_MIME_EXPORT DispatchModeAttribute : public Akonadi::Attribute 0030 { 0031 public: 0032 /** 0033 Determines how the message is sent. 0034 */ 0035 enum DispatchMode { 0036 Automatic, ///< Send message as soon as possible, but no earlier than 0037 /// specified by setSendAfter() 0038 Manual ///< Send message only when the user requests so. 0039 }; 0040 0041 /** 0042 Creates a new DispatchModeAttribute. 0043 */ 0044 explicit DispatchModeAttribute(DispatchMode mode = Automatic); 0045 0046 /** 0047 Destroys the DispatchModeAttribute. 0048 */ 0049 ~DispatchModeAttribute() override; 0050 0051 /* reimpl */ 0052 DispatchModeAttribute *clone() const override; 0053 [[nodiscard]] QByteArray type() const override; 0054 [[nodiscard]] QByteArray serialized() const override; 0055 void deserialize(const QByteArray &data) override; 0056 0057 /** 0058 Returns the dispatch mode for the message. 0059 @see DispatchMode. 0060 */ 0061 [[nodiscard]] DispatchMode dispatchMode() const; 0062 0063 /** 0064 Sets the dispatch mode for the message. 0065 @param mode the dispatch mode to set 0066 @see DispatchMode. 0067 */ 0068 void setDispatchMode(DispatchMode mode); 0069 0070 /** 0071 Returns the date and time when the message should be sent. 0072 Only valid if dispatchMode() is Automatic. 0073 */ 0074 [[nodiscard]] QDateTime sendAfter() const; 0075 0076 /** 0077 Sets the date and time when the message should be sent. 0078 @param date the date and time to set 0079 @see setDispatchMode. 0080 */ 0081 void setSendAfter(const QDateTime &date); 0082 0083 private: 0084 std::unique_ptr<DispatchModeAttributePrivate> const d; 0085 }; 0086 } // namespace MailTransport