diff --git a/src/driver/shutdown_count.cpp b/src/driver/shutdown_count.cpp index 9416a30fd..92fcc1c6f 100644 --- a/src/driver/shutdown_count.cpp +++ b/src/driver/shutdown_count.cpp @@ -63,8 +63,8 @@ void* SHTDCNT::TimeThread(void *) void SHTDCNT::init() { - shutdown_cnt = atoi(g_settings.shutdown_count) * 60; - sleep_cnt = atoi(g_settings.shutdown_min)*60; + shutdown_cnt = g_settings.shutdown_count * 60; + sleep_cnt = g_settings.shutdown_min * 60; if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 ) { perror("[SHTDCNT]: pthread_create(TimeThread)"); @@ -75,7 +75,7 @@ void SHTDCNT::init() void SHTDCNT::shutdown_counter() { static bool sleeptimer_active = true; - if (atoi(g_settings.shutdown_count) > 0) + if (g_settings.shutdown_count > 0) { if ((CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby) && (!CNeutrinoApp::getInstance ()->recordingstatus)) { @@ -95,11 +95,11 @@ void SHTDCNT::shutdown_counter() else { // reset counter - shutdown_cnt = atoi(g_settings.shutdown_count) * 60; + shutdown_cnt = g_settings.shutdown_count * 60; } } - if(atoi(g_settings.shutdown_min) > 0) { + if(g_settings.shutdown_min > 0) { if(sleep_cnt > 0) { sleeptimer_active = true; sleep_cnt--; @@ -118,5 +118,5 @@ void SHTDCNT::shutdown_counter() void SHTDCNT::resetSleepTimer() { - sleep_cnt = atoi(g_settings.shutdown_min)*60; + sleep_cnt = g_settings.shutdown_min * 60; } diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index 28e6474f0..f823e5f32 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -332,8 +333,11 @@ int CMiscMenue::showMiscSettingsMenuEnergy() CMenuOptionChooser *m1 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL_RCDELAY, &g_settings.shutdown_real_rcdelay, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, !g_settings.shutdown_real); m1->setHint("", LOCALE_MENU_HINT_SHUTDOWN_RCDELAY); - CStringInput * miscSettings_shutdown_count = new CStringInput(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, g_settings.shutdown_count, 3, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT1, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT2, "0123456789 "); - CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, g_settings.shutdown_count, miscSettings_shutdown_count); + std::string shutdown_count = to_string(g_settings.shutdown_count); + if (shutdown_count.length() < 3) + shutdown_count.insert(0, 3 - shutdown_count.length(), '0'); + CStringInput * miscSettings_shutdown_count = new CStringInput(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, &shutdown_count, 3, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT1, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT2, "0123456789 "); + CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, shutdown_count.c_str(), miscSettings_shutdown_count); m2->setHint("", LOCALE_MENU_HINT_SHUTDOWN_COUNT); COnOffNotifier * miscNotifier = new COnOffNotifier(1); @@ -347,7 +351,7 @@ int CMiscMenue::showMiscSettingsMenuEnergy() ms_energy->addItem(m1); ms_energy->addItem(m2); - m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, g_settings.shutdown_min, new CSleepTimerWidget, "permanent"); + m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, NULL, new CSleepTimerWidget, "permanent"); m2->setHint("", LOCALE_MENU_HINT_INACT_TIMER); ms_energy->addItem(m2); @@ -362,6 +366,9 @@ int CMiscMenue::showMiscSettingsMenuEnergy() } int res = ms_energy->exec(NULL, ""); + + g_settings.shutdown_count = atoi(shutdown_count.c_str()); + delete ms_energy; delete miscNotifier; return res; @@ -377,7 +384,7 @@ void CMiscMenue::showMiscSettingsMenuEpg(CMenuWidget *ms_epg) mc1->setHint("", LOCALE_MENU_HINT_EPG_SAVE_STANDBY); CStringInput * miscSettings_epg_cache = new CStringInput(LOCALE_MISCSETTINGS_EPG_CACHE, &g_settings.epg_cache, 2,LOCALE_MISCSETTINGS_EPG_CACHE_HINT1, LOCALE_MISCSETTINGS_EPG_CACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); - CMenuForwarder * mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_CACHE, true, g_settings.epg_cache, miscSettings_epg_cache); + CMenuForwarder * mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_CACHE, true, NULL, miscSettings_epg_cache); mf->setHint("", LOCALE_MENU_HINT_EPG_CACHE); CStringInput * miscSettings_epg_cache_e = new CStringInput(LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE, &g_settings.epg_extendedcache, 3,LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE_HINT1, LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); diff --git a/src/gui/sleeptimer.cpp b/src/gui/sleeptimer.cpp index 02c847b78..b34caddde 100644 --- a/src/gui/sleeptimer.cpp +++ b/src/gui/sleeptimer.cpp @@ -61,7 +61,7 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) parent->hide(); if(permanent) { - strcpy(value,g_settings.shutdown_min); + sprintf(value,"%03d", g_settings.shutdown_min); } else { shutdown_min = g_Timerd->getSleepTimerRemaining(); // remaining shutdown time? sprintf(value,"%03d", shutdown_min); @@ -100,8 +100,8 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) int new_val = atoi(value); if(permanent) { - sprintf(g_settings.shutdown_min,"%03d", new_val); - printf("permanent sleeptimer min: %s\n", g_settings.shutdown_min); + g_settings.shutdown_min = new_val; + printf("permanent sleeptimer min: %d\n", g_settings.shutdown_min); } else if(shutdown_min != new_val) { shutdown_min = new_val; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 6b9b7cc0d..8d3afd9f3 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -388,11 +388,11 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.shutdown_real = configfile.getBool("shutdown_real" , false ); g_settings.shutdown_real_rcdelay = configfile.getBool("shutdown_real_rcdelay", false ); - strcpy(g_settings.shutdown_count, configfile.getString("shutdown_count","0").c_str()); + g_settings.shutdown_count = configfile.getInt32("shutdown_count", 0); - strcpy(g_settings.shutdown_min, "000"); + g_settings.shutdown_min = 0; if(cs_get_revision() > 7) - strcpy(g_settings.shutdown_min, configfile.getString("shutdown_min","180").c_str()); + g_settings.shutdown_min = configfile.getInt32("shutdown_min", 180); g_settings.sleeptimer_min = configfile.getInt32("sleeptimer_min", 0); g_settings.infobar_sat_display = configfile.getBool("infobar_sat_display" , true ); @@ -895,8 +895,8 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32( "hdd_noise", g_settings.hdd_noise); configfile.setBool("shutdown_real" , g_settings.shutdown_real ); configfile.setBool("shutdown_real_rcdelay", g_settings.shutdown_real_rcdelay); - configfile.setString("shutdown_count" , g_settings.shutdown_count); - configfile.setString("shutdown_min" , g_settings.shutdown_min ); + configfile.setInt32("shutdown_count" , g_settings.shutdown_count); + configfile.setInt32("shutdown_min" , g_settings.shutdown_min ); configfile.setInt32("sleeptimer_min", g_settings.sleeptimer_min); configfile.setBool("infobar_sat_display" , g_settings.infobar_sat_display ); configfile.setBool("infobar_show_channeldesc" , g_settings.infobar_show_channeldesc ); diff --git a/src/system/settings.h b/src/system/settings.h index a1afa39b5..7ea4f2780 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -68,8 +68,8 @@ struct SNeutrinoSettings //misc int shutdown_real; int shutdown_real_rcdelay; - char shutdown_count[4]; - char shutdown_min[4]; + int shutdown_count; + int shutdown_min; int sleeptimer_min; int record_safety_time_before; int record_safety_time_after; @@ -141,10 +141,10 @@ struct SNeutrinoSettings // EPG int epg_save; int epg_save_standby; - std::string epg_cache; - std::string epg_old_events; - std::string epg_max_events; - std::string epg_extendedcache; + std::string epg_cache; // FIXME + std::string epg_old_events; // FIXME + std::string epg_max_events; // FIXME + std::string epg_extendedcache; // FIXME std::string epg_dir; int epg_scan;