File indexing completed on 2024-09-29 04:28:03
0001 // SPDX-FileCopyrightText: 2021-2023 Tobias Fella <tobias.fella@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include <QList> 0007 #include <Quotient/events/eventcontent.h> 0008 #include <Quotient/events/stateevent.h> 0009 0010 namespace Quotient 0011 { 0012 /** 0013 * @class ImagePackEventContent 0014 * 0015 * A class to define the content of an image pack event. 0016 * 0017 * See Matrix MSC2545 for more details. 0018 * https://github.com/Sorunome/matrix-doc/blob/soru/emotes/proposals/2545-emotes.md 0019 * 0020 * @sa ImagePackEvent 0021 */ 0022 class ImagePackEventContent 0023 { 0024 public: 0025 /** 0026 * @brief Defines the properties of an image pack. 0027 */ 0028 struct Pack { 0029 Quotient::Omittable<QString> displayName; /**< The display name of the pack. */ 0030 Quotient::Omittable<QUrl> avatarUrl; /**< The source mxc URL for the pack avatar. */ 0031 Quotient::Omittable<QStringList> usage; /**< An array of the usages for this pack. Possible usages are "emoticon" and "sticker". */ 0032 Quotient::Omittable<QString> attribution; /**< The attribution for the pack author(s). */ 0033 }; 0034 0035 /** 0036 * @brief Defines the properties of an image pack image. 0037 */ 0038 struct ImagePackImage { 0039 QString shortcode; /**< The shortcode for the image. */ 0040 QUrl url; /**< The mxc URL for this image. */ 0041 Quotient::Omittable<QString> body; /**< An optional text body for this image. */ 0042 Quotient::Omittable<Quotient::EventContent::ImageInfo> info; /**< The ImageInfo object used for the info block of m.sticker events. */ 0043 /** 0044 * @brief An array of the usages for this image. 0045 * 0046 * The possible values match those of the usage key of a pack object. 0047 */ 0048 Quotient::Omittable<QStringList> usage; 0049 }; 0050 0051 /** 0052 * @brief Return the pack properties. 0053 * 0054 * @sa Pack 0055 */ 0056 Quotient::Omittable<Pack> pack; 0057 0058 /** 0059 * @brief Return a vector of images in the pack. 0060 * 0061 * @sa ImagePackImage 0062 */ 0063 QList<ImagePackEventContent::ImagePackImage> images; 0064 0065 explicit ImagePackEventContent(const QJsonObject &o); 0066 0067 /** 0068 * @brief The definition of how to convert the content to Json. 0069 * 0070 * This is a specialization of the standard fillJson function from libQuotient. 0071 * 0072 * @sa Quotient::converters 0073 */ 0074 void fillJson(QJsonObject *o) const; 0075 }; 0076 0077 /** 0078 * @class ImagePackEvent 0079 * 0080 * Class to define an image pack state event. 0081 * 0082 * The event content is ImagePackEventContent. 0083 * 0084 * @sa Quotient::StateEvent, ImagePackEventContent 0085 */ 0086 class ImagePackEvent : public KeyedStateEventBase<ImagePackEvent, ImagePackEventContent> 0087 { 0088 public: 0089 QUO_EVENT(ImagePackEvent, "im.ponies.room_emotes") 0090 using KeyedStateEventBase::KeyedStateEventBase; 0091 }; 0092 0093 REGISTER_EVENT_TYPE(ImagePackEvent) 0094 }