File indexing completed on 2024-11-10 04:40:27

0001 /*
0002  *  SPDX-FileCopyrightText: 2008 Omat Holding B.V. <info@omat.nl>
0003  *  SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com>
0004  *
0005  *  SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #pragma once
0009 
0010 #include "akonadicore_export.h"
0011 #include "attribute.h"
0012 
0013 #include <QMap>
0014 
0015 namespace Akonadi
0016 {
0017 /**
0018  * An attribute for annotations.
0019  *
0020  * The attribute is inspired by RFC5257(IMAP ANNOTATION) and RFC5464(IMAP METADATA), but serves
0021  * the purpose of RFC5257.
0022  *
0023  * For a private note annotation the entry name is:
0024  * /private/comment
0025  * for a shared note:
0026  * /shared/comment
0027  *
0028  * @since 4.13
0029  */
0030 class AKONADICORE_EXPORT EntityAnnotationsAttribute : public Akonadi::Attribute
0031 {
0032 public:
0033     explicit EntityAnnotationsAttribute() = default;
0034     explicit EntityAnnotationsAttribute(const QMap<QByteArray, QByteArray> &annotations);
0035 
0036     void setAnnotations(const QMap<QByteArray, QByteArray> &annotations);
0037     [[nodiscard]] QMap<QByteArray, QByteArray> annotations() const;
0038 
0039     void insert(const QByteArray &key, const QString &value);
0040     [[nodiscard]] QString value(const QByteArray &key) const;
0041     [[nodiscard]] bool contains(const QByteArray &key) const;
0042 
0043     [[nodiscard]] QByteArray type() const override;
0044     Attribute *clone() const override;
0045     [[nodiscard]] QByteArray serialized() const override;
0046     void deserialize(const QByteArray &data) override;
0047 
0048 private:
0049     QMap<QByteArray, QByteArray> mAnnotations;
0050 };
0051 
0052 } // namespace Akonadi