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 <QString>
0012 
0013 #include <Akonadi/Attribute>
0014 
0015 #include <memory>
0016 
0017 namespace Akonadi
0018 {
0019 class ErrorAttributePrivate;
0020 
0021 /**
0022  * @short An Attribute to mark messages that failed to be sent.
0023  *
0024  * This attribute contains the error message encountered.
0025  *
0026  * @author Constantin Berzan <exit3219@gmail.com>
0027  * @since 4.4
0028  */
0029 class AKONADI_MIME_EXPORT ErrorAttribute : public Akonadi::Attribute
0030 {
0031 public:
0032     /**
0033      * Creates a new error attribute.
0034      *
0035      * @param msg The i18n'ed error message.
0036      */
0037     explicit ErrorAttribute(const QString &msg = QString());
0038 
0039     /**
0040      * Destroys the error attribute.
0041      */
0042     ~ErrorAttribute() override;
0043 
0044     /**
0045      * Returns the i18n'ed error message.
0046      */
0047     [[nodiscard]] QString message() const;
0048 
0049     /**
0050      * Sets the i18n'ed error message.
0051      */
0052     void setMessage(const QString &msg);
0053 
0054     /* reimpl */
0055     ErrorAttribute *clone() const override;
0056     [[nodiscard]] QByteArray type() const override;
0057     [[nodiscard]] QByteArray serialized() const override;
0058     void deserialize(const QByteArray &data) override;
0059 
0060 private:
0061     //@cond PRIVATE
0062     std::unique_ptr<ErrorAttributePrivate> const d;
0063     //@endcond
0064 };
0065 }