mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
needs build- and functional fixes Conflicts: configure.ac data/icons/shutdown.jpg data/icons/start.jpg data/locale/deutsch.locale data/locale/english.locale lib/libmd5sum/md5.c src/driver/scanepg.cpp src/driver/streamts.cpp src/driver/vfd.cpp src/driver/vfd.h src/driver/volume.cpp src/eitd/dmx.cpp src/eitd/xmlutil.cpp src/gui/Makefile.am src/gui/audiomute.cpp src/gui/channellist.cpp src/gui/dboxinfo.cpp src/gui/epgview.cpp src/gui/eventlist.cpp src/gui/filebrowser.cpp src/gui/hdd_menu.cpp src/gui/infoviewer.cpp src/gui/infoviewer_bb.cpp src/gui/infoviewer_bb.h src/gui/keybind_setup.cpp src/gui/luainstance.cpp src/gui/luainstance.h src/gui/miscsettings_menu.cpp src/gui/moviebrowser.cpp src/gui/movieplayer.cpp src/gui/osd_progressbar_setup.cpp src/gui/osd_progressbar_setup.h src/gui/osd_setup.cpp src/gui/osdlang_setup.cpp src/gui/personalize.cpp src/gui/plugins.cpp src/gui/plugins.h src/gui/scan.cpp src/gui/scan_setup.cpp src/gui/update_settings.cpp src/gui/user_menue.cpp src/gui/user_menue_setup.cpp src/gui/videosettings.cpp src/gui/widget/buttons.cpp src/gui/widget/menue.cpp src/gui/widget/menue.h src/gui/widget/progresswindow.cpp src/neutrino.cpp src/neutrino_menue.cpp src/nhttpd/yhttpd.cpp src/system/helpers.cpp src/system/locals.h src/system/locals_intern.h src/system/setting_helpers.cpp src/zapit/lib/zapitclient.cpp src/zapit/src/fastscan.cpp src/zapit/src/frontend.cpp src/zapit/src/getservices.cpp src/zapit/src/scan.cpp src/zapit/src/scannit.cpp src/zapit/src/scanpmt.cpp src/zapit/src/transponder.cpp src/zapit/src/zapit.cpp
205 lines
6.4 KiB
C++
205 lines
6.4 KiB
C++
/*
|
|
settings mangaer menue - Neutrino-GUI
|
|
|
|
Copyright (C) 2001 Steffen Hehn 'McClean'
|
|
and some other guys
|
|
Homepage: http://dbox.cyberphoria.org/
|
|
|
|
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 <config.h>
|
|
#endif
|
|
|
|
#include <global.h>
|
|
#include <neutrino.h>
|
|
#include <neutrino_menue.h>
|
|
|
|
#include <gui/settings_manager.h>
|
|
#include <gui/filebrowser.h>
|
|
#include <gui/widget/messagebox.h>
|
|
#include <gui/widget/stringinput.h>
|
|
|
|
#include <driver/screen_max.h>
|
|
#include <driver/display.h>
|
|
#include <system/helpers.h>
|
|
|
|
#include <sys/vfs.h>
|
|
|
|
|
|
|
|
CSettingsManager::CSettingsManager()
|
|
{
|
|
width = w_max (40, 10);
|
|
}
|
|
|
|
|
|
CSettingsManager::~CSettingsManager()
|
|
{
|
|
}
|
|
|
|
int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey)
|
|
{
|
|
printf("[neutrino] CSettingsManager %s: init...\n",__FUNCTION__);
|
|
int res = menu_return::RETURN_REPAINT;
|
|
|
|
if (parent)
|
|
parent->hide();
|
|
|
|
CFileBrowser fileBrowser;
|
|
CFileFilter fileFilter;
|
|
|
|
if(actionKey == "loadconfig")
|
|
{
|
|
fileFilter.addFilter("conf");
|
|
fileBrowser.Filter = &fileFilter;
|
|
if (fileBrowser.exec(CONFIGDIR) == true)
|
|
{
|
|
CNeutrinoApp::getInstance()->loadSetup(fileBrowser.getSelectedFile()->Name.c_str());
|
|
CColorSetupNotifier *colorSetupNotifier = new CColorSetupNotifier;
|
|
colorSetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL);
|
|
CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_ALL);
|
|
CVFD::getInstance()->setlcdparameter();
|
|
printf("[neutrino] new settings: %s\n", fileBrowser.getSelectedFile()->Name.c_str());
|
|
delete colorSetupNotifier;
|
|
}
|
|
return res;
|
|
}
|
|
else if(actionKey == "saveconfig")
|
|
{
|
|
fileBrowser.Dir_Mode = true;
|
|
if (fileBrowser.exec("/var/tuxbox") == true)
|
|
{
|
|
std::string fname = "neutrino.conf";
|
|
CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVECONFIG, &fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. ");
|
|
sms->exec(NULL, "");
|
|
|
|
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;
|
|
}
|
|
else if(actionKey == "backup")
|
|
{
|
|
fileBrowser.Dir_Mode = true;
|
|
if (fileBrowser.exec("/media") == true)
|
|
{
|
|
struct statfs s;
|
|
int ret = ::statfs(fileBrowser.getSelectedFile()->Name.c_str(), &s);
|
|
if(ret == 0 && s.f_type != 0x72b6L) /*jffs2*/
|
|
{
|
|
const char backup_sh[] = "/bin/backup.sh";
|
|
printf("backup: executing [%s %s]\n",backup_sh, fileBrowser.getSelectedFile()->Name.c_str());
|
|
my_system(2, backup_sh, fileBrowser.getSelectedFile()->Name.c_str());
|
|
}
|
|
else
|
|
ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR);
|
|
}
|
|
return res;
|
|
}
|
|
else if(actionKey == "restore")
|
|
{
|
|
fileFilter.addFilter("tar");
|
|
fileBrowser.Filter = &fileFilter;
|
|
if (fileBrowser.exec("/media") == true)
|
|
{
|
|
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";
|
|
printf("restore: executing [%s %s]\n", restore_sh, fileBrowser.getSelectedFile()->Name.c_str());
|
|
my_system(2, restore_sh, fileBrowser.getSelectedFile()->Name.c_str());
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
res = showMenu();
|
|
|
|
return res;
|
|
}
|
|
|
|
int CSettingsManager::showMenu()
|
|
{
|
|
printf("[neutrino] CSettingsManager call %s...\n", __FUNCTION__);
|
|
|
|
CDataResetNotifier * resetNotifier = new CDataResetNotifier();
|
|
|
|
CMenuWidget * mset = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_SETTINGS_MNGR);
|
|
mset->addIntroItems(LOCALE_MAINSETTINGS_MANAGE);
|
|
|
|
CMenuForwarder * mf;
|
|
if (g_settings.easymenu)
|
|
mf = new CMenuForwarder(LOCALE_RESET_SETTINGS, true, NULL, resetNotifier, "settings", CRCInput::RC_red);
|
|
else
|
|
mf = new CMenuForwarder(LOCALE_RESET_SETTINGS, true, NULL, resetNotifier, "settings", CRCInput::RC_recall);
|
|
|
|
mf->setHint(NEUTRINO_ICON_HINT_RESET, LOCALE_MENU_HINT_RESET); // FIXME: RC-button RECALL is broken
|
|
mset->addItem(mf);
|
|
|
|
if (!g_settings.easymenu) {
|
|
mset->addItem(GenericMenuSeparatorLine);
|
|
|
|
mf = new CMenuForwarder(LOCALE_EXTRA_SAVECONFIG, true, NULL, this, "saveconfig", CRCInput::RC_red);
|
|
mf->setHint(NEUTRINO_ICON_HINT_SAVEAS, LOCALE_MENU_HINT_SAVEAS);
|
|
mset->addItem(mf);
|
|
|
|
mf = new CMenuForwarder(LOCALE_EXTRA_LOADCONFIG, true, NULL, this, "loadconfig", CRCInput::RC_green);
|
|
mf->setHint(NEUTRINO_ICON_HINT_LOAD, LOCALE_MENU_HINT_LOAD);
|
|
mset->addItem(mf);
|
|
|
|
mset->addItem(GenericMenuSeparatorLine);
|
|
}
|
|
|
|
if (g_settings.easymenu)
|
|
mf = new CMenuForwarder(LOCALE_SETTINGS_BACKUP, true, NULL, this, "backup", CRCInput::RC_green);
|
|
else
|
|
mf = new CMenuForwarder(LOCALE_SETTINGS_BACKUP, true, NULL, this, "backup", CRCInput::RC_yellow);
|
|
|
|
mf->setHint(NEUTRINO_ICON_HINT_BACKUP, LOCALE_MENU_HINT_BACKUP);
|
|
mset->addItem(mf);
|
|
|
|
if (g_settings.easymenu)
|
|
mf = new CMenuForwarder(LOCALE_SETTINGS_RESTORE, true, NULL, this, "restore", CRCInput::RC_yellow);
|
|
else
|
|
mf = new CMenuForwarder(LOCALE_SETTINGS_RESTORE, true, NULL, this, "restore", CRCInput::RC_blue);
|
|
|
|
mf->setHint(NEUTRINO_ICON_HINT_RESTORE, LOCALE_MENU_HINT_RESTORE);
|
|
mset->addItem(mf);
|
|
|
|
if (g_settings.easymenu) {
|
|
mf = new CMenuForwarder(LOCALE_RESET_ALL, true, NULL, resetNotifier, "all", CRCInput::RC_blue);
|
|
} else {
|
|
mset->addItem(GenericMenuSeparatorLine);
|
|
mf = new CMenuForwarder(LOCALE_RESET_ALL, true, NULL, resetNotifier, "all", CRCInput::RC_standby);
|
|
}
|
|
mf->setHint(NEUTRINO_ICON_HINT_FACTORY, LOCALE_MENU_HINT_FACTORY);
|
|
mset->addItem(mf);
|
|
|
|
int res = mset->exec(NULL, "");
|
|
delete resetNotifier;
|
|
delete mset;
|
|
return res;
|
|
}
|