From 7f86f0478218fe738e852570ea2d20c6da51e6a2 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 12 Sep 2017 22:30:35 +0200 Subject: [PATCH] move some actionkey-stuff from ni-menu directly to neutrino.cpp Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/16b57e40a859bf8b35836b9c957731641ad4793b Author: vanhofen Date: 2017-09-12 (Tue, 12 Sep 2017) Origin message was: ------------------ - move some actionkey-stuff from ni-menu directly to neutrino.cpp --- src/gui/ni_menu.cpp | 52 ------------------------------------------ src/gui/ni_menu.h | 1 - src/gui/user_menue.cpp | 6 ++--- src/neutrino.cpp | 43 ++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 57 deletions(-) diff --git a/src/gui/ni_menu.cpp b/src/gui/ni_menu.cpp index 915dc384e..f518aa894 100644 --- a/src/gui/ni_menu.cpp +++ b/src/gui/ni_menu.cpp @@ -79,66 +79,14 @@ CNIMenu::~CNIMenu() { } -CNIMenu* CNIMenu::getInstance() -{ - static CNIMenu* NIMenu = NULL; - if (!NIMenu) - NIMenu = new CNIMenu(); - return NIMenu; -} - int CNIMenu::exec(CMenuTarget* parent, const std::string &actionkey) { printf("CNIMenu::exec: actionkey %s\n", actionkey.c_str()); int res = menu_return::RETURN_REPAINT; - char *buffer; - ssize_t read; - size_t len; - FILE *fh; if (parent) parent->hide(); - if (actionkey == "camd_reset") - { - CHintBox hintbox(LOCALE_CAMD_CONTROL, g_Locale->getText(LOCALE_CAMD_MSG_RESET)); - hintbox.paint(); - - 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(); - - return menu_return::RETURN_EXIT_ALL; - } - else if(actionkey == "ecmInfo") - { - buffer=NULL; - CFileHelpers fhlp; - if (fhlp.copyFile("/tmp/ecm.info", "/tmp/ecm.info.tmp", 0644)) - { - if ((fh = fopen("/tmp/ecm.info.tmp", "r"))) - { - std::string str = ""; - while ((read = getline(&buffer, &len, fh)) != -1) - { - str += buffer; - } - fclose(fh); - remove("/tmp/ecm.info.tmp"); - if(buffer) - free(buffer); - ShowHint(LOCALE_ECMINFO, str.c_str(), 450, 20); - } - } - else - ShowHint(LOCALE_ECMINFO, LOCALE_ECMINFO_NULL, 450, 20); - - return menu_return::RETURN_EXIT_ALL; - } - res = show(); return res; diff --git a/src/gui/ni_menu.h b/src/gui/ni_menu.h index f454af178..038a391ee 100644 --- a/src/gui/ni_menu.h +++ b/src/gui/ni_menu.h @@ -39,7 +39,6 @@ class CNIMenu : public CMenuTarget, CChangeObserver public: CNIMenu(); ~CNIMenu(); - static CNIMenu* getInstance(); int exec(CMenuTarget* parent, const std::string &actionkey); #if 0 virtual bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/); diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 62f7e3b37..669004ec6 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -95,7 +95,6 @@ extern CCAMMenuHandler * g_CamHandler; #include //NI -#include #include #include @@ -167,7 +166,6 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg) // define classes CSubChannelSelectMenu subchanselect; CNeutrinoApp * neutrino = CNeutrinoApp::getInstance(); - CNIMenu *ni_menu = CNIMenu::getInstance(); //NI std::string txt = g_settings.usermenu[button]->title; if (button < COL_BUTTONMAX && txt.empty()) @@ -417,7 +415,7 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg) case SNeutrinoSettings::ITEM_ECMINFO: { keyhelper.get(&key,&icon); - menu_item = new CMenuForwarder(LOCALE_ECMINFO_SHOW, file_size("/tmp/ecm.info"), NULL, ni_menu, "ecmInfo", key, icon); + menu_item = new CMenuForwarder(LOCALE_ECMINFO_SHOW, file_size("/tmp/ecm.info"), NULL, neutrino, "ecmInfo", key, icon); // FIXME menu_item->setHint("", NONEXISTANT_LOCALE); break; } @@ -425,7 +423,7 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg) case SNeutrinoSettings::ITEM_CAMD_RESET: { keyhelper.get(&key,&icon); - menu_item = new CMenuForwarder(LOCALE_CAMD_RESET, true, NULL, ni_menu, "camd_reset", key, icon); + menu_item = new CMenuForwarder(LOCALE_CAMD_RESET, true, NULL, neutrino, "camd_reset", key, icon); // FIXME menu_item->setHint("", NONEXISTANT_LOCALE); break; } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index de5090980..f3d66a4c2 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -4514,6 +4514,49 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) hintBox->hide(); delete hintBox; } + else if (actionKey == "camd_reset") + { + CHintBox hintbox(LOCALE_CAMD_CONTROL, LOCALE_CAMD_MSG_RESET); + hintbox.paint(); + + printf("[neutrino.cpp] executing \"service emu restart\"\n"); + if (my_system(3, "service", "emu", "restart") != 0) + printf("[neutrino.cpp] executing failed\n"); + sleep(1); + + hintbox.hide(); + + return menu_return::RETURN_EXIT_ALL; + } + else if (actionKey == "ecmInfo") + { + char *buffer = NULL; + ssize_t read; + size_t len; + FILE *fh; + + CFileHelpers fhlp; + if (fhlp.copyFile("/tmp/ecm.info", "/tmp/ecm.info.tmp", 0644)) + { + if ((fh = fopen("/tmp/ecm.info.tmp", "r"))) + { + std::string str = ""; + while ((read = getline(&buffer, &len, fh)) != -1) + { + str += buffer; + } + fclose(fh); + remove("/tmp/ecm.info.tmp"); + if(buffer) + free(buffer); + ShowHint(LOCALE_ECMINFO, str.c_str(), 450, 20); + } + } + else + ShowHint(LOCALE_ECMINFO, LOCALE_ECMINFO_NULL, 450, 20); + + return menu_return::RETURN_EXIT_ALL; + } else if(actionKey=="nkplayback" || actionKey=="ytplayback" || actionKey=="tsmoviebrowser" || actionKey=="fileplayback") { frameBuffer->Clear(); if(mode == NeutrinoMessages::mode_radio )