#ifndef FLUTTER_PLUGIN_PROXY_PLUGIN_H_ #define FLUTTER_PLUGIN_PROXY_PLUGIN_H_ #include #include #include #include #include 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 &method_call, std::unique_ptr> result); static bool IsSessionEnding(UINT message, WPARAM wparam); std::optional 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_