2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Add 'Use proxy for calls' option.

This commit is contained in:
John Preston
2018-05-07 00:29:53 +03:00
parent d2fa8ef0b0
commit 48c1576d7f
14 changed files with 201 additions and 66 deletions

View File

@@ -1218,6 +1218,13 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
if (connectionType == dbictProxiesList) {
qint32 count = 0, index = 0;
stream >> count >> index;
if (std::abs(index) > count) {
Global::SetUseProxyForCalls(true);
index -= (index > 0 ? count : -count);
} else {
Global::SetUseProxyForCalls(false);
}
auto list = std::vector<ProxyData>();
for (auto i = 0; i < count; ++i) {
const auto proxy = readProxy();
@@ -2485,7 +2492,9 @@ void writeSettings() {
data.stream << quint32(dbiConnectionType) << qint32(dbictProxiesList);
data.stream << qint32(proxies.size());
const auto index = qint32(proxyIt - begin(proxies)) + 1;
const auto index = qint32(proxyIt - begin(proxies))
+ qint32(Global::UseProxyForCalls() ? proxies.size() : 0)
+ 1;
data.stream << (Global::UseProxy() ? index : -index);
for (const auto &proxy : proxies) {
data.stream << qint32(kProxyTypeShift + int(proxy.type));