2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Display channels promoted by proxy on top.

This commit is contained in:
John Preston
2018-05-11 17:03:53 +03:00
parent df9ec4b466
commit d3f85b4c4e
25 changed files with 392 additions and 387 deletions

View File

@@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/rsa_public_key.h"
#include "storage/localstorage.h"
#include "auth_session.h"
#include "application.h"
#include "apiwrap.h"
#include "messenger.h"
#include "lang/lang_instance.h"
@@ -36,6 +37,7 @@ public:
void start(Config &&config);
void setCurrentProxy(const ProxyData &proxy, bool enabled);
void suggestMainDcId(DcId mainDcId);
void setMainDcId(DcId mainDcId);
DcId mainDcId() const;
@@ -259,6 +261,28 @@ void Instance::Private::start(Config &&config) {
requestConfig();
}
void Instance::Private::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();
restart();
if (previousKey != key(proxy)) {
reInitConnection(mainDcId());
}
Global::RefConnectionTypeChanged().notify();
}
void Instance::Private::suggestMainDcId(DcId mainDcId) {
if (_mainDcIdForced) return;
setMainDcId(mainDcId);
@@ -1342,11 +1366,16 @@ void Instance::Private::prepareToDestroy() {
MustNotCreateSessions = true;
}
Instance::Instance(not_null<DcOptions*> options, Mode mode, Config &&config) : QObject()
Instance::Instance(not_null<DcOptions*> options, Mode mode, Config &&config)
: QObject()
, _private(std::make_unique<Private>(this, options, mode)) {
_private->start(std::move(config));
}
void Instance::setCurrentProxy(const ProxyData &proxy, bool enabled) {
_private->setCurrentProxy(proxy, enabled);
}
void Instance::suggestMainDcId(DcId mainDcId) {
_private->suggestMainDcId(mainDcId);
}