"Fossies" - the Fresh Open Source Software Archive

Member "tdesktop-4.8.3/Telegram/SourceFiles/api/api_peer_photo.h" (1 Jun 2023, 2568 Bytes) of package /linux/misc/tdesktop-4.8.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "api_peer_photo.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2 This file is part of Telegram Desktop,
    3 the official desktop application for the Telegram messaging service.
    4 
    5 For license and copyright information please follow this link:
    6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
    7 */
    8 #pragma once
    9 
   10 #include "mtproto/sender.h"
   11 
   12 class ApiWrap;
   13 class PeerData;
   14 class UserData;
   15 
   16 namespace Data {
   17 struct FileOrigin;
   18 } // namespace Data
   19 
   20 namespace Main {
   21 class Session;
   22 } // namespace Main
   23 
   24 namespace Api {
   25 
   26 class PeerPhoto final {
   27 public:
   28     using UserPhotoId = PhotoId;
   29     explicit PeerPhoto(not_null<ApiWrap*> api);
   30 
   31     enum class EmojiListType {
   32         Profile,
   33         Group,
   34     };
   35 
   36     struct UserPhoto {
   37         QImage image;
   38         DocumentId markupDocumentId = 0;
   39         std::vector<QColor> markupColors;
   40     };
   41 
   42     void upload(
   43         not_null<PeerData*> peer,
   44         UserPhoto &&photo,
   45         Fn<void()> done = nullptr);
   46     void uploadFallback(not_null<PeerData*> peer, UserPhoto &&photo);
   47     void updateSelf(
   48         not_null<PhotoData*> photo,
   49         Data::FileOrigin origin,
   50         Fn<void()> done = nullptr);
   51     void suggest(not_null<PeerData*> peer, UserPhoto &&photo);
   52     void clear(not_null<PhotoData*> photo);
   53     void clearPersonal(not_null<UserData*> user);
   54     void set(not_null<PeerData*> peer, not_null<PhotoData*> photo);
   55 
   56     void requestUserPhotos(not_null<UserData*> user, UserPhotoId afterId);
   57 
   58     void requestEmojiList(EmojiListType type);
   59     using EmojiList = std::vector<DocumentId>;
   60     [[nodiscard]] rpl::producer<EmojiList> emojiListValue(EmojiListType type);
   61 
   62     // Non-personal photo in case a personal photo is set.
   63     void registerNonPersonalPhoto(
   64         not_null<UserData*> user,
   65         not_null<PhotoData*> photo);
   66     void unregisterNonPersonalPhoto(not_null<UserData*> user);
   67     [[nodiscard]] PhotoData *nonPersonalPhoto(
   68         not_null<UserData*> user) const;
   69 
   70 private:
   71     enum class UploadType {
   72         Default,
   73         Suggestion,
   74         Fallback,
   75     };
   76 
   77     void ready(
   78         const FullMsgId &msgId,
   79         std::optional<MTPInputFile> file,
   80         std::optional<MTPVideoSize> videoSize);
   81     void upload(
   82         not_null<PeerData*> peer,
   83         UserPhoto &&photo,
   84         UploadType type,
   85         Fn<void()> done);
   86 
   87     const not_null<Main::Session*> _session;
   88     MTP::Sender _api;
   89 
   90     struct UploadValue {
   91         not_null<PeerData*> peer;
   92         UploadType type = UploadType::Default;
   93         Fn<void()> done;
   94     };
   95 
   96     base::flat_map<FullMsgId, UploadValue> _uploads;
   97 
   98     base::flat_map<not_null<UserData*>, mtpRequestId> _userPhotosRequests;
   99 
  100     base::flat_map<
  101         not_null<UserData*>,
  102         not_null<PhotoData*>> _nonPersonalPhotos;
  103 
  104     mtpRequestId _requestIdEmojiList = 0;
  105     rpl::variable<EmojiList> _profileEmojiList;
  106     rpl::variable<EmojiList> _groupEmojiList;
  107 
  108 };
  109 
  110 } // namespace Api