mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 07:22:57 +02:00
plugins: allow to control menu_return value
Origin commit data
------------------
Commit: 8b38584ac1
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-02-28 (Sun, 28 Feb 2021)
Origin message was:
------------------
- plugins: allow to control menu_return value
This commit is contained in:
@@ -62,12 +62,12 @@ CPluginList::CPluginList(const neutrino_locale_t Title, const uint32_t listtype)
|
|||||||
|
|
||||||
int CPluginList::run()
|
int CPluginList::run()
|
||||||
{
|
{
|
||||||
g_Plugins->startPlugin(number);
|
int ret = g_Plugins->startPlugin(number);
|
||||||
if (!g_Plugins->getScriptOutput().empty()) {
|
if (!g_Plugins->getScriptOutput().empty()) {
|
||||||
hide();
|
hide();
|
||||||
ShowMsg(LOCALE_PLUGINS_RESULT, g_Plugins->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL, 320, g_settings.timing[SNeutrinoSettings::TIMING_STATIC_MESSAGES]);
|
ShowMsg(LOCALE_PLUGINS_RESULT, g_Plugins->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL, 320, g_settings.timing[SNeutrinoSettings::TIMING_STATIC_MESSAGES]);
|
||||||
}
|
}
|
||||||
return menu_return::RETURN_REPAINT;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CPluginList::exec(CMenuTarget* parent, const std::string &actionKey)
|
int CPluginList::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||||
@@ -138,6 +138,8 @@ CPluginsExec* CPluginsExec::getInstance()
|
|||||||
|
|
||||||
int CPluginsExec::exec(CMenuTarget* parent, const std::string & actionKey)
|
int CPluginsExec::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||||
{
|
{
|
||||||
|
int ret = menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
if (actionKey.empty())
|
if (actionKey.empty())
|
||||||
return menu_return::RETURN_NONE;
|
return menu_return::RETURN_NONE;
|
||||||
|
|
||||||
@@ -153,7 +155,7 @@ int CPluginsExec::exec(CMenuTarget* parent, const std::string & actionKey)
|
|||||||
return menu_return::RETURN_EXIT;
|
return menu_return::RETURN_EXIT;
|
||||||
}
|
}
|
||||||
else if (sel >= 0)
|
else if (sel >= 0)
|
||||||
g_Plugins->startPlugin(sel);
|
ret = g_Plugins->startPlugin(sel);
|
||||||
|
|
||||||
if (!g_Plugins->getScriptOutput().empty())
|
if (!g_Plugins->getScriptOutput().empty())
|
||||||
ShowMsg(LOCALE_PLUGINS_RESULT, g_Plugins->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL);
|
ShowMsg(LOCALE_PLUGINS_RESULT, g_Plugins->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL);
|
||||||
@@ -161,5 +163,5 @@ int CPluginsExec::exec(CMenuTarget* parent, const std::string & actionKey)
|
|||||||
if (g_Plugins->getIntegration(sel) == PLUGIN_INTEGRATION_DISABLED)
|
if (g_Plugins->getIntegration(sel) == PLUGIN_INTEGRATION_DISABLED)
|
||||||
return menu_return::RETURN_EXIT;
|
return menu_return::RETURN_EXIT;
|
||||||
|
|
||||||
return menu_return::RETURN_REPAINT;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -193,6 +193,7 @@ bool CPlugins::parseCfg(plugin *plugin_data)
|
|||||||
plugin_data->description = "";
|
plugin_data->description = "";
|
||||||
plugin_data->shellwindow = false;
|
plugin_data->shellwindow = false;
|
||||||
plugin_data->hide = false;
|
plugin_data->hide = false;
|
||||||
|
plugin_data->menu_return = menu_return::RETURN_REPAINT;
|
||||||
plugin_data->type = CPlugins::P_TYPE_DISABLED;
|
plugin_data->type = CPlugins::P_TYPE_DISABLED;
|
||||||
plugin_data->integration = PLUGIN_INTEGRATION_DISABLED;
|
plugin_data->integration = PLUGIN_INTEGRATION_DISABLED;
|
||||||
plugin_data->hinticon = NEUTRINO_ICON_HINT_PLUGIN;
|
plugin_data->hinticon = NEUTRINO_ICON_HINT_PLUGIN;
|
||||||
@@ -260,6 +261,17 @@ bool CPlugins::parseCfg(plugin *plugin_data)
|
|||||||
{
|
{
|
||||||
plugin_data->hide = atoi(parm);
|
plugin_data->hide = atoi(parm);
|
||||||
}
|
}
|
||||||
|
else if (cmd == "menu_return")
|
||||||
|
{
|
||||||
|
if (parm == "none")
|
||||||
|
plugin_data->menu_return = menu_return::RETURN_NONE;
|
||||||
|
else if (parm == "exit")
|
||||||
|
plugin_data->menu_return = menu_return::RETURN_EXIT;
|
||||||
|
else if (parm == "exit_all")
|
||||||
|
plugin_data->menu_return = menu_return::RETURN_EXIT_ALL;
|
||||||
|
else // (parm == "repaint")
|
||||||
|
plugin_data->menu_return = menu_return::RETURN_REPAINT;
|
||||||
|
}
|
||||||
else if (cmd == "needenigma")
|
else if (cmd == "needenigma")
|
||||||
{
|
{
|
||||||
reject = atoi(parm);
|
reject = atoi(parm);
|
||||||
@@ -284,28 +296,29 @@ bool CPlugins::parseCfg(plugin *plugin_data)
|
|||||||
return !reject;
|
return !reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlugins::startPlugin_by_name(const std::string & name)
|
int CPlugins::startPlugin_by_name(const std::string & name)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < (int) plugin_list.size(); i++)
|
for (int i = 0; i < (int) plugin_list.size(); i++)
|
||||||
{
|
{
|
||||||
if (name.compare(g_Plugins->getName(i)) == 0)
|
if (name.compare(g_Plugins->getName(i)) == 0)
|
||||||
{
|
{
|
||||||
startPlugin(i);
|
return startPlugin(i);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlugins::startPlugin(const char * const filename)
|
int CPlugins::startPlugin(const char * const filename)
|
||||||
{
|
{
|
||||||
int pluginnr = find_plugin(filename);
|
int pluginnr = find_plugin(filename);
|
||||||
if (pluginnr > -1)
|
if (pluginnr > -1)
|
||||||
startPlugin(pluginnr);
|
return startPlugin(pluginnr);
|
||||||
else
|
else
|
||||||
printf("[CPlugins] could not find %s\n", filename);
|
printf("[CPlugins] could not find %s\n", filename);
|
||||||
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlugins::popenScriptPlugin(const char * script)
|
int CPlugins::popenScriptPlugin(int number, const char * script)
|
||||||
{
|
{
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
FILE *f = my_popen(pid, script, "r");
|
FILE *f = my_popen(pid, script, "r");
|
||||||
@@ -324,9 +337,11 @@ void CPlugins::popenScriptPlugin(const char * script)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("[CPlugins] can't execute %s\n",script);
|
printf("[CPlugins] can't execute %s\n",script);
|
||||||
|
|
||||||
|
return plugin_list[number].menu_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlugins::startScriptPlugin(int number)
|
int CPlugins::startScriptPlugin(int number)
|
||||||
{
|
{
|
||||||
const char *script = plugin_list[number].pluginfile.c_str();
|
const char *script = plugin_list[number].pluginfile.c_str();
|
||||||
printf("[CPlugins] executing script %s\n",script);
|
printf("[CPlugins] executing script %s\n",script);
|
||||||
@@ -334,7 +349,7 @@ void CPlugins::startScriptPlugin(int number)
|
|||||||
{
|
{
|
||||||
printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n",
|
printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n",
|
||||||
script, plugin_list[number].cfgfile.c_str());
|
script, plugin_list[number].cfgfile.c_str());
|
||||||
return;
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround for manually messed up permissions
|
// workaround for manually messed up permissions
|
||||||
@@ -347,10 +362,12 @@ void CPlugins::startScriptPlugin(int number)
|
|||||||
scriptOutput = "";
|
scriptOutput = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
popenScriptPlugin(script);
|
return popenScriptPlugin(number, script);
|
||||||
|
|
||||||
|
return plugin_list[number].menu_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlugins::startLuaPlugin(int number)
|
int CPlugins::startLuaPlugin(int number)
|
||||||
{
|
{
|
||||||
const char *script = plugin_list[number].pluginfile.c_str();
|
const char *script = plugin_list[number].pluginfile.c_str();
|
||||||
printf("[CPlugins] executing lua script %s\n",script);
|
printf("[CPlugins] executing lua script %s\n",script);
|
||||||
@@ -358,10 +375,11 @@ void CPlugins::startLuaPlugin(int number)
|
|||||||
{
|
{
|
||||||
printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n",
|
printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n",
|
||||||
script, plugin_list[number].cfgfile.c_str());
|
script, plugin_list[number].cfgfile.c_str());
|
||||||
return;
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_LUA
|
#ifdef ENABLE_LUA
|
||||||
CLuaInstance *lua = new CLuaInstance();
|
CLuaInstance *lua = new CLuaInstance();
|
||||||
|
// FIXME: runScript() should return the exit-code from script
|
||||||
lua->runScript(script);
|
lua->runScript(script);
|
||||||
delete lua;
|
delete lua;
|
||||||
#endif
|
#endif
|
||||||
@@ -370,9 +388,11 @@ void CPlugins::startLuaPlugin(int number)
|
|||||||
#endif
|
#endif
|
||||||
videoDecoder->Pig(-1, -1, -1, -1);
|
videoDecoder->Pig(-1, -1, -1, -1);
|
||||||
frameBuffer->paintBackground();
|
frameBuffer->paintBackground();
|
||||||
|
|
||||||
|
return plugin_list[number].menu_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlugins::startPlugin(int number)
|
int CPlugins::startPlugin(int number)
|
||||||
{
|
{
|
||||||
// always delete old output
|
// always delete old output
|
||||||
delScriptOutput();
|
delScriptOutput();
|
||||||
@@ -390,22 +410,21 @@ void CPlugins::startPlugin(int number)
|
|||||||
bool ispip = strstr(plugin_list[number].pluginfile.c_str(), "pip") != 0;
|
bool ispip = strstr(plugin_list[number].pluginfile.c_str(), "pip") != 0;
|
||||||
//printf("exec: %s pip: %d\n", plugin_list[number].pluginfile.c_str(), ispip);
|
//printf("exec: %s pip: %d\n", plugin_list[number].pluginfile.c_str(), ispip);
|
||||||
if (ispip && !g_RemoteControl->is_video_started)
|
if (ispip && !g_RemoteControl->is_video_started)
|
||||||
return;
|
return menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
if (plugin_list[number].type == CPlugins::P_TYPE_SCRIPT)
|
if (plugin_list[number].type == CPlugins::P_TYPE_SCRIPT)
|
||||||
{
|
{
|
||||||
startScriptPlugin(number);
|
return startScriptPlugin(number);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (plugin_list[number].type == CPlugins::P_TYPE_LUA)
|
if (plugin_list[number].type == CPlugins::P_TYPE_LUA)
|
||||||
{
|
{
|
||||||
startLuaPlugin(number);
|
return startLuaPlugin(number);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!file_exists(plugin_list[number].pluginfile.c_str()))
|
if (!file_exists(plugin_list[number].pluginfile.c_str()))
|
||||||
{
|
{
|
||||||
printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n",
|
printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n",
|
||||||
plugin_list[number].pluginfile.c_str(), plugin_list[number].cfgfile.c_str());
|
plugin_list[number].pluginfile.c_str(), plugin_list[number].cfgfile.c_str());
|
||||||
return;
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_RCInput->clearRCMsg();
|
g_RCInput->clearRCMsg();
|
||||||
@@ -429,6 +448,8 @@ void CPlugins::startPlugin(int number)
|
|||||||
frameBuffer->paintBackground();
|
frameBuffer->paintBackground();
|
||||||
g_RCInput->restartInput();
|
g_RCInput->restartInput();
|
||||||
g_RCInput->clearRCMsg();
|
g_RCInput->clearRCMsg();
|
||||||
|
|
||||||
|
return plugin_list[number].menu_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPlugins::hasPlugin(CPlugins::p_type_t type)
|
bool CPlugins::hasPlugin(CPlugins::p_type_t type)
|
||||||
|
@@ -65,6 +65,7 @@ class CPlugins
|
|||||||
int integration;
|
int integration;
|
||||||
bool shellwindow;
|
bool shellwindow;
|
||||||
bool hide;
|
bool hide;
|
||||||
|
int menu_return;
|
||||||
bool operator< (const plugin& a) const
|
bool operator< (const plugin& a) const
|
||||||
{
|
{
|
||||||
return this->index < a.index ;
|
return this->index < a.index ;
|
||||||
@@ -103,18 +104,19 @@ class CPlugins
|
|||||||
inline int getType (const int number) const { return plugin_list[number].type ; }
|
inline int getType (const int number) const { return plugin_list[number].type ; }
|
||||||
inline int getIntegration (const int number) const { return plugin_list[number].integration ; }
|
inline int getIntegration (const int number) const { return plugin_list[number].integration ; }
|
||||||
inline bool isHidden (const int number) const { return plugin_list[number].hide ; }
|
inline bool isHidden (const int number) const { return plugin_list[number].hide ; }
|
||||||
|
inline int getMenuReturn (const int number) const { return plugin_list[number].menu_return ; }
|
||||||
inline int getIndex (const int number) const { return plugin_list[number].index ; }
|
inline int getIndex (const int number) const { return plugin_list[number].index ; }
|
||||||
inline neutrino_msg_t getKey (const int number) const { return plugin_list[number].key ; }
|
inline neutrino_msg_t getKey (const int number) const { return plugin_list[number].key ; }
|
||||||
|
|
||||||
void setType (const int number, int t) { plugin_list[number].type = (CPlugins::p_type_t) t ; }
|
void setType (const int number, int t) { plugin_list[number].type = (CPlugins::p_type_t) t ; }
|
||||||
bool overrideType(plugin *plugin_data, std::string &setting, p_type type);
|
bool overrideType(plugin *plugin_data, std::string &setting, p_type type);
|
||||||
|
|
||||||
void startPlugin(int number); // start plugins by number
|
int startPlugin(int number); // start plugins by number
|
||||||
void startPlugin(const char * const filename); // start plugins by filename
|
int startPlugin(const char * const filename); // start plugins by filename
|
||||||
void startPlugin_by_name(const std::string & name); // start plugins by "name=" in .cfg
|
int startPlugin_by_name(const std::string & name); // start plugins by "name=" in .cfg
|
||||||
void startScriptPlugin(int number);
|
int startScriptPlugin(int number);
|
||||||
void popenScriptPlugin(const char * script);
|
int popenScriptPlugin(int number, const char * script);
|
||||||
void startLuaPlugin(int number);
|
int startLuaPlugin(int number);
|
||||||
bool hasPlugin(CPlugins::p_type_t type);
|
bool hasPlugin(CPlugins::p_type_t type);
|
||||||
|
|
||||||
const std::string& getScriptOutput() const;
|
const std::string& getScriptOutput() const;
|
||||||
|
Reference in New Issue
Block a user