/* 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 "mtproto/sender.h" class ApiWrap; class PeerData; class UserData; namespace Data { struct FileOrigin; } // namespace Data namespace Main { class Session; } // namespace Main namespace Api { class PeerPhoto final { public: using UserPhotoId = PhotoId; explicit PeerPhoto(not_null api); enum class EmojiListType { Profile, Group, Background, NoChannelStatus, }; struct UserPhoto { QImage image; DocumentId markupDocumentId = 0; std::vector markupColors; }; void upload( not_null peer, UserPhoto &&photo, Fn done = nullptr); void uploadFallback(not_null peer, UserPhoto &&photo); void updateSelf( not_null photo, Data::FileOrigin origin, Fn done = nullptr); void suggest(not_null peer, UserPhoto &&photo); void clear(not_null photo); void clearPersonal(not_null user); void set(not_null peer, not_null photo); void requestUserPhotos(not_null user, UserPhotoId afterId); void requestEmojiList(EmojiListType type); using EmojiList = std::vector; [[nodiscard]] rpl::producer emojiListValue(EmojiListType type); // Non-personal photo in case a personal photo is set. void registerNonPersonalPhoto( not_null user, not_null photo); void unregisterNonPersonalPhoto(not_null user); [[nodiscard]] PhotoData *nonPersonalPhoto( not_null user) const; private: enum class UploadType { Default, Suggestion, Fallback, }; struct EmojiListData { rpl::variable list; mtpRequestId requestId = 0; }; void ready( const FullMsgId &msgId, std::optional file, std::optional videoSize); void upload( not_null peer, UserPhoto &&photo, UploadType type, Fn done); [[nodiscard]] EmojiListData &emojiList(EmojiListType type); [[nodiscard]] const EmojiListData &emojiList(EmojiListType type) const; const not_null _session; MTP::Sender _api; struct UploadValue { not_null peer; UploadType type = UploadType::Default; Fn done; }; base::flat_map _uploads; base::flat_map, mtpRequestId> _userPhotosRequests; base::flat_map< not_null, not_null> _nonPersonalPhotos; EmojiListData _profileEmojiList; EmojiListData _groupEmojiList; EmojiListData _backgroundEmojiList; EmojiListData _noChannelStatusEmojiList; }; } // namespace Api