File indexing completed on 2024-12-01 04:35:32

0001 /*
0002    SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqola_private_export.h"
0010 #include <QDebug>
0011 #include <QString>
0012 
0013 class LIBRUQOLACORE_TESTS_EXPORT CustomEmoji
0014 {
0015     Q_GADGET
0016 public:
0017     CustomEmoji();
0018     ~CustomEmoji();
0019 
0020     void parseEmoji(const QJsonObject &emoji, bool useIsoDate = false);
0021 
0022     [[nodiscard]] QString identifier() const;
0023     void setIdentifier(const QString &identifier);
0024 
0025     [[nodiscard]] QString extension() const;
0026     void setExtension(const QString &extension);
0027 
0028     void setName(const QString &name);
0029     [[nodiscard]] QString name() const;
0030 
0031     [[nodiscard]] bool operator==(const CustomEmoji &other) const;
0032 
0033     CustomEmoji &operator=(const CustomEmoji &other) = default;
0034 
0035     [[nodiscard]] bool isValid() const;
0036 
0037     [[nodiscard]] QStringList aliases() const;
0038     void setAliases(const QStringList &aliases);
0039 
0040     [[nodiscard]] QString emojiIdentifier() const;
0041     void setEmojiIdentifier(const QString &emojiIdentifier);
0042 
0043     [[nodiscard]] QString cachedHtml() const;
0044 
0045     void clearCachedHtml();
0046     [[nodiscard]] bool hasEmoji(const QString &identifier) const;
0047 
0048     [[nodiscard]] qint64 updatedAt() const;
0049     void setUpdatedAt(qint64 updatedAt);
0050 
0051     [[nodiscard]] bool isAnimatedImage() const;
0052 
0053     [[nodiscard]] QString emojiUrl(const QString &serverUrl) const;
0054     [[nodiscard]] QString emojiFileName() const;
0055 
0056     [[nodiscard]] QString generateAnimatedUrlFromCustomEmoji(const QString &serverUrl) const;
0057     [[nodiscard]] QString generateHtmlFromCustomEmojiLocalPath(const QString &emojoLocalPath) const;
0058 
0059 private:
0060     QString mEmojiIdentifier;
0061     QString mIdentifier;
0062     QString mExtension;
0063     QString mName;
0064     mutable QString mCachedHtml;
0065     QStringList mAliases;
0066     qint64 mUpdatedAt = 0;
0067 };
0068 Q_DECLARE_TYPEINFO(CustomEmoji, Q_RELOCATABLE_TYPE);
0069 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const CustomEmoji &t);