/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "passport/passport_form_view_controller.h" #include "passport/passport_form_controller.h" namespace Passport { class FormController; class Panel; struct ScanInfo { FileKey key; QString status; QImage thumb; bool deleted = false; bool selfie = false; }; class BoxPointer { public: BoxPointer(QPointer value = nullptr); BoxPointer(BoxPointer &&other); BoxPointer &operator=(BoxPointer &&other); ~BoxPointer(); BoxContent *get() const; operator BoxContent*() const; explicit operator bool() const; BoxContent *operator->() const; private: QPointer _value; }; class PanelController : public ViewController { public: PanelController(not_null form); not_null bot() const; QString privacyPolicyUrl() const; void submitPassword(const QString &password); rpl::producer passwordError() const; QString passwordHint() const; void uploadScan(QByteArray &&content); void deleteScan(int fileIndex); void restoreScan(int fileIndex); void uploadSelfie(QByteArray &&content); void deleteSelfie(); void restoreSelfie(); rpl::producer scanUpdated() const; QString defaultEmail() const; QString defaultPhoneNumber() const; void showAskPassword() override; void showNoPassword() override; void showPasswordUnconfirmed() override; void fillRows( base::lambda callback); void editScope(int index) override; void saveScope(ValueMap &&data, ValueMap &&filesData); bool editScopeChanged( const ValueMap &data, const ValueMap &filesData) const; void cancelEditScope(); void showBox(object_ptr box) override; void cancelAuth(); rpl::lifetime &lifetime(); private: struct Row { QString title; QString description; }; void ensurePanelCreated(); void editScope(int index, int filesIndex); void editWithUpload(int index, int filesIndex); int findNonEmptyIndex( const std::vector> &files) const; void requestScopeFilesType(int index); void cancelValueEdit(); std::vector valueFiles(const Value &value) const; std::unique_ptr valueSelfie(const Value &value) const; void processValueSaveFinished(not_null value); void processVerificationNeeded(not_null value); Row collectRowInfo(const Scope &scope) const; QString collectRowReadyString(const Scope &scope) const; ScanInfo collectScanInfo(const EditFile &file) const; QString getDefaultContactValue(Scope::Type type) const; not_null _form; std::vector _scopes; std::unique_ptr _panel; base::lambda _panelHasUnsavedChanges; BoxPointer _confirmForgetChangesBox; Scope *_editScope = nullptr; int _editScopeFilesIndex = -1; BoxPointer _scopeFilesTypeBox; std::map, BoxPointer> _verificationBoxes; rpl::lifetime _lifetime; }; } // namespace Passport