mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
- plugins: add configparam 'shellwindow'
This commit is contained in:
@@ -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);
|
||||
if (plugin_list[number].shellwindow)
|
||||
{
|
||||
CShellWindow(script, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE);
|
||||
scriptOutput = "";
|
||||
}
|
||||
else
|
||||
popenScriptPlugin(script);
|
||||
}
|
||||
|
||||
void CPlugins::startLuaPlugin(int number)
|
||||
|
@@ -81,6 +81,7 @@ class CPlugins
|
||||
int posx, posy, sizex, sizey;
|
||||
bool showpig;
|
||||
bool needoffset;
|
||||
bool shellwindow;
|
||||
bool hide;
|
||||
bool operator< (const plugin& a) const
|
||||
{
|
||||
@@ -129,6 +130,7 @@ class CPlugins
|
||||
void startPlugin(const char * const filename); // start plugins by filename
|
||||
void startPlugin_by_name(const std::string & name); // start plugins by "name=" in .cfg
|
||||
void startScriptPlugin(int number);
|
||||
void popenScriptPlugin(const char * script);
|
||||
void startLuaPlugin(int number);
|
||||
bool hasPlugin(CPlugins::p_type_t type);
|
||||
|
||||
|
Reference in New Issue
Block a user