/* 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 "base/weak_ptr.h" #include "data/stickers/data_stickers.h" #include "mtproto/sender.h" class DocumentData; namespace ChatHelpers { class Show; } // namespace ChatHelpers namespace Main { class Session; } // namespace Main namespace Ui { class PopupMenu; namespace Menu { struct MenuCallback; } // namespace Menu } // namespace Ui namespace Api { inline constexpr auto kStickersInOwnedSetMax = 120; inline constexpr auto kEmojiInOwnedSetMax = 200; inline constexpr auto kEmojiStickerSideMax = 100; void AddExistingStickerToSet( not_null session, const StickerSetIdentifier &set, not_null document, const QString &emoji, Fn done, Fn fail); void DeleteStickerSet( not_null session, const StickerSetIdentifier &set, Fn done, Fn fail); [[nodiscard]] bool HasOwnedStickerSets(not_null session); [[nodiscard]] bool HasOwnedEmojiSets(not_null session); [[nodiscard]] QString StickerEmojiOrDefault( not_null document); void FillChooseStickerSetMenu( not_null menu, std::shared_ptr show, not_null document); void FillChooseEmojiSetMenu( not_null menu, std::shared_ptr show, not_null document); void AddAddToStickerSetAction( const Ui::Menu::MenuCallback &addAction, std::shared_ptr show, not_null document); void AddAddToEmojiSetAction( const Ui::Menu::MenuCallback &addAction, std::shared_ptr show, not_null document); void AddAddToOwnedSetAction( const Ui::Menu::MenuCallback &addAction, std::shared_ptr show, not_null document); class StickerUpload final : public base::has_weak_ptr { public: StickerUpload( not_null session, StickerSetIdentifier set, QByteArray webpBytes, QString emoji); ~StickerUpload(); void start( Fn done, Fn fail, Fn progress = nullptr); void cancel(); private: void uploadReady(const MTPInputFile &file); void uploadFailed(); void uploadProgressed(); void requestAddSticker(const MTPInputDocument &document); const not_null _session; StickerSetIdentifier _set; QByteArray _bytes; QString _emoji; MTP::Sender _api; rpl::lifetime _uploadLifetime; FullMsgId _uploadId; DocumentId _documentId = 0; mtpRequestId _addRequestId = 0; Fn _done; Fn _fail; Fn _progress; int _lastReportedPercent = -1; }; } // namespace Api