calls_choose_join_as.h 1.3 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. #include "base/weak_ptr.h"
  9. #include "base/object_ptr.h"
  10. class PeerData;
  11. namespace Ui {
  12. class Show;
  13. class BoxContent;
  14. } // namespace Ui
  15. namespace Calls::Group {
  16. struct JoinInfo;
  17. class ChooseJoinAsProcess final {
  18. public:
  19. ChooseJoinAsProcess() = default;
  20. ~ChooseJoinAsProcess();
  21. enum class Context {
  22. Create,
  23. CreateScheduled,
  24. Join,
  25. JoinWithConfirm,
  26. Switch,
  27. };
  28. void start(
  29. not_null<PeerData*> peer,
  30. Context context,
  31. std::shared_ptr<Ui::Show> show,
  32. Fn<void(JoinInfo)> done,
  33. PeerData *changingJoinAsFrom = nullptr);
  34. private:
  35. void requestList();
  36. void processList(std::vector<not_null<PeerData*>> &&list);
  37. void finish(JoinInfo info);
  38. struct ChannelsListRequest {
  39. not_null<PeerData*> peer;
  40. std::shared_ptr<Ui::Show> show;
  41. Fn<void(JoinInfo)> done;
  42. base::has_weak_ptr guard;
  43. QPointer<Ui::BoxContent> box;
  44. rpl::lifetime lifetime;
  45. Context context = Context();
  46. mtpRequestId id = 0;
  47. PeerData *changingJoinAsFrom = nullptr;
  48. };
  49. std::unique_ptr<ChannelsListRequest> _request;
  50. };
  51. } // namespace Calls::Group