diff --git a/src/gui/ni_menu.cpp b/src/gui/ni_menu.cpp index 45a7f2ba7..d574d54d3 100644 --- a/src/gui/ni_menu.cpp +++ b/src/gui/ni_menu.cpp @@ -39,15 +39,14 @@ #include #include #include -#include #include #include #include -#include #include #include +#include #include @@ -126,7 +125,6 @@ int CNIMenu::exec(CMenuTarget* parent, const std::string &actionkey) ssize_t read; size_t len; FILE *fh; - std::ostringstream buf; if (parent) parent->hide(); @@ -136,12 +134,9 @@ int CNIMenu::exec(CMenuTarget* parent, const std::string &actionkey) CHintBox hintbox(LOCALE_CAMD_CONTROL, g_Locale->getText(LOCALE_CAMD_MSG_RESET)); hintbox.paint(); - buf.str(""); - buf << EMU_START_SCRIPT << " restart"; - - printf("[ni_menu.cpp] executing %s\n", buf.str().c_str()); - if (my_system(2, EMU_START_SCRIPT, "restart") != 0) - printf("[ni_menu.cpp] executing %s failed\n", buf.str().c_str()); + printf("[ni_menu.cpp] executing \"service emu restart\"\n"); + if (my_system(3, "service", "emu", "restart") != 0) + printf("[ni_menu.cpp] executing failed\n"); sleep(1); hintbox.hide(); @@ -203,127 +198,6 @@ bool CNIMenu::changeNotify(const neutrino_locale_t OptionName, void * /*data*/) } #endif -bool CNITouchFileNotifier::changeNotify(const neutrino_locale_t, void * data) -{ - std::ostringstream buf; - - buf << FLAGDIR << "/." << filename; - std::string flag = buf.str(); - - if ((*(int *)data) != 0) - { - FILE * fd = fopen(flag.c_str(), "w"); - if (fd) - { - fclose(fd); - if (strstr(filename, "scart_osd_fix")) - { - //change to scart-osd-fix values - g_settings.screen_StartX_crt_0 = 29; - g_settings.screen_StartY_crt_0 = 43; - g_settings.screen_EndX_crt_0 = 693; - g_settings.screen_EndY_crt_0 = 535; - g_settings.screen_preset = 0; - - //set values - g_settings.screen_StartX = g_settings.screen_preset ? g_settings.screen_StartX_lcd_0 : g_settings.screen_StartX_crt_0; - g_settings.screen_StartY = g_settings.screen_preset ? g_settings.screen_StartY_lcd_0 : g_settings.screen_StartY_crt_0; - g_settings.screen_EndX = g_settings.screen_preset ? g_settings.screen_EndX_lcd_0 : g_settings.screen_EndX_crt_0; - g_settings.screen_EndY = g_settings.screen_preset ? g_settings.screen_EndY_lcd_0 : g_settings.screen_EndY_crt_0; - - CFrameBuffer::getInstance()->Clear(); - - g_settings.font_scaling_x = 100; - g_settings.font_scaling_y = 100; - } - else if (strstr(filename, "mgcamd") || - strstr(filename, "newcs") || - strstr(filename, "osemu") || - strstr(filename, "doscam") || - strstr(filename, "ncam") || - strstr(filename, "oscam") || - strstr(filename, "cs2gbox") || - strstr(filename, "gbox")) - { - CHintBox hintbox(LOCALE_CAMD_CONTROL, g_Locale->getText(LOCALE_CAMD_MSG_START)); - hintbox.paint(); - - buf.str(""); - buf << EMU_START_SCRIPT << " start " << filename; - - printf("[ni_menu.cpp] executing %s\n", buf.str().c_str()); - if (my_system(3, EMU_START_SCRIPT, "start", filename) != 0) - printf("[ni_menu.cpp] executing %s failed\n", buf.str().c_str()); - sleep(1); - - hintbox.hide(); - } - else - { - buf.str(""); - buf << "service " << filename << " start"; - printf("[ni_menu.cpp] executing %s\n", buf.str().c_str()); - - if (my_system(3, "service", filename, "start") != 0) - printf("[ni_menu.cpp] executing %s failed\n", buf.str().c_str()); - } - } - } - else - { - buf.str(""); - if (strstr(filename, "scart_osd_fix")) - { - //reset to defaults - g_settings.screen_StartX_crt_0 = 60; - g_settings.screen_StartY_crt_0 = 20; - g_settings.screen_EndX_crt_0 = 1220; - g_settings.screen_EndY_crt_0 = 560; - - //set values - g_settings.screen_StartX = g_settings.screen_preset ? g_settings.screen_StartX_lcd_0 : g_settings.screen_StartX_crt_0; - g_settings.screen_StartY = g_settings.screen_preset ? g_settings.screen_StartY_lcd_0 : g_settings.screen_StartY_crt_0; - g_settings.screen_EndX = g_settings.screen_preset ? g_settings.screen_EndX_lcd_0 : g_settings.screen_EndX_crt_0; - g_settings.screen_EndY = g_settings.screen_preset ? g_settings.screen_EndY_lcd_0 : g_settings.screen_EndY_crt_0; - - CFrameBuffer::getInstance()->Clear(); - - g_settings.font_scaling_x = 105; - g_settings.font_scaling_y = 105; - } - else if (strstr(filename, "mgcamd") || - strstr(filename, "newcs") || - strstr(filename, "osemu") || - strstr(filename, "doscam") || - strstr(filename, "ncam") || - strstr(filename, "oscam") || - strstr(filename, "cs2gbox") || - strstr(filename, "gbox")) - { - CHintBox hintbox(LOCALE_CAMD_CONTROL, g_Locale->getText(LOCALE_CAMD_MSG_STOP)); - hintbox.paint(); - - buf << EMU_START_SCRIPT << " stop " << filename; - printf("[ni_menu.cpp] executing %s\n", buf.str().c_str()); - if (my_system(3, EMU_START_SCRIPT, "stop", filename) != 0) - printf("[ni_menu.cpp] executing %s failed\n", buf.str().c_str()); - sleep(1); - - hintbox.hide(); - } - else - { - buf << "service " << filename << " stop"; - printf("[ni_menu.cpp] executing %s\n", buf.str().c_str()); - - if (my_system(3, "service", filename, "stop") != 0) - printf("[ni_menu.cpp] executing %s failed\n", buf.str().c_str()); - } - remove(flag.c_str()); - } - return menu_return::RETURN_REPAINT; -} - int CNIMenu::show() { int shortcut = 1; @@ -400,7 +274,7 @@ int CNIMenu::show() std::string hint(g_Locale->getText(emu_menu[i].hint)); hint.append("\nvinfo: " + vinfo); - mc = new CMenuOptionChooser(emu_menu[i].name, &emu_menu[i].flag_exist, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, emu_menu[i].cam_exist, new CNITouchFileNotifier(emu_menu[i].cam_file), CRCInput::convertDigitToKey(cam_shortcut++)); + mc = new CMenuOptionChooser(emu_menu[i].name, &emu_menu[i].flag_exist, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, emu_menu[i].cam_exist, new CFlagFileNotifier(emu_menu[i].cam_file), CRCInput::convertDigitToKey(cam_shortcut++)); mc->setHint(NEUTRINO_ICON_HINT_IMAGELOGO, hint); emuMenu->addItem(mc); } @@ -442,7 +316,7 @@ int CNIMenu::show() buf << "/var/etc/." << plugin_menu[i].flag; plugin_menu[i].flag_exist=file_exists(buf.str().c_str()); - CNITouchFileNotifier * pluginFileNotifier = new CNITouchFileNotifier(plugin_menu[i].flag); + CFlagFileNotifier * pluginFileNotifier = new CFlagFileNotifier(plugin_menu[i].flag); mc = new CMenuOptionChooser(plugin_menu[i].name, &plugin_menu[i].flag_exist, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, pluginFileNotifier, CRCInput::convertDigitToKey(plugin_shortcut++)); mc->setHint(plugin_menu[i].icon, plugin_menu[i].desc); diff --git a/src/gui/ni_menu.h b/src/gui/ni_menu.h index c010dbca0..f454af178 100644 --- a/src/gui/ni_menu.h +++ b/src/gui/ni_menu.h @@ -27,20 +27,6 @@ #include -#define SCRIPT_DIR "/etc/init.d/" -#define EMU_DIR "/var/bin/" -#define EMU_START_SCRIPT SCRIPT_DIR "emu" - -using namespace std; - -class CNITouchFileNotifier : public CChangeObserver -{ - const char * filename; - public: - inline CNITouchFileNotifier(const char * file_name) { filename = file_name; }; - bool changeNotify(const neutrino_locale_t, void * data); -}; - class CNIMenu : public CMenuTarget, CChangeObserver { private: diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index b59ce312a..c908971c8 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -50,7 +50,6 @@ #include #include #include -#include //NI #include #include #include @@ -64,6 +63,7 @@ #include #include #include +#include extern CRemoteControl * g_RemoteControl; @@ -696,7 +696,7 @@ int COsdSetup::showOsdSetup() if (file_exists("/var/etc/.scart_osd_fix")) scart_osd_fix_exist = 1; - CNITouchFileNotifier * scartFileNotifier = new CNITouchFileNotifier("scart_osd_fix"); + CFlagFileNotifier * scartFileNotifier = new CFlagFileNotifier("scart_osd_fix"); mc = new CMenuOptionChooser(LOCALE_SCART_OSD_FIX, &scart_osd_fix_exist, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, !g_settings.screen_preset, scartFileNotifier); mc->setHint(NEUTRINO_ICON_HINT_IMAGELOGO, LOCALE_MENU_HINT_SCART_OSD_FIX); osd_menu->addItem(mc); diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index f0d696180..4a749457a 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -137,6 +137,117 @@ bool CTouchFileNotifier::changeNotify(const neutrino_locale_t, void * data) return true; } +bool CFlagFileNotifier::changeNotify(const neutrino_locale_t, void * data) +{ + std::ostringstream buf; + buf << FLAGDIR << "/." << filename; + + const char *flagfile = buf.str().c_str(); + + if ((*(int *)data) != 0) + { + FILE * fd = fopen(flagfile, "w"); + if (fd) + { + fclose(fd); + if (strstr(filename, "scart_osd_fix")) + { + //change to scart-osd-fix values + g_settings.screen_StartX_crt_0 = 29; + g_settings.screen_StartY_crt_0 = 43; + g_settings.screen_EndX_crt_0 = 693; + g_settings.screen_EndY_crt_0 = 535; + g_settings.screen_preset = 0; + + //set values + g_settings.screen_StartX = g_settings.screen_preset ? g_settings.screen_StartX_lcd_0 : g_settings.screen_StartX_crt_0; + g_settings.screen_StartY = g_settings.screen_preset ? g_settings.screen_StartY_lcd_0 : g_settings.screen_StartY_crt_0; + g_settings.screen_EndX = g_settings.screen_preset ? g_settings.screen_EndX_lcd_0 : g_settings.screen_EndX_crt_0; + g_settings.screen_EndY = g_settings.screen_preset ? g_settings.screen_EndY_lcd_0 : g_settings.screen_EndY_crt_0; + + CFrameBuffer::getInstance()->Clear(); + + g_settings.font_scaling_x = 100; + g_settings.font_scaling_y = 100; + } + else if (strstr(filename, "mgcamd") || + strstr(filename, "newcs") || + strstr(filename, "osemu") || + strstr(filename, "doscam") || + strstr(filename, "ncam") || + strstr(filename, "oscam") || + strstr(filename, "cs2gbox") || + strstr(filename, "gbox")) + { + CHintBox hintbox(LOCALE_CAMD_CONTROL, g_Locale->getText(LOCALE_CAMD_MSG_START)); + hintbox.paint(); + + printf("[CFlagFileNotifier] executing \"service emu start %s\"\n", filename); + if (my_system(4, "service", "emu", "start", filename) != 0) + printf("[CFlagFileNotifier] executing failed\n"); + sleep(1); + + hintbox.hide(); + } + else + { + printf("[CFlagFileNotifier] executing \"service %s start\"\n", filename); + if (my_system(3, "service", filename, "start") != 0) + printf("[CFlagFileNotifier] executing failed\n"); + } + } + } + else + { + if (strstr(filename, "scart_osd_fix")) + { + //reset to defaults + g_settings.screen_StartX_crt_0 = 60; + g_settings.screen_StartY_crt_0 = 20; + g_settings.screen_EndX_crt_0 = 1220; + g_settings.screen_EndY_crt_0 = 560; + + //set values + g_settings.screen_StartX = g_settings.screen_preset ? g_settings.screen_StartX_lcd_0 : g_settings.screen_StartX_crt_0; + g_settings.screen_StartY = g_settings.screen_preset ? g_settings.screen_StartY_lcd_0 : g_settings.screen_StartY_crt_0; + g_settings.screen_EndX = g_settings.screen_preset ? g_settings.screen_EndX_lcd_0 : g_settings.screen_EndX_crt_0; + g_settings.screen_EndY = g_settings.screen_preset ? g_settings.screen_EndY_lcd_0 : g_settings.screen_EndY_crt_0; + + CFrameBuffer::getInstance()->Clear(); + + g_settings.font_scaling_x = 105; + g_settings.font_scaling_y = 105; + } + else if (strstr(filename, "mgcamd") || + strstr(filename, "newcs") || + strstr(filename, "osemu") || + strstr(filename, "doscam") || + strstr(filename, "ncam") || + strstr(filename, "oscam") || + strstr(filename, "cs2gbox") || + strstr(filename, "gbox")) + { + CHintBox hintbox(LOCALE_CAMD_CONTROL, g_Locale->getText(LOCALE_CAMD_MSG_STOP)); + hintbox.paint(); + + printf("[CFlagFileNotifier] executing \"service emu stop %s\"\n", filename); + if (my_system(4, "service", "emu", "stop", filename) != 0) + printf("[CFlagFileNotifier] executing failed\n"); + sleep(1); + + hintbox.hide(); + } + else + { + printf("[CFlagFileNotifier] executing \"service %s stop\"\n", filename); + if (my_system(3, "service", filename, "stop") != 0) + printf("[CFlagFileNotifier] executing failed\n"); + } + remove(flagfile); + } + return menu_return::RETURN_REPAINT; +} + void CColorSetupNotifier::setPalette() { CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); diff --git a/src/system/setting_helpers.h b/src/system/setting_helpers.h index 1c23a2ddc..9ebcacd2b 100644 --- a/src/system/setting_helpers.h +++ b/src/system/setting_helpers.h @@ -82,6 +82,14 @@ class CTouchFileNotifier : public CChangeObserver bool changeNotify(const neutrino_locale_t, void * data); }; +class CFlagFileNotifier : public CChangeObserver +{ + const char * filename; + public: + inline CFlagFileNotifier(const char * _filename) { filename = _filename; }; + bool changeNotify(const neutrino_locale_t, void * data); +}; + class CColorSetupNotifier : public CChangeObserver { public: