plugins: add configparam 'shellwindow'

Origin commit data
------------------
Branch: ni/coolstream
Commit: b46ad0c5ae
Author: vanhofen <vanhofen@gmx.de>
Date: 2014-09-17 (Wed, 17 Sep 2014)

Origin message was:
------------------
- plugins: add configparam 'shellwindow'

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2014-09-17 18:04:54 +02:00
parent e0e5c5de42
commit ceb3ca7c6f
2 changed files with 35 additions and 2 deletions

View File

@@ -205,6 +205,7 @@ bool CPlugins::parseCfg(plugin *plugin_data)
plugin_data->vtxtpid = false;
plugin_data->showpig = false;
plugin_data->needoffset = false;
plugin_data->shellwindow = false;
plugin_data->hide = false;
plugin_data->type = CPlugins::P_TYPE_DISABLED;
@@ -265,6 +266,10 @@ bool CPlugins::parseCfg(plugin *plugin_data)
{
plugin_data->needoffset = atoi(parm);
}
else if (cmd == "shellwindow")
{
plugin_data->shellwindow = atoi(parm);
}
else if (cmd == "hide")
{
plugin_data->hide = atoi(parm);
@@ -331,6 +336,27 @@ void CPlugins::startPlugin(const char * const name)
}
void CPlugins::popenScriptPlugin(const char * script)
{
pid_t pid = 0;
FILE *f = my_popen(pid, script, "r");
if (f != NULL)
{
char *output=NULL;
size_t len = 0;
while ((getline(&output, &len, f)) != -1)
scriptOutput += output;
pclose(f);
int s;
while (waitpid(pid, &s, WNOHANG)>0);
kill(pid, SIGTERM);
if (output)
free(output);
}
else
printf("[CPlugins] can't execute %s\n",script);
}
void CPlugins::startScriptPlugin(int number)
{
const char *script = plugin_list[number].pluginfile.c_str();
@@ -345,8 +371,13 @@ void CPlugins::startScriptPlugin(int number)
// workaround for manually messed up permissions
if (access(script, X_OK))
chmod(script, 0755);
CShellWindow(script, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE);
scriptOutput = "";
if (plugin_list[number].shellwindow)
{
CShellWindow(script, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE);
scriptOutput = "";
}
else
popenScriptPlugin(script);
}
void CPlugins::startLuaPlugin(int number)