2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Apply proxy settings in mtproto-key-destroyer.

This commit is contained in:
John Preston
2018-05-18 15:20:28 +03:00
parent 4478c0a143
commit 425e56b3ea
5 changed files with 35 additions and 33 deletions

View File

@@ -278,13 +278,42 @@ bool Messenger::eventFilter(QObject *object, QEvent *e) {
return QObject::eventFilter(object, e);
}
void Messenger::setCurrentProxy(
const ProxyData &proxy,
bool enabled) {
const auto key = [&](const ProxyData &proxy) {
if (proxy.type == ProxyData::Type::Mtproto) {
return std::make_pair(proxy.host, proxy.port);
}
return std::make_pair(QString(), uint32(0));
};
const auto previousKey = key(Global::UseProxy()
? Global::SelectedProxy()
: ProxyData());
Global::SetSelectedProxy(proxy);
Global::SetUseProxy(enabled);
Sandbox::refreshGlobalProxy();
if (_mtproto) {
_mtproto->restart();
if (previousKey != key(proxy)) {
_mtproto->reInitConnection(_mtproto->mainDcId());
}
}
if (_mtprotoForKeysDestroy) {
_mtprotoForKeysDestroy->restart();
}
Global::RefConnectionTypeChanged().notify();
}
void Messenger::setMtpMainDcId(MTP::DcId mainDcId) {
Expects(!_mtproto);
_private->mtpConfig.mainDcId = mainDcId;
}
void Messenger::setMtpKey(MTP::DcId dcId, const MTP::AuthKey::Data &keyData) {
Expects(!_mtproto);
_private->mtpConfig.keys.push_back(std::make_shared<MTP::AuthKey>(MTP::AuthKey::Type::ReadFromFile, dcId, keyData));
}