mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 15:02:56 +02:00
Add a --enable-lua switch to enable LUA support
This commit is contained in:
12
configure.ac
12
configure.ac
@@ -171,12 +171,24 @@ AC_ARG_ENABLE(pip,
|
||||
[AC_DEFINE(ENABLE_PIP,1,[enable picture in picture support])])
|
||||
|
||||
|
||||
AC_ARG_ENABLE(testmenu,
|
||||
AS_HELP_STRING(--enable-testmenu,include test menu in neutrino main menu))
|
||||
|
||||
AM_CONDITIONAL(ENABLE_TEST_MENU,test "$enable_testmenu" = "yes")
|
||||
if test "$enable_testmenu" = "yes"; then
|
||||
AC_DEFINE(ENABLE_TEST_MENU,1,[include test menu in neutrino main menu - not recommended for general users!])
|
||||
fi
|
||||
|
||||
|
||||
AC_ARG_ENABLE(lua,
|
||||
AS_HELP_STRING(--enable-lua,enable LUA support))
|
||||
|
||||
AM_CONDITIONAL(ENABLE_LUA,test "$enable_lua" = "yes")
|
||||
if test "$enable_lua" = "yes"; then
|
||||
AC_DEFINE(ENABLE_LUA,1,[include LUA support])
|
||||
fi
|
||||
|
||||
|
||||
if test "$BOXTYPE" = "coolstream"; then
|
||||
if test -e ${srcdir}/lib/libcoolstream/nevis_ir.h; then
|
||||
AC_DEFINE(HAVE_COOLSTREAM_NEVIS_IR_H,1,[Define to 1 if you have the <nevis_ir.h> header file.])
|
||||
|
@@ -122,7 +122,9 @@ neutrino_LDADD += -lgif
|
||||
else
|
||||
neutrino_LDADD += -lungif
|
||||
endif
|
||||
if ENABLE_LUA
|
||||
neutrino_LDADD += @LUA_LIBS@
|
||||
endif
|
||||
|
||||
if ENABLE_UPNP
|
||||
neutrino_LDADD += \
|
||||
|
@@ -28,9 +28,14 @@ AM_CPPFLAGS += \
|
||||
-I$(top_srcdir)/lib/xmltree \
|
||||
-I$(top_srcdir)/lib/libupnpclient \
|
||||
@CURL_CFLAGS@ \
|
||||
@LUA_CFLAGS@ \
|
||||
@FREETYPE_CFLAGS@
|
||||
|
||||
if ENABLE_LUA
|
||||
AM_CPPFLAGS += \
|
||||
@LUA_CFLAGS@
|
||||
endif
|
||||
|
||||
|
||||
if BOXTYPE_COOL
|
||||
if BOXMODEL_APOLLO
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/lib/libcoolstream2
|
||||
@@ -115,8 +120,10 @@ libneutrino_gui_a_SOURCES += \
|
||||
test_menu.cpp
|
||||
endif
|
||||
|
||||
if ENABLE_LUA
|
||||
libneutrino_gui_a_SOURCES += \
|
||||
luainstance.cpp
|
||||
endif
|
||||
|
||||
libneutrino_gui2_a_SOURCES = \
|
||||
cam_menu.cpp \
|
||||
|
@@ -69,7 +69,9 @@
|
||||
#endif
|
||||
|
||||
#include <daemonc/remotecontrol.h>
|
||||
#if ENABLE_LUA
|
||||
#include <gui/luainstance.h>
|
||||
#endif
|
||||
|
||||
extern CPlugins * g_PluginList; /* neutrino.cpp */
|
||||
extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */
|
||||
@@ -128,8 +130,10 @@ void CPlugins::scanDir(const char *dir)
|
||||
new_plugin.pluginfile = fname;
|
||||
if (new_plugin.type == CPlugins::P_TYPE_SCRIPT)
|
||||
new_plugin.pluginfile.append(".sh");
|
||||
#if ENABLE_LUA
|
||||
else if (new_plugin.type == CPlugins::P_TYPE_LUA)
|
||||
new_plugin.pluginfile.append(".lua");
|
||||
#endif
|
||||
else
|
||||
new_plugin.pluginfile.append(".so");
|
||||
// We do not check if new_plugin.pluginfile exists since .cfg in
|
||||
@@ -344,6 +348,7 @@ void CPlugins::startScriptPlugin(int number)
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_LUA
|
||||
void CPlugins::startLuaPlugin(int number)
|
||||
{
|
||||
const char *script = plugin_list[number].pluginfile.c_str();
|
||||
@@ -358,6 +363,7 @@ void CPlugins::startLuaPlugin(int number)
|
||||
lua->runScript(script);
|
||||
delete lua;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CPlugins::startPlugin(int number,int /*param*/)
|
||||
{
|
||||
@@ -384,11 +390,13 @@ void CPlugins::startPlugin(int number,int /*param*/)
|
||||
startScriptPlugin(number);
|
||||
return;
|
||||
}
|
||||
#if ENABLE_LUA
|
||||
if (plugin_list[number].type == CPlugins::P_TYPE_LUA)
|
||||
{
|
||||
startLuaPlugin(number);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (!file_exists(plugin_list[number].pluginfile.c_str()))
|
||||
{
|
||||
printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n",
|
||||
@@ -655,8 +663,10 @@ CPlugins::p_type_t CPlugins::getPluginType(int type)
|
||||
case PLUGIN_TYPE_SCRIPT:
|
||||
return P_TYPE_SCRIPT;
|
||||
break;
|
||||
#if ENABLE_LUA
|
||||
case PLUGIN_TYPE_LUA:
|
||||
return P_TYPE_LUA;
|
||||
#endif
|
||||
default:
|
||||
return P_TYPE_DISABLED;
|
||||
}
|
||||
|
@@ -51,8 +51,12 @@ class CPlugins
|
||||
P_TYPE_DISABLED = 0x1,
|
||||
P_TYPE_GAME = 0x2,
|
||||
P_TYPE_TOOL = 0x4,
|
||||
P_TYPE_SCRIPT = 0x8,
|
||||
P_TYPE_SCRIPT = 0x8
|
||||
|
||||
#if ENABLE_LUA
|
||||
,
|
||||
P_TYPE_LUA = 0x10
|
||||
#endif
|
||||
}
|
||||
p_type_t;
|
||||
|
||||
@@ -123,8 +127,9 @@ class CPlugins
|
||||
void startPlugin(int number,int param);
|
||||
void start_plugin_by_name(const std::string & filename,int param);// start plugins by "name=" in .cfg
|
||||
void startScriptPlugin(int number);
|
||||
#if ENABLE_LUA
|
||||
void startLuaPlugin(int number);
|
||||
|
||||
#endif
|
||||
void startPlugin(const char * const filename); // start plugins also by name
|
||||
bool hasPlugin(CPlugins::p_type_t type);
|
||||
|
||||
|
@@ -308,8 +308,11 @@ bool CUserMenu::showUserMenu(int button)
|
||||
int cnt = 0;
|
||||
for (unsigned int count = 0; count < (unsigned int) g_PluginList->getNumberOfPlugins(); count++)
|
||||
{
|
||||
bool show = g_PluginList->getType(count) == CPlugins::P_TYPE_TOOL ||
|
||||
g_PluginList->getType(count) == CPlugins::P_TYPE_LUA;
|
||||
bool show = g_PluginList->getType(count) == CPlugins::P_TYPE_TOOL;
|
||||
|
||||
#if ENABLE_LUA
|
||||
show = show || g_PluginList->getType(count) == CPlugins::P_TYPE_LUA;
|
||||
#endif
|
||||
if (show && !g_PluginList->isHidden(count))
|
||||
{
|
||||
sprintf(id, "%d", count);
|
||||
|
@@ -1260,10 +1260,12 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*)
|
||||
else
|
||||
(*optionValue)++;
|
||||
}
|
||||
#if ENABLE_LUA
|
||||
if(observ && !luaAction.empty()) {
|
||||
// optionValue is int*
|
||||
observ->changeNotify(luaState, luaAction, luaId, (void *) to_string(*optionValue).c_str());
|
||||
} else
|
||||
#endif
|
||||
if(observ)
|
||||
observ->changeNotify(name, optionValue);
|
||||
|
||||
@@ -1484,8 +1486,9 @@ int CMenuOptionChooser::exec(CMenuTarget*)
|
||||
{
|
||||
bool wantsRepaint = false;
|
||||
int ret = menu_return::RETURN_NONE;
|
||||
#if ENABLE_LUA
|
||||
char *optionValname = NULL;
|
||||
|
||||
#endif
|
||||
if (optionsSort) {
|
||||
optionsSort = false;
|
||||
clearChooserOptions();
|
||||
@@ -1538,7 +1541,9 @@ int CMenuOptionChooser::exec(CMenuTarget*)
|
||||
if(select >= 0)
|
||||
{
|
||||
*optionValue = options[select].key;
|
||||
#if ENABLE_LUA
|
||||
optionValname = (char *) options[select].valname;
|
||||
#endif
|
||||
}
|
||||
delete menu;
|
||||
delete selector;
|
||||
@@ -1547,23 +1552,31 @@ int CMenuOptionChooser::exec(CMenuTarget*)
|
||||
if (options[count].key == (*optionValue)) {
|
||||
if(msg == CRCInput::RC_left) {
|
||||
if(count > 0)
|
||||
#if ENABLE_LUA
|
||||
optionValname = (char *) options[(count-1) % number_of_options].valname,
|
||||
#endif
|
||||
*optionValue = options[(count-1) % number_of_options].key;
|
||||
else
|
||||
#if ENABLE_LUA
|
||||
optionValname = (char *) options[number_of_options-1].valname,
|
||||
#endif
|
||||
*optionValue = options[number_of_options-1].key;
|
||||
} else
|
||||
#if ENABLE_LUA
|
||||
optionValname = (char *) options[(count+1) % number_of_options].valname,
|
||||
#endif
|
||||
*optionValue = options[(count+1) % number_of_options].key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
paint(true);
|
||||
#if ENABLE_LUA
|
||||
if(observ && !luaAction.empty()) {
|
||||
if (optionValname)
|
||||
wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, optionValname);
|
||||
} else
|
||||
#endif
|
||||
if(observ)
|
||||
wantsRepaint = observ->changeNotify(name, optionValue);
|
||||
|
||||
@@ -1724,9 +1737,11 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent)
|
||||
|
||||
paint(true);
|
||||
}
|
||||
#if ENABLE_LUA
|
||||
if(observ && !luaAction.empty())
|
||||
wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *)(optionValueString ? optionValueString->c_str() : ""));
|
||||
else
|
||||
#endif
|
||||
if(observ) {
|
||||
wantsRepaint = observ->changeNotify(name, (void *)(optionValueString ? optionValueString->c_str() : ""));
|
||||
}
|
||||
|
@@ -45,11 +45,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if ENABLE_LUA
|
||||
extern "C" {
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NO_WIDGET_ID -1
|
||||
|
||||
@@ -75,10 +77,12 @@ class CChangeObserver
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#if ENABLE_LUA
|
||||
virtual bool changeNotify(lua_State * /*L*/, const std::string & /*luaId*/, const std::string & /*luaAction*/, void * /*Data*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class CMenuTarget
|
||||
@@ -103,9 +107,11 @@ class CMenuItem
|
||||
fb_pixel_t item_color, item_bgcolor;
|
||||
|
||||
void initItemColors(const bool select_mode);
|
||||
#if ENABLE_LUA
|
||||
lua_State *luaState;
|
||||
std::string luaAction;
|
||||
std::string luaId;
|
||||
#endif
|
||||
neutrino_locale_t name;
|
||||
std::string nameString;
|
||||
|
||||
@@ -170,8 +176,9 @@ class CMenuItem
|
||||
void setHint(const std::string icon, const neutrino_locale_t text) { hintIcon = icon; hint = text; }
|
||||
void setHint(const std::string icon, const std::string text) { hintIcon = icon; hintText = text; }
|
||||
|
||||
#if ENABLE_LUA
|
||||
void setLua(lua_State *_luaState, std::string &_luaAction, std::string &_luaId) { luaState = _luaState; luaAction = _luaAction; luaId = _luaId; };
|
||||
|
||||
#endif
|
||||
virtual const char *getName();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user