From 88c69c92bd44d1c56bed253037c03c2213c5f395 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 17 Mar 2013 23:24:45 +0100 Subject: [PATCH 01/54] neutrino: add a prototype of a lua plugin interface this is just for preliminary tests, not yet really usable for anything useful Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f26357e88733cef30ff9fd9279f9362985c68de0 Author: Stefan Seyfried Date: 2013-03-17 (Sun, 17 Mar 2013) ------------------ This commit was generated by Migit --- src/Makefile.am | 1 + src/gui/Makefile.am | 3 + src/gui/luainstance.cpp | 287 ++++++++++++++++++++++++++++++++++++++++ src/gui/luainstance.h | 52 ++++++++ src/gui/plugins.cpp | 30 ++++- src/gui/plugins.h | 4 +- src/gui/user_menue.cpp | 4 +- src/plugin.h | 3 +- 8 files changed, 378 insertions(+), 6 deletions(-) create mode 100644 src/gui/luainstance.cpp create mode 100644 src/gui/luainstance.h diff --git a/src/Makefile.am b/src/Makefile.am index 38b3ca66f..f80eed707 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,6 +122,7 @@ neutrino_LDADD += -lgif else neutrino_LDADD += -lungif endif +neutrino_LDADD += -llua -ldl if ENABLE_UPNP neutrino_LDADD += \ diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index e26d7aab0..d0da43b10 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -114,6 +114,9 @@ libneutrino_gui_a_SOURCES += \ test_menu.cpp endif +libneutrino_gui_a_SOURCES += \ + luainstance.cpp + libneutrino_gui2_a_SOURCES = \ cam_menu.cpp \ color.cpp \ diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp new file mode 100644 index 000000000..3060c135d --- /dev/null +++ b/src/gui/luainstance.cpp @@ -0,0 +1,287 @@ +/* + * neutrino-mp lua to c++ bridge + * + * (C) 2013 Stefan Seyfried + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include "luainstance.h" + +#define DBG printf + +#define lua_boxpointer(L, u) \ + (*(void **)(lua_newuserdata(L, sizeof(void *))) = (u)) + +#define lua_unboxpointer(L, i) \ + (*(void **)(lua_touserdata(L, i))) + +const char CLUAInstance::className[] = "neutrino"; + +CLUAInstance::CLUAInstance() +{ + /* Create the intepreter object. */ + lua = luaL_newstate(); + + /* register standard + custom functions. */ + registerFunctions(); +} + +CLUAInstance::~CLUAInstance() +{ + if (lua != NULL) + { + lua_close(lua); + lua = NULL; + } +} + +#define SET_VAR1(NAME) \ + lua_pushinteger(lua, NAME); \ + lua_setglobal(lua, #NAME); +#define SET_VAR2(NAME, VALUE) \ + lua_pushinteger(lua, VALUE); \ + lua_setglobal(lua, #NAME); +#define SET_FONT(NAME) \ + lua_pushinteger(lua, SNeutrinoSettings::NAME); \ + lua_setglobal(lua, #NAME); + +/* Run the given script. */ +void CLUAInstance::runScript(const char *fileName) +{ + // luaL_dofile(lua, fileName); + /* run the script */ + int status = luaL_loadfile(lua, fileName); + if (status) { + fprintf(stderr, "[CLUAInstance::%s] Can't load file: %s\n", __func__, lua_tostring(lua, -1)); + return; + } + + /* set variables */ + SET_VAR1(COL_COLORED_EVENTS_CHANNELLIST); + SET_VAR1(COL_COLORED_EVENTS_INFOBAR); + SET_VAR1(COL_INFOBAR_SHADOW); + SET_VAR1(COL_INFOBAR); + SET_VAR1(COL_MENUHEAD); + SET_VAR1(COL_MENUCONTENT); + SET_VAR1(COL_MENUCONTENTDARK); + SET_VAR1(COL_MENUCONTENTSELECTED); + SET_VAR1(COL_MENUCONTENTINACTIVE); + SET_VAR1(COL_BACKGROUND); + + SET_VAR2(SCREEN_OFF_X, g_settings.screen_StartX); + SET_VAR2(SCREEN_OFF_Y, g_settings.screen_StartY); + SET_VAR2(SCREEN_END_X, g_settings.screen_EndX); + SET_VAR2(SCREEN_END_Y, g_settings.screen_EndY); + + SET_FONT(FONT_TYPE_MENU); + SET_FONT(FONT_TYPE_MENU_TITLE); + SET_FONT(FONT_TYPE_MENU_INFO); + SET_FONT(FONT_TYPE_EPG_TITLE); + SET_FONT(FONT_TYPE_EPG_INFO1); + SET_FONT(FONT_TYPE_EPG_INFO2); + SET_FONT(FONT_TYPE_EPG_DATE); + SET_FONT(FONT_TYPE_EVENTLIST_TITLE); + SET_FONT(FONT_TYPE_EVENTLIST_ITEMLARGE); + SET_FONT(FONT_TYPE_EVENTLIST_ITEMSMALL); + SET_FONT(FONT_TYPE_EVENTLIST_DATETIME); + SET_FONT(FONT_TYPE_GAMELIST_ITEMLARGE); + SET_FONT(FONT_TYPE_GAMELIST_ITEMSMALL); + SET_FONT(FONT_TYPE_CHANNELLIST); + SET_FONT(FONT_TYPE_CHANNELLIST_DESCR); + SET_FONT(FONT_TYPE_CHANNELLIST_NUMBER); + SET_FONT(FONT_TYPE_CHANNELLIST_EVENT); + SET_FONT(FONT_TYPE_CHANNEL_NUM_ZAP); + SET_FONT(FONT_TYPE_INFOBAR_NUMBER); + SET_FONT(FONT_TYPE_INFOBAR_CHANNAME); + SET_FONT(FONT_TYPE_INFOBAR_INFO); + SET_FONT(FONT_TYPE_INFOBAR_SMALL); + SET_FONT(FONT_TYPE_FILEBROWSER_ITEM); + SET_FONT(FONT_TYPE_MENU_HINT); + + status = lua_pcall(lua, 0, LUA_MULTRET, 0); + if (status) + fprintf(stderr, "[CLUAInstance::%s] error in script: %s\n", __func__, lua_tostring(lua, -1)); +} + +const luaL_Reg CLUAInstance::methods[] = +{ + { "PaintBox", CLUAInstance::PaintBox }, + { "RenderString", CLUAInstance::RenderString }, + { "PaintIcon", CLUAInstance::PaintIcon }, + { NULL, NULL } +}; + +/* load basic functions and register our own C callbacks */ +void CLUAInstance::registerFunctions() +{ + luaL_openlibs(lua); + luaopen_table(lua); + luaopen_io(lua); + luaopen_string(lua); + luaopen_math(lua); + + lua_newtable(lua); + int methodtable = lua_gettop(lua); + luaL_newmetatable(lua, className); + int metatable = lua_gettop(lua); + lua_pushliteral(lua, "__metatable"); + lua_pushvalue(lua, methodtable); + lua_settable(lua, metatable); + + lua_pushliteral(lua, "__index"); + lua_pushvalue(lua, methodtable); + lua_settable(lua, metatable); + + lua_pushliteral(lua, "__gc"); + lua_pushcfunction(lua, GCWindow); + lua_settable(lua, metatable); + + lua_pop(lua, 1); + + luaL_setfuncs(lua, methods, 0); + lua_pop(lua, 1); + + lua_register(lua, className, NewWindow); +} + +CFBWindow *CLUAInstance::CheckWindow(lua_State *L, int narg) +{ + luaL_checktype(L, narg, LUA_TUSERDATA); + void *ud = luaL_checkudata(L, narg, className); + if (!ud) + fprintf(stderr, "[CLUAInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className); + return *(CFBWindow **)ud; // unbox pointer +} + +int CLUAInstance::NewWindow(lua_State *L) +{ + int count = lua_gettop(L); + int x = g_settings.screen_StartX; + int y = g_settings.screen_StartY; + int w = g_settings.screen_EndX - x; + int h = g_settings.screen_EndY - y; + if (count > 0) + x = luaL_checkint(L, 1); + if (count > 1) + y = luaL_checkint(L, 2); + if (count > 2) + w = luaL_checkint(L, 3); + if (count > 3) + h = luaL_checkint(L, 4); + CFBWindow *W = new CFBWindow(x, y, w, h); + lua_boxpointer(L, W); + luaL_getmetatable(L, className); + lua_setmetatable(L, -2); + return 1; +} + +int CLUAInstance::PaintBox(lua_State *L) +{ + DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L)); + int x, y, w, h; + unsigned int c; + + CFBWindow *W = CheckWindow(L, 1); + if (!W) + return 0; + x = luaL_checkint(L, 2); + y = luaL_checkint(L, 3); + w = luaL_checkint(L, 4); + h = luaL_checkint(L, 5); + c = luaL_checkint(L, 6); + /* those checks should be done in CFBWindow instead... */ + if (x < 0) + x = 0; + if (y < 0) + y = 0; + if (w < 0 || x + w > W->dx) + w = W->dx - x; + if (h < 0 || y + h > W->dy) + h = W->dy - y; + /* use the color constants */ + c = CFrameBuffer::getInstance()->realcolor[c & 0xff]; + W->paintBoxRel(x, y, w, h, c); + return 0; +} + +int CLUAInstance::PaintIcon(lua_State *L) +{ + DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L)); + int x, y, h; + unsigned int o; + const char *fname; + + CFBWindow *W = CheckWindow(L, 1); + if (!W) + return 0; + fname = luaL_checkstring(L, 2); + x = luaL_checkint(L, 3); + y = luaL_checkint(L, 4); + h = luaL_checkint(L, 5); + o = luaL_checkint(L, 6); + W->paintIcon(fname, x, y, h, o); + return 0; +} + +int CLUAInstance::RenderString(lua_State *L) +{ + int x, y, w, boxh, utf8, f; + unsigned int c; + const char *text; + int numargs = lua_gettop(L); + DBG("CLUAInstance::%s %d\n", __func__, numargs); + c = COL_MENUCONTENT; + boxh = 0; + utf8 = 1; + + CFBWindow *W = CheckWindow(L, 1); + if (!W) + return 0; + f = luaL_checkint(L, 2); /* font number, use FONT_TYPE_XXX in the script */ + text = luaL_checkstring(L, 3); /* text */ + x = luaL_checkint(L, 4); + y = luaL_checkint(L, 5); + if (numargs > 5) + c = luaL_checkint(L, 6); + if (numargs > 6) + w = luaL_checkint(L, 7); + else + w = W->dx - x; + if (numargs > 7) + boxh = luaL_checkint(L, 8); + if (numargs > 8) + utf8 = luaL_checkint(L, 9); + if (f >= FONT_TYPE_COUNT || f < 0) + f = SNeutrinoSettings::FONT_TYPE_MENU; + W->RenderString(g_Font[f], x, y, w, text, c, boxh, utf8); + return 0; +} + +int CLUAInstance::GCWindow(lua_State *L) +{ + DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L)); + CFBWindow *w = (CFBWindow *)lua_unboxpointer(L, 1); + delete w; + return 0; +} diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h new file mode 100644 index 000000000..89274bdc1 --- /dev/null +++ b/src/gui/luainstance.h @@ -0,0 +1,52 @@ +/* + * neutrino-mp lua to c++ bridge + * + * (C) 2013 Stefan Seyfried + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef _LUAINSTANCE_H +#define _LUAINSTANCE_H + +/* LUA Is C */ +extern "C" { +#include +#include +#include +} +#include + +/* inspired by Steve Kemp http://www.steve.org.uk/ */ +class CLUAInstance +{ + static const char className[]; + static const luaL_Reg methods[]; + static CFBWindow *CheckWindow(lua_State *L, int narg); +public: + CLUAInstance(); + ~CLUAInstance(); + void runScript(const char *fileName); + +private: + lua_State* lua; + void registerFunctions(); + + static int NewWindow(lua_State *L); + static int PaintBox(lua_State *L); + static int PaintIcon(lua_State *L); + static int RenderString(lua_State *L); + static int GCWindow(lua_State *L); +}; + +#endif /* _LUAINSTANCE_H */ diff --git a/src/gui/plugins.cpp b/src/gui/plugins.cpp index 0c5022ad8..b56e535d7 100644 --- a/src/gui/plugins.cpp +++ b/src/gui/plugins.cpp @@ -69,6 +69,8 @@ #endif #include +#include + extern CPlugins * g_PluginList; /* neutrino.cpp */ extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ @@ -125,11 +127,11 @@ void CPlugins::scanDir(const char *dir) if (plugin_ok) { new_plugin.pluginfile = fname; if (new_plugin.type == CPlugins::P_TYPE_SCRIPT) - { new_plugin.pluginfile.append(".sh"); - } else { + else if (new_plugin.type == CPlugins::P_TYPE_LUA) + new_plugin.pluginfile.append(".lua"); + else new_plugin.pluginfile.append(".so"); - } // We do not check if new_plugin.pluginfile exists since .cfg in // PLUGINDIR_VAR can overwrite settings in read only dir // PLUGINDIR. This needs PLUGINDIR_VAR to be scanned at @@ -342,6 +344,21 @@ void CPlugins::startScriptPlugin(int number) } } +void CPlugins::startLuaPlugin(int number) +{ + const char *script = plugin_list[number].pluginfile.c_str(); + 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()); + return; + } + CLUAInstance *lua = new CLUAInstance(); + lua->runScript(script); + delete lua; +} + void CPlugins::startPlugin(int number,int /*param*/) { // always delete old output @@ -367,6 +384,11 @@ void CPlugins::startPlugin(int number,int /*param*/) startScriptPlugin(number); return; } + if (plugin_list[number].type == CPlugins::P_TYPE_LUA) + { + startLuaPlugin(number); + return; + } if (!file_exists(plugin_list[number].pluginfile.c_str())) { printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n", @@ -633,6 +655,8 @@ CPlugins::p_type_t CPlugins::getPluginType(int type) case PLUGIN_TYPE_SCRIPT: return P_TYPE_SCRIPT; break; + case PLUGIN_TYPE_LUA: + return P_TYPE_LUA; default: return P_TYPE_DISABLED; } diff --git a/src/gui/plugins.h b/src/gui/plugins.h index 501e6172c..1bd6c614f 100644 --- a/src/gui/plugins.h +++ b/src/gui/plugins.h @@ -51,7 +51,8 @@ class CPlugins P_TYPE_DISABLED = 0x1, P_TYPE_GAME = 0x2, P_TYPE_TOOL = 0x4, - P_TYPE_SCRIPT = 0x8 + P_TYPE_SCRIPT = 0x8, + P_TYPE_LUA = 0x10 } p_type_t; @@ -122,6 +123,7 @@ 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); + void startLuaPlugin(int number); void startPlugin(const char * const filename); // start plugins also by name bool hasPlugin(CPlugins::p_type_t type); diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 3758d1fad..914b04ca7 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -308,7 +308,9 @@ bool CUserMenu::showUserMenu(int button) int cnt = 0; for (unsigned int count = 0; count < (unsigned int) g_PluginList->getNumberOfPlugins(); count++) { - if (g_PluginList->getType(count)== CPlugins::P_TYPE_TOOL && !g_PluginList->isHidden(count)) + bool show = g_PluginList->getType(count) == CPlugins::P_TYPE_TOOL || + g_PluginList->getType(count) == CPlugins::P_TYPE_LUA; + if (show && !g_PluginList->isHidden(count)) { sprintf(id, "%d", count); menu_items++; diff --git a/src/plugin.h b/src/plugin.h index 3e45c0860..e0394b37a 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -39,7 +39,8 @@ typedef enum plugin_type PLUGIN_TYPE_DISABLED = 0, PLUGIN_TYPE_GAME = 1, PLUGIN_TYPE_TOOL = 2, - PLUGIN_TYPE_SCRIPT = 3 + PLUGIN_TYPE_SCRIPT = 3, + PLUGIN_TYPE_LUA = 4 } plugin_type_t; From cef20d5284885cf9e91e374bb46a34635601353c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 18 Mar 2013 16:10:01 +0100 Subject: [PATCH 02/54] luainstance: the name is "Lua", not "LUA" Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/4d7e07f81f4867f142ab03ffc8cd799f11d81831 Author: Stefan Seyfried Date: 2013-03-18 (Mon, 18 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 44 ++++++++++++++++++++--------------------- src/gui/luainstance.h | 6 +++--- src/gui/plugins.cpp | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 3060c135d..4a6efc69e 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -36,9 +36,9 @@ #define lua_unboxpointer(L, i) \ (*(void **)(lua_touserdata(L, i))) -const char CLUAInstance::className[] = "neutrino"; +const char CLuaInstance::className[] = "neutrino"; -CLUAInstance::CLUAInstance() +CLuaInstance::CLuaInstance() { /* Create the intepreter object. */ lua = luaL_newstate(); @@ -47,7 +47,7 @@ CLUAInstance::CLUAInstance() registerFunctions(); } -CLUAInstance::~CLUAInstance() +CLuaInstance::~CLuaInstance() { if (lua != NULL) { @@ -67,13 +67,13 @@ CLUAInstance::~CLUAInstance() lua_setglobal(lua, #NAME); /* Run the given script. */ -void CLUAInstance::runScript(const char *fileName) +void CLuaInstance::runScript(const char *fileName) { // luaL_dofile(lua, fileName); /* run the script */ int status = luaL_loadfile(lua, fileName); if (status) { - fprintf(stderr, "[CLUAInstance::%s] Can't load file: %s\n", __func__, lua_tostring(lua, -1)); + fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, lua_tostring(lua, -1)); return; } @@ -121,19 +121,19 @@ void CLUAInstance::runScript(const char *fileName) status = lua_pcall(lua, 0, LUA_MULTRET, 0); if (status) - fprintf(stderr, "[CLUAInstance::%s] error in script: %s\n", __func__, lua_tostring(lua, -1)); + fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, lua_tostring(lua, -1)); } -const luaL_Reg CLUAInstance::methods[] = +const luaL_Reg CLuaInstance::methods[] = { - { "PaintBox", CLUAInstance::PaintBox }, - { "RenderString", CLUAInstance::RenderString }, - { "PaintIcon", CLUAInstance::PaintIcon }, + { "PaintBox", CLuaInstance::PaintBox }, + { "RenderString", CLuaInstance::RenderString }, + { "PaintIcon", CLuaInstance::PaintIcon }, { NULL, NULL } }; /* load basic functions and register our own C callbacks */ -void CLUAInstance::registerFunctions() +void CLuaInstance::registerFunctions() { luaL_openlibs(lua); luaopen_table(lua); @@ -165,16 +165,16 @@ void CLUAInstance::registerFunctions() lua_register(lua, className, NewWindow); } -CFBWindow *CLUAInstance::CheckWindow(lua_State *L, int narg) +CFBWindow *CLuaInstance::CheckWindow(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TUSERDATA); void *ud = luaL_checkudata(L, narg, className); if (!ud) - fprintf(stderr, "[CLUAInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className); + fprintf(stderr, "[CLuaInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className); return *(CFBWindow **)ud; // unbox pointer } -int CLUAInstance::NewWindow(lua_State *L) +int CLuaInstance::NewWindow(lua_State *L) { int count = lua_gettop(L); int x = g_settings.screen_StartX; @@ -196,9 +196,9 @@ int CLUAInstance::NewWindow(lua_State *L) return 1; } -int CLUAInstance::PaintBox(lua_State *L) +int CLuaInstance::PaintBox(lua_State *L) { - DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L)); + DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); int x, y, w, h; unsigned int c; @@ -225,9 +225,9 @@ int CLUAInstance::PaintBox(lua_State *L) return 0; } -int CLUAInstance::PaintIcon(lua_State *L) +int CLuaInstance::PaintIcon(lua_State *L) { - DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L)); + DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); int x, y, h; unsigned int o; const char *fname; @@ -244,13 +244,13 @@ int CLUAInstance::PaintIcon(lua_State *L) return 0; } -int CLUAInstance::RenderString(lua_State *L) +int CLuaInstance::RenderString(lua_State *L) { int x, y, w, boxh, utf8, f; unsigned int c; const char *text; int numargs = lua_gettop(L); - DBG("CLUAInstance::%s %d\n", __func__, numargs); + DBG("CLuaInstance::%s %d\n", __func__, numargs); c = COL_MENUCONTENT; boxh = 0; utf8 = 1; @@ -278,9 +278,9 @@ int CLUAInstance::RenderString(lua_State *L) return 0; } -int CLUAInstance::GCWindow(lua_State *L) +int CLuaInstance::GCWindow(lua_State *L) { - DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L)); + DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); CFBWindow *w = (CFBWindow *)lua_unboxpointer(L, 1); delete w; return 0; diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 89274bdc1..e7206c7fd 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -28,14 +28,14 @@ extern "C" { #include /* inspired by Steve Kemp http://www.steve.org.uk/ */ -class CLUAInstance +class CLuaInstance { static const char className[]; static const luaL_Reg methods[]; static CFBWindow *CheckWindow(lua_State *L, int narg); public: - CLUAInstance(); - ~CLUAInstance(); + CLuaInstance(); + ~CLuaInstance(); void runScript(const char *fileName); private: diff --git a/src/gui/plugins.cpp b/src/gui/plugins.cpp index b56e535d7..a05cde321 100644 --- a/src/gui/plugins.cpp +++ b/src/gui/plugins.cpp @@ -354,7 +354,7 @@ void CPlugins::startLuaPlugin(int number) script, plugin_list[number].cfgfile.c_str()); return; } - CLUAInstance *lua = new CLUAInstance(); + CLuaInstance *lua = new CLuaInstance(); lua->runScript(script); delete lua; } From 6d808199fc2ea9c73eb8fa857e787e70a5f8974d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 18 Mar 2013 17:38:37 +0100 Subject: [PATCH 03/54] luainstance: add simple GetInput() method use like this in the lua script: -- RC_home = 174 local n = neutrino() repeat msg, data = m:GetInput(1000) until msg == RC_home Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/eefd75537ee5736c2843c465d5328ec5789a3aed Author: Stefan Seyfried Date: 2013-03-18 (Mon, 18 Mar 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 68 ++++++++++++++++++++++++++++++----------- src/gui/luainstance.h | 10 +++++- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 4a6efc69e..8fda14245 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "luainstance.h" @@ -129,6 +130,7 @@ const luaL_Reg CLuaInstance::methods[] = { "PaintBox", CLuaInstance::PaintBox }, { "RenderString", CLuaInstance::RenderString }, { "PaintIcon", CLuaInstance::PaintIcon }, + { "GetInput", CLuaInstance::GetInput }, { NULL, NULL } }; @@ -165,13 +167,13 @@ void CLuaInstance::registerFunctions() lua_register(lua, className, NewWindow); } -CFBWindow *CLuaInstance::CheckWindow(lua_State *L, int narg) +CLuaData *CLuaInstance::CheckData(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TUSERDATA); void *ud = luaL_checkudata(L, narg, className); if (!ud) fprintf(stderr, "[CLuaInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className); - return *(CFBWindow **)ud; // unbox pointer + return *(CLuaData **)ud; // unbox pointer } int CLuaInstance::NewWindow(lua_State *L) @@ -181,6 +183,7 @@ int CLuaInstance::NewWindow(lua_State *L) int y = g_settings.screen_StartY; int w = g_settings.screen_EndX - x; int h = g_settings.screen_EndY - y; + CLuaData *D = new CLuaData(); if (count > 0) x = luaL_checkint(L, 1); if (count > 1) @@ -190,7 +193,9 @@ int CLuaInstance::NewWindow(lua_State *L) if (count > 3) h = luaL_checkint(L, 4); CFBWindow *W = new CFBWindow(x, y, w, h); - lua_boxpointer(L, W); + D->fbwin = W; + D->rcinput = g_RCInput; + lua_boxpointer(L, D); luaL_getmetatable(L, className); lua_setmetatable(L, -2); return 1; @@ -202,8 +207,8 @@ int CLuaInstance::PaintBox(lua_State *L) int x, y, w, h; unsigned int c; - CFBWindow *W = CheckWindow(L, 1); - if (!W) + CLuaData *W = CheckData(L, 1); + if (!W || !W->fbwin) return 0; x = luaL_checkint(L, 2); y = luaL_checkint(L, 3); @@ -215,13 +220,13 @@ int CLuaInstance::PaintBox(lua_State *L) x = 0; if (y < 0) y = 0; - if (w < 0 || x + w > W->dx) - w = W->dx - x; - if (h < 0 || y + h > W->dy) - h = W->dy - y; + if (w < 0 || x + w > W->fbwin->dx) + w = W->fbwin->dx - x; + if (h < 0 || y + h > W->fbwin->dy) + h = W->fbwin->dy - y; /* use the color constants */ c = CFrameBuffer::getInstance()->realcolor[c & 0xff]; - W->paintBoxRel(x, y, w, h, c); + W->fbwin->paintBoxRel(x, y, w, h, c); return 0; } @@ -232,15 +237,15 @@ int CLuaInstance::PaintIcon(lua_State *L) unsigned int o; const char *fname; - CFBWindow *W = CheckWindow(L, 1); - if (!W) + CLuaData *W = CheckData(L, 1); + if (!W || !W->fbwin) return 0; fname = luaL_checkstring(L, 2); x = luaL_checkint(L, 3); y = luaL_checkint(L, 4); h = luaL_checkint(L, 5); o = luaL_checkint(L, 6); - W->paintIcon(fname, x, y, h, o); + W->fbwin->paintIcon(fname, x, y, h, o); return 0; } @@ -255,8 +260,8 @@ int CLuaInstance::RenderString(lua_State *L) boxh = 0; utf8 = 1; - CFBWindow *W = CheckWindow(L, 1); - if (!W) + CLuaData *W = CheckData(L, 1); + if (!W || !W->fbwin) return 0; f = luaL_checkint(L, 2); /* font number, use FONT_TYPE_XXX in the script */ text = luaL_checkstring(L, 3); /* text */ @@ -267,21 +272,48 @@ int CLuaInstance::RenderString(lua_State *L) if (numargs > 6) w = luaL_checkint(L, 7); else - w = W->dx - x; + w = W->fbwin->dx - x; if (numargs > 7) boxh = luaL_checkint(L, 8); if (numargs > 8) utf8 = luaL_checkint(L, 9); if (f >= FONT_TYPE_COUNT || f < 0) f = SNeutrinoSettings::FONT_TYPE_MENU; - W->RenderString(g_Font[f], x, y, w, text, c, boxh, utf8); + W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, utf8); return 0; } +int CLuaInstance::GetInput(lua_State *L) +{ + int numargs = lua_gettop(L); + int timeout = 0; + neutrino_msg_t msg; + neutrino_msg_data_t data; + CLuaData *W = CheckData(L, 1); + if (!W) + return 0; + if (numargs > 1) + timeout = luaL_checkint(L, 2); + W->rcinput->getMsg_ms(&msg, &data, timeout); + /* TODO: I'm not sure if this works... */ + if (msg != CRCInput::RC_timeout && msg > CRCInput::RC_MaxRC) + { + DBG("CLuaInstance::%s: msg 0x%08lx data 0x%08lx\n", __func__, msg, data); + CNeutrinoApp::getInstance()->handleMsg(msg, data); + } + /* signed int is debatable, but the "big" messages can't yet be handled + * inside lua scripts anyway. RC_timeout == -1, RC_nokey == -2 */ + lua_pushinteger(L, (int)msg); + lua_pushunsigned(L, data); + return 2; +} + int CLuaInstance::GCWindow(lua_State *L) { DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); - CFBWindow *w = (CFBWindow *)lua_unboxpointer(L, 1); + CLuaData *w = (CLuaData *)lua_unboxpointer(L, 1); + delete w->fbwin; + w->rcinput = NULL; delete w; return 0; } diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index e7206c7fd..24cb73123 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -27,12 +27,19 @@ extern "C" { } #include +/* this is stored as userdata in the lua_State */ +struct CLuaData +{ + CFBWindow *fbwin; + CRCInput *rcinput; +}; + /* inspired by Steve Kemp http://www.steve.org.uk/ */ class CLuaInstance { static const char className[]; static const luaL_Reg methods[]; - static CFBWindow *CheckWindow(lua_State *L, int narg); + static CLuaData *CheckData(lua_State *L, int narg); public: CLuaInstance(); ~CLuaInstance(); @@ -46,6 +53,7 @@ private: static int PaintBox(lua_State *L); static int PaintIcon(lua_State *L); static int RenderString(lua_State *L); + static int GetInput(lua_State *L); static int GCWindow(lua_State *L); }; From 729a2adf34c3a24058d917b06bbb509ba082c7fc Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 19 Mar 2013 10:23:11 +0100 Subject: [PATCH 04/54] luainstance: add minimal error reporting Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/8dfa4c9bf8e5208a4d67b5b5242fcbba570f0fa4 Author: Stefan Seyfried Date: 2013-03-19 (Tue, 19 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 8fda14245..d789a38a5 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include "luainstance.h" @@ -122,7 +123,11 @@ void CLuaInstance::runScript(const char *fileName) status = lua_pcall(lua, 0, LUA_MULTRET, 0); if (status) + { fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, lua_tostring(lua, -1)); + ShowMsg2UTF("Lua script error:", lua_tostring(lua, -1), CMsgBox::mbrBack, CMsgBox::mbBack); + } + } const luaL_Reg CLuaInstance::methods[] = From 5276420b9bd4110d33ab4723fb2de5d0c5b1511a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Fri, 22 Mar 2013 09:20:09 +0100 Subject: [PATCH 05/54] luainstance: show errors from loadfile() Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9bdc0309a727545a3fe106d2367613edc02752d0 Author: Stefan Seyfried Date: 2013-03-22 (Fri, 22 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index d789a38a5..5e0457809 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -76,6 +76,7 @@ void CLuaInstance::runScript(const char *fileName) int status = luaL_loadfile(lua, fileName); if (status) { fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, lua_tostring(lua, -1)); + ShowMsg2UTF("Lua script error:", lua_tostring(lua, -1), CMsgBox::mbrBack, CMsgBox::mbBack); return; } From 8d62a8c553c792748ea1703334a7e56401259c9b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Fri, 22 Mar 2013 13:44:32 +0100 Subject: [PATCH 06/54] luainstance: export variables as tables This exports arrays FONT_TYPE_foo as FONT['foo'], COL_bar als COL['bar'] and SCREEN_OFF_a as SCREEN['OFF_a'] instead of lots of single variables. Later these could also be made dynamic if the need arises. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/fee8c10f427e363745d4ffaca698da429e4cefdd Author: Stefan Seyfried Date: 2013-03-22 (Fri, 22 Mar 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 140 ++++++++++++++++++++++++++-------------- 1 file changed, 93 insertions(+), 47 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 5e0457809..3f48cf9c1 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -30,6 +30,98 @@ #include "luainstance.h" +struct table_key { + const char *name; + long code; +}; + +struct lua_envexport { + const char *name; + table_key *t; +}; + +static void set_lua_variables(lua_State *L) +{ + /* list of colors, exported e.g. as COL['INFOBAR_SHADOW'] */ + static table_key colorlist[] = + { + { "COLORED_EVENTS_CHANNELLIST", COL_COLORED_EVENTS_CHANNELLIST }, + { "COLORED_EVENTS_INFOBAR", COL_COLORED_EVENTS_INFOBAR }, + { "INFOBAR_SHADOW", COL_INFOBAR_SHADOW }, + { "INFOBAR", COL_INFOBAR }, + { "MENUHEAD", COL_MENUHEAD }, + { "MENUCONTENT", COL_MENUCONTENT }, + { "MENUCONTENTDARK", COL_MENUCONTENTDARK }, + { "MENUCONTENTSELECTED", COL_MENUCONTENTSELECTED }, + { "MENUCONTENTINACTIVE", COL_MENUCONTENTINACTIVE }, + { "BACKGROUND", COL_BACKGROUND }, + { NULL, 0 } + }; + + /* font list, the _TYPE_ is redundant, exported e.g. as FONT['MENU'] */ + static table_key fontlist[] = + { + { "MENU", SNeutrinoSettings::FONT_TYPE_MENU }, + { "MENU_TITLE", SNeutrinoSettings::FONT_TYPE_MENU_TITLE }, + { "MENU_INFO", SNeutrinoSettings::FONT_TYPE_MENU_INFO }, + { "EPG_TITLE", SNeutrinoSettings::FONT_TYPE_EPG_TITLE }, + { "EPG_INFO1", SNeutrinoSettings::FONT_TYPE_EPG_INFO1 }, + { "EPG_INFO2", SNeutrinoSettings::FONT_TYPE_EPG_INFO2 }, + { "EPG_DATE", SNeutrinoSettings::FONT_TYPE_EPG_DATE }, + { "EVENTLIST_TITLE", SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE }, + { "EVENTLIST_ITEMLARGE",SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE }, + { "EVENTLIST_ITEMSMALL",SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL }, + { "EVENTLIST_DATETIME", SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME }, + { "GAMELIST_ITEMLARGE", SNeutrinoSettings::FONT_TYPE_GAMELIST_ITEMLARGE }, + { "GAMELIST_ITEMSMALL", SNeutrinoSettings::FONT_TYPE_GAMELIST_ITEMSMALL }, + { "CHANNELLIST", SNeutrinoSettings::FONT_TYPE_CHANNELLIST }, + { "CHANNELLIST_DESCR", SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR }, + { "CHANNELLIST_NUMBER", SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER }, + { "CHANNELLIST_EVENT", SNeutrinoSettings::FONT_TYPE_CHANNELLIST_EVENT }, + { "CHANNEL_NUM_ZAP", SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP }, + { "INFOBAR_NUMBER", SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER }, + { "INFOBAR_CHANNAME", SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME }, + { "INFOBAR_INFO", SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO }, + { "INFOBAR_SMALL", SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL }, + { "FILEBROWSER_ITEM", SNeutrinoSettings::FONT_TYPE_FILEBROWSER_ITEM }, + { "MENU_HINT", SNeutrinoSettings::FONT_TYPE_MENU_HINT }, + { NULL, 0 } + }; + + /* screen offsets, exported as e.g. SCREEN['END_Y'] */ + static table_key screenopts[] = + { + { "OFF_X", g_settings.screen_StartX }, + { "OFF_Y", g_settings.screen_StartY }, + { "END_X", g_settings.screen_EndX }, + { "END_Y", g_settings.screen_EndY }, + { NULL, 0 } + }; + + /* list of environment variable arrays to be exported */ + static lua_envexport e[] = + { + { "COL", colorlist }, + { "SCREEN", screenopts }, + { "FONT", fontlist }, + { NULL, NULL } + }; + + int i = 0; + while (e[i].name) { + int j = 0; + lua_newtable(L); + while (e[i].t[j].name) { + lua_pushstring(L, e[i].t[j].name); + lua_pushinteger(L, e[i].t[j].code); + lua_settable(L, -3); + j++; + } + lua_setglobal(L, e[i].name); + i++; + } +} + #define DBG printf #define lua_boxpointer(L, u) \ @@ -64,9 +156,6 @@ CLuaInstance::~CLuaInstance() #define SET_VAR2(NAME, VALUE) \ lua_pushinteger(lua, VALUE); \ lua_setglobal(lua, #NAME); -#define SET_FONT(NAME) \ - lua_pushinteger(lua, SNeutrinoSettings::NAME); \ - lua_setglobal(lua, #NAME); /* Run the given script. */ void CLuaInstance::runScript(const char *fileName) @@ -79,56 +168,13 @@ void CLuaInstance::runScript(const char *fileName) ShowMsg2UTF("Lua script error:", lua_tostring(lua, -1), CMsgBox::mbrBack, CMsgBox::mbBack); return; } - - /* set variables */ - SET_VAR1(COL_COLORED_EVENTS_CHANNELLIST); - SET_VAR1(COL_COLORED_EVENTS_INFOBAR); - SET_VAR1(COL_INFOBAR_SHADOW); - SET_VAR1(COL_INFOBAR); - SET_VAR1(COL_MENUHEAD); - SET_VAR1(COL_MENUCONTENT); - SET_VAR1(COL_MENUCONTENTDARK); - SET_VAR1(COL_MENUCONTENTSELECTED); - SET_VAR1(COL_MENUCONTENTINACTIVE); - SET_VAR1(COL_BACKGROUND); - - SET_VAR2(SCREEN_OFF_X, g_settings.screen_StartX); - SET_VAR2(SCREEN_OFF_Y, g_settings.screen_StartY); - SET_VAR2(SCREEN_END_X, g_settings.screen_EndX); - SET_VAR2(SCREEN_END_Y, g_settings.screen_EndY); - - SET_FONT(FONT_TYPE_MENU); - SET_FONT(FONT_TYPE_MENU_TITLE); - SET_FONT(FONT_TYPE_MENU_INFO); - SET_FONT(FONT_TYPE_EPG_TITLE); - SET_FONT(FONT_TYPE_EPG_INFO1); - SET_FONT(FONT_TYPE_EPG_INFO2); - SET_FONT(FONT_TYPE_EPG_DATE); - SET_FONT(FONT_TYPE_EVENTLIST_TITLE); - SET_FONT(FONT_TYPE_EVENTLIST_ITEMLARGE); - SET_FONT(FONT_TYPE_EVENTLIST_ITEMSMALL); - SET_FONT(FONT_TYPE_EVENTLIST_DATETIME); - SET_FONT(FONT_TYPE_GAMELIST_ITEMLARGE); - SET_FONT(FONT_TYPE_GAMELIST_ITEMSMALL); - SET_FONT(FONT_TYPE_CHANNELLIST); - SET_FONT(FONT_TYPE_CHANNELLIST_DESCR); - SET_FONT(FONT_TYPE_CHANNELLIST_NUMBER); - SET_FONT(FONT_TYPE_CHANNELLIST_EVENT); - SET_FONT(FONT_TYPE_CHANNEL_NUM_ZAP); - SET_FONT(FONT_TYPE_INFOBAR_NUMBER); - SET_FONT(FONT_TYPE_INFOBAR_CHANNAME); - SET_FONT(FONT_TYPE_INFOBAR_INFO); - SET_FONT(FONT_TYPE_INFOBAR_SMALL); - SET_FONT(FONT_TYPE_FILEBROWSER_ITEM); - SET_FONT(FONT_TYPE_MENU_HINT); - + set_lua_variables(lua); status = lua_pcall(lua, 0, LUA_MULTRET, 0); if (status) { fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, lua_tostring(lua, -1)); ShowMsg2UTF("Lua script error:", lua_tostring(lua, -1), CMsgBox::mbrBack, CMsgBox::mbBack); } - } const luaL_Reg CLuaInstance::methods[] = From ea17e401835612b47cf9a4307d1ae3793569d3c5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Fri, 22 Mar 2013 13:46:45 +0100 Subject: [PATCH 07/54] luainstance: also export RCInput constants Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f43585cbe3dacc76f27eab43a15bc0d7e0a1188b Author: Stefan Seyfried Date: 2013-03-22 (Fri, 22 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 79 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 3f48cf9c1..6b7be3d49 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -42,6 +42,84 @@ struct lua_envexport { static void set_lua_variables(lua_State *L) { + /* keyname table created with + * sed -n '/^[[:space:]]*RC_0/,/^[[:space:]]*RC_analog_off/ { + * s#^[[:space:]]*RC_\([^[:space:]]*\).*# { "\1", CRCInput::RC_\1 },#p + * }' driver/rcinput.h + */ + static table_key keyname[] = + { + { "0", CRCInput::RC_0 }, + { "1", CRCInput::RC_1 }, + { "2", CRCInput::RC_2 }, + { "3", CRCInput::RC_3 }, + { "4", CRCInput::RC_4 }, + { "5", CRCInput::RC_5 }, + { "6", CRCInput::RC_6 }, + { "7", CRCInput::RC_7 }, + { "8", CRCInput::RC_8 }, + { "9", CRCInput::RC_9 }, + { "backspace", CRCInput::RC_backspace }, + { "up", CRCInput::RC_up }, + { "left", CRCInput::RC_left }, + { "right", CRCInput::RC_right }, + { "down", CRCInput::RC_down }, + { "spkr", CRCInput::RC_spkr }, + { "minus", CRCInput::RC_minus }, + { "plus", CRCInput::RC_plus }, + { "standby", CRCInput::RC_standby }, + { "help", CRCInput::RC_help }, + { "home", CRCInput::RC_home }, + { "setup", CRCInput::RC_setup }, + { "topleft", CRCInput::RC_topleft }, + { "topright", CRCInput::RC_topright }, + { "page_up", CRCInput::RC_page_up }, + { "page_down", CRCInput::RC_page_down }, + { "ok", CRCInput::RC_ok }, + { "red", CRCInput::RC_red }, + { "green", CRCInput::RC_green }, + { "yellow", CRCInput::RC_yellow }, + { "blue", CRCInput::RC_blue }, + { "top_left", CRCInput::RC_top_left }, + { "top_right", CRCInput::RC_top_right }, + { "bottom_left", CRCInput::RC_bottom_left }, + { "bottom_right", CRCInput::RC_bottom_right }, + { "audio", CRCInput::RC_audio }, + { "video", CRCInput::RC_video }, + { "tv", CRCInput::RC_tv }, + { "radio", CRCInput::RC_radio }, + { "text", CRCInput::RC_text }, + { "info", CRCInput::RC_info }, + { "epg", CRCInput::RC_epg }, + { "recall", CRCInput::RC_recall }, + { "favorites", CRCInput::RC_favorites }, + { "sat", CRCInput::RC_sat }, + { "sat2", CRCInput::RC_sat2 }, + { "record", CRCInput::RC_record }, + { "play", CRCInput::RC_play }, + { "pause", CRCInput::RC_pause }, + { "forward", CRCInput::RC_forward }, + { "rewind", CRCInput::RC_rewind }, + { "stop", CRCInput::RC_stop }, + { "timeshift", CRCInput::RC_timeshift }, + { "mode", CRCInput::RC_mode }, + { "games", CRCInput::RC_games }, + { "next", CRCInput::RC_next }, + { "prev", CRCInput::RC_prev }, + { "www", CRCInput::RC_www }, + { "power_on", CRCInput::RC_power_on }, + { "power_off", CRCInput::RC_power_off }, + { "standby_on", CRCInput::RC_standby_on }, + { "standby_off", CRCInput::RC_standby_off }, + { "mute_on", CRCInput::RC_mute_on }, + { "mute_off", CRCInput::RC_mute_off }, + { "analog_on", CRCInput::RC_analog_on }, + { "analog_off", CRCInput::RC_analog_off }, + /* to check if it is in our range */ + { "MaxRC", CRCInput::RC_MaxRC }, + { NULL, 0 } + }; + /* list of colors, exported e.g. as COL['INFOBAR_SHADOW'] */ static table_key colorlist[] = { @@ -101,6 +179,7 @@ static void set_lua_variables(lua_State *L) /* list of environment variable arrays to be exported */ static lua_envexport e[] = { + { "RC", keyname }, { "COL", colorlist }, { "SCREEN", screenopts }, { "FONT", fontlist }, From fac400e38e3c4d06d813ea3885fef684846d857b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Fri, 22 Mar 2013 22:22:21 +0100 Subject: [PATCH 08/54] luainstance: export FontHeight to Lua scripts Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f7fc13becdb78df9c51c5039ffd2d7cdeeedd64e Author: Stefan Seyfried Date: 2013-03-22 (Fri, 22 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 16 ++++++++++++++++ src/gui/luainstance.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 6b7be3d49..30bdbf6e0 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -262,6 +262,7 @@ const luaL_Reg CLuaInstance::methods[] = { "RenderString", CLuaInstance::RenderString }, { "PaintIcon", CLuaInstance::PaintIcon }, { "GetInput", CLuaInstance::GetInput }, + { "FontHeight", CLuaInstance::FontHeight }, { NULL, NULL } }; @@ -439,6 +440,21 @@ int CLuaInstance::GetInput(lua_State *L) return 2; } +int CLuaInstance::FontHeight(lua_State *L) +{ + int f; + DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); + + CLuaData *W = CheckData(L, 1); + if (!W) + return 0; + f = luaL_checkint(L, 2); /* font number, use FONT['xxx'] for FONT_TYPE_xxx in the script */ + if (f >= FONT_TYPE_COUNT || f < 0) + f = SNeutrinoSettings::FONT_TYPE_MENU; + lua_pushinteger(L, (int)g_Font[f]->getHeight()); + return 1; +} + int CLuaInstance::GCWindow(lua_State *L) { DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 24cb73123..fe1a250ff 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -53,6 +53,7 @@ private: static int PaintBox(lua_State *L); static int PaintIcon(lua_State *L); static int RenderString(lua_State *L); + static int FontHeight(lua_State *L); static int GetInput(lua_State *L); static int GCWindow(lua_State *L); }; From ea0c70e2b1198435700f1c5b3da0c2777d88afc5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 24 Mar 2013 13:15:13 +0100 Subject: [PATCH 09/54] luainstance: dynamic values are not static Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/56db06436835b7ba6a6762d7275da701482d3545 Author: Stefan Seyfried Date: 2013-03-24 (Sun, 24 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 30bdbf6e0..cbd0bff29 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -167,7 +167,7 @@ static void set_lua_variables(lua_State *L) }; /* screen offsets, exported as e.g. SCREEN['END_Y'] */ - static table_key screenopts[] = + table_key screenopts[] = { { "OFF_X", g_settings.screen_StartX }, { "OFF_Y", g_settings.screen_StartY }, @@ -177,7 +177,7 @@ static void set_lua_variables(lua_State *L) }; /* list of environment variable arrays to be exported */ - static lua_envexport e[] = + lua_envexport e[] = { { "RC", keyname }, { "COL", colorlist }, From 3ae75d9992a63198ffc9d3705415af834db88349 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 24 Mar 2013 19:26:10 +0100 Subject: [PATCH 10/54] luainstance: allow rounded corners in PaintBox Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a73dfbb2c5c2c5f75a0108e528d7d514a40b537c Author: Stefan Seyfried Date: 2013-03-24 (Sun, 24 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index cbd0bff29..232b0b487 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -166,6 +166,19 @@ static void set_lua_variables(lua_State *L) { NULL, 0 } }; + table_key corners[] = + { + { "TOP_LEFT", CORNER_TOP_LEFT }, + { "TOP_RIGHT", CORNER_TOP_RIGHT }, + { "BOTTOM_LEFT", CORNER_BOTTOM_LEFT }, + { "BOTTOM_RIGHT", CORNER_BOTTOM_RIGHT }, + { "RADIUS_LARGE", RADIUS_LARGE }, /* those depend on g_settings.rounded_corners */ + { "RADIUS_MID", RADIUS_MID }, + { "RADIUS_SMALL", RADIUS_SMALL }, + { "RADIUS_MIN", RADIUS_MIN }, + { NULL, 0 } + }; + /* screen offsets, exported as e.g. SCREEN['END_Y'] */ table_key screenopts[] = { @@ -183,6 +196,7 @@ static void set_lua_variables(lua_State *L) { "COL", colorlist }, { "SCREEN", screenopts }, { "FONT", fontlist }, + { "CORNER", corners }, { NULL, NULL } }; @@ -266,6 +280,11 @@ const luaL_Reg CLuaInstance::methods[] = { NULL, NULL } }; +#ifndef DYNAMIC_LUAPOSIX +/* hack: we link against luaposix, which is included in our + * custom built lualib */ +extern "C" { LUAMOD_API int (luaopen_posix_c) (lua_State *L); } +#endif /* load basic functions and register our own C callbacks */ void CLuaInstance::registerFunctions() { @@ -274,6 +293,9 @@ void CLuaInstance::registerFunctions() luaopen_io(lua); luaopen_string(lua); luaopen_math(lua); +#ifndef DYNAMIC_LUAPOSIX + luaopen_posix_c(lua); +#endif lua_newtable(lua); int methodtable = lua_gettop(lua); @@ -335,8 +357,9 @@ int CLuaInstance::NewWindow(lua_State *L) int CLuaInstance::PaintBox(lua_State *L) { - DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); - int x, y, w, h; + int count = lua_gettop(L); + DBG("CLuaInstance::%s %d\n", __func__, count); + int x, y, w, h, radius = 0, corner = CORNER_ALL; unsigned int c; CLuaData *W = CheckData(L, 1); @@ -347,6 +370,10 @@ int CLuaInstance::PaintBox(lua_State *L) w = luaL_checkint(L, 4); h = luaL_checkint(L, 5); c = luaL_checkint(L, 6); + if (count > 6) + radius = luaL_checkint(L, 7); + if (count > 7) + corner = luaL_checkint(L, 8); /* those checks should be done in CFBWindow instead... */ if (x < 0) x = 0; @@ -358,7 +385,7 @@ int CLuaInstance::PaintBox(lua_State *L) h = W->fbwin->dy - y; /* use the color constants */ c = CFrameBuffer::getInstance()->realcolor[c & 0xff]; - W->fbwin->paintBoxRel(x, y, w, h, c); + W->fbwin->paintBoxRel(x, y, w, h, c, radius, corner); return 0; } From 5354846491b2894c1b0d86196b5b8f33cf9bdfff Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 6 Apr 2013 12:26:24 +0200 Subject: [PATCH 11/54] luainstance: allow any color for PaintBox, disable debug Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ef512f897a897b4a1aeef1b7a2797a3666f89246 Author: Stefan Seyfried Date: 2013-04-06 (Sat, 06 Apr 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 232b0b487..d979989dc 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -30,6 +30,10 @@ #include "luainstance.h" +/* the magic color that tells us we are using one of the palette colors */ +#define MAGIC_COLOR 0x42424200 +#define MAGIC_MASK 0xFFFFFF00 + struct table_key { const char *name; long code; @@ -123,16 +127,16 @@ static void set_lua_variables(lua_State *L) /* list of colors, exported e.g. as COL['INFOBAR_SHADOW'] */ static table_key colorlist[] = { - { "COLORED_EVENTS_CHANNELLIST", COL_COLORED_EVENTS_CHANNELLIST }, - { "COLORED_EVENTS_INFOBAR", COL_COLORED_EVENTS_INFOBAR }, - { "INFOBAR_SHADOW", COL_INFOBAR_SHADOW }, - { "INFOBAR", COL_INFOBAR }, - { "MENUHEAD", COL_MENUHEAD }, - { "MENUCONTENT", COL_MENUCONTENT }, - { "MENUCONTENTDARK", COL_MENUCONTENTDARK }, - { "MENUCONTENTSELECTED", COL_MENUCONTENTSELECTED }, - { "MENUCONTENTINACTIVE", COL_MENUCONTENTINACTIVE }, - { "BACKGROUND", COL_BACKGROUND }, + { "COLORED_EVENTS_CHANNELLIST", MAGIC_COLOR | (COL_COLORED_EVENTS_CHANNELLIST) }, + { "COLORED_EVENTS_INFOBAR", MAGIC_COLOR | (COL_COLORED_EVENTS_INFOBAR) }, + { "INFOBAR_SHADOW", MAGIC_COLOR | (COL_INFOBAR_SHADOW) }, + { "INFOBAR", MAGIC_COLOR | (COL_INFOBAR) }, + { "MENUHEAD", MAGIC_COLOR | (COL_MENUHEAD) }, + { "MENUCONTENT", MAGIC_COLOR | (COL_MENUCONTENT) }, + { "MENUCONTENTDARK", MAGIC_COLOR | (COL_MENUCONTENTDARK) }, + { "MENUCONTENTSELECTED", MAGIC_COLOR | (COL_MENUCONTENTSELECTED) }, + { "MENUCONTENTINACTIVE", MAGIC_COLOR | (COL_MENUCONTENTINACTIVE) }, + { "BACKGROUND", MAGIC_COLOR | (COL_BACKGROUND) }, { NULL, 0 } }; @@ -215,7 +219,8 @@ static void set_lua_variables(lua_State *L) } } -#define DBG printf +//#define DBG printf +#define DBG(...) #define lua_boxpointer(L, u) \ (*(void **)(lua_newuserdata(L, sizeof(void *))) = (u)) @@ -384,7 +389,8 @@ int CLuaInstance::PaintBox(lua_State *L) if (h < 0 || y + h > W->fbwin->dy) h = W->fbwin->dy - y; /* use the color constants */ - c = CFrameBuffer::getInstance()->realcolor[c & 0xff]; + if ((c & MAGIC_MASK) == MAGIC_COLOR) + c = CFrameBuffer::getInstance()->realcolor[c & 0x000000ff]; W->fbwin->paintBoxRel(x, y, w, h, c, radius, corner); return 0; } @@ -438,6 +444,7 @@ int CLuaInstance::RenderString(lua_State *L) utf8 = luaL_checkint(L, 9); if (f >= FONT_TYPE_COUNT || f < 0) f = SNeutrinoSettings::FONT_TYPE_MENU; + c &= 0x000000FF; /* TODO: colors that are not in the palette? */ W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, utf8); return 0; } From 2c7777ef6862fbc9499492a3402f4fe798865c5c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 6 Apr 2013 19:06:46 +0200 Subject: [PATCH 12/54] luainstance: work around a signed/unsigned problem on ppc Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/8af79e11525b24e54e2e6adf98be155f9cd6a032 Author: Stefan Seyfried Date: 2013-04-06 (Sat, 06 Apr 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index d979989dc..3be1806b7 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -374,7 +374,8 @@ int CLuaInstance::PaintBox(lua_State *L) y = luaL_checkint(L, 3); w = luaL_checkint(L, 4); h = luaL_checkint(L, 5); - c = luaL_checkint(L, 6); + /* luaL_checkint does not like e.g. 0xffcc0000 on powerpc (returns INT_MAX) instead */ + c = (unsigned int)luaL_checknumber(L, 6); if (count > 6) radius = luaL_checkint(L, 7); if (count > 7) From 9d1589525f84f5d55101bf5878420b2a16cca566 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 7 Apr 2013 18:18:02 +0200 Subject: [PATCH 13/54] luainstance: export customcolor.h colors, too Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3f57d7c5287119818fd5f44d07852e03c0cf8cda Author: Stefan Seyfried Date: 2013-04-07 (Sun, 07 Apr 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 3be1806b7..9e3a0bb98 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -137,6 +137,19 @@ static void set_lua_variables(lua_State *L) { "MENUCONTENTSELECTED", MAGIC_COLOR | (COL_MENUCONTENTSELECTED) }, { "MENUCONTENTINACTIVE", MAGIC_COLOR | (COL_MENUCONTENTINACTIVE) }, { "BACKGROUND", MAGIC_COLOR | (COL_BACKGROUND) }, + { "DARK_RED", MAGIC_COLOR | (COL_DARK_RED0) }, + { "DARK_GREEN", MAGIC_COLOR | (COL_DARK_GREEN0) }, + { "DARK_BLUE", MAGIC_COLOR | (COL_DARK_BLUE0) }, + { "LIGHT_GRAY", MAGIC_COLOR | (COL_LIGHT_GRAY0) }, + { "DARK_GRAY", MAGIC_COLOR | (COL_DARK_GRAY0) }, + { "RED", MAGIC_COLOR | (COL_RED0) }, + { "GREEN", MAGIC_COLOR | (COL_GREEN0) }, + { "YELLOW", MAGIC_COLOR | (COL_YELLOW0) }, + { "BLUE", MAGIC_COLOR | (COL_BLUE0) }, + { "PURP", MAGIC_COLOR | (COL_PURP0) }, + { "LIGHT_BLUE", MAGIC_COLOR | (COL_LIGHT_BLUE0) }, + { "WHITE", MAGIC_COLOR | (COL_WHITE0) }, + { "BLACK", MAGIC_COLOR | (COL_BLACK0) }, { NULL, 0 } }; From e0e54236d20149e211e45ab138827798f838c292 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 7 Apr 2013 18:18:38 +0200 Subject: [PATCH 14/54] luainstance: remove utf8 parameter from RenderString, add center Everybody should always be using utf8 anyway, so remove the "utf8" parameter from RenderString and replace it with a "center" parameter which centers the string horizontally in its box. new usage: RenderString(font, text, x, y, color, boxwidth, boxheight, center) defaults: color = COL_MENUCONTENT, boxwidth = window's width minus x boxheight = 0, center = 0 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7c7c7e55a4be89cc6969e48a8f262ec3514fb2e1 Author: Stefan Seyfried Date: 2013-04-07 (Sun, 07 Apr 2013) Origin message was: ------------------ luainstance: remove utf8 parameter from RenderString, add center Everybody should always be using utf8 anyway, so remove the "utf8" parameter from RenderString and replace it with a "center" parameter which centers the string horizontally in its box. new usage: RenderString(font, text, x, y, color, boxwidth, boxheight, center) defaults: color = COL_MENUCONTENT, boxwidth = window's width minus x boxheight = 0, center = 0 ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 9e3a0bb98..b1a83ddde 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -430,14 +430,14 @@ int CLuaInstance::PaintIcon(lua_State *L) int CLuaInstance::RenderString(lua_State *L) { - int x, y, w, boxh, utf8, f; + int x, y, w, boxh, f, center; unsigned int c; const char *text; int numargs = lua_gettop(L); DBG("CLuaInstance::%s %d\n", __func__, numargs); c = COL_MENUCONTENT; boxh = 0; - utf8 = 1; + center = 0; CLuaData *W = CheckData(L, 1); if (!W || !W->fbwin) @@ -455,11 +455,16 @@ int CLuaInstance::RenderString(lua_State *L) if (numargs > 7) boxh = luaL_checkint(L, 8); if (numargs > 8) - utf8 = luaL_checkint(L, 9); - if (f >= FONT_TYPE_COUNT || f < 0) + center = luaL_checkint(L, 9); + if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0) f = SNeutrinoSettings::FONT_TYPE_MENU; + if (center) { /* center the text inside the box */ + int rwidth = g_Font[f]->getRenderWidth(text, true); + if (rwidth < w) + x += (w - rwidth) / 2; + } c &= 0x000000FF; /* TODO: colors that are not in the palette? */ - W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, utf8); + W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, true); return 0; } @@ -497,7 +502,7 @@ int CLuaInstance::FontHeight(lua_State *L) if (!W) return 0; f = luaL_checkint(L, 2); /* font number, use FONT['xxx'] for FONT_TYPE_xxx in the script */ - if (f >= FONT_TYPE_COUNT || f < 0) + if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0) f = SNeutrinoSettings::FONT_TYPE_MENU; lua_pushinteger(L, (int)g_Font[f]->getHeight()); return 1; From 7f612417032bd05c74c5c8cf66ec4dffc8d1de33 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 7 Apr 2013 18:54:57 +0200 Subject: [PATCH 15/54] luainstance: return render width from RenderString Return the string's renderwidth from RenderString. If boxh is < 0 then the string is not rendered and only the width is determined. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a61dbcee0bbcd15780574f3ad795c293c553fe20 Author: Stefan Seyfried Date: 2013-04-07 (Sun, 07 Apr 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index b1a83ddde..d893ad4dd 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -458,14 +458,16 @@ int CLuaInstance::RenderString(lua_State *L) center = luaL_checkint(L, 9); if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0) f = SNeutrinoSettings::FONT_TYPE_MENU; + int rwidth = g_Font[f]->getRenderWidth(text, true); if (center) { /* center the text inside the box */ - int rwidth = g_Font[f]->getRenderWidth(text, true); if (rwidth < w) x += (w - rwidth) / 2; } c &= 0x000000FF; /* TODO: colors that are not in the palette? */ - W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, true); - return 0; + if (boxh > -1) /* if boxh < 0, don't paint string */ + W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, true); + lua_pushinteger(L, rwidth); /* return renderwidth */ + return 1; } int CLuaInstance::GetInput(lua_State *L) From fdeb112c639516ebc8429becd28708f931d0f52f Mon Sep 17 00:00:00 2001 From: Christian Ege Date: Sun, 28 Apr 2013 09:28:13 +0200 Subject: [PATCH 16/54] handling of luaposix for dynamic environment Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/53ed75f66de8e36be0e0a4b48a94553705bc339e Author: Christian Ege Date: 2013-04-28 (Sun, 28 Apr 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index d893ad4dd..8afc712fd 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -302,6 +302,30 @@ const luaL_Reg CLuaInstance::methods[] = /* hack: we link against luaposix, which is included in our * custom built lualib */ extern "C" { LUAMOD_API int (luaopen_posix_c) (lua_State *L); } +#else +static int dolibrary (lua_State *L, const char *name) +{ + int status = 0; + const char *msg = ""; + lua_getglobal(L, "require"); + lua_pushstring(L, name); + status = lua_pcall(L, 1, 0, 0); + if (status && !lua_isnil(L, -1)) + { + msg = lua_tostring(L, -1); + if (NULL == msg) + { + msg = "(error object is not a string)"; + } + fprintf(stderr, "[CLuaInstance::%s] error in dolibrary: %s (%s)\n", __func__, name,msg); + lua_pop(L, 1); + } + else + { + printf("[CLuaInstance::%s] loaded library: %s\n", __func__, name); + } + return status; +} #endif /* load basic functions and register our own C callbacks */ void CLuaInstance::registerFunctions() @@ -313,6 +337,8 @@ void CLuaInstance::registerFunctions() luaopen_math(lua); #ifndef DYNAMIC_LUAPOSIX luaopen_posix_c(lua); +#else + dolibrary(lua,"posix"); #endif lua_newtable(lua); From 6df70a56d021fa68130ae6383ac66cd7af55f93e Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 27 May 2013 13:36:50 +0200 Subject: [PATCH 17/54] configure: try to autodetect lualib Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/966c7f13797ff3f466c3b2d55b98347a2ca83937 Author: Stefan Seyfried Date: 2013-05-27 (Mon, 27 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- configure.ac | 13 +++++++++++++ src/Makefile.am | 2 +- src/gui/Makefile.am | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fbd243680..9da436a10 100644 --- a/configure.ac +++ b/configure.ac @@ -94,6 +94,17 @@ TUXBOX_APPS_LIB_PKGCONFIG(PNG,libpng) TUXBOX_APPS_LIB_PKGCONFIG(AVFORMAT,libavformat) TUXBOX_APPS_LIB_PKGCONFIG(AVCODEC,libavcodec) TUXBOX_APPS_LIB_PKGCONFIG(AVUTIL,libavutil) + +# either use dynamic lualib in package lua (openSUSE) +# ... or in package lua5.2 (debian-derivates) +# ... and if all fails, assume it is in the linker path (cross build) +PKG_CHECK_MODULES([LUA], [lua >= 5.2], echo "lua >= 5.2 found", [ + PKG_CHECK_MODULES([LUA], [lua5.2 >= 5.2], echo "lua5.2 found", [ + echo "=> lualib not found, assuming static lua in linker path..." + LUA_LIBS="-llua -ldl" + ]) +]) + #TUXBOX_APPS_LIB_PKGCONFIG(CONFIGFILE,tuxbox-configfile) #TUXBOX_APPS_LIB_PKGCONFIG(CONNECTION,tuxbox-connection) #TUXBOX_APPS_LIB_PKGCONFIG(EVENTSERVER,tuxbox-eventserver) @@ -202,6 +213,8 @@ AC_SUBST(FREETYPE_CFLAGS) AC_SUBST(FREETYPE_LIBS) AC_SUBST(VORBISIDEC_CFLAGS) AC_SUBST(VORBISIDEC_LIBS) +AC_SUBST(LUA_CFLAGS) +AC_SUBST(LUA_LIBS) AC_OUTPUT([ Makefile diff --git a/src/Makefile.am b/src/Makefile.am index f80eed707..c3630c191 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,7 +122,7 @@ neutrino_LDADD += -lgif else neutrino_LDADD += -lungif endif -neutrino_LDADD += -llua -ldl +neutrino_LDADD += @LUA_LIBS@ if ENABLE_UPNP neutrino_LDADD += \ diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index d0da43b10..6f13bfacb 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -28,6 +28,7 @@ AM_CPPFLAGS += \ -I$(top_srcdir)/lib/xmltree \ -I$(top_srcdir)/lib/libupnpclient \ @CURL_CFLAGS@ \ + @LUA_CFLAGS@ \ @FREETYPE_CFLAGS@ if BOXTYPE_COOL From 74f58b383c8fd377a9d9bd13b1f13fb9e8cf3f88 Mon Sep 17 00:00:00 2001 From: martii Date: Thu, 29 Aug 2013 17:56:08 +0200 Subject: [PATCH 18/54] luainstance: support new text coloring scheme Signed-off-by: Stefan Seyfried Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c0a720bd8bee4ce8eec89b6f57aa4989db2faa07 Author: martii Date: 2013-08-29 (Thu, 29 Aug 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 8afc712fd..1db573b2d 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -150,6 +150,21 @@ static void set_lua_variables(lua_State *L) { "LIGHT_BLUE", MAGIC_COLOR | (COL_LIGHT_BLUE0) }, { "WHITE", MAGIC_COLOR | (COL_WHITE0) }, { "BLACK", MAGIC_COLOR | (COL_BLACK0) }, + { "COLORED_EVENTS_TEXT", (COL_COLORED_EVENTS_TEXT) }, + { "INFOBAR_TEXT", (COL_INFOBAR_TEXT) }, + { "INFOBAR_SHADOW_TEXT", (COL_INFOBAR_SHADOW_TEXT) }, + { "MENUHEAD_TEXT", (COL_MENUHEAD_TEXT) }, + { "MENUCONTENT_TEXT", (COL_MENUCONTENT_TEXT) }, + { "MENUCONTENT_TEXT_PLUS_1", (COL_MENUCONTENT_TEXT_PLUS_1) }, + { "MENUCONTENT_TEXT_PLUS_2", (COL_MENUCONTENT_TEXT_PLUS_2) }, + { "MENUCONTENT_TEXT_PLUS_3", (COL_MENUCONTENT_TEXT_PLUS_3) }, + { "MENUCONTENTDARK_TEXT", (COL_MENUCONTENTDARK_TEXT) }, + { "MENUCONTENTDARK_TEXT_PLUS_1", (COL_MENUCONTENTDARK_TEXT_PLUS_1) }, + { "MENUCONTENTDARK_TEXT_PLUS_2", (COL_MENUCONTENTDARK_TEXT_PLUS_2) }, + { "MENUCONTENTSELECTED_TEXT", (COL_MENUCONTENTSELECTED_TEXT) }, + { "MENUCONTENTSELECTED_TEXT_PLUS_1", (COL_MENUCONTENTSELECTED_TEXT_PLUS_1) }, + { "MENUCONTENTSELECTED_TEXT_PLUS_2", (COL_MENUCONTENTSELECTED_TEXT_PLUS_2) }, + { "MENUCONTENTINACTIVE_TEXT", (COL_MENUCONTENTINACTIVE_TEXT) }, { NULL, 0 } }; @@ -461,7 +476,7 @@ int CLuaInstance::RenderString(lua_State *L) const char *text; int numargs = lua_gettop(L); DBG("CLuaInstance::%s %d\n", __func__, numargs); - c = COL_MENUCONTENT; + c = COL_MENUCONTENT_TEXT; boxh = 0; center = 0; @@ -489,7 +504,8 @@ int CLuaInstance::RenderString(lua_State *L) if (rwidth < w) x += (w - rwidth) / 2; } - c &= 0x000000FF; /* TODO: colors that are not in the palette? */ + if ((c & MAGIC_MASK) == MAGIC_COLOR) + c = CFrameBuffer::getInstance()->realcolor[c & 0x000000ff]; if (boxh > -1) /* if boxh < 0, don't paint string */ W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, true); lua_pushinteger(L, rwidth); /* return renderwidth */ From 917e8aafa4df41f16a537f75de4bf9d8c6e925ac Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Thu, 16 Jan 2014 21:15:55 +0100 Subject: [PATCH 19/54] Preparing the menu classes for Lua Part #1 - Remove CNonLocalizedMenuSeparator - Add overloaded function CMenuSeparator for non local THX Martii Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2c9c9debccc17cefe793ceba05308c60c570017b Author: Michael Liebmann Date: 2014-01-16 (Thu, 16 Jan 2014) Origin message was: ------------------ Preparing the menu classes for Lua Part #1 - Remove CNonLocalizedMenuSeparator - Add overloaded function CMenuSeparator for non local THX Martii ------------------ This commit was generated by Migit --- src/gui/personalize.cpp | 2 +- src/gui/update.cpp | 2 +- src/gui/widget/menue.cpp | 118 +++++++++++++++++++++++++-------------- src/gui/widget/menue.h | 72 +++++++++++++----------- 4 files changed, 117 insertions(+), 77 deletions(-) diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index d9637f11a..7a2ed7331 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -491,7 +491,7 @@ int CPersonalizeGui::ShowMenuOptions(const int& widget) CMenuSeparator * pm_subhead = new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING); string s_sh = g_Locale->getText(LOCALE_PERSONALIZE_ACCESS); s_sh += ": " + mn_name; - pm_subhead->setString(s_sh); + pm_subhead->setName(s_sh); pm->addItem(pm_subhead); pm->addIntroItems(); diff --git a/src/gui/update.cpp b/src/gui/update.cpp index f705165fb..c9a725678 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -194,7 +194,7 @@ bool CFlashUpdate::selectHttpImage(void) } //updates_lists.push_back(url.substr(startpos, endpos - startpos)); - SelectionWidget.addItem(new CNonLocalizedMenuSeparator(updates_lists.rbegin()->c_str(), LOCALE_FLASHUPDATE_SELECTIMAGE)); + SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, updates_lists.rbegin()->c_str())); if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20)) { std::ifstream in(gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index d622db8c3..83838687f 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -56,25 +56,29 @@ CMenuForwarder * const GenericMenuNext = &CGenericMenuNext; CMenuItem::CMenuItem() { - x = -1; - directKey = CRCInput::RC_nokey; - iconName = ""; + x = -1; + directKey = CRCInput::RC_nokey; + iconName = ""; iconName_Info_right = ""; - used = false; - icon_frame_w = 10; - hint = NONEXISTANT_LOCALE; - isStatic = false; + used = false; + icon_frame_w = 10; + hint = NONEXISTANT_LOCALE; + name = NONEXISTANT_LOCALE; + nameString = ""; + isStatic = false; + marked = false; + inert = false; } void CMenuItem::init(const int X, const int Y, const int DX, const int OFFX) { - x = X; - y = Y; - dx = DX; - offx = OFFX; - name_start_x = x + offx + icon_frame_w; - item_color = COL_MENUCONTENT_TEXT; - item_bgcolor = COL_MENUCONTENT_PLUS_0; + x = X; + y = Y; + dx = DX; + offx = OFFX; + name_start_x = x + offx + icon_frame_w; + item_color = COL_MENUCONTENT_TEXT; + item_bgcolor = COL_MENUCONTENT_PLUS_0; } void CMenuItem::setActive(const bool Active) @@ -87,6 +91,20 @@ void CMenuItem::setActive(const bool Active) paint(); } +void CMenuItem::setMarked(const bool Marked) +{ + marked = Marked; + if (used && x != -1) + paint(); +} + +void CMenuItem::setInert(const bool Inert) +{ + inert = Inert; + if (used && x != -1) + paint(); +} + void CMenuItem::setItemButton(const std::string& icon_Name, const bool is_select_button) { if (is_select_button) @@ -102,11 +120,16 @@ void CMenuItem::initItemColors(const bool select_mode) item_color = COL_MENUCONTENTSELECTED_TEXT; item_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; } - else if (!active) + else if (!active || inert) { item_color = COL_MENUCONTENTINACTIVE_TEXT; item_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0; } + else if (marked) + { + item_color = COL_MENUCONTENT_TEXT; + item_bgcolor = COL_MENUCONTENT_PLUS_1; + } else { item_color = COL_MENUCONTENT_TEXT; @@ -281,6 +304,13 @@ void CMenuItem::paintItemButton(const bool select_mode, const int &item_height, } } +const char *CMenuItem::getName(void) +{ + if (name != NONEXISTANT_LOCALE) + return g_Locale->getText(name); + return nameString.c_str(); +} + //small helper class to manage values e.g.: handling needed but deallocated widget objects CMenuGlobal::CMenuGlobal() { @@ -1151,10 +1181,10 @@ void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::stri } //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn) +CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name1, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionName = name; + optionName = name1; active = Active; optionValue = OptionValue; @@ -1930,33 +1960,41 @@ CMenuDForwarderNonLocalized::~CMenuDForwarderNonLocalized() //------------------------------------------------------------------------------------------------------------------------------- CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic) { - directKey = CRCInput::RC_nokey; - iconName = ""; - type = Type; - text = Text; - isStatic = IsStatic; + directKey = CRCInput::RC_nokey; + iconName = ""; + type = Type; + name = Text; + nameString = ""; + isStatic = IsStatic; } +CMenuSeparator::CMenuSeparator(const int Type, const std::string Text, bool IsStatic) +{ + directKey = CRCInput::RC_nokey; + iconName = ""; + type = Type; + name = NONEXISTANT_LOCALE; + nameString = Text; + isStatic = IsStatic; +} int CMenuSeparator::getHeight(void) const { - if (separator_text.empty() && text == NONEXISTANT_LOCALE) + if (nameString.empty() && name == NONEXISTANT_LOCALE) return 10; - else - return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); } -const char * CMenuSeparator::getString(void) +void CMenuSeparator::setName(const std::string& t) { - if (!separator_text.empty()) - return separator_text.c_str(); - else - return g_Locale->getText(text); + name = NONEXISTANT_LOCALE; + nameString = t; } -void CMenuSeparator::setString(const std::string& s_text) +void CMenuSeparator::setName(const neutrino_locale_t t) { - separator_text = s_text; + name = t; + nameString = ""; } int CMenuSeparator::getWidth(void) @@ -1964,11 +2002,9 @@ int CMenuSeparator::getWidth(void) int w = 0; if (type & LINE) w = 30; /* 15 pixel left and right */ - if ((type & STRING) && text != NONEXISTANT_LOCALE) - { - const char *l_text = getString(); - w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true); - } + const char *l_name = getName(); + if ((type & STRING) && *l_name) + w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true); return w; } @@ -1996,11 +2032,11 @@ int CMenuSeparator::paint(bool selected) } if ((type & STRING)) { - const char * l_text = getString(); + const char * l_name = getName(); - if (text != NONEXISTANT_LOCALE || strlen(l_text) != 0) + if (*l_name) { - int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true); // UTF-8 + int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true); // UTF-8 /* if no alignment is specified, align centered */ if (type & ALIGN_LEFT) @@ -2012,7 +2048,7 @@ int CMenuSeparator::paint(bool selected) frameBuffer->paintBoxRel(name_start_x-5, y, stringwidth+10, height, item_bgcolor); - paintItemCaption(selected, height, l_text); + paintItemCaption(selected, height, l_name); } } return y+ height; diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index d5b067093..5e0d826a2 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -45,6 +45,12 @@ #include #include +extern "C" { +#include +#include +#include +} + #define NO_WIDGET_ID -1 typedef int mn_widget_id_t; @@ -90,16 +96,24 @@ class CMenuItem fb_pixel_t item_color, item_bgcolor; void initItemColors(const bool select_mode); - + lua_State *luaState; + std::string luaAction; + std::string luaId; + neutrino_locale_t name; + std::string nameString; + public: - bool active; + bool active; + bool marked; + bool inert; bool isStatic; neutrino_msg_t directKey; neutrino_msg_t msg; - std::string iconName; - std::string selected_iconName; - std::string iconName_Info_right; + std::string iconName; + std::string selected_iconName; + std::string iconName_Info_right; std::string hintIcon; + std::string hintText; neutrino_locale_t hint; CMenuItem(); @@ -130,6 +144,8 @@ class CMenuItem return 0; } virtual void setActive(const bool Active); + virtual void setMarked(const bool Marked); + virtual void setInert(const bool Inert); virtual void paintItemButton(const bool select_mode, const int &item_height, const std::string& icon_Name = NEUTRINO_ICON_BUTTON_RIGHT); @@ -144,54 +160,42 @@ class CMenuItem virtual void paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text=NULL, const char * right_text=NULL); virtual int isMenueOptionChooser(void) const{return 0;} - void setHint(std::string icon, neutrino_locale_t text) { hintIcon = icon; hint = text; } + 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; } + + void setLua(lua_State *_luaState, std::string &_luaAction, std::string &_luaId) { luaState = _luaState; luaAction = _luaAction; luaId = _luaId; }; + + virtual const char *getName(); }; class CMenuSeparator : public CMenuItem { - int type; - std::string separator_text; + int type; public: - neutrino_locale_t text; enum { - EMPTY = 0, - LINE = 1, - STRING = 2, - ALIGN_CENTER = 4, - ALIGN_LEFT = 8, - ALIGN_RIGHT = 16, - SUB_HEAD = 32 + EMPTY = 0, + LINE = 1, + STRING = 2, + ALIGN_CENTER = 4, + ALIGN_LEFT = 8, + ALIGN_RIGHT = 16, + SUB_HEAD = 32 }; CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE, bool IsStatic = false); + CMenuSeparator(const int Type, const std::string Text, bool IsStatic = false); virtual ~CMenuSeparator(){} int paint(bool selected=false); int getHeight(void) const; int getWidth(void); - virtual const char * getString(void); - void setString(const std::string& text); -}; - -class CNonLocalizedMenuSeparator : public CMenuSeparator -{ - const char * the_text; - -public: - CNonLocalizedMenuSeparator(const char * ptext, const neutrino_locale_t Text1) : CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, Text1) - { - the_text = ptext; - } - - virtual const char * getString(void) - { - return the_text; - } + void setName(const std::string& text); + void setName(const neutrino_locale_t text); }; class CMenuForwarder : public CMenuItem From 7b4e3bc03bb1a8a2285eff555fa4477b2aad22c3 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Thu, 16 Jan 2014 23:20:04 +0100 Subject: [PATCH 20/54] Preparing the menu classes for Lua Part #2 - Remove CMenuForwarderNonLocalized - Add overloaded function CMenuForwarder for non local THX Martii Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b41819190dbce023ab7ebacb5e45442c16f10ce5 Author: Michael Liebmann Date: 2014-01-16 (Thu, 16 Jan 2014) Origin message was: ------------------ Preparing the menu classes for Lua Part #2 - Remove CMenuForwarderNonLocalized - Add overloaded function CMenuForwarder for non local THX Martii ------------------ This commit was generated by Migit --- lib/timerdclient/timerdclient.cpp | 15 +- lib/timerdclient/timerdclient.h | 4 +- src/driver/record.cpp | 4 +- src/gui/audio_select.cpp | 6 +- src/gui/cam_menu.cpp | 18 +- src/gui/eventlist.cpp | 4 +- src/gui/eventlist.h | 2 +- src/gui/hdd_menu.cpp | 2 +- src/gui/miscsettings_menu.cpp | 6 +- src/gui/moviebrowser.cpp | 8 +- src/gui/movieplayer.cpp | 6 +- src/gui/network_setup.cpp | 4 +- src/gui/nfs.cpp | 4 +- src/gui/nfs.h | 2 +- src/gui/osd_setup.cpp | 44 ++-- src/gui/personalize.cpp | 6 +- src/gui/scan_setup.cpp | 10 +- src/gui/sleeptimer.cpp | 47 ++-- src/gui/sleeptimer.h | 6 +- src/gui/subchannel_select.cpp | 4 +- src/gui/test_menu.cpp | 64 +++--- src/gui/themes.cpp | 4 +- src/gui/timerlist.cpp | 38 ++-- src/gui/timerlist.h | 2 +- src/gui/update.cpp | 14 +- src/gui/user_menue.cpp | 2 +- src/gui/widget/menue.cpp | 214 +++++++----------- src/gui/widget/menue.h | 92 ++++---- src/gui/widget/mountchooser.cpp | 2 +- src/gui/widget/stringinput_ext.h | 4 - src/gui/zapit_setup.cpp | 4 +- src/neutrino.cpp | 2 +- src/neutrino_menue.cpp | 2 +- .../tuxboxapi/coolstream/controlapi.cpp | 6 +- .../tuxboxapi/coolstream/neutrinoyparser.cpp | 2 +- 35 files changed, 298 insertions(+), 356 deletions(-) diff --git a/lib/timerdclient/timerdclient.cpp b/lib/timerdclient/timerdclient.cpp index 8f5827d74..44429ed6b 100644 --- a/lib/timerdclient/timerdclient.cpp +++ b/lib/timerdclient/timerdclient.cpp @@ -434,8 +434,10 @@ void CTimerdClient::getRecordingSafety(int &pre, int &post) //------------------------------------------------------------------------- //void CTimerdClient::getWeekdaysFromStr(int *rep, const char* str) -void CTimerdClient::getWeekdaysFromStr(CTimerd::CTimerEventRepeat *eventRepeat, const char* str) +void CTimerdClient::getWeekdaysFromStr(CTimerd::CTimerEventRepeat *eventRepeat, std::string &str) { + if (str.length() < 7) + str.append(7 - str.length(), '-'); int rep = (int) *eventRepeat; if(rep >= (int)CTimerd::TIMERREPEAT_WEEKDAYS) { @@ -454,21 +456,22 @@ void CTimerdClient::getWeekdaysFromStr(CTimerd::CTimerEventRepeat *eventRepeat, *eventRepeat = (CTimerd::CTimerEventRepeat) rep; } //------------------------------------------------------------------------- -void CTimerdClient::setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, char* str) +void CTimerdClient::setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, std::string &str) { + if (str.length() < 7) + str.append(7 - str.length(), '-'); if(rep >= CTimerd::TIMERREPEAT_WEEKDAYS) { for(int n=0;n<7;n++) { if(rep & (1 << (n+9))) - str[n]='X'; + str.at(n)='X'; else - str[n]='-'; + str.at(n)='-'; } - str[7]=0; } else - strcpy(str,"-------"); + str = "-------"; } //------------------------------------------------------------------------- void CTimerdClient::stopTimerEvent( int evId) diff --git a/lib/timerdclient/timerdclient.h b/lib/timerdclient/timerdclient.h index 89ef81d84..16bdcad77 100644 --- a/lib/timerdclient/timerdclient.h +++ b/lib/timerdclient/timerdclient.h @@ -170,8 +170,8 @@ class CTimerdClient:private CBasicClient // Convert String of O and X to repeat type and vice versa //void getWeekdaysFromStr(int *rep, const char* str); - void getWeekdaysFromStr(CTimerd::CTimerEventRepeat *rep, const char* str); - void setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, char* str); + void getWeekdaysFromStr(CTimerd::CTimerEventRepeat *rep, std::string &str); + void setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, std::string &str); }; #endif diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 1ba5b97c8..b1c3dd307 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1450,7 +1450,7 @@ bool CRecordManager::ShowMenu(void) { int select = -1, rec_count = recmap.size(); char cnt[5]; - CMenuForwarderNonLocalized * item; + CMenuForwarder * item; CMenuForwarder * iteml; t_channel_id channel_ids[RECORD_MAX_COUNT] = { 0 }; /* initialization avoids false "might */ int recording_ids[RECORD_MAX_COUNT] = { 0 }; /* be used uninitialized" warning */ @@ -1508,7 +1508,7 @@ bool CRecordManager::ShowMenu(void) rc_key = CRCInput::RC_stop; btn_icon = NEUTRINO_ICON_BUTTON_STOP; } - item = new CMenuForwarderNonLocalized(title.c_str(), true, durations[i].c_str(), selector, cnt, rc_key, NULL, mode_icon); + item = new CMenuForwarder(title.c_str(), true, durations[i].c_str(), selector, cnt, rc_key, NULL, mode_icon); item->setItemButton(btn_icon, true); //if only one recording is running, set the focus to this menu item diff --git a/src/gui/audio_select.cpp b/src/gui/audio_select.cpp index c2a5f4a3c..9b8c9433b 100644 --- a/src/gui/audio_select.cpp +++ b/src/gui/audio_select.cpp @@ -111,7 +111,7 @@ int CAudioSelectMenuHandler::doMenu () { char apid[5]; sprintf(apid, "%d", i); - CMenuForwarderNonLocalized *fw = new CMenuForwarderNonLocalized(g_RemoteControl->current_PIDs.APIDs[i].desc, + CMenuForwarder *fw = new CMenuForwarder(g_RemoteControl->current_PIDs.APIDs[i].desc, true, NULL, this, apid, CRCInput::convertDigitToKey(i + 1)); fw->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); AudioSelector.addItem(fw, (i == g_RemoteControl->current_PIDs.PIDs.selected_apid)); @@ -156,7 +156,7 @@ int CAudioSelectMenuHandler::doMenu () snprintf(spid,sizeof(spid), "DVB:%d", sd->pId); char item[64]; snprintf(item,sizeof(item), "DVB: %s (pid %x)", sd->ISO639_language_code.c_str(), sd->pId); - AudioSelector.addItem(new CMenuForwarderNonLocalized(item /*sd->ISO639_language_code.c_str()*/, + AudioSelector.addItem(new CMenuForwarder(item /*sd->ISO639_language_code.c_str()*/, sd->pId != dvbsub_getpid(), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num))); } if (s->thisSubType == CZapitAbsSub::TTX) @@ -174,7 +174,7 @@ int CAudioSelectMenuHandler::doMenu () snprintf(spid,sizeof(spid), "TTX:%d:%03X:%s", sd->pId, page, sd->ISO639_language_code.c_str()); char item[64]; snprintf(item,sizeof(item), "TTX: %s (pid %x page %03X)", sd->ISO639_language_code.c_str(), sd->pId, page); - AudioSelector.addItem(new CMenuForwarderNonLocalized(item /*sd->ISO639_language_code.c_str()*/, + AudioSelector.addItem(new CMenuForwarder(item /*sd->ISO639_language_code.c_str()*/, !tuxtx_subtitle_running(&pid, &page, NULL), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num))); } } diff --git a/src/gui/cam_menu.cpp b/src/gui/cam_menu.cpp index 50d4ca2f3..a07ea0209 100644 --- a/src/gui/cam_menu.cpp +++ b/src/gui/cam_menu.cpp @@ -128,14 +128,14 @@ int CCAMMenuHandler::doMainMenu() char tmp[32]; snprintf(tmp, sizeof(tmp), "ca_ci%d", i); - cammenu->addItem(new CMenuForwarderNonLocalized(name1, true, NULL, this, tmp, CRCInput::RC_1 + cnt++)); + cammenu->addItem(new CMenuForwarder(name1, true, NULL, this, tmp, CRCInput::RC_1 + cnt++)); snprintf(tmp, sizeof(tmp), "ca_ci_reset%d", i); cammenu->addItem(new CMenuForwarder(LOCALE_CI_RESET, true, NULL, this, tmp)); memset(name1,0,sizeof(name1)); } else { snprintf(str1, sizeof(str1), "%s %d", g_Locale->getText(LOCALE_CI_EMPTY), i); tempMenu = new CMenuWidget(str1, NEUTRINO_ICON_SETTINGS); - cammenu->addItem(new CMenuDForwarderNonLocalized(str1, false, NULL, tempMenu)); + cammenu->addItem(new CMenuDForwarder(str1, false, NULL, tempMenu)); memset(str1,0,sizeof(str1)); } if (i < (CiSlots - 1)) @@ -157,7 +157,7 @@ int CCAMMenuHandler::doMainMenu() char tmp[32]; snprintf(tmp, sizeof(tmp), "ca_sc%d", i); - cammenu->addItem(new CMenuForwarderNonLocalized(name1, true, NULL, this, tmp, CRCInput::RC_1 + cnt++)); + cammenu->addItem(new CMenuForwarder(name1, true, NULL, this, tmp, CRCInput::RC_1 + cnt++)); #if 0 // FIXME not implemented yet snprintf(tmp, sizeof(tmp), "ca_sc_reset%d", i); cammenu->addItem(new CMenuForwarder(LOCALE_SC_RESET, true, NULL, this, tmp)); @@ -166,7 +166,7 @@ int CCAMMenuHandler::doMainMenu() } else { snprintf(str1, sizeof(str1), "%s %d", g_Locale->getText(LOCALE_SC_EMPTY), i); tempMenu = new CMenuWidget(str1, NEUTRINO_ICON_SETTINGS); - cammenu->addItem(new CMenuDForwarderNonLocalized(str1, false, NULL, tempMenu)); + cammenu->addItem(new CMenuDForwarder(str1, false, NULL, tempMenu)); memset(str1,0,sizeof(str1)); } if (i < (ScNum - 1)) @@ -330,27 +330,27 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t bpos = 0; tptr[li] = 0; printf("CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr); - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); + menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); sptr = &tptr[li+1]; } bpos++; } if(strlen(sptr)) { printf("CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr); - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); + menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); } } for(i = 0; (i < pMenu->choice_nb) && (i < MAX_MMI_ITEMS); i++) { snprintf(cnt, sizeof(cnt), "%d", i); if(sublevel) - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt)); + menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt)); else - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i+1))); + menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i+1))); } slen = strlen(pMenu->bottom); if(slen) { printf("CCAMMenuHandler::handleCamMsg: bottom: %s\n", pMenu->bottom); - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(pMenu->bottom, slen, 0).c_str(), false)); + menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->bottom, slen, 0).c_str(), false)); } menu->exec(NULL, ""); diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 863533b1b..ae9816c14 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -1288,7 +1288,7 @@ int CEventFinderMenu::exec(CMenuTarget* parent, const std::string &actionkey) m->addItem(GenericMenuSeparatorLine); std::list::iterator it = g_settings.epg_search_history.begin(); for (int i = 0; i < g_settings.epg_search_history_size; i++, ++it) - m->addItem(new CMenuForwarderNonLocalized((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); + m->addItem(new CMenuForwarder((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); m->exec(NULL, ""); m->hide(); delete m; @@ -1345,7 +1345,7 @@ int CEventFinderMenu::showMenu(void) CMenuForwarder* mf0 = new CMenuForwarder(LOCALE_EVENTFINDER_KEYWORD, true, *m_search_keyword, &stringInput, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); CMenuOptionChooser* mo0 = new CMenuOptionChooser(LOCALE_EVENTFINDER_SEARCH_WITHIN_LIST, m_search_list, SEARCH_LIST_OPTIONS, SEARCH_LIST_OPTION_COUNT, true, this, CRCInput::convertDigitToKey(shortcut++)); - m_search_channelname_mf = new CMenuForwarderNonLocalized("", *m_search_list != CNeutrinoEventList::SEARCH_LIST_ALL, m_search_channelname, this, "#2", CRCInput::convertDigitToKey(shortcut++)); + m_search_channelname_mf = new CMenuForwarder("", *m_search_list != CNeutrinoEventList::SEARCH_LIST_ALL, m_search_channelname, this, "#2", CRCInput::convertDigitToKey(shortcut++)); CMenuOptionChooser* mo1 = new CMenuOptionChooser(LOCALE_EVENTFINDER_SEARCH_WITHIN_EPG, m_search_epg_item, SEARCH_EPG_OPTIONS, SEARCH_EPG_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(shortcut++)); CMenuForwarder* mf1 = new CMenuForwarder(LOCALE_EVENTFINDER_START_SEARCH, true, NULL, this, "#1", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index 7e83d8391..96f79265b 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -138,7 +138,7 @@ class CEventListHandler : public CMenuTarget class CEventFinderMenu : public CMenuTarget, CChangeObserver { private: - CMenuForwarderNonLocalized* m_search_channelname_mf; + CMenuForwarder* m_search_channelname_mf; int* m_event; int* m_search_epg_item; std::string* m_search_keyword; diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 5b2318398..5f8b7d6d6 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -242,7 +242,7 @@ int CHDDMenuHandler::doMenu () tempMenu[i]->addItem(mf); snprintf(sstr, sizeof(sstr), "%s (%s)", g_Locale->getText(LOCALE_HDD_REMOVABLE_DEVICE), namelist[i]->d_name); - mf = new CMenuForwarderNonLocalized((removable ? sstr : namelist[i]->d_name), enabled, tmp_str[i], tempMenu[i]); + mf = new CMenuForwarder((removable ? sstr : namelist[i]->d_name), enabled, tmp_str[i], tempMenu[i]); mf->setHint("", LOCALE_MENU_HINT_HDD_TOOLS); hddmenu->addItem(mf); diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index ebfba55df..ba38027e2 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -111,7 +111,7 @@ int CMiscMenue::exec(CMenuTarget* parent, const std::string &actionKey) // e.g. vtxt-plugins sprintf(id, "%d", count); enabled_count++; - MoviePluginSelector.addItem(new CMenuForwarderNonLocalized(g_PluginList->getName(count), true, NULL, new COnekeyPluginChangeExec(), id, CRCInput::convertDigitToKey(count)), (cnt == 0)); + MoviePluginSelector.addItem(new CMenuForwarder(g_PluginList->getName(count), true, NULL, new COnekeyPluginChangeExec(), id, CRCInput::convertDigitToKey(count)), (cnt == 0)); cnt++; } } @@ -265,7 +265,7 @@ int CMiscMenue::showMiscSettingsMenu() //CPU CMenuWidget misc_menue_cpu("CPU", NEUTRINO_ICON_SETTINGS, width); showMiscSettingsMenuCPUFreq(&misc_menue_cpu); - misc_menue.addItem( new CMenuForwarderNonLocalized("CPU", true, NULL, &misc_menue_cpu, NULL, CRCInput::RC_4)); + misc_menue.addItem( new CMenuForwarder("CPU", true, NULL, &misc_menue_cpu, NULL, CRCInput::RC_4)); #endif /*CPU_FREQ*/ int res = misc_menue.exec(NULL, ""); @@ -357,7 +357,7 @@ int CMiscMenue::showMiscSettingsMenuEnergy() ms_energy->addItem(m1); ms_energy->addItem(m2); - m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, NULL, new CSleepTimerWidget, "permanent"); + m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, NULL, new CSleepTimerWidget(true)); m2->setHint("", LOCALE_MENU_HINT_INACT_TIMER); ms_energy->addItem(m2); diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 082ee51d4..70b5862ea 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -2977,7 +2977,7 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) pBookItemMenu[li]->addItem( new CMenuForwarder(LOCALE_MOVIEBROWSER_BOOK_POSITION, true, pBookPosIntInput[li]->getValue(), pBookPosIntInput[li])); pBookItemMenu[li]->addItem( new CMenuForwarder(LOCALE_MOVIEBROWSER_BOOK_TYPE, true, pBookTypeIntInput[li]->getValue(),pBookTypeIntInput[li])); - bookmarkMenu.addItem( new CMenuForwarderNonLocalized (movie_info->bookmarks.user[li].name.c_str(), true, pBookPosIntInput[li]->getValue(),pBookItemMenu[li])); + bookmarkMenu.addItem( new CMenuForwarder (movie_info->bookmarks.user[li].name.c_str(), true, pBookPosIntInput[li]->getValue(),pBookItemMenu[li])); } /********************************************************************/ @@ -3277,7 +3277,7 @@ int CMovieBrowser::showStartPosSelectionMenu(void) // P2 position[menu_nr] = m_movieSelectionHandler->bookmarks.user[i].pos + m_movieSelectionHandler->bookmarks.user[i].length; snprintf(book[i], 19,"%5d min",position[menu_nr]/60); - startPosSelectionMenu.addItem(new CMenuForwarderNonLocalized (m_movieSelectionHandler->bookmarks.user[i].name.c_str(), true, book[i])); + startPosSelectionMenu.addItem(new CMenuForwarder (m_movieSelectionHandler->bookmarks.user[i].name.c_str(), true, book[i])); menu_nr++; } } @@ -3692,7 +3692,7 @@ int CYTHistory::exec(CMenuTarget* parent, const std::string &actionKey) m->addItem(GenericMenuSeparatorLine); std::list::iterator it = settings->ytsearch_history.begin(); for (int i = 0; i < settings->ytsearch_history_size; i++, ++it) - m->addItem(new CMenuForwarderNonLocalized((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); + m->addItem(new CMenuForwarder((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); m->exec(NULL, ""); m->hide(); delete m; @@ -4131,7 +4131,7 @@ int CDirMenu::show(void) { snprintf(tmp, sizeof(tmp),"%d",i); tmp[1]=0; - dirMenu.addItem( new CMenuForwarderNonLocalized ( (*dirList)[i].name.c_str(), (dirState[i] != DIR_STATE_UNKNOWN), dirOptionText[i], this,tmp)); + dirMenu.addItem( new CMenuForwarder ( (*dirList)[i].name.c_str(), (dirState[i] != DIR_STATE_UNKNOWN), dirOptionText[i], this,tmp)); } int ret = dirMenu.exec(NULL," "); return ret; diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 84d050bdf..23af4dd12 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -994,7 +994,7 @@ void CMoviePlayerGui::selectAudioPid(bool file_player) char cnt[5]; sprintf(cnt, "%d", count); - CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(apidtitle.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); + CMenuForwarder * item = new CMenuForwarder(apidtitle.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); APIDSelector.addItem(item, defpid); } @@ -1326,7 +1326,7 @@ void CMoviePlayerGui::selectChapter() char cnt[5]; for (unsigned i = 0; i < positions.size(); i++) { sprintf(cnt, "%d", i); - CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(titles[i].c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i + 1)); + CMenuForwarder * item = new CMenuForwarder(titles[i].c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i + 1)); ChSelector.addItem(item, position > positions[i]); } ChSelector.exec(NULL, ""); @@ -1361,7 +1361,7 @@ void CMoviePlayerGui::selectSubtitle() title = pidnumber; } sprintf(cnt, "%d", count); - CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(title.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); + CMenuForwarder * item = new CMenuForwarder(title.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); item->setItemButton(NEUTRINO_ICON_BUTTON_STOP, false); APIDSelector.addItem(item, defpid); } diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index a74ac4106..67b44db8d 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -233,7 +233,7 @@ int CNetworkSetup::showNetworkSetup() m0->setHint("", LOCALE_MENU_HINT_NET_SETUPNOW); //eth id - CMenuForwarder *mac = new CMenuForwarderNonLocalized("MAC", false, mac_addr); + CMenuForwarder *mac = new CMenuForwarder("MAC", false, mac_addr); //prepare input entries CIPInput networkSettings_NetworkIP(LOCALE_NETWORKMENU_IPADDRESS , network_address , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2, this); @@ -828,7 +828,7 @@ int CNetworkSetup::showWlanList() const char * icon = NULL; if (networks[i].encrypted) icon = NEUTRINO_ICON_LOCK; - CMenuForwarderNonLocalized * net = new CMenuForwarderNonLocalized(networks[i].ssid.c_str(), true, option[i], selector, cnt, CRCInput::RC_nokey, NULL, icon); + CMenuForwarder * net = new CMenuForwarder(networks[i].ssid.c_str(), true, option[i], selector, cnt, CRCInput::RC_nokey, NULL, icon); net->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); wlist.addItem(net, networks[i].ssid == network_ssid); } diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 4cb28a441..5cb6bbe25 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -183,7 +183,7 @@ int CNFSMountGui::menu() { sprintf(s2,"mountentry%d",i); ISO_8859_1_entry[i] = ZapitTools::UTF8_to_Latin1(m_entry[i].c_str()); - mountMenuEntry[i] = new CMenuForwarderNonLocalized("", true, ISO_8859_1_entry[i], this, s2); + mountMenuEntry[i] = new CMenuForwarder("", true, ISO_8859_1_entry[i], this, s2); if (!i) menu_offset = mountMenuW.getItemsCount(); @@ -324,7 +324,7 @@ int CNFSUmountGui::menu() s1 += it->mountPoint; std::string s2 = "doumount "; s2 += it->mountPoint; - CMenuForwarder *forwarder = new CMenuForwarderNonLocalized(s1.c_str(), true, NULL, this, s2.c_str()); + CMenuForwarder *forwarder = new CMenuForwarder(s1.c_str(), true, NULL, this, s2.c_str()); forwarder->iconName = NEUTRINO_ICON_MOUNTED; umountMenu.addItem(forwarder); } diff --git a/src/gui/nfs.h b/src/gui/nfs.h index 17f33e08b..1c3be441f 100644 --- a/src/gui/nfs.h +++ b/src/gui/nfs.h @@ -53,7 +53,7 @@ class CNFSMountGui : public CMenuTarget CMenuWidget *mountMenuWPtr; int menu_offset; - CMenuForwarderNonLocalized* mountMenuEntry[NETWORK_NFS_NR_OF_ENTRIES]; + CMenuForwarder* mountMenuEntry[NETWORK_NFS_NR_OF_ENTRIES]; CFSMounter::FS_Support m_nfs_sup; CFSMounter::FS_Support m_cifs_sup; diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 903e5a761..8516f87d1 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -710,36 +710,42 @@ private: CChangeObserver * observer; CConfigFile * configfile; int32_t defaultvalue; - char value[11]; + std::string value; protected: - virtual const char * getOption(void) - { - sprintf(value, "%u", configfile->getInt32(locale_real_names[text], defaultvalue)); - return value; - } + std::string getOption(fb_pixel_t * bgcol __attribute__((unused)) = NULL) { + return to_string(configfile->getInt32(locale_real_names[name], defaultvalue)); + } virtual bool changeNotify(const neutrino_locale_t OptionName, void * Data) - { - configfile->setInt32(locale_real_names[text], atoi(value)); - return observer->changeNotify(OptionName, Data); - } + { + configfile->setInt32(locale_real_names[name], atoi(value.c_str())); + return observer->changeNotify(OptionName, Data); + } public: CMenuNumberInput(const neutrino_locale_t Text, const int32_t DefaultValue, CChangeObserver * const Observer, CConfigFile * const Configfile) : CMenuForwarder(Text, true, NULL, this) - { - observer = Observer; - configfile = Configfile; - defaultvalue = DefaultValue; - } + { + observer = Observer; + configfile = Configfile; + defaultvalue = DefaultValue; + } int exec(CMenuTarget * parent, const std::string & action_Key) - { - CStringInput input(text, (char *)getOption(), 3, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2, "0123456789 ", this); - return input.exec(parent, action_Key); - } + { + value = getOption(); + while (value.length() < 3) + value = " " + value; + CStringInput input(name, &value, 3, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2, "0123456789 ", this); + return input.exec(parent, action_Key); + } + + std::string &getValue(void) { + value = getOption(); + return value; + } }; void COsdSetup::AddFontSettingItem(CMenuWidget &font_Settings, const SNeutrinoSettings::FONT_TYPES number_of_fontsize_entry) diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index 7a2ed7331..7a50f8792 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -324,7 +324,7 @@ int CPersonalizeGui::ShowPersonalizationMenu() } //personalized menues - CMenuForwarderNonLocalized *p_mn[widget_count]; + CMenuForwarder *p_mn[widget_count]; for (int i = 0; i<(widget_count); i++) { ostringstream i_str; @@ -332,7 +332,7 @@ int CPersonalizeGui::ShowPersonalizationMenu() string s(i_str.str()); string action_key = s; string mn_name = v_widget[i]->getName(); - p_mn[i] = new CMenuForwarderNonLocalized(mn_name.c_str(), true, NULL, this, action_key.c_str(), CRCInput::convertDigitToKey(i+1)); + p_mn[i] = new CMenuForwarder(mn_name.c_str(), true, NULL, this, action_key.c_str(), CRCInput::convertDigitToKey(i+1)); pMenu->addItem(p_mn[i]); } @@ -467,7 +467,7 @@ void CPersonalizeGui::ShowPluginMenu(CMenuWidget* p_widget) { if( g_PluginList->getType(i)== CPlugins::P_TYPE_TOOL && !g_PluginList->isHidden(i)) //don't show hidden plugins an games { - p_widget->addItem(new CMenuForwarderNonLocalized(g_PluginList->getName(i), true, g_PluginList->getDescription(i), NULL, NULL, getShortcut(d_key))); + p_widget->addItem(new CMenuForwarder(g_PluginList->getName(i), true, g_PluginList->getDescription(i), NULL, NULL, getShortcut(d_key))); d_key++; } } diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index 638956ef3..b0ecff917 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -412,7 +412,7 @@ int CScanSetup::showScanMenu() CMenuWidget * autoScan = new CMenuWidget(LOCALE_SERVICEMENU_SCANTS, NEUTRINO_ICON_SETTINGS, w/*width*/, MN_WIDGET_ID_SCAN_AUTO_SCAN); addScanMenuAutoScan(autoScan); - mf = new CMenuDForwarderNonLocalized(autoscan, true, NULL, autoScan, "", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); + mf = new CMenuDForwarder(autoscan, true, NULL, autoScan, "", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); mf->setHint("", LOCALE_MENU_HINT_SCAN_AUTO); settings->addItem(mf); @@ -458,7 +458,7 @@ int CScanSetup::showScanMenu() CMenuWidget * autoScan = new CMenuWidget(LOCALE_SERVICEMENU_SCANTS, NEUTRINO_ICON_SETTINGS, w/*width*/, MN_WIDGET_ID_SCAN_AUTO_SCAN); addScanMenuAutoScan(autoScan); - mf = new CMenuDForwarderNonLocalized(autoscan, true, NULL, autoScan, "", have_sat ? CRCInput::convertDigitToKey(shortcut++) : CRCInput::RC_red, have_sat ? NULL : NEUTRINO_ICON_BUTTON_RED); + mf = new CMenuDForwarder(autoscan, true, NULL, autoScan, "", have_sat ? CRCInput::convertDigitToKey(shortcut++) : CRCInput::RC_red, have_sat ? NULL : NEUTRINO_ICON_BUTTON_RED); mf->setHint("", LOCALE_MENU_HINT_SCAN_AUTO); settings->addItem(mf); @@ -558,7 +558,7 @@ int CScanSetup::showScanMenuFrontendSetup() modestr[i] = g_Locale->getText(getModeLocale(fe->getMode())); - mf = new CMenuForwarderNonLocalized(name, allow_start, modestr[i], this, tmp, key, icon); + mf = new CMenuForwarder(name, allow_start, modestr[i], this, tmp, key, icon); mf->setHint("", LOCALE_MENU_HINT_SCAN_SETUP_FE); setupMenu->addItem(mf); if(i != 0) @@ -849,7 +849,7 @@ int CScanSetup::showScanMenuLnbSetup() char opt[100]; sprintf(opt, "diseqc %2d / rotor %2d", sit->second.diseqc+1, sit->second.motor_position); satoptions.push_back(opt); - CMenuForwarder * mf = new CMenuForwarderNonLocalized(satname.c_str(), true, satoptions[count].c_str(), tempsat); + CMenuForwarder * mf = new CMenuForwarder(satname.c_str(), true, satoptions[count].c_str(), tempsat); mf->setHint("", LOCALE_MENU_HINT_SCAN_LNBCONFIG); sat_setup->addItem(mf); satmf.push_back(mf); @@ -1535,7 +1535,7 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) old_selected = i; std::string tname = t.description(); - CMenuForwarderNonLocalized * ts_item = new CMenuForwarderNonLocalized(tname.c_str(), true, NULL, selector, cnt, CRCInput::RC_nokey, NULL)/*, false*/; + CMenuForwarder * ts_item = new CMenuForwarder(tname.c_str(), true, NULL, selector, cnt, CRCInput::RC_nokey, NULL)/*, false*/; ts_item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); menu.addItem(ts_item, old_selected == i); diff --git a/src/gui/sleeptimer.cpp b/src/gui/sleeptimer.cpp index eeb5dd079..2f2b2e446 100644 --- a/src/gui/sleeptimer.cpp +++ b/src/gui/sleeptimer.cpp @@ -42,7 +42,7 @@ extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ bool CSleepTimerWidget::is_running = false; -int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) +int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &/*actionKey*/) { int res = menu_return::RETURN_REPAINT; @@ -53,24 +53,21 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) } is_running = true; - shutdown_min = 0; - char value[16]; + int shutdown_min = 0; + std::string value; CStringInput *inbox; - bool permanent = (actionKey == "permanent"); if (parent) parent->hide(); if(permanent) { - sprintf(value,"%03d", g_settings.shutdown_min); + value = to_string(g_settings.shutdown_min); + if (value.length() < 3) + value.insert(0, 3 - value.length(), '0'); + inbox = new CStringInput(LOCALE_SLEEPTIMERBOX_TITLE2, &value, 3, LOCALE_SLEEPTIMERBOX_HINT1, LOCALE_SLEEPTIMERBOX_HINT3, "0123456789 "); } else { shutdown_min = g_Timerd->getSleepTimerRemaining(); // remaining shutdown time? - sprintf(value,"%03d", shutdown_min); - } - - if(permanent) { - inbox = new CStringInput(LOCALE_SLEEPTIMERBOX_TITLE2, value, 3, LOCALE_SLEEPTIMERBOX_HINT1, LOCALE_SLEEPTIMERBOX_HINT3, "0123456789 "); - } else { + value = to_string(shutdown_min); if (g_settings.sleeptimer_min == 0) { CSectionsdClient::CurrentNextInfo info_CurrentNext; g_InfoViewer->getEPG(g_RemoteControl->current_channel_id, info_CurrentNext); @@ -79,14 +76,16 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) int current_epg_zeit_dauer_rest = (info_CurrentNext.current_zeit.dauer+150 - (jetzt - info_CurrentNext.current_zeit.startzeit ))/60 ; if(shutdown_min == 0 && current_epg_zeit_dauer_rest > 0 && current_epg_zeit_dauer_rest < 1000) { - sprintf(value,"%03d", current_epg_zeit_dauer_rest); + value = to_string(current_epg_zeit_dauer_rest); } } + } else { + value = to_string(g_settings.sleeptimer_min); } - else - sprintf(value,"%03d", g_settings.sleeptimer_min); + if (value.length() < 3) + value.insert(0, 3 - value.length(), '0'); - inbox = new CStringInput(LOCALE_SLEEPTIMERBOX_TITLE, value, 3, LOCALE_SLEEPTIMERBOX_HINT1, LOCALE_SLEEPTIMERBOX_HINT2, "0123456789 "); + inbox = new CStringInput(LOCALE_SLEEPTIMERBOX_TITLE, &value, 3, LOCALE_SLEEPTIMERBOX_HINT1, LOCALE_SLEEPTIMERBOX_HINT2, "0123456789 "); } int ret = inbox->exec (NULL, ""); @@ -99,7 +98,7 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) return res; } - int new_val = atoi(value); + int new_val = atoi(value.c_str()); if(permanent) { g_settings.shutdown_min = new_val; printf("permanent sleeptimer min: %d\n", g_settings.shutdown_min); @@ -125,15 +124,13 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) return res; } -const char * CSleepTimerWidget::getTargetValue() +std::string &CSleepTimerWidget::getValue(void) { - shutdown_min = g_Timerd->getSleepTimerRemaining(); - if (shutdown_min > 0) - { - shutdown_min_string = to_string(shutdown_min); - shutdown_min_string += " "; - shutdown_min_string += g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE); - return shutdown_min_string.c_str(); + if (permanent) { + valueStringTmp = (g_settings.shutdown_min > 0) ? to_string(g_settings.shutdown_min) + " " + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE) : ""; + } else { + int remaining = g_Timerd->getSleepTimerRemaining(); + valueStringTmp = (remaining > 0) ? to_string(remaining) + " " + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE) : ""; } - return NULL; + return valueStringTmp; } diff --git a/src/gui/sleeptimer.h b/src/gui/sleeptimer.h index f52f9bebc..0d612966e 100644 --- a/src/gui/sleeptimer.h +++ b/src/gui/sleeptimer.h @@ -29,12 +29,12 @@ class CSleepTimerWidget: public CMenuTarget { private: static bool is_running; - int shutdown_min; - std::string shutdown_min_string; + bool permanent; public: + CSleepTimerWidget(bool _permanent = false) { permanent = _permanent; } int exec(CMenuTarget* parent, const std::string & actionKey); - const char * getTargetValue(); + std::string &getValue(void); }; diff --git a/src/gui/subchannel_select.cpp b/src/gui/subchannel_select.cpp index 86b0a6a1c..36867ce1c 100644 --- a/src/gui/subchannel_select.cpp +++ b/src/gui/subchannel_select.cpp @@ -100,11 +100,11 @@ int CSubChannelSelectMenu::getNVODMenu(CMenuWidget* menu) nvod_time_x[0]= 0; sprintf(nvod_s, "%s - %s %s", nvod_time_a, nvod_time_e, nvod_time_x); - menu->addItem(new CMenuForwarderNonLocalized(nvod_s, enabled, NULL, &NVODChanger, nvod_id), (count == g_RemoteControl->selected_subchannel)); + menu->addItem(new CMenuForwarder(nvod_s, enabled, NULL, &NVODChanger, nvod_id), (count == g_RemoteControl->selected_subchannel)); } else { - menu->addItem(new CMenuForwarderNonLocalized(e->subservice_name.c_str(), enabled, NULL, &NVODChanger, nvod_id, CRCInput::convertDigitToKey(count)), (count == g_RemoteControl->selected_subchannel)); + menu->addItem(new CMenuForwarder(e->subservice_name.c_str(), enabled, NULL, &NVODChanger, nvod_id, CRCInput::convertDigitToKey(count)), (count == g_RemoteControl->selected_subchannel)); } count++; diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index e9687e322..94fcf2b3e 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -665,15 +665,15 @@ int CTestMenu::showTestMenu() //hardware CMenuWidget * w_hw = new CMenuWidget("Hardware Test", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_HARDWARE); - w_test.addItem(new CMenuForwarderNonLocalized(w_hw->getName().c_str(), true, NULL, w_hw)); + w_test.addItem(new CMenuForwarder(w_hw->getName().c_str(), true, NULL, w_hw)); showHWTests(w_hw); //buttons - w_test.addItem(new CMenuForwarderNonLocalized("Buttons", true, NULL, this, "buttons")); + w_test.addItem(new CMenuForwarder("Buttons", true, NULL, this, "buttons")); //components CMenuWidget * w_cc = new CMenuWidget("OSD-Components Demo", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_COMPONENTS); - w_test.addItem(new CMenuForwarderNonLocalized(w_cc->getName().c_str(), true, NULL, w_cc)); + w_test.addItem(new CMenuForwarder(w_cc->getName().c_str(), true, NULL, w_cc)); showCCTests(w_cc); //buildinfo @@ -688,31 +688,31 @@ int CTestMenu::showTestMenu() void CTestMenu::showCCTests(CMenuWidget *widget) { widget->addIntroItems(); - widget->addItem(new CMenuForwarderNonLocalized("Running Clock", true, NULL, this, "running_clock")); - widget->addItem(new CMenuForwarderNonLocalized("Clock", true, NULL, this, "clock")); - widget->addItem(new CMenuForwarderNonLocalized("Button", true, NULL, this, "button")); - widget->addItem(new CMenuForwarderNonLocalized("Circle", true, NULL, this, "circle")); - widget->addItem(new CMenuForwarderNonLocalized("Square", true, NULL, this, "square")); - widget->addItem(new CMenuForwarderNonLocalized("Picture", true, NULL, this, "picture")); - widget->addItem(new CMenuForwarderNonLocalized("Channel-Logo", true, NULL, this, "channellogo")); - widget->addItem(new CMenuForwarderNonLocalized("Form", true, NULL, this, "form")); - widget->addItem(new CMenuForwarderNonLocalized("Text", true, NULL, this, "text")); - widget->addItem(new CMenuForwarderNonLocalized("Header", true, NULL, this, "header")); - widget->addItem(new CMenuForwarderNonLocalized("Footer", true, NULL, this, "footer")); - widget->addItem(new CMenuForwarderNonLocalized("Icon-Form", true, NULL, this, "iconform")); - widget->addItem(new CMenuForwarderNonLocalized("Window", true, NULL, this, "window")); - widget->addItem(new CMenuForwarderNonLocalized("Text-Extended", true, NULL, this, "text_ext")); + widget->addItem(new CMenuForwarder("Running Clock", true, NULL, this, "running_clock")); + widget->addItem(new CMenuForwarder("Clock", true, NULL, this, "clock")); + widget->addItem(new CMenuForwarder("Button", true, NULL, this, "button")); + widget->addItem(new CMenuForwarder("Circle", true, NULL, this, "circle")); + widget->addItem(new CMenuForwarder("Square", true, NULL, this, "square")); + widget->addItem(new CMenuForwarder("Picture", true, NULL, this, "picture")); + widget->addItem(new CMenuForwarder("Channel-Logo", true, NULL, this, "channellogo")); + widget->addItem(new CMenuForwarder("Form", true, NULL, this, "form")); + widget->addItem(new CMenuForwarder("Text", true, NULL, this, "text")); + widget->addItem(new CMenuForwarder("Header", true, NULL, this, "header")); + widget->addItem(new CMenuForwarder("Footer", true, NULL, this, "footer")); + widget->addItem(new CMenuForwarder("Icon-Form", true, NULL, this, "iconform")); + widget->addItem(new CMenuForwarder("Window", true, NULL, this, "window")); + widget->addItem(new CMenuForwarder("Text-Extended", true, NULL, this, "text_ext")); } void CTestMenu::showHWTests(CMenuWidget *widget) { widget->addIntroItems(); - widget->addItem(new CMenuForwarderNonLocalized("VFD", true, NULL, this, "vfd")); - widget->addItem(new CMenuForwarderNonLocalized("Network", true, NULL, this, "network")); - widget->addItem(new CMenuForwarderNonLocalized("Smartcard 1", true, NULL, this, "card0")); - widget->addItem(new CMenuForwarderNonLocalized("Smartcard 2", true, NULL, this, "card1")); - widget->addItem(new CMenuForwarderNonLocalized("HDD", true, NULL, this, "hdd")); - widget->addItem(new CMenuForwarderNonLocalized("SD/MMC", true, NULL, this, "mmc")); + widget->addItem(new CMenuForwarder("VFD", true, NULL, this, "vfd")); + widget->addItem(new CMenuForwarder("Network", true, NULL, this, "network")); + widget->addItem(new CMenuForwarder("Smartcard 1", true, NULL, this, "card0")); + widget->addItem(new CMenuForwarder("Smartcard 2", true, NULL, this, "card1")); + widget->addItem(new CMenuForwarder("HDD", true, NULL, this, "hdd")); + widget->addItem(new CMenuForwarder("SD/MMC", true, NULL, this, "mmc")); for (unsigned i = 0; i < sizeof(test_pos)/sizeof(int); i++) { CServiceManager::getInstance()->InitSatPosition(test_pos[i], NULL, true); @@ -732,7 +732,7 @@ void CTestMenu::showHWTests(CMenuWidget *widget) } else continue; - widget->addItem(new CMenuForwarderNonLocalized(title, true, NULL, this, scan)); + widget->addItem(new CMenuForwarder(title, true, NULL, this, scan)); if (frontend->getInfo()->type == FE_QPSK) { frontend->setMode(CFrontend::FE_MODE_INDEPENDENT); @@ -740,20 +740,20 @@ void CTestMenu::showHWTests(CMenuWidget *widget) satmap[test_pos[i]].configured = 1; frontend->setSatellites(satmap); if (i == 0) { - widget->addItem(new CMenuForwarderNonLocalized("Tuner 1: 22 Khz ON", true, NULL, this, "22kon0")); - widget->addItem(new CMenuForwarderNonLocalized("Tuner 1: 22 Khz OFF", true, NULL, this, "22koff0")); + widget->addItem(new CMenuForwarder("Tuner 1: 22 Khz ON", true, NULL, this, "22kon0")); + widget->addItem(new CMenuForwarder("Tuner 1: 22 Khz OFF", true, NULL, this, "22koff0")); } if (i == 1) { - widget->addItem(new CMenuForwarderNonLocalized("Tuner 2: 22 Khz ON", true, NULL, this, "22kon1")); - widget->addItem(new CMenuForwarderNonLocalized("Tuner 2: 22 Khz OFF", true, NULL, this, "22koff1")); + widget->addItem(new CMenuForwarder("Tuner 2: 22 Khz ON", true, NULL, this, "22kon1")); + widget->addItem(new CMenuForwarder("Tuner 2: 22 Khz OFF", true, NULL, this, "22koff1")); } if (i == 2) { - widget->addItem(new CMenuForwarderNonLocalized("Tuner 3: 22 Khz ON", true, NULL, this, "22kon2")); - widget->addItem(new CMenuForwarderNonLocalized("Tuner 3: 22 Khz OFF", true, NULL, this, "22koff2")); + widget->addItem(new CMenuForwarder("Tuner 3: 22 Khz ON", true, NULL, this, "22kon2")); + widget->addItem(new CMenuForwarder("Tuner 3: 22 Khz OFF", true, NULL, this, "22koff2")); } if (i == 3) { - widget->addItem(new CMenuForwarderNonLocalized("Tuner 4: 22 Khz ON", true, NULL, this, "22kon3")); - widget->addItem(new CMenuForwarderNonLocalized("Tuner 4: 22 Khz OFF", true, NULL, this, "22koff3")); + widget->addItem(new CMenuForwarder("Tuner 4: 22 Khz ON", true, NULL, this, "22kon3")); + widget->addItem(new CMenuForwarder("Tuner 4: 22 Khz OFF", true, NULL, this, "22koff3")); } } } diff --git a/src/gui/themes.cpp b/src/gui/themes.cpp index 5786a237d..64644e555 100644 --- a/src/gui/themes.cpp +++ b/src/gui/themes.cpp @@ -129,9 +129,9 @@ void CThemes::readThemes(CMenuWidget &themes) *pos = '\0'; if ( p == 1 ) { userThemeFile = "{U}" + (std::string)file; - oj = new CMenuForwarderNonLocalized((char*)file, true, "", this, userThemeFile.c_str()); + oj = new CMenuForwarder((char*)file, true, "", this, userThemeFile.c_str()); } else - oj = new CMenuForwarderNonLocalized((char*)file, true, "", this, file); + oj = new CMenuForwarder((char*)file, true, "", this, file); themes.addItem( oj ); } free(themelist[count]); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 35180e121..4f3ca671d 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -88,12 +88,12 @@ private: CMenuItem* m4; CMenuItem* m5; CMenuItem* m6; - char* display; + std::string * display; int* iType; time_t* stopTime; public: CTimerListNewNotifier( int* Type, time_t* time,CMenuItem* a1, CMenuItem* a2, - CMenuItem* a3, CMenuItem* a4, CMenuItem* a5, CMenuItem* a6,char* d) + CMenuItem* a3, CMenuItem* a4, CMenuItem* a5, CMenuItem* a6, std::string *d) { m1 = a1; m2 = a2; @@ -112,16 +112,18 @@ public: { *stopTime=(time(NULL)/60)*60; struct tm *tmTime2 = localtime(stopTime); - sprintf( display, "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1, + char disp[40]; + snprintf(disp, sizeof(disp), "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1, tmTime2->tm_year+1900, tmTime2->tm_hour, tmTime2->tm_min); + *display = std::string(disp); m1->setActive(true); m6->setActive((g_settings.recording_type == RECORDING_FILE)); } else { *stopTime=0; - strcpy(display," "); + *display = " "; m1->setActive (false); m6->setActive(false); } @@ -158,9 +160,9 @@ private: CMenuForwarder* m2; int* iRepeat; - char * weekdays; + std::string * weekdays; public: - CTimerListRepeatNotifier( int* repeat, CMenuForwarder* a1, CMenuForwarder *a2, char * wstr) + CTimerListRepeatNotifier( int* repeat, CMenuForwarder* a1, CMenuForwarder *a2, std::string * wstr) { m1 = a1; m2 = a2; @@ -172,11 +174,11 @@ public: { if (*iRepeat >= (int)CTimerd::TIMERREPEAT_WEEKDAYS) { m1->setActive (true); - strcpy(weekdays, "XXXXX--"); + *weekdays = "XXXXX--"; } else { m1->setActive (false); - strcpy(weekdays, "-------"); + *weekdays = "-------"; } if (*iRepeat != (int)CTimerd::TIMERREPEAT_ONCE) m2->setActive(true); @@ -1081,13 +1083,13 @@ int CTimerList::modifyTimer() Timer->setWeekdaysToStr(timer->eventRepeat, m_weekdaysStr); timer->eventRepeat = (CTimerd::CTimerEventRepeat)(((int)timer->eventRepeat) & 0x1FF); - CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); + CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, &m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); CMenuForwarder *m4 = new CMenuForwarder(LOCALE_TIMERLIST_WEEKDAYS, ((int)timer->eventRepeat) >= (int)CTimerd::TIMERREPEAT_WEEKDAYS, m_weekdaysStr, &timerSettings_weekdays ); CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int&)timer->repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); CMenuForwarder *m5 = new CMenuForwarder(LOCALE_TIMERLIST_REPEATCOUNT, timer->eventRepeat != (int)CTimerd::TIMERREPEAT_ONCE ,timerSettings_repeatCount.getValue() , &timerSettings_repeatCount); - CTimerListRepeatNotifier notifier((int *)&timer->eventRepeat,m4,m5, m_weekdaysStr); + CTimerListRepeatNotifier notifier((int *)&timer->eventRepeat,m4,m5, &m_weekdaysStr); CMenuOptionChooser* m3 = new CMenuOptionChooser(LOCALE_TIMERLIST_REPEAT, (int *)&timer->eventRepeat, TIMERLIST_REPEAT_OPTIONS, TIMERLIST_REPEAT_OPTION_COUNT, true, ¬ifier); //printf("TIMER: rec dir %s len %s\n", timer->recordingDir, strlen(timer->recordingDir)); @@ -1162,14 +1164,14 @@ int CTimerList::newTimer() CDateInput timerSettings_stopTime(LOCALE_TIMERLIST_STOPTIME, &(timerNew.stopTime) , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); CMenuForwarder *m2 = new CMenuForwarder(LOCALE_TIMERLIST_STOPTIME, true, timerSettings_stopTime.getValue (), &timerSettings_stopTime ); - CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); + CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, &m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); CMenuForwarder *m4 = new CMenuForwarder(LOCALE_TIMERLIST_WEEKDAYS, false, m_weekdaysStr, &timerSettings_weekdays); CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int&)timerNew.repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); CMenuForwarder *m5 = new CMenuForwarder(LOCALE_TIMERLIST_REPEATCOUNT, false,timerSettings_repeatCount.getValue() , &timerSettings_repeatCount); - CTimerListRepeatNotifier notifier((int *)&timerNew.eventRepeat,m4,m5, m_weekdaysStr); - strcpy(m_weekdaysStr,"XXXXX--"); + CTimerListRepeatNotifier notifier((int *)&timerNew.eventRepeat,m4,m5, &m_weekdaysStr); + m_weekdaysStr = "XXXXX--"; CMenuOptionChooser* m3 = new CMenuOptionChooser(LOCALE_TIMERLIST_REPEAT, (int *)&timerNew.eventRepeat, TIMERLIST_REPEAT_OPTIONS, TIMERLIST_REPEAT_OPTION_COUNT, true, ¬ifier); @@ -1188,20 +1190,20 @@ int CTimerList::newTimer() for (int j = 0; j < (int) channels.size(); j++) { char cChannelId[3+16+1+1]; sprintf(cChannelId, "SC:" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS ",", channels[j]->channel_id); - mwtv->addItem(new CMenuForwarderNonLocalized(channels[j]->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channels[j]->getName()).c_str(), CRCInput::RC_nokey, NULL, channels[j]->scrambled ? NEUTRINO_ICON_SCRAMBLED : NULL)); + mwtv->addItem(new CMenuForwarder(channels[j]->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channels[j]->getName()).c_str(), CRCInput::RC_nokey, NULL, channels[j]->scrambled ? NEUTRINO_ICON_SCRAMBLED : NULL)); } if (!channels.empty()) - mctv.addItem(new CMenuForwarderNonLocalized(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : g_bouquetManager->Bouquets[i]->Name.c_str() /*g_bouquetManager->Bouquets[i]->Name.c_str()*/, true, NULL, mwtv)); + mctv.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : g_bouquetManager->Bouquets[i]->Name.c_str() /*g_bouquetManager->Bouquets[i]->Name.c_str()*/, true, NULL, mwtv)); g_bouquetManager->Bouquets[i]->getRadioChannels(channels); for (int j = 0; j < (int) channels.size(); j++) { char cChannelId[3+16+1+1]; sprintf(cChannelId, "SC:" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS ",", channels[j]->channel_id); - mwradio->addItem(new CMenuForwarderNonLocalized(channels[j]->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channels[j]->getName()).c_str(), CRCInput::RC_nokey, NULL, channels[j]->scrambled ? NEUTRINO_ICON_SCRAMBLED : NULL)); + mwradio->addItem(new CMenuForwarder(channels[j]->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channels[j]->getName()).c_str(), CRCInput::RC_nokey, NULL, channels[j]->scrambled ? NEUTRINO_ICON_SCRAMBLED : NULL)); } if (!channels.empty()) - mcradio.addItem(new CMenuForwarderNonLocalized(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwradio)); + mcradio.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwradio)); } } @@ -1225,7 +1227,7 @@ int CTimerList::newTimer() CTimerListNewNotifier notifier2((int *)&timerNew.eventType, &timerNew.stopTime,m2,m6,m8,m9,m10,m7, - timerSettings_stopTime.getValue()); + &timerSettings_stopTime.getValue()); CMenuOptionChooser* m0; if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) m0 = new CMenuOptionChooser(LOCALE_TIMERLIST_TYPE, (int *)&timerNew.eventType, TIMERLIST_TYPE_OPTIONS, TIMERLIST_TYPE_OPTION_COUNT, true, ¬ifier2); diff --git a/src/gui/timerlist.h b/src/gui/timerlist.h index 4e752c4e6..067d942bb 100644 --- a/src/gui/timerlist.h +++ b/src/gui/timerlist.h @@ -64,7 +64,7 @@ class CTimerList : public CMenuTarget CTimerd::responseGetTimer timerNew; int timerNew_standby_on; char timerNew_channel_name[30]; - char m_weekdaysStr[8]; + std::string m_weekdaysStr; int timer_apids_dflt; int timer_apids_std; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index c9a725678..48d65de19 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -162,7 +162,7 @@ bool CFlashUpdate::selectHttpImage(void) SelectionWidget.addItem(GenericMenuBack); SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::LINE)); - SelectionWidget.addItem(new CMenuForwarderNonLocalized(current, false)); + SelectionWidget.addItem(new CMenuForwarder(current, false)); std::ifstream urlFile(g_settings.softupdate_url_file); #ifdef DEBUG printf("[update] file %s\n", g_settings.softupdate_url_file); @@ -230,10 +230,10 @@ bool CFlashUpdate::selectHttpImage(void) descriptions.push_back(description); /* workaround since CMenuForwarder does not store the Option String itself */ - //SelectionWidget.addItem(new CMenuForwarderNonLocalized(names[i].c_str(), enabled, descriptions[i].c_str(), new CUpdateMenuTarget(i, &selected))); + //SelectionWidget.addItem(new CMenuForwarder(names[i].c_str(), enabled, descriptions[i].c_str(), new CUpdateMenuTarget(i, &selected))); CUpdateMenuTarget * up = new CUpdateMenuTarget(i, &selected); update_t_list.push_back(up); - SelectionWidget.addItem(new CMenuForwarderNonLocalized(descriptions[i].c_str(), enabled, names[i].c_str(), up)); + SelectionWidget.addItem(new CMenuForwarder(descriptions[i].c_str(), enabled, names[i].c_str(), up)); i++; } } @@ -814,7 +814,7 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey) enabled = false; // build jffs2 image from root0 if ((actionkey == "readmtd") && (lx == mtdInfo->findMTDNumberFromName("root0"))) { - CMenuForwarder *mf = new CMenuDForwarderNonLocalized("root0", true, NULL, new CFlashExpertSetup(), NULL, CRCInput::convertDigitToKey(shortcut++)); + CMenuForwarder *mf = new CMenuDForwarder("root0", true, NULL, new CFlashExpertSetup(), NULL, CRCInput::convertDigitToKey(shortcut++)); mtdselector->addItem(mf); continue; } @@ -824,11 +824,11 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey) enabled = false; #endif sprintf(sActionKey, "%s%d", actionkey.c_str(), lx); - mtdselector->addItem(new CMenuForwarderNonLocalized(mtdInfo->getMTDName(lx).c_str(), enabled, NULL, this, sActionKey, CRCInput::convertDigitToKey(shortcut++))); + mtdselector->addItem(new CMenuForwarder(mtdInfo->getMTDName(lx).c_str(), enabled, NULL, this, sActionKey, CRCInput::convertDigitToKey(shortcut++))); } #ifndef BOXMODEL_APOLLO if (actionkey == "writemtd") - mtdselector->addItem(new CMenuForwarderNonLocalized("systemFS with settings", true, NULL, this, "writemtd10", CRCInput::convertDigitToKey(shortcut++))); + mtdselector->addItem(new CMenuForwarder("systemFS with settings", true, NULL, this, "writemtd10", CRCInput::convertDigitToKey(shortcut++))); #endif int res = mtdselector->exec(NULL,""); delete mtdselector; @@ -855,7 +855,7 @@ int CFlashExpert::showFileSelector(const std::string & actionkey) int pos = filen.find(".img"); if(pos!=-1) { - fileselector->addItem(new CMenuForwarderNonLocalized(filen.c_str(), true, NULL, this, (actionkey + filen).c_str())); + fileselector->addItem(new CMenuForwarder(filen.c_str(), true, NULL, this, (actionkey + filen).c_str())); //TODO make sure filen is UTF-8 encoded } free(namelist[count]); diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 914b04ca7..d70d8ba5d 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -319,7 +319,7 @@ bool CUserMenu::showUserMenu(int button) //printf("[neutrino usermenu] plugin %d, set key %d...\n", count, g_PluginList->getKey(count)); StreamFeaturesChanger = new CStreamFeaturesChangeExec(); keyhelper.get(&key,&icon, d_key); - menu_item = new CMenuForwarderNonLocalized(g_PluginList->getName(count), true, NULL, StreamFeaturesChanger, id, key, icon); + menu_item = new CMenuForwarder(g_PluginList->getName(count), true, NULL, StreamFeaturesChanger, id, key, icon); menu->addItem(menu_item, 0); cnt++; diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 83838687f..6b8257306 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -39,6 +39,7 @@ #include #include +#include #include @@ -174,14 +175,12 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y+ item_height, _dx- (name_start_x - x), left_text, item_color, 0, true); // UTF-8 //right text - if (right_text || right_bgcol) + if (right_text && (*right_text || right_bgcol)) { - int stringwidth = 0; - if (right_text) - stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text, true); + int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text, true); int stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text, true) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx if (right_bgcol) { - if (!right_text) + if (!*right_text) stringstartposOption -= 60; fb_pixel_t right_frame_col, right_bg_col; if (active) { @@ -197,7 +196,7 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, col.setCorner(RADIUS_LARGE); col.paint(false); } - if (right_text) { + if (*right_text) { stringstartposOption -= (icon_w == 0 ? 0 : icon_w + icon_frame_w); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+item_height,dx- (stringstartposOption- x), right_text, item_color, 0, true); } @@ -1457,7 +1456,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) else l_option = g_Locale->getText(options[count].value); sprintf(cnt, "%d", count); - CMenuForwarderNonLocalized *mn_option = new CMenuForwarderNonLocalized(l_option, true, NULL, selector, cnt); + CMenuForwarder *mn_option = new CMenuForwarder(l_option, true, NULL, selector, to_string(count).c_str()); mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); menu->addItem(mn_option, selected); } @@ -1640,7 +1639,7 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) if (strcmp(options[count].c_str(), optionValue) == 0) selected = true; sprintf(cnt, "%d", count); - CMenuForwarderNonLocalized *mn_option = new CMenuForwarderNonLocalized(options[count].c_str(), true, NULL, selector, cnt); + CMenuForwarder *mn_option = new CMenuForwarder(options[count], true, NULL, selector, to_string(count).c_str()); mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); menu->addItem(mn_option, selected); } @@ -1757,25 +1756,11 @@ int CMenuOptionLanguageChooser::paint( bool selected ) } //------------------------------------------------------------------------------------------------------------------------------- -CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) -{ - option = Option; - option_string = NULL; - text=Text; - active = Active; - jumpTarget = Target; - actionKey = ActionKey ? ActionKey : ""; - directKey = DirectKey; - iconName = IconName ? IconName : ""; - iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; - isStatic = IsStatic; -} - CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { - option = NULL; - option_string = &Option; - text=Text; + option_string_ptr = &Option; + name = Text; + nameString = ""; active = Active; jumpTarget = Target; actionKey = ActionKey ? ActionKey : ""; @@ -1785,20 +1770,65 @@ CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, isStatic = IsStatic; } -void CMenuForwarder::setOption(const char * const Option) +CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { - option = Option; - option_string = NULL; - if (used && x != -1) - paint(); + option_string_ptr = &Option; + name = NONEXISTANT_LOCALE; + nameString = Text; + active = Active; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; + directKey = DirectKey; + iconName = IconName ? IconName : ""; + iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; + isStatic = IsStatic; +} + +CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) +{ + option_string = Option ? Option : ""; + option_string_ptr = &option_string; + name = Text; + nameString = ""; + active = Active; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; + directKey = DirectKey; + iconName = IconName ? IconName : ""; + iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; + isStatic = IsStatic; +} + +CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) +{ + option_string = Option ? Option : ""; + option_string_ptr = &option_string; + name = NONEXISTANT_LOCALE; + nameString = Text; + active = Active; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; + directKey = DirectKey; + iconName = IconName ? IconName : ""; + iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; + isStatic = IsStatic; +} + +void CMenuForwarder::setName(const std::string& t) +{ + name = NONEXISTANT_LOCALE; + nameString = t; +} + +void CMenuForwarder::setName(const neutrino_locale_t t) +{ + name = t; + nameString = ""; } void CMenuForwarder::setOption(const std::string &Option) { - option = NULL; - option_string = &Option; - if (used && x != -1) - paint(); + option_string = Option; } int CMenuForwarder::getHeight(void) const @@ -1806,32 +1836,18 @@ int CMenuForwarder::getHeight(void) const return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); } -// used gets set by the addItem() function. This is for set to paint Text from locales by just not calling the addItem() function. -// Without this, the changeNotifiers would become machine-dependent. -void CMenuForwarder::setTextLocale(const neutrino_locale_t Text) -{ - text=Text; - - if (used && x != -1) - paint(); -} - int CMenuForwarder::getWidth(void) { - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(text), true); - const char * option_text = NULL; - - if (option) - option_text = option; - else if (option_string) - option_text = option_string->c_str(); + const char *_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); + int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(_name, true); fb_pixel_t bgcol = 0; + std::string option_name = getOption(); if (jumpTarget) bgcol = jumpTarget->getColor(); - if (option_text != NULL) - tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true); + if (!option_name.empty()) + tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_name.c_str(), true); else if (bgcol) tw += 10 + 60; @@ -1850,28 +1866,21 @@ int CMenuForwarder::exec(CMenuTarget* parent) } } -const char * CMenuForwarder::getOption(void) +std::string CMenuForwarder::getOption(void) { - if (option) - return option; - if (option_string) - return option_string->c_str(); + if (!option_string_ptr->empty()) + return *option_string_ptr; if (jumpTarget) - return jumpTarget->getTargetValue(); - return NULL; -} - -const char * CMenuForwarder::getName(void) -{ - return g_Locale->getText(text); + return jumpTarget->getValue(); + return ""; } int CMenuForwarder::paint(bool selected) { int height = getHeight(); - const char * l_text = getName(); + const char * l_name = getName(); - const char * option_text = getOption(); + std::string option_name = getOption(); fb_pixel_t bgcol = 0; if (jumpTarget) bgcol = jumpTarget->getColor(); @@ -1883,80 +1892,11 @@ int CMenuForwarder::paint(bool selected) paintItemButton(selected, height); //caption - paintItemCaption(selected, height, l_text, option_text, bgcol); + paintItemCaption(selected, height, l_name, option_name.c_str(), bgcol); return y+ height; } -CMenuDForwarder::CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) - : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ -} - -CMenuDForwarder::CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) - : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ -} - -CMenuDForwarder::~CMenuDForwarder() -{ - delete jumpTarget; -} - -//------------------------------------------------------------------------------------------------------------------------------- -const char * CMenuForwarderNonLocalized::getName(void) -{ - return the_text.c_str(); -} - -CMenuForwarderNonLocalized::CMenuForwarderNonLocalized(const char * const Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) : CMenuForwarder(NONEXISTANT_LOCALE, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ - the_text = Text; -} - -CMenuForwarderNonLocalized::CMenuForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) : CMenuForwarder(NONEXISTANT_LOCALE, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ - the_text = Text; -} - -// used gets set by the addItem() function. This is for set to paint non localized Text by just not calling the addItem() function. -// Without this, the changeNotifiers would become machine-dependent. -void CMenuForwarderNonLocalized::setText(const char * const Text) -{ - the_text = Text; - - if (used && x != -1) - paint(); -} - -int CMenuForwarderNonLocalized::getWidth(void) -{ - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(the_text, true); - const char * option_text = NULL; - if (option) - option_text = option; - else if (option_string) - option_text = option_string->c_str(); - - if (option_text != NULL) - tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true); - - return tw; -} - -CMenuDForwarderNonLocalized::CMenuDForwarderNonLocalized(const char * const Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) : CMenuForwarderNonLocalized(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ -} - -CMenuDForwarderNonLocalized::CMenuDForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) : CMenuForwarderNonLocalized(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ -} - -CMenuDForwarderNonLocalized::~CMenuDForwarderNonLocalized() -{ - delete jumpTarget; -} - //------------------------------------------------------------------------------------------------------------------------------- CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic) { diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 5e0d826a2..56cfcc88e 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -79,13 +79,16 @@ class CChangeObserver class CMenuTarget { + protected: + std::string *valueString; + std::string valueStringTmp; public: - CMenuTarget(){} + CMenuTarget(){ valueString = &valueStringTmp; } virtual ~CMenuTarget(){} virtual void hide(){} virtual int exec(CMenuTarget* parent, const std::string & actionKey) = 0; + virtual std::string &getValue(void) { return *valueString; } virtual fb_pixel_t getColor(void) { return 0; } - virtual const char * getTargetValue() { return NULL; } }; class CMenuItem @@ -200,72 +203,67 @@ class CMenuSeparator : public CMenuItem class CMenuForwarder : public CMenuItem { - std::string actionKey; + std::string actionKey; protected: - const char * option; - const std::string * option_string; - CMenuTarget * jumpTarget; - neutrino_locale_t text; + std::string option_string; + const std::string * option_string_ptr; + CMenuTarget * jumpTarget; - virtual const char * getOption(void); - virtual const char * getName(void); + virtual std::string getOption(void); public: - CMenuForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); - CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const std::string & Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const neutrino_locale_t Text, const bool Active = true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const std::string & Text, const bool Active = true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); virtual ~CMenuForwarder(){} int paint(bool selected=false); int getHeight(void) const; int getWidth(void); - void setTextLocale(const neutrino_locale_t Text); - neutrino_locale_t getTextLocale() const {return text;}; - CMenuTarget* getTarget() const {return jumpTarget;}; - std::string getActionKey(){return actionKey;}; + neutrino_locale_t getTextLocale() const {return name;} + CMenuTarget* getTarget() const {return jumpTarget;} + std::string getActionKey(){return actionKey;} int exec(CMenuTarget* parent); - bool isSelectable(void) const - { - return active; - } - void setOption(const char * const Option); + bool isSelectable(void) const { return active; } void setOption(const std::string &Option); + void setName(const std::string& text); + void setName(const neutrino_locale_t text); }; class CMenuDForwarder : public CMenuForwarder { public: - CMenuDForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); + CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) + : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; + CMenuDForwarder(const std::string & Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) + : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; + CMenuDForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) + : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; + CMenuDForwarder(const std::string & Text, const bool Active=true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) + : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; - ~CMenuDForwarder(); -}; - -class CMenuForwarderNonLocalized : public CMenuForwarder -{ - protected: - std::string the_text; - virtual const char * getName(void); - public: - // Text must be UTF-8 encoded: - CMenuForwarderNonLocalized(const char * const Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - CMenuForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - virtual ~CMenuForwarderNonLocalized(){} - - int getWidth(void); - - void setText(const char * const Text); -}; - -class CMenuDForwarderNonLocalized : public CMenuForwarderNonLocalized -{ - public: - CMenuDForwarderNonLocalized(const char * const Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - CMenuDForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - ~CMenuDForwarderNonLocalized(); + ~CMenuDForwarder() { delete jumpTarget; } }; class CAbstractMenuOptionChooser : public CMenuItem diff --git a/src/gui/widget/mountchooser.cpp b/src/gui/widget/mountchooser.cpp index ff3f25ebe..fa56e462f 100644 --- a/src/gui/widget/mountchooser.cpp +++ b/src/gui/widget/mountchooser.cpp @@ -53,7 +53,7 @@ CMountChooser::CMountChooser(const neutrino_locale_t Name, const std::string & I { std::string s = g_settings.network_nfs[i].local_dir + " (" + g_settings.network_nfs[i].ip + ":" + g_settings.network_nfs[i].dir + ")"; snprintf(indexStr,sizeof(indexStr),"%d",i); - addItem(new CMenuForwarderNonLocalized(s.c_str(),true,NULL,this,(std::string("MID:") + std::string(indexStr)).c_str()), + addItem(new CMenuForwarder(s.c_str(),true,NULL,this,(std::string("MID:") + std::string(indexStr)).c_str()), selectedLocalDir == g_settings.network_nfs[i].local_dir); } } diff --git a/src/gui/widget/stringinput_ext.h b/src/gui/widget/stringinput_ext.h index 26e1c0d6f..cd1d9665f 100644 --- a/src/gui/widget/stringinput_ext.h +++ b/src/gui/widget/stringinput_ext.h @@ -180,7 +180,6 @@ class CDateInput : public CExtendedInput public: CDateInput(const neutrino_locale_t Name, time_t* Time, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL); ~CDateInput(); - char* getValue() {return value;} }; //---------------------------------------------------------------------------------------------------- @@ -230,9 +229,6 @@ class CIntInput : public CExtendedInput *@param Size how many digits can be entered */ CIntInput(const neutrino_locale_t Name, int& Value, const unsigned int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL); - char* getValue() { - return myValueStringOutput; - } void updateValue() { onBeforeExec(); } }; diff --git a/src/gui/zapit_setup.cpp b/src/gui/zapit_setup.cpp index c869c2d41..a9b2e8bc3 100644 --- a/src/gui/zapit_setup.cpp +++ b/src/gui/zapit_setup.cpp @@ -161,14 +161,14 @@ int CSelectChannelWidget::InitZapitChannelHelper(CZapitClient::channelsMode mode char cChannelId[60] = {0}; snprintf(cChannelId, sizeof(cChannelId), "ZC%c:%d|%" PRIx64 "#", (mode==CZapitClient::MODE_TV)?'T':'R', channel->number, channel->channel_id); - CMenuForwarderNonLocalized * chan_item = new CMenuForwarderNonLocalized(channel->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channel->getName()).c_str(), CRCInput::RC_nokey, NULL, channel->scrambled ?NEUTRINO_ICON_SCRAMBLED:NULL); + CMenuForwarder * chan_item = new CMenuForwarder(channel->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channel->getName()).c_str(), CRCInput::RC_nokey, NULL, channel->scrambled ?NEUTRINO_ICON_SCRAMBLED:NULL); chan_item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); mwtv->addItem(chan_item); } if(!channels.empty() && (!g_bouquetManager->Bouquets[i]->bHidden )) { - mctv.addItem(new CMenuForwarderNonLocalized(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwtv)); + mctv.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwtv)); } } int res = mctv.exec (NULL, ""); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 453f9f5a8..a180fa93a 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -3621,7 +3621,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) // zB vtxt-plugins sprintf(id, "%d", count); enabled_count++; - MoviePluginSelector.addItem(new CMenuForwarderNonLocalized(g_PluginList->getName(count), true, NULL, MoviePluginChanger, id, CRCInput::convertDigitToKey(count)), (cnt == 0)); + MoviePluginSelector.addItem(new CMenuForwarder(g_PluginList->getName(count), true, NULL, MoviePluginChanger, id, CRCInput::convertDigitToKey(count)), (cnt == 0)); cnt++; } } diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index 72c476b93..3caad3e5c 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -288,7 +288,7 @@ void CNeutrinoApp::InitMenuMain() } #ifdef ENABLE_TEST_MENU - personalize.addItem(MENU_MAIN, new CMenuForwarderNonLocalized("Test menu", true, NULL, new CTestMenu()), NULL, false, CPersonalizeGui::PERSONALIZE_SHOW_NO); + personalize.addItem(MENU_MAIN, new CMenuForwarder("Test menu", true, NULL, new CTestMenu()), NULL, false, CPersonalizeGui::PERSONALIZE_SHOW_NO); #endif } diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index 48c500b05..61f01bd0e 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -2006,9 +2006,9 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh) hh->printf("\t\t\t\t%s\n",zRepCount.c_str()); hh->printf("\t\t\t\t%d\n",(int)timer->eventRepeat); hh->printf("\t\t\t\t%s\n",zRep.c_str()); - char weekdays[8]= {0}; + std::string weekdays; NeutrinoAPI->Timerd->setWeekdaysToStr(timer->eventRepeat, weekdays); - hh->printf("\t\t\t\t%s\n",weekdays); + hh->printf("\t\t\t\t%s\n", weekdays.c_str()); hh->WriteLn("\t\t\t\n"); // channel infos @@ -2354,7 +2354,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) else // default: no repeat rep = (CTimerd::CTimerEventRepeat)0; if(((int)rep) >= ((int)CTimerd::TIMERREPEAT_WEEKDAYS) && hh->ParamList["wd"] != "") - NeutrinoAPI->Timerd->getWeekdaysFromStr(&rep, hh->ParamList["wd"].c_str()); + NeutrinoAPI->Timerd->getWeekdaysFromStr(&rep, hh->ParamList["wd"]); // apids bool changeApids=false; diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp index 9d557fbbb..593c74c51 100644 --- a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp @@ -981,7 +981,7 @@ std::string CNeutrinoYParser::func_set_timer_form(CyhookHandler *hh, std::strin string_printf("\n",(int)CTimerd::TIMERREPEAT_WEEKDAYS, sel.c_str(), zRep.c_str()); // Weekdays - char weekdays[8]; + std::string weekdays; NeutrinoAPI->Timerd->setWeekdaysToStr(timer.eventRepeat, weekdays); hh->ParamList["weekdays"]= weekdays; From ed9ee24f68d7a0eb588ad6bd936c6c36b1813d4b Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sat, 18 Jan 2014 01:47:22 +0100 Subject: [PATCH 21/54] Preparing the menu classes for Lua Part #3 - Add non locale variants for CMenuOptionNumberChooser and CMenuOptionChooser - Adaptation of CMenuOptionStringChooser, CChangeObserver THX Martii Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/afbd87083bf56bbcea1eb5be43625bf5a9a8b86d Author: Michael Liebmann Date: 2014-01-18 (Sat, 18 Jan 2014) Origin message was: ------------------ Preparing the menu classes for Lua Part #3 - Add non locale variants for CMenuOptionNumberChooser and CMenuOptionChooser - Adaptation of CMenuOptionStringChooser, CChangeObserver THX Martii ------------------ This commit was generated by Migit --- src/gui/audio_select.cpp | 7 +- src/gui/moviebrowser.cpp | 5 +- src/gui/personalize.cpp | 4 +- src/gui/user_menue_setup.cpp | 4 +- src/gui/vfd_setup.cpp | 8 +- src/gui/widget/menue.cpp | 297 ++++++++++++++++++++--------------- src/gui/widget/menue.h | 98 ++++++------ 7 files changed, 236 insertions(+), 187 deletions(-) diff --git a/src/gui/audio_select.cpp b/src/gui/audio_select.cpp index 9b8c9433b..5ec7c5fd7 100644 --- a/src/gui/audio_select.cpp +++ b/src/gui/audio_select.cpp @@ -194,10 +194,9 @@ int CAudioSelectMenuHandler::doMenu () int percent[p_count]; for (uint i=0; i < p_count; i++) { percent[i] = CZapit::getInstance()->GetPidVolume(0, g_RemoteControl->current_PIDs.APIDs[i].pid); - AudioSelector.addItem(new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &percent[i], - i == g_RemoteControl->current_PIDs.PIDs.selected_apid, - 0, 999, CVolume::getInstance(), 0, 0, NONEXISTANT_LOCALE, - g_RemoteControl->current_PIDs.APIDs[i].desc)); + AudioSelector.addItem(new CMenuOptionNumberChooser(g_RemoteControl->current_PIDs.APIDs[i].desc, + &percent[i], i == g_RemoteControl->current_PIDs.PIDs.selected_apid, + 0, 999, CVolume::getInstance())); } return AudioSelector.exec(NULL, ""); diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 70b5862ea..b93f43586 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -3751,9 +3751,8 @@ bool CMovieBrowser::showYTMenu() mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_MAX_RESULTS, &m_settings.ytresults, true, 10, 50, NULL)); mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_MAX_HISTORY, &m_settings.ytsearch_history_max, true, 10, 50, NULL)); - char rstr[20] = {0}; - sprintf(rstr, "%s", m_settings.ytregion.c_str()); - CMenuOptionStringChooser * region = new CMenuOptionStringChooser(LOCALE_MOVIEBROWSER_YT_REGION, rstr, true, NULL, CRCInput::RC_nokey, "", true); + std::string rstr = m_settings.ytregion; + CMenuOptionStringChooser * region = new CMenuOptionStringChooser(LOCALE_MOVIEBROWSER_YT_REGION, &rstr, true, NULL, CRCInput::RC_nokey, "", true); region->addOption("default"); region->addOption("DE"); region->addOption("PL"); diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index 7a50f8792..3f9dc798d 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -604,10 +604,10 @@ bool CPersonalizeGui::changeNotify(const neutrino_locale_t locale, void *data) if (opt_val == PERSONALIZE_MODE_VISIBLE || opt_val == PERSONALIZE_MODE_PIN) { chooser->setActive(false); - chooser->setOptionValue(PERSONALIZE_MODE_NOTVISIBLE); + chooser->setOption(PERSONALIZE_MODE_NOTVISIBLE); }else{ chooser->setActive(true); - chooser->setOptionValue(PERSONALIZE_MODE_VISIBLE); + chooser->setOption(PERSONALIZE_MODE_VISIBLE); } } } diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index 1872aa542..967b5666b 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -165,8 +165,8 @@ void CUserMenuSetup::checkButtonItems() { CMenuOptionChooser * opt_c = NULL; opt_c = static_cast (ums->getItem(i)); - neutrino_locale_t opt_locale = USERMENU_ITEM_OPTIONS[opt_c->getOptionValue()].value; - int set_key = USERMENU_ITEM_OPTIONS[opt_c->getOptionValue()].key; + neutrino_locale_t opt_locale = USERMENU_ITEM_OPTIONS[opt_c->getOption()].value; + int set_key = USERMENU_ITEM_OPTIONS[opt_c->getOption()].key; opt_c = NULL; if (set_key != SNeutrinoSettings::ITEM_NONE) diff --git a/src/gui/vfd_setup.cpp b/src/gui/vfd_setup.cpp index 03796cba5..73d4d65f4 100644 --- a/src/gui/vfd_setup.cpp +++ b/src/gui/vfd_setup.cpp @@ -169,20 +169,20 @@ void CVfdSetup::showBrightnessSetup(CMenuWidget *mn_widget) brightnessstandby = CVFD::getInstance()->getBrightnessStandby(); brightnessdeepstandby = CVFD::getInstance()->getBrightnessDeepStandby(); - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESS, &brightness, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESS, &brightness, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESS); mn_widget->addItem(nc); - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, &brightnessstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, &brightnessstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSSTANDBY); mn_widget->addItem(nc); if(cs_get_revision() > 7) { - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY, &brightnessdeepstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY, &brightnessdeepstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSDEEPSTANDBY); mn_widget->addItem(nc); } - nc = new CMenuOptionNumberChooser(LOCALE_LCDMENU_DIM_BRIGHTNESS, &g_settings.lcd_setting_dim_brightness, vfd_enabled, -1, 15, NULL, 0, -1, LOCALE_OPTIONS_OFF, NULL, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDMENU_DIM_BRIGHTNESS, &g_settings.lcd_setting_dim_brightness, vfd_enabled, -1, 15, NULL, 0, -1, LOCALE_OPTIONS_OFF, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSDIM); mn_widget->addItem(nc); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 6b8257306..625505c24 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1180,47 +1180,97 @@ void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::stri } //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name1, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn) +CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t Name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) { - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionName = name1; - active = Active; - optionValue = OptionValue; + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + name = Name; + active = Active; + optionValue = OptionValue; - lower_bound = min_value; - upper_bound = max_value; + lower_bound = min_value; + upper_bound = max_value; - display_offset = print_offset; + display_offset = print_offset; - localized_value = special_value; + localized_value = special_value; localized_value_name = special_value_name; - optionString = non_localized_name; - numberFormat = "%d"; + nameString = ""; + numberFormat = "%d"; + numberFormatFunction = NULL; + observ = Observ; + slider_on = sliderOn; + + numeric_input = false; +} + +CMenuOptionNumberChooser::CMenuOptionNumberChooser(const std::string &Name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + name = NONEXISTANT_LOCALE; + active = Active; + optionValue = OptionValue; + + lower_bound = min_value; + upper_bound = max_value; + + display_offset = print_offset; + + localized_value = special_value; + localized_value_name = special_value_name; + + nameString = Name; + numberFormat = "%d"; numberFormatFunction = NULL; observ = Observ; slider_on = sliderOn; + + numeric_input = false; } int CMenuOptionNumberChooser::exec(CMenuTarget*) { + int res = menu_return::RETURN_NONE; + if(msg == CRCInput::RC_left) { if (((*optionValue) > upper_bound) || ((*optionValue) <= lower_bound)) *optionValue = upper_bound; else (*optionValue)--; + } else if (numeric_input && msg == CRCInput::RC_ok) { + int size = 0; + int b = lower_bound; + if (b < 0) { + size++, + b = -b; + } + if (b < upper_bound) + b = upper_bound; + for (; b; b /= 10, size++); + CIntInput cii(name, *optionValue, size, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + cii.exec(NULL, ""); + if (*optionValue > upper_bound) + *optionValue = upper_bound; + else if (*optionValue < lower_bound) + *optionValue = lower_bound; + res = menu_return::RETURN_REPAINT; } else { if (((*optionValue) >= upper_bound) || ((*optionValue) < lower_bound)) *optionValue = lower_bound; else (*optionValue)++; } - if(observ) - observ->changeNotify(optionName, optionValue); + if(observ && !luaAction.empty()) { + // optionValue is int* + observ->changeNotify(luaState, luaAction, luaId, (void *) to_string(*optionValue).c_str()); + } else + if(observ) + observ->changeNotify(name, optionValue); + // give the observer a chance to modify the value paint(true); - return menu_return::RETURN_NONE; + return res; } int CMenuOptionNumberChooser::paint(bool selected) @@ -1240,46 +1290,38 @@ int CMenuOptionNumberChooser::paint(bool selected) else l_option = g_Locale->getText(localized_value_name); - const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName); - //paint item prepareItem(selected, height); //paint item icon paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); if(slider_on) - paintItemSlider( selected, height, *optionValue, (upper_bound - lower_bound) , l_optionName, l_option); + paintItemSlider( selected, height, *optionValue, (upper_bound - lower_bound) , getName(), l_option); //paint text - paintItemCaption(selected, height , l_optionName, l_option); + paintItemCaption(selected, height , getName(), l_option); return y+height; } int CMenuOptionNumberChooser::getWidth(void) { - const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName); - int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_optionName, true); - + int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName(), true); int _lower_bound = lower_bound; int _upper_bound = upper_bound; int m = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth(); int w1 = 0; - if (_lower_bound < 0) { + if (_lower_bound < 0) w1 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true); - _lower_bound *= -1; - } - while (_lower_bound > 0) { + while (_lower_bound) { w1 += m; _lower_bound /= 10; } int w2 = 0; - if (_upper_bound < 0) { + if (_upper_bound < 0) w2 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true); - _upper_bound *= -1; - } - while (_upper_bound > 0) { + while (_upper_bound) { w1 += m; _upper_bound /= 10; } @@ -1298,11 +1340,13 @@ int CMenuOptionNumberChooser::getWidth(void) return width + 10; /* min 10 pixels between option name and value. enough? */ } +//------------------------------------------------------------------------------------------------------------------------------- + CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = g_Locale->getText(OptionName); - optionName = OptionName; + nameString = ""; + name = OptionName; active = Active; optionValue = OptionValue; number_of_options = Number_Of_Options; @@ -1321,11 +1365,11 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * } } -CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = OptionName; - optionName = NONEXISTANT_LOCALE; + nameString = OptionName; + name = NONEXISTANT_LOCALE; active = Active; optionValue = OptionValue; number_of_options = Number_Of_Options; @@ -1349,8 +1393,8 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = g_Locale->getText(OptionName); - optionName = OptionName; + nameString = ""; + name = OptionName; active = Active; optionValue = OptionValue; number_of_options = Number_Of_Options; @@ -1363,13 +1407,13 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * options.push_back(Options[i]); } -CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval_ext * const Options, +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = OptionName; - optionName = NONEXISTANT_LOCALE; + nameString = OptionName; + name = NONEXISTANT_LOCALE; active = Active; optionValue = OptionValue; number_of_options = Number_Of_Options; @@ -1382,18 +1426,48 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio options.push_back(Options[i]); } +CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, std::vector &Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = ""; + name = OptionName; + active = Active; + optionValue = OptionValue; + options = Options; + observ = Observ; + directKey = DirectKey; + iconName = IconName; + pulldown = Pulldown; + optionsSort = OptionsSort; +} + +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, std::vector &Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = OptionName; + name = NONEXISTANT_LOCALE; + active = Active; + optionValue = OptionValue; + options = Options; + observ = Observ; + directKey = DirectKey; + iconName = IconName; + pulldown = Pulldown; + optionsSort = OptionsSort; +} + CMenuOptionChooser::~CMenuOptionChooser() { options.clear(); clearChooserOptions(); } -void CMenuOptionChooser::setOptionValue(const int newvalue) +void CMenuOptionChooser::setOption(const int newvalue) { *optionValue = newvalue; } -int CMenuOptionChooser::getOptionValue(void) const +int CMenuOptionChooser::getOption(void) const { return *optionValue; } @@ -1410,6 +1484,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) { bool wantsRepaint = false; int ret = menu_return::RETURN_NONE; + char *optionValname = NULL; if (optionsSort) { optionsSort = false; @@ -1437,8 +1512,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) if((msg == CRCInput::RC_ok) && pulldown) { int select = -1; - char cnt[5]; - CMenuWidget* menu = new CMenuWidget(optionNameString.c_str(), NEUTRINO_ICON_SETTINGS); + CMenuWidget* menu = new CMenuWidget(getName(), NEUTRINO_ICON_SETTINGS); /* FIXME: BACK button with hints enabled - parent menu getting holes, possible solution * to hide parent, or add hints ? */ menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); @@ -1455,7 +1529,6 @@ int CMenuOptionChooser::exec(CMenuTarget*) l_option = options[count].valname; else l_option = g_Locale->getText(options[count].value); - sprintf(cnt, "%d", count); CMenuForwarder *mn_option = new CMenuForwarder(l_option, true, NULL, selector, to_string(count).c_str()); mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); menu->addItem(mn_option, selected); @@ -1465,6 +1538,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) if(select >= 0) { *optionValue = options[select].key; + optionValname = (char *) options[select].valname; } delete menu; delete selector; @@ -1473,18 +1547,25 @@ int CMenuOptionChooser::exec(CMenuTarget*) if (options[count].key == (*optionValue)) { if(msg == CRCInput::RC_left) { if(count > 0) + optionValname = (char *) options[(count-1) % number_of_options].valname, *optionValue = options[(count-1) % number_of_options].key; else + optionValname = (char *) options[number_of_options-1].valname, *optionValue = options[number_of_options-1].key; } else + optionValname = (char *) options[(count+1) % number_of_options].valname, *optionValue = options[(count+1) % number_of_options].key; break; } } } paint(true); - if(observ) - wantsRepaint = observ->changeNotify(optionName, optionValue); + if(observ && !luaAction.empty()) { + if (optionValname) + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, optionValname); + } else + if(observ) + wantsRepaint = observ->changeNotify(name, optionValue); if ( wantsRepaint ) ret = menu_return::RETURN_REPAINT; @@ -1494,9 +1575,6 @@ int CMenuOptionChooser::exec(CMenuTarget*) int CMenuOptionChooser::paint( bool selected) { - if(optionName != NONEXISTANT_LOCALE) - optionNameString = g_Locale->getText(optionName); - neutrino_locale_t option = NONEXISTANT_LOCALE; const char * l_option = NULL; @@ -1528,7 +1606,7 @@ int CMenuOptionChooser::paint( bool selected) paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); //paint text - paintItemCaption(selected, height , optionNameString.c_str(), l_option); + paintItemCaption(selected, height , getName(), l_option); return y+height; } @@ -1536,7 +1614,7 @@ int CMenuOptionChooser::paint( bool selected) int CMenuOptionChooser::getWidth(void) { int ow = 0; - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(optionNameString, true); + int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName(), true); int width = tw; for(unsigned int count = 0; count < options.size(); count++) { @@ -1557,47 +1635,29 @@ int CMenuOptionChooser::getWidth(void) //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, char* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = g_Locale->getText(OptionName); - optionName = OptionName; - active = Active; - optionValue = OptionValue; - observ = Observ; - optionValueString = NULL; - directKey = DirectKey; - iconName = IconName; - pulldown = Pulldown; -} - -CMenuOptionStringChooser::CMenuOptionStringChooser(const char* OptionName, char* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = OptionName; - optionName = NONEXISTANT_LOCALE; - active = Active; - optionValue = OptionValue; - observ = Observ; - optionValueString = NULL; - - directKey = DirectKey; - iconName = IconName; - pulldown = Pulldown; -} - CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) { - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = g_Locale->getText(OptionName); - optionName = OptionName; - active = Active; - optionValue = (char *) OptionValue->c_str(); + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = ""; + name = OptionName; + active = Active; optionValueString = OptionValue; - observ = Observ; + observ = Observ; + directKey = DirectKey; + iconName = IconName; + pulldown = Pulldown; +} - directKey = DirectKey; - iconName = IconName; +CMenuOptionStringChooser::CMenuOptionStringChooser(const std::string &OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = OptionName; + name = NONEXISTANT_LOCALE; + active = Active; + optionValueString = OptionValue; + observ = Observ; + directKey = DirectKey; + iconName = IconName; pulldown = Pulldown; } @@ -1607,9 +1667,9 @@ CMenuOptionStringChooser::~CMenuOptionStringChooser() options.clear(); } -void CMenuOptionStringChooser::addOption(const char * const value) +void CMenuOptionStringChooser::addOption(const std::string &value) { - options.push_back(std::string(value)); + options.push_back(value); } void CMenuOptionStringChooser::sortOptions() @@ -1624,61 +1684,39 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) if((!parent || msg == CRCInput::RC_ok) && pulldown) { int select = -1; - char cnt[5]; if (parent) parent->hide(); - CMenuWidget* menu = new CMenuWidget(optionNameString.c_str(), NEUTRINO_ICON_SETTINGS); + const char *l_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); + CMenuWidget* menu = new CMenuWidget(l_name, NEUTRINO_ICON_SETTINGS); menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); //if(parent) menu->move(20, 0); CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); for(unsigned int count = 0; count < options.size(); count++) { - bool selected = false; - if (strcmp(options[count].c_str(), optionValue) == 0) - selected = true; - sprintf(cnt, "%d", count); + bool selected = optionValueString && (options[count] == *optionValueString); CMenuForwarder *mn_option = new CMenuForwarder(options[count], true, NULL, selector, to_string(count).c_str()); mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); menu->addItem(mn_option, selected); } menu->exec(NULL, ""); ret = menu_return::RETURN_REPAINT; - if(select >= 0) { - if (optionValueString) { - *optionValueString = options[select]; - optionValue = (char *)optionValueString->c_str(); - } else - strcpy(optionValue, options[select].c_str()); - } + if(select >= 0 && optionValueString) + *optionValueString = options[select]; delete menu; delete selector; } else { //select next value for(unsigned int count = 0; count < options.size(); count++) { - if (strcmp(options[count].c_str(), optionValue) == 0) { + if (optionValueString && (options[count] == *optionValueString)) { if(msg == CRCInput::RC_left) { - if(count > 0) { - if (optionValueString) { - *optionValueString = options[(count - 1) % options.size()]; - optionValue = (char *)optionValueString->c_str(); - } else - strcpy(optionValue, options[(count - 1) % options.size()].c_str()); - } else { - if (optionValueString) { - *optionValueString = options[options.size() - 1]; - optionValue = (char *)optionValueString->c_str(); - } else - strcpy(optionValue, options[options.size() - 1].c_str()); - } - } else { - if (optionValueString) { - *optionValueString = options[(count + 1) % options.size()]; - optionValue = (char *)optionValueString->c_str(); - } else - strcpy(optionValue, options[(count + 1) % options.size()].c_str()); - } + if(count > 0) + *optionValueString = options[(count - 1) % options.size()]; + else + *optionValueString = options[options.size() - 1]; + } else + *optionValueString = options[(count + 1) % options.size()]; //wantsRepaint = true; break; } @@ -1686,8 +1724,11 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) paint(true); } - if(observ) { - wantsRepaint = observ->changeNotify(optionName, optionValue); + if(observ && !luaAction.empty()) + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *)(optionValueString ? optionValueString->c_str() : "")); + else + if(observ) { + wantsRepaint = observ->changeNotify(name, (void *)(optionValueString ? optionValueString->c_str() : "")); } if (wantsRepaint) ret = menu_return::RETURN_REPAINT; @@ -1697,7 +1738,7 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) int CMenuOptionStringChooser::paint( bool selected ) { - const char * l_optionName = optionNameString.c_str(); + const char *l_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); //paint item prepareItem(selected, height); @@ -1706,7 +1747,7 @@ int CMenuOptionStringChooser::paint( bool selected ) paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); //paint text - paintItemCaption(selected, height , l_optionName, optionValue); + paintItemCaption(selected, height , l_name, optionValueString->c_str()); return y+height; } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 56cfcc88e..1d7423737 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -75,6 +75,10 @@ class CChangeObserver { return false; } + virtual bool changeNotify(lua_State * /*L*/, const std::string & /*luaId*/, const std::string & /*luaAction*/, void * /*Data*/) + { + return false; + } }; class CMenuTarget @@ -269,9 +273,8 @@ class CMenuDForwarder : public CMenuForwarder class CAbstractMenuOptionChooser : public CMenuItem { protected: - neutrino_locale_t optionName; - int height; - int * optionValue; + int height; + int * optionValue; int getHeight(void) const{return height;} @@ -279,10 +282,10 @@ class CAbstractMenuOptionChooser : public CMenuItem public: CAbstractMenuOptionChooser() { - optionName = NONEXISTANT_LOCALE; + name = NONEXISTANT_LOCALE; height = 0; optionValue = NULL; - }; + } ~CAbstractMenuOptionChooser(){} }; @@ -290,21 +293,26 @@ class CAbstractMenuOptionChooser : public CMenuItem class CMenuOptionNumberChooser : public CAbstractMenuOptionChooser { private: - const char * optionString; + int lower_bound; + int upper_bound; - int lower_bound; - int upper_bound; + int display_offset; - int display_offset; + int localized_value; + neutrino_locale_t localized_value_name; + bool slider_on; + bool numeric_input; + CChangeObserver * observ; + std::string numberFormat; + std::string (*numberFormatFunction)(int num); - int localized_value; - neutrino_locale_t localized_value_name; - bool slider_on; - CChangeObserver * observ; - std::string numberFormat; - std::string (*numberFormatFunction)(int num); public: - CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, const char * non_localized_name = NULL, bool sliderOn = false ); + CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, + const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, bool sliderOn = false ); + CMenuOptionNumberChooser(const std::string &name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, + const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, bool sliderOn = false ); int paint(bool selected); @@ -313,6 +321,7 @@ private: int getWidth(void); void setNumberFormat(std::string format) { numberFormat = format; } void setNumberFormat(std::string (*fun)(int)) { numberFormatFunction = fun; } + void setNumericInput(bool _numeric_input) { numeric_input = _numeric_input; } }; class CMenuOptionChooserOptions @@ -347,7 +356,7 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser struct keyval { - const int key; + const int key; const neutrino_locale_t value; }; @@ -356,37 +365,44 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser std::vector option_chooser_options_v; unsigned number_of_options; CChangeObserver * observ; - std::string optionNameString; bool pulldown; bool optionsSort; void clearChooserOptions(); public: - CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false, bool OptionsSort = false); - CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false, bool OptionsSort = false); - CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, + CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false, bool OptionsSort = false); - CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval_ext * const Options, + CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, std::vector &Options, + const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", + bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const std::string &Name, int * const OptionValue, std::vector &Options, + const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", + bool Pulldown = false, bool OptionsSort = false); ~CMenuOptionChooser(); - void setOptionValue(const int newvalue); - int getOptionValue(void) const; + void setOption(const int newvalue); + int getOption(void) const; int getWidth(void); int paint(bool selected); - std::string getOptionName()const {return optionNameString;}; + std::string getOptionName()const {return nameString;}; int exec(CMenuTarget* parent); int isMenueOptionChooser(void) const{return 1;} @@ -394,33 +410,27 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser class CMenuOptionStringChooser : public CMenuItem { - neutrino_locale_t optionName; - std::string optionNameString; - int height; - char * optionValue; - std::string * optionValueString; + int height; + std::string * optionValueString; std::vector options; - CChangeObserver * observ; - bool pulldown; + CChangeObserver * observ; + bool pulldown; public: - CMenuOptionStringChooser(const neutrino_locale_t OptionName, char* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false); - CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false); - CMenuOptionStringChooser(const char* OptionName, char* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false); + CMenuOptionStringChooser(const neutrino_locale_t Name, std::string* OptionValue, bool Active = false, + CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const std::string & IconName= "", bool Pulldown = false); + CMenuOptionStringChooser(const std::string &Name, std::string* OptionValue, bool Active = false, + CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const std::string & IconName= "", bool Pulldown = false); ~CMenuOptionStringChooser(); - void addOption(const char * value); + void addOption(const std::string &value); void removeOptions(){options.clear();}; int paint(bool selected); - int getHeight(void) const - { - return height; - } - bool isSelectable(void) const - { - return active; - } + int getHeight(void) const { return height; } + bool isSelectable(void) const { return active; } void sortOptions(); int exec(CMenuTarget* parent); int isMenueOptionChooser(void) const{return 1;} From 9cf6b04250ac5408640527192e33c68e11ee5a60 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sat, 18 Jan 2014 17:11:12 +0100 Subject: [PATCH 22/54] SNeutrinoSettings: convert more char[...] configuration values to std::string Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/004aa84e32fc3985aba5dfb86604e0748050fa86 Author: Michael Liebmann Date: 2014-01-18 (Sat, 18 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/vfd.cpp | 4 ++-- src/gui/settings_manager.cpp | 11 ++++++----- src/gui/update.cpp | 4 ++-- src/gui/update_settings.cpp | 2 +- src/neutrino.cpp | 14 +++++++------- src/system/httptool.cpp | 19 ++++++++----------- src/system/settings.h | 14 +++++++------- 7 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/driver/vfd.cpp b/src/driver/vfd.cpp index 6cfabe673..d6bb4d5b6 100644 --- a/src/driver/vfd.cpp +++ b/src/driver/vfd.cpp @@ -117,8 +117,8 @@ void CVFD::count_down() { void CVFD::wake_up() { if(!has_lcd) return; - if (atoi(g_settings.lcd_setting_dim_time) > 0) { - timeout_cnt = atoi(g_settings.lcd_setting_dim_time); + if (atoi(g_settings.lcd_setting_dim_time.c_str()) > 0) { + timeout_cnt = atoi(g_settings.lcd_setting_dim_time.c_str()); g_settings.lcd_setting_dim_brightness > -1 ? setBrightness(g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS]) : setPower(1); } diff --git a/src/gui/settings_manager.cpp b/src/gui/settings_manager.cpp index 9bb0d2bf5..46ef84f34 100644 --- a/src/gui/settings_manager.cpp +++ b/src/gui/settings_manager.cpp @@ -87,12 +87,13 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) fileBrowser.Dir_Mode = true; if (fileBrowser.exec("/var/tuxbox") == true) { - char fname[256] = "neutrino.conf", sname[256]; - CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVECONFIG, fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. "); + std::string fname = "neutrino.conf"; + CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVECONFIG, &fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. "); sms->exec(NULL, ""); - sprintf(sname, "%s/%s", fileBrowser.getSelectedFile()->Name.c_str(), fname); - printf("[neutrino] save settings: %s\n", sname); - CNeutrinoApp::getInstance()->saveSetup(sname); + + std::string sname = fileBrowser.getSelectedFile()->Name + "/" + fname; + printf("[neutrino] save settings: %s\n", sname.c_str()); + CNeutrinoApp::getInstance()->saveSetup(sname.c_str()); delete sms; } return res; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 48d65de19..d6f28f846 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -163,9 +163,9 @@ bool CFlashUpdate::selectHttpImage(void) SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::LINE)); SelectionWidget.addItem(new CMenuForwarder(current, false)); - std::ifstream urlFile(g_settings.softupdate_url_file); + std::ifstream urlFile(g_settings.softupdate_url_file.c_str()); #ifdef DEBUG - printf("[update] file %s\n", g_settings.softupdate_url_file); + printf("[update] file %s\n", g_settings.softupdate_url_file.c_str()); #endif unsigned int i = 0; diff --git a/src/gui/update_settings.cpp b/src/gui/update_settings.cpp index a261feac6..065f46b41 100644 --- a/src/gui/update_settings.cpp +++ b/src/gui/update_settings.cpp @@ -107,7 +107,7 @@ int CUpdateSettings::exec(CMenuTarget* parent, const std::string &actionKey) fileFilter.addFilter("urls"); fileBrowser.Filter = &fileFilter; if (fileBrowser.exec("/var/etc") == true) - strncpy(g_settings.softupdate_url_file, fileBrowser.getSelectedFile()->Name.c_str(), 30); + g_settings.softupdate_url_file = fileBrowser.getSelectedFile()->Name; return res; } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index a180fa93a..ced01ca64 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -517,7 +517,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.infobar_Text_blue = configfile.getInt32( "infobar_Text_blue", 0x64 ); //personalize - strcpy( g_settings.personalize_pincode, configfile.getString( "personalize_pincode", "0000" ).c_str() ); + g_settings.personalize_pincode = configfile.getString( "personalize_pincode", "0000" ); for (int i = 0; i < SNeutrinoSettings::P_SETTINGS_MAX; i++)//settings.h, settings.cpp g_settings.personalize[i] = configfile.getInt32( personalize_settings[i].personalize_settings_name, personalize_settings[i].personalize_default_val ); @@ -683,10 +683,10 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.flashupdate_createimage_add_spare = configfile.getInt32( "flashupdate_createimage_add_spare", 0); g_settings.flashupdate_createimage_add_kernel = configfile.getInt32( "flashupdate_createimage_add_kernel", 1); - strcpy(g_settings.softupdate_url_file, configfile.getString("softupdate_url_file", "/var/etc/update.urls").c_str()); - strcpy(g_settings.softupdate_proxyserver, configfile.getString("softupdate_proxyserver", "" ).c_str()); - strcpy(g_settings.softupdate_proxyusername, configfile.getString("softupdate_proxyusername", "" ).c_str()); - strcpy(g_settings.softupdate_proxypassword, configfile.getString("softupdate_proxypassword", "" ).c_str()); + g_settings.softupdate_url_file = configfile.getString("softupdate_url_file", "/var/etc/update.urls"); + g_settings.softupdate_proxyserver = configfile.getString("softupdate_proxyserver", "" ); + g_settings.softupdate_proxyusername = configfile.getString("softupdate_proxyusername", "" ); + g_settings.softupdate_proxypassword = configfile.getString("softupdate_proxypassword", "" ); // g_settings.font_file = configfile.getString("font_file", FONTDIR"/neutrino.ttf"); g_settings.ttx_font_file = configfile.getString( "ttx_font_file", FONTDIR"/DejaVuLGCSansMono-Bold.ttf"); @@ -702,14 +702,14 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.parentallock_lockage = 18; } g_settings.parentallock_defaultlocked = configfile.getInt32("parentallock_defaultlocked", 0); - strcpy( g_settings.parentallock_pincode, configfile.getString( "parentallock_pincode", "0000" ).c_str() ); + g_settings.parentallock_pincode = configfile.getString( "parentallock_pincode", "0000" ); for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) g_settings.timing[i] = configfile.getInt32(locale_real_names[timing_setting[i].name], timing_setting[i].default_timing); for (int i = 0; i < SNeutrinoSettings::LCD_SETTING_COUNT; i++) g_settings.lcd_setting[i] = configfile.getInt32(lcd_setting[i].name, lcd_setting[i].default_value); - strcpy(g_settings.lcd_setting_dim_time, configfile.getString("lcd_dim_time","0").c_str()); + g_settings.lcd_setting_dim_time = configfile.getString("lcd_dim_time","0"); g_settings.lcd_setting_dim_brightness = configfile.getInt32("lcd_dim_brightness", 0); g_settings.lcd_info_line = configfile.getInt32("lcd_info_line", 0);//channel name or clock diff --git a/src/system/httptool.cpp b/src/system/httptool.cpp index 20bd5fba7..ab93c954c 100644 --- a/src/system/httptool.cpp +++ b/src/system/httptool.cpp @@ -96,21 +96,18 @@ printf("url is %s\n", URL.c_str()); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); #endif - if(strcmp(g_settings.softupdate_proxyserver, "")!=0) - {//use proxyserver + if (!g_settings.softupdate_proxyserver.empty()) {//use proxyserver #ifdef DEBUG -printf("use proxyserver : %s\n", g_settings.softupdate_proxyserver); +printf("use proxyserver : %s\n", g_settings.softupdate_proxyserver.c_str()); #endif - curl_easy_setopt(curl, CURLOPT_PROXY, g_settings.softupdate_proxyserver); + curl_easy_setopt(curl, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); - if(strcmp(g_settings.softupdate_proxyusername,"")!=0) - {//use auth + if (!g_settings.softupdate_proxyusername.empty()) {//use auth //printf("use proxyauth\n"); - char tmp[200]; - strcpy(tmp, g_settings.softupdate_proxyusername); - strcat(tmp, ":"); - strcat(tmp, g_settings.softupdate_proxypassword); - curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, tmp); + std::string tmp = g_settings.softupdate_proxyusername; + tmp += ":"; + tmp += g_settings.softupdate_proxypassword; + curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, tmp.c_str()); } } #ifdef DEBUG diff --git a/src/system/settings.h b/src/system/settings.h index 61b9998cb..ff069d879 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -238,7 +238,7 @@ struct SNeutrinoSettings }; int personalize[P_SETTINGS_MAX]; - char personalize_pincode[5]; + std::string personalize_pincode; //timing enum TIMING_SETTINGS @@ -492,10 +492,10 @@ struct SNeutrinoSettings //Software-update int softupdate_mode; - char softupdate_url_file[31]; - char softupdate_proxyserver[31]; - char softupdate_proxyusername[31]; - char softupdate_proxypassword[31]; + std::string softupdate_url_file; + std::string softupdate_proxyserver; + std::string softupdate_proxyusername; + std::string softupdate_proxypassword; int softupdate_name_mode_apply; int softupdate_name_mode_backup; int apply_settings; @@ -514,7 +514,7 @@ struct SNeutrinoSettings int parentallock_prompt; int parentallock_lockage; int parentallock_defaultlocked; - char parentallock_pincode[5]; + std::string parentallock_pincode; // Font sizes @@ -568,7 +568,7 @@ struct SNeutrinoSettings }; int lcd_setting[LCD_SETTING_COUNT]; int lcd_info_line; - char lcd_setting_dim_time[4]; + std::string lcd_setting_dim_time; int lcd_setting_dim_brightness; int led_tv_mode; int led_standby_mode; From a46c5586690e22851f843f03b9c385c7700977b5 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sat, 18 Jan 2014 17:12:32 +0100 Subject: [PATCH 23/54] CScanSettings: convert char[...] configuration values to std::string Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/0a5a7b3146743eade2c47f5f395d5ac15ef71578 Author: Michael Liebmann Date: 2014-01-18 (Sat, 18 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/motorcontrol.cpp | 6 +-- src/gui/scan.cpp | 12 +++--- src/gui/scan.h | 2 +- src/gui/scan_setup.cpp | 81 ++++++++++++++++++++++------------------ src/gui/test_menu.cpp | 31 +++++++-------- src/system/settings.cpp | 24 ++++++------ src/system/settings.h | 13 +++---- 7 files changed, 86 insertions(+), 83 deletions(-) diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index ab86826c2..f23aa878f 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -117,7 +117,7 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) CZapitClient::commandSetScanSatelliteList sat; sat.position = CServiceManager::getInstance()->GetSatellitePosition(scansettings.satName); - strncpy(sat.satName, scansettings.satName, 49); + strncpy(sat.satName, scansettings.satName.c_str(), sizeof(sat.satName)); satList.push_back(sat); satellite_map_t & satmap = frontend->getSatellites(); @@ -131,8 +131,8 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) g_Zapit->setScanSatelliteList(satList); CZapit::getInstance()->SetLiveFrontend(frontend); - TP.feparams.dvb_feparams.frequency = atoi(scansettings.sat_TP_freq); - TP.feparams.dvb_feparams.u.qpsk.symbol_rate = atoi(scansettings.sat_TP_rate); + TP.feparams.dvb_feparams.frequency = atoi(scansettings.sat_TP_freq.c_str()); + TP.feparams.dvb_feparams.u.qpsk.symbol_rate = atoi(scansettings.sat_TP_rate.c_str()); TP.feparams.dvb_feparams.u.qpsk.fec_inner = (fe_code_rate_t)scansettings.sat_TP_fec; TP.polarization = scansettings.sat_TP_pol; diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index e96934ff3..2ed59771f 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -148,7 +148,7 @@ void CScanTs::testFunc() snprintf(buffer,sizeof(buffer), "%u %d %s %s %s", TP.feparams.dvb_feparams.frequency/1000, TP.feparams.dvb_feparams.u.qam.symbol_rate/1000, f, s, m); } printf("CScanTs::testFunc: %s\n", buffer); - paintLine(xpos2, ypos_cur_satellite, w - 95, pname); + paintLine(xpos2, ypos_cur_satellite, w - 95, pname.c_str()); paintLine(xpos2, ypos_frequency, w, buffer); success = g_Zapit->tune_TP(TP); } @@ -217,13 +217,13 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) scan_flags |= CServiceScan::SCAN_NIT; TP.scan_mode = scan_flags; if (deltype == FE_QPSK) { - TP.feparams.dvb_feparams.frequency = atoi(scansettings.sat_TP_freq); - TP.feparams.dvb_feparams.u.qpsk.symbol_rate = atoi(scansettings.sat_TP_rate); + TP.feparams.dvb_feparams.frequency = atoi(scansettings.sat_TP_freq.c_str()); + TP.feparams.dvb_feparams.u.qpsk.symbol_rate = atoi(scansettings.sat_TP_rate.c_str()); TP.feparams.dvb_feparams.u.qpsk.fec_inner = (fe_code_rate_t) scansettings.sat_TP_fec; TP.polarization = scansettings.sat_TP_pol; } else { - TP.feparams.dvb_feparams.frequency = atoi(scansettings.cable_TP_freq); - TP.feparams.dvb_feparams.u.qam.symbol_rate = atoi(scansettings.cable_TP_rate); + TP.feparams.dvb_feparams.frequency = atoi(scansettings.cable_TP_freq.c_str()); + TP.feparams.dvb_feparams.u.qam.symbol_rate = atoi(scansettings.cable_TP_rate.c_str()); TP.feparams.dvb_feparams.u.qam.fec_inner = (fe_code_rate_t)scansettings.cable_TP_fec; TP.feparams.dvb_feparams.u.qam.modulation = (fe_modulation_t) scansettings.cable_TP_mod; } @@ -243,7 +243,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) } else if(manual || !scan_all) { sat.position = CServiceManager::getInstance()->GetSatellitePosition(pname); - strncpy(sat.satName, pname, 49); + strncpy(sat.satName, pname.c_str(), 49); satList.push_back(sat); } else { satellite_map_t & satmap = CServiceManager::getInstance()->SatelliteList(); diff --git a/src/gui/scan.h b/src/gui/scan.h index 721e0cb33..b5851d420 100644 --- a/src/gui/scan.h +++ b/src/gui/scan.h @@ -80,7 +80,7 @@ class CScanTs : public CMenuTarget void prev_next_TP(bool); TP_params TP; int deltype; - char * pname; + std::string pname; public: CScanTs(int dtype = FE_QPSK); diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index b0ecff917..58f35dc42 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -569,16 +569,21 @@ int CScanSetup::showScanMenuFrontendSetup() nc->setHint("", LOCALE_MENU_HINT_SCAN_FETIMEOUT); setupMenu->addItem(nc); + std::string zapit_lat_str; + std::string zapit_long_str; + if (CFEManager::getInstance()->haveSat()) { sprintf(zapit_lat, "%02.6f", zapitCfg.gotoXXLatitude); sprintf(zapit_long, "%02.6f", zapitCfg.gotoXXLongitude); + zapit_lat_str = std::string(zapit_lat); + zapit_long_str = std::string(zapit_long); setupMenu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SATSETUP_EXTENDED_MOTOR)); CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_EXTRA_LADIRECTION, (int *)&zapitCfg.gotoXXLaDirection, OPTIONS_SOUTH0_NORTH1_OPTIONS, OPTIONS_SOUTH0_NORTH1_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(shortcut++)); mc->setHint("", LOCALE_MENU_HINT_SCAN_LADIRECTION); setupMenu->addItem(mc); - CStringInput * toff1 = new CStringInput(LOCALE_EXTRA_LATITUDE, (char *) zapit_lat, 10, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789."); + CStringInput * toff1 = new CStringInput(LOCALE_EXTRA_LATITUDE, &zapit_lat_str, 10, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789."); mf = new CMenuDForwarder(LOCALE_EXTRA_LATITUDE, true, zapit_lat, toff1, "", CRCInput::convertDigitToKey(shortcut++)); mf->setHint("", LOCALE_MENU_HINT_SCAN_LATITUDE); setupMenu->addItem(mf); @@ -587,7 +592,7 @@ int CScanSetup::showScanMenuFrontendSetup() mc->setHint("", LOCALE_MENU_HINT_SCAN_LODIRECTION); setupMenu->addItem(mc); - CStringInput * toff2 = new CStringInput(LOCALE_EXTRA_LONGITUDE, (char *) zapit_long, 10, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789."); + CStringInput * toff2 = new CStringInput(LOCALE_EXTRA_LONGITUDE, &zapit_long_str, 10, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789."); mf = new CMenuDForwarder(LOCALE_EXTRA_LONGITUDE, true, zapit_long, toff2, "", CRCInput::convertDigitToKey(shortcut++)); mf->setHint("", LOCALE_MENU_HINT_SCAN_LONGITUDE); setupMenu->addItem(mf); @@ -598,6 +603,10 @@ int CScanSetup::showScanMenuFrontendSetup() } int res = setupMenu->exec(NULL, ""); + + strncpy(zapit_lat, zapit_lat_str.c_str(), sizeof(zapit_lat)); + strncpy(zapit_long, zapit_long_str.c_str(), sizeof(zapit_long)); + delete setupMenu; if (fe_restart) { fe_restart = false; @@ -893,7 +902,7 @@ void CScanSetup::fillSatSelect(CMenuOptionStringChooser * select) select->addOption(satname.c_str()); satpos.insert(sit->first); - if (!sfound && strcmp(scansettings.satName, satname.c_str()) == 0) + if (!sfound && (scansettings.satName == satname)) sfound = true; } } @@ -901,7 +910,7 @@ void CScanSetup::fillSatSelect(CMenuOptionStringChooser * select) if(!sfound && !satpos.empty()) { tmpit = satpos.begin(); std::string satname = CServiceManager::getInstance()->GetSatelliteName(*tmpit); - snprintf(scansettings.satName, sizeof(scansettings.satName), "%s", satname.c_str()); + scansettings.satName = satname; } satellite_map_t & satmap = CServiceManager::getInstance()->SatelliteList(); for (sat_iterator_t sit = satmap.begin(); sit != satmap.end(); sit++) { @@ -933,13 +942,13 @@ void CScanSetup::fillCableSelect(CMenuOptionStringChooser * select) if (fname.empty()) fname = sit->second.name; - if (!sfound && strcmp(scansettings.cableName, sit->second.name.c_str()) == 0) + if (!sfound && (scansettings.cableName == sit->second.name)) sfound = true; dprintf(DEBUG_DEBUG, "got scanprovider (cable): %s\n", sit->second.name.c_str()); } if (!sfound && !fname.empty()) - snprintf(scansettings.cableName, sizeof(scansettings.cableName), "%s", fname.c_str()); + scansettings.cableName = fname; } int CScanSetup::showScanMenuSatFind() @@ -958,7 +967,7 @@ int CScanSetup::showScanMenuSatFind() sat_findMenu->setSelected(selected); sat_findMenu->addIntroItems(); - CMenuOptionStringChooser * feSatSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, scansettings.satName, true, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * feSatSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, &scansettings.satName, true, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); feSatSelect->setHint("", LOCALE_MENU_HINT_SCAN_SATSELECT); satellite_map_t & satmap = fe->getSatellites(); @@ -969,14 +978,14 @@ int CScanSetup::showScanMenuSatFind() continue; std::string satname = CServiceManager::getInstance()->GetSatelliteName(sit->first); feSatSelect->addOption(satname.c_str()); - if (!sfound && strcmp(scansettings.satName, satname.c_str()) == 0) + if (!sfound && (scansettings.satName == satname)) sfound = true; if (!sfound && firstname.empty()) firstname = satname; count++; } if(count && !sfound) - snprintf(scansettings.satName, sizeof(scansettings.satName), "%s", firstname.c_str()); + scansettings.satName = firstname; sat_findMenu->addItem(feSatSelect); @@ -1065,7 +1074,7 @@ void CScanSetup::addScanMenuManualScan(CMenuWidget *manual_Scan) manual_Scan->addIntroItems(); //---------------------------------------------------------------------- if (r_system == DVB_C) { - CMenuOptionStringChooser * cableSelect = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * cableSelect = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, &scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); cableSelect->setHint("", LOCALE_MENU_HINT_SCAN_CABLE); fillCableSelect(cableSelect); manual_Scan->addItem(cableSelect); @@ -1074,7 +1083,7 @@ void CScanSetup::addScanMenuManualScan(CMenuWidget *manual_Scan) manual_Scan->addItem(mf); mf = new CMenuDForwarder(LOCALE_SCANTS_SELECT_TP, true, NULL, new CTPSelectHandler(), "cable", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); } else { - CMenuOptionStringChooser * satSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, scansettings.satName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * satSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, &scansettings.satName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); satSelect->setHint("", LOCALE_MENU_HINT_SCAN_SATELLITE); /* add configured satellites to satSelect */ fillSatSelect(satSelect); @@ -1168,7 +1177,7 @@ void CScanSetup::addScanMenuAutoScan(CMenuWidget *auto_Scan) auto_Scan->addIntroItems(); if (r_system == DVB_C) { //cable - CMenuOptionStringChooser * cableSelect = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * cableSelect = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, &scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); cableSelect->setHint("", LOCALE_MENU_HINT_SCAN_CABLE); fillCableSelect(cableSelect); auto_Scan->addItem(cableSelect); @@ -1176,7 +1185,7 @@ void CScanSetup::addScanMenuAutoScan(CMenuWidget *auto_Scan) mf->setHint("", LOCALE_MENU_HINT_SCAN_NID); auto_Scan->addItem(mf); } else { - CMenuOptionStringChooser * satSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, scansettings.satName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * satSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, &scansettings.satName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); satSelect->setHint("", LOCALE_MENU_HINT_SCAN_SATELLITE); /* add configured satellites to satSelect */ fillSatSelect(satSelect); @@ -1202,7 +1211,7 @@ void CScanSetup::addScanMenuCable(CMenuWidget *menu) menu->addIntroItems(); //---------------------------------------------------------------------- - CMenuOptionStringChooser * select = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * select = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, &scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); fillCableSelect(select); select->setHint("", LOCALE_MENU_HINT_SCAN_CABLE); menu->addItem(select); @@ -1217,11 +1226,11 @@ void CScanSetup::addScanMenuCable(CMenuWidget *menu) menu->addItem(GenericMenuSeparatorLine); - CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, (char *) scansettings.cable_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, &scansettings.cable_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); CMenuForwarder *Freq = new CMenuDForwarder(LOCALE_EXTRA_TP_FREQ, true, scansettings.cable_TP_freq, freq, "", CRCInput::convertDigitToKey(shortCut++)); Freq->setHint("", LOCALE_MENU_HINT_SCAN_FREQ); - CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, (char *) scansettings.cable_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, &scansettings.cable_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); CMenuForwarder *Rate = new CMenuDForwarder(LOCALE_EXTRA_TP_RATE, true, scansettings.cable_TP_rate, rate, "", CRCInput::convertDigitToKey(shortCut++)); Rate->setHint("", LOCALE_MENU_HINT_SCAN_RATE); @@ -1263,11 +1272,11 @@ int CScanSetup::addScanOptionsItems(CMenuWidget *options_menu, const int &shortc CMenuForwarder *Freq = NULL; CMenuForwarder *Rate = NULL; if (r_system == DVB_S) { - CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, (char *) scansettings.sat_TP_freq, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, &scansettings.sat_TP_freq, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Freq = new CMenuDForwarder(LOCALE_EXTRA_TP_FREQ, true, scansettings.sat_TP_freq, freq, "", CRCInput::convertDigitToKey(shortCut++)); Freq->setHint("", LOCALE_MENU_HINT_SCAN_FREQ); - CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, (char *) scansettings.sat_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, &scansettings.sat_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Rate = new CMenuDForwarder(LOCALE_EXTRA_TP_RATE, true, scansettings.sat_TP_rate, rate, "", CRCInput::convertDigitToKey(shortCut++)); Rate->setHint("", LOCALE_MENU_HINT_SCAN_RATE); fec = new CMenuOptionChooser(LOCALE_EXTRA_TP_FEC, (int *)&scansettings.sat_TP_fec, SATSETUP_SCANTP_FEC, SATSETUP_SCANTP_FEC_COUNT, true, NULL, CRCInput::convertDigitToKey(shortCut++), "", true); @@ -1275,11 +1284,11 @@ int CScanSetup::addScanOptionsItems(CMenuWidget *options_menu, const int &shortc mod_pol = new CMenuOptionChooser(LOCALE_EXTRA_TP_POL, (int *)&scansettings.sat_TP_pol, SATSETUP_SCANTP_POL, SATSETUP_SCANTP_POL_COUNT, true, NULL, CRCInput::convertDigitToKey(shortCut++)); mod_pol->setHint("", LOCALE_MENU_HINT_SCAN_POL); } else if (r_system == DVB_C) { - CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, (char *) scansettings.cable_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, &scansettings.cable_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Freq = new CMenuDForwarder(LOCALE_EXTRA_TP_FREQ, true, scansettings.cable_TP_freq, freq, "", CRCInput::convertDigitToKey(shortCut++)); Freq->setHint("", LOCALE_MENU_HINT_SCAN_FREQ); - CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, (char *) scansettings.cable_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, &scansettings.cable_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Rate = new CMenuDForwarder(LOCALE_EXTRA_TP_RATE, true, scansettings.cable_TP_rate, rate, "", CRCInput::convertDigitToKey(shortCut++)); Rate->setHint("", LOCALE_MENU_HINT_SCAN_RATE); mod_pol = new CMenuOptionChooser(LOCALE_EXTRA_TP_MOD, (int *)&scansettings.cable_TP_mod, SATSETUP_SCANTP_MOD, SATSETUP_SCANTP_MOD_COUNT, true, NULL, CRCInput::convertDigitToKey(shortCut++)); @@ -1414,11 +1423,11 @@ bool CScanSetup::changeNotify(const neutrino_locale_t OptionName, void * /*data* fe->setMaster(femaster); } else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_CABLESETUP_PROVIDER)) { - printf("[neutrino] CScanSetup::%s: new provider: [%s]\n", __FUNCTION__, scansettings.cableName); + printf("[neutrino] CScanSetup::%s: new provider: [%s]\n", __FUNCTION__, scansettings.cableName.c_str()); satellite_map_t & satmap = CServiceManager::getInstance()->SatelliteList(); for (sat_iterator_t sit = satmap.begin(); sit != satmap.end(); sit++) { - if (strcmp(scansettings.cableName, sit->second.name.c_str()) == 0) { + if (scansettings.cableName == sit->second.name) { if(sit->second.cable_nid > 0) { scansettings.cable_nid = sit->second.cable_nid; nid->updateValue(); @@ -1464,20 +1473,18 @@ void CScanSetup::updateManualSettings() CFrontend * frontend = CFEManager::getInstance()->getLiveFE(); switch (frontend->getType()) { case FE_QPSK: - sprintf(scansettings.sat_TP_freq, "%d", tI->second.feparams.dvb_feparams.frequency); - sprintf(scansettings.sat_TP_rate, "%d", tI->second.feparams.dvb_feparams.u.qpsk.symbol_rate); + scansettings.sat_TP_freq = to_string(tI->second.feparams.dvb_feparams.frequency); + scansettings.sat_TP_rate = to_string(tI->second.feparams.dvb_feparams.u.qpsk.symbol_rate); scansettings.sat_TP_fec = tI->second.feparams.dvb_feparams.u.qpsk.fec_inner; scansettings.sat_TP_pol = tI->second.polarization; - strncpy(scansettings.satName, - CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()).c_str(), 50); + scansettings.satName = CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()); break; case FE_QAM: - sprintf(scansettings.cable_TP_freq, "%d", tI->second.feparams.dvb_feparams.frequency); - sprintf(scansettings.cable_TP_rate, "%d", tI->second.feparams.dvb_feparams.u.qam.symbol_rate); + scansettings.cable_TP_freq = to_string(tI->second.feparams.dvb_feparams.frequency); + scansettings.cable_TP_rate = to_string(tI->second.feparams.dvb_feparams.u.qam.symbol_rate); scansettings.cable_TP_fec = tI->second.feparams.dvb_feparams.u.qam.fec_inner; scansettings.cable_TP_mod = tI->second.feparams.dvb_feparams.u.qam.modulation; - strncpy(scansettings.cableName, - CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()).c_str(), 50); + scansettings.cableName = CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()); break; case FE_OFDM: case FE_ATSC: @@ -1502,14 +1509,14 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) parent->hide(); t_satellite_position position; - char * name; + std::string name; if (actionkey == "sat") name = scansettings.satName; else name = scansettings.cableName; - position = CServiceManager::getInstance()->GetSatellitePosition(name); - INFO("%s: %s\n", actionkey.c_str(), name); + position = CServiceManager::getInstance()->GetSatellitePosition(name.c_str()); + INFO("%s: %s\n", actionkey.c_str(), name.c_str()); if (old_position != position) { old_selected = 0; @@ -1565,14 +1572,14 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) switch (tmpI->second.deltype) { case FE_QPSK: - sprintf(scansettings.sat_TP_freq, "%d", tmpI->second.feparams.dvb_feparams.frequency); - sprintf(scansettings.sat_TP_rate, "%d", tmpI->second.feparams.dvb_feparams.u.qpsk.symbol_rate); + scansettings.sat_TP_freq = to_string(tmpI->second.feparams.dvb_feparams.frequency); + scansettings.sat_TP_rate = to_string(tmpI->second.feparams.dvb_feparams.u.qpsk.symbol_rate); scansettings.sat_TP_fec = tmpI->second.feparams.dvb_feparams.u.qpsk.fec_inner; scansettings.sat_TP_pol = tmpI->second.polarization; break; case FE_QAM: - sprintf(scansettings.cable_TP_freq, "%d", tmpI->second.feparams.dvb_feparams.frequency); - sprintf(scansettings.cable_TP_rate, "%d", tmpI->second.feparams.dvb_feparams.u.qam.symbol_rate); + scansettings.cable_TP_freq = to_string(tmpI->second.feparams.dvb_feparams.frequency); + scansettings.cable_TP_rate = to_string(tmpI->second.feparams.dvb_feparams.u.qam.symbol_rate); scansettings.cable_TP_fec = tmpI->second.feparams.dvb_feparams.u.qam.fec_inner; scansettings.cable_TP_mod = tmpI->second.feparams.dvb_feparams.u.qam.modulation; break; diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 94fcf2b3e..4c50d7e83 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -302,9 +302,8 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) { int fnum = atoi(actionKey.substr(5, 1).c_str()); printf("22kon: fe %d sat pos %d\n", fnum, test_pos[fnum]); - sprintf(scansettings.sat_TP_freq, "%d", 12000*1000); - strncpy(scansettings.satName, - CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]).c_str(), 50); + scansettings.sat_TP_freq = "12000000"; + scansettings.satName = CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]); CScanTs scanTs(FE_QPSK); scanTs.exec(NULL, "test"); return res; @@ -313,9 +312,8 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) { int fnum = atoi(actionKey.substr(6, 1).c_str()); printf("22koff: fe %d sat pos %d\n", fnum, test_pos[fnum]); - sprintf(scansettings.sat_TP_freq, "%d", 11000*1000); - strncpy(scansettings.satName, - CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]).c_str(), 50); + scansettings.sat_TP_freq = "11000000"; + scansettings.satName = CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]); CScanTs scanTs(FE_QPSK); scanTs.exec(NULL, "test"); return res; @@ -328,12 +326,11 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) CFrontend *frontend = CFEManager::getInstance()->getFE(fnum); switch (frontend->getInfo()->type) { case FE_QPSK: - strncpy(scansettings.satName, - CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]).c_str(), 50); - sprintf(scansettings.sat_TP_freq, "%d", (fnum & 1) ? 12439000: 12538000); - sprintf(scansettings.sat_TP_rate, "%d", (fnum & 1) ? 2500*1000 : 41250*1000); - scansettings.sat_TP_fec = (fnum & 1) ? FEC_3_4 : FEC_1_2; - scansettings.sat_TP_pol = (fnum & 1) ? 0 : 1; + scansettings.satName = CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]); + scansettings.sat_TP_freq = (fnum & 1) ? "12439000": "12538000"; + scansettings.sat_TP_rate = (fnum & 1) ? "2500000" : "41250000"; + scansettings.sat_TP_fec = (fnum & 1) ? FEC_3_4 : FEC_1_2; + scansettings.sat_TP_pol = (fnum & 1) ? 0 : 1; break; case FE_QAM: { @@ -344,11 +341,11 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) fe->setMode(CFrontend::FE_MODE_UNUSED); } frontend->setMode(CFrontend::FE_MODE_INDEPENDENT); - strncpy(scansettings.cableName, "CST Berlin", 50); - sprintf(scansettings.cable_TP_freq, "%d", 474*1000); - sprintf(scansettings.cable_TP_rate, "%d", 6875*1000); - scansettings.cable_TP_fec = 1; - scansettings.cable_TP_mod = 5; + scansettings.cableName = "CST Berlin"; + scansettings.cable_TP_freq = "474000"; + scansettings.cable_TP_rate = "6875000"; + scansettings.cable_TP_fec = 1; + scansettings.cable_TP_mod = 5; } break; case FE_OFDM: diff --git a/src/system/settings.cpp b/src/system/settings.cpp index 4a8cf8e72..63e96586a 100644 --- a/src/system/settings.cpp +++ b/src/system/settings.cpp @@ -111,8 +111,8 @@ CScanSettings::CScanSettings(void) delivery_system = DVB_S; bouquetMode = CZapitClient::BM_UPDATEBOUQUETS; scanType = CServiceScan::SCAN_TVRADIO; - strcpy(satName, "none"); - strcpy(cableName, "none"); + satName = "none"; + cableName ="none"; } bool CScanSettings::loadSettings(const char * const fileName, const delivery_system_t dsys) @@ -138,17 +138,17 @@ bool CScanSettings::loadSettings(const char * const fileName, const delivery_sys scan_logical_numbers = configfile.getInt32("scan_logical_numbers", 0); scan_logical_hd = configfile.getInt32("scan_logical_hd", 1); - strcpy(satName, configfile.getString("satName", satName).c_str()); - sat_TP_fec = configfile.getInt32("sat_TP_fec", 1); - sat_TP_pol = configfile.getInt32("sat_TP_pol", 0); - strcpy(sat_TP_freq, configfile.getString("sat_TP_freq", "10100000").c_str()); - strcpy(sat_TP_rate, configfile.getString("sat_TP_rate", "27500000").c_str()); + satName = configfile.getString("satName", satName); + sat_TP_fec = configfile.getInt32("sat_TP_fec", 1); + sat_TP_pol = configfile.getInt32("sat_TP_pol", 0); + sat_TP_freq = configfile.getString("sat_TP_freq", "10100000"); + sat_TP_rate = configfile.getString("sat_TP_rate", "27500000"); - strcpy(cableName, configfile.getString("cableName", cableName).c_str()); - cable_TP_mod = configfile.getInt32("cable_TP_mod", 3); - cable_TP_fec = configfile.getInt32("cable_TP_fec", 1); - strcpy(cable_TP_freq, configfile.getString("cable_TP_freq", "369000").c_str()); - strcpy(cable_TP_rate, configfile.getString("cable_TP_rate", "6875000").c_str()); + cableName = configfile.getString("cableName", cableName); + cable_TP_mod = configfile.getInt32("cable_TP_mod", 3); + cable_TP_fec = configfile.getInt32("cable_TP_fec", 1); + cable_TP_freq = configfile.getString("cable_TP_freq", "369000"); + cable_TP_rate = configfile.getString("cable_TP_rate", "6875000"); #if 1 if(sat_TP_fec == 4) sat_TP_fec = 5; #endif diff --git a/src/system/settings.h b/src/system/settings.h index ff069d879..042fe5112 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -762,17 +762,17 @@ class CScanSettings int fast_op; int cable_nid; - char satName[50]; + std::string satName; int sat_TP_fec; int sat_TP_pol; - char sat_TP_freq[10]; - char sat_TP_rate[9]; + std::string sat_TP_freq; + std::string sat_TP_rate; - char cableName[50]; + std::string cableName; int cable_TP_mod; int cable_TP_fec; - char cable_TP_freq[10]; - char cable_TP_rate[9]; + std::string cable_TP_freq; + std::string cable_TP_rate; CScanSettings(); @@ -781,5 +781,4 @@ class CScanSettings bool saveSettings(const char * const fileName); }; - #endif From 2fd195d66a112325794bf7ebc14d4565d59a9fc6 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sat, 18 Jan 2014 13:32:01 +0100 Subject: [PATCH 24/54] Preparing the input classes for Lua - Add non locale variants for CExtendedInput, CStringInput, CStringInputSMS, CPINInput THX Martii Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/31842369cc70401657a76f2abd60921bc5104498 Author: Michael Liebmann Date: 2014-01-18 (Sat, 18 Jan 2014) Origin message was: ------------------ Preparing the input classes for Lua - Add non locale variants for CExtendedInput, CStringInput, CStringInputSMS, CPINInput THX Martii ------------------ This commit was generated by Migit --- src/gui/audioplayer.cpp | 11 +- src/gui/bedit/bouqueteditor_bouquets.cpp | 6 +- src/gui/bookmarkmanager.cpp | 8 +- src/gui/cam_menu.cpp | 13 +- src/gui/keybind_setup.cpp | 10 +- src/gui/moviebrowser.cpp | 24 +- src/gui/network_setup.cpp | 10 +- src/gui/nfs.cpp | 4 +- src/gui/osd_setup.cpp | 34 +-- src/gui/parentallock_setup.cpp | 2 +- src/gui/personalize.cpp | 2 +- src/gui/proxyserver_setup.cpp | 6 +- src/gui/scan_setup.cpp | 10 +- src/gui/timerlist.cpp | 9 +- src/gui/vfd_setup.cpp | 2 +- src/gui/widget/menue.cpp | 26 +- src/gui/widget/menue.h | 12 +- src/gui/widget/stringinput.cpp | 318 ++++++++++------------- src/gui/widget/stringinput.h | 40 ++- src/gui/widget/stringinput_ext.cpp | 222 ++++++++-------- src/gui/widget/stringinput_ext.h | 28 +- 21 files changed, 359 insertions(+), 438 deletions(-) diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 9ebb8f4c4..fbd81df70 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -599,7 +599,7 @@ int CAudioPlayerGui::show() // is no stream, so we do not have to test for this case int seconds=0; CIntInput secondsInput(LOCALE_AUDIOPLAYER_JUMP_DIALOG_TITLE, - seconds, + &seconds, 5, LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT1, LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT2); @@ -706,7 +706,7 @@ int CAudioPlayerGui::show() // is no stream, so we do not have to test for this case int seconds=0; CIntInput secondsInput(LOCALE_AUDIOPLAYER_JUMP_DIALOG_TITLE, - seconds, + &seconds, 5, LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT1, LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT2); @@ -2605,7 +2605,7 @@ void CAudioPlayerGui::savePlaylist() absPlaylistDir += file->getFileName(); const int filenamesize = 30; - char filename[filenamesize + 1] = ""; + std::string filename; if (file->getType() == CFile::FILE_PLAYLIST) { @@ -2616,15 +2616,14 @@ void CAudioPlayerGui::savePlaylist() bool overwrite = askToOverwriteFile(name); if (!overwrite) return; - - snprintf(filename, name.size(), "%s", name.c_str()); + filename = name; } else if (file->getType() == CFile::FILE_DIR) { // query for filename this->hide(); CStringInputSMS filenameInput(LOCALE_AUDIOPLAYER_PLAYLIST_NAME, - filename, + &filename, filenamesize - 1, LOCALE_AUDIOPLAYER_PLAYLIST_NAME_HINT1, LOCALE_AUDIOPLAYER_PLAYLIST_NAME_HINT2, diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 91a9700e9..e57b7c7c3 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -526,11 +526,9 @@ void CBEBouquetWidget::switchLockBouquet() std::string CBEBouquetWidget::inputName(const char * const defaultName, const neutrino_locale_t caption) { - char Name[30]; + std::string Name = defaultName; - strncpy(Name, defaultName, sizeof(Name)-1); - - CStringInputSMS * nameInput = new CStringInputSMS(caption, Name, 29, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.,:|!?/ "); + CStringInputSMS * nameInput = new CStringInputSMS(caption, &Name, 29, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.,:|!?/ "); nameInput->exec(this, ""); delete nameInput; diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index d750f323f..ebebd8f1b 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -82,12 +82,12 @@ inline int CBookmarkManager::createBookmark (const std::string & name, const std } int CBookmarkManager::createBookmark (const std::string & url, const std::string & time) { - char bookmarkname[26]=""; - CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_"); + std::string bookmarkname; + CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, &bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_"); bookmarkname_input.exec(NULL, ""); // TODO: return -1 if no name was entered - if (!strlen(bookmarkname)) return -1; - return createBookmark(std::string(bookmarkname), url, time); + if (bookmarkname.empty()) return -1; + return createBookmark(bookmarkname, url, time); } //------------------------------------------------------------------------ diff --git a/src/gui/cam_menu.cpp b/src/gui/cam_menu.cpp index a07ea0209..db0608019 100644 --- a/src/gui/cam_menu.cpp +++ b/src/gui/cam_menu.cpp @@ -410,21 +410,20 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t printf("CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str()); hideHintBox(); - char ENQAnswer[pMmiEnquiry->answerlen+1]; - ENQAnswer[0] = 0; + std::string ENQAnswer; - CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str(), ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE); + CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str(), &ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE); Inquiry->exec(NULL, ""); delete Inquiry; - printf("CCAMMenuHandler::handleCamMsg: input=[%s]\n", ENQAnswer); + printf("CCAMMenuHandler::handleCamMsg: input=[%s]\n", ENQAnswer.c_str()); - if((int) strlen(ENQAnswer) != pMmiEnquiry->answerlen) { + if((int) ENQAnswer.length() != pMmiEnquiry->answerlen) { printf("CCAMMenuHandler::handleCamMsg: wrong input len\n"); - ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer, 0); + ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer.c_str(), 0); return 1; //FIXME } else { - ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer, pMmiEnquiry->answerlen); + ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer.c_str(), pMmiEnquiry->answerlen); return 1; } } diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index 65650bb70..f41534c1f 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -101,12 +101,12 @@ int CKeybindSetup::exec(CMenuTarget* parent, const std::string &actionKey) CFileBrowser fileBrowser; fileBrowser.Dir_Mode = true; if (fileBrowser.exec("/var/tuxbox") == true) { - char fname[256] = "keys.conf", sname[256]; - CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVEKEYS, fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. "); + std::string fname = "keys.conf"; + CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVEKEYS, &fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. "); sms->exec(NULL, ""); - sprintf(sname, "%s/%s", fileBrowser.getSelectedFile()->Name.c_str(), fname); - printf("[neutrino keybind_setup] save keys: %s\n", sname); - CNeutrinoApp::getInstance()->saveKeys(sname); + std::string sname = fileBrowser.getSelectedFile()->Name + "/" + fname; + printf("[neutrino keybind_setup] save keys: %s\n", sname.c_str()); + CNeutrinoApp::getInstance()->saveKeys(sname.c_str()); delete sms; } return menu_return::RETURN_REPAINT; diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index b93f43586..eff2d9506 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -2951,9 +2951,9 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) CIntInput* pBookTypeIntInput[MAX_NUMBER_OF_BOOKMARK_ITEMS]; CMenuWidget* pBookItemMenu[MAX_NUMBER_OF_BOOKMARK_ITEMS]; - CIntInput bookStartIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&)movie_info->bookmarks.start, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); - CIntInput bookLastIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&)movie_info->bookmarks.lastPlayStop, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); - CIntInput bookEndIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&)movie_info->bookmarks.end, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); + CIntInput bookStartIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.start, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); + CIntInput bookLastIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.lastPlayStop, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); + CIntInput bookEndIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.end, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); CMenuWidget bookmarkMenu (LOCALE_MOVIEBROWSER_HEAD , NEUTRINO_ICON_MOVIEPLAYER); @@ -2968,8 +2968,8 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) for(int li =0 ; li < MI_MOVIE_BOOK_USER_MAX && li < MAX_NUMBER_OF_BOOKMARK_ITEMS; li++ ) { pBookNameInput[li] = new CStringInputSMS (LOCALE_MOVIEBROWSER_EDIT_BOOK, &movie_info->bookmarks.user[li].name, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_NAME_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_NAME_INFO2, "abcdefghijklmnopqrstuvwxyz0123456789-.: "); - pBookPosIntInput[li] = new CIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&) movie_info->bookmarks.user[li].pos, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); - pBookTypeIntInput[li] = new CIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&) movie_info->bookmarks.user[li].length, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_TYPE_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_TYPE_INFO2); + pBookPosIntInput[li] = new CIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.user[li].pos, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); + pBookTypeIntInput[li] = new CIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.user[li].length, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_TYPE_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_TYPE_INFO2); pBookItemMenu[li] = new CMenuWidget(LOCALE_MOVIEBROWSER_BOOK_HEAD, NEUTRINO_ICON_MOVIEPLAYER); pBookItemMenu[li]->addItem(GenericMenuSeparator); @@ -3031,9 +3031,9 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) CStringInputSMS epgUserInput(LOCALE_MOVIEBROWSER_INFO_INFO1, &movie_info->epgInfo1, 20, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.: "); CDateInput dateUserDateInput(LOCALE_MOVIEBROWSER_INFO_LENGTH, &movie_info->dateOfLastPlay, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CDateInput recUserDateInput(LOCALE_MOVIEBROWSER_INFO_LENGTH, &movie_info->file.Time, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput lengthUserIntInput(LOCALE_MOVIEBROWSER_INFO_LENGTH, (int&)movie_info->length, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput lengthUserIntInput(LOCALE_MOVIEBROWSER_INFO_LENGTH, (int *)&movie_info->length, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CStringInputSMS countryUserInput(LOCALE_MOVIEBROWSER_INFO_PRODCOUNTRY, &movie_info->productionCountry, 11, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "ABCDEFGHIJKLMNOPQRSTUVWXYZ "); - CIntInput yearUserIntInput(LOCALE_MOVIEBROWSER_INFO_PRODYEAR, (int&)movie_info->productionDate, 4, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput yearUserIntInput(LOCALE_MOVIEBROWSER_INFO_PRODYEAR, (int *)&movie_info->productionDate, 4, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CMenuWidget movieInfoMenu(LOCALE_MOVIEBROWSER_HEAD, NEUTRINO_ICON_MOVIEPLAYER /*,m_cBoxFrame.iWidth*/); //TODO: check @@ -3122,13 +3122,13 @@ bool CMovieBrowser::showMenu(MI_MOVIE_INFO* /*movie_info*/) /********************************************************************/ /** optionsMenuBrowser **************************************************/ - CIntInput playMaxUserIntInput(LOCALE_MOVIEBROWSER_LAST_PLAY_MAX_ITEMS, (int&) m_settings.lastPlayMaxItems, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput recMaxUserIntInput(LOCALE_MOVIEBROWSER_LAST_RECORD_MAX_ITEMS, (int&) m_settings.lastRecordMaxItems, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput browserFrameUserIntInput(LOCALE_MOVIEBROWSER_BROWSER_FRAME_HIGH, (int&) m_settings.browserFrameHeight, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput browserRowNrIntInput(LOCALE_MOVIEBROWSER_BROWSER_ROW_NR, (int&) m_settings.browserRowNr, 1, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput playMaxUserIntInput(LOCALE_MOVIEBROWSER_LAST_PLAY_MAX_ITEMS, (int *)&m_settings.lastPlayMaxItems, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput recMaxUserIntInput(LOCALE_MOVIEBROWSER_LAST_RECORD_MAX_ITEMS, (int *)&m_settings.lastRecordMaxItems, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput browserFrameUserIntInput(LOCALE_MOVIEBROWSER_BROWSER_FRAME_HIGH, (int *)&m_settings.browserFrameHeight, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput browserRowNrIntInput(LOCALE_MOVIEBROWSER_BROWSER_ROW_NR, (int *)&m_settings.browserRowNr, 1, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CIntInput* browserRowWidthIntInput[MB_MAX_ROWS]; for(i=0; isetNumericInput(true); + mc->setNumberFormat("%d%%"); + fontscale.addItem(mc); - CStringInput yres_count(LOCALE_FONTMENU_SCALING_Y, val_y,50,200, 3, LOCALE_FONTMENU_SCALING, LOCALE_FONTMENU_SCALING_Y_HINT2, "0123456789 "); - CMenuForwarder *m_y = new CMenuForwarder(LOCALE_FONTMENU_SCALING_Y, true, val_y, &yres_count); + mc = new CMenuOptionNumberChooser(LOCALE_FONTMENU_SCALING_Y, &g_settings.screen_yres, true, 50, 200, this); + mc->setNumericInput(true); + mc->setNumberFormat("%d%%"); + fontscale.addItem(mc); - fontscale.addItem(m_x); - fontscale.addItem(m_y); res = fontscale.exec(NULL, ""); - xre = atoi(val_x); - yre = atoi(val_y); - //fallback for min/max bugs ;) - if( xre < 50 || xre > 200 ){ - xre = g_settings.screen_xres; - snprintf(val_x,sizeof(val_x), "%03d",g_settings.screen_xres); - } - if( yre < 50 || yre > 200 ){ - yre = g_settings.screen_yres; - snprintf(val_y,sizeof(val_y), "%03d",g_settings.screen_yres); - } if (xre != g_settings.screen_xres || yre != g_settings.screen_yres) { - printf("[neutrino] new font scale settings x: %d%% y: %d%%\n", xre, yre); - g_settings.screen_xres = xre; - g_settings.screen_yres = yre; + printf("[neutrino] new font scale settings x: %d%% y: %d%%\n", g_settings.screen_xres, g_settings.screen_yres); CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT | CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT_INST); } - //return menu_return::RETURN_REPAINT; return res; } else if(actionKey=="window_size") { diff --git a/src/gui/parentallock_setup.cpp b/src/gui/parentallock_setup.cpp index 160d88701..3fcbef378 100644 --- a/src/gui/parentallock_setup.cpp +++ b/src/gui/parentallock_setup.cpp @@ -137,7 +137,7 @@ int CParentalSetup::showParentalSetup() mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_BOUQUETMODE, &g_settings.parentallock_defaultlocked, PARENTALLOCK_DEFAULTLOCKED_OPTIONS, PARENTALLOCK_DEFAULTLOCKED_OPTION_COUNT, !parentallocked); plock->addItem(mc); - CPINChangeWidget pinChangeWidget(LOCALE_PARENTALLOCK_CHANGEPIN, g_settings.parentallock_pincode, 4, LOCALE_PARENTALLOCK_CHANGEPIN_HINT1); + CPINChangeWidget pinChangeWidget(LOCALE_PARENTALLOCK_CHANGEPIN, &g_settings.parentallock_pincode, 4, LOCALE_PARENTALLOCK_CHANGEPIN_HINT1); mf = new CMenuForwarder(LOCALE_PARENTALLOCK_CHANGEPIN, true, g_settings.parentallock_pincode, &pinChangeWidget); mf->setHint("", LOCALE_MENU_HINT_PARENTALLOCK_CHANGEPIN); plock->addItem(mf); diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index 3f9dc798d..b8098cbf5 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -372,7 +372,7 @@ int CPersonalizeGui::ShowPersonalizationMenu() //init pin setup dialog void CPersonalizeGui::ShowPinSetup(CMenuWidget* p_widget, CPINChangeWidget * &pin_widget) { - pin_widget = new CPINChangeWidget(LOCALE_PERSONALIZE_PINCODE, g_settings.personalize_pincode, 4, LOCALE_PERSONALIZE_PINHINT); + pin_widget = new CPINChangeWidget(LOCALE_PERSONALIZE_PINCODE, &g_settings.personalize_pincode, 4, LOCALE_PERSONALIZE_PINHINT); CMenuForwarder * fw_pin_setup = new CMenuForwarder(LOCALE_PERSONALIZE_PINCODE, true, g_settings.personalize_pincode, pin_widget, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); pin_setup_notifier = new CPinSetupNotifier(fw_pin_setup); diff --git a/src/gui/proxyserver_setup.cpp b/src/gui/proxyserver_setup.cpp index b4600e7f0..db03bf765 100644 --- a/src/gui/proxyserver_setup.cpp +++ b/src/gui/proxyserver_setup.cpp @@ -80,17 +80,17 @@ int CProxySetup::showProxySetup() neutrino_locale_t subtitle = (menue_title == LOCALE_FLASHUPDATE_PROXYSERVER_SEP ? NONEXISTANT_LOCALE : LOCALE_FLASHUPDATE_PROXYSERVER_SEP); mn->addIntroItems(subtitle); - CStringInputSMS softUpdate_proxy(LOCALE_FLASHUPDATE_PROXYSERVER, g_settings.softupdate_proxyserver, 23, LOCALE_FLASHUPDATE_PROXYSERVER_HINT1, LOCALE_FLASHUPDATE_PROXYSERVER_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-.: "); + CStringInputSMS softUpdate_proxy(LOCALE_FLASHUPDATE_PROXYSERVER, &g_settings.softupdate_proxyserver, 23, LOCALE_FLASHUPDATE_PROXYSERVER_HINT1, LOCALE_FLASHUPDATE_PROXYSERVER_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-.: "); CMenuForwarder * mf = new CMenuForwarder(LOCALE_FLASHUPDATE_PROXYSERVER, true, g_settings.softupdate_proxyserver, &softUpdate_proxy, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); mf->setHint("", LOCALE_MENU_HINT_NET_PROXYSERVER); mn->addItem(mf); - CStringInputSMS softUpdate_proxyuser(LOCALE_FLASHUPDATE_PROXYUSERNAME, g_settings.softupdate_proxyusername, 23, LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT1, LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789!""§$%&/()=?-. "); + CStringInputSMS softUpdate_proxyuser(LOCALE_FLASHUPDATE_PROXYUSERNAME, &g_settings.softupdate_proxyusername, 23, LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT1, LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789!""§$%&/()=?-. "); mf = new CMenuForwarder(LOCALE_FLASHUPDATE_PROXYUSERNAME, true, g_settings.softupdate_proxyusername, &softUpdate_proxyuser, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); mf->setHint("", LOCALE_MENU_HINT_NET_PROXYUSER); mn->addItem(mf); - CStringInputSMS softUpdate_proxypass(LOCALE_FLASHUPDATE_PROXYPASSWORD, g_settings.softupdate_proxypassword, 20, LOCALE_FLASHUPDATE_PROXYPASSWORD_HINT1, LOCALE_FLASHUPDATE_PROXYPASSWORD_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789!""§$%&/()=?-. "); + CStringInputSMS softUpdate_proxypass(LOCALE_FLASHUPDATE_PROXYPASSWORD, &g_settings.softupdate_proxypassword, 20, LOCALE_FLASHUPDATE_PROXYPASSWORD_HINT1, LOCALE_FLASHUPDATE_PROXYPASSWORD_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789!""§$%&/()=?-. "); mf = new CMenuForwarder(LOCALE_FLASHUPDATE_PROXYPASSWORD, true, g_settings.softupdate_proxypassword, &softUpdate_proxypass, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW); mf->setHint("", LOCALE_MENU_HINT_NET_PROXYPASS); mn->addItem(mf); diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index 58f35dc42..1d203d60f 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -214,7 +214,7 @@ CScanSetup::CScanSetup(bool wizard_mode) in_menu = false; allow_start = true; if (CFEManager::getInstance()->haveCable()) - nid = new CIntInput(LOCALE_SATSETUP_CABLE_NID, (int&) scansettings.cable_nid, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + nid = new CIntInput(LOCALE_SATSETUP_CABLE_NID, (int*) &scansettings.cable_nid, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); } CScanSetup* CScanSetup::getInstance() @@ -808,7 +808,7 @@ int CScanSetup::showUnicableSetup() int unicable_qrg = fe_config.uni_qrg; CMenuOptionNumberChooser *uniscr = new CMenuOptionNumberChooser(LOCALE_UNICABLE_SCR, &unicable_scr, true, 0, 7); - CIntInput *uniqrg = new CIntInput(LOCALE_UNICABLE_QRG, unicable_qrg, 4, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput *uniqrg = new CIntInput(LOCALE_UNICABLE_QRG, &unicable_qrg, 4, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CMenuWidget *uni_setup = new CMenuWidget(LOCALE_SATSETUP_UNI_SETTINGS, NEUTRINO_ICON_SETTINGS, width); uni_setup->addIntroItems(); @@ -1038,9 +1038,9 @@ void CScanSetup::addScanMenuTempSat(CMenuWidget *temp_sat, sat_config_t & satcon unilnb = new CMenuOptionNumberChooser(LOCALE_UNICABLE_LNB, &satconfig.diseqc, true, 0, 1); } - CIntInput* lofL = new CIntInput(LOCALE_SATSETUP_LOFL, (int&) satconfig.lnbOffsetLow, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput* lofH = new CIntInput(LOCALE_SATSETUP_LOFH, (int&) satconfig.lnbOffsetHigh, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput* lofS = new CIntInput(LOCALE_SATSETUP_LOFS, (int&) satconfig.lnbSwitch, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput* lofL = new CIntInput(LOCALE_SATSETUP_LOFL, (int*) &satconfig.lnbOffsetLow, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput* lofH = new CIntInput(LOCALE_SATSETUP_LOFH, (int*) &satconfig.lnbOffsetHigh, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput* lofS = new CIntInput(LOCALE_SATSETUP_LOFS, (int*) &satconfig.lnbSwitch, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); if (!unicable) { temp_sat->addItem(diseqc); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 4f3ca671d..146c782b3 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -1085,7 +1085,7 @@ int CTimerList::modifyTimer() timer->eventRepeat = (CTimerd::CTimerEventRepeat)(((int)timer->eventRepeat) & 0x1FF); CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, &m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); CMenuForwarder *m4 = new CMenuForwarder(LOCALE_TIMERLIST_WEEKDAYS, ((int)timer->eventRepeat) >= (int)CTimerd::TIMERREPEAT_WEEKDAYS, m_weekdaysStr, &timerSettings_weekdays ); - CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int&)timer->repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); + CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int*)&timer->repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); CMenuForwarder *m5 = new CMenuForwarder(LOCALE_TIMERLIST_REPEATCOUNT, timer->eventRepeat != (int)CTimerd::TIMERREPEAT_ONCE ,timerSettings_repeatCount.getValue() , &timerSettings_repeatCount); @@ -1167,7 +1167,7 @@ int CTimerList::newTimer() CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, &m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); CMenuForwarder *m4 = new CMenuForwarder(LOCALE_TIMERLIST_WEEKDAYS, false, m_weekdaysStr, &timerSettings_weekdays); - CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int&)timerNew.repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); + CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int*)&timerNew.repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); CMenuForwarder *m5 = new CMenuForwarder(LOCALE_TIMERLIST_REPEATCOUNT, false,timerSettings_repeatCount.getValue() , &timerSettings_repeatCount); CTimerListRepeatNotifier notifier((int *)&timerNew.eventRepeat,m4,m5, &m_weekdaysStr); @@ -1217,7 +1217,8 @@ int CTimerList::newTimer() CMenuOptionChooser* m8 = new CMenuOptionChooser(LOCALE_TIMERLIST_STANDBY, &timerNew_standby_on, TIMERLIST_STANDBY_OPTIONS, TIMERLIST_STANDBY_OPTION_COUNT, false); - CStringInputSMS timerSettings_msg(LOCALE_TIMERLIST_MESSAGE, timerNew.message, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.,:!?/ "); + std::string timerNew_message(timerNew.message); + CStringInputSMS timerSettings_msg(LOCALE_TIMERLIST_MESSAGE, &timerNew_message, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.,:!?/ "); CMenuForwarder *m9 = new CMenuForwarder(LOCALE_TIMERLIST_MESSAGE, false, timerNew.message, &timerSettings_msg ); strcpy(timerNew.pluginName,"---"); @@ -1251,6 +1252,8 @@ int CTimerList::newTimer() notifier2.changeNotify(NONEXISTANT_LOCALE, NULL); int ret=timerSettings.exec(this,""); + strncpy(timerNew.message, timerNew_message.c_str(), sizeof(timerNew.message)); + // delete dynamic created objects for (unsigned int count=0; countaddItem(GenericMenuSeparatorLine); if (dim_time == NULL) - dim_time = new CStringInput(LOCALE_LCDMENU_DIM_TIME, g_settings.lcd_setting_dim_time, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"0123456789 "); + dim_time = new CStringInput(LOCALE_LCDMENU_DIM_TIME, &g_settings.lcd_setting_dim_time, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"0123456789 "); mf = new CMenuForwarder(LOCALE_LCDMENU_DIM_TIME, vfd_enabled, g_settings.lcd_setting_dim_time,dim_time); mf->setHint("", LOCALE_MENU_HINT_VFD_DIMTIME); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 625505c24..8348dcac7 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1247,7 +1247,7 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*) if (b < upper_bound) b = upper_bound; for (; b; b /= 10, size++); - CIntInput cii(name, *optionValue, size, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + CIntInput cii(name, optionValue, size, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); cii.exec(NULL, ""); if (*optionValue > upper_bound) *optionValue = upper_bound; @@ -2037,38 +2037,38 @@ int CMenuSeparator::paint(bool selected) bool CPINProtection::check() { - char cPIN[5]; + hint = NONEXISTANT_LOCALE; + std::string cPIN; do { - cPIN[0] = 0; - CPINInput* PINInput = new CPINInput(title, cPIN, 4, hint); + cPIN = ""; + CPINInput* PINInput = new CPINInput(title, &cPIN, 4, hint); PINInput->exec( getParent(), ""); delete PINInput; hint = LOCALE_PINPROTECTION_WRONGCODE; - } while ((strncmp(cPIN,validPIN,4) != 0) && (cPIN[0] != 0)); - return ( strncmp(cPIN,validPIN,4) == 0); + } while ((cPIN != *validPIN) && !cPIN.empty()); + return (cPIN == *validPIN); } - bool CZapProtection::check() { + hint = NONEXISTANT_LOCALE; int res; - char cPIN[5]; + std::string cPIN; do { - cPIN[0] = 0; + cPIN = ""; - CPLPINInput* PINInput = new CPLPINInput(title, cPIN, 4, hint, fsk); + CPLPINInput* PINInput = new CPLPINInput(title, &cPIN, 4, hint, fsk); res = PINInput->exec(getParent(), ""); delete PINInput; hint = LOCALE_PINPROTECTION_WRONGCODE; - } while ( (strncmp(cPIN,validPIN,4) != 0) && - (cPIN[0] != 0) && + } while ( (cPIN != *validPIN) && !cPIN.empty() && ( res == menu_return::RETURN_REPAINT ) && ( fsk >= g_settings.parentallock_lockage ) ); - return ( ( strncmp(cPIN,validPIN,4) == 0 ) || + return ( (cPIN == *validPIN) || ( fsk < g_settings.parentallock_lockage ) ); } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 1d7423737..5eac43348 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -572,14 +572,14 @@ class CMenuWidget : public CMenuTarget class CPINProtection { protected: - char* validPIN; + std::string *validPIN; bool check(); virtual CMenuTarget* getParent() = 0; neutrino_locale_t title, hint; public: - CPINProtection( char* validpin) + CPINProtection(std::string &validpin) { - validPIN = validpin; + validPIN = &validpin; hint = NONEXISTANT_LOCALE; title = LOCALE_PINPROTECTION_HEAD; }; @@ -595,7 +595,7 @@ class CZapProtection : public CPINProtection public: int fsk; - CZapProtection( char* validpin, int FSK ) : CPINProtection(validpin) + CZapProtection(std::string &validpin, int FSK ) : CPINProtection(validpin) { fsk = FSK; title = LOCALE_PARENTALLOCK_HEAD; @@ -611,7 +611,7 @@ class CLockedMenuForwarder : public CMenuForwarder, public CPINProtection protected: virtual CMenuTarget* getParent(){ return Parent;}; public: - CLockedMenuForwarder(const neutrino_locale_t Text, char* _validPIN, bool ask=true, const bool Active=true, char *Option=NULL, + CLockedMenuForwarder(const neutrino_locale_t Text, std::string &_validPIN, bool ask=true, const bool Active=true, const char * const Option = NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL) @@ -625,7 +625,7 @@ class CLockedMenuForwarder : public CMenuForwarder, public CPINProtection iconName_Info_right = IconName_Info_right ? IconName_Info_right : NEUTRINO_ICON_LOCK; else iconName_Info_right = ""; - }; + }; virtual int exec(CMenuTarget* parent); }; diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index 1be9a80f6..c7f0970e0 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -4,6 +4,7 @@ Copyright (C) 2001 Steffen Hehn 'McClean' Homepage: http://dbox.cyberphoria.org/ + Copyright (C) 2009-2012 Stefan Seyfried License: GPL @@ -38,58 +39,15 @@ #include #include +#include + #include #include -CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, const int min_value, const int max_value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) -{ - name = Name; - head = NULL; - value = Value; - valueString = NULL; - lower_bound = min_value - 1; - upper_bound = max_value + 1; - size = Size; - - hint_1 = Hint_1; - hint_2 = Hint_2; - validchars = Valid_Chars; - iconfile = Icon ? Icon : ""; - - observ = Observ; - init(); -} - -CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) -{ - name = Name; - head = NULL; - value = Value; - valueString = NULL; - lower_bound = -1; - upper_bound = -1; - - size = Size; - - hint_1 = Hint_1; - hint_2 = Hint_2; - validchars = Valid_Chars; - iconfile = Icon ? Icon : ""; - - observ = Observ; - init(); -} - CStringInput::CStringInput(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) { name = Name; - head = NULL; - value = NULL; -#if 0 - value = new char[Size+1]; - value[Size] = '\0'; - strncpy(value,Value->c_str(),Size); -#endif + head = g_Locale->getText(Name); valueString = Value; lower_bound = -1; upper_bound = -1; @@ -104,11 +62,11 @@ CStringInput::CStringInput(const neutrino_locale_t Name, std::string* Value, int init(); } -CStringInput::CStringInput(char * Head, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) +CStringInput::CStringInput(const std::string &Name, std::string *Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) { - head = strdup(Head); - value = Value; - valueString = NULL; + name = NONEXISTANT_LOCALE; + head = Name; + valueString = Value; lower_bound = -1; upper_bound = -1; size = Size; @@ -124,19 +82,15 @@ CStringInput::CStringInput(char * Head, char* Value, int Size, const neutrino_lo CStringInput::~CStringInput() { -#if 0 - if (valueString != NULL) - { - delete[] value; - } -#endif - if(head) { - free(head); - } - g_RCInput->killTimer (smstimer); } +void CStringInput::setMinMax(const int min_value, const int max_value) +{ + lower_bound = min_value - 1; + upper_bound = max_value + 1; +} + #define CStringInputSMSButtonsCount 2 const struct button_label CStringInputSMSButtons[CStringInputSMSButtonsCount] = { @@ -160,11 +114,7 @@ void CStringInput::init() width = std::max(size*input_w + 2*offset, (int) frameBuffer->getScreenWidth() / 100 * 45); - int tmp_w = 0; - if (head) - tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head, true); // UTF-8 - else - tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true); // UTF-8 + int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head.c_str(), true); // UTF-8 if (!(iconfile.empty())) { @@ -205,18 +155,36 @@ void CStringInput::NormalKeyPressed(const neutrino_msg_t key) { if (CRCInput::isNumeric(key)) { - std::string tmp_value = value; - value[selected] = validchars[CRCInput::getNumericValue(key)]; - int current_value = atoi(value); + std::string tmp_value = *valueString; + if (selected >= (int)valueString->length()) + valueString->append(selected - valueString->length() + 1, ' '); + valueString->at(selected) = validchars[CRCInput::getNumericValue(key)]; + int current_value = atoi((*valueString).c_str()); + int tmp = current_value; + if (lower_bound != -1 || upper_bound != -1) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + if (tmp != current_value) + *valueString = to_string(current_value).substr(0, size); + } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ if (selected < (size - 1)) { selected++; paintChar(selected - 1); } - paintChar(selected); + if (tmp != current_value) + { + for (tmp = 0; tmp < size; tmp++) + paintChar(tmp); + } + else + paintChar(selected); }else{ - snprintf(value, size,"%s",tmp_value.c_str()); + *valueString = tmp_value; } } } @@ -228,10 +196,10 @@ void CStringInput::keyBackspacePressed(void) selected--; for (int i = selected; i < size - 1; i++) { - value[i] = value[i + 1]; + valueString->at(i) = valueString->at(i + 1); paintChar(i); } - value[size - 1] = ' '; + valueString->at(size - 1) = ' '; paintChar(size - 1); } } @@ -242,7 +210,7 @@ void CStringInput::keyRedPressed() if(lower_bound == -1 || upper_bound == -1){ if (index(validchars, ' ') != NULL) { - value[selected] = ' '; + valueString->at(selected) = ' '; if (selected < (size - 1)) { @@ -259,22 +227,20 @@ void CStringInput::keyYellowPressed() { if(lower_bound == -1 || upper_bound == -1){ selected=0; + valueString->assign(valueString->length(), ' '); for(int i=0 ; i < size ; i++) - { - value[i]=' '; paintChar(i); - } } } void CStringInput::keyBluePressed() { - if (((value[selected] | 32) >= 'a') && ((value[selected] | 32) <= 'z')) + if (((valueString->at(selected) | 32) >= 'a') && ((valueString->at(selected) | 32) <= 'z')) { - char newValue = value[selected] ^ 32; + char newValue = valueString->at(selected) ^ 32; if (index(validchars, newValue) != NULL) { - value[selected] = newValue; + valueString->at(selected) = newValue; paintChar(selected); } } @@ -283,40 +249,72 @@ void CStringInput::keyBluePressed() void CStringInput::keyUpPressed() { int npos = 0; - std::string tmp_value = value; + std::string tmp_value = *valueString; for(int count=0;count<(int)strlen(validchars);count++) - if(value[selected]==validchars[count]) + if(valueString->at(selected)==validchars[count]) npos = count; npos++; if(npos>=(int)strlen(validchars)) npos = 0; - value[selected]=validchars[npos]; + valueString->at(selected)=validchars[npos]; - int current_value = atoi(value); + int current_value = atoi((*valueString).c_str()); + int tmp = current_value; + if (lower_bound != -1 || upper_bound != -1) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + if (tmp != current_value) + *valueString = to_string(current_value).substr(0, size); + } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ - paintChar(selected); + if (tmp != current_value) + { + for (tmp = 0; tmp < size; tmp++) + paintChar(tmp); + } + else + paintChar(selected); }else{ - snprintf(value, size,"%s",tmp_value.c_str()); + *valueString = tmp_value; } } void CStringInput::keyDownPressed() { int npos = 0; - std::string tmp_value = value; + std::string tmp_value = *valueString; for(int count=0;count<(int)strlen(validchars);count++) - if(value[selected]==validchars[count]) + if(valueString->at(selected)==validchars[count]) npos = count; npos--; if(npos<0) npos = strlen(validchars)-1; - value[selected]=validchars[npos]; + valueString->at(selected)=validchars[npos]; - int current_value = atoi(value); + int current_value = atoi((*valueString).c_str()); + int tmp = current_value; + if (lower_bound != -1 || upper_bound != -1) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + if (tmp != current_value) + *valueString = to_string(current_value).substr(0, size); + } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ - paintChar(selected); + if (tmp != current_value) + { + for (tmp = 0; tmp < size; tmp++) + paintChar(tmp); + } + else + paintChar(selected); }else{ - snprintf(value, size,"%s",tmp_value.c_str()); + *valueString = tmp_value; } } @@ -349,11 +347,11 @@ void CStringInput::keyMinusPressed() int item = selected; while (item < (size -1)) { - value[item] = value[item+1]; + valueString->at(item) = valueString->at(item+1); paintChar(item); item++; } - value[item] = ' '; + valueString->at(item) = ' '; paintChar(item); } } @@ -364,48 +362,41 @@ void CStringInput::keyPlusPressed() int item = size -1; while (item > selected) { - value[item] = value[item-1]; + valueString->at(item) = valueString->at(item-1); paintChar(item); item--; } - value[item] = ' '; + valueString->at(item) = ' '; paintChar(item); } } +std::string &CStringInput::getValue(void) +{ + return *valueString; +} + int CStringInput::exec( CMenuTarget* parent, const std::string & ) { neutrino_msg_t msg; neutrino_msg_data_t data; int res = menu_return::RETURN_REPAINT; - char *oldval = new char[size+1]; - if(oldval == NULL) - return res; - char *dispval = new char[size+1]; - if(dispval == NULL){ - delete[] oldval; - return res; - } - if (valueString != NULL) { - value = new char[size+1]; - value[size] = '\0'; - strncpy(value,valueString->c_str(),size); - } - oldval[size] = 0; - dispval[size] = 0; + std::string oldval = *valueString; + std::string dispval = *valueString; if (parent) parent->hide(); - for(int count=strlen(value)-1;count (int) valueString->length()) + valueString->append(size - valueString->length(), ' '); - fb_pixel_t * pixbuf = new fb_pixel_t[(width + SHADOW_OFFSET) * (height + SHADOW_OFFSET)]; - - if (pixbuf != NULL) - frameBuffer->SaveScreen(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET, pixbuf); + fb_pixel_t * pixbuf = NULL; + if (!parent) { + pixbuf = new fb_pixel_t[(width + SHADOW_OFFSET) * (height + SHADOW_OFFSET)]; + if (pixbuf) + frameBuffer->SaveScreen(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET, pixbuf); + } paint(); @@ -414,11 +405,10 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) bool loop=true; while (loop) { - if ( strncmp(value, dispval, size) != 0) + if (*valueString != dispval) { - std::string tmp = value; - CVFD::getInstance()->showMenuText(1,tmp.c_str() , selected+1); - strncpy(dispval, value, size); + CVFD::getInstance()->showMenuText(1,valueString->c_str() , selected+1); + dispval = *valueString; } g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true ); @@ -458,7 +448,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_green) && (index(validchars, '.') != NULL)) { - value[selected] = '.'; + valueString->at(selected) = '.'; if (selected < (size - 1)) { @@ -492,11 +482,11 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { - if ( ( strcmp(value, oldval) != 0) && + if ((*valueString != oldval) && (ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) continue; - strncpy(value, oldval, size); + *valueString = oldval; loop=false; res = menu_return::RETURN_EXIT_REPAINT; } @@ -522,39 +512,19 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } } - hide(); - - if (pixbuf != NULL) + if (pixbuf) { frameBuffer->RestoreScreen(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET, pixbuf); delete[] pixbuf;//Mismatching allocation and deallocation: pixbuf - } + } else + hide(); - for(int count=size-1;count>=0;count--) - { - if((value[count]==' ') || (value[count]==0)) - { - value[count]=0; - } - else - break; - } - value[size]=0; - - if ( (valueString != NULL) && (msg == CRCInput::RC_ok) ) - { - *valueString = value; - } + *valueString = trim (*valueString); if ( (observ) && (msg==CRCInput::RC_ok) ) { - observ->changeNotify(name, value); + observ->changeNotify(name, (void *) valueString->c_str()); } - if (valueString != NULL) - delete[] value; - - delete[] dispval; - delete[] oldval; return res; } @@ -582,7 +552,7 @@ void CStringInput::paint(bool sms) icol_o = icol_w + (offset/2); } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ (offset/2)+ icol_o, y+ hheight, width- offset- icol_o, head ? head : g_Locale->getText(name), COL_MENUHEAD_TEXT, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ (offset/2)+ icol_o, y+ hheight, width- offset- icol_o, head.c_str(), COL_MENUHEAD_TEXT, 0, true); // UTF-8 int tmp_y = y+ hheight+ offset+ input_h+ offset; if ((hint_1 != NONEXISTANT_LOCALE) || (hint_2 != NONEXISTANT_LOCALE)) @@ -617,8 +587,8 @@ void CStringInput::paint(bool sms) void CStringInput::paintChar(int pos) { - if(pos<(int)strlen(value)) - paintChar(pos, value[pos]); + if(pos<(int)valueString->length()) + paintChar(pos, valueString->at(pos)); } void CStringInput::paintChar(int pos, const char c) @@ -650,13 +620,13 @@ void CStringInput::paintChar(int pos, const char c) g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(ch_x, ypos+ input_h, ch_w, ch, color); } -CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) +CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, std::string *Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) : CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, Icon) { initSMS(Valid_Chars); } -CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) +CStringInputSMS::CStringInputSMS(const std::string &Name, std::string *Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) : CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, Icon) { initSMS(Valid_Chars); @@ -723,7 +693,7 @@ void CStringInputSMS::NormalKeyPressed(const neutrino_msg_t key) } else keyCounter = (keyCounter + 1) % arraySizes[numericvalue]; - value[selected] = Chars[numericvalue][keyCounter]; + valueString->at(selected) = Chars[numericvalue][keyCounter]; last_digit = numericvalue; paintChar(selected); g_RCInput->killTimer (smstimer); @@ -731,7 +701,7 @@ void CStringInputSMS::NormalKeyPressed(const neutrino_msg_t key) } else { - value[selected] = (char)CRCInput::getUnicodeValue(key); + valueString->at(selected) = (char)CRCInput::getUnicodeValue(key); keyRedPressed(); /* to lower, paintChar */ keyRightPressed(); /* last_digit = -1, move to next position */ } @@ -745,8 +715,8 @@ void CStringInputSMS::keyBackspacePressed(void) void CStringInputSMS::keyRedPressed() // switch between lower & uppercase { - if (((value[selected] | 32) >= 'a') && ((value[selected] | 32) <= 'z')) - value[selected] ^= 32; + if (((valueString->at(selected) | 32) >= 'a') && ((valueString->at(selected) | 32) <= 'z')) + valueString->at(selected) ^= 32; paintChar(selected); } @@ -778,7 +748,7 @@ void CStringInputSMS::keyDownPressed() selected = size - 1; - while (value[selected] == ' ') + while (valueString->at(selected) == ' ') { selected--; if (selected < 0) @@ -811,7 +781,7 @@ void CStringInputSMS::paint(bool /*unused*/) void CPINInput::paintChar(int pos) { - CStringInput::paintChar(pos, (value[pos] == ' ') ? ' ' : '*'); + CStringInput::paintChar(pos, (valueString->at(pos) == ' ') ? ' ' : '*'); } int CPINInput::exec( CMenuTarget* parent, const std::string & ) @@ -824,8 +794,8 @@ int CPINInput::exec( CMenuTarget* parent, const std::string & ) if (parent) parent->hide(); - for(int count=strlen(value)-1;count (int) valueString->length()) + valueString->append(size - valueString->length(), ' '); paint(); @@ -878,25 +848,15 @@ int CPINInput::exec( CMenuTarget* parent, const std::string & ) } } } - } hide(); - for(int count=size-1;count>=0;count--) - { - if((value[count]==' ') || (value[count]==0)) - { - value[count]=0; - } - else - break; - } - value[size]=0; + *valueString = trim (*valueString); if ( (observ) && (msg==CRCInput::RC_ok) ) { - observ->changeNotify(name, value); + observ->changeNotify(name, (void *) valueString->c_str()); } return res; @@ -905,9 +865,9 @@ int CPINInput::exec( CMenuTarget* parent, const std::string & ) void CEnquiryInput::paintChar(int pos) { if (blind) - CStringInput::paintChar(pos, (value[pos] == ' ') ? ' ' : '*'); + CStringInput::paintChar(pos, (valueString->at(pos) == ' ') ? ' ' : '*'); else - CStringInput::paintChar(pos, value[pos]); + CStringInput::paintChar(pos, valueString->at(pos)); } int CPLPINInput::handleOthers(neutrino_msg_t msg, neutrino_msg_data_t data) @@ -946,7 +906,7 @@ int CPLPINInput::exec( CMenuTarget* parent, const std::string & ) { fb_pixel_t * pixbuf = new fb_pixel_t[(width+ 2* borderwidth) * (height+ 2* borderwidth)]; - if (pixbuf != NULL) + if (pixbuf) frameBuffer->SaveScreen(x- borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf); // clear border @@ -957,9 +917,9 @@ int CPLPINInput::exec( CMenuTarget* parent, const std::string & ) int res = CPINInput::exec ( parent, "" ); - if (pixbuf != NULL) + if (pixbuf) { - frameBuffer->RestoreScreen(x- borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf); + frameBuffer->RestoreScreen(x - borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf); delete[] pixbuf;//Mismatching allocation and deallocation: pixbuf } diff --git a/src/gui/widget/stringinput.h b/src/gui/widget/stringinput.h index c7391dad3..d460b2bae 100644 --- a/src/gui/widget/stringinput.h +++ b/src/gui/widget/stringinput.h @@ -53,13 +53,11 @@ class CStringInput : public CMenuTarget uint32_t smstimer; - char * head; + std::string head; neutrino_locale_t name; neutrino_locale_t hint_1, hint_2; std::string iconfile; const char * validchars; - char * value; - std::string *valueString; int size; int selected; CChangeObserver * observ; @@ -85,18 +83,14 @@ class CStringInput : public CMenuTarget virtual int handleOthers(const neutrino_msg_t msg, const neutrino_msg_data_t data); public: - //CStringInput with max min value option - CStringInput(const neutrino_locale_t Name, char* Value , const int min_value, const int max_value - , int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); - - CStringInput(const neutrino_locale_t Name, char* Value , int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); - CStringInput(char * Head, char* Value , int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); CStringInput(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); + CStringInput(const std::string &Name, std::string* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); ~CStringInput(); void hide(); int exec( CMenuTarget* parent, const std::string & actionKey ); - + void setMinMax(const int min_value, const int max_value); + virtual std::string &getValue(void); }; class CStringInputSMS : public CStringInput @@ -121,8 +115,8 @@ class CStringInputSMS : public CStringInput void initSMS(const char * const Valid_Chars); public: - CStringInputSMS(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ = NULL, const char * const Icon = NULL); CStringInputSMS(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ = NULL, const char * const Icon = NULL); + CStringInputSMS(const std::string &Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ = NULL, const char * const Icon = NULL); }; class CPINInput : public CStringInput @@ -130,10 +124,10 @@ class CPINInput : public CStringInput protected: virtual void paintChar(int pos); public: - CPINInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) - : CStringInput(Name, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *) NEUTRINO_ICON_LOCK) {}; - CPINInput(char * Head, char* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) - : CStringInput(Head, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *) NEUTRINO_ICON_LOCK) {}; + CPINInput(const neutrino_locale_t Name, std::string *Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) + : CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *) NEUTRINO_ICON_LOCK) {}; + CPINInput(const std::string &Name, std::string *Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) + : CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *) NEUTRINO_ICON_LOCK) {}; int exec( CMenuTarget* parent, const std::string & actionKey ); }; @@ -146,10 +140,10 @@ class CEnquiryInput : public CPINInput protected: virtual void paintChar(int pos); public: - CEnquiryInput(const neutrino_locale_t Name, char* Value, int Size, bool Blind, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) - : CPINInput(Name, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ) { blind = Blind; } - CEnquiryInput(char * Head, char* Value, int Size, bool Blind, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) - : CPINInput(Head, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ) { blind = Blind; } + CEnquiryInput(const neutrino_locale_t Name, std::string *Value, int Size, bool Blind, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) + : CPINInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ) { blind = Blind; } + CEnquiryInput(const std::string &Name, std::string *Value, int Size, bool Blind, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) + : CPINInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ) { blind = Blind; } }; @@ -164,8 +158,8 @@ class CPLPINInput : public CPINInput virtual const char * getHint1(void); public: - CPLPINInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_2, int FSK ) - : CPINInput(Name, (char *)Value, Size, NONEXISTANT_LOCALE, Hint_2) { fsk = FSK; }; + CPLPINInput(const neutrino_locale_t Name, std::string *Value, int Size, const neutrino_locale_t Hint_2, int FSK ) + : CPINInput(Name, Value, Size, NONEXISTANT_LOCALE, Hint_2) { fsk = FSK; }; int exec( CMenuTarget* parent, const std::string & actionKey ); }; @@ -173,8 +167,8 @@ class CPLPINInput : public CPINInput class CPINChangeWidget : public CStringInput { public: - CPINChangeWidget(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const char * const Valid_Chars= (const char *) "0123456789", CChangeObserver* Observ = NULL) - : CStringInput(Name, (char *)Value, Size, Hint_1, NONEXISTANT_LOCALE, Valid_Chars, Observ){}; + CPINChangeWidget(const neutrino_locale_t Name, std::string *Value, int Size, const neutrino_locale_t Hint_1, const char * const Valid_Chars= (const char *) "0123456789", CChangeObserver* Observ = NULL) + : CStringInput(Name, Value, Size, Hint_1, NONEXISTANT_LOCALE, Valid_Chars, Observ){}; }; diff --git a/src/gui/widget/stringinput_ext.cpp b/src/gui/widget/stringinput_ext.cpp index 0766b235f..56f8410dd 100644 --- a/src/gui/widget/stringinput_ext.cpp +++ b/src/gui/widget/stringinput_ext.cpp @@ -36,14 +36,15 @@ #include +#include #include #include -CExtendedInput::CExtendedInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel) +CExtendedInput::CExtendedInput(const neutrino_locale_t Name, std::string *Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel) { name = Name; - value = Value; + valueString = Value; cancel = Cancel; hint_1 = Hint_1; @@ -111,11 +112,14 @@ void CExtendedInput::calculateDialog() int maxX = 0; int maxY = 0; + if (valueString->size() < inputFields.size()) + valueString->append(inputFields.size() - valueString->size(), ' '); + selectedChar = -1; for(unsigned int i=0; iinit( ix, iy); - inputFields[i]->setDataPointer( &value[i] ); + inputFields[i]->setDataPointer( &valueString->at(i) ); if ((selectedChar==-1) && (inputFields[i]->isSelectable())) { selectedChar = i; @@ -138,24 +142,14 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) neutrino_msg_data_t data; onBeforeExec(); + calculateDialog(); int res = menu_return::RETURN_REPAINT; - char *oldval = new char[inputFields.size()+10]; - if(oldval == NULL) - return res; - char *dispval = new char[inputFields.size()+10]; - if(dispval == NULL){ - delete[] oldval; - return res; - } - if (parent) - { parent->hide(); - } - strcpy(oldval, value); - strcpy(dispval, value); + std::string oldval = *valueString; + std::string dispval = *valueString; paint(); uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); @@ -163,11 +157,10 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) bool loop=true; while (loop) { - if ( strcmp(value, dispval) != 0) + if (*valueString != dispval) { - std::string tmp = value; - CVFD::getInstance()->showMenuText(1, tmp.c_str(), selectedChar+1); - strcpy(dispval, value); + CVFD::getInstance()->showMenuText(1, valueString->c_str(), selectedChar+1); + dispval = *valueString; } g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true ); @@ -195,8 +188,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) if(found) { inputFields[oldSelectedChar]->paint(x+ offset, y+ hheight+ offset, false ); inputFields[selectedChar]->paint(x+ offset, y+ hheight+ offset, true ); - std::string tmp = value; - CVFD::getInstance()->showMenuText(1, tmp.c_str(), selectedChar+1); + CVFD::getInstance()->showMenuText(1, valueString->c_str(), selectedChar+1); } } else if (msg==CRCInput::RC_right) { bool found = false; @@ -223,8 +215,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) if(found) { inputFields[oldSelectedChar]->paint(x+ offset, y+ hheight+ offset, false ); inputFields[selectedChar]->paint(x+ offset, y+ hheight+ offset, true ); - std::string tmp = value; - CVFD::getInstance()->showMenuText(1, tmp.c_str(), selectedChar+1); + CVFD::getInstance()->showMenuText(1, valueString->c_str(), selectedChar+1); } } else if ( (CRCInput::getUnicodeValue(msg) != -1) || (msg == CRCInput::RC_red) || (msg == CRCInput::RC_green) || (msg == CRCInput::RC_blue) || (msg == CRCInput::RC_yellow) @@ -241,10 +232,10 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { - if(strcmp(value, oldval)!= 0){ + if(*valueString != oldval){ int erg = ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbNo | CMessageBox::mbYes | CMessageBox::mbCancel); if(erg==CMessageBox::mbrYes){ - strcpy(value, oldval); + *valueString = oldval; loop=false; if(cancel != NULL) *cancel = true; @@ -268,7 +259,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) } else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { - strcpy(value, oldval); + *valueString = oldval; loop=false; if(cancel != NULL) *cancel = true; @@ -278,15 +269,12 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) hide(); + *valueString = trim(*valueString); + onAfterExec(); if ((observ) && (msg == CRCInput::RC_ok)) - { - observ->changeNotify(name, value); - } - - delete[] dispval; - delete[] oldval; + observ->changeNotify(name, (void *)valueString->c_str()); return res; } @@ -428,11 +416,8 @@ void CExtendedInput_Item_Char::keyPressed(const int key) //-----------------------------#################################------------------------------------------------------- -CIPInput::CIPInput(const neutrino_locale_t Name, std::string & Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, IP, Hint_1, Hint_2, Observ) +CIPInput::CIPInput(const neutrino_locale_t Name, std::string *Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) : CExtendedInput(Name, Value, Hint_1, Hint_2, Observ) { - ip = &Value; - frameBuffer = CFrameBuffer::getInstance(); addInputField( new CExtendedInput_Item_Char("012") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); @@ -449,47 +434,45 @@ CIPInput::CIPInput(const neutrino_locale_t Name, std::string & Value, const neut addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_newLiner(30) ); - calculateDialog(); } void CIPInput::onBeforeExec() { - if (ip->empty()) + if (valueString->empty()) { - strcpy(value, "000.000.000.000"); - //printf("[neutrino] value-before(2): %s\n", value); + *valueString = "000.000.000.000"; return; } - unsigned char _ip[4]; - sscanf(ip->c_str(), "%hhu.%hhu.%hhu.%hhu", &_ip[0], &_ip[1], &_ip[2], &_ip[3]); - sprintf( value, "%03hhu.%03hhu.%03hhu.%03hhu", _ip[0], _ip[1], _ip[2], _ip[3]); + unsigned char ip[4]; + sscanf(valueString->c_str(), "%hhu.%hhu.%hhu.%hhu", &ip[0], &ip[1], &ip[2], &ip[3]); + char s[20]; + snprintf(s, sizeof(s), "%03hhu.%03hhu.%03hhu.%03hhu", ip[0], ip[1], ip[2], ip[3]); + *valueString = std::string(s); } void CIPInput::onAfterExec() { - int _ip[4]; - sscanf( value, "%3d.%3d.%3d.%3d", &_ip[0], &_ip[1], &_ip[2], &_ip[3] ); - sprintf( value, "%d.%d.%d.%d", _ip[0], _ip[1], _ip[2], _ip[3]); - if(strcmp(value,"0.0.0.0")==0) - { - (*ip) = ""; - } - else - (*ip) = value; + int ip[4]; + sscanf(valueString->c_str(), "%3d.%3d.%3d.%3d", &ip[0], &ip[1], &ip[2], &ip[3] ); + char s[20]; + snprintf(s, sizeof(s), "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + *valueString = std::string(s); + if(*valueString == "0.0.0.0") + *valueString = ""; } //-----------------------------#################################------------------------------------------------------- CDateInput::CDateInput(const neutrino_locale_t Name, time_t* Time, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, (char *) "", Hint_1, Hint_2, Observ) + : CExtendedInput(Name, &valueStringTmp, Hint_1, Hint_2, Observ) { time=Time; - value= new char[20]; + char value[40]; struct tm *tmTime = localtime(time); - sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1, + snprintf(value, sizeof(value), "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900, tmTime->tm_hour, tmTime->tm_min); + *valueString = std::string(value); - frameBuffer = CFrameBuffer::getInstance(); addInputField( new CExtendedInput_Item_Char("0123") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_Char(".",false) ); @@ -507,24 +490,22 @@ CDateInput::CDateInput(const neutrino_locale_t Name, time_t* Time, const neutrin addInputField( new CExtendedInput_Item_Char("012345") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_newLiner(30) ); - calculateDialog(); -} -CDateInput::~CDateInput() -{ - delete value; } + void CDateInput::onBeforeExec() { + char value[40]; struct tm *tmTime = localtime(time); - sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1, + snprintf(value, sizeof(value), "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900, tmTime->tm_hour, tmTime->tm_min); + *valueString = std::string(value); } void CDateInput::onAfterExec() { struct tm tmTime; - sscanf( value, "%02d.%02d.%04d %02d:%02d", &tmTime.tm_mday, &tmTime.tm_mon, + sscanf(valueString->c_str(), "%02d.%02d.%04d %02d:%02d", &tmTime.tm_mday, &tmTime.tm_mon, &tmTime.tm_year, &tmTime.tm_hour, &tmTime.tm_min); tmTime.tm_mon -= 1; @@ -559,18 +540,17 @@ void CDateInput::onAfterExec() tmTime.tm_sec=0; *time=mktime(&tmTime); + char value[40]; struct tm *tmTime2 = localtime(time); - sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1, - tmTime2->tm_year+1900, - tmTime2->tm_hour, tmTime2->tm_min); + snprintf(value, sizeof(value), "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1, + tmTime2->tm_year+1900, + tmTime2->tm_hour, tmTime2->tm_min); + *valueString = std::string(value); } //-----------------------------#################################------------------------------------------------------- -CMACInput::CMACInput(const neutrino_locale_t Name, std::string & -Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, MAC, Hint_1, Hint_2, Observ) +CMACInput::CMACInput(const neutrino_locale_t Name, std::string * Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) : CExtendedInput(Name, Value, Hint_1, Hint_2, Observ) { - mac = &Value; frameBuffer = CFrameBuffer::getInstance(); addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); @@ -590,41 +570,65 @@ Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeOb addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); addInputField( new CExtendedInput_Item_newLiner(30) ); - calculateDialog(); } void CMACInput::onBeforeExec() { - if (value[0] == 0) /* strcmp(value, "") == 0 */ + if (valueString->empty()) { - strcpy(value, "00:00:00:00:00:00"); - printf("[neutrino] value-before(2): %s\n", value); + *valueString = "00:00:00:00:00:00"; return; } - int _mac[6]; - sscanf( mac->c_str(), "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] ); - sprintf( value, "%02x:%02x:%02x:%02x:%02x:%02x", _mac[0], _mac[1], _mac[2], _mac[3], _mac[4], _mac[5]); + int mac[6]; + sscanf(valueString->c_str(), "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ); + char s[20]; + snprintf(s, sizeof(s), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + *valueString = std::string(s); } void CMACInput::onAfterExec() { - int _mac[6]; - sscanf( value, "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] ); - sprintf( value, "%02x:%02x:%02x:%02x:%02x:%02x", _mac[0], _mac[1], _mac[2], _mac[3], _mac[4], _mac[5]); - if(strcmp(value,"00:00:00:00:00:00")==0) - { - (*mac) = ""; - } - else - (*mac) = value; + int mac[6]; + sscanf(valueString->c_str(), "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ); + char s[20]; + snprintf(s, sizeof(s), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + *valueString = std::string(s); + if(*valueString == "00:00:00:00:00:00") + *valueString = ""; } //-----------------------------#################################------------------------------------------------------- -CTimeInput::CTimeInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel) - : CExtendedInput(Name, Value, Hint_1, Hint_2, Observ, Cancel) +CTimeInput::CTimeInput(const neutrino_locale_t Name, std::string* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel) + : CExtendedInput(Name, &valueStringTmp, Hint_1, Hint_2, Observ, Cancel) { + valueString = Value; frameBuffer = CFrameBuffer::getInstance(); +#if 0 + // As nobody else seems to use this class I feel free to make some minor (and mostly backwards-compatible) + // adjustments to make it suitable for movieplayer playtime selection ... --martii + + const char *v = valueString->c_str(); + if (!isdigit(*v)) { + addInputField( new CExtendedInput_Item_Char("=+-") ); + addInputField( new CExtendedInput_Item_Spacer(20) ); + } + addInputField( new CExtendedInput_Item_Char("0123456789") ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + v = strstr(v, ":"); + if (v) { + v++; + addInputField( new CExtendedInput_Item_Char(":",false) ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + v = strstr(v, ":"); + if (v) { + addInputField( new CExtendedInput_Item_Char(":",false) ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + } + } +#else addInputField( new CExtendedInput_Item_Char("=+-") ); addInputField( new CExtendedInput_Item_Spacer(20) ); addInputField( new CExtendedInput_Item_Char("0123456789") ); @@ -635,66 +639,56 @@ CTimeInput::CTimeInput(const neutrino_locale_t Name, char* Value, const neutrino addInputField( new CExtendedInput_Item_Char(":",false) ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); +#endif addInputField( new CExtendedInput_Item_newLiner(30) ); - calculateDialog(); } void CTimeInput::onBeforeExec() { +#if 0 //--martii strcpy(value, "= 00:00:00"); +#endif } void CTimeInput::onAfterExec() { +#if 0 //--martii char tmp[10+1]; strcpy(tmp, value); strcpy(value+1, tmp+2); +#endif } //-----------------------------#################################------------------------------------------------------- -CIntInput::CIntInput(const neutrino_locale_t Name, int& Value, const unsigned int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, myValueStringInput, Hint_1, Hint_2, Observ) +CIntInput::CIntInput(const neutrino_locale_t Name, int *Value, const unsigned int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) + : CExtendedInput(Name, &valueStringTmp, Hint_1, Hint_2, Observ) { - myValue = &Value; + myValue = Value; if (Size Date: Sun, 19 Jan 2014 02:50:31 +0100 Subject: [PATCH 25/54] Preparing the hintbox classes for Lua - Add non locale variants for CHintBoxExt, CMessageBox, ShowMsgUTF THX Martii Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/df06f83a20fc4b39a0d27bab038ecdc43e687dee Author: Michael Liebmann Date: 2014-01-19 (Sun, 19 Jan 2014) Origin message was: ------------------ Preparing the hintbox classes for Lua - Add non locale variants for CHintBoxExt, CMessageBox, ShowMsgUTF THX Martii ------------------ This commit was generated by Migit --- src/gui/widget/hintboxext.cpp | 66 +++++++++++++++++++++++++++-------- src/gui/widget/hintboxext.h | 7 ++-- src/gui/widget/messagebox.cpp | 34 +++++++++++++++--- src/gui/widget/messagebox.h | 6 ++-- 4 files changed, 90 insertions(+), 23 deletions(-) diff --git a/src/gui/widget/hintboxext.cpp b/src/gui/widget/hintboxext.cpp index 040e525f9..4ac14c74c 100644 --- a/src/gui/widget/hintboxext.cpp +++ b/src/gui/widget/hintboxext.cpp @@ -43,8 +43,6 @@ #include -#define HINTBOXEXT_MAX_HEIGHT 420 - CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon) { m_message = strdup(Text); @@ -61,15 +59,44 @@ CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, const char * const Tex m_lines.push_back(oneLine); begin = strtok(NULL, "\n"); } - init(Caption, Width, Icon); + m_bbheight = 0; + init(Caption, "", Width, Icon); } +CHintBoxExt::CHintBoxExt(const std::string &CaptionString, const char * const Text, const int Width, const char * const Icon) +{ + m_message = strdup(Text); + + char *begin = m_message; + + begin = strtok(m_message, "\n"); + while (begin != NULL) + { + std::vector oneLine; + std::string s(begin); + DText *d = new DText(s); + oneLine.push_back(d); + m_lines.push_back(oneLine); + begin = strtok(NULL, "\n"); + } + m_bbheight = 0; + init(NONEXISTANT_LOCALE, CaptionString, Width, Icon); +} CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, ContentLines& lines, const int Width, const char * const Icon) { m_message = NULL; m_lines = lines; - init(Caption, Width, Icon); + m_bbheight = 0; + init(Caption, "", Width, Icon); +} + +CHintBoxExt::CHintBoxExt(const std::string &CaptionString, ContentLines& lines, const int Width, const char * const Icon) +{ + m_message = NULL; + m_lines = lines; + m_bbheight = 0; + init(NONEXISTANT_LOCALE, CaptionString, Width, Icon); } CHintBoxExt::~CHintBoxExt(void) @@ -97,7 +124,7 @@ CHintBoxExt::~CHintBoxExt(void) } } -void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const char * const Icon) +void CHintBoxExt::init(const neutrino_locale_t Caption, const std::string &CaptionString, const int Width, const char * const Icon) { m_width = Width; int nw = 0; @@ -111,11 +138,14 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c bgPainted = false; m_caption = Caption; + m_captionString = CaptionString; int page = 0; int line = 0; int maxWidth = m_width > 0 ? m_width : 0; int maxOverallHeight = 0; + int screenheight = CFrameBuffer::getInstance()->getScreenHeight() * 9 / 10 - m_bbheight; + m_startEntryOfPage.clear(); m_startEntryOfPage.push_back(0); for (ContentLines::iterator it = m_lines.begin(); it!=m_lines.end(); ++it) { @@ -134,7 +164,7 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c if (lineWidth > maxWidth) maxWidth = lineWidth; m_height += maxHeight; - if (m_height > HINTBOXEXT_MAX_HEIGHT || pagebreak) { + if (m_height > screenheight || pagebreak) { if (m_height-maxHeight > maxOverallHeight) maxOverallHeight = m_height - maxHeight; m_height = m_theight + m_fheight + maxHeight; @@ -193,10 +223,18 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c else m_iconfile = ""; - nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(m_caption), true); // UTF-8 + const char *l_caption = (m_caption == NONEXISTANT_LOCALE) ? m_captionString.c_str() : g_Locale->getText(m_caption); + nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(l_caption, true); // UTF-8 if (nw > m_width) m_width = nw; + + /* if the output does not fit, make sure we at least + * stay inside the screen... */ + m_width = w_max(m_width ,SHADOW_OFFSET); + if (maxLineWidth + scrollWidth > m_width) + maxLineWidth = m_width - scrollWidth; + textStartX = (m_width - scrollWidth - maxLineWidth) / 2; m_window = NULL; @@ -216,11 +254,10 @@ void CHintBoxExt::paint(bool toround) } bgPainted = false; - CFrameBuffer* frameBuffer = CFrameBuffer::getInstance(); - m_window = new CFBWindow(frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - m_width ) >> 1), - frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - m_height) >> 2), - m_width + SHADOW_OFFSET, - m_height + SHADOW_OFFSET); + m_window = new CFBWindow(getScreenStartX(m_width + SHADOW_OFFSET), + getScreenStartY(m_height + SHADOW_OFFSET), + m_width + SHADOW_OFFSET, + m_height + SHADOW_OFFSET); refresh(toround); } @@ -243,7 +280,8 @@ void CHintBoxExt::refresh(bool toround) // icon int x_offset = 6, icon_space = x_offset, x_text; - std::string title_text = g_Locale->getText(m_caption); + const char *title_text = (m_caption == NONEXISTANT_LOCALE) ? m_captionString.c_str() : g_Locale->getText(m_caption); + if (!m_iconfile.empty()) { int w, h; @@ -257,7 +295,7 @@ void CHintBoxExt::refresh(bool toround) x_text = x_offset; // title text - m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], x_text, m_theight, m_width, title_text.c_str(), COL_MENUHEAD_TEXT, 0, true); // UTF-8 + m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], x_text, m_theight, m_width, title_text, COL_MENUHEAD_TEXT, 0, true); // UTF-8 // background of text panel m_window->paintBoxRel(0, m_theight, m_width, (m_maxEntriesPerPage + 1) * m_fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0, toround ? RADIUS_LARGE : 0, CORNER_BOTTOM);//round diff --git a/src/gui/widget/hintboxext.h b/src/gui/widget/hintboxext.h index 9cec2bd8b..445c2aaeb 100644 --- a/src/gui/widget/hintboxext.h +++ b/src/gui/widget/hintboxext.h @@ -55,11 +55,13 @@ class CHintBoxExt int m_width; int m_height; + int m_bbheight; /* a button bar at the bottom? */ int textStartX; int m_fheight; int m_theight; neutrino_locale_t m_caption; + std::string m_captionString; char * m_message; ContentLines m_lines; std::string m_iconfile; @@ -69,12 +71,13 @@ class CHintBoxExt public: CHintBoxExt(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon); - CHintBoxExt(const neutrino_locale_t Caption, ContentLines& lines, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO); + CHintBoxExt(const std::string &Caption, const char * const Text, const int Width, const char * const Icon); + CHintBoxExt(const std::string &Caption, ContentLines& lines, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO); ~CHintBoxExt(void); - void init(const neutrino_locale_t Caption, const int Width, const char * const Icon); + void init(const neutrino_locale_t Caption, const std::string &CaptionString, const int Width, const char * const Icon); bool has_scrollbar(void); void scroll_up(void); diff --git a/src/gui/widget/messagebox.cpp b/src/gui/widget/messagebox.cpp index 747af9503..5e8d3e5c6 100644 --- a/src/gui/widget/messagebox.cpp +++ b/src/gui/widget/messagebox.cpp @@ -50,6 +50,16 @@ CMessageBox::CMessageBox(const neutrino_locale_t Caption, ContentLines& Lines, c Init(Default, ShowButtons); } +CMessageBox::CMessageBox(const std::string &Caption, const char * const Text, const int Width, const char * const Icon, const CMessageBox::result_ &Default, const uint32_t ShowButtons) : CHintBoxExt(Caption, Text, Width, Icon) +{ + Init(Default, ShowButtons); +} + +CMessageBox::CMessageBox(const std::string &Caption, ContentLines& Lines, const int Width, const char * const Icon, const CMessageBox::result_ &Default, const uint32_t ShowButtons) : CHintBoxExt(Caption, Lines, Width, Icon) +{ + Init(Default, ShowButtons); +} + void CMessageBox::Init(const CMessageBox::result_ &Default, const uint32_t ShowButtons) { #define BtnCount 3 @@ -65,8 +75,7 @@ void CMessageBox::Init(const CMessageBox::result_ &Default, const uint32_t ShowB } fh = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight(); b_height = std::max(fh, ih) + 8 + (RADIUS_LARGE / 2); - bb_height = b_height + fh/2 + ButtonSpacing; - m_height += bb_height; + m_bbheight = b_height + fh/2 + ButtonSpacing; result = Default; b_width = getButtonWidth(); if (ShowButtons & CMessageBox::mbBtnAlignCenter1) @@ -101,10 +110,14 @@ void CMessageBox::Init(const CMessageBox::result_ &Default, const uint32_t ShowB ButtonDistance = ButtonSpacing; bb_width = b_width * ButtonCount + ButtonDistance * (ButtonCount - 1); if(bb_width > m_width) - m_width = bb_width; + m_width = bb_width; /* FIXME: what if bigger than screen area? */ else if (mbBtnAlign == CMessageBox::mbBtnAlignCenter1) ButtonDistance = (m_width - b_width * ButtonCount) / (ButtonCount + 1); + + /* this is ugly: re-init (CHintBoxExt) to recalculate the number of lines and pages */ + init(m_caption, m_captionString, m_width, m_iconfile == "" ? NULL : m_iconfile.c_str()); + m_height += m_bbheight; } void CMessageBox::returnDefaultValueOnTimeout(bool returnDefault) @@ -138,9 +151,9 @@ void CMessageBox::paintButtons() else if (mbBtnAlign == CMessageBox::mbBtnAlignRight) xpos = m_width - bb_width - ButtonSpacing; - int ypos = (m_height - bb_height) + fh/2; + int ypos = (m_height - m_bbheight) + fh/2; - m_window->paintBoxRel(0, m_height - bb_height, m_width, bb_height, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + m_window->paintBoxRel(0, m_height - m_bbheight, m_width, m_bbheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); i = 0; if (showbuttons & mbYes) { @@ -295,6 +308,17 @@ int ShowMsgUTF(const neutrino_locale_t Caption, const std::string & Text, const return ShowMsgUTF(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); } +int ShowMsgUTF(const std::string & Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +{ + CMessageBox* messageBox = new CMessageBox(Caption, Text.c_str(), Width, Icon, Default, ShowButtons); + messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout); + messageBox->exec(timeout); + int res = messageBox->result; + delete messageBox; + + return res; +} + void DisplayErrorMessage(const char * const ErrorMsg) { ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); diff --git a/src/gui/widget/messagebox.h b/src/gui/widget/messagebox.h index 46178788a..2fac497e2 100644 --- a/src/gui/widget/messagebox.h +++ b/src/gui/widget/messagebox.h @@ -56,7 +56,7 @@ class CMessageBox : public CHintBoxExt int mbBtnAlign; int ButtonSpacing, ButtonDistance; int fh, i_maxw; - int b_height, b_width, bb_height, bb_width; + int b_height, b_width, bb_width; int ButtonCount; void paintButtons(); @@ -88,8 +88,9 @@ class CMessageBox : public CHintBoxExt // Text & Caption are always UTF-8 encoded CMessageBox(const neutrino_locale_t Caption, const char * const Text, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll); - + CMessageBox(const std::string &Caption, const char * const Text, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll); CMessageBox(const neutrino_locale_t Caption, ContentLines& Lines, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll); + CMessageBox(const std::string &Caption, ContentLines& Lines, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll); int exec(int timeout = -1); void returnDefaultValueOnTimeout(bool returnDefault); @@ -102,6 +103,7 @@ class CMessageBox : public CHintBoxExt int ShowLocalizedMessage(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); int ShowMsgUTF(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 int ShowMsgUTF(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsgUTF(const std::string & Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 void DisplayErrorMessage(const char * const ErrorMsg); // UTF-8 void DisplayInfoMessage(const char * const InfoMsg); // UTF-8 From d003aeca10f3006fbc471f3d22ddfc78f70f28c5 Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 4 May 2013 20:49:14 +0200 Subject: [PATCH 26/54] LUA: experimental support for native neutrino menues Signed-off-by: M. Liebmann Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2a41749eb54624a9a12b4ddc0a6272cbbbd11483 Author: martii Date: 2013-05-04 (Sat, 04 May 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 391 ++++++++++++++++++++++++++++++++++++++++ src/gui/luainstance.h | 88 +++++++++ 2 files changed, 479 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 1db573b2d..c12cf9a51 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -26,6 +26,9 @@ #include #include #include +#ifdef MARTII +#include +#endif #include #include "luainstance.h" @@ -220,6 +223,17 @@ static void set_lua_variables(lua_State *L) { "END_Y", g_settings.screen_EndY }, { NULL, 0 } }; +#ifdef MARTII + table_key menureturn[] = + { + { "NONE", menu_return::RETURN_NONE }, + { "REPAINT", menu_return::RETURN_REPAINT }, + { "EXIT", menu_return::RETURN_EXIT }, + { "EXIT_ALL", menu_return::RETURN_EXIT_ALL }, + { "EXIT_REPAINT", menu_return::RETURN_EXIT_REPAINT }, + { NULL, 0 } + }; +#endif /* list of environment variable arrays to be exported */ lua_envexport e[] = @@ -229,6 +243,9 @@ static void set_lua_variables(lua_State *L) { "SCREEN", screenopts }, { "FONT", fontlist }, { "CORNER", corners }, +#ifdef MARTII + { "MENU_RETURN", menureturn }, +#endif { NULL, NULL } }; @@ -378,6 +395,9 @@ void CLuaInstance::registerFunctions() lua_pop(lua, 1); lua_register(lua, className, NewWindow); +#ifdef MARTII + MenueRegister(lua); +#endif } CLuaData *CLuaInstance::CheckData(lua_State *L, int narg) @@ -561,3 +581,374 @@ int CLuaInstance::GCWindow(lua_State *L) delete w; return 0; } +#ifdef MARTII +#if 0 +local m = menue.new{name="mytitle", icon="myicon", hide_parent=true} +m:addItem{type="back"} +m:addItem{type="separator"} + +function talk(a) + print(">talk") + print(a) + print(">anothermenue"); + local m = menue.new{name="anothermenue", icon="settings"} + m:addItem{type="back"} + m:addItem{type="separator"} + m:addItem{type="numeric", name="testnumeric"} + m:exec() + print("<Name.c_str()); + if (!luaAction.empty()){ + lua_pushglobaltable(L); + lua_getfield(L, -1, luaAction.c_str()); + lua_remove(L, -2); + lua_pushstring(L, value); + lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0); + //double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0; + lua_pop(L, 1); + } + return menu_return::RETURN_REPAINT; +} + +CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon) +{ + L = _L; + luaAction = _luaAction; + name = _name; + value = _value; + size = _size; + valid_chars = _valid_chars; + icon = _icon; + observ = _observ; +} + +CLuaMenueStringinput::~CLuaMenueStringinput() +{ +} + +int CLuaMenueStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) +{ + CStringInput i((char *)name, value, size, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, valid_chars.c_str(), observ, icon); + i.luaAction = luaAction; + i.luaState = L; + i.exec(NULL, ""); + return menu_return::RETURN_REPAINT; +} + + +int CLuaInstance::MenueNew(lua_State *L) +{ + CMenuWidget *m; + + if (lua_istable(L, 1)) { + std::string name, icon; + tableLookupString(L, "name", name) || tableLookupString(L, "title", name); + tableLookupString(L, "icon", icon); + int mwidth; + if(tableLookupInt(L, "mwidth", mwidth)) + m = new CMenuWidget(name.c_str(), icon.c_str(), mwidth); + else + m = new CMenuWidget(name.c_str(), icon.c_str()); + } else + m = new CMenuWidget(); + + CLuaMenue **udata = (CLuaMenue **) lua_newuserdata(L, sizeof(CLuaMenue *)); + *udata = new CLuaMenue(); + (*udata)->m = m; + luaL_getmetatable(L, "menue"); + lua_setmetatable(L, -2); + return 1; +} + +int CLuaInstance::MenueDelete(lua_State *L) +{ + CLuaMenue *m = MenueCheck(L, 1); + + while(!m->targets.empty()) { + delete m->targets.front(); + m->targets.pop_front(); + } + while(!m->tofree.empty()) { + free(m->tofree.front()); + m->tofree.pop_front(); + } + + delete m; + return 0; +} + +int CLuaInstance::MenueAddItem(lua_State *L) +{ + CLuaMenue *m = MenueCheck(L, 1); + lua_assert(lua_istable(L, 2)); + + CLuaMenueItem i; + m->items.push_front(i); + std::list::iterator it = m->items.begin(); + + tableLookupString(L, "name", (*it).name); + std::string type; tableLookupString(L, "type", type); + + if (type == "back") { + m->m->addItem(GenericMenuBack); + } else if (type == "separator") { + if (!(*it).name.empty()) + m->m->addItem(new CNonLocalizedMenuSeparator((*it).name.c_str(), NONEXISTANT_LOCALE)); + else + m->m->addItem(GenericMenuSeparatorLine); + } else { + tableLookupString(L, "icon", (*it).Icon); + tableLookupString(L, "right_icon", (*it).right_Icon); + std::string action; tableLookupString(L, "action", action); + std::string shortcut; tableLookupString(L, "shortcut", shortcut); + std::string value; tableLookupString(L, "value", value); + int directkey = CRCInput::RC_nokey; tableLookupInt(L, "directkey", directkey); + int pulldown = false; tableLookupInt(L, "pulldown", pulldown); + const char *icon = (*it).Icon.c_str(); + const char *right_icon = (*it).right_Icon.c_str(); + if (!*icon) + icon = NULL; + if (!*right_icon) + right_icon = NULL; + + std::string tmp = "true"; + tableLookupString(L, "enabled", tmp) || tableLookupString(L, "active", tmp); + bool enabled = (tmp == "true" || tmp == "1" || tmp == "yes"); + tableLookupString(L, "range", tmp); + int range_from = 0, range_to = 99; + sscanf(tmp.c_str(), "%d,%d", &range_from, &range_to); + + if (type == "forwarder") { + strncpy((*it).s, value.c_str(), sizeof((*it).s)); + CLuaMenueForwarder *forwarder = new CLuaMenueForwarder(L, action); + CMenuItem *mi = new CMenuForwarderNonLocalized( + (*it).name.c_str(), enabled, (*it).s, forwarder, NULL/*ActionKey*/, directkey, icon, right_icon); + mi->luaAction = action; + mi->luaState = L; + m->m->addItem(mi); + m->targets.push_front(forwarder); + } else if (type == "chooser") { + int options_count = 0; + lua_pushstring(L, "options"); + lua_gettable(L, -2); + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + options_count++; + } + lua_pop(L, 1); + + CMenuOptionChooser::keyval_ext *kext = (CMenuOptionChooser::keyval_ext *)calloc(options_count, sizeof(CMenuOptionChooser::keyval_ext)); + m->tofree.push_front(kext); + lua_pushstring(L, "options"); + lua_gettable(L, -2); + (*it).i = 0; + int j = 0; + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + const char *key = lua_tostring(L, -1); + const char *val = lua_tostring(L, -2); + kext[j].key = atoi(key); + kext[j].value = NONEXISTANT_LOCALE; + kext[j].valname = strdup(val); + m->tofree.push_front((void *)kext[j].valname); + if (!strcmp(value.c_str(), kext[j].valname)) + (*it).i = j; + j++; + } + lua_pop(L, 1); + CMenuItem *mi = new CMenuOptionChooser((*it).name.c_str(), &(*it).i, kext, options_count, enabled, m->observ, directkey, icon, pulldown); + mi->luaAction = action; + mi->luaState = L; + m->m->addItem(mi); + } else if (type == "numeric") { + (*it).i = range_from; + sscanf(value.c_str(), "%d", &(*it).i); + CMenuItem *mi = new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &(*it).i, enabled, range_from, range_to, m->observ, + 0, 0, NONEXISTANT_LOCALE, (*it).name.c_str(), pulldown); + mi->luaAction = action; + mi->luaState = L; + m->m->addItem(mi); + } else if (type == "string") { + strncpy((*it).s, value.c_str(), sizeof((*it).s)); + CMenuItem *mi = new CMenuOptionStringChooser((*it).name.c_str(), (*it).s, enabled, m->observ, directkey, icon, pulldown); + mi->luaAction = action; + mi->luaState = L; + m->m->addItem(mi); + + } else if (type == "stringinput") { + strncpy((*it).s, value.c_str(), sizeof((*it).s)); + std::string valid_chars = " 0123456789. "; + tableLookupString(L, "valid_chars", valid_chars); + int size = 30; + tableLookupInt(L, "size", size); + CLuaMenueStringinput *stringinput = new CLuaMenueStringinput(L, action, (*it).name.c_str(), (*it).s, size, valid_chars, m->observ, icon); + CMenuItem *mi = new CMenuForwarderNonLocalized( + (*it).name.c_str(), enabled, (*it).s, stringinput, NULL/*ActionKey*/, directkey, icon, right_icon); + mi->luaAction = action; + mi->luaState = L; + m->m->addItem(mi); + m->targets.push_front(stringinput); + } else if (type == "filebrowser") { + strncpy((*it).s, value.c_str(), sizeof((*it).s)); + CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, (*it).s); + CMenuItem *mi = new CMenuForwarderNonLocalized( + (*it).name.c_str(), enabled, (*it).s, filebrowser, NULL/*ActionKey*/, directkey, icon, right_icon); + mi->luaAction = action; + mi->luaState = L; + m->m->addItem(mi); + m->targets.push_front(filebrowser); + } + } + return 1; +} + +int CLuaInstance::MenueHide(lua_State *L) +{ + CLuaMenue *m = MenueCheck(L, 1); + m->m->hide(); + return 0; +} + +int CLuaInstance::MenueExec(lua_State *L) +{ + CLuaMenue *m = MenueCheck(L, 1); + m->m->exec(NULL, ""); + m->m->hide(); + return 0; +} +#endif diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index fe1a250ff..d3a75a397 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -26,6 +26,9 @@ extern "C" { #include } #include +#ifdef MARTII +#include +#endif /* this is stored as userdata in the lua_State */ struct CLuaData @@ -33,12 +36,86 @@ struct CLuaData CFBWindow *fbwin; CRCInput *rcinput; }; +#ifdef MARTII +struct CLuaMenueItem +{ + union + { + int i; + char s[255]; + }; + std::string name; + std::string Icon; + std::string right_Icon; +}; + +class CLuaMenueChangeObserver : public CChangeObserver +{ + public: + bool changeNotify(lua_State *, const std::string &, void *); +}; + +class CLuaMenue +{ + public: + CMenuWidget *m; + CLuaMenueChangeObserver *observ; + std::list items; + std::list targets; + std::list tofree; + CLuaMenue(); + ~CLuaMenue(); +}; + +class CLuaMenueForwarder : public CMenuTarget +{ + private: + lua_State *L; + std::string luaAction; + public: + CLuaMenueForwarder(lua_State *L, std::string _luaAction); + ~CLuaMenueForwarder(); + int exec(CMenuTarget* parent, const std::string & actionKey); +}; + +class CLuaMenueFilebrowser : public CMenuTarget +{ + private: + lua_State *L; + std::string luaAction; + char *value; + public: + CLuaMenueFilebrowser(lua_State *L, std::string _luaAction, char *_value); + ~CLuaMenueFilebrowser(); + int exec(CMenuTarget* parent, const std::string & actionKey); +}; + +class CLuaMenueStringinput : public CMenuTarget +{ + private: + lua_State *L; + std::string luaAction; + const char *name; + char *value; + int size; + std::string valid_chars; + CChangeObserver *observ; + const char *icon; + public: + CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon); + ~CLuaMenueStringinput(); + int exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/); +}; +#endif /* inspired by Steve Kemp http://www.steve.org.uk/ */ class CLuaInstance { static const char className[]; static const luaL_Reg methods[]; +#ifdef MARTII + static const luaL_Reg menue_methods[]; +#endif static CLuaData *CheckData(lua_State *L, int narg); public: CLuaInstance(); @@ -56,6 +133,17 @@ private: static int FontHeight(lua_State *L); static int GetInput(lua_State *L); static int GCWindow(lua_State *L); +#ifdef MARTII + void MenueRegister(lua_State *L); + static int MenueNew(lua_State *L); + static int MenueDelete(lua_State *L); + static int MenueAddItem(lua_State *L); + static int MenueHide(lua_State *L); + static int MenueExec(lua_State *L); + static CLuaMenue *MenueCheck(lua_State *L, int n); + static bool tableLookupString(lua_State*, const char*, std::string&); + static bool tableLookupInt(lua_State*, const char*, int&); +#endif }; #endif /* _LUAINSTANCE_H */ From 650c925e54d0279b590c7cc8ef42864e7381d17e Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 5 May 2013 10:18:00 +0200 Subject: [PATCH 27/54] LUA: add hintbox; bugfixes Signed-off-by: M. Liebmann Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/0b38475439fb5d73a2e3618798f9106b10910c3b Author: martii Date: 2013-05-05 (Sun, 05 May 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 236 ++++++++++++++++++++++++++++++++-------- src/gui/luainstance.h | 29 ++++- 2 files changed, 216 insertions(+), 49 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index c12cf9a51..f8ebc45c9 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -397,6 +397,7 @@ void CLuaInstance::registerFunctions() lua_register(lua, className, NewWindow); #ifdef MARTII MenueRegister(lua); + HintboxRegister(lua); #endif } @@ -588,20 +589,20 @@ m:addItem{type="back"} m:addItem{type="separator"} function talk(a) - print(">talk") - print(a) - print("talk") + print(a) + print(">anothermenue"); - local m = menue.new{name="anothermenue", icon="settings"} - m:addItem{type="back"} - m:addItem{type="separator"} - m:addItem{type="numeric", name="testnumeric"} - m:exec() - print("<>anothermenue"); + local m = menue.new{name="anothermenue", icon="settings"} + m:addItem{type="back"} + m:addItem{type="separator"} + m:addItem{type="numeric", name="testnumeric"} + m:exec() + print("<Name.c_str()); + if (fileBrowser.exec(value) == true) + strcpy(value, fileBrowser.getSelectedFile()->Name.c_str()); if (!luaAction.empty()){ lua_pushglobaltable(L); lua_getfield(L, -1, luaAction.c_str()); @@ -745,7 +751,7 @@ int CLuaMenueFilebrowser::exec(CMenuTarget* /*parent*/, const std::string & /*ac return menu_return::RETURN_REPAINT; } -CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon) +CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms) { L = _L; luaAction = _luaAction; @@ -755,6 +761,7 @@ CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction valid_chars = _valid_chars; icon = _icon; observ = _observ; + sms = _sms; } CLuaMenueStringinput::~CLuaMenueStringinput() @@ -763,10 +770,17 @@ CLuaMenueStringinput::~CLuaMenueStringinput() int CLuaMenueStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) { - CStringInput i((char *)name, value, size, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, valid_chars.c_str(), observ, icon); - i.luaAction = luaAction; - i.luaState = L; - i.exec(NULL, ""); + CStringInput *i; + if (sms) + i = new CStringInputSMS((char *)name, value, size, + NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, valid_chars.c_str(), observ, icon); + else + i = new CStringInput((char *)name, value, size, + NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, valid_chars.c_str(), observ, icon); + i->luaAction = luaAction; + i->luaState = L; + i->exec(NULL, ""); + delete i; return menu_return::RETURN_REPAINT; } @@ -822,8 +836,8 @@ int CLuaInstance::MenueAddItem(lua_State *L) std::list::iterator it = m->items.begin(); tableLookupString(L, "name", (*it).name); - std::string type; tableLookupString(L, "type", type); - + std::string icon; tableLookupString(L, "icon", icon); + std::string type; tableLookupString(L, "type", type); if (type == "back") { m->m->addItem(GenericMenuBack); } else if (type == "separator") { @@ -832,20 +846,11 @@ int CLuaInstance::MenueAddItem(lua_State *L) else m->m->addItem(GenericMenuSeparatorLine); } else { - tableLookupString(L, "icon", (*it).Icon); - tableLookupString(L, "right_icon", (*it).right_Icon); + std::string right_icon; tableLookupString(L, "right_icon", right_icon); std::string action; tableLookupString(L, "action", action); - std::string shortcut; tableLookupString(L, "shortcut", shortcut); std::string value; tableLookupString(L, "value", value); int directkey = CRCInput::RC_nokey; tableLookupInt(L, "directkey", directkey); int pulldown = false; tableLookupInt(L, "pulldown", pulldown); - const char *icon = (*it).Icon.c_str(); - const char *right_icon = (*it).right_Icon.c_str(); - if (!*icon) - icon = NULL; - if (!*right_icon) - right_icon = NULL; - std::string tmp = "true"; tableLookupString(L, "enabled", tmp) || tableLookupString(L, "active", tmp); bool enabled = (tmp == "true" || tmp == "1" || tmp == "yes"); @@ -857,7 +862,7 @@ int CLuaInstance::MenueAddItem(lua_State *L) strncpy((*it).s, value.c_str(), sizeof((*it).s)); CLuaMenueForwarder *forwarder = new CLuaMenueForwarder(L, action); CMenuItem *mi = new CMenuForwarderNonLocalized( - (*it).name.c_str(), enabled, (*it).s, forwarder, NULL/*ActionKey*/, directkey, icon, right_icon); + (*it).name.c_str(), enabled, (*it).s, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); @@ -891,7 +896,7 @@ int CLuaInstance::MenueAddItem(lua_State *L) j++; } lua_pop(L, 1); - CMenuItem *mi = new CMenuOptionChooser((*it).name.c_str(), &(*it).i, kext, options_count, enabled, m->observ, directkey, icon, pulldown); + CMenuItem *mi = new CMenuOptionChooser((*it).name.c_str(), &(*it).i, kext, options_count, enabled, m->observ, directkey, icon.c_str(), pulldown); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); @@ -905,7 +910,7 @@ int CLuaInstance::MenueAddItem(lua_State *L) m->m->addItem(mi); } else if (type == "string") { strncpy((*it).s, value.c_str(), sizeof((*it).s)); - CMenuItem *mi = new CMenuOptionStringChooser((*it).name.c_str(), (*it).s, enabled, m->observ, directkey, icon, pulldown); + CMenuItem *mi = new CMenuOptionStringChooser((*it).name.c_str(), (*it).s, enabled, m->observ, directkey, icon.c_str(), pulldown); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); @@ -914,20 +919,23 @@ int CLuaInstance::MenueAddItem(lua_State *L) strncpy((*it).s, value.c_str(), sizeof((*it).s)); std::string valid_chars = " 0123456789. "; tableLookupString(L, "valid_chars", valid_chars); + int sms = 0; + tableLookupInt(L, "sms", sms); int size = 30; tableLookupInt(L, "size", size); - CLuaMenueStringinput *stringinput = new CLuaMenueStringinput(L, action, (*it).name.c_str(), (*it).s, size, valid_chars, m->observ, icon); + CLuaMenueStringinput *stringinput = new CLuaMenueStringinput(L, action, (*it).name.c_str(), (*it).s, size, valid_chars, m->observ, icon.c_str(), sms); CMenuItem *mi = new CMenuForwarderNonLocalized( - (*it).name.c_str(), enabled, (*it).s, stringinput, NULL/*ActionKey*/, directkey, icon, right_icon); + (*it).name.c_str(), enabled, (*it).s, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); m->targets.push_front(stringinput); } else if (type == "filebrowser") { strncpy((*it).s, value.c_str(), sizeof((*it).s)); - CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, (*it).s); + int dirMode = 0; tableLookupInt(L, "dir_mode", dirMode); + CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, (*it).s, dirMode); CMenuItem *mi = new CMenuForwarderNonLocalized( - (*it).name.c_str(), enabled, (*it).s, filebrowser, NULL/*ActionKey*/, directkey, icon, right_icon); + (*it).name.c_str(), enabled, (*it).s, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); @@ -951,4 +959,142 @@ int CLuaInstance::MenueExec(lua_State *L) m->m->hide(); return 0; } + +void CLuaInstance::HintboxRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "new", CLuaInstance::HintboxNew }, + { "show", CLuaInstance::HintboxShow }, + { "paint", CLuaInstance::HintboxPaint }, + { "hide", CLuaInstance::HintboxHide }, + { "__gc", CLuaInstance::HintboxDelete }, + { NULL, NULL } + }; + + luaL_newmetatable(L, "hintbox"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "hintbox"); +} + +CLuaHintbox *CLuaInstance::HintboxCheck(lua_State *L, int n) +{ + return *(CLuaHintbox **) luaL_checkudata(L, n, "hintbox"); +} + +CLuaHintbox::CLuaHintbox() +{ + caption = NULL; + b = NULL; +} + +CLuaHintbox::~CLuaHintbox() +{ + if (caption) + free(caption); + delete b; +} + +int CLuaInstance::HintboxNew(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + + std::string name, text, icon = std::string(NEUTRINO_ICON_INFO); + tableLookupString(L, "name", name) || tableLookupString(L, "title", name) || tableLookupString(L, "caption", name); + tableLookupString(L, "text", text); + tableLookupString(L, "icon", icon); + int width = 450; + tableLookupInt(L, "width", width); + + CLuaHintbox **udata = (CLuaHintbox **) lua_newuserdata(L, sizeof(CLuaHintbox *)); + *udata = new CLuaHintbox(); + (*udata)->caption = strdup(name.c_str()); + (*udata)->b = new CHintBox((*udata)->caption, text.c_str(), width, icon.c_str()); + luaL_getmetatable(L, "hintbox"); + lua_setmetatable(L, -2); + return 1; +} + +int CLuaInstance::HintboxDelete(lua_State *L) +{ + CLuaHintbox *m = HintboxCheck(L, 1); + delete m; + return 0; +} + +int CLuaInstance::HintboxPaint(lua_State *L) +{ + CLuaHintbox *m = HintboxCheck(L, 1); + m->b->paint(); + return 0; +} + +int CLuaInstance::HintboxHide(lua_State *L) +{ + CLuaHintbox *m = HintboxCheck(L, 1); + m->b->hide(); + return 0; +} + +int CLuaInstance::HintboxShow(lua_State *L) +{ + CLuaHintbox *m = HintboxCheck(L, 1); + int timeout = -1; + if (lua_isnumber(L, -1)) + timeout = (int) lua_tonumber(L, -1); + m->b->paint(); + + // copied from gui/widget/hintbox.cpp + + neutrino_msg_t msg; + neutrino_msg_data_t data; + if ( timeout == -1 ) + timeout = 5; /// default timeout 5 sec + //timeout = g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR]; + + uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout ); + + int res = messages_return::none; + + while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) ) + { + g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); + + if ((msg == CRCInput::RC_timeout) || (msg == CRCInput::RC_ok)) + res = messages_return::cancel_info; + else if(msg == CRCInput::RC_home) + res = messages_return::cancel_all; + else if ((m->b->has_scrollbar()) && ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))) + { + if (msg == CRCInput::RC_up) + m->b->scroll_up(); + else + m->b->scroll_down(); + } + else if((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites)) { + } + else if(msg == CRCInput::RC_mode) { + res = messages_return::handled; + break; + } + else if((msg == CRCInput::RC_next) || (msg == CRCInput::RC_prev)) { + res = messages_return::cancel_all; + g_RCInput->postMsg(msg, data); + } + else + { + res = CNeutrinoApp::getInstance()->handleMsg(msg, data); + if (res & messages_return::unhandled) + { + + // leave here and handle above... + g_RCInput->postMsg(msg, data); + res = messages_return::cancel_all; + } + } + } + m->b->hide(); + return 0; +} #endif diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index d3a75a397..50f7a6e14 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -28,6 +28,8 @@ extern "C" { #include #ifdef MARTII #include +#include +#include #endif /* this is stored as userdata in the lua_State */ @@ -45,8 +47,6 @@ struct CLuaMenueItem char s[255]; }; std::string name; - std::string Icon; - std::string right_Icon; }; class CLuaMenueChangeObserver : public CChangeObserver @@ -84,8 +84,9 @@ class CLuaMenueFilebrowser : public CMenuTarget lua_State *L; std::string luaAction; char *value; + bool dirMode; public: - CLuaMenueFilebrowser(lua_State *L, std::string _luaAction, char *_value); + CLuaMenueFilebrowser(lua_State *L, std::string _luaAction, char *_value, bool _dirMode); ~CLuaMenueFilebrowser(); int exec(CMenuTarget* parent, const std::string & actionKey); }; @@ -101,11 +102,22 @@ class CLuaMenueStringinput : public CMenuTarget std::string valid_chars; CChangeObserver *observ; const char *icon; + bool sms; public: - CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon); + CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms); ~CLuaMenueStringinput(); int exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/); }; + +class CLuaHintbox +{ + public: + CHintBox *b; + char *caption; + CLuaHintbox(); + ~CLuaHintbox(); +}; + #endif /* inspired by Steve Kemp http://www.steve.org.uk/ */ @@ -141,6 +153,15 @@ private: static int MenueHide(lua_State *L); static int MenueExec(lua_State *L); static CLuaMenue *MenueCheck(lua_State *L, int n); + + void HintboxRegister(lua_State *L); + static int HintboxNew(lua_State *L); + static int HintboxDelete(lua_State *L); + static int HintboxShow(lua_State *L); + static int HintboxPaint(lua_State *L); + static int HintboxHide(lua_State *L); + static CLuaHintbox *HintboxCheck(lua_State *L, int n); + static bool tableLookupString(lua_State*, const char*, std::string&); static bool tableLookupInt(lua_State*, const char*, int&); #endif From 261cd2f6fbb90c0fee2a56a5a1b4ab09590d0f51 Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 5 May 2013 14:37:58 +0200 Subject: [PATCH 28/54] LUA: messagebox support Signed-off-by: M. Liebmann Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/098c205b57de776e364c4248ea63decbf33e8ed7 Author: martii Date: 2013-05-05 (Sun, 05 May 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 75 +++++++++++++++++++++++++++++++++++++++-- src/gui/luainstance.h | 14 +++++++- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index f8ebc45c9..fd55203d8 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -398,6 +398,7 @@ void CLuaInstance::registerFunctions() #ifdef MARTII MenueRegister(lua); HintboxRegister(lua); + MessageboxRegister(lua); #endif } @@ -964,7 +965,7 @@ void CLuaInstance::HintboxRegister(lua_State *L) { luaL_Reg meth[] = { { "new", CLuaInstance::HintboxNew }, - { "show", CLuaInstance::HintboxShow }, + { "exec", CLuaInstance::HintboxExec }, { "paint", CLuaInstance::HintboxPaint }, { "hide", CLuaInstance::HintboxHide }, { "__gc", CLuaInstance::HintboxDelete }, @@ -1037,7 +1038,7 @@ int CLuaInstance::HintboxHide(lua_State *L) return 0; } -int CLuaInstance::HintboxShow(lua_State *L) +int CLuaInstance::HintboxExec(lua_State *L) { CLuaHintbox *m = HintboxCheck(L, 1); int timeout = -1; @@ -1097,4 +1098,74 @@ int CLuaInstance::HintboxShow(lua_State *L) m->b->hide(); return 0; } + +void CLuaInstance::MessageboxRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "exec", CLuaInstance::MessageboxExec }, + { NULL, NULL } + }; + + luaL_newmetatable(L, "messagebox"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "messagebox"); +} + +// messagebox.exec{caption="Title", text="text", icon="settings", width=500,timeout=-1,return_default_on_timeout=0, +// default = "yes", buttons = { "yes", "no", "cancel", "all", "back", "ok" }, align="center1|center2|left|right" } +int CLuaInstance::MessageboxExec(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + + std::string name, text, icon = std::string(NEUTRINO_ICON_INFO); + tableLookupString(L, "name", name) || tableLookupString(L, "title", name) || tableLookupString(L, "caption", name); + tableLookupString(L, "text", text); + tableLookupString(L, "icon", icon); + int timeout = -1, width = 450, return_default_on_timeout = 0, show_buttons = 0, default_button = 0; + tableLookupInt(L, "timeout", timeout); + tableLookupInt(L, "width", width); + tableLookupInt(L, "return_default_on_timeout", return_default_on_timeout); + + std::string tmp; + if (tableLookupString(L, "align", tmp)) { + if (tmp == "center1") show_buttons |= CMessageBox::mbBtnAlignCenter1; + else if (tmp == "center2") show_buttons |= CMessageBox::mbBtnAlignCenter2; + else if (tmp == "left") show_buttons |= CMessageBox::mbBtnAlignLeft; + else if (tmp == "right") show_buttons |= CMessageBox::mbBtnAlignRight; + } + lua_pushstring(L, "buttons"); + lua_gettable(L, -2); + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + if (!strcmp(val, "yes")) show_buttons |= CMessageBox::mbYes; + else if (!strcmp(val, "no")) show_buttons |= CMessageBox::mbNo; + else if (!strcmp(val, "cancel")) show_buttons |= CMessageBox::mbCancel; + else if (!strcmp(val, "all")) show_buttons |= CMessageBox::mbAll; + else if (!strcmp(val, "back")) show_buttons |= CMessageBox::mbBack; + else if (!strcmp(val, "ok")) show_buttons |= CMessageBox::mbOk; + } + lua_pop(L, 1); + + if (tableLookupString(L, "default", tmp)) { + if (tmp == "yes") default_button = CMessageBox::mbrYes; + else if (tmp == "no") default_button = CMessageBox::mbrNo; + else if (tmp == "cancel") default_button = CMessageBox::mbrCancel; + else if (tmp == "back") default_button = CMessageBox::mbrBack; + else if (tmp == "ok") default_button = CMessageBox::mbrOk; + } + + int res = ShowMsgUTF(name.c_str(), text.c_str(), (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); + + if (res == CMessageBox::mbrYes) tmp = "yes"; + else if (res == CMessageBox::mbrNo) tmp = "no"; + else if (res == CMessageBox::mbrBack) tmp = "back"; + else if (res == CMessageBox::mbrOk) tmp = "ok"; + else tmp = "cancel"; + lua_pushstring(L, tmp.c_str()); + + return 1; +} #endif diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 50f7a6e14..2e5a16d85 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -118,6 +118,14 @@ class CLuaHintbox ~CLuaHintbox(); }; +class CLuaMessagebox +{ + public: + CMessageBox *b; + CLuaMessagebox(); + ~CLuaMessagebox(); +}; + #endif /* inspired by Steve Kemp http://www.steve.org.uk/ */ @@ -157,11 +165,15 @@ private: void HintboxRegister(lua_State *L); static int HintboxNew(lua_State *L); static int HintboxDelete(lua_State *L); - static int HintboxShow(lua_State *L); + static int HintboxExec(lua_State *L); static int HintboxPaint(lua_State *L); static int HintboxHide(lua_State *L); static CLuaHintbox *HintboxCheck(lua_State *L, int n); + void MessageboxRegister(lua_State *L); + static int MessageboxExec(lua_State *L); + static CLuaMessagebox *MessageboxCheck(lua_State *L, int n); + static bool tableLookupString(lua_State*, const char*, std::string&); static bool tableLookupInt(lua_State*, const char*, int&); #endif From 239f4beae06dbc1f3d9001cd425ee9c762e5880b Mon Sep 17 00:00:00 2001 From: martii Date: Mon, 6 May 2013 21:08:31 +0200 Subject: [PATCH 29/54] LUA: change stringinput valid chars Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/920e4755267fe9d5584736a253b4f2574d50f1fc Author: martii Date: 2013-05-06 (Mon, 06 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index fd55203d8..7dfb5a53c 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -918,7 +918,7 @@ int CLuaInstance::MenueAddItem(lua_State *L) } else if (type == "stringinput") { strncpy((*it).s, value.c_str(), sizeof((*it).s)); - std::string valid_chars = " 0123456789. "; + std::string valid_chars = "abcdefghijklmnopqrstuvwxyz0123456789!\"§$%&/()=?-. "; tableLookupString(L, "valid_chars", valid_chars); int sms = 0; tableLookupInt(L, "sms", sms); From fa8cab37ee2463cce7f4f636e8254e88b7fcf826 Mon Sep 17 00:00:00 2001 From: martii Date: Tue, 7 May 2013 19:57:06 +0200 Subject: [PATCH 30/54] LUA fixes Signed-off-by: M. Liebmann Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/df1ec2398037fa1c285ed29248c51e269808a856 Author: martii Date: 2013-05-07 (Tue, 07 May 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 307 ++++++++++++++++++++++++++-------------- src/gui/luainstance.h | 34 +++-- 2 files changed, 217 insertions(+), 124 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 7dfb5a53c..f139c7d23 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -122,6 +122,24 @@ static void set_lua_variables(lua_State *L) { "mute_off", CRCInput::RC_mute_off }, { "analog_on", CRCInput::RC_analog_on }, { "analog_off", CRCInput::RC_analog_off }, +#ifdef MARTII +/* SPARK keys */ + { "find", CRCInput::RC_find }, + { "pip", CRCInput::RC_pip }, + { "folder", CRCInput::RC_archive }, + { "forward", CRCInput::RC_fastforward }, + { "slow", CRCInput::RC_slow }, + { "playmode", CRCInput::RC_playmode }, + { "usb", CRCInput::RC_usb }, + { "f1", CRCInput::RC_f1 }, + { "f2", CRCInput::RC_f2 }, + { "f3", CRCInput::RC_f3 }, + { "f4", CRCInput::RC_f4 }, + { "prog1", CRCInput::RC_prog1 }, + { "prog2", CRCInput::RC_prog2 }, + { "prog3", CRCInput::RC_prog3 }, + { "prog4", CRCInput::RC_prog4 }, +#endif /* to check if it is in our range */ { "MaxRC", CRCInput::RC_MaxRC }, { NULL, 0 } @@ -327,6 +345,10 @@ const luaL_Reg CLuaInstance::methods[] = { "PaintIcon", CLuaInstance::PaintIcon }, { "GetInput", CLuaInstance::GetInput }, { "FontHeight", CLuaInstance::FontHeight }, +#ifdef MARTII + { "Blit", CLuaInstance::Blit }, + { "GetLanguage", CLuaInstance::GetLanguage }, +#endif { NULL, NULL } }; @@ -584,6 +606,26 @@ int CLuaInstance::GCWindow(lua_State *L) return 0; } #ifdef MARTII +int CLuaInstance::Blit(lua_State *L) +{ + CLuaData *W = CheckData(L, 1); + if (W && W->fbwin) { + if (lua_isnumber(L, 2)) { + W->fbwin->mayBlit = (int)lua_tonumber(L, 2); // enable/disable automatic blit + } else + W->fbwin->blit(); + } + return 0; +} + +int CLuaInstance::GetLanguage(lua_State *L) +{ + // FIXME -- should conform to ISO 639-1/ISO 3166-1 + lua_pushstring(L, g_settings.language); + + return 1; +} + #if 0 local m = menue.new{name="mytitle", icon="myicon", hide_parent=true} m:addItem{type="back"} @@ -618,8 +660,9 @@ m:addItem{type="stringinput", name="stringinput", action="talk"} m:exec() #endif -bool CLuaInstance::tableLookupString(lua_State *L, const char *what, std::string &value) +bool CLuaInstance::tableLookup(lua_State *L, const char *what, std::string &value) { +fprintf(stderr, "tableLookupString\n"); bool res = false; lua_pushstring(L, what); lua_gettable(L, -2); @@ -627,11 +670,13 @@ bool CLuaInstance::tableLookupString(lua_State *L, const char *what, std::string if (res) value = lua_tostring(L, -1); lua_pop(L, 1); +fprintf(stderr, "res=%d\n", res); return res; } -bool CLuaInstance::tableLookupInt(lua_State *L, const char *what, int &value) +bool CLuaInstance::tableLookup(lua_State *L, const char *what, int &value) { +fprintf(stderr, "tableLookupInt\n"); bool res = false; lua_pushstring(L, what); lua_gettable(L, -2); @@ -639,6 +684,7 @@ bool CLuaInstance::tableLookupInt(lua_State *L, const char *what, int &value) if (res) value = (int) lua_tonumber(L, -1); lua_pop(L, 1); +fprintf(stderr, "res=%d\n", res); return res; } @@ -702,7 +748,6 @@ CLuaMenueForwarder::~CLuaMenueForwarder() int CLuaMenueForwarder::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) { - CFileBrowser fileBrowser; if (!luaAction.empty()){ lua_pushglobaltable(L); lua_getfield(L, -1, luaAction.c_str()); @@ -717,29 +762,27 @@ int CLuaMenueForwarder::exec(CMenuTarget* /*parent*/, const std::string & /*acti } return menu_return::RETURN_REPAINT; } -CLuaMenueFilebrowser::CLuaMenueFilebrowser(lua_State *_L, std::string _luaAction, char *_value, bool _dirMode) + +CLuaMenueFilebrowser::CLuaMenueFilebrowser(lua_State *_L, std::string _luaAction, char *_value, bool _dirMode) : CLuaMenueForwarder(_L, _luaAction) { - L = _L; - luaAction = _luaAction; value = _value; dirMode = _dirMode; } -CLuaMenueFilebrowser::~CLuaMenueFilebrowser() -{ -} - -int CLuaMenueFilebrowser::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) +int CLuaMenueFilebrowser::exec(CMenuTarget* /*parent*/, const std::string& /*actionKey*/) { CFileBrowser fileBrowser; fileBrowser.Dir_Mode = dirMode; -#if 0 // NOTYET + CFileFilter fileFilter; - fileFilter.addFilter("..."); - fileBrowser.Filter = &fileFilter; -#endif + for (std::vector::iterator it = filter.begin(); it != filter.end(); ++it) + fileFilter.addFilter(*it); + if (!filter.empty()) + fileBrowser.Filter = &fileFilter; + if (fileBrowser.exec(value) == true) strcpy(value, fileBrowser.getSelectedFile()->Name.c_str()); + if (!luaAction.empty()){ lua_pushglobaltable(L); lua_getfield(L, -1, luaAction.c_str()); @@ -752,10 +795,8 @@ int CLuaMenueFilebrowser::exec(CMenuTarget* /*parent*/, const std::string & /*ac return menu_return::RETURN_REPAINT; } -CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms) +CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms) : CLuaMenueForwarder(_L, _luaAction) { - L = _L; - luaAction = _luaAction; name = _name; value = _value; size = _size; @@ -765,10 +806,6 @@ CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction sms = _sms; } -CLuaMenueStringinput::~CLuaMenueStringinput() -{ -} - int CLuaMenueStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) { CStringInput *i; @@ -782,20 +819,28 @@ int CLuaMenueStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*ac i->luaState = L; i->exec(NULL, ""); delete i; + if (!luaAction.empty()){ + lua_pushglobaltable(L); + lua_getfield(L, -1, luaAction.c_str()); + lua_remove(L, -2); + lua_pushstring(L, value); + lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0); + //double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0; + lua_pop(L, 1); + } return menu_return::RETURN_REPAINT; } - int CLuaInstance::MenueNew(lua_State *L) { CMenuWidget *m; if (lua_istable(L, 1)) { std::string name, icon; - tableLookupString(L, "name", name) || tableLookupString(L, "title", name); - tableLookupString(L, "icon", icon); + tableLookup(L, "name", name) || tableLookup(L, "title", name); + tableLookup(L, "icon", icon); int mwidth; - if(tableLookupInt(L, "mwidth", mwidth)) + if(tableLookup(L, "mwidth", mwidth)) m = new CMenuWidget(name.c_str(), icon.c_str(), mwidth); else m = new CMenuWidget(name.c_str(), icon.c_str()); @@ -813,14 +858,16 @@ int CLuaInstance::MenueNew(lua_State *L) int CLuaInstance::MenueDelete(lua_State *L) { CLuaMenue *m = MenueCheck(L, 1); + if (!m) + return 0; while(!m->targets.empty()) { - delete m->targets.front(); - m->targets.pop_front(); + delete m->targets.back(); + m->targets.pop_back(); } while(!m->tofree.empty()) { - free(m->tofree.front()); - m->tofree.pop_front(); + free(m->tofree.back()); + m->tofree.pop_back(); } delete m; @@ -830,44 +877,48 @@ int CLuaInstance::MenueDelete(lua_State *L) int CLuaInstance::MenueAddItem(lua_State *L) { CLuaMenue *m = MenueCheck(L, 1); + if (!m) + return 0; lua_assert(lua_istable(L, 2)); CLuaMenueItem i; - m->items.push_front(i); - std::list::iterator it = m->items.begin(); + m->items.push_back(i); + CLuaMenueItem *b = &m->items.back(); - tableLookupString(L, "name", (*it).name); - std::string icon; tableLookupString(L, "icon", icon); - std::string type; tableLookupString(L, "type", type); + tableLookup(L, "name", b->name); + std::string icon; tableLookup(L, "icon", icon); + std::string type; tableLookup(L, "type", type); if (type == "back") { m->m->addItem(GenericMenuBack); } else if (type == "separator") { - if (!(*it).name.empty()) - m->m->addItem(new CNonLocalizedMenuSeparator((*it).name.c_str(), NONEXISTANT_LOCALE)); + if (!b->name.empty()) + m->m->addItem(new CNonLocalizedMenuSeparator(b->name.c_str(), NONEXISTANT_LOCALE)); else m->m->addItem(GenericMenuSeparatorLine); } else { - std::string right_icon; tableLookupString(L, "right_icon", right_icon); - std::string action; tableLookupString(L, "action", action); - std::string value; tableLookupString(L, "value", value); - int directkey = CRCInput::RC_nokey; tableLookupInt(L, "directkey", directkey); - int pulldown = false; tableLookupInt(L, "pulldown", pulldown); - std::string tmp = "true"; - tableLookupString(L, "enabled", tmp) || tableLookupString(L, "active", tmp); + std::string right_icon; tableLookup(L, "right_icon", right_icon); + std::string action; tableLookup(L, "action", action); + std::string value; tableLookup(L, "value", value); + std::string tmp; + int directkey = CRCInput::RC_nokey; + tableLookup(L, "directkey", directkey); + int pulldown = false; tableLookup(L, "pulldown", pulldown); + tmp = "true"; + tableLookup(L, "enabled", tmp) || tableLookup(L, "active", tmp); bool enabled = (tmp == "true" || tmp == "1" || tmp == "yes"); - tableLookupString(L, "range", tmp); + tableLookup(L, "range", tmp); int range_from = 0, range_to = 99; sscanf(tmp.c_str(), "%d,%d", &range_from, &range_to); if (type == "forwarder") { - strncpy((*it).s, value.c_str(), sizeof((*it).s)); + strncpy(b->s, value.c_str(), sizeof(b->s)); CLuaMenueForwarder *forwarder = new CLuaMenueForwarder(L, action); CMenuItem *mi = new CMenuForwarderNonLocalized( - (*it).name.c_str(), enabled, (*it).s, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + b->name.c_str(), enabled, b->s, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); - m->targets.push_front(forwarder); + m->targets.push_back(forwarder); } else if (type == "chooser") { int options_count = 0; lua_pushstring(L, "options"); @@ -879,10 +930,10 @@ int CLuaInstance::MenueAddItem(lua_State *L) lua_pop(L, 1); CMenuOptionChooser::keyval_ext *kext = (CMenuOptionChooser::keyval_ext *)calloc(options_count, sizeof(CMenuOptionChooser::keyval_ext)); - m->tofree.push_front(kext); + m->tofree.push_back(kext); lua_pushstring(L, "options"); lua_gettable(L, -2); - (*it).i = 0; + b->i = 0; int j = 0; for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { lua_pushvalue(L, -2); @@ -891,56 +942,64 @@ int CLuaInstance::MenueAddItem(lua_State *L) kext[j].key = atoi(key); kext[j].value = NONEXISTANT_LOCALE; kext[j].valname = strdup(val); - m->tofree.push_front((void *)kext[j].valname); + m->tofree.push_back((void *)kext[j].valname); if (!strcmp(value.c_str(), kext[j].valname)) - (*it).i = j; + b->i = kext[j].key; j++; } lua_pop(L, 1); - CMenuItem *mi = new CMenuOptionChooser((*it).name.c_str(), &(*it).i, kext, options_count, enabled, m->observ, directkey, icon.c_str(), pulldown); + CMenuItem *mi = new CMenuOptionChooser(b->name.c_str(), &b->i, kext, options_count, enabled, m->observ, directkey, icon.c_str(), pulldown); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); } else if (type == "numeric") { - (*it).i = range_from; - sscanf(value.c_str(), "%d", &(*it).i); - CMenuItem *mi = new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &(*it).i, enabled, range_from, range_to, m->observ, - 0, 0, NONEXISTANT_LOCALE, (*it).name.c_str(), pulldown); + b->i = range_from; + sscanf(value.c_str(), "%d", &b->i); + CMenuItem *mi = new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &b->i, enabled, range_from, range_to, m->observ, + 0, 0, NONEXISTANT_LOCALE, b->name.c_str(), pulldown); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); } else if (type == "string") { - strncpy((*it).s, value.c_str(), sizeof((*it).s)); - CMenuItem *mi = new CMenuOptionStringChooser((*it).name.c_str(), (*it).s, enabled, m->observ, directkey, icon.c_str(), pulldown); + strncpy(b->s, value.c_str(), sizeof(b->s)); + CMenuItem *mi = new CMenuOptionStringChooser(b->name.c_str(), b->s, enabled, m->observ, directkey, icon.c_str(), pulldown); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); } else if (type == "stringinput") { - strncpy((*it).s, value.c_str(), sizeof((*it).s)); + strncpy(b->s, value.c_str(), sizeof(b->s)); std::string valid_chars = "abcdefghijklmnopqrstuvwxyz0123456789!\"§$%&/()=?-. "; - tableLookupString(L, "valid_chars", valid_chars); - int sms = 0; - tableLookupInt(L, "sms", sms); - int size = 30; - tableLookupInt(L, "size", size); - CLuaMenueStringinput *stringinput = new CLuaMenueStringinput(L, action, (*it).name.c_str(), (*it).s, size, valid_chars, m->observ, icon.c_str(), sms); + tableLookup(L, "valid_chars", valid_chars); + int sms = 0; tableLookup(L, "sms", sms); + int size = 30; tableLookup(L, "size", size); + CLuaMenueStringinput *stringinput = new CLuaMenueStringinput(L, action, b->name.c_str(), b->s, size, valid_chars, m->observ, icon.c_str(), sms); CMenuItem *mi = new CMenuForwarderNonLocalized( - (*it).name.c_str(), enabled, (*it).s, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + b->name.c_str(), enabled, b->s, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); - m->targets.push_front(stringinput); + m->targets.push_back(stringinput); } else if (type == "filebrowser") { - strncpy((*it).s, value.c_str(), sizeof((*it).s)); - int dirMode = 0; tableLookupInt(L, "dir_mode", dirMode); - CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, (*it).s, dirMode); + strncpy(b->s, value.c_str(), sizeof(b->s)); + int dirMode = 0; tableLookup(L, "dir_mode", dirMode); + CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, b->s, dirMode); + + lua_pushstring(L, "filter"); + lua_gettable(L, -2); + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + filebrowser->addFilter(val); + } + lua_pop(L, 1); + CMenuItem *mi = new CMenuForwarderNonLocalized( - (*it).name.c_str(), enabled, (*it).s, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + b->name.c_str(), enabled, b->s, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); mi->luaAction = action; mi->luaState = L; m->m->addItem(mi); - m->targets.push_front(filebrowser); + m->targets.push_back(filebrowser); } } return 1; @@ -949,6 +1008,8 @@ int CLuaInstance::MenueAddItem(lua_State *L) int CLuaInstance::MenueHide(lua_State *L) { CLuaMenue *m = MenueCheck(L, 1); + if (!m) + return 0; m->m->hide(); return 0; } @@ -956,6 +1017,8 @@ int CLuaInstance::MenueHide(lua_State *L) int CLuaInstance::MenueExec(lua_State *L) { CLuaMenue *m = MenueCheck(L, 1); + if (!m) + return 0; m->m->exec(NULL, ""); m->m->hide(); return 0; @@ -1002,11 +1065,11 @@ int CLuaInstance::HintboxNew(lua_State *L) lua_assert(lua_istable(L,1)); std::string name, text, icon = std::string(NEUTRINO_ICON_INFO); - tableLookupString(L, "name", name) || tableLookupString(L, "title", name) || tableLookupString(L, "caption", name); - tableLookupString(L, "text", text); - tableLookupString(L, "icon", icon); + tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); + tableLookup(L, "text", text); + tableLookup(L, "icon", icon); int width = 450; - tableLookupInt(L, "width", width); + tableLookup(L, "width", width); CLuaHintbox **udata = (CLuaHintbox **) lua_newuserdata(L, sizeof(CLuaHintbox *)); *udata = new CLuaHintbox(); @@ -1027,6 +1090,8 @@ int CLuaInstance::HintboxDelete(lua_State *L) int CLuaInstance::HintboxPaint(lua_State *L) { CLuaHintbox *m = HintboxCheck(L, 1); + if (!m) + return 0; m->b->paint(); return 0; } @@ -1041,6 +1106,8 @@ int CLuaInstance::HintboxHide(lua_State *L) int CLuaInstance::HintboxExec(lua_State *L) { CLuaHintbox *m = HintboxCheck(L, 1); + if (!m) + return 0; int timeout = -1; if (lua_isnumber(L, -1)) timeout = (int) lua_tonumber(L, -1); @@ -1120,50 +1187,78 @@ int CLuaInstance::MessageboxExec(lua_State *L) lua_assert(lua_istable(L,1)); std::string name, text, icon = std::string(NEUTRINO_ICON_INFO); - tableLookupString(L, "name", name) || tableLookupString(L, "title", name) || tableLookupString(L, "caption", name); - tableLookupString(L, "text", text); - tableLookupString(L, "icon", icon); + tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); + tableLookup(L, "text", text); + tableLookup(L, "icon", icon); int timeout = -1, width = 450, return_default_on_timeout = 0, show_buttons = 0, default_button = 0; - tableLookupInt(L, "timeout", timeout); - tableLookupInt(L, "width", width); - tableLookupInt(L, "return_default_on_timeout", return_default_on_timeout); + tableLookup(L, "timeout", timeout); + tableLookup(L, "width", width); + tableLookup(L, "return_default_on_timeout", return_default_on_timeout); std::string tmp; - if (tableLookupString(L, "align", tmp)) { - if (tmp == "center1") show_buttons |= CMessageBox::mbBtnAlignCenter1; - else if (tmp == "center2") show_buttons |= CMessageBox::mbBtnAlignCenter2; - else if (tmp == "left") show_buttons |= CMessageBox::mbBtnAlignLeft; - else if (tmp == "right") show_buttons |= CMessageBox::mbBtnAlignRight; + if (tableLookup(L, "align", tmp)) { + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + table_key mb[] = { + { "center1", CMessageBox::mbBtnAlignCenter1 }, + { "center2", CMessageBox::mbBtnAlignCenter1 }, + { "left", CMessageBox::mbBtnAlignLeft }, + { "right", CMessageBox::mbBtnAlignRight }, + { NULL, 0 } + }; + for (int i = 0; mb[i].name; i++) + if (!strcmp(mb[i].name, val)) { + show_buttons |= mb[i].code; + break; + } } lua_pushstring(L, "buttons"); lua_gettable(L, -2); for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { lua_pushvalue(L, -2); const char *val = lua_tostring(L, -2); - if (!strcmp(val, "yes")) show_buttons |= CMessageBox::mbYes; - else if (!strcmp(val, "no")) show_buttons |= CMessageBox::mbNo; - else if (!strcmp(val, "cancel")) show_buttons |= CMessageBox::mbCancel; - else if (!strcmp(val, "all")) show_buttons |= CMessageBox::mbAll; - else if (!strcmp(val, "back")) show_buttons |= CMessageBox::mbBack; - else if (!strcmp(val, "ok")) show_buttons |= CMessageBox::mbOk; + table_key mb[] = { + { "yes", CMessageBox::mbYes }, + { "no", CMessageBox::mbNo }, + { "cancel", CMessageBox::mbCancel }, + { "all", CMessageBox::mbAll }, + { "back", CMessageBox::mbBack }, + { "ok", CMessageBox::mbOk }, + { NULL, 0 } + }; + for (int i = 0; mb[i].name; i++) + if (!strcmp(mb[i].name, val)) { + show_buttons |= mb[i].code; + break; + } } lua_pop(L, 1); - if (tableLookupString(L, "default", tmp)) { - if (tmp == "yes") default_button = CMessageBox::mbrYes; - else if (tmp == "no") default_button = CMessageBox::mbrNo; - else if (tmp == "cancel") default_button = CMessageBox::mbrCancel; - else if (tmp == "back") default_button = CMessageBox::mbrBack; - else if (tmp == "ok") default_button = CMessageBox::mbrOk; - } + table_key mbr[] = { + { "yes", CMessageBox::mbrYes }, + { "no", CMessageBox::mbrNo }, + { "cancel", CMessageBox::mbrCancel }, + { "back", CMessageBox::mbrBack }, + { "ok", CMessageBox::mbrOk }, + { NULL, 0 } + }; + if (tableLookup(L, "default", tmp)) + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + for (int i = 0; mbr[i].name; i++) + if (!strcmp(mbr[i].name, val)) { + default_button = mbr[i].code; + break; + } int res = ShowMsgUTF(name.c_str(), text.c_str(), (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); - if (res == CMessageBox::mbrYes) tmp = "yes"; - else if (res == CMessageBox::mbrNo) tmp = "no"; - else if (res == CMessageBox::mbrBack) tmp = "back"; - else if (res == CMessageBox::mbrOk) tmp = "ok"; - else tmp = "cancel"; + tmp = "cancel"; + for (int i = 0; mbr[i].name; i++) + if (res == mbr[i].code) { + tmp == mbr[i].name; + break; + } lua_pushstring(L, tmp.c_str()); return 1; diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 2e5a16d85..0005824e2 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -41,7 +41,7 @@ struct CLuaData #ifdef MARTII struct CLuaMenueItem { - union + union //value { int i; char s[255]; @@ -69,44 +69,39 @@ class CLuaMenue class CLuaMenueForwarder : public CMenuTarget { - private: + public: lua_State *L; std::string luaAction; - public: CLuaMenueForwarder(lua_State *L, std::string _luaAction); ~CLuaMenueForwarder(); int exec(CMenuTarget* parent, const std::string & actionKey); }; -class CLuaMenueFilebrowser : public CMenuTarget +class CLuaMenueFilebrowser : public CLuaMenueForwarder { private: - lua_State *L; - std::string luaAction; char *value; bool dirMode; + std::vector filter; public: - CLuaMenueFilebrowser(lua_State *L, std::string _luaAction, char *_value, bool _dirMode); - ~CLuaMenueFilebrowser(); + CLuaMenueFilebrowser(lua_State *_L, std::string _luaAction, char *_value, bool _dirMode); int exec(CMenuTarget* parent, const std::string & actionKey); + void addFilter(std::string s) { filter.push_back(s); }; }; -class CLuaMenueStringinput : public CMenuTarget +class CLuaMenueStringinput : public CLuaMenueForwarder { private: - lua_State *L; - std::string luaAction; - const char *name; char *value; - int size; std::string valid_chars; - CChangeObserver *observ; + const char *name; const char *icon; bool sms; + int size; + CChangeObserver *observ; public: CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms); - ~CLuaMenueStringinput(); - int exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/); + int exec(CMenuTarget* parent, const std::string & actionKey); }; class CLuaHintbox @@ -154,6 +149,9 @@ private: static int GetInput(lua_State *L); static int GCWindow(lua_State *L); #ifdef MARTII + static int Blit(lua_State *L); + static int GetLanguage(lua_State *L); + void MenueRegister(lua_State *L); static int MenueNew(lua_State *L); static int MenueDelete(lua_State *L); @@ -174,8 +172,8 @@ private: static int MessageboxExec(lua_State *L); static CLuaMessagebox *MessageboxCheck(lua_State *L, int n); - static bool tableLookupString(lua_State*, const char*, std::string&); - static bool tableLookupInt(lua_State*, const char*, int&); + static bool tableLookup(lua_State*, const char*, std::string&); + static bool tableLookup(lua_State*, const char*, int&); #endif }; From 8d162845c2b71f5bb10eae8fe3ea6a2466f21636 Mon Sep 17 00:00:00 2001 From: martii Date: Tue, 7 May 2013 20:56:57 +0200 Subject: [PATCH 31/54] lua: remove debugging output Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a568f3004e2c1f543e453b40ae753f06cc592f8b Author: martii Date: 2013-05-07 (Tue, 07 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index f139c7d23..d719d1c09 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -662,7 +662,6 @@ m:exec() bool CLuaInstance::tableLookup(lua_State *L, const char *what, std::string &value) { -fprintf(stderr, "tableLookupString\n"); bool res = false; lua_pushstring(L, what); lua_gettable(L, -2); @@ -670,13 +669,11 @@ fprintf(stderr, "tableLookupString\n"); if (res) value = lua_tostring(L, -1); lua_pop(L, 1); -fprintf(stderr, "res=%d\n", res); return res; } bool CLuaInstance::tableLookup(lua_State *L, const char *what, int &value) { -fprintf(stderr, "tableLookupInt\n"); bool res = false; lua_pushstring(L, what); lua_gettable(L, -2); @@ -684,7 +681,6 @@ fprintf(stderr, "tableLookupInt\n"); if (res) value = (int) lua_tonumber(L, -1); lua_pop(L, 1); -fprintf(stderr, "res=%d\n", res); return res; } From 5443274f6c7bf833deaf5ec51fc61aa1dd06835d Mon Sep 17 00:00:00 2001 From: martii Date: Wed, 8 May 2013 18:25:30 +0200 Subject: [PATCH 32/54] lua related fixes Signed-off-by: M. Liebmann Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c6912180ee89de41cab75ef945d0a9d90e5f62ba Author: martii Date: 2013-05-08 (Wed, 08 May 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 60 +++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index d719d1c09..f9d93571d 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -610,9 +610,9 @@ int CLuaInstance::Blit(lua_State *L) { CLuaData *W = CheckData(L, 1); if (W && W->fbwin) { - if (lua_isnumber(L, 2)) { + if (lua_isnumber(L, 2)) W->fbwin->mayBlit = (int)lua_tonumber(L, 2); // enable/disable automatic blit - } else + else W->fbwin->blit(); } return 0; @@ -887,17 +887,17 @@ int CLuaInstance::MenueAddItem(lua_State *L) if (type == "back") { m->m->addItem(GenericMenuBack); } else if (type == "separator") { - if (!b->name.empty()) + if (!b->name.empty()) { m->m->addItem(new CNonLocalizedMenuSeparator(b->name.c_str(), NONEXISTANT_LOCALE)); - else + } else { m->m->addItem(GenericMenuSeparatorLine); + } } else { std::string right_icon; tableLookup(L, "right_icon", right_icon); std::string action; tableLookup(L, "action", action); std::string value; tableLookup(L, "value", value); std::string tmp; - int directkey = CRCInput::RC_nokey; - tableLookup(L, "directkey", directkey); + int directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); int pulldown = false; tableLookup(L, "pulldown", pulldown); tmp = "true"; tableLookup(L, "enabled", tmp) || tableLookup(L, "active", tmp); @@ -919,10 +919,11 @@ int CLuaInstance::MenueAddItem(lua_State *L) int options_count = 0; lua_pushstring(L, "options"); lua_gettable(L, -2); - for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { - lua_pushvalue(L, -2); - options_count++; - } + if (lua_istable(L, -1)) + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + options_count++; + } lua_pop(L, 1); CMenuOptionChooser::keyval_ext *kext = (CMenuOptionChooser::keyval_ext *)calloc(options_count, sizeof(CMenuOptionChooser::keyval_ext)); @@ -931,18 +932,19 @@ int CLuaInstance::MenueAddItem(lua_State *L) lua_gettable(L, -2); b->i = 0; int j = 0; - for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { - lua_pushvalue(L, -2); - const char *key = lua_tostring(L, -1); - const char *val = lua_tostring(L, -2); - kext[j].key = atoi(key); - kext[j].value = NONEXISTANT_LOCALE; - kext[j].valname = strdup(val); - m->tofree.push_back((void *)kext[j].valname); - if (!strcmp(value.c_str(), kext[j].valname)) - b->i = kext[j].key; - j++; - } + if (lua_istable(L, -1)) + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + const char *key = lua_tostring(L, -1); + const char *val = lua_tostring(L, -2); + kext[j].key = atoi(key); + kext[j].value = NONEXISTANT_LOCALE; + kext[j].valname = strdup(val); + m->tofree.push_back((void *)kext[j].valname); + if (!strcmp(value.c_str(), kext[j].valname)) + b->i = kext[j].key; + j++; + } lua_pop(L, 1); CMenuItem *mi = new CMenuOptionChooser(b->name.c_str(), &b->i, kext, options_count, enabled, m->observ, directkey, icon.c_str(), pulldown); mi->luaAction = action; @@ -980,14 +982,14 @@ int CLuaInstance::MenueAddItem(lua_State *L) strncpy(b->s, value.c_str(), sizeof(b->s)); int dirMode = 0; tableLookup(L, "dir_mode", dirMode); CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, b->s, dirMode); - lua_pushstring(L, "filter"); lua_gettable(L, -2); - for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { - lua_pushvalue(L, -2); - const char *val = lua_tostring(L, -2); - filebrowser->addFilter(val); - } + if (lua_istable(L, -1)) + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + filebrowser->addFilter(val); + } lua_pop(L, 1); CMenuItem *mi = new CMenuForwarderNonLocalized( @@ -998,7 +1000,7 @@ int CLuaInstance::MenueAddItem(lua_State *L) m->targets.push_back(filebrowser); } } - return 1; + return 0; } int CLuaInstance::MenueHide(lua_State *L) From efd5dd91e0a338de27f533bff7c03888ca8b514e Mon Sep 17 00:00:00 2001 From: martii Date: Wed, 8 May 2013 21:53:09 +0200 Subject: [PATCH 33/54] lua: msgbox fix Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7b9adbe65b8bbbe54e6d92bc3d5d65acb049ecf9 Author: martii Date: 2013-05-08 (Wed, 08 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index f9d93571d..93ed8de87 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1240,7 +1240,7 @@ int CLuaInstance::MessageboxExec(lua_State *L) { "ok", CMessageBox::mbrOk }, { NULL, 0 } }; - if (tableLookup(L, "default", tmp)) + if (tableLookup(L, "default", tmp)) { lua_pushvalue(L, -2); const char *val = lua_tostring(L, -2); for (int i = 0; mbr[i].name; i++) @@ -1248,6 +1248,7 @@ int CLuaInstance::MessageboxExec(lua_State *L) default_button = mbr[i].code; break; } + } int res = ShowMsgUTF(name.c_str(), text.c_str(), (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); From 0fce4ea83a7427d26cad480aed5b85c6a826c529 Mon Sep 17 00:00:00 2001 From: martii Date: Wed, 8 May 2013 21:58:10 +0200 Subject: [PATCH 34/54] lua: msgbox fix Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/82be6f8e666ad8f025fc6ebc784a0768869d5048 Author: martii Date: 2013-05-08 (Wed, 08 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 93ed8de87..1d232a6d3 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1255,7 +1255,7 @@ int CLuaInstance::MessageboxExec(lua_State *L) tmp = "cancel"; for (int i = 0; mbr[i].name; i++) if (res == mbr[i].code) { - tmp == mbr[i].name; + tmp = mbr[i].name; break; } lua_pushstring(L, tmp.c_str()); From 52ef75cd9656b43bd0a9024fdcd0fa52f7af1026 Mon Sep 17 00:00:00 2001 From: martii Date: Fri, 10 May 2013 15:25:57 +0200 Subject: [PATCH 35/54] lua: update menue callback api to include an id parameter Signed-off-by: M. Liebmann Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/d2e5a703c3ad87b7004b4becf56cb52eaf38e69b Author: martii Date: 2013-05-10 (Fri, 10 May 2013) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 57 +++++++++++++++++++---------------------- src/gui/luainstance.h | 9 ++++--- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 1d232a6d3..d04f9e5c5 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -631,9 +631,9 @@ local m = menue.new{name="mytitle", icon="myicon", hide_parent=true} m:addItem{type="back"} m:addItem{type="separator"} -function talk(a) +function talk(a, b) print(">talk") - print(a) + print(a .. " => " b) print("luaAction = luaAction; - i->luaState = L; i->exec(NULL, ""); delete i; if (!luaAction.empty()){ lua_pushglobaltable(L); lua_getfield(L, -1, luaAction.c_str()); lua_remove(L, -2); + lua_pushstring(L, luaId.c_str()); lua_pushstring(L, value); - lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0); + lua_pcall(L, 2 /* two args */, 1 /* one result */, 0); //double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0; - lua_pop(L, 1); + lua_pop(L, 2); } return menu_return::RETURN_REPAINT; } @@ -896,6 +897,7 @@ int CLuaInstance::MenueAddItem(lua_State *L) std::string right_icon; tableLookup(L, "right_icon", right_icon); std::string action; tableLookup(L, "action", action); std::string value; tableLookup(L, "value", value); + std::string id; tableLookup(L, "id", id); std::string tmp; int directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); int pulldown = false; tableLookup(L, "pulldown", pulldown); @@ -908,11 +910,10 @@ int CLuaInstance::MenueAddItem(lua_State *L) if (type == "forwarder") { strncpy(b->s, value.c_str(), sizeof(b->s)); - CLuaMenueForwarder *forwarder = new CLuaMenueForwarder(L, action); + CLuaMenueForwarder *forwarder = new CLuaMenueForwarder(L, action, id); CMenuItem *mi = new CMenuForwarderNonLocalized( b->name.c_str(), enabled, b->s, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); - mi->luaAction = action; - mi->luaState = L; + mi->setLua(L, action, id); m->m->addItem(mi); m->targets.push_back(forwarder); } else if (type == "chooser") { @@ -947,41 +948,36 @@ int CLuaInstance::MenueAddItem(lua_State *L) } lua_pop(L, 1); CMenuItem *mi = new CMenuOptionChooser(b->name.c_str(), &b->i, kext, options_count, enabled, m->observ, directkey, icon.c_str(), pulldown); - mi->luaAction = action; - mi->luaState = L; + mi->setLua(L, action, id); m->m->addItem(mi); } else if (type == "numeric") { b->i = range_from; sscanf(value.c_str(), "%d", &b->i); CMenuItem *mi = new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &b->i, enabled, range_from, range_to, m->observ, 0, 0, NONEXISTANT_LOCALE, b->name.c_str(), pulldown); - mi->luaAction = action; - mi->luaState = L; + mi->setLua(L, action, id); m->m->addItem(mi); } else if (type == "string") { strncpy(b->s, value.c_str(), sizeof(b->s)); CMenuItem *mi = new CMenuOptionStringChooser(b->name.c_str(), b->s, enabled, m->observ, directkey, icon.c_str(), pulldown); - mi->luaAction = action; - mi->luaState = L; + mi->setLua(L, action, id); m->m->addItem(mi); - } else if (type == "stringinput") { strncpy(b->s, value.c_str(), sizeof(b->s)); std::string valid_chars = "abcdefghijklmnopqrstuvwxyz0123456789!\"§$%&/()=?-. "; tableLookup(L, "valid_chars", valid_chars); int sms = 0; tableLookup(L, "sms", sms); int size = 30; tableLookup(L, "size", size); - CLuaMenueStringinput *stringinput = new CLuaMenueStringinput(L, action, b->name.c_str(), b->s, size, valid_chars, m->observ, icon.c_str(), sms); + CLuaMenueStringinput *stringinput = new CLuaMenueStringinput(L, action, id, b->name.c_str(), b->s, size, valid_chars, m->observ, icon.c_str(), sms); CMenuItem *mi = new CMenuForwarderNonLocalized( b->name.c_str(), enabled, b->s, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); - mi->luaAction = action; - mi->luaState = L; + mi->setLua(L, action, id); m->m->addItem(mi); m->targets.push_back(stringinput); } else if (type == "filebrowser") { strncpy(b->s, value.c_str(), sizeof(b->s)); int dirMode = 0; tableLookup(L, "dir_mode", dirMode); - CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, b->s, dirMode); + CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, id, b->s, dirMode); lua_pushstring(L, "filter"); lua_gettable(L, -2); if (lua_istable(L, -1)) @@ -994,8 +990,7 @@ int CLuaInstance::MenueAddItem(lua_State *L) CMenuItem *mi = new CMenuForwarderNonLocalized( b->name.c_str(), enabled, b->s, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); - mi->luaAction = action; - mi->luaState = L; + mi->setLua(L, action, id); m->m->addItem(mi); m->targets.push_back(filebrowser); } diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 0005824e2..daf2428ea 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -52,7 +52,7 @@ struct CLuaMenueItem class CLuaMenueChangeObserver : public CChangeObserver { public: - bool changeNotify(lua_State *, const std::string &, void *); + bool changeNotify(lua_State *, const std::string &, const std::string &, void *); }; class CLuaMenue @@ -72,7 +72,8 @@ class CLuaMenueForwarder : public CMenuTarget public: lua_State *L; std::string luaAction; - CLuaMenueForwarder(lua_State *L, std::string _luaAction); + std::string luaId; + CLuaMenueForwarder(lua_State *L, std::string _luaAction, std::string _luaId); ~CLuaMenueForwarder(); int exec(CMenuTarget* parent, const std::string & actionKey); }; @@ -84,7 +85,7 @@ class CLuaMenueFilebrowser : public CLuaMenueForwarder bool dirMode; std::vector filter; public: - CLuaMenueFilebrowser(lua_State *_L, std::string _luaAction, char *_value, bool _dirMode); + CLuaMenueFilebrowser(lua_State *_L, std::string _luaAction, std::string _luaId, char *_value, bool _dirMode); int exec(CMenuTarget* parent, const std::string & actionKey); void addFilter(std::string s) { filter.push_back(s); }; }; @@ -100,7 +101,7 @@ class CLuaMenueStringinput : public CLuaMenueForwarder int size; CChangeObserver *observ; public: - CLuaMenueStringinput(lua_State *_L, std::string _luaAction, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms); + CLuaMenueStringinput(lua_State *_L, std::string _luaAction, std::string _luaId, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms); int exec(CMenuTarget* parent, const std::string & actionKey); }; From c830035ce532bfd3a4d0e97f7365e89a82dc5064 Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 11 May 2013 11:40:14 +0200 Subject: [PATCH 36/54] lua menues: add directkey forwarder Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1bdd23676ac9fb165063bb0c0258f52fd55b5773 Author: martii Date: 2013-05-11 (Sat, 11 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 30 +++++++++++++++++++++++++----- src/gui/luainstance.h | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index d04f9e5c5..dd7f12a0f 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -702,6 +702,7 @@ void CLuaInstance::MenueRegister(lua_State *L) { luaL_Reg meth[] = { { "new", CLuaInstance::MenueNew }, + { "addKey", CLuaInstance::MenueAddKey }, { "addItem", CLuaInstance::MenueAddItem }, { "exec", CLuaInstance::MenueExec }, { "hide", CLuaInstance::MenueHide }, @@ -746,19 +747,22 @@ CLuaMenueForwarder::~CLuaMenueForwarder() int CLuaMenueForwarder::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) { + int res = menu_return::RETURN_REPAINT; if (!luaAction.empty()){ lua_pushglobaltable(L); lua_getfield(L, -1, luaAction.c_str()); lua_remove(L, -2); - int status = lua_pcall(L, 0 /* no arg */, 1 /* one result */, 0); + lua_pushstring(L, luaId.c_str()); + int status = lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0); if (status) { fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, lua_tostring(L, -1)); ShowMsg2UTF("Lua script error:", lua_tostring(L, -1), CMsgBox::mbrBack, CMsgBox::mbBack); } - //double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0; + if (lua_isnumber(L, -1)) + res = (int) lua_tonumber(L, -1); lua_pop(L, 1); } - return menu_return::RETURN_REPAINT; + return res; } CLuaMenueFilebrowser::CLuaMenueFilebrowser(lua_State *_L, std::string _luaAction, std::string _luaId, char *_value, bool _dirMode) : CLuaMenueForwarder(_L, _luaAction, _luaId) @@ -787,7 +791,6 @@ int CLuaMenueFilebrowser::exec(CMenuTarget* /*parent*/, const std::string& /*act lua_remove(L, -2); lua_pushstring(L, value); lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0); - //double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0; lua_pop(L, 1); } return menu_return::RETURN_REPAINT; @@ -822,7 +825,6 @@ int CLuaMenueStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*ac lua_pushstring(L, luaId.c_str()); lua_pushstring(L, value); lua_pcall(L, 2 /* two args */, 1 /* one result */, 0); - //double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0; lua_pop(L, 2); } return menu_return::RETURN_REPAINT; @@ -871,6 +873,24 @@ int CLuaInstance::MenueDelete(lua_State *L) return 0; } +int CLuaInstance::MenueAddKey(lua_State *L) +{ + CLuaMenue *m = MenueCheck(L, 1); + if (!m) + return 0; + lua_assert(lua_istable(L, 2)); + + std::string action; tableLookup(L, "action", action); + std::string id; tableLookup(L, "id", id); + int directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); + if (action != "" && directkey != (int) CRCInput::RC_nokey) { + CLuaMenueForwarder *forwarder = new CLuaMenueForwarder(L, action, id); + m->m->addKey(directkey, forwarder, action); + m->targets.push_back(forwarder); + } + return 0; +} + int CLuaInstance::MenueAddItem(lua_State *L) { CLuaMenue *m = MenueCheck(L, 1); diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index daf2428ea..301cfc059 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -156,6 +156,7 @@ private: void MenueRegister(lua_State *L); static int MenueNew(lua_State *L); static int MenueDelete(lua_State *L); + static int MenueAddKey(lua_State *L); static int MenueAddItem(lua_State *L); static int MenueHide(lua_State *L); static int MenueExec(lua_State *L); From 19a4f62f2c71dc52744ac5a3c646d00f1af81f29 Mon Sep 17 00:00:00 2001 From: martii Date: Fri, 17 May 2013 13:16:30 +0200 Subject: [PATCH 37/54] lua: pictureviewer support Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/007d700d53966405f9ce74cd04b7c8764e9f0515 Author: martii Date: 2013-05-17 (Fri, 17 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/gui/luainstance.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index dd7f12a0f..db04fefc6 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -28,6 +28,7 @@ #include #ifdef MARTII #include +#include #endif #include @@ -346,6 +347,8 @@ const luaL_Reg CLuaInstance::methods[] = { "GetInput", CLuaInstance::GetInput }, { "FontHeight", CLuaInstance::FontHeight }, #ifdef MARTII + { "GetSize", CLuaInstance::GetSize }, + { "DisplayImage", CLuaInstance::DisplayImage }, { "Blit", CLuaInstance::Blit }, { "GetLanguage", CLuaInstance::GetLanguage }, #endif @@ -513,6 +516,41 @@ int CLuaInstance::PaintIcon(lua_State *L) return 0; } +#ifdef MARTII +extern CPictureViewer * g_PicViewer; + +int CLuaInstance::DisplayImage(lua_State *L) +{ + DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); + int x, y, w, h; + const char *fname; + + fname = luaL_checkstring(L, 2); + x = luaL_checkint(L, 3); + y = luaL_checkint(L, 4); + w = luaL_checkint(L, 5); + h = luaL_checkint(L, 6); + int trans = 0; + if (lua_isnumber(L, 7)) + trans = luaL_checkint(L, 7); + g_PicViewer->DisplayImage(fname, x, y, w, h, trans); + return 0; +} + +int CLuaInstance::GetSize(lua_State *L) +{ + DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); + int w = 0, h = 0; + const char *fname; + + fname = luaL_checkstring(L, 2); + g_PicViewer->getSize(fname, &w, &h); + lua_pushinteger(L, w); + lua_pushinteger(L, h); + return 2; +} +#endif + int CLuaInstance::RenderString(lua_State *L) { int x, y, w, boxh, f, center; diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 301cfc059..d20f20164 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -152,6 +152,8 @@ private: #ifdef MARTII static int Blit(lua_State *L); static int GetLanguage(lua_State *L); + static int GetSize(lua_State *L); + static int DisplayImage(lua_State *L); void MenueRegister(lua_State *L); static int MenueNew(lua_State *L); From 33d8a9aa95a3756479ec17ee8d1dbb4ff7c8aa09 Mon Sep 17 00:00:00 2001 From: martii Date: Wed, 11 Dec 2013 12:07:46 +0100 Subject: [PATCH 38/54] gui/luainstance: rename menue => menu Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/60dbf9194e849dac712fbb5063122ebe24a40c2c Author: martii Date: 2013-12-11 (Wed, 11 Dec 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 101 +++++++++++++++++++++------------------- src/gui/luainstance.h | 50 ++++++++++---------- 2 files changed, 76 insertions(+), 75 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index db04fefc6..ec504bf7c 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -420,11 +420,9 @@ void CLuaInstance::registerFunctions() lua_pop(lua, 1); lua_register(lua, className, NewWindow); -#ifdef MARTII - MenueRegister(lua); + MenuRegister(lua); HintboxRegister(lua); MessageboxRegister(lua); -#endif } CLuaData *CLuaInstance::CheckData(lua_State *L, int narg) @@ -722,7 +720,7 @@ bool CLuaInstance::tableLookup(lua_State *L, const char *what, int &value) return res; } -bool CLuaMenueChangeObserver::changeNotify(lua_State *L, const std::string &luaAction, const std::string &luaId, void *Data) +bool CLuaMenuChangeObserver::changeNotify(lua_State *L, const std::string &luaAction, const std::string &luaId, void *Data) { const char *optionValue = (const char *) Data; lua_pushglobaltable(L); @@ -736,54 +734,61 @@ bool CLuaMenueChangeObserver::changeNotify(lua_State *L, const std::string &luaA return res == menu_return::RETURN_REPAINT || res == menu_return::RETURN_EXIT_REPAINT; } -void CLuaInstance::MenueRegister(lua_State *L) +void CLuaInstance::MenuRegister(lua_State *L) { luaL_Reg meth[] = { - { "new", CLuaInstance::MenueNew }, - { "addKey", CLuaInstance::MenueAddKey }, - { "addItem", CLuaInstance::MenueAddItem }, - { "exec", CLuaInstance::MenueExec }, - { "hide", CLuaInstance::MenueHide }, - { "__gc", CLuaInstance::MenueDelete }, + { "new", CLuaInstance::MenuNew }, + { "addKey", CLuaInstance::MenuAddKey }, + { "addItem", CLuaInstance::MenuAddItem }, + { "exec", CLuaInstance::MenuExec }, + { "hide", CLuaInstance::MenuHide }, + { "__gc", CLuaInstance::MenuDelete }, { NULL, NULL } }; - luaL_newmetatable(L, "menue"); + luaL_newmetatable(L, "menu"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "menu"); + + // keep misspelled "menue" for backwards-compatibility + luaL_newmetatable(L, "menu"); luaL_setfuncs(L, meth, 0); lua_pushvalue(L, -1); lua_setfield(L, -1, "__index"); lua_setglobal(L, "menue"); } -CLuaMenue *CLuaInstance::MenueCheck(lua_State *L, int n) +CLuaMenu *CLuaInstance::MenuCheck(lua_State *L, int n) { - return *(CLuaMenue **) luaL_checkudata(L, n, "menue"); + return *(CLuaMenu **) luaL_checkudata(L, n, "menu"); } -CLuaMenue::CLuaMenue() +CLuaMenu::CLuaMenu() { m = NULL; - observ = new CLuaMenueChangeObserver(); + observ = new CLuaMenuChangeObserver(); } -CLuaMenue::~CLuaMenue() +CLuaMenu::~CLuaMenu() { delete m; delete observ; } -CLuaMenueForwarder::CLuaMenueForwarder(lua_State *_L, std::string _luaAction, std::string _luaId) +CLuaMenuForwarder::CLuaMenuForwarder(lua_State *_L, std::string _luaAction, std::string _luaId) { L = _L; luaAction = _luaAction; luaId = _luaId; } -CLuaMenueForwarder::~CLuaMenueForwarder() +CLuaMenuForwarder::~CLuaMenuForwarder() { } -int CLuaMenueForwarder::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) +int CLuaMenuForwarder::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) { int res = menu_return::RETURN_REPAINT; if (!luaAction.empty()){ @@ -803,13 +808,13 @@ int CLuaMenueForwarder::exec(CMenuTarget* /*parent*/, const std::string & /*acti return res; } -CLuaMenueFilebrowser::CLuaMenueFilebrowser(lua_State *_L, std::string _luaAction, std::string _luaId, char *_value, bool _dirMode) : CLuaMenueForwarder(_L, _luaAction, _luaId) +CLuaMenuFilebrowser::CLuaMenuFilebrowser(lua_State *_L, std::string _luaAction, std::string _luaId, std::string *_value, bool _dirMode) : CLuaMenuForwarder(_L, _luaAction, _luaId) { value = _value; dirMode = _dirMode; } -int CLuaMenueFilebrowser::exec(CMenuTarget* /*parent*/, const std::string& /*actionKey*/) +int CLuaMenuFilebrowser::exec(CMenuTarget* /*parent*/, const std::string& /*actionKey*/) { CFileBrowser fileBrowser; fileBrowser.Dir_Mode = dirMode; @@ -834,7 +839,7 @@ int CLuaMenueFilebrowser::exec(CMenuTarget* /*parent*/, const std::string& /*act return menu_return::RETURN_REPAINT; } -CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction, std::string _luaId, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms) : CLuaMenueForwarder(_L, _luaAction, _luaId) +CLuaMenuStringinput::CLuaMenuStringinput(lua_State *_L, std::string _luaAction, std::string _luaId, const char *_name, std::string *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms) : CLuaMenuForwarder(_L, _luaAction, _luaId) { name = _name; value = _value; @@ -845,7 +850,7 @@ CLuaMenueStringinput::CLuaMenueStringinput(lua_State *_L, std::string _luaAction sms = _sms; } -int CLuaMenueStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) +int CLuaMenuStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) { CStringInput *i; if (sms) @@ -868,7 +873,7 @@ int CLuaMenueStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*ac return menu_return::RETURN_REPAINT; } -int CLuaInstance::MenueNew(lua_State *L) +int CLuaInstance::MenuNew(lua_State *L) { CMenuWidget *m; @@ -884,17 +889,17 @@ int CLuaInstance::MenueNew(lua_State *L) } else m = new CMenuWidget(); - CLuaMenue **udata = (CLuaMenue **) lua_newuserdata(L, sizeof(CLuaMenue *)); - *udata = new CLuaMenue(); + CLuaMenu **udata = (CLuaMenu **) lua_newuserdata(L, sizeof(CLuaMenu *)); + *udata = new CLuaMenu(); (*udata)->m = m; - luaL_getmetatable(L, "menue"); + luaL_getmetatable(L, "menu"); lua_setmetatable(L, -2); return 1; } -int CLuaInstance::MenueDelete(lua_State *L) +int CLuaInstance::MenuDelete(lua_State *L) { - CLuaMenue *m = MenueCheck(L, 1); + CLuaMenu *m = MenuCheck(L, 1); if (!m) return 0; @@ -911,9 +916,9 @@ int CLuaInstance::MenueDelete(lua_State *L) return 0; } -int CLuaInstance::MenueAddKey(lua_State *L) +int CLuaInstance::MenuAddKey(lua_State *L) { - CLuaMenue *m = MenueCheck(L, 1); + CLuaMenu *m = MenuCheck(L, 1); if (!m) return 0; lua_assert(lua_istable(L, 2)); @@ -922,23 +927,23 @@ int CLuaInstance::MenueAddKey(lua_State *L) std::string id; tableLookup(L, "id", id); int directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); if (action != "" && directkey != (int) CRCInput::RC_nokey) { - CLuaMenueForwarder *forwarder = new CLuaMenueForwarder(L, action, id); + CLuaMenuForwarder *forwarder = new CLuaMenuForwarder(L, action, id); m->m->addKey(directkey, forwarder, action); m->targets.push_back(forwarder); } return 0; } -int CLuaInstance::MenueAddItem(lua_State *L) +int CLuaInstance::MenuAddItem(lua_State *L) { - CLuaMenue *m = MenueCheck(L, 1); + CLuaMenu *m = MenuCheck(L, 1); if (!m) return 0; lua_assert(lua_istable(L, 2)); - CLuaMenueItem i; + CLuaMenuItem i; m->items.push_back(i); - CLuaMenueItem *b = &m->items.back(); + CLuaMenuItem *b = &m->items.back(); tableLookup(L, "name", b->name); std::string icon; tableLookup(L, "icon", icon); @@ -967,10 +972,9 @@ int CLuaInstance::MenueAddItem(lua_State *L) sscanf(tmp.c_str(), "%d,%d", &range_from, &range_to); if (type == "forwarder") { - strncpy(b->s, value.c_str(), sizeof(b->s)); - CLuaMenueForwarder *forwarder = new CLuaMenueForwarder(L, action, id); - CMenuItem *mi = new CMenuForwarderNonLocalized( - b->name.c_str(), enabled, b->s, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + b->str_val = value; + CLuaMenuForwarder *forwarder = new CLuaMenuForwarder(L, action, id); + CMenuItem *mi = new CMenuForwarder(b->name, enabled, b->str_val, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); mi->setLua(L, action, id); m->m->addItem(mi); m->targets.push_back(forwarder); @@ -1026,16 +1030,15 @@ int CLuaInstance::MenueAddItem(lua_State *L) tableLookup(L, "valid_chars", valid_chars); int sms = 0; tableLookup(L, "sms", sms); int size = 30; tableLookup(L, "size", size); - CLuaMenueStringinput *stringinput = new CLuaMenueStringinput(L, action, id, b->name.c_str(), b->s, size, valid_chars, m->observ, icon.c_str(), sms); - CMenuItem *mi = new CMenuForwarderNonLocalized( - b->name.c_str(), enabled, b->s, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + CLuaMenuStringinput *stringinput = new CLuaMenuStringinput(L, action, id, b->name.c_str(), &b->str_val, size, valid_chars, m->observ, icon.c_str(), sms); + CMenuItem *mi = new CMenuForwarder(b->name, enabled, b->str_val, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); mi->setLua(L, action, id); m->m->addItem(mi); m->targets.push_back(stringinput); } else if (type == "filebrowser") { strncpy(b->s, value.c_str(), sizeof(b->s)); int dirMode = 0; tableLookup(L, "dir_mode", dirMode); - CLuaMenueFilebrowser *filebrowser = new CLuaMenueFilebrowser(L, action, id, b->s, dirMode); + CLuaMenuFilebrowser *filebrowser = new CLuaMenuFilebrowser(L, action, id, &b->str_val, dirMode); lua_pushstring(L, "filter"); lua_gettable(L, -2); if (lua_istable(L, -1)) @@ -1056,18 +1059,18 @@ int CLuaInstance::MenueAddItem(lua_State *L) return 0; } -int CLuaInstance::MenueHide(lua_State *L) +int CLuaInstance::MenuHide(lua_State *L) { - CLuaMenue *m = MenueCheck(L, 1); + CLuaMenu *m = MenuCheck(L, 1); if (!m) return 0; m->m->hide(); return 0; } -int CLuaInstance::MenueExec(lua_State *L) +int CLuaInstance::MenuExec(lua_State *L) { - CLuaMenue *m = MenueCheck(L, 1); + CLuaMenu *m = MenuCheck(L, 1); if (!m) return 0; m->m->exec(NULL, ""); diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index d20f20164..fa3898b35 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -38,8 +38,8 @@ struct CLuaData CFBWindow *fbwin; CRCInput *rcinput; }; -#ifdef MARTII -struct CLuaMenueItem + +struct CLuaMenuItem { union //value { @@ -49,48 +49,48 @@ struct CLuaMenueItem std::string name; }; -class CLuaMenueChangeObserver : public CChangeObserver +class CLuaMenuChangeObserver : public CChangeObserver { public: bool changeNotify(lua_State *, const std::string &, const std::string &, void *); }; -class CLuaMenue +class CLuaMenu { public: CMenuWidget *m; - CLuaMenueChangeObserver *observ; - std::list items; + CLuaMenuChangeObserver *observ; + std::list items; std::list targets; std::list tofree; - CLuaMenue(); - ~CLuaMenue(); + CLuaMenu(); + ~CLuaMenu(); }; -class CLuaMenueForwarder : public CMenuTarget +class CLuaMenuForwarder : public CMenuTarget { public: lua_State *L; std::string luaAction; std::string luaId; - CLuaMenueForwarder(lua_State *L, std::string _luaAction, std::string _luaId); - ~CLuaMenueForwarder(); + CLuaMenuForwarder(lua_State *L, std::string _luaAction, std::string _luaId); + ~CLuaMenuForwarder(); int exec(CMenuTarget* parent, const std::string & actionKey); }; -class CLuaMenueFilebrowser : public CLuaMenueForwarder +class CLuaMenuFilebrowser : public CLuaMenuForwarder { private: char *value; bool dirMode; std::vector filter; public: - CLuaMenueFilebrowser(lua_State *_L, std::string _luaAction, std::string _luaId, char *_value, bool _dirMode); + CLuaMenuFilebrowser(lua_State *_L, std::string _luaAction, std::string _luaId, std::string *_value, bool _dirMode); int exec(CMenuTarget* parent, const std::string & actionKey); void addFilter(std::string s) { filter.push_back(s); }; }; -class CLuaMenueStringinput : public CLuaMenueForwarder +class CLuaMenuStringinput : public CLuaMenuForwarder { private: char *value; @@ -101,7 +101,7 @@ class CLuaMenueStringinput : public CLuaMenueForwarder int size; CChangeObserver *observ; public: - CLuaMenueStringinput(lua_State *_L, std::string _luaAction, std::string _luaId, const char *_name, char *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms); + CLuaMenuStringinput(lua_State *_L, std::string _luaAction, std::string _luaId, const char *_name, std::string *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms); int exec(CMenuTarget* parent, const std::string & actionKey); }; @@ -129,9 +129,7 @@ class CLuaInstance { static const char className[]; static const luaL_Reg methods[]; -#ifdef MARTII - static const luaL_Reg menue_methods[]; -#endif + static const luaL_Reg menu_methods[]; static CLuaData *CheckData(lua_State *L, int narg); public: CLuaInstance(); @@ -155,14 +153,14 @@ private: static int GetSize(lua_State *L); static int DisplayImage(lua_State *L); - void MenueRegister(lua_State *L); - static int MenueNew(lua_State *L); - static int MenueDelete(lua_State *L); - static int MenueAddKey(lua_State *L); - static int MenueAddItem(lua_State *L); - static int MenueHide(lua_State *L); - static int MenueExec(lua_State *L); - static CLuaMenue *MenueCheck(lua_State *L, int n); + void MenuRegister(lua_State *L); + static int MenuNew(lua_State *L); + static int MenuDelete(lua_State *L); + static int MenuAddKey(lua_State *L); + static int MenuAddItem(lua_State *L); + static int MenuHide(lua_State *L); + static int MenuExec(lua_State *L); + static CLuaMenu *MenuCheck(lua_State *L, int n); void HintboxRegister(lua_State *L); static int HintboxNew(lua_State *L); From d5de320ec6c6ceb1b94c302b8a41573700e9d28e Mon Sep 17 00:00:00 2001 From: martii Date: Wed, 11 Dec 2013 12:41:25 +0100 Subject: [PATCH 39/54] gui/luainstance: recognize menu hints Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b59141d1f502cf358bc2671fdca444f90d360091 Author: martii Date: 2013-12-11 (Wed, 11 Dec 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 44 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index ec504bf7c..33820e2b0 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -960,6 +960,8 @@ int CLuaInstance::MenuAddItem(lua_State *L) std::string right_icon; tableLookup(L, "right_icon", right_icon); std::string action; tableLookup(L, "action", action); std::string value; tableLookup(L, "value", value); + std::string hint; tableLookup(L, "hint", hint); + std::string hint_icon; tableLookup(L, "hint_icon", hint_icon); std::string id; tableLookup(L, "id", id); std::string tmp; int directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); @@ -971,12 +973,14 @@ int CLuaInstance::MenuAddItem(lua_State *L) int range_from = 0, range_to = 99; sscanf(tmp.c_str(), "%d,%d", &range_from, &range_to); + CMenuItem *mi = NULL; + if (type == "forwarder") { b->str_val = value; CLuaMenuForwarder *forwarder = new CLuaMenuForwarder(L, action, id); - CMenuItem *mi = new CMenuForwarder(b->name, enabled, b->str_val, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); - mi->setLua(L, action, id); - m->m->addItem(mi); + mi = new CMenuForwarder(b->name, enabled, b->str_val, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + if (!hint.empty() || !hint_icon.empty()) + mi->setHint(hint_icon, hint); m->targets.push_back(forwarder); } else if (type == "chooser") { int options_count = 0; @@ -1009,21 +1013,14 @@ int CLuaInstance::MenuAddItem(lua_State *L) j++; } lua_pop(L, 1); - CMenuItem *mi = new CMenuOptionChooser(b->name.c_str(), &b->i, kext, options_count, enabled, m->observ, directkey, icon.c_str(), pulldown); - mi->setLua(L, action, id); - m->m->addItem(mi); + mi = new CMenuOptionChooser(b->name.c_str(), &b->int_val, kext, options_count, enabled, m->observ, directkey, icon.c_str(), pulldown); } else if (type == "numeric") { - b->i = range_from; - sscanf(value.c_str(), "%d", &b->i); - CMenuItem *mi = new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &b->i, enabled, range_from, range_to, m->observ, - 0, 0, NONEXISTANT_LOCALE, b->name.c_str(), pulldown); - mi->setLua(L, action, id); - m->m->addItem(mi); + b->int_val = range_from; + sscanf(value.c_str(), "%d", &b->int_val); + mi = new CMenuOptionNumberChooser(b->name, &b->int_val, enabled, range_from, range_to, m->observ, 0, 0, NONEXISTANT_LOCALE, pulldown); } else if (type == "string") { - strncpy(b->s, value.c_str(), sizeof(b->s)); - CMenuItem *mi = new CMenuOptionStringChooser(b->name.c_str(), b->s, enabled, m->observ, directkey, icon.c_str(), pulldown); - mi->setLua(L, action, id); - m->m->addItem(mi); + b->str_val = value; + mi = new CMenuOptionStringChooser(b->name.c_str(), &b->str_val, enabled, m->observ, directkey, icon.c_str(), pulldown); } else if (type == "stringinput") { strncpy(b->s, value.c_str(), sizeof(b->s)); std::string valid_chars = "abcdefghijklmnopqrstuvwxyz0123456789!\"§$%&/()=?-. "; @@ -1031,9 +1028,7 @@ int CLuaInstance::MenuAddItem(lua_State *L) int sms = 0; tableLookup(L, "sms", sms); int size = 30; tableLookup(L, "size", size); CLuaMenuStringinput *stringinput = new CLuaMenuStringinput(L, action, id, b->name.c_str(), &b->str_val, size, valid_chars, m->observ, icon.c_str(), sms); - CMenuItem *mi = new CMenuForwarder(b->name, enabled, b->str_val, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); - mi->setLua(L, action, id); - m->m->addItem(mi); + mi = new CMenuForwarder(b->name, enabled, b->str_val, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); m->targets.push_back(stringinput); } else if (type == "filebrowser") { strncpy(b->s, value.c_str(), sizeof(b->s)); @@ -1049,12 +1044,15 @@ int CLuaInstance::MenuAddItem(lua_State *L) } lua_pop(L, 1); - CMenuItem *mi = new CMenuForwarderNonLocalized( - b->name.c_str(), enabled, b->s, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); - mi->setLua(L, action, id); - m->m->addItem(mi); + mi = new CMenuForwarder(b->name, enabled, b->str_val, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); m->targets.push_back(filebrowser); } + if (mi) { + mi->setLua(L, action, id); + if (!hint.empty() || !hint_icon.empty()) + mi->setHint(hint_icon, hint); + m->m->addItem(mi); + } } return 0; } From c71d5ae8326aba7bd78ea6bb01414e2548677acb Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sun, 19 Jan 2014 11:48:38 +0100 Subject: [PATCH 40/54] Adaptation of CLuaInstance Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ab00bb11b2863dde512390c42cd767ad0713e799 Author: Michael Liebmann Date: 2014-01-19 (Sun, 19 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 86 ++++++++++++----------------------------- src/gui/luainstance.h | 17 +++----- 2 files changed, 30 insertions(+), 73 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 33820e2b0..cf071a43e 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -26,10 +26,9 @@ #include #include #include -#ifdef MARTII +#include #include #include -#endif #include #include "luainstance.h" @@ -123,8 +122,7 @@ static void set_lua_variables(lua_State *L) { "mute_off", CRCInput::RC_mute_off }, { "analog_on", CRCInput::RC_analog_on }, { "analog_off", CRCInput::RC_analog_off }, -#ifdef MARTII -/* SPARK keys */ +#if !HAVE_COOL_HARDWARE { "find", CRCInput::RC_find }, { "pip", CRCInput::RC_pip }, { "folder", CRCInput::RC_archive }, @@ -242,7 +240,6 @@ static void set_lua_variables(lua_State *L) { "END_Y", g_settings.screen_EndY }, { NULL, 0 } }; -#ifdef MARTII table_key menureturn[] = { { "NONE", menu_return::RETURN_NONE }, @@ -252,7 +249,6 @@ static void set_lua_variables(lua_State *L) { "EXIT_REPAINT", menu_return::RETURN_EXIT_REPAINT }, { NULL, 0 } }; -#endif /* list of environment variable arrays to be exported */ lua_envexport e[] = @@ -262,9 +258,7 @@ static void set_lua_variables(lua_State *L) { "SCREEN", screenopts }, { "FONT", fontlist }, { "CORNER", corners }, -#ifdef MARTII { "MENU_RETURN", menureturn }, -#endif { NULL, NULL } }; @@ -346,12 +340,10 @@ const luaL_Reg CLuaInstance::methods[] = { "PaintIcon", CLuaInstance::PaintIcon }, { "GetInput", CLuaInstance::GetInput }, { "FontHeight", CLuaInstance::FontHeight }, -#ifdef MARTII { "GetSize", CLuaInstance::GetSize }, { "DisplayImage", CLuaInstance::DisplayImage }, { "Blit", CLuaInstance::Blit }, { "GetLanguage", CLuaInstance::GetLanguage }, -#endif { NULL, NULL } }; @@ -393,7 +385,9 @@ void CLuaInstance::registerFunctions() luaopen_string(lua); luaopen_math(lua); #ifndef DYNAMIC_LUAPOSIX +#if !HAVE_COOL_HARDWARE luaopen_posix_c(lua); +#endif #else dolibrary(lua,"posix"); #endif @@ -514,7 +508,6 @@ int CLuaInstance::PaintIcon(lua_State *L) return 0; } -#ifdef MARTII extern CPictureViewer * g_PicViewer; int CLuaInstance::DisplayImage(lua_State *L) @@ -547,7 +540,6 @@ int CLuaInstance::GetSize(lua_State *L) lua_pushinteger(L, h); return 2; } -#endif int CLuaInstance::RenderString(lua_State *L) { @@ -641,61 +633,34 @@ int CLuaInstance::GCWindow(lua_State *L) delete w; return 0; } -#ifdef MARTII + +#if HAVE_COOL_HARDWARE +int CLuaInstance::Blit(lua_State *) +{ + return 0; +} +#else int CLuaInstance::Blit(lua_State *L) { CLuaData *W = CheckData(L, 1); if (W && W->fbwin) { if (lua_isnumber(L, 2)) - W->fbwin->mayBlit = (int)lua_tonumber(L, 2); // enable/disable automatic blit + W->fbwin->blit((int)lua_tonumber(L, 2)); // enable/disable automatic blit else W->fbwin->blit(); } return 0; } +#endif int CLuaInstance::GetLanguage(lua_State *L) { // FIXME -- should conform to ISO 639-1/ISO 3166-1 - lua_pushstring(L, g_settings.language); + lua_pushstring(L, g_settings.language.c_str()); return 1; } -#if 0 -local m = menue.new{name="mytitle", icon="myicon", hide_parent=true} -m:addItem{type="back"} -m:addItem{type="separator"} - -function talk(a, b) - print(">talk") - print(a .. " => " b) - print(">anothermenue"); - local m = menue.new{name="anothermenue", icon="settings"} - m:addItem{type="back"} - m:addItem{type="separator"} - m:addItem{type="numeric", name="testnumeric"} - m:exec() - print("<Name.c_str()); + if (fileBrowser.exec(value->c_str()) == true) + *value = fileBrowser.getSelectedFile()->Name; if (!luaAction.empty()){ lua_pushglobaltable(L); lua_getfield(L, -1, luaAction.c_str()); lua_remove(L, -2); - lua_pushstring(L, value); + lua_pushstring(L, value->c_str()); lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0); lua_pop(L, 1); } @@ -866,7 +831,7 @@ int CLuaMenuStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*act lua_getfield(L, -1, luaAction.c_str()); lua_remove(L, -2); lua_pushstring(L, luaId.c_str()); - lua_pushstring(L, value); + lua_pushstring(L, value->c_str()); lua_pcall(L, 2 /* two args */, 1 /* one result */, 0); lua_pop(L, 2); } @@ -952,7 +917,7 @@ int CLuaInstance::MenuAddItem(lua_State *L) m->m->addItem(GenericMenuBack); } else if (type == "separator") { if (!b->name.empty()) { - m->m->addItem(new CNonLocalizedMenuSeparator(b->name.c_str(), NONEXISTANT_LOCALE)); + m->m->addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, b->name.c_str(), NONEXISTANT_LOCALE)); } else { m->m->addItem(GenericMenuSeparatorLine); } @@ -997,7 +962,7 @@ int CLuaInstance::MenuAddItem(lua_State *L) m->tofree.push_back(kext); lua_pushstring(L, "options"); lua_gettable(L, -2); - b->i = 0; + b->int_val = 0; int j = 0; if (lua_istable(L, -1)) for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { @@ -1009,7 +974,7 @@ int CLuaInstance::MenuAddItem(lua_State *L) kext[j].valname = strdup(val); m->tofree.push_back((void *)kext[j].valname); if (!strcmp(value.c_str(), kext[j].valname)) - b->i = kext[j].key; + b->int_val = kext[j].key; j++; } lua_pop(L, 1); @@ -1022,7 +987,7 @@ int CLuaInstance::MenuAddItem(lua_State *L) b->str_val = value; mi = new CMenuOptionStringChooser(b->name.c_str(), &b->str_val, enabled, m->observ, directkey, icon.c_str(), pulldown); } else if (type == "stringinput") { - strncpy(b->s, value.c_str(), sizeof(b->s)); + b->str_val = value; std::string valid_chars = "abcdefghijklmnopqrstuvwxyz0123456789!\"§$%&/()=?-. "; tableLookup(L, "valid_chars", valid_chars); int sms = 0; tableLookup(L, "sms", sms); @@ -1031,7 +996,7 @@ int CLuaInstance::MenuAddItem(lua_State *L) mi = new CMenuForwarder(b->name, enabled, b->str_val, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); m->targets.push_back(stringinput); } else if (type == "filebrowser") { - strncpy(b->s, value.c_str(), sizeof(b->s)); + b->str_val = value; int dirMode = 0; tableLookup(L, "dir_mode", dirMode); CLuaMenuFilebrowser *filebrowser = new CLuaMenuFilebrowser(L, action, id, &b->str_val, dirMode); lua_pushstring(L, "filter"); @@ -1304,7 +1269,7 @@ int CLuaInstance::MessageboxExec(lua_State *L) } } - int res = ShowMsgUTF(name.c_str(), text.c_str(), (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); + int res = ShowMsgUTF(name, text, (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); tmp = "cancel"; for (int i = 0; mbr[i].name; i++) @@ -1316,4 +1281,3 @@ int CLuaInstance::MessageboxExec(lua_State *L) return 1; } -#endif diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index fa3898b35..58246e727 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -26,11 +26,9 @@ extern "C" { #include } #include -#ifdef MARTII #include #include #include -#endif /* this is stored as userdata in the lua_State */ struct CLuaData @@ -41,11 +39,8 @@ struct CLuaData struct CLuaMenuItem { - union //value - { - int i; - char s[255]; - }; + int int_val; + std::string str_val; std::string name; }; @@ -81,7 +76,7 @@ class CLuaMenuForwarder : public CMenuTarget class CLuaMenuFilebrowser : public CLuaMenuForwarder { private: - char *value; + std::string *value; bool dirMode; std::vector filter; public: @@ -93,7 +88,7 @@ class CLuaMenuFilebrowser : public CLuaMenuForwarder class CLuaMenuStringinput : public CLuaMenuForwarder { private: - char *value; + std::string *value; std::string valid_chars; const char *name; const char *icon; @@ -122,7 +117,7 @@ class CLuaMessagebox ~CLuaMessagebox(); }; -#endif + /* inspired by Steve Kemp http://www.steve.org.uk/ */ class CLuaInstance @@ -147,7 +142,6 @@ private: static int FontHeight(lua_State *L); static int GetInput(lua_State *L); static int GCWindow(lua_State *L); -#ifdef MARTII static int Blit(lua_State *L); static int GetLanguage(lua_State *L); static int GetSize(lua_State *L); @@ -176,7 +170,6 @@ private: static bool tableLookup(lua_State*, const char*, std::string&); static bool tableLookup(lua_State*, const char*, int&); -#endif }; #endif /* _LUAINSTANCE_H */ From c14d774373161357df3364fb68e1a2acfbb2dfd5 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sun, 19 Jan 2014 21:18:41 +0100 Subject: [PATCH 41/54] deutsch.locale: update vfd scroll Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7c6c8b3cc985d135a5fc2de429668eea19c498c8 Author: vanhofen Date: 2014-01-19 (Sun, 19 Jan 2014) Origin message was: ------------------ - deutsch.locale: update vfd scroll ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/locale/deutsch.locale | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 73e47824d..12847d421 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -718,6 +718,7 @@ lcdmenu.dim_brightness nach Dimm-Timeout lcdmenu.dim_time Dimm-Timeout lcdmenu.head VFD Einstellungen lcdmenu.lcdcontroler Helligkeit +lcdmenu.scroll Laufschrift lcdmenu.statusline Statuszeile lcdmenu.statusline.both Lautstärke/Fortschritt lcdmenu.statusline.playtime Sendungsfortschritt @@ -1175,6 +1176,7 @@ menu.hint_vfd_brightnessstandby Definiert die Helligkeit im Standby-Modus menu.hint_vfd_defaults Zurücksetzen der Helligkeitswerte auf die Standardeinstellungen menu.hint_vfd_dimtime Geben Sie einen Wert in Sekunden ein, nachdem sich das Display automatisch auf den gewünschten Wert dimmt menu.hint_vfd_infoline Wählen Sie, was in der Infozeile angezeigt werden soll +menu.hint_vfd_scroll Laufschrift im Display ein- oder ausschalten menu.hint_vfd_statusline Wählen Sie, was in der Statuszeile angezeigt werden soll menu.hint_video Video-Ausgang, Auflösung, Format, Seitenverhältnisse und mehr menu.hint_video_43mode Anzeige-Modus für 4:3-Inhalte auf 16:9-Fernsehern From 984eb63c595fcc04834a71d5aab2ee5e0cd42066 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Mon, 20 Jan 2014 10:50:32 +0100 Subject: [PATCH 42/54] Fix audio menu in movieplayer Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/506203dd8524ccf98060077b39123bef08962660 Author: Michael Liebmann Date: 2014-01-20 (Mon, 20 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/movieplayer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 23af4dd12..a7f36e9e3 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -1006,10 +1006,9 @@ void CMoviePlayerGui::selectAudioPid(bool file_player) int percent[numpida]; for (uint i=0; i < numpida; i++) { percent[i] = CZapit::getInstance()->GetPidVolume(p_movie_info->epgId, apids[i], ac3flags[i]); - APIDSelector.addItem(new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &percent[i], - currentapid == apids[i], - 0, 999, CVolume::getInstance(), 0, 0, NONEXISTANT_LOCALE, - p_movie_info->audioPids[i].epgAudioPidName.c_str())); + APIDSelector.addItem(new CMenuOptionNumberChooser(p_movie_info->audioPids[i].epgAudioPidName, + &percent[i], currentapid == apids[i], + 0, 999, CVolume::getInstance())); } } From 960502da2a13839d1ba0e66eaf40331bbf921a37 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Mon, 20 Jan 2014 19:28:05 +0100 Subject: [PATCH 43/54] CSignalBox: Set current tuner as the default frontend Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c83f1956372db31b494f3217898df57bc546bfd4 Author: Michael Liebmann Date: 2014-01-20 (Mon, 20 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/components/cc_frm_signalbars.cpp | 3 ++- src/gui/components/cc_frm_signalbars.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index a046e10da..d50bf21e1 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -29,6 +29,7 @@ #include #include +#include #include "cc_frm_signalbars.h" #include @@ -262,7 +263,7 @@ CSignalBox::CSignalBox(const int& xpos, const int& ypos, const int& w, const int initVarSigBox(); vertical = vert; - sbx_frontend = frontend_ref; + sbx_frontend = (frontend_ref == NULL) ? CFEManager::getInstance()->getLiveFE() : frontend_ref; x = xpos; y = ypos; width = w; diff --git a/src/gui/components/cc_frm_signalbars.h b/src/gui/components/cc_frm_signalbars.h index 846e0707e..c18344142 100644 --- a/src/gui/components/cc_frm_signalbars.h +++ b/src/gui/components/cc_frm_signalbars.h @@ -272,7 +272,7 @@ class CSignalBox : public CComponentsForm public: ///class constructor for signal noise ratio. - CSignalBox(const int& xpos, const int& ypos, const int& w, const int& h, CFrontend *frontend_ref, const bool vertical = true); + CSignalBox(const int& xpos, const int& ypos, const int& w, const int& h, CFrontend *frontend_ref = NULL, const bool vertical = true); ///returns the signal object, type = CSignalBar* CSignalBar* getScaleObject(){return sbar;}; From be79e13eabd7b2ceb8909a8acbceffc5c50de6bc Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Mon, 20 Jan 2014 20:21:13 +0100 Subject: [PATCH 44/54] CLuaInstance: Multiple functions made from CComponents in CLuaInstance available - CComponentsWindow: new(), paint(), hide() - CSignalBox: new(), paint() Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ad206dbbc1cabfa813a31d335d3bc3725c2d3b2f Author: Michael Liebmann Date: 2014-01-20 (Mon, 20 Jan 2014) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 158 ++++++++++++++++++++++++++++++++++++++++ src/gui/luainstance.h | 29 ++++++++ 2 files changed, 187 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index cf071a43e..71fa8f550 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -417,6 +417,8 @@ void CLuaInstance::registerFunctions() MenuRegister(lua); HintboxRegister(lua); MessageboxRegister(lua); + CWindowRegister(lua); + SignalBoxRegister(lua); } CLuaData *CLuaInstance::CheckData(lua_State *L, int narg) @@ -1281,3 +1283,159 @@ int CLuaInstance::MessageboxExec(lua_State *L) return 1; } + +// -------------------------------------------------------------------------------- + +void CLuaInstance::CWindowRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "new", CLuaInstance::CWindowNew }, + { "paint", CLuaInstance::CWindowPaint }, + { "hide", CLuaInstance::CWindowHide }, + { "__gc", CLuaInstance::CWindowDelete }, + { NULL, NULL } + }; +#if 0 + { "exec", CLuaInstance::CWindowExec }, +#endif + + luaL_newmetatable(L, "cwindow"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "cwindow"); +} + +int CLuaInstance::CWindowNew(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + + std::string name, icon = std::string(NEUTRINO_ICON_INFO); + int x = 100, y = 100, dx = 450, dy = 250; + tableLookup(L, "x", x); + tableLookup(L, "y", y); + tableLookup(L, "dx", dx); + tableLookup(L, "dy", dy); + tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); + tableLookup(L, "icon", icon); + + CLuaCWindow **udata = (CLuaCWindow **) lua_newuserdata(L, sizeof(CLuaCWindow *)); + *udata = new CLuaCWindow(); + (*udata)->w = new CComponentsWindow(x, y, dx, dy, name.c_str(), icon.c_str()); + luaL_getmetatable(L, "cwindow"); + lua_setmetatable(L, -2); + return 1; +} + +CLuaCWindow *CLuaInstance::CWindowCheck(lua_State *L, int n) +{ + return *(CLuaCWindow **) luaL_checkudata(L, n, "cwindow"); +} + +int CLuaInstance::CWindowPaint(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + int do_save_bg = 1; + tableLookup(L, "do_save_bg", do_save_bg); + + CLuaCWindow *m = CWindowCheck(L, 1); + if (!m) + return 0; + + m->w->paint((do_save_bg!=0)?true:false); + return 0; +} + +int CLuaInstance::CWindowHide(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + int no_restore = 0; + tableLookup(L, "no_restore", no_restore); + + CLuaCWindow *m = CWindowCheck(L, 1); + if (!m) + return 0; + + m->w->hide((no_restore!=0)?true:false); + return 0; +} + +int CLuaInstance::CWindowDelete(lua_State *L) +{ + CLuaCWindow *m = CWindowCheck(L, 1); + if (!m) + return 0; + + m->w->kill(); + delete m; + return 0; +} + +// -------------------------------------------------------------------------------- + +CLuaSignalBox *CLuaInstance::SignalBoxCheck(lua_State *L, int n) +{ + return *(CLuaSignalBox **) luaL_checkudata(L, n, "signalbox"); +} + +void CLuaInstance::SignalBoxRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "new", CLuaInstance::SignalBoxNew }, + { "paint", CLuaInstance::SignalBoxPaint }, + { "__gc", CLuaInstance::SignalBoxDelete }, + { NULL, NULL } + }; + + luaL_newmetatable(L, "signalbox"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "signalbox"); +} + +int CLuaInstance::SignalBoxNew(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + + std::string name, icon = std::string(NEUTRINO_ICON_INFO); + int x = 110, y = 150, dx = 430, dy = 150; + tableLookup(L, "x", x); + tableLookup(L, "y", y); + tableLookup(L, "dx", dx); + tableLookup(L, "dy", dy); + + CLuaSignalBox **udata = (CLuaSignalBox **) lua_newuserdata(L, sizeof(CLuaSignalBox *)); + *udata = new CLuaSignalBox(); + (*udata)->s = new CSignalBox(x, y, dx, dy); + luaL_getmetatable(L, "signalbox"); + lua_setmetatable(L, -2); + return 1; +} + +int CLuaInstance::SignalBoxPaint(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + int do_save_bg = 1; + tableLookup(L, "do_save_bg", do_save_bg); + + CLuaSignalBox *m = SignalBoxCheck(L, 1); + if (!m) + return 0; + + m->s->paint((do_save_bg!=0)?true:false); + return 0; +} + +int CLuaInstance::SignalBoxDelete(lua_State *L) +{ + CLuaSignalBox *m = SignalBoxCheck(L, 1); + if (!m) + return 0; + + m->s->kill(); + delete m; + return 0; +} + +// -------------------------------------------------------------------------------- diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 58246e727..74c155fe0 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -29,6 +29,7 @@ extern "C" { #include #include #include +#include /* this is stored as userdata in the lua_State */ struct CLuaData @@ -117,6 +118,21 @@ class CLuaMessagebox ~CLuaMessagebox(); }; +class CLuaCWindow +{ + public: + CComponentsWindow *w; + CLuaCWindow() { w = NULL; } + ~CLuaCWindow() { delete w; } +}; + +class CLuaSignalBox +{ + public: + CSignalBox *s; + CLuaSignalBox() { s = NULL; } + ~CLuaSignalBox() { delete s; } +}; /* inspired by Steve Kemp http://www.steve.org.uk/ */ @@ -168,6 +184,19 @@ private: static int MessageboxExec(lua_State *L); static CLuaMessagebox *MessageboxCheck(lua_State *L, int n); + void CWindowRegister(lua_State *L); + static int CWindowNew(lua_State *L); + static CLuaCWindow *CWindowCheck(lua_State *L, int n); + static int CWindowPaint(lua_State *L); + static int CWindowHide(lua_State *L); + static int CWindowDelete(lua_State *L); + + static CLuaSignalBox *SignalBoxCheck(lua_State *L, int n); + static void SignalBoxRegister(lua_State *L); + static int SignalBoxNew(lua_State *L); + static int SignalBoxPaint(lua_State *L); + static int SignalBoxDelete(lua_State *L); + static bool tableLookup(lua_State*, const char*, std::string&); static bool tableLookup(lua_State*, const char*, int&); }; From c980278eb13caa6fec9db92bd07afc5f03b397ac Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 21 Jan 2014 16:23:58 +0100 Subject: [PATCH 45/54] Add a --enable-lua switch to enable LUA support Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/82d4832013e3074b8e2a7a2ad762dfd5bdce2472 Author: Michael Liebmann Date: 2014-01-21 (Tue, 21 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- configure.ac | 12 ++++++++++++ src/Makefile.am | 2 ++ src/gui/Makefile.am | 9 ++++++++- src/gui/plugins.cpp | 10 ++++++++++ src/gui/plugins.h | 9 +++++++-- src/gui/user_menue.cpp | 7 +++++-- src/gui/widget/menue.cpp | 17 ++++++++++++++++- src/gui/widget/menue.h | 9 ++++++++- 8 files changed, 68 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 9da436a10..45043c41c 100644 --- a/configure.ac +++ b/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 header file.]) diff --git a/src/Makefile.am b/src/Makefile.am index c3630c191..1df8a164b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 += \ diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 6f13bfacb..e681ead81 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -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 \ diff --git a/src/gui/plugins.cpp b/src/gui/plugins.cpp index a05cde321..5573204cb 100644 --- a/src/gui/plugins.cpp +++ b/src/gui/plugins.cpp @@ -69,7 +69,9 @@ #endif #include +#if ENABLE_LUA #include +#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; } diff --git a/src/gui/plugins.h b/src/gui/plugins.h index 1bd6c614f..349219ec7 100644 --- a/src/gui/plugins.h +++ b/src/gui/plugins.h @@ -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); diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index d70d8ba5d..7f786b82c 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -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); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 8348dcac7..8023ddf53 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -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() : "")); } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 5eac43348..d80d446c3 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -45,11 +45,13 @@ #include #include +#if ENABLE_LUA extern "C" { #include #include #include } +#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(); }; From 56ed327449ca1a7da8524e5ad4e902191875152c Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 21 Jan 2014 01:39:30 +0100 Subject: [PATCH 46/54] CLuaInstance: fix format strings Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9a346f8d25128194ea9a83ef39fc9cc143aedfc8 Author: Michael Liebmann Date: 2014-01-21 (Tue, 21 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 71fa8f550..73ad1b0e4 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -601,7 +601,7 @@ int CLuaInstance::GetInput(lua_State *L) /* TODO: I'm not sure if this works... */ if (msg != CRCInput::RC_timeout && msg > CRCInput::RC_MaxRC) { - DBG("CLuaInstance::%s: msg 0x%08lx data 0x%08lx\n", __func__, msg, data); + DBG("CLuaInstance::%s: msg 0x%08"PRIx32" data 0x%08"PRIx32"\n", __func__, msg, data); CNeutrinoApp::getInstance()->handleMsg(msg, data); } /* signed int is debatable, but the "big" messages can't yet be handled From 862553d1c149182e784c55101e1aac9cc2d5a3ea Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 21 Jan 2014 17:20:40 +0100 Subject: [PATCH 47/54] CLuaInstance: Add parameter 'vertical' to CLuaSignalBox Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1f7e8b41d70ff2b97af119ac49180e05eb85ef87 Author: Michael Liebmann Date: 2014-01-21 (Tue, 21 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 73ad1b0e4..d326cf31f 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1400,14 +1400,16 @@ int CLuaInstance::SignalBoxNew(lua_State *L) std::string name, icon = std::string(NEUTRINO_ICON_INFO); int x = 110, y = 150, dx = 430, dy = 150; + int vertical = true; tableLookup(L, "x", x); tableLookup(L, "y", y); tableLookup(L, "dx", dx); tableLookup(L, "dy", dy); + tableLookup(L, "vertical", vertical); CLuaSignalBox **udata = (CLuaSignalBox **) lua_newuserdata(L, sizeof(CLuaSignalBox *)); *udata = new CLuaSignalBox(); - (*udata)->s = new CSignalBox(x, y, dx, dy); + (*udata)->s = new CSignalBox(x, y, dx, dy, NULL, (vertical!=0)?true:false); luaL_getmetatable(L, "signalbox"); lua_setmetatable(L, -2); return 1; From d03ee601245fb2c3dbdf6a9710c19dfdd8b7d425 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 21 Jan 2014 17:24:05 +0100 Subject: [PATCH 48/54] CSignalBar: Fix display "value caption" Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/4fa3a245dfe35e34e940bc60404bf4847359ae10 Author: Michael Liebmann Date: 2014-01-21 (Tue, 21 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/components/cc_frm_signalbars.cpp | 34 +++++++++++++----------- src/gui/components/cc_frm_signalbars.h | 13 +++------ src/gui/motorcontrol.cpp | 1 - src/gui/scan.cpp | 1 - src/gui/streaminfo2.cpp | 1 - 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index d50bf21e1..df2e1d27d 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -41,6 +41,8 @@ CSignalBar::CSignalBar() { initVarSigBar(); sb_name = "SIG"; + + initDimensions(); initSBItems(); } @@ -54,6 +56,7 @@ CSignalBar::CSignalBar(const int& xpos, const int& ypos, const int& w, const int height = h; sb_name = sbname; + initDimensions(); initSBItems(); } @@ -65,15 +68,14 @@ void CSignalBar::initDimensions() if (sb_scale_height == -1) sb_scale_height = sb_item_height; - //use value in % of signalbox width for scale, rest is reserved for caption - sb_scale_width = width*sb_scale_w_percent/100; + int dx = 0; + int dy = min(sb_item_height, 100); + sb_font = *dy_font->getDynFont(dx, dy, "100% "+sb_name); + dx += dx/10; + sb_scale_width = width - dx; - int dx = width - sb_scale_width; - int dy = sb_item_height; - sb_font = *dy_font->getDynFont(dx, dy); - - //use 15% for value and name label - sb_vlbl_width = sb_lbl_width = dx /2; + sb_vlbl_width = sb_font->getRenderWidth("100% ") + dx/20; + sb_lbl_width = dx - sb_vlbl_width; } void CSignalBar::initSBItems() @@ -87,9 +89,6 @@ void CSignalBar::initSBItems() sb_caption_color = sbx->getTextColor(); } - //reinit dimensions - initDimensions(); - //init items scale, value and name initSBarScale(); initSBarValue(); @@ -105,7 +104,6 @@ void CSignalBar::initVarSigBar() height = SB_MIN_HEIGHT; sb_scale_height = -1; - sb_scale_w_percent = 60; dy_font = CNeutrinoFonts::getInstance(); sb_caption_color= COL_INFOBAR_TEXT; @@ -170,7 +168,7 @@ void CSignalBar::initSBarName() if (sb_lbl == NULL){ sb_lbl = new CComponentsLabel(); sb_lbl->doPaintBg(false); - sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK/* | CTextBox::RIGHT*/, sb_font); + sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, sb_font); sb_lbl->forceTextPaint(); sb_lbl->doPaintTextBoxBg(true); } @@ -299,7 +297,6 @@ void CSignalBox::initVarSigBox() sbx_bar_height = height/2; sbx_bar_x = corner_rad; sbx_caption_color = COL_INFOBAR_TEXT; - sbx_scale_w_percent = 60; vertical = true; } @@ -316,17 +313,22 @@ void CSignalBox::initSignalItems() int sbar_x = sbx_bar_x + fr_thickness; int scale_h = sbar_h * 76 / 100; + int sbar_sw = sbar->getScaleWidth(); + int snrbar_sw = snrbar->getScaleWidth(); + if (sbar_sw < snrbar_sw) + snrbar->setScaleWidth(sbar_sw); + else if (snrbar_sw < sbar_sw) + sbar->setScaleWidth(snrbar_sw); + sbar->setDimensionsAll(sbar_x, fr_thickness, sbar_w, sbar_h); sbar->setFrontEnd(sbx_frontend); sbar->setCorner(0); sbar->setScaleHeight(scale_h); - sbar->setScaleWidth(sbx_scale_w_percent); snrbar->setDimensionsAll(vertical ? sbar_x : CC_APPEND, vertical ? CC_APPEND : fr_thickness, sbar_w, sbar_h); snrbar->setFrontEnd(sbx_frontend); snrbar->setCorner(0); snrbar->setScaleHeight(scale_h); - snrbar->setScaleWidth(sbx_scale_w_percent); } void CSignalBox::paintScale() diff --git a/src/gui/components/cc_frm_signalbars.h b/src/gui/components/cc_frm_signalbars.h index c18344142..c7474ffa7 100644 --- a/src/gui/components/cc_frm_signalbars.h +++ b/src/gui/components/cc_frm_signalbars.h @@ -88,9 +88,6 @@ class CSignalBar : public CComponentsForm int sb_lastsig; ///current signal value uint16_t sb_signal; - - ///allowed width of scale bar from full width in %, rest used by caption, default value = 60% of width, use setScaleWidth() to set this value - short sb_scale_w_percent; ///initialize all needed basich attributes and objects void initVarSigBar(); @@ -126,7 +123,7 @@ class CSignalBar : public CComponentsForm ///assigns the height of scale virtual void setScaleHeight(const int& scale_height){sb_scale_height = scale_height;}; ///assigns the width of scale - virtual void setScaleWidth(const short & scale_width_percent){sb_scale_w_percent = scale_width_percent;}; + virtual void setScaleWidth(const int & scale_width){sb_scale_width = scale_width;}; ///assigns the name of signal value in the caption object, see also sb_name virtual void setName(const std::string& name){sb_name = name;}; @@ -136,6 +133,8 @@ class CSignalBar : public CComponentsForm virtual CComponentsLabel* getLabelValObject(){return sb_vlbl;}; ///returns the name label object, type = CComponentsLabel* virtual CComponentsLabel* getLabelNameObject(){return sb_lbl;}; + /// return the scale width + virtual int getScaleWidth(){ return sb_scale_width;}; ///paint this items virtual void paint(bool do_save_bg); @@ -256,9 +255,6 @@ class CSignalBox : public CComponentsForm ///property: text color, see also setTextColor() fb_pixel_t sbx_caption_color; - ///allowed width of scale bar from full width in %, rest used by caption, default value = 60% of width, use setScaleWidth() to set this value - short sbx_scale_w_percent; - // true if vertical arrangement, false if horizontal bool vertical; @@ -283,9 +279,6 @@ class CSignalBox : public CComponentsForm void setTextColor(const fb_pixel_t& caption_color){ sbx_caption_color = caption_color;}; ///get caption color of signalbars, see also property 'sbx_caption_color' fb_pixel_t getTextColor(){return sbx_caption_color;}; - - ///assigns the width of scale in percent related of full width of signal box, the rest is reserved for text - void setScaleWidth(const short & scale_width_percent){sbx_scale_w_percent = scale_width_percent;}; ///paint items void paint(bool do_save_bg); diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index f23aa878f..fbe2581bc 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -582,7 +582,6 @@ void CMotorControl::showSNR () if (signalbox == NULL){ int xpos1 = x + 10; signalbox = new CSignalBox(xpos1, y + height - mheight - 5, width - 2*(xpos1-x), g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), frontend, false); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUCONTENT_PLUS_0); signalbox->setTextColor(COL_MENUCONTENT_TEXT); signalbox->doPaintBg(true); diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 2ed59771f..d0f0493d8 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -552,7 +552,6 @@ void CScanTs::showSNR () if (signalbox == NULL){ CFrontend * frontend = CServiceScan::getInstance()->GetFrontend(); signalbox = new CSignalBox(xpos1, y + height - mheight - 5, width - 2*(xpos1-x), g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), frontend, false); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUCONTENT_PLUS_0); signalbox->setTextColor(COL_MENUCONTENT_TEXT); signalbox->doPaintBg(true); diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 9447241d0..2c61b5819 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -886,7 +886,6 @@ void CStreamInfo2::showSNR () { if (signalbox == NULL){ signalbox = new CSignalBox(x + 10, yypos, 240, 50, frontend); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUHEAD_PLUS_0); signalbox->setTextColor(COL_INFOBAR_TEXT); signalbox->doPaintBg(true); From 0c52941204b7ab55fc83da24c966ca2445c0a209 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 21 Jan 2014 22:15:19 +0100 Subject: [PATCH 49/54] CLuaInstance: Fix compiler warnings Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/87031add9489c8766005f62ad559da2252ea6fd2 Author: Michael Liebmann Date: 2014-01-21 (Tue, 21 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index d326cf31f..09fb48f9d 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -39,7 +39,7 @@ struct table_key { const char *name; - long code; + uint32_t code; }; struct lua_envexport { @@ -224,20 +224,20 @@ static void set_lua_variables(lua_State *L) { "TOP_RIGHT", CORNER_TOP_RIGHT }, { "BOTTOM_LEFT", CORNER_BOTTOM_LEFT }, { "BOTTOM_RIGHT", CORNER_BOTTOM_RIGHT }, - { "RADIUS_LARGE", RADIUS_LARGE }, /* those depend on g_settings.rounded_corners */ - { "RADIUS_MID", RADIUS_MID }, - { "RADIUS_SMALL", RADIUS_SMALL }, - { "RADIUS_MIN", RADIUS_MIN }, + { "RADIUS_LARGE", (uint32_t) RADIUS_LARGE }, /* those depend on g_settings.rounded_corners */ + { "RADIUS_MID", (uint32_t) RADIUS_MID }, + { "RADIUS_SMALL", (uint32_t) RADIUS_SMALL }, + { "RADIUS_MIN", (uint32_t) RADIUS_MIN }, { NULL, 0 } }; /* screen offsets, exported as e.g. SCREEN['END_Y'] */ table_key screenopts[] = { - { "OFF_X", g_settings.screen_StartX }, - { "OFF_Y", g_settings.screen_StartY }, - { "END_X", g_settings.screen_EndX }, - { "END_Y", g_settings.screen_EndY }, + { "OFF_X", (uint32_t) g_settings.screen_StartX }, + { "OFF_Y", (uint32_t) g_settings.screen_StartY }, + { "END_X", (uint32_t) g_settings.screen_EndX }, + { "END_Y", (uint32_t) g_settings.screen_EndY }, { NULL, 0 } }; table_key menureturn[] = @@ -696,7 +696,7 @@ bool CLuaMenuChangeObserver::changeNotify(lua_State *L, const std::string &luaAc lua_pushstring(L, luaId.c_str()); lua_pushstring(L, optionValue); lua_pcall(L, 2 /* two args */, 1 /* one result */, 0); - double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0; + int res = lua_isnumber(L, -1) ? (int)lua_tonumber(L, -1) : 0; lua_pop(L, 2); return ((res == menu_return::RETURN_REPAINT) || (res == menu_return::RETURN_EXIT_REPAINT)); } @@ -1275,7 +1275,7 @@ int CLuaInstance::MessageboxExec(lua_State *L) tmp = "cancel"; for (int i = 0; mbr[i].name; i++) - if (res == mbr[i].code) { + if ((uint32_t)res == mbr[i].code) { tmp = mbr[i].name; break; } From 4957329c44fbfbf76a23d8601d8a5963239c67d5 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 22 Jan 2014 12:27:07 +0400 Subject: [PATCH 50/54] mmi.h, cam_menu.cpp fix spelling error Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/cfe6facea45262addd60342aafcf431547343f41 Author: [CST] Focus Date: 2014-01-22 (Wed, 22 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libcoolstream/mmi.h | 4 ++-- lib/libcoolstream2/mmi.h | 4 ++-- src/gui/cam_menu.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/libcoolstream/mmi.h b/lib/libcoolstream/mmi.h index 96266ea44..e32ce198e 100644 --- a/lib/libcoolstream/mmi.h +++ b/lib/libcoolstream/mmi.h @@ -47,8 +47,8 @@ typedef struct { typedef struct { int blind; int answerlen; - char enguiryText[MAX_MMI_TEXT_LEN]; -} MMI_ENGUIRY_INFO; + char enquiryText[MAX_MMI_TEXT_LEN]; +} MMI_ENQUIRY_INFO; #endif // __MMI_H_ diff --git a/lib/libcoolstream2/mmi.h b/lib/libcoolstream2/mmi.h index 96266ea44..e32ce198e 100644 --- a/lib/libcoolstream2/mmi.h +++ b/lib/libcoolstream2/mmi.h @@ -47,8 +47,8 @@ typedef struct { typedef struct { int blind; int answerlen; - char enguiryText[MAX_MMI_TEXT_LEN]; -} MMI_ENGUIRY_INFO; + char enquiryText[MAX_MMI_TEXT_LEN]; +} MMI_ENQUIRY_INFO; #endif // __MMI_H_ diff --git a/src/gui/cam_menu.cpp b/src/gui/cam_menu.cpp index db0608019..3314228c0 100644 --- a/src/gui/cam_menu.cpp +++ b/src/gui/cam_menu.cpp @@ -218,9 +218,9 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t char cnt[5]; int i; MMI_MENU_LIST_INFO Menu; - MMI_ENGUIRY_INFO MmiEnquiry; + MMI_ENQUIRY_INFO MmiEnquiry; MMI_MENU_LIST_INFO *pMenu = &Menu; - MMI_ENGUIRY_INFO *pMmiEnquiry = &MmiEnquiry; + MMI_ENQUIRY_INFO *pMmiEnquiry = &MmiEnquiry; CA_MESSAGE Msg, *rMsg; if (msg != NeutrinoMessages::EVT_CA_MESSAGE) @@ -405,14 +405,14 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t if (!(Msg.Flags & CA_MESSAGE_HAS_PARAM1_DATA)) return -1; - memmove(pMmiEnquiry, (MMI_ENGUIRY_INFO *)Msg.Msg.Data[0], sizeof(MMI_ENGUIRY_INFO)); + memmove(pMmiEnquiry, (MMI_ENQUIRY_INFO *)Msg.Msg.Data[0], sizeof(MMI_ENQUIRY_INFO)); free((void *)Msg.Msg.Data[0]); - printf("CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str()); + printf("CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enquiryText, strlen(pMmiEnquiry->enquiryText), 0).c_str()); hideHintBox(); std::string ENQAnswer; - CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str(), &ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE); + CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enquiryText, strlen(pMmiEnquiry->enquiryText), 0).c_str(), &ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE); Inquiry->exec(NULL, ""); delete Inquiry; From ae8cfd7dc20a5dbd85bf1f899f21545b3e487fbb Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 22 Jan 2014 12:11:52 +0100 Subject: [PATCH 51/54] adapt ShowHint handling from martii's neutrino-mp Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6995e1a7657e2ea124a08ede3aa93b4a191166c9 Author: vanhofen Date: 2014-01-22 (Wed, 22 Jan 2014) Origin message was: ------------------ - adapt ShowHint handling from martii's neutrino-mp ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/record.cpp | 2 +- src/gui/cam_menu.cpp | 14 +++++++------- src/gui/epgview.cpp | 2 +- src/gui/infoviewer.cpp | 4 ++-- src/gui/scan_setup.cpp | 2 +- src/gui/timerlist.cpp | 2 +- src/gui/update.cpp | 32 ++++++++++++++++---------------- src/gui/videosettings.cpp | 8 ++++---- src/gui/widget/hintbox.cpp | 29 +++++++++++++---------------- src/gui/widget/hintbox.h | 7 ++++--- src/neutrino.cpp | 24 ++++++++++++------------ 11 files changed, 62 insertions(+), 64 deletions(-) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index b1c3dd307..13f796c28 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1437,7 +1437,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey ) } else if(actionKey == "Stop_record") { if(!CRecordManager::getInstance()->RecordingStatus()) { - ShowHintUTF(LOCALE_MAINMENU_RECORDING_STOP, g_Locale->getText(LOCALE_RECORDINGMENU_RECORD_IS_NOT_RUNNING), 450, 2); + ShowHint(LOCALE_MAINMENU_RECORDING_STOP, g_Locale->getText(LOCALE_RECORDINGMENU_RECORD_IS_NOT_RUNNING), 450, 2); return menu_return::RETURN_EXIT_ALL; } } diff --git a/src/gui/cam_menu.cpp b/src/gui/cam_menu.cpp index 3314228c0..d0dc13e7f 100644 --- a/src/gui/cam_menu.cpp +++ b/src/gui/cam_menu.cpp @@ -250,7 +250,7 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t snprintf(str, sizeof(str), "%s %d", g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INSERTED : LOCALE_SC_INSERTED), (int)curslot+1); printf("CCAMMenuHandler::handleCamMsg: %s\n", str); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, str); + ShowHint(LOCALE_MESSAGEBOX_INFO, str); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, str, CI_MSG_TIME); #endif @@ -261,7 +261,7 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_REMOVED : LOCALE_SC_REMOVED), (int)curslot+1); printf("CCAMMenuHandler::handleCamMsg: %s\n", str); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, str); + ShowHint(LOCALE_MESSAGEBOX_INFO, str); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, str, CI_MSG_TIME); #endif @@ -279,7 +279,7 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INIT_OK : LOCALE_SC_INIT_OK), (int)curslot+1, name); printf("CCAMMenuHandler::handleCamMsg: %s\n", str); CCamManager::getInstance()->Start(CZapit::getInstance()->GetCurrentChannelID(), CCamManager::PLAY, true); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, str); + ShowHint(LOCALE_MESSAGEBOX_INFO, str); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, str, CI_MSG_TIME); #endif @@ -294,7 +294,7 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INIT_FAILED : LOCALE_SC_INIT_FAILED), (int)curslot+1, name); printf("CCAMMenuHandler::handleCamMsg: %s\n", str); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, str); + ShowHint(LOCALE_MESSAGEBOX_INFO, str); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, str, CI_MSG_TIME); #endif @@ -371,13 +371,13 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t if(strlen(pMenu->bottom)) slen += snprintf(&lstr[slen], 255-slen, "\n%s", pMenu->bottom); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(lstr, slen, 0).c_str()); + ShowHint(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(lstr, slen, 0).c_str()); #else if(strlen(pMenu->subtitle)) slen += snprintf(&lstr[slen], 255-slen, "\n%s", pMenu->subtitle); if(strlen(pMenu->bottom)) slen += snprintf(&lstr[slen], 255-slen, "\n%s", pMenu->bottom); - ShowHintUTF(convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), convertDVBUTF8(lstr, slen, 0).c_str()); + ShowHint(convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), convertDVBUTF8(lstr, slen, 0).c_str()); #endif #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(lstr, slen, 0).c_str()); @@ -463,7 +463,7 @@ int CCAMMenuHandler::doMenu(int slot, CA_SLOT_TYPE slotType) if (msg == CRCInput::RC_timeout) { printf("CCAMMenuHandler::doMenu: menu timeout\n"); hideHintBox(); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(slotType == CA_SLOT_TYPE_CI ? LOCALE_CI_TIMEOUT : LOCALE_SC_TIMEOUT)); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_CI_TIMEOUT), 5); diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 1116d8bde..f90515da1 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -465,7 +465,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if (epgData.title.empty()) /* no epg info found */ { - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EPGVIEWER_NOTFOUND)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EPGVIEWER_NOTFOUND)); // UTF-8 hide(); return res; } diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index f55b44f27..ccfea0f2d 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -1078,7 +1078,7 @@ void CInfoViewer::showSubchan () void CInfoViewer::showFailure () { - ShowHintUTF (LOCALE_MESSAGEBOX_ERROR, g_Locale->getText (LOCALE_INFOVIEWER_NOTAVAILABLE), 430); // UTF-8 + ShowHint (LOCALE_MESSAGEBOX_ERROR, g_Locale->getText (LOCALE_INFOVIEWER_NOTAVAILABLE), 430); // UTF-8 } void CInfoViewer::showMotorMoving (int duration) @@ -1087,7 +1087,7 @@ void CInfoViewer::showMotorMoving (int duration) char text[256]; snprintf(text, sizeof(text), "%s (%ds)", g_Locale->getText (LOCALE_INFOVIEWER_MOTOR_MOVING), duration); - ShowHintUTF (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, duration); // UTF-8 + ShowHint (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, duration); // UTF-8 } void CInfoViewer::killRadiotext() diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index 1d203d60f..a00bfde8e 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -1553,7 +1553,7 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) if (i == 0) { std::string text = "No transponders found for "; text += name; - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, text.c_str(), 450, 2); + ShowHint(LOCALE_MESSAGEBOX_ERROR, text.c_str(), 450, 2); return menu_return::RETURN_REPAINT; } diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 146c782b3..d3b42a66f 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -650,7 +650,7 @@ int CTimerList::show() if (timer->epgID != 0) res = g_EpgData->show(timer->channel_id, timer->epgID, &timer->epg_starttime); else - ShowLocalizedHint(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NOTFOUND); + ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NOTFOUND); if (res==menu_return::RETURN_EXIT_ALL) loop=false; else diff --git a/src/gui/update.cpp b/src/gui/update.cpp index d6f28f846..4e3ee8b91 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -332,7 +332,7 @@ printf("[update] mode is %d\n", softupdate_mode); (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) { delete versionInfo; - //ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE)); // UTF-8 + //ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE)); // UTF-8 return false; } @@ -378,7 +378,7 @@ printf("[update] mode is %d\n", softupdate_mode); else { hide(); printf("flash-file not found: %s\n", filename.c_str()); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE)); // UTF-8 return false; } hide(); @@ -415,7 +415,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) paint(); if(sysfs.size() < 8) { - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD)); + ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD)); hide(); return menu_return::RETURN_REPAINT; } @@ -440,7 +440,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) if(!getUpdateImage(newVersion)) { hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILEERROR)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILEERROR)); // UTF-8 return menu_return::RETURN_REPAINT; } sprintf(fullname, "%s/%s", g_settings.update_dir.c_str(), fname); @@ -457,7 +457,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_MD5CHECK)); // UTF-8 if((softupdate_mode==1) && !ft.check_md5(filename, file_md5)) { hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_MD5SUMERROR)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_MD5SUMERROR)); // UTF-8 return menu_return::RETURN_REPAINT; } if(softupdate_mode==1) { //internet-update @@ -491,7 +491,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) if(!ft.program(filename, 80, 100)) { #endif hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str()); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str()); // UTF-8 return menu_return::RETURN_REPAINT; } @@ -499,7 +499,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) showGlobalStatus(100); showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8 hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8 sleep(2); ft.reboot(); } @@ -528,7 +528,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) my_system(3, install_sh, g_settings.update_dir.c_str(), filename.c_str()); #endif showGlobalStatus(100); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8 } hide(); return menu_return::RETURN_REPAINT; @@ -567,7 +567,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) std::string path = getPathName(backupFile); if (!file_exists(path.c_str())) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_DIRECTORY_NOT_EXIST), path.c_str()); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); + ShowHint(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } @@ -578,7 +578,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) if (mtd == -1) { // check disk space for image creation if (!get_fs_usage("/", btotal, bused, &bsize)) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), "root0"); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); + ShowHint(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } backupRequiredSize = ((bused * bsize) / 1024ULL) * 2ULL; // twice disk space for summarized image @@ -590,7 +590,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) btotal = 0; bused = 0; bsize = 0; if (!get_fs_usage(path.c_str(), btotal, bused, &bsize)) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), path.c_str()); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); + ShowHint(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } uint64_t backupMaxSize = (btotal - bused) * (uint64_t)bsize; @@ -601,7 +601,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) if (backupMaxSize < backupRequiredSize) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_NO_AVAILABLE_SPACE), path.c_str(), backupMaxSize, backupRequiredSize); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); + ShowHint(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } @@ -674,7 +674,7 @@ void CFlashExpert::readmtdJFFS2(std::string &filename) char message[500]; sprintf(message, g_Locale->getText(LOCALE_FLASHUPDATE_SAVESUCCESS), filename.c_str()); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, message); + ShowHint(LOCALE_MESSAGEBOX_INFO, message); } #endif @@ -746,9 +746,9 @@ void CFlashExpert::readmtd(int preadmtd) hide(); #ifdef BOXMODEL_APOLLO if (!forceOtherFilename) - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, message); + ShowHint(LOCALE_MESSAGEBOX_INFO, message); #else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, message); + ShowHint(LOCALE_MESSAGEBOX_INFO, message); #endif } } @@ -783,7 +783,7 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber) showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8 sleep(2); hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8 ft.reboot(); } } diff --git a/src/gui/videosettings.cpp b/src/gui/videosettings.cpp index 90a6fe3d3..60a3d8329 100644 --- a/src/gui/videosettings.cpp +++ b/src/gui/videosettings.cpp @@ -496,7 +496,7 @@ void CVideoSettings::next43Mode(void) #ifdef ENABLE_PIP pipDecoder->setAspectRatio(-1, g_settings.video_43mode); #endif - ShowHintUTF(LOCALE_VIDEOMENU_43MODE, g_Locale->getText(text), 450, 2); + ShowHint(LOCALE_VIDEOMENU_43MODE, g_Locale->getText(text), 450, 2); } void CVideoSettings::SwitchFormat() @@ -522,7 +522,7 @@ void CVideoSettings::SwitchFormat() #ifdef ENABLE_PIP pipDecoder->setAspectRatio(g_settings.video_Format, -1); #endif - ShowHintUTF(LOCALE_VIDEOMENU_VIDEOFORMAT, g_Locale->getText(text), 450, 2); + ShowHint(LOCALE_VIDEOMENU_VIDEOFORMAT, g_Locale->getText(text), 450, 2); } void CVideoSettings::nextMode(void) @@ -543,7 +543,7 @@ void CVideoSettings::nextMode(void) while(1) { CVFD::getInstance()->ShowText(text); - int res = ShowHintUTF(LOCALE_VIDEOMENU_VIDEOMODE, text, 450, 2); + int res = ShowHint(LOCALE_VIDEOMENU_VIDEOMODE, text, 450, 2); if(disp_cur && res != messages_return::handled) break; @@ -578,7 +578,7 @@ void CVideoSettings::nextMode(void) break; } CVFD::getInstance()->showServicename(g_RemoteControl->getCurrentChannelName()); - //ShowHintUTF(LOCALE_VIDEOMENU_VIDEOMODE, text, 450, 2); + //ShowHint(LOCALE_VIDEOMENU_VIDEOMODE, text, 450, 2); } //sets menu mode to "wizard" or "default" diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 3c9828678..314b0519a 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -3,14 +3,7 @@ Copyright (C) 2001 Steffen Hehn 'McClean' Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - + Copyright (C) 2008-2009, 2011, 2013 Stefan Seyfried License: GPL @@ -25,8 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ @@ -177,7 +169,7 @@ void CHintBox::refresh(void) //window->paintBoxRel(borderwidth, height, width, borderwidth, COL_INFOBAR_SHADOW_PLUS_0); //window->paintBoxRel(width, borderwidth, borderwidth, height - borderwidth, COL_INFOBAR_SHADOW_PLUS_0); - window->paintBoxRel(width-20, borderwidth, borderwidth+20, height - borderwidth, COL_INFOBAR_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_TOP); // right + window->paintBoxRel(width - 20, borderwidth, borderwidth + 20, height - borderwidth - 20, COL_INFOBAR_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_TOP); // right window->paintBoxRel(borderwidth, height-20, width, borderwidth+20, COL_INFOBAR_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); // bottom //window->paintBoxRel(0, 0, width, theight, (CFBWindow::color_t)COL_MENUHEAD_PLUS_0); @@ -245,14 +237,14 @@ void CHintBox::hide(void) } } -int ShowHintUTF(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon) +int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon) { const char * caption = g_Locale->getText(Caption); - return ShowHintUTF(caption, Text, Width, timeout, Icon); + return ShowHint(caption, Text, Width, timeout, Icon); } -int ShowHintUTF(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon) +int ShowHint(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon) { neutrino_msg_t msg; neutrino_msg_data_t data; @@ -315,8 +307,13 @@ int ShowHintUTF(const char * const Caption, const char * const Text, const int W return res; } -int ShowLocalizedHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon) +int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon) { - return ShowHintUTF(Caption, g_Locale->getText(Text),Width,timeout,Icon); + return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon); +} + +int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon) +{ + return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon); } diff --git a/src/gui/widget/hintbox.h b/src/gui/widget/hintbox.h index 7e7a5f36b..d58761c7d 100644 --- a/src/gui/widget/hintbox.h +++ b/src/gui/widget/hintbox.h @@ -77,9 +77,10 @@ class CHintBox }; // Text is UTF-8 encoded -int ShowHintUTF(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); -int ShowHintUTF(const char * const Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); -int ShowLocalizedHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const char * const Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); #endif diff --git a/src/neutrino.cpp b/src/neutrino.cpp index ced01ca64..f58b548ae 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -1968,7 +1968,7 @@ TIMER_START(); if(loadSettingsErg) { hintBox->hide(); dprintf(DEBUG_INFO, "config file or options missing\n"); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, loadSettingsErg == 1 ? g_Locale->getText(LOCALE_SETTINGS_NOCONFFILE) + ShowHint(LOCALE_MESSAGEBOX_INFO, loadSettingsErg == 1 ? g_Locale->getText(LOCALE_SETTINGS_NOCONFFILE) : g_Locale->getText(LOCALE_SETTINGS_MISSINGOPTIONSCONFFILE)); configfile.setModifiedFlag(true); saveSetup(NEUTRINO_SETTINGS_FILE); @@ -2255,8 +2255,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) usermenu.showUserMenu(SNeutrinoSettings::BUTTON_RED); StartSubtitles(); } - else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + else + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); } else if ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) { @@ -2273,7 +2273,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) StartSubtitles(); } else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); } else if( msg == CRCInput::RC_yellow ) { // NVODs if (g_settings.personalize[SNeutrinoSettings::P_MAIN_YELLOW_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED) @@ -2283,7 +2283,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) StartSubtitles(); } else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); } else if( (msg == CRCInput::RC_green) || ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) ) { @@ -2303,8 +2303,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) usermenu.showUserMenu(SNeutrinoSettings::BUTTON_BLUE); StartSubtitles(); } - else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT), 450, 10); + else + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT), 450, 10); } else if( (msg == CRCInput::RC_audio) && g_settings.audio_run_player) { //open mediaplayer menu in audio mode, user can select between audioplayer and internetradio @@ -2478,7 +2478,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) scrambled_timer = 0; if(g_settings.scrambled_message && videoDecoder->getBlank() && videoDecoder->getPlayState()) { const char * text = g_Locale->getText(LOCALE_SCRAMBLED_CHANNEL); - ShowHintUTF (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, 5); + ShowHint (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, 5); } return messages_return::handled; } @@ -2811,7 +2811,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) CTimerd::RecordingInfo * eventinfo = (CTimerd::RecordingInfo *) data; std::string name = g_Locale->getText(LOCALE_ZAPTOTIMER_ANNOUNCE); getAnnounceEpgName( eventinfo, name); - ShowHintUTF( LOCALE_MESSAGEBOX_INFO, name.c_str() ); + ShowHint( LOCALE_MESSAGEBOX_INFO, name.c_str() ); } delete [] (unsigned char*) data; return messages_return::handled; @@ -2847,7 +2847,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) if(( mode != mode_scart ) && ( mode != mode_standby ) && g_settings.recording_startstop_msg) { std::string name = g_Locale->getText(LOCALE_RECORDTIMER_ANNOUNCE); getAnnounceEpgName(eventinfo, name); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, name.c_str()); + ShowHint(LOCALE_MESSAGEBOX_INFO, name.c_str()); } delete[] (unsigned char*) data; return messages_return::handled; @@ -2938,7 +2938,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } if (msg == NeutrinoMessages::EVT_POPUP) - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, text.c_str(), 0, atoi(timeout.c_str())); + ShowHint(LOCALE_MESSAGEBOX_INFO, text.c_str(), 0, atoi(timeout.c_str())); else if (msg == NeutrinoMessages::EVT_EXTMSG) ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO, 0, atoi(timeout.c_str())); @@ -3032,7 +3032,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) g_RCInput->postMsg(NeutrinoMessages::SHOW_INFOBAR , 0); } return messages_return::handled; -// ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EXTRA_ZAPIT_SDT_CHANGED), +// ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EXTRA_ZAPIT_SDT_CHANGED), // CMessageBox::mbrBack,CMessageBox::mbBack, NEUTRINO_ICON_INFO); } if ((msg >= CRCInput::RC_WithData) && (msg < CRCInput::RC_WithData + 0x10000000)) From 35830797d6db82f4f2f1e7b33b1e984aaec35262 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 22 Jan 2014 12:37:21 +0100 Subject: [PATCH 52/54] adapt ShowMsg handling from martii's neutrino-mp Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/53f5801d6f8b251b0c9ef0cc16a532852f1da961 Author: vanhofen Date: 2014-01-22 (Wed, 22 Jan 2014) Origin message was: ------------------ - adapt ShowMsg handling from martii's neutrino-mp ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/record.cpp | 8 ++--- src/gui/audioplayer.cpp | 2 +- src/gui/bedit/bouqueteditor_bouquets.cpp | 4 +-- src/gui/bedit/bouqueteditor_channels.cpp | 2 +- src/gui/channellist.cpp | 2 +- src/gui/epgplus.cpp | 4 +-- src/gui/epgview.cpp | 6 ++-- src/gui/eventlist.cpp | 6 ++-- src/gui/favorites.cpp | 6 ++-- src/gui/filebrowser.cpp | 2 +- src/gui/hdd_menu.cpp | 2 +- src/gui/keybind_setup.cpp | 2 +- src/gui/luainstance.cpp | 2 +- src/gui/miscsettings_menu.cpp | 2 +- src/gui/motorcontrol.cpp | 2 +- src/gui/moviebrowser.cpp | 26 ++++++++-------- src/gui/network_setup.cpp | 12 ++++---- src/gui/personalize.cpp | 4 +-- src/gui/pictureviewer.cpp | 2 +- src/gui/pluginlist.cpp | 4 +-- src/gui/rc_lock.cpp | 4 +-- src/gui/record_setup.cpp | 2 +- src/gui/scan.cpp | 2 +- src/gui/screensetup.cpp | 2 +- src/gui/settings_manager.cpp | 4 +-- src/gui/start_wizard.cpp | 4 +-- src/gui/test_menu.cpp | 24 +++++++-------- src/gui/themes.cpp | 2 +- src/gui/timerlist.cpp | 4 +-- src/gui/update.cpp | 24 +++++++-------- src/gui/update_ext.cpp | 6 ++-- src/gui/upnpbrowser.cpp | 6 ++-- src/gui/videosettings.cpp | 2 +- src/gui/widget/colorchooser.cpp | 2 +- src/gui/widget/messagebox.cpp | 38 +++++++++++++++--------- src/gui/widget/messagebox.h | 10 ++++--- src/gui/widget/stringinput.cpp | 2 +- src/gui/widget/stringinput_ext.cpp | 2 +- src/neutrino.cpp | 22 +++++++------- src/system/setting_helpers.cpp | 2 +- 40 files changed, 138 insertions(+), 126 deletions(-) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 13f796c28..f7aba8256 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1382,7 +1382,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey ) snprintf(rec_msg1, sizeof(rec_msg1)-1, "%s", g_Locale->getText(LOCALE_RECORDINGMENU_MULTIMENU_ASK_STOP_ALL)); snprintf(rec_msg, sizeof(rec_msg)-1, rec_msg1, records); - if(ShowMsgUTF(LOCALE_SHUTDOWN_RECODING_QUERY, rec_msg, + if(ShowMsg(LOCALE_SHUTDOWN_RECODING_QUERY, rec_msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { snprintf(rec_msg1, sizeof(rec_msg1)-1, "%s", g_Locale->getText(LOCALE_RECORDINGMENU_MULTIMENU_INFO_STOP_ALL)); @@ -1415,7 +1415,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey ) std::string title, duration; inst->GetRecordString(title, duration); title += duration; - tostart = (ShowMsgUTF(LOCALE_RECORDING_IS_RUNNING, title.c_str(), + tostart = (ShowMsg(LOCALE_RECORDING_IS_RUNNING, title.c_str(), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes); } if (tostart) { @@ -1569,7 +1569,7 @@ bool CRecordManager::AskToStop(const t_channel_id channel_id, const int recid) if(inst == NULL) return false; - if(ShowMsgUTF(LOCALE_SHUTDOWN_RECODING_QUERY, title.c_str(), + if(ShowMsg(LOCALE_SHUTDOWN_RECODING_QUERY, title.c_str(), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { #if 0 g_Timerd->stopTimerEvent(recording_id); @@ -1864,7 +1864,7 @@ bool CRecordManager::MountDirectory(const char *recordingDir) strcat(msg,"\nDir: "); strcat(msg,recordingDir); - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, msg, + ShowMsg(LOCALE_MESSAGEBOX_ERROR, msg, CMessageBox::mbrBack, CMessageBox::mbBack,NEUTRINO_ICON_ERROR, 450, 10); // UTF-8 ret = false; } diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index fbd81df70..8f082c969 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -2702,7 +2702,7 @@ bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename) "%s\n%s", g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_MSG), filename.c_str()); - bool res = (ShowMsgUTF(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE, + bool res = (ShowMsg(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE, msg,CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes); this->paint(); diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index e57b7c7c3..e8d112740 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -255,7 +255,7 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* { if (bouquetsChanged) { - int result = ShowLocalizedMessage(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMessageBox::mbrYes, CMessageBox::mbAll); + int result = ShowMsg(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMessageBox::mbrYes, CMessageBox::mbAll); switch( result ) { @@ -429,7 +429,7 @@ void CBEBouquetWidget::deleteBouquet() if (selected >= Bouquets->size()) /* Bouquets->size() might be 0 */ return; - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, (*Bouquets)[selected]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[selected]->Name, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Bouquets)[selected]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[selected]->Name, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) return; g_bouquetManager->deleteBouquet(selected); diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 24029c475..2095ceebb 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -447,7 +447,7 @@ void CBEChannelWidget::deleteChannel() if (selected >= Channels->size()) /* Channels.size() might be 0 */ return; - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, (*Channels)[selected]->getName(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Channels)[selected]->getName(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) return; g_bouquetManager->Bouquets[bouquet]->removeService((*Channels)[selected]->channel_id); diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index ac7141cc1..997e4a25c 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -383,7 +383,7 @@ int CChannelList::doChannelMenu(void) switch(select) { case 0: { hide(); - int result = ShowMsgUTF ( LOCALE_BOUQUETEDITOR_DELETE, g_Locale->getText(LOCALE_BOUQUETEDITOR_DELETE_QUESTION), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); + int result = ShowMsg ( LOCALE_BOUQUETEDITOR_DELETE, g_Locale->getText(LOCALE_BOUQUETEDITOR_DELETE_QUESTION), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); if(result == CMessageBox::mbrYes) { bouquet_id = bouquetList->getActiveBouquetNumber(); diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 670917254..9e899fe7b 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -1285,7 +1285,7 @@ int EpgPlus::MenuTargetAddReminder::exec (CMenuTarget * /*parent*/, const std::s if (g_Timerd->isTimerdAvailable()) { g_Timerd->addZaptoTimerEvent (this->epgPlus->selectedChannelEntry->channel->channel_id, (*It)->channelEvent.startTime - (g_settings.zapto_pre_time * 60), (*It)->channelEvent.startTime - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, (*It)->channelEvent.eventID, (*It)->channelEvent.startTime, 0); - ShowMsgUTF (LOCALE_TIMER_EVENTTIMED_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTTIMED_MSG) + ShowMsg (LOCALE_TIMER_EVENTTIMED_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTTIMED_MSG) , CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } else printf ("timerd not available\n"); @@ -1308,7 +1308,7 @@ int EpgPlus::MenuTargetAddRecordTimer::exec (CMenuTarget * /*parent*/, const std g_Timerd->addRecordTimerEvent (this->epgPlus->selectedChannelEntry->channel->channel_id, (*It)->channelEvent.startTime, (*It)->channelEvent.startTime + (*It)->channelEvent.duration, (*It)->channelEvent.eventID, (*It)->channelEvent.startTime, (*It)->channelEvent.startTime - (ANNOUNCETIME + 120) , TIMERD_APIDS_CONF, true); - ShowMsgUTF (LOCALE_TIMER_EVENTRECORD_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTRECORD_MSG) + ShowMsg (LOCALE_TIMER_EVENTRECORD_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTRECORD_MSG) , CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } else printf ("timerd not available\n"); diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index f90515da1..7e687d5d6 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -843,11 +843,11 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start epgData.eventID, epgData.epg_times.startzeit, epgData.epg_times.startzeit - (ANNOUNCETIME + 120 ), TIMERD_APIDS_CONF, true, recDir,true); - ShowLocalizedMessage(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } else { - ShowLocalizedMessage(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } @@ -867,7 +867,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start epgData.epg_times.startzeit - (g_settings.zapto_pre_time * 60), epgData.epg_times.startzeit - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, epgData.eventID, epgData.epg_times.startzeit, 0); - ShowLocalizedMessage(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } else diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index ae9816c14..7c808e6ba 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -493,13 +493,13 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c TIMERD_APIDS_CONF, true, recDir,true); //ask user whether the timer event should be set anyway - ShowLocalizedMessage(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } else { - //ShowLocalizedMessage(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + //ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } @@ -526,7 +526,7 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c evtlist[selected].startTime - (g_settings.zapto_pre_time * 60), evtlist[selected].startTime - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, evtlist[selected].eventID, evtlist[selected].startTime, 0); - //ShowLocalizedMessage(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + //ShowMsg(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(evtlist[selected].channelID ); diff --git a/src/gui/favorites.cpp b/src/gui/favorites.cpp index a6703fd27..c3d978f99 100644 --- a/src/gui/favorites.cpp +++ b/src/gui/favorites.cpp @@ -122,7 +122,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) #if 0 if (!bouquetList) { - ShowLocalizedMessage(LOCALE_FAVORITES_BOUQUETNAME, LOCALE_FAVORITES_NOBOUQUETS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, LOCALE_FAVORITES_NOBOUQUETS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return res; } #endif @@ -147,7 +147,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) { if (status & 2) str += g_Locale->getText(LOCALE_EXTRA_CHADDED); else str += g_Locale->getText(LOCALE_EXTRA_CHALREADYINBQ); - ShowMsgUTF(LOCALE_EXTRA_ADD_TO_BOUQUET, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_EXTRA_ADD_TO_BOUQUET, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } else { @@ -155,7 +155,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) if (status & 2) str += g_Locale->getText(LOCALE_FAVORITES_CHADDED); else str += g_Locale->getText(LOCALE_FAVORITES_CHALREADYINBQ); if (status) str += g_Locale->getText(LOCALE_FAVORITES_FINALHINT); - ShowMsgUTF(LOCALE_FAVORITES_BOUQUETNAME, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 2967377c4..0fb560727 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -932,7 +932,7 @@ bool CFileBrowser::exec(const char * const dirname) _msg << filelist[selected].getFileName(); _msg << " " << g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, _msg.str(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, _msg.str(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) { std::string n = filelist[selected].Name; recursiveDelete(n.c_str()); diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 5f8b7d6d6..f0459a8dc 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -356,7 +356,7 @@ int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key) printf("CHDDFmtExec: key %s\n", key.c_str()); - res = ShowMsgUTF ( LOCALE_HDD_FORMAT, g_Locale->getText(LOCALE_HDD_FORMAT_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); + res = ShowMsg ( LOCALE_HDD_FORMAT, g_Locale->getText(LOCALE_HDD_FORMAT_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); if(res != CMessageBox::mbrYes) return 0; diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index f41534c1f..08bd0ac0e 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -266,7 +266,7 @@ int CKeybindSetup::showKeySetup() strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART2)); strcat(RC_HW_msg, RC_HW_str[g_settings.remote_control_hardware]); strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART3)); - if(ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, RC_HW_msg, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 450, 15, true) == CMessageBox::mbrNo) { + if(ShowMsg(LOCALE_MESSAGEBOX_INFO, RC_HW_msg, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 450, 15, true) == CMessageBox::mbrNo) { g_settings.remote_control_hardware = org_remote_control_hardware; g_RCInput->CRCInput::set_rc_hw(); } diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 09fb48f9d..39cdcd8ca 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1271,7 +1271,7 @@ int CLuaInstance::MessageboxExec(lua_State *L) } } - int res = ShowMsgUTF(name, text, (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); + int res = ShowMsg(name, text, (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); tmp = "cancel"; for (int i = 0; mbr[i].name; i++) diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index ba38027e2..0ad001558 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -125,7 +125,7 @@ int CMiscMenue::exec(CMenuTarget* parent, const std::string &actionKey) unsigned num = CEitManager::getInstance()->getEventsCount(); char str[128]; sprintf(str, "Event count: %d", num); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack); return menu_return::RETURN_REPAINT; } else if(actionKey == "energy") diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index fbe2581bc..954aad025 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -223,7 +223,7 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) buf += " "; buf += satname; buf += " ?"; - store = (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); + store = (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); } } if(store) diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index eff2d9506..013d750fc 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1836,7 +1836,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) char buf1[1024]; memset(buf1, '\0', sizeof(buf1)); snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_MOVIEBROWSER_ASK_REC_TO_DELETE), delName.c_str()); - if(ShowMsgUTF(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, + if(ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) onDelete = false; else { @@ -1872,7 +1872,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) } else if (msg == CRCInput::RC_text || msg == CRCInput::RC_radio) { if((show_mode == MB_SHOW_RECORDS) && - (ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, msg == CRCInput::RC_radio ? "Copy jumps from movie to new file ?" : "Copy jumps from movie to new files ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) { + (ShowMsg (LOCALE_MESSAGEBOX_INFO, msg == CRCInput::RC_radio ? "Copy jumps from movie to new file ?" : "Copy jumps from movie to new files ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Coping, please wait"); hintBox->paint(); sleep(1); @@ -1882,7 +1882,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) off64_t res = copy_movie(m_movieSelectionHandler, &m_movieInfo, msg == CRCInput::RC_radio); //g_RCInput->clearRCMsg(); if(res == 0) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Copy failed, is there jump bookmarks ? Or check free space.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Copy failed, is there jump bookmarks ? Or check free space.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else loadMovies(); refresh(); @@ -1891,11 +1891,11 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) else if (msg == CRCInput::RC_audio) { #if 0 if((m_movieSelectionHandler == playing_info) && (NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode())) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Impossible to cut playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Impossible to cut playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else #endif if((show_mode == MB_SHOW_RECORDS) && - (ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, "Cut jumps from movie ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) { + (ShowMsg (LOCALE_MESSAGEBOX_INFO, "Cut jumps from movie ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Cutting, please wait"); hintBox->paint(); sleep(1); @@ -1905,7 +1905,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) off64_t res = cut_movie(m_movieSelectionHandler, &m_movieInfo); //g_RCInput->clearRCMsg(); if(res == 0) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Cut failed, is there jump bookmarks ? Or check free space.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Cut failed, is there jump bookmarks ? Or check free space.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else { loadMovies(); } @@ -1915,11 +1915,11 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) else if (msg == CRCInput::RC_games) { if((show_mode == MB_SHOW_RECORDS) && m_movieSelectionHandler != NULL) { if((m_movieSelectionHandler == playing_info) && (NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode())) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Impossible to truncate playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Impossible to truncate playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else if(m_movieSelectionHandler->bookmarks.end == 0) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "No End bookmark defined!", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "No End bookmark defined!", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else { - if(ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, "Truncate movie ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if(ShowMsg (LOCALE_MESSAGEBOX_INFO, "Truncate movie ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Truncating, please wait"); hintBox->paint(); off64_t res = truncate_movie(m_movieSelectionHandler); @@ -1927,7 +1927,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) delete hintBox; g_RCInput->clearRCMsg(); if(res == 0) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Truncate failed.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Truncate failed.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else { //printf("New movie info: size %lld len %d\n", res, m_movieSelectionHandler->bookmarks.end/60); m_movieInfo.saveMovieInfo( *m_movieSelectionHandler); @@ -1939,7 +1939,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) } } else if (msg == CRCInput::RC_topleft) { if (m_movieSelectionHandler != NULL) { - if(ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, "Remove screenshot ?", CMessageBox::mbrNo, CMessageBox:: mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if(ShowMsg (LOCALE_MESSAGEBOX_INFO, "Remove screenshot ?", CMessageBox::mbrNo, CMessageBox:: mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { std::string fname = getScreenshotName(m_movieSelectionHandler->file.Name); if (fname != "") unlink(fname.c_str()); @@ -2185,7 +2185,7 @@ void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skip msg += "\r\n "; msg += g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); - if ((skipAsk) || (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes)) + if ((skipAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO)); hintBox->paint(); @@ -4338,7 +4338,7 @@ static int get_input(bool * stop) * stop = false; g_RCInput->getMsg(&msg, &data, 1, false); if(msg == CRCInput::RC_home) { - if(ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, "Cancel movie cut/split ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if(ShowMsg (LOCALE_MESSAGEBOX_INFO, "Cancel movie cut/split ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { * stop = true; } } diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index cb834807b..fbd91f73e 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -127,7 +127,7 @@ int CNetworkSetup::exec(CMenuTarget* parent, const std::string &actionKey) } else if(actionKey=="restore") { - int result = ShowMsgUTF(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_RESET_SETTINGS_NOW), CMessageBox::mbrNo, + int result = ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_RESET_SETTINGS_NOW), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo , NEUTRINO_ICON_QUESTION, @@ -535,7 +535,7 @@ bool CNetworkSetup::checkForIP() printf("[network setup] empty address %s\n", g_Locale->getText(n_settings[i].addr_name)); char msg[64]; snprintf(msg, 64, g_Locale->getText(LOCALE_NETWORKMENU_ERROR_NO_ADDRESS), g_Locale->getText(n_settings[i].addr_name)); - ShowMsgUTF(LOCALE_MAINSETTINGS_NETWORK, msg, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR, width); + ShowMsg(LOCALE_MAINSETTINGS_NETWORK, msg, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR, width); return false; } } @@ -578,7 +578,7 @@ void CNetworkSetup::applyNetworkSettings() int CNetworkSetup::saveChangesDialog() { // Save the settings after changes, if user wants to! - int result = ShowMsgUTF(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_APPLY_SETTINGS_NOW), CMessageBox::mbrYes, + int result = ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_APPLY_SETTINGS_NOW), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo , NEUTRINO_ICON_QUESTION, @@ -696,7 +696,7 @@ void CNetworkSetup::showCurrentNetworkSettings() + g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ": " + nameserver + '\n' + g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY ) + ": " + router; } - ShowMsgUTF(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 } const char * CNetworkSetup::mypinghost(std::string &host) @@ -792,7 +792,7 @@ void CNetworkSetup::testNetworkSettings() } } - ShowMsgUTF(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 } int CNetworkSetup::showWlanList() @@ -806,7 +806,7 @@ int CNetworkSetup::showWlanList() bool found = get_wlan_list(g_settings.ifname, networks); hintBox.hide(); if (!found) { - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_NETWORKMENU_SSID_SCAN_ERROR), CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_NETWORKMENU_SSID_SCAN_ERROR), CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 return res; } diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index b8098cbf5..f8c9b2584 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -649,7 +649,7 @@ void CPersonalizeGui::SaveAndExit() ApplySettings(); return; } - if (ShowMsgUTF(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_PERSONALIZE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_PERSONALIZE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) { CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MAINSETTINGS_SAVESETTINGSNOW_HINT)); // UTF-8 hintBox.paint(); @@ -658,7 +658,7 @@ void CPersonalizeGui::SaveAndExit() } else { - if (ShowMsgUTF(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_MESSAGEBOX_DISCARD), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_MESSAGEBOX_DISCARD), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) exec(NULL, "restore"); } } diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index f491d67a3..99b8ae043 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -842,7 +842,7 @@ void CPictureViewerGui::endView() void CPictureViewerGui::deletePicFile(unsigned int index, bool mode) { CVFD::getInstance()->showMenuText(0, playlist[index].Name.c_str()); - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, playlist[index].Filename, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, playlist[index].Filename, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) { unlink(playlist[index].Filename.c_str()); printf("[ %s ] delete file: %s\r\n",__FUNCTION__,playlist[index].Filename.c_str()); diff --git a/src/gui/pluginlist.cpp b/src/gui/pluginlist.cpp index 6d0c5f1c1..3855d78fb 100644 --- a/src/gui/pluginlist.cpp +++ b/src/gui/pluginlist.cpp @@ -360,8 +360,8 @@ CPluginList::result_ CPluginList::pluginSelected() if (!g_PluginList->getScriptOutput().empty()) { hide(); - //ShowMsgUTF(LOCALE_PLUGINS_RESULT, Latin1_to_UTF8(g_PluginList->getScriptOutput()), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); - ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + //ShowMsg(LOCALE_PLUGINS_RESULT, Latin1_to_UTF8(g_PluginList->getScriptOutput()), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); } paint(); return resume; diff --git a/src/gui/rc_lock.cpp b/src/gui/rc_lock.cpp index 2b7177692..f8ee6b28a 100644 --- a/src/gui/rc_lock.cpp +++ b/src/gui/rc_lock.cpp @@ -53,7 +53,7 @@ int CRCLock::exec(CMenuTarget* parent, const std::string &actionKey) parent->hide(); bool no_input = (actionKey == NO_USER_INPUT); - if (ShowLocalizedMessage(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_LOCKMSG, + if (ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_LOCKMSG, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel, NEUTRINO_ICON_INFO,450,no_input ? 5 : -1,no_input) == CMessageBox::mbrCancel) return menu_return::RETURN_EXIT_ALL; @@ -63,7 +63,7 @@ int CRCLock::exec(CMenuTarget* parent, const std::string &actionKey) lockBox(); locked = false; - ShowLocalizedMessage(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_UNLOCKMSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO,450, no_input ? 5 : -1); + ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_UNLOCKMSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO,450, no_input ? 5 : -1); return menu_return::RETURN_EXIT_ALL; } diff --git a/src/gui/record_setup.cpp b/src/gui/record_setup.cpp index 97812d6d7..207b6ea94 100644 --- a/src/gui/record_setup.cpp +++ b/src/gui/record_setup.cpp @@ -83,7 +83,7 @@ int CRecordSetup::exec(CMenuTarget* parent, const std::string &actionKey) } else if(actionKey == "help_recording") { - ShowLocalizedMessage(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); return res; } else if(actionKey == "recordingdir") diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index d0f0493d8..f7d9baa9e 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -307,7 +307,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) else if(msg == CRCInput::RC_home) { if(manual && !scansettings.scan_nit_manual) continue; - if (ShowLocalizedMessage(LOCALE_SCANTS_ABORT_HEADER, LOCALE_SCANTS_ABORT_BODY, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if (ShowMsg(LOCALE_SCANTS_ABORT_HEADER, LOCALE_SCANTS_ABORT_BODY, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { g_Zapit->stopScan(); } } diff --git a/src/gui/screensetup.cpp b/src/gui/screensetup.cpp index b1662e478..6e98f1409 100644 --- a/src/gui/screensetup.cpp +++ b/src/gui/screensetup.cpp @@ -135,7 +135,7 @@ int CScreenSetup::exec(CMenuTarget* parent, const std::string &) ( g_settings.screen_EndX != x_coord[1] ) || ( g_settings.screen_StartY != y_coord[0] ) || ( g_settings.screen_EndY != y_coord[1] ) ) && - (ShowLocalizedMessage(LOCALE_VIDEOMENU_SCREENSETUP, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) + (ShowMsg(LOCALE_VIDEOMENU_SCREENSETUP, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) break; case CRCInput::RC_timeout: diff --git a/src/gui/settings_manager.cpp b/src/gui/settings_manager.cpp index 46ef84f34..c7ed3990d 100644 --- a/src/gui/settings_manager.cpp +++ b/src/gui/settings_manager.cpp @@ -112,7 +112,7 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) my_system(2, backup_sh, fileBrowser.getSelectedFile()->Name.c_str()); } else - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR); } return res; } @@ -122,7 +122,7 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) fileBrowser.Filter = &fileFilter; if (fileBrowser.exec("/media") == true) { - int result = ShowMsgUTF(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); + int result = ShowMsg(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); if(result == CMessageBox::mbrYes) { const char restore_sh[] = "/bin/restore.sh"; diff --git a/src/gui/start_wizard.cpp b/src/gui/start_wizard.cpp index 827781abf..56d544b0a 100644 --- a/src/gui/start_wizard.cpp +++ b/src/gui/start_wizard.cpp @@ -90,7 +90,7 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) languageSettings.showLanguageSetup(&osdl_setup); osdl_setup.exec(NULL, ""); - if(ShowMsgUTF (LOCALE_WIZARD_WELCOME_HEAD, g_Locale->getText(LOCALE_WIZARD_WELCOME_TEXT), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbrCancel) == CMessageBox::mbrYes) + if(ShowMsg (LOCALE_WIZARD_WELCOME_HEAD, g_Locale->getText(LOCALE_WIZARD_WELCOME_TEXT), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbrCancel) == CMessageBox::mbrYes) { int advanced = 1; #ifdef ENABLE_FASTSCAN @@ -129,7 +129,7 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) if(advanced && init_settings && (res != menu_return::RETURN_EXIT_ALL)) { - if (ShowMsgUTF(LOCALE_WIZARD_INITIAL_SETTINGS, g_Locale->getText(LOCALE_WIZARD_INSTALL_SETTINGS), + if (ShowMsg(LOCALE_WIZARD_INITIAL_SETTINGS, g_Locale->getText(LOCALE_WIZARD_INSTALL_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { system("/bin/cp " CONFIGDIR "/initial/* " CONFIGDIR "/zapit/"); CFEManager::getInstance()->loadSettings(); diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 4c50d7e83..ef833b272 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -133,7 +133,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) text[12*len] = 0; CVFD::getInstance()->ShowText(text); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "VFD test, Press OK to return", CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "VFD test, Press OK to return", CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); CVFD::getInstance()->Clear(); return res; @@ -173,7 +173,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) close(fd); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return res; } @@ -184,17 +184,17 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) switch(ret) { case 0: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); break; case -1: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; case -2: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; default: case -3: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; } @@ -207,17 +207,17 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) switch(ret) { case 0: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); break; case -1: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; case -2: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; default: case -3: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; } @@ -240,7 +240,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) sprintf(buffer, "HDD: /dev/sda1 is %s", mounted ? "mounted" : "NOT mounted"); printf("%s\n", buffer); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return res; } @@ -261,7 +261,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) sprintf(buffer, "MMC: /dev/mmcblk0p1 is %s", mounted ? "mounted" : "NOT mounted"); printf("%s\n", buffer); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return res; } diff --git a/src/gui/themes.cpp b/src/gui/themes.cpp index 64644e555..4f864b1ba 100644 --- a/src/gui/themes.cpp +++ b/src/gui/themes.cpp @@ -180,7 +180,7 @@ int CThemes::Show() } if (hasThemeChanged) { - if (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes) rememberOldTheme( false ); else hasThemeChanged = false; diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index d3b42a66f..90e530189 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -598,7 +598,7 @@ int CTimerList::show() if (epgdata.title != "") title = "(" + epgdata.title + ")\n"; snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_TIMERLIST_ASK_TO_DELETE), title.c_str()); - if(ShowMsgUTF(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, + if(ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) { killTimer = false; update = false; @@ -1313,7 +1313,7 @@ bool askUserOnTimerConflict(time_t announceTime, time_t stopTime) // todo: localize message //g_Locale->getText(TIMERLIST_OVERLAPPING_MESSAGE); - return (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO,timerbuf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); + return (ShowMsg(LOCALE_MESSAGEBOX_INFO,timerbuf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); } else return true; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 4e3ee8b91..de2948901 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -243,13 +243,13 @@ bool CFlashUpdate::selectHttpImage(void) if (urls.empty()) { - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR), CMessageBox::mbrOk, CMessageBox::mbOk); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR), CMessageBox::mbrOk, CMessageBox::mbOk); // UTF-8 return false; } if(newfound) - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_FOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_FOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); else - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_NOTFOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_NOTFOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); menu_ret = SelectionWidget.exec(NULL, ""); @@ -329,7 +329,7 @@ printf("[update] mode is %d\n", softupdate_mode); if(fileType < '3') { if ((strncmp(RELEASE_CYCLE, versionInfo->getReleaseCycle(), 2) != 0) && - (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) + (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) { delete versionInfo; //ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE)); // UTF-8 @@ -337,8 +337,8 @@ printf("[update] mode is %d\n", softupdate_mode); } if ((strcmp("Release", versionInfo->getType()) != 0) && - //(ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) // UTF-8 - (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) + //(ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) // UTF-8 + (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) { delete versionInfo; return false; @@ -397,7 +397,7 @@ printf("[update] mode is %d\n", softupdate_mode); strcpy(msg, g_Locale->getText(LOCALE_FLASHUPDATE_NOVERSION)); msg_body = LOCALE_FLASHUPDATE_MSGBOX_MANUAL; } - return (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes); // UTF-8 + return (ShowMsg(LOCALE_MESSAGEBOX_INFO, msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes); // UTF-8 } int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) @@ -461,7 +461,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) return menu_return::RETURN_REPAINT; } if(softupdate_mode==1) { //internet-update - if ( ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, (fileType < '3') ? "Flash downloaded image ?" : "Install downloaded pack ?", CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 + if ( ShowMsg(LOCALE_MESSAGEBOX_INFO, (fileType < '3') ? "Flash downloaded image ?" : "Install downloaded pack ?", CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 { hide(); return menu_return::RETURN_REPAINT; @@ -477,7 +477,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) //flash it... #ifndef BOXMODEL_APOLLO if (g_settings.apply_settings) { - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes) if (!CExtUpdate::getInstance()->applySettings(filename, CExtUpdate::MODE_SOFTUPDATE)) { hide(); return menu_return::RETURN_REPAINT; @@ -514,7 +514,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) fread(buffer, (uint32_t)filesize, 1, fd); fclose(fd); buffer[filesize] = 0; - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 free(buffer); } } @@ -762,7 +762,7 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber) FILESYSTEM_ENCODING_TO_UTF8_STRING(filename).c_str(), CMTDInfo::getInstance()->getMTDName(mtdNumber).c_str()); - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 return; #ifdef VFD_UPDATE CVFD::getInstance()->showProgressBar2(0,"checking",0,"Update Neutrino"); @@ -949,7 +949,7 @@ int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey) // create image warning const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank"; snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_WARNING), box, box); - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) skipImage = true; } if (!skipImage) { diff --git a/src/gui/update_ext.cpp b/src/gui/update_ext.cpp index f8cc39f7c..06b107b5f 100644 --- a/src/gui/update_ext.cpp +++ b/src/gui/update_ext.cpp @@ -549,7 +549,7 @@ bool CExtUpdate::checkSpecialFolders(std::string line, bool copy) neutrino_locale_t msg = (copy) ? LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED : LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED; snprintf(buf, sizeof(buf), g_Locale->getText(msg), line.c_str()); WRITE_UPDATE_LOG("%s%s", buf, "\n"); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buf, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); return true; } return false; @@ -719,13 +719,13 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) memset(buf1, '\0', sizeof(buf1)); if (free3 <= flashError) { snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR), free3, total); - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, buf1, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, buf1, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR); flashErrorFlag = true; return false; } else if (free3 <= flashWarning) { snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING), free3, total); - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { flashErrorFlag = true; return false; } diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index c240b85cb..9486289eb 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -202,13 +202,13 @@ bool CUpnpBrowserGui::discoverDevices() catch (std::runtime_error error) { delete scanBox; - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return false; } delete scanBox; if (m_devices.empty()) { - ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_UPNPBROWSER_NOSERVERS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_UPNPBROWSER_NOSERVERS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return false; } return true; @@ -236,7 +236,7 @@ bool CUpnpBrowserGui::getResults(std::string id, unsigned int start, unsigned in } catch (std::runtime_error error) { - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return false; } return true; diff --git a/src/gui/videosettings.cpp b/src/gui/videosettings.cpp index 60a3d8329..7be331eba 100644 --- a/src/gui/videosettings.cpp +++ b/src/gui/videosettings.cpp @@ -394,7 +394,7 @@ void CVideoSettings::setupVideoSystem(bool do_ask) if (prev_video_mode != g_settings.video_Mode) { frameBuffer->paintBackground(); - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_VIDEO_MODE_OK), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_VIDEO_MODE_OK), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { g_settings.video_Mode = prev_video_mode; videoDecoder->SetVideoSystem(g_settings.video_Mode); diff --git a/src/gui/widget/colorchooser.cpp b/src/gui/widget/colorchooser.cpp index 4269fc328..758cce4a7 100644 --- a/src/gui/widget/colorchooser.cpp +++ b/src/gui/widget/colorchooser.cpp @@ -201,7 +201,7 @@ int CColorChooser::exec(CMenuTarget* parent, const std::string &) } case CRCInput::RC_home: if (((*value[VALUE_R] != r_alt) || (*value[VALUE_G] != g_alt) || (*value[VALUE_B] != b_alt) || ((value[VALUE_ALPHA]) && (*(value[VALUE_ALPHA]) != a_alt))) && - (ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) + (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) break; // sonst abbruch... diff --git a/src/gui/widget/messagebox.cpp b/src/gui/widget/messagebox.cpp index 5e8d3e5c6..cb88930de 100644 --- a/src/gui/widget/messagebox.cpp +++ b/src/gui/widget/messagebox.cpp @@ -287,7 +287,18 @@ int CMessageBox::exec(int timeout) return res; } -int ShowMsgUTF(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +{ + CMessageBox* messageBox = new CMessageBox(Caption, Text, Width, Icon, Default, ShowButtons); + messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout); + messageBox->exec(timeout); + int res = messageBox->result; + delete messageBox; + + return res; +} + +int ShowMsg(const std::string &Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) { CMessageBox* messageBox = new CMessageBox(Caption, Text, Width, Icon, Default, ShowButtons); messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout); @@ -298,33 +309,32 @@ int ShowMsgUTF(const neutrino_locale_t Caption, const char * const Text, const C return res; } -int ShowLocalizedMessage(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +int ShowMsg(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) { - return ShowMsgUTF(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); + return ShowMsg(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout, returnDefaultOnTimeout); } -int ShowMsgUTF(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +int ShowMsg(const std::string &Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) { - return ShowMsgUTF(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); + return ShowMsg(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout, returnDefaultOnTimeout); } -int ShowMsgUTF(const std::string & Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +int ShowMsg(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) { - CMessageBox* messageBox = new CMessageBox(Caption, Text.c_str(), Width, Icon, Default, ShowButtons); - messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout); - messageBox->exec(timeout); - int res = messageBox->result; - delete messageBox; + return ShowMsg(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); +} - return res; +int ShowMsg(const std::string &Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +{ + return ShowMsg(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); } void DisplayErrorMessage(const char * const ErrorMsg) { - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); } void DisplayInfoMessage(const char * const ErrorMsg) { - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, ErrorMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, ErrorMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); } diff --git a/src/gui/widget/messagebox.h b/src/gui/widget/messagebox.h index 2fac497e2..9c63d70bc 100644 --- a/src/gui/widget/messagebox.h +++ b/src/gui/widget/messagebox.h @@ -100,10 +100,12 @@ class CMessageBox : public CHintBoxExt }; // Text is always UTF-8 encoded -int ShowLocalizedMessage(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); -int ShowMsgUTF(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 -int ShowMsgUTF(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 -int ShowMsgUTF(const std::string & Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const std::string &Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const std::string &Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const std::string &Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 void DisplayErrorMessage(const char * const ErrorMsg); // UTF-8 void DisplayInfoMessage(const char * const InfoMsg); // UTF-8 diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index c7f0970e0..04e2b769c 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -483,7 +483,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { if ((*valueString != oldval) && - (ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) + (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) continue; *valueString = oldval; diff --git a/src/gui/widget/stringinput_ext.cpp b/src/gui/widget/stringinput_ext.cpp index 56f8410dd..82abac222 100644 --- a/src/gui/widget/stringinput_ext.cpp +++ b/src/gui/widget/stringinput_ext.cpp @@ -233,7 +233,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { if(*valueString != oldval){ - int erg = ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbNo | CMessageBox::mbYes | CMessageBox::mbCancel); + int erg = ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbNo | CMessageBox::mbYes | CMessageBox::mbCancel); if(erg==CMessageBox::mbrYes){ *valueString = oldval; loop=false; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f58b548ae..2761eec41 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -1858,7 +1858,7 @@ TIMER_START(); /* later on, we'll crash anyway, so tell about it. */ if (! zapit_init) - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Zapit initialization failed.\nThis is a fatal error, sorry.", CMessageBox::mbrBack, CMessageBox::mbBack); @@ -2054,7 +2054,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) g_PluginList->startPlugin("startup.cfg"); if (!g_PluginList->getScriptOutput().empty()) { - ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); } g_RCInput->clearRCMsg(); @@ -2854,13 +2854,13 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } else if( msg == NeutrinoMessages::ANNOUNCE_SLEEPTIMER) { if( mode != mode_scart && mode != mode_standby) - skipSleepTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); + skipSleepTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); return messages_return::handled; } else if( msg == NeutrinoMessages::SLEEPTIMER) { if(data) {//INACTIVITY SLEEPTIMER skipShutdownTimer = - (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE, + (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);//FIXME if(skipShutdownTimer) { printf("NeutrinoMessages::INACTIVITY SLEEPTIMER: skiping\n"); @@ -2909,7 +2909,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } else if( msg == NeutrinoMessages::ANNOUNCE_SHUTDOWN) { if( mode != mode_scart ) - skipShutdownTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 5) == CMessageBox::mbrYes); + skipShutdownTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 5) == CMessageBox::mbrYes); } else if( msg == NeutrinoMessages::SHUTDOWN ) { if(!skipShutdownTimer) { @@ -2940,7 +2940,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) if (msg == NeutrinoMessages::EVT_POPUP) ShowHint(LOCALE_MESSAGEBOX_INFO, text.c_str(), 0, atoi(timeout.c_str())); else if (msg == NeutrinoMessages::EVT_EXTMSG) - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO, 0, atoi(timeout.c_str())); + ShowMsg(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO, 0, atoi(timeout.c_str())); } delete[] (unsigned char*) data; @@ -2962,7 +2962,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) text[pos] = '\n'; } if( mode != mode_scart ) - ShowMsgUTF(LOCALE_TIMERLIST_TYPE_REMIND, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_TIMERLIST_TYPE_REMIND, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 delete[] (unsigned char*) data; return messages_return::handled; } @@ -3019,7 +3019,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) else if (msg == NeutrinoMessages::EVT_START_PLUGIN) { g_PluginList->startPlugin((const char *)data); if (!g_PluginList->getScriptOutput().empty()) { - ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); } delete[] (unsigned char*) data; @@ -3051,7 +3051,7 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode) CRecordManager::getInstance()->StopAutoRecord(); if(CRecordManager::getInstance()->RecordingStatus()) { do_shutdown = - (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECODING_QUERY, CMessageBox::mbrNo, + (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECODING_QUERY, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); } @@ -3504,7 +3504,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) int returnval = menu_return::RETURN_REPAINT; if(actionKey == "help_recording") { - ShowLocalizedMessage(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); } else if(actionKey=="shutdown") { ExitRun(true, 1); @@ -3647,7 +3647,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) g_settings.easymenu = (g_settings.easymenu == 0) ? 1 : 0; INFO("change easymenu to %d\n", g_settings.easymenu); const char * text = g_settings.easymenu ? "Easy menu switched ON, restart box ?" : "Easy menu switched OFF, restart box ?"; - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 0) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 0) == CMessageBox::mbrYes) g_RCInput->postMsg(NeutrinoMessages::REBOOT, 0); } } diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 8ffd94536..e94306ecd 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -526,7 +526,7 @@ int CDataResetNotifier::exec(CMenuTarget* /*parent*/, const std::string& actionK /* no need to confirm if we only remove deleted channels */ if (!delete_removed) { - int result = ShowMsgUTF(msg, g_Locale->getText(LOCALE_RESET_CONFIRM), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); + int result = ShowMsg(msg, g_Locale->getText(LOCALE_RESET_CONFIRM), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); if (result != CMessageBox::mbrYes) return true; } From 42c5e747a872a83049910fa3db1cd46c3bef6825 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 23 Jan 2014 12:24:33 +0400 Subject: [PATCH 53/54] cross-configure.apollo.debug: enable ffmpegdec and lua Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/40408c82cdbd6e3b9a285a44ca1626e45af401cc Author: [CST] Focus Date: 2014-01-23 (Thu, 23 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- cross-configure.apollo.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-configure.apollo.debug b/cross-configure.apollo.debug index 4d7e066fe..de760d9fd 100755 --- a/cross-configure.apollo.debug +++ b/cross-configure.apollo.debug @@ -29,5 +29,5 @@ export FREETYPE_CONFIG=$PREFIX/bin/freetype-config export CURL_CONFIG=$PREFIX/bin/curl-config ./autogen.sh -./configure --prefix=${PREFIX} --build=i386-pc-linux-gnu --host=$HOST --enable-flac --with-target=cdk --with-targetprefix="" --with-boxmodel=apollo --enable-mdev "$@" +./configure --prefix=${PREFIX} --build=i386-pc-linux-gnu --host=$HOST --enable-flac --with-target=cdk --with-targetprefix="" --with-boxmodel=apollo --enable-mdev --enable-pip --enable-ffmpegdec --enable-lua "$@" From d6ae5d04531d0df612ebfb156afe2f8812ba1f3c Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 23 Jan 2014 12:25:52 +0400 Subject: [PATCH 54/54] driver/vfd.cpp: init timeout_cnt, to fix random vfd dimm Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3ad7175c457fe9ba5ba3fdba3da9c5ba7686dea5 Author: [CST] Focus Date: 2014-01-23 (Thu, 23 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/vfd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/driver/vfd.cpp b/src/driver/vfd.cpp index d6bb4d5b6..8072f0bf3 100644 --- a/src/driver/vfd.cpp +++ b/src/driver/vfd.cpp @@ -72,6 +72,7 @@ CVFD::CVFD() clearClock = 0; mode = MODE_TVRADIO; switch_name_time_cnt = 0; + timeout_cnt = 0; } CVFD::~CVFD()