confirm_phone_box.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "ui/layers/box_content.h"
  9. #include "ui/widgets/sent_code_field.h"
  10. namespace Ui {
  11. class FlatLabel;
  12. class RoundButton;
  13. class ConfirmPhoneBox final : public Ui::BoxContent {
  14. public:
  15. ConfirmPhoneBox(
  16. QWidget*,
  17. const QString &phone,
  18. int codeLength,
  19. const QString &openUrl,
  20. std::optional<int> timeout);
  21. [[nodiscard]] rpl::producer<QString> checkRequests() const;
  22. [[nodiscard]] rpl::producer<> resendRequests() const;
  23. void callDone();
  24. void showServerError(const QString &text);
  25. protected:
  26. void prepare() override;
  27. void setInnerFocus() override;
  28. void paintEvent(QPaintEvent *e) override;
  29. void resizeEvent(QResizeEvent *e) override;
  30. private:
  31. void sendCode();
  32. void sendCall();
  33. void checkPhoneAndHash();
  34. [[nodiscard]] int fragmentSkip() const;
  35. QString getPhone() const;
  36. void showError(const QString &error);
  37. // _hash from the link for account.sendConfirmPhoneCode call.
  38. // _phoneHash from auth.sentCode for account.confirmPhone call.
  39. const QString _phone;
  40. // If we receive the code length, we autosubmit _code field when enough symbols is typed.
  41. const int _sentCodeLength = 0;
  42. bool _isWaitingCheck = false;
  43. object_ptr<Ui::FlatLabel> _about = { nullptr };
  44. object_ptr<Ui::SentCodeField> _code = { nullptr };
  45. object_ptr<Ui::RoundButton> _fragment = { nullptr };
  46. QString _error;
  47. Ui::SentCodeCall _call;
  48. rpl::event_stream<QString> _checkRequests;
  49. rpl::event_stream<> _resendRequests;
  50. };
  51. } // namespace Ui