mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
- plugins: formatting code using astyle
Conflicts: src/gui/plugins.h Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -56,15 +56,15 @@
|
||||
#include <vector>
|
||||
|
||||
#include <hardware/video.h>
|
||||
extern cVideo * videoDecoder;
|
||||
extern cVideo *videoDecoder;
|
||||
|
||||
#include "plugins.h"
|
||||
|
||||
#include <daemonc/remotecontrol.h>
|
||||
#include <gui/lua/luainstance.h>
|
||||
|
||||
extern CPlugins * g_Plugins; /* neutrino.cpp */
|
||||
extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */
|
||||
extern CPlugins *g_Plugins;
|
||||
extern CRemoteControl *g_RemoteControl;
|
||||
|
||||
CPlugins::CPlugins()
|
||||
{
|
||||
@@ -72,16 +72,16 @@ CPlugins::CPlugins()
|
||||
number_of_plugins = 0;
|
||||
}
|
||||
|
||||
bool CPlugins::plugin_exists(const std::string & filename)
|
||||
bool CPlugins::plugin_exists(const std::string &filename)
|
||||
{
|
||||
return (find_plugin(filename) >= 0);
|
||||
}
|
||||
|
||||
int CPlugins::find_plugin(const std::string & filename)
|
||||
int CPlugins::find_plugin(const std::string &filename)
|
||||
{
|
||||
for (int i = 0; i < (int) plugin_list.size(); i++)
|
||||
for (int i = 0; i < (int) plugin_list.size(); i++)
|
||||
{
|
||||
if ( (filename.compare(plugin_list[i].filename) == 0) || (filename.compare(plugin_list[i].filename + ".cfg") == 0) )
|
||||
if ((filename.compare(plugin_list[i].filename) == 0) || (filename.compare(plugin_list[i].filename + ".cfg") == 0))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
@@ -152,7 +152,7 @@ void CPlugins::loadPlugins()
|
||||
scanDir(PLUGINDIR_VAR);
|
||||
scanDir(PLUGINDIR);
|
||||
|
||||
sort (plugin_list.begin(), plugin_list.end());
|
||||
sort(plugin_list.begin(), plugin_list.end());
|
||||
}
|
||||
|
||||
CPlugins::~CPlugins()
|
||||
@@ -162,12 +162,14 @@ CPlugins::~CPlugins()
|
||||
|
||||
bool CPlugins::overrideType(plugin *plugin_data, std::string &setting, p_type type)
|
||||
{
|
||||
if (!setting.empty()) {
|
||||
if (!setting.empty())
|
||||
{
|
||||
char s[setting.length() + 1];
|
||||
cstrncpy(s, setting, setting.length() + 1);
|
||||
char *t, *p = s;
|
||||
while ((t = strsep(&p, ",")))
|
||||
if (!strcmp(t, plugin_data->filename.c_str())) {
|
||||
if (!strcmp(t, plugin_data->filename.c_str()))
|
||||
{
|
||||
plugin_data->type = type;
|
||||
return true;
|
||||
}
|
||||
@@ -301,9 +303,9 @@ bool CPlugins::parseCfg(plugin *plugin_data)
|
||||
return !reject;
|
||||
}
|
||||
|
||||
int 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)
|
||||
{
|
||||
@@ -313,7 +315,7 @@ int CPlugins::startPlugin_by_name(const std::string & name)
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
int CPlugins::startPlugin(const char * const filename)
|
||||
int CPlugins::startPlugin(const char *const filename)
|
||||
{
|
||||
int pluginnr = find_plugin(filename);
|
||||
if (pluginnr > -1)
|
||||
@@ -323,25 +325,25 @@ int CPlugins::startPlugin(const char * const filename)
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
int CPlugins::popenScriptPlugin(int number, const char * script)
|
||||
int CPlugins::popenScriptPlugin(int number, const char *script)
|
||||
{
|
||||
pid_t pid = 0;
|
||||
FILE *f = my_popen(pid, script, "r");
|
||||
if (f != NULL)
|
||||
{
|
||||
char *output=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);
|
||||
while (waitpid(pid, &s, WNOHANG) > 0);
|
||||
kill(pid, SIGTERM);
|
||||
if (output)
|
||||
free(output);
|
||||
}
|
||||
else
|
||||
printf("[CPlugins] can't execute %s\n",script);
|
||||
printf("[CPlugins] can't execute %s\n", script);
|
||||
|
||||
return plugin_list[number].menu_return;
|
||||
}
|
||||
@@ -349,11 +351,11 @@ int CPlugins::popenScriptPlugin(int number, const char * script)
|
||||
int CPlugins::startScriptPlugin(int number)
|
||||
{
|
||||
const char *script = plugin_list[number].pluginfile.c_str();
|
||||
printf("[CPlugins] executing script %s\n",script);
|
||||
printf("[CPlugins] executing script %s\n", script);
|
||||
if (!file_exists(script))
|
||||
{
|
||||
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 menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
@@ -363,7 +365,7 @@ int CPlugins::startScriptPlugin(int number)
|
||||
if (plugin_list[number].shellwindow)
|
||||
{
|
||||
int res = 0;
|
||||
CShellWindow (script, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE, &res);
|
||||
CShellWindow(script, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE, &res);
|
||||
scriptOutput = "";
|
||||
}
|
||||
else
|
||||
@@ -375,11 +377,11 @@ int CPlugins::startScriptPlugin(int number)
|
||||
int CPlugins::startLuaPlugin(int number)
|
||||
{
|
||||
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);
|
||||
if (!file_exists(script))
|
||||
{
|
||||
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 menu_return::RETURN_REPAINT;
|
||||
}
|
||||
#ifdef ENABLE_LUA
|
||||
@@ -428,7 +430,7 @@ int CPlugins::startPlugin(int number)
|
||||
#endif
|
||||
setenv("SCREEN_END_Y", tmp, 1);
|
||||
|
||||
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);
|
||||
if (ispip && !g_RemoteControl->is_video_started)
|
||||
return menu_return::RETURN_REPAINT;
|
||||
@@ -444,7 +446,7 @@ int CPlugins::startPlugin(int number)
|
||||
if (!file_exists(plugin_list[number].pluginfile.c_str()))
|
||||
{
|
||||
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 menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
@@ -475,8 +477,7 @@ int CPlugins::startPlugin(int number)
|
||||
|
||||
bool CPlugins::hasPlugin(CPlugins::p_type_t type)
|
||||
{
|
||||
for (std::vector<plugin>::iterator it=plugin_list.begin();
|
||||
it!=plugin_list.end(); ++it)
|
||||
for (std::vector<plugin>::iterator it = plugin_list.begin(); it != plugin_list.end(); ++it)
|
||||
{
|
||||
if ((it->type & type) && !it->hide)
|
||||
return true;
|
||||
@@ -484,7 +485,7 @@ bool CPlugins::hasPlugin(CPlugins::p_type_t type)
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string& CPlugins::getScriptOutput() const
|
||||
const std::string &CPlugins::getScriptOutput() const
|
||||
{
|
||||
return scriptOutput;
|
||||
}
|
||||
@@ -498,22 +499,22 @@ CPlugins::p_type_t CPlugins::getPluginType(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case PLUGIN_TYPE_DISABLED:
|
||||
return P_TYPE_DISABLED;
|
||||
break;
|
||||
case PLUGIN_TYPE_GAME:
|
||||
return P_TYPE_GAME;
|
||||
break;
|
||||
case PLUGIN_TYPE_TOOL:
|
||||
return P_TYPE_TOOL;
|
||||
break;
|
||||
case PLUGIN_TYPE_SCRIPT:
|
||||
return P_TYPE_SCRIPT;
|
||||
break;
|
||||
case PLUGIN_TYPE_LUA:
|
||||
return P_TYPE_LUA;
|
||||
default:
|
||||
return P_TYPE_DISABLED;
|
||||
case PLUGIN_TYPE_DISABLED:
|
||||
return P_TYPE_DISABLED;
|
||||
break;
|
||||
case PLUGIN_TYPE_GAME:
|
||||
return P_TYPE_GAME;
|
||||
break;
|
||||
case PLUGIN_TYPE_TOOL:
|
||||
return P_TYPE_TOOL;
|
||||
break;
|
||||
case PLUGIN_TYPE_SCRIPT:
|
||||
return P_TYPE_SCRIPT;
|
||||
break;
|
||||
case PLUGIN_TYPE_LUA:
|
||||
return P_TYPE_LUA;
|
||||
default:
|
||||
return P_TYPE_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,17 +36,17 @@ class CPlugins
|
||||
public:
|
||||
typedef enum p_type
|
||||
{
|
||||
P_TYPE_DISABLED = 0x1,
|
||||
P_TYPE_GAME = 0x2,
|
||||
P_TYPE_TOOL = 0x4,
|
||||
P_TYPE_SCRIPT = 0x8,
|
||||
P_TYPE_LUA = 0x10,
|
||||
P_TYPE_NO_GAME = P_TYPE_TOOL|P_TYPE_SCRIPT|P_TYPE_LUA
|
||||
P_TYPE_DISABLED = 0x1,
|
||||
P_TYPE_GAME = 0x2,
|
||||
P_TYPE_TOOL = 0x4,
|
||||
P_TYPE_SCRIPT = 0x8,
|
||||
P_TYPE_LUA = 0x10,
|
||||
P_TYPE_NO_GAME = P_TYPE_TOOL | P_TYPE_SCRIPT | P_TYPE_LUA
|
||||
}
|
||||
p_type_t;
|
||||
|
||||
private:
|
||||
CFrameBuffer *frameBuffer;
|
||||
CFrameBuffer *frameBuffer;
|
||||
|
||||
struct plugin
|
||||
{
|
||||
@@ -58,15 +58,15 @@ class CPlugins
|
||||
std::string plugindir;
|
||||
std::string hinticon;
|
||||
int version;
|
||||
std::string name; // UTF-8 encoded
|
||||
std::string description; // UTF-8 encoded
|
||||
std::string name; // UTF-8 encoded
|
||||
std::string description; // UTF-8 encoded
|
||||
std::string depend;
|
||||
CPlugins::p_type_t type;
|
||||
int integration;
|
||||
bool shellwindow;
|
||||
bool hide;
|
||||
int menu_return;
|
||||
bool operator< (const plugin& a) const
|
||||
bool operator< (const plugin &a) const
|
||||
{
|
||||
return this->index < a.index ;
|
||||
}
|
||||
@@ -80,10 +80,10 @@ class CPlugins
|
||||
|
||||
bool parseCfg(plugin *plugin_data);
|
||||
void scanDir(const char *dir);
|
||||
bool plugin_exists(const std::string & filename);
|
||||
int find_plugin(const std::string & filename);
|
||||
bool plugin_exists(const std::string &filename);
|
||||
int find_plugin(const std::string &filename);
|
||||
CPlugins::p_type_t getPluginType(int type);
|
||||
neutrino_msg_t getPluginKey(std::string key="auto");
|
||||
neutrino_msg_t getPluginKey(std::string key = "auto");
|
||||
|
||||
public:
|
||||
CPlugins();
|
||||
@@ -91,34 +91,35 @@ class CPlugins
|
||||
|
||||
void loadPlugins();
|
||||
|
||||
void setPluginDir(const std::string & dir) { plugin_dir = dir; }
|
||||
void setPluginDir(const std::string &dir) { plugin_dir = dir; }
|
||||
|
||||
inline int getNumberOfPlugins (void ) const { return (int)plugin_list.size() ; }
|
||||
inline const char * getName (const int number) const { return plugin_list[number].name.c_str() ; }
|
||||
inline const char * getPluginFile (const int number) const { return plugin_list[number].pluginfile.c_str(); }
|
||||
inline const char * getPluginDir (const int number) const { return plugin_list[number].plugindir.c_str() ; }
|
||||
inline const char * getHintIcon (const int number) const { return plugin_list[number].hinticon.c_str() ; }
|
||||
inline const char * getFileName (const int number) const { return plugin_list[number].filename.c_str() ; }
|
||||
inline const std::string & getDescription (const int number) const { return plugin_list[number].description ; }
|
||||
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 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 neutrino_msg_t getKey (const int number) const { return plugin_list[number].key ; }
|
||||
inline int getNumberOfPlugins(void) const { return (int)plugin_list.size() ; }
|
||||
inline const char *getName (const int number) const { return plugin_list[number].name.c_str() ; }
|
||||
inline const char *getPluginFile (const int number) const { return plugin_list[number].pluginfile.c_str(); }
|
||||
inline const char *getCfgFile (const int number) const { return plugin_list[number].cfgfile.c_str() ; }
|
||||
inline const char *getPluginDir (const int number) const { return plugin_list[number].plugindir.c_str() ; }
|
||||
inline const char *getHintIcon (const int number) const { return plugin_list[number].hinticon.c_str() ; }
|
||||
inline const char *getFileName (const int number) const { return plugin_list[number].filename.c_str() ; }
|
||||
inline const std::string &getDescription (const int number) const { return plugin_list[number].description ; }
|
||||
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 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 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);
|
||||
|
||||
int startPlugin(int number); // start plugins by number
|
||||
int startPlugin(const char * const filename); // start plugins by filename
|
||||
int startPlugin_by_name(const std::string & name); // start plugins by "name=" in .cfg
|
||||
int startPlugin(const char *const filename); // start plugins by filename
|
||||
int startPlugin_by_name(const std::string &name); // start plugins by "name=" in .cfg
|
||||
int startScriptPlugin(int number);
|
||||
int popenScriptPlugin(int number, const char * script);
|
||||
int popenScriptPlugin(int number, const char *script);
|
||||
int startLuaPlugin(int number);
|
||||
bool hasPlugin(CPlugins::p_type_t type);
|
||||
|
||||
const std::string& getScriptOutput() const;
|
||||
const std::string &getScriptOutput() const;
|
||||
void delScriptOutput();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user