export_controller.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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/variant.h"
  9. #include "mtproto/mtproto_response.h"
  10. #include <QtCore/QPointer>
  11. #include <crl/crl_object_on_queue.h>
  12. namespace MTP {
  13. class Instance;
  14. } // namespace MTP
  15. namespace Export {
  16. class ControllerObject;
  17. struct Settings;
  18. struct Environment;
  19. struct PasswordCheckState {
  20. QString hint;
  21. QString unconfirmedPattern;
  22. bool requesting = true;
  23. bool hasPassword = false;
  24. bool checked = false;
  25. MTPInputPeer singlePeer = MTP_inputPeerEmpty();
  26. };
  27. struct ProcessingState {
  28. enum class Step {
  29. Initializing,
  30. DialogsList,
  31. PersonalInfo,
  32. Userpics,
  33. Stories,
  34. Contacts,
  35. Sessions,
  36. OtherData,
  37. Dialogs,
  38. };
  39. enum class EntityType {
  40. Chat,
  41. SavedMessages,
  42. RepliesMessages,
  43. VerifyCodes,
  44. Other,
  45. };
  46. Step step = Step::Initializing;
  47. int substepsPassed = 0;
  48. int substepsNow = 0;
  49. int substepsTotal = 0;
  50. EntityType entityType = EntityType::Other;
  51. QString entityName;
  52. int entityIndex = 0;
  53. int entityCount = 0;
  54. int itemIndex = 0;
  55. int itemCount = 0;
  56. uint64 bytesRandomId = 0;
  57. QString bytesName;
  58. int64 bytesLoaded = 0;
  59. int64 bytesCount = 0;
  60. };
  61. struct ApiErrorState {
  62. MTP::Error data;
  63. };
  64. struct OutputErrorState {
  65. QString path;
  66. };
  67. struct CancelledState {
  68. };
  69. struct FinishedState {
  70. QString path;
  71. int filesCount = 0;
  72. int64 bytesCount = 0;
  73. };
  74. using State = std::variant<
  75. v::null_t,
  76. PasswordCheckState,
  77. ProcessingState,
  78. ApiErrorState,
  79. OutputErrorState,
  80. CancelledState,
  81. FinishedState>;
  82. //struct PasswordUpdate {
  83. // enum class Type {
  84. // CheckSucceed,
  85. // WrongPassword,
  86. // FloodLimit,
  87. // RecoverUnavailable,
  88. // };
  89. // Type type = Type::WrongPassword;
  90. //
  91. //};
  92. class Controller {
  93. public:
  94. Controller(
  95. QPointer<MTP::Instance> mtproto,
  96. const MTPInputPeer &peer);
  97. rpl::producer<State> state() const;
  98. // Password step.
  99. //void submitPassword(const QString &password);
  100. //void requestPasswordRecover();
  101. //rpl::producer<PasswordUpdate> passwordUpdate() const;
  102. //void reloadPasswordState();
  103. //void cancelUnconfirmedPassword();
  104. // Processing step.
  105. void startExport(
  106. const Settings &settings,
  107. const Environment &environment);
  108. void skipFile(uint64 randomId);
  109. void cancelExportFast();
  110. rpl::lifetime &lifetime();
  111. ~Controller();
  112. private:
  113. using Implementation = ControllerObject;
  114. crl::object_on_queue<Implementation> _wrapped;
  115. rpl::lifetime _lifetime;
  116. };
  117. } // namespace Export