Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
add: added start detached option
Browse files Browse the repository at this point in the history
  • Loading branch information
Qv2ray-dev authored and Qv2ray-dev committed Apr 23, 2020
1 parent f2e02d4 commit 85f864d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
45 changes: 36 additions & 9 deletions core/EventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,19 @@ QvPlugin_EventHandler(SimpleEventHandler, Connectivity)
{
_command.replace("$$INBOUND_" + protocol, QString::number(pluginEvent.inboundPorts[protocol]));
}
auto returnvalue = QProcess::execute(_command);
if (returnvalue != 0)
bool detached = _command.contains("$$CALL");
_command.replace("$$CALL", "");
if (detached)
{
CommandPlugin::instance->PluginLog("Failed to execute command : \"" + action + "\"");
auto returnvalue = QProcess::execute(_command);
if (returnvalue != 0)
{
CommandPlugin::instance->PluginLog("Failed to execute command : \"" + action + "\"");
}
}
else
{
QProcess::startDetached(_command);
}
}
}
Expand Down Expand Up @@ -83,10 +92,19 @@ QvPlugin_EventHandler(SimpleEventHandler, SystemProxy)
auto _command = action;
_command.replace("$$HTTP", QString::number(pluginEvent.systemProxyPortSettings[Events::SystemProxy::SystemProxy_HTTP]));
_command.replace("$$SOCKS", QString::number(pluginEvent.systemProxyPortSettings[Events::SystemProxy::SystemProxy_SOCKS]));
auto returnvalue = QProcess::execute(_command);
if (returnvalue != 0)
bool detached = _command.contains("$$CALL");
_command.replace("$$CALL", "");
if (detached)
{
auto returnvalue = QProcess::execute(_command);
if (returnvalue != 0)
{
CommandPlugin::instance->PluginLog("Failed to execute command : \"" + action + "\"");
}
}
else
{
CommandPlugin::instance->PluginLog("Failed to execute command : \"" + action + "\"");
QProcess::startDetached(_command);
}
}
}
Expand Down Expand Up @@ -127,10 +145,19 @@ QvPlugin_EventHandler(SimpleEventHandler, ConnectionEntry)
auto _command = action;
_command.replace("$$DISPLAYNAME", pluginEvent.displayName);
_command.replace("$$ORIGINAL_NAME", pluginEvent.originalDisplayName);
auto returnvalue = QProcess::execute(_command);
if (returnvalue != 0)
bool detached = _command.contains("$$CALL");
_command.replace("$$CALL", "");
if (detached)
{
auto returnvalue = QProcess::execute(_command);
if (returnvalue != 0)
{
CommandPlugin::instance->PluginLog("Failed to execute command : \"" + action + "\"");
}
}
else
{
CommandPlugin::instance->PluginLog("Failed to execute command : \"" + action + "\"");
QProcess::startDetached(_command);
}
}
}
9 changes: 8 additions & 1 deletion ui/CommandPluginSettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
Expand Down Expand Up @@ -201,6 +201,13 @@ $$SOCKS: SOCKS port (could be 0)</string>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Commands start with &quot;$$CALL&quot; will make program start detached.</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down

0 comments on commit 85f864d

Please sign in to comment.