Files
FlClash/plugins/proxy/windows/proxy_plugin.h
T
chen08209 94a25f4827 fix(desktop): fix the system proxy, tray and Helper on Windows and Linux
Changelog: Windows and Linux desktop fixes
2026-10-11 12:28:52 +08:00

50 lines
1.4 KiB
C++

#ifndef FLUTTER_PLUGIN_PROXY_PLUGIN_H_
#define FLUTTER_PLUGIN_PROXY_PLUGIN_H_
#include <windows.h>
#include <flutter/method_channel.h>
#include <flutter/plugin_registrar_windows.h>
#include <memory>
#include <optional>
namespace proxy {
// Turns off a system proxy that still points at FlClash's address while
// nothing listens on its port any more, the state a killed app leaves behind.
bool ClearStaleProxy();
class ProxyPlugin : public flutter::Plugin {
public:
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar);
ProxyPlugin() = default;
explicit ProxyPlugin(flutter::PluginRegistrarWindows* registrar);
~ProxyPlugin() override;
ProxyPlugin(const ProxyPlugin&) = delete;
ProxyPlugin& operator=(const ProxyPlugin&) = delete;
void HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue> &method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
static bool IsSessionEnding(UINT message, WPARAM wparam);
std::optional<LRESULT> HandleWindowProc(
HWND window, UINT message, WPARAM wparam, LPARAM lparam);
private:
flutter::PluginRegistrarWindows* registrar_ = nullptr;
int window_proc_id_ = -1;
// Whether this process is the one that pointed Windows at a proxy.
bool proxy_applied_ = false;
};
} // namespace proxy
#endif // FLUTTER_PLUGIN_PROXY_PLUGIN_H_