iv_data.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. namespace Iv {
  9. struct Source;
  10. struct Options {
  11. };
  12. struct Prepared {
  13. uint64 pageId = 0;
  14. QString name;
  15. QByteArray content;
  16. QByteArray script;
  17. QString url;
  18. QString hash;
  19. base::flat_map<QByteArray, QByteArray> embeds;
  20. base::flat_set<QByteArray> channelIds;
  21. bool rtl = false;
  22. bool hasCode = false;
  23. bool hasEmbeds = false;
  24. };
  25. struct Geo {
  26. float64 lat = 0.;
  27. float64 lon = 0.;
  28. uint64 access = 0;
  29. };
  30. [[nodiscard]] QByteArray GeoPointId(Geo point);
  31. [[nodiscard]] Geo GeoPointFromId(QByteArray data);
  32. class Data final {
  33. public:
  34. Data(const MTPDwebPage &webpage, const MTPPage &page);
  35. ~Data();
  36. [[nodiscard]] QString id() const;
  37. [[nodiscard]] bool partial() const;
  38. void updateCachedViews(int cachedViews);
  39. void prepare(const Options &options, Fn<void(Prepared)> done) const;
  40. private:
  41. const std::unique_ptr<Source> _source;
  42. };
  43. [[nodiscard]] QString SiteNameFromUrl(const QString &url);
  44. [[nodiscard]] bool ShowButton();
  45. void RecordShowFailure();
  46. [[nodiscard]] bool FailedToShow();
  47. } // namespace Iv