Add proxy auto-rotation option.

This commit is contained in:
John Preston
2026-04-16 14:50:06 +07:00
parent 1b96772126
commit 2cd90eb3ce
14 changed files with 958 additions and 133 deletions
+15
View File
@@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/sandbox.h"
#include "core/local_url_handlers.h"
#include "core/launcher.h"
#include "core/proxy_rotation_manager.h"
#include "core/ui_integration.h"
#include "chat_helpers/emoji_keywords.h"
#include "chat_helpers/stickers_emoji_image_loader.h"
@@ -146,6 +147,7 @@ struct Application::Private {
base::Timer quitTimer;
UiIntegration uiIntegration;
Settings settings;
std::unique_ptr<ProxyRotationManager> proxyRotation;
};
Application::Application()
@@ -173,6 +175,7 @@ Application::Application()
, _setupEmailLock(false)
, _autoLockTimer([=] { checkAutoLock(); }) {
Ui::Integration::Set(&_private->uiIntegration);
_private->proxyRotation = std::make_unique<ProxyRotationManager>();
_platformIntegration->init();
@@ -234,6 +237,7 @@ Application::~Application() {
// Domain::finish() and there is a violation on Ensures(started()).
closeAdditionalWindows();
_private->proxyRotation = nullptr;
_domain->finish();
Local::finish();
@@ -833,6 +837,17 @@ void Application::setCurrentProxy(
refreshGlobalProxy();
_proxyChanges.fire({ was, now });
my.connectionTypeChangesNotify();
proxyRotationSettingsChanged();
}
void Application::proxyRotationSettingsChanged() {
_private->proxyRotation->settingsChanged();
}
void Application::checkProxyRotation(
not_null<Main::Account*> account,
int32 state) {
_private->proxyRotation->handleConnectionStateChanged(account, state);
}
auto Application::proxyChanges() const -> rpl::producer<ProxyChange> {