From 1c45363191d793439bb36732c39a5893649fc0e7 Mon Sep 17 00:00:00 2001 From: thilo Date: Fri, 15 Apr 2011 15:05:04 +0000 Subject: [PATCH] *neutrino software_update: moved firmware update menu to it's own modules git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1401 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/gui/Makefile.am | 1 + src/gui/software_update.cpp | 155 ++++++++++++++++++++++++++++++++++++ src/gui/software_update.h | 58 ++++++++++++++ src/neutrino.cpp | 9 --- src/neutrino_menue.cpp | 55 +------------ 5 files changed, 216 insertions(+), 62 deletions(-) create mode 100644 src/gui/software_update.cpp create mode 100644 src/gui/software_update.h diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 3e65c16b1..cc30301c0 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -79,6 +79,7 @@ libneutrino_gui_a_SOURCES = \ screensetup.cpp \ settings_manager.cpp \ sleeptimer.cpp \ + software_update.cpp \ streaminfo2.cpp \ test_menu.cpp \ themes.cpp \ diff --git a/src/gui/software_update.cpp b/src/gui/software_update.cpp new file mode 100644 index 000000000..a33cf2b7d --- /dev/null +++ b/src/gui/software_update.cpp @@ -0,0 +1,155 @@ +/* + $Id: port of software_update.cpp,v 1.8 2011/04/03 21:56:13 tuxbox-cvs Exp $ + + Neutrino-GUI - DBoxII-Project + + Software update implementation - Neutrino-GUI + + Copyright (C) 2001 Steffen Hehn 'McClean' + and some other guys + Homepage: http://dbox.cyberphoria.org/ + + rework Copyright (C) 2011 T. Graf 'dbt' + Homepage: http://www.dbox2-tuning.net/ + + License: GPL + + 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "gui/info_menue.h" +#include "gui/imageinfo.h" +#include "gui/dboxinfo.h" +#include +#include +#include + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "software_update.h" + +#include "gui/imageinfo.h" + +#include + +#include + +#include +#include + +CSoftwareUpdate::CSoftwareUpdate() +{ + width = w_max (40, 10); + selected = -1; + fe = new CFlashExpert(); + input_url_file = new CStringInputSMS(LOCALE_FLASHUPDATE_URL_FILE, g_settings.softupdate_url_file, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789!""�$%&/()=?-. "); +} + +CSoftwareUpdate::~CSoftwareUpdate() +{ + delete fe; + delete input_url_file; +} + +#define FLASHUPDATE_UPDATEMODE_OPTION_COUNT 2 +const CMenuOptionChooser::keyval FLASHUPDATE_UPDATEMODE_OPTIONS[FLASHUPDATE_UPDATEMODE_OPTION_COUNT] = +{ + { 0, LOCALE_FLASHUPDATE_UPDATEMODE_MANUAL }, + { 1, LOCALE_FLASHUPDATE_UPDATEMODE_INTERNET } +}; + +int CSoftwareUpdate::exec(CMenuTarget* parent, const std::string &actionKey) +{ + dprintf(DEBUG_DEBUG, "init software-update\n"); + int res = menu_return::RETURN_REPAINT; + + if (parent) + { + parent->hide(); + } + + if(actionKey == "update_dir") { + + const char *action_str = "update"; + if(chooserDir(g_settings.update_dir, true, action_str, sizeof(g_settings.update_dir)-1)) + printf("[neutrino] new %s dir %s\n", action_str, g_settings.update_dir); + + return res; + } + + showSoftwareUpdate(); + return res; +} + +void CSoftwareUpdate::showSoftwareUpdate() +/* shows the menue and options for software update */ +{ + CMenuWidget* softUpdate = new CMenuWidget(LOCALE_MAINMENU_SERVICE, NEUTRINO_ICON_UPDATE, width); + softUpdate->setSelected(selected); + + softUpdate->addIntroItems(LOCALE_SERVICEMENU_UPDATE); + + //expert-functions + CMenuWidget *mtdexpert = new CMenuWidget(LOCALE_FLASHUPDATE_EXPERTFUNCTIONS, NEUTRINO_ICON_UPDATE, width); + showSoftwareUpdateExpert(mtdexpert); + softUpdate->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_EXPERTFUNCTIONS, true, NULL, mtdexpert, "", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED)); + + softUpdate->addItem(GenericMenuSeparatorLine); + + CMenuOptionChooser *oj = new CMenuOptionChooser(LOCALE_FLASHUPDATE_UPDATEMODE, &g_settings.softupdate_mode, FLASHUPDATE_UPDATEMODE_OPTIONS, FLASHUPDATE_UPDATEMODE_OPTION_COUNT, true, NULL); + softUpdate->addItem( oj ); + + softUpdate->addItem( new CMenuForwarder(LOCALE_EXTRA_UPDATE_DIR, true, g_settings.update_dir , this, "update_dir", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN)); + + softUpdate->addItem(GenericMenuSeparatorLine); + softUpdate->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_CHECKUPDATE, true, NULL, new CFlashUpdate(), "", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW )); + softUpdate->addItem(new CMenuForwarder(LOCALE_SERVICEMENU_IMAGEINFO, true, NULL, new CImageInfo(), NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE)); + + softUpdate->exec (NULL, ""); + softUpdate->hide (); + selected = softUpdate->getSelected(); + delete softUpdate; +} + +/* shows experts-functions to read/write to the mtd */ +void CSoftwareUpdate::showSoftwareUpdateExpert(CMenuWidget *mtd_expert) +{ + mtd_expert->addIntroItems(); + + mtd_expert->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_READFLASHMTD , true, NULL, fe, "readflashmtd" )); + mtd_expert->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_WRITEFLASHMTD, true, NULL, fe, "writeflashmtd")); + + mtd_expert->addItem(GenericMenuSeparatorLine); + + mtd_expert->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_URL_FILE, true, g_settings.softupdate_url_file, input_url_file)); +} + + + diff --git a/src/gui/software_update.h b/src/gui/software_update.h new file mode 100644 index 000000000..3bb5db33b --- /dev/null +++ b/src/gui/software_update.h @@ -0,0 +1,58 @@ +/* + $Id: port of software_update.h,v 1.6 2011/04/03 21:56:13 tuxbox-cvs Exp $ + + Neutrino-GUI - DBoxII-Project + + Software update implementation - Neutrino-GUI + + Copyright (C) 2001 Steffen Hehn 'McClean' + and some other guys + Homepage: http://dbox.cyberphoria.org/ + + Rework Copyright (C) 2011 T. Graf 'dbt' + Homepage: http://www.dbox2-tuning.net/ + + 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __software_update__ +#define __software_update__ + +#include + +#include "gui/update.h" +#include "gui/widget/stringinput.h" + +#include + +class CSoftwareUpdate : public CMenuTarget +{ + private: + int width, selected; + + void showSoftwareUpdate(); + void showSoftwareUpdateExpert(CMenuWidget *mtd_expert); + + CFlashExpert *fe; + CStringInputSMS *input_url_file; + + public: + CSoftwareUpdate(); + ~CSoftwareUpdate(); + int exec(CMenuTarget* parent, const std::string & actionKey); +}; + +#endif diff --git a/src/neutrino.cpp b/src/neutrino.cpp index b85d69629..eb41a77ec 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -4263,15 +4263,6 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) return menu_return::RETURN_REPAINT; } - else if(actionKey == "update_dir") { - parent->hide(); - - const char *action_str = "update"; - if(chooserDir(g_settings.update_dir, true, action_str, sizeof(g_settings.update_dir)-1)){ - printf("[neutrino] new %s dir %s\n", action_str, g_settings.update_dir); - } - return menu_return::RETURN_REPAINT; - } else if(actionKey == "movieplugin") { parent->hide(); CMenuWidget MoviePluginSelector(LOCALE_MOVIEPLAYER_DEFPLUGIN, NEUTRINO_ICON_FEATURES); diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index be88dc8ad..ecc5f8622 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -71,6 +71,7 @@ #include "gui/scan_setup.h" #include "gui/settings_manager.h" #include "gui/sleeptimer.h" +#include "gui/software_update.h" #include #ifdef TEST_MENU #include "gui/test_menu.h" @@ -266,59 +267,7 @@ void CNeutrinoApp::InitServiceSettings(CMenuWidget &service) // end of infomenu in service //softupdate - //if(softupdate) - { - dprintf(DEBUG_DEBUG, "init soft-update-stuff\n"); - CMenuWidget* updateSettings = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE); - updateSettings->addIntroItems(); - - // expert-functions to read/write mtd - CMenuWidget* mtdexpert = new CMenuWidget(LOCALE_FLASHUPDATE_EXPERTFUNCTIONS, NEUTRINO_ICON_UPDATE); - mtdexpert->addIntroItems(); - CFlashExpert* fe = new CFlashExpert(); - - //mtdexpert->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_READFLASH , true, NULL, fe, "readflash" )); - //if(softupdate) - // mtdexpert->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_WRITEFLASH , true, NULL, fe, "writeflash" )); - //mtdexpert->addItem(GenericMenuSeparatorLine); - mtdexpert->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_READFLASHMTD , true, NULL, fe, "readflashmtd" )); - if (softupdate) - mtdexpert->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_WRITEFLASHMTD, true, NULL, fe, "writeflashmtd")); - mtdexpert->addItem(GenericMenuSeparatorLine); - - CStringInputSMS * updateSettings_url_file = new CStringInputSMS(LOCALE_FLASHUPDATE_URL_FILE, g_settings.softupdate_url_file, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789!""�$%&/()=?-. "); - mtdexpert->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_URL_FILE, true, g_settings.softupdate_url_file, updateSettings_url_file)); - - updateSettings->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_EXPERTFUNCTIONS, true, NULL, mtdexpert, "", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED)); - - updateSettings->addItem(GenericMenuSeparatorLine); - CMenuOptionChooser *oj = new CMenuOptionChooser(LOCALE_FLASHUPDATE_UPDATEMODE, &g_settings.softupdate_mode, FLASHUPDATE_UPDATEMODE_OPTIONS, FLASHUPDATE_UPDATEMODE_OPTION_COUNT, true, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); - updateSettings->addItem( oj ); - updateSettings->addItem( new CMenuForwarder(LOCALE_EXTRA_UPDATE_DIR, true, g_settings.update_dir , this, "update_dir", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW) ); - -#if 0 // image info and update list show current version, probably ehough - /* show current version */ - updateSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_FLASHUPDATE_CURRENTVERSION_SEP)); - - /* get current version SBBBYYYYMMTTHHMM -- formatsting */ - CConfigFile _configfile('\t'); - - const char * versionString = (_configfile.loadConfig("/.version")) ? (_configfile.getString( "version", "????????????????").c_str()) : "????????????????"; - - dprintf(DEBUG_INFO, "current flash-version: %s\n", versionString); - - static CFlashVersionInfo versionInfo(versionString); - - updateSettings->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_CURRENTVERSIONDATE , false, versionInfo.getDate())); - updateSettings->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_CURRENTVERSIONTIME , false, versionInfo.getTime())); - updateSettings->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_CURRENTRELEASECYCLE , false, versionInfo.getReleaseCycle())); - /* versionInfo.getType() returns const char * which is never deallocated */ - updateSettings->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_CURRENTVERSIONSNAPSHOT, false, versionInfo.getType())); -#endif - updateSettings->addItem(GenericMenuSeparatorLine); - updateSettings->addItem(new CMenuForwarder(LOCALE_FLASHUPDATE_CHECKUPDATE, true, NULL, new CFlashUpdate(), "", CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE)); - service.addItem(new CMenuForwarder(LOCALE_SERVICEMENU_UPDATE, true, NULL, updateSettings)); - } + service.addItem(new CMenuForwarder(LOCALE_SERVICEMENU_UPDATE, true, NULL, new CSoftwareUpdate())); }