2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Decouple MTP::Instance from Core::App.

This commit is contained in:
John Preston
2019-02-01 10:48:31 +03:00
parent 4f3263d979
commit f5cc93ec64
5 changed files with 44 additions and 5 deletions

View File

@@ -440,10 +440,13 @@ void Application::setMtpAuthorization(const QByteArray &serialized) {
void Application::startMtp() {
Expects(!_mtproto);
auto config = base::take(_private->mtpConfig);
config.deviceModel = _launcher->deviceModel();
config.systemVersion = _launcher->systemVersion();
_mtproto = std::make_unique<MTP::Instance>(
_dcOptions.get(),
MTP::Instance::Mode::Normal,
base::take(_private->mtpConfig));
std::move(config));
_mtproto->setUserPhone(cLoggedPhoneNumber());
_private->mtpConfig.mainDcId = _mtproto->mainDcId();
@@ -526,7 +529,12 @@ void Application::destroyMtpKeys(MTP::AuthKeysList &&keys) {
auto destroyConfig = MTP::Instance::Config();
destroyConfig.mainDcId = MTP::Instance::Config::kNoneMainDc;
destroyConfig.keys = std::move(keys);
_mtprotoForKeysDestroy = std::make_unique<MTP::Instance>(_dcOptions.get(), MTP::Instance::Mode::KeysDestroyer, std::move(destroyConfig));
destroyConfig.deviceModel = _launcher->deviceModel();
destroyConfig.systemVersion = _launcher->systemVersion();
_mtprotoForKeysDestroy = std::make_unique<MTP::Instance>(
_dcOptions.get(),
MTP::Instance::Mode::KeysDestroyer,
std::move(destroyConfig));
connect(
_mtprotoForKeysDestroy.get(),
&MTP::Instance::allKeysDestroyed,