add: added SystemProxyEvent

This commit is contained in:
Qv2ray-dev 2020-04-08 15:42:35 +08:00
parent 0bd4e4bd22
commit f439cc7f49
3 changed files with 15 additions and 29 deletions

View File

@ -63,11 +63,8 @@ namespace Qv2ray::components::plugins
info.errorMessage = tr("This plugin was built against an incompactable version of Qv2ray Plugin Interface.") + NEWLINE + info.errorMessage = tr("This plugin was built against an incompactable version of Qv2ray Plugin Interface.") + NEWLINE +
QObject::tr("Please contact the plugin provider or report the issue to Qv2ray Workgroup."); QObject::tr("Please contact the plugin provider or report the issue to Qv2ray Workgroup.");
} }
connect(plugin, SIGNAL(PluginLog(const QString &)), this, SLOT(QvPluginLog(const QString &)));
connect(dynamic_cast<QObject *>(info.pluginInterface), SIGNAL(PluginLog(const QString &)), this, connect(plugin, SIGNAL(PluginErrorMessageBox(const QString &)), this, SLOT(QvPluginMessageBox(const QString &)));
SLOT(QvPluginLog(const QString &)));
connect(dynamic_cast<QObject *>(info.pluginInterface), SIGNAL(PluginErrorMessageBox(const QString &)), this,
SLOT(QvPluginMessageBox(const QString &)));
LOG(MODULE_PLUGINHOST, "Loaded plugin: \"" + info.metadata.Name + "\" made by: \"" + info.metadata.Author + "\"") LOG(MODULE_PLUGINHOST, "Loaded plugin: \"" + info.metadata.Name + "\" made by: \"" + info.metadata.Author + "\"")
plugins.insert(info.metadata.InternalName, info); plugins.insert(info.metadata.InternalName, info);
} }

@ -1 +1 @@
Subproject commit 79632b01f48bbfff9404af740f10e543d77bb0a3 Subproject commit 95f4540ac3b8e32b6bc7251212d4aee2182f9740

View File

@ -1,6 +1,7 @@
#include "QvProxyConfigurator.hpp" #include "QvProxyConfigurator.hpp"
#include "common/QvHelpers.hpp" #include "common/QvHelpers.hpp"
#include "components/plugins/QvPluginHost.hpp"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <WinInet.h> #include <WinInet.h>
#include <Windows.h> #include <Windows.h>
@ -234,21 +235,6 @@ namespace Qv2ray::components::proxy
{ {
LOG(MODULE_PROXY, "KDE detected") LOG(MODULE_PROXY, "KDE detected")
} }
//
// if (usePAC)
// {
// actions << QString("gsettings set org.gnome.system.proxy autoconfig-url '%1'").arg(address);
// if (isKDE)
// {
// actions << QString("kwriteconfig5 --file " + QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) +
// "/kioslaverc --group \"Proxy Settings\" --key ProxyType 2");
// actions << QString("kwriteconfig5 --file " + QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) +
// "/kioslaverc --group \"Proxy Settings\" --key \"Proxy Config Script\" " + address);
// }
// }
// else
// {
if (isKDE) if (isKDE)
{ {
actions << QString("kwriteconfig5 --file " + QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + actions << QString("kwriteconfig5 --file " + QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) +
@ -309,13 +295,6 @@ namespace Qv2ray::components::proxy
{ {
LOG(MODULE_PROXY, "Setting proxy for interface: " + service) LOG(MODULE_PROXY, "Setting proxy for interface: " + service)
// if (usePAC)
// {
// QProcess::execute("/usr/sbin/networksetup -setautoproxystate " + service + " on");
// QProcess::execute("/usr/sbin/networksetup -setautoproxyurl " + service + " " + address);
// }
// else
// {
if (hasHTTP) if (hasHTTP)
{ {
QProcess::execute("/usr/sbin/networksetup -setwebproxystate " + service + " on"); QProcess::execute("/usr/sbin/networksetup -setwebproxystate " + service + " on");
@ -329,10 +308,17 @@ namespace Qv2ray::components::proxy
QProcess::execute("/usr/sbin/networksetup -setsocksfirewallproxystate " + service + " on"); QProcess::execute("/usr/sbin/networksetup -setsocksfirewallproxystate " + service + " on");
QProcess::execute("/usr/sbin/networksetup -setsocksfirewallproxy " + service + " " + address + " " + QSTRN(socksPort)); QProcess::execute("/usr/sbin/networksetup -setsocksfirewallproxy " + service + " " + address + " " + QSTRN(socksPort));
} }
// }
} }
#endif #endif
//
// Trigger plugin events
QMap<QvSystemProxyType, int> portSettings;
if (hasHTTP)
portSettings.insert(QvSystemProxyType::SystemProxy_HTTP, httpPort);
if (hasSOCKS)
portSettings.insert(QvSystemProxyType::SystemProxy_SOCKS, socksPort);
PluginHost->Send_SystemProxyEvent(QvSystemProxyEventObject{ portSettings, QvSystemProxyStateType::SystemProxyState_SetProxy });
} }
void ClearSystemProxy() void ClearSystemProxy()
@ -386,5 +372,8 @@ namespace Qv2ray::components::proxy
} }
#endif #endif
//
// Trigger plugin events
PluginHost->Send_SystemProxyEvent(QvSystemProxyEventObject{ {}, QvSystemProxyStateType::SystemProxyState_ClearProxy });
} }
} // namespace Qv2ray::components::proxy } // namespace Qv2ray::components::proxy