mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 07:22:57 +02:00
plugins: formatting code using astyle
Origin commit data
------------------
Branch: ni/coolstream
Commit: 33107ebbc4
Author: vanhofen <vanhofen@gmx.de>
Date: 2022-03-27 (Sun, 27 Mar 2022)
Origin message was:
------------------
- plugins: formatting code using astyle
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -56,15 +56,15 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <hardware/video.h>
|
#include <hardware/video.h>
|
||||||
extern cVideo * videoDecoder;
|
extern cVideo *videoDecoder;
|
||||||
|
|
||||||
#include "plugins.h"
|
#include "plugins.h"
|
||||||
|
|
||||||
#include <daemonc/remotecontrol.h>
|
#include <daemonc/remotecontrol.h>
|
||||||
#include <gui/lua/luainstance.h>
|
#include <gui/lua/luainstance.h>
|
||||||
|
|
||||||
extern CPlugins * g_Plugins; /* neutrino.cpp */
|
extern CPlugins *g_Plugins;
|
||||||
extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */
|
extern CRemoteControl *g_RemoteControl;
|
||||||
|
|
||||||
CPlugins::CPlugins()
|
CPlugins::CPlugins()
|
||||||
{
|
{
|
||||||
@@ -72,16 +72,16 @@ CPlugins::CPlugins()
|
|||||||
number_of_plugins = 0;
|
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);
|
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 i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -152,7 +152,7 @@ void CPlugins::loadPlugins()
|
|||||||
scanDir(PLUGINDIR_VAR);
|
scanDir(PLUGINDIR_VAR);
|
||||||
scanDir(PLUGINDIR);
|
scanDir(PLUGINDIR);
|
||||||
|
|
||||||
sort (plugin_list.begin(), plugin_list.end());
|
sort(plugin_list.begin(), plugin_list.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlugins::~CPlugins()
|
CPlugins::~CPlugins()
|
||||||
@@ -162,12 +162,14 @@ CPlugins::~CPlugins()
|
|||||||
|
|
||||||
bool CPlugins::overrideType(plugin *plugin_data, std::string &setting, p_type type)
|
bool CPlugins::overrideType(plugin *plugin_data, std::string &setting, p_type type)
|
||||||
{
|
{
|
||||||
if (!setting.empty()) {
|
if (!setting.empty())
|
||||||
|
{
|
||||||
char s[setting.length() + 1];
|
char s[setting.length() + 1];
|
||||||
cstrncpy(s, setting, setting.length() + 1);
|
cstrncpy(s, setting, setting.length() + 1);
|
||||||
char *t, *p = s;
|
char *t, *p = s;
|
||||||
while ((t = strsep(&p, ",")))
|
while ((t = strsep(&p, ",")))
|
||||||
if (!strcmp(t, plugin_data->filename.c_str())) {
|
if (!strcmp(t, plugin_data->filename.c_str()))
|
||||||
|
{
|
||||||
plugin_data->type = type;
|
plugin_data->type = type;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -301,7 +303,7 @@ bool CPlugins::parseCfg(plugin *plugin_data)
|
|||||||
return !reject;
|
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++)
|
||||||
{
|
{
|
||||||
@@ -313,7 +315,7 @@ int CPlugins::startPlugin_by_name(const std::string & name)
|
|||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int 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)
|
||||||
@@ -323,25 +325,25 @@ int CPlugins::startPlugin(const char * const filename)
|
|||||||
return menu_return::RETURN_REPAINT;
|
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;
|
pid_t pid = 0;
|
||||||
FILE *f = my_popen(pid, script, "r");
|
FILE *f = my_popen(pid, script, "r");
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
{
|
{
|
||||||
char *output=NULL;
|
char *output = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
while ((getline(&output, &len, f)) != -1)
|
while ((getline(&output, &len, f)) != -1)
|
||||||
scriptOutput += output;
|
scriptOutput += output;
|
||||||
pclose(f);
|
pclose(f);
|
||||||
int s;
|
int s;
|
||||||
while (waitpid(pid, &s, WNOHANG)>0);
|
while (waitpid(pid, &s, WNOHANG) > 0);
|
||||||
kill(pid, SIGTERM);
|
kill(pid, SIGTERM);
|
||||||
if (output)
|
if (output)
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("[CPlugins] can't execute %s\n",script);
|
printf("[CPlugins] can't execute %s\n", script);
|
||||||
|
|
||||||
return plugin_list[number].menu_return;
|
return plugin_list[number].menu_return;
|
||||||
}
|
}
|
||||||
@@ -349,7 +351,7 @@ int CPlugins::popenScriptPlugin(int number, const char * script)
|
|||||||
int 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);
|
||||||
if (!file_exists(script))
|
if (!file_exists(script))
|
||||||
{
|
{
|
||||||
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",
|
||||||
@@ -363,7 +365,7 @@ int CPlugins::startScriptPlugin(int number)
|
|||||||
if (plugin_list[number].shellwindow)
|
if (plugin_list[number].shellwindow)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
CShellWindow (script, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE, &res);
|
CShellWindow(script, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE, &res);
|
||||||
scriptOutput = "";
|
scriptOutput = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -375,7 +377,7 @@ int CPlugins::startScriptPlugin(int number)
|
|||||||
int 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);
|
||||||
if (!file_exists(script))
|
if (!file_exists(script))
|
||||||
{
|
{
|
||||||
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",
|
||||||
@@ -459,8 +461,7 @@ int CPlugins::startPlugin(int number)
|
|||||||
|
|
||||||
bool CPlugins::hasPlugin(CPlugins::p_type_t type)
|
bool CPlugins::hasPlugin(CPlugins::p_type_t type)
|
||||||
{
|
{
|
||||||
for (std::vector<plugin>::iterator it=plugin_list.begin();
|
for (std::vector<plugin>::iterator it = plugin_list.begin(); it != plugin_list.end(); ++it)
|
||||||
it!=plugin_list.end(); ++it)
|
|
||||||
{
|
{
|
||||||
if ((it->type & type) && !it->hide)
|
if ((it->type & type) && !it->hide)
|
||||||
return true;
|
return true;
|
||||||
@@ -468,7 +469,7 @@ bool CPlugins::hasPlugin(CPlugins::p_type_t type)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& CPlugins::getScriptOutput() const
|
const std::string &CPlugins::getScriptOutput() const
|
||||||
{
|
{
|
||||||
return scriptOutput;
|
return scriptOutput;
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ class CPlugins
|
|||||||
P_TYPE_TOOL = 0x4,
|
P_TYPE_TOOL = 0x4,
|
||||||
P_TYPE_SCRIPT = 0x8,
|
P_TYPE_SCRIPT = 0x8,
|
||||||
P_TYPE_LUA = 0x10,
|
P_TYPE_LUA = 0x10,
|
||||||
P_TYPE_NO_GAME = P_TYPE_TOOL|P_TYPE_SCRIPT|P_TYPE_LUA
|
P_TYPE_NO_GAME = P_TYPE_TOOL | P_TYPE_SCRIPT | P_TYPE_LUA
|
||||||
}
|
}
|
||||||
p_type_t;
|
p_type_t;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ class CPlugins
|
|||||||
bool shellwindow;
|
bool shellwindow;
|
||||||
bool hide;
|
bool hide;
|
||||||
int menu_return;
|
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 ;
|
||||||
}
|
}
|
||||||
@@ -80,10 +80,10 @@ class CPlugins
|
|||||||
|
|
||||||
bool parseCfg(plugin *plugin_data);
|
bool parseCfg(plugin *plugin_data);
|
||||||
void scanDir(const char *dir);
|
void scanDir(const char *dir);
|
||||||
bool plugin_exists(const std::string & filename);
|
bool plugin_exists(const std::string &filename);
|
||||||
int find_plugin(const std::string & filename);
|
int find_plugin(const std::string &filename);
|
||||||
CPlugins::p_type_t getPluginType(int type);
|
CPlugins::p_type_t getPluginType(int type);
|
||||||
neutrino_msg_t getPluginKey(std::string key="auto");
|
neutrino_msg_t getPluginKey(std::string key = "auto");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CPlugins();
|
CPlugins();
|
||||||
@@ -91,16 +91,16 @@ class CPlugins
|
|||||||
|
|
||||||
void loadPlugins();
|
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 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 *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 *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() ; } //NI
|
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 *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 *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 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 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 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 ; }
|
||||||
@@ -108,18 +108,18 @@ class CPlugins
|
|||||||
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);
|
||||||
|
|
||||||
int startPlugin(int number); // start plugins by number
|
int startPlugin(int number); // start plugins by number
|
||||||
int startPlugin(const char * const filename); // start plugins by filename
|
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_by_name(const std::string &name); // start plugins by "name=" in .cfg
|
||||||
int startScriptPlugin(int number);
|
int startScriptPlugin(int number);
|
||||||
int popenScriptPlugin(int number, const char * script);
|
int popenScriptPlugin(int number, const char *script);
|
||||||
int 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;
|
||||||
void delScriptOutput();
|
void delScriptOutput();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user