/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "ui/text/text_isolated_emoji.h" #include "ui/image/image.h" #include "base/timer.h" #include class HistoryItem; class DocumentData; namespace Main { class Session; } // namespace Main namespace Lottie { class SinglePlayer; class FrameProvider; struct ColorReplacements; } // namespace Lottie namespace Ui { namespace Text { class String; } // namespace Text namespace Emoji { class UniversalImages; } // namespace Emoji } // namespace Ui namespace Stickers { using IsolatedEmoji = Ui::Text::IsolatedEmoji; struct LargeEmojiImage { std::optional image; FnMut load; [[nodiscard]] static QSize Size(); }; class EmojiPack final { public: struct Sticker { DocumentData *document = nullptr; const Lottie::ColorReplacements *replacements = nullptr; [[nodiscard]] bool empty() const { return (document == nullptr); } [[nodiscard]] explicit operator bool() const { return !empty(); } }; explicit EmojiPack(not_null session); ~EmojiPack(); bool add(not_null item); void remove(not_null item); [[nodiscard]] Sticker stickerForEmoji(const IsolatedEmoji &emoji); [[nodiscard]] std::shared_ptr image(EmojiPtr emoji); [[nodiscard]] auto animationsForEmoji(EmojiPtr emoji) const -> const base::flat_map> &; [[nodiscard]] std::unique_ptr effectPlayer( not_null document, QByteArray data, QString filepath, bool premium); private: class ImageLoader; void refresh(); void refreshDelayed(); void refreshAnimations(); void applySet(const MTPDmessages_stickerSet &data); void applyPack( const MTPDstickerPack &data, const base::flat_map> &map); void applyAnimationsSet(const MTPDmessages_stickerSet &data); [[nodiscard]] auto collectStickers(const QVector &list) const -> base::flat_map>; [[nodiscard]] auto collectAnimationsIndices( const QVector &packs) const -> base::flat_map>; void refreshAll(); void refreshItems(EmojiPtr emoji); void refreshItems(const base::flat_set> &list); not_null _session; base::flat_map> _map; base::flat_map< IsolatedEmoji, base::flat_set>> _items; base::flat_map> _images; mtpRequestId _requestId = 0; base::flat_map< EmojiPtr, base::flat_map>> _animations; mtpRequestId _animationsRequestId = 0; base::flat_map< not_null, std::weak_ptr> _sharedProviders; rpl::lifetime _lifetime; }; } // namespace Stickers