api_transcribes.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "mtproto/sender.h"
  9. class ApiWrap;
  10. namespace Main {
  11. class Session;
  12. } // namespace Main
  13. namespace Api {
  14. class Transcribes final {
  15. public:
  16. explicit Transcribes(not_null<ApiWrap*> api);
  17. struct Entry {
  18. QString result;
  19. bool shown = false;
  20. bool failed = false;
  21. bool toolong = false;
  22. bool pending = false;
  23. bool roundview = false;
  24. mtpRequestId requestId = 0;
  25. };
  26. void toggle(not_null<HistoryItem*> item);
  27. [[nodiscard]] const Entry &entry(not_null<HistoryItem*> item) const;
  28. void apply(const MTPDupdateTranscribedAudio &update);
  29. [[nodiscard]] bool freeFor(not_null<HistoryItem*> item) const;
  30. [[nodiscard]] bool trialsSupport();
  31. [[nodiscard]] TimeId trialsRefreshAt();
  32. [[nodiscard]] int trialsCount();
  33. [[nodiscard]] crl::time trialsMaxLengthMs() const;
  34. private:
  35. void load(not_null<HistoryItem*> item);
  36. const not_null<Main::Session*> _session;
  37. MTP::Sender _api;
  38. int _trialsCount = -1;
  39. std::optional<bool> _trialsSupport;
  40. TimeId _trialsRefreshAt = -1;
  41. base::flat_map<FullMsgId, Entry> _map;
  42. base::flat_map<uint64, FullMsgId> _ids;
  43. };
  44. } // namespace Api