system/settings: use integers for shutdown_count/_min

Signed-off-by: Jacek Jendrzej <crashdvb@googlemail.com>
This commit is contained in:
martii
2013-12-24 09:53:20 +01:00
committed by Jacek Jendrzej
parent 2cee6929d6
commit d125301ede
5 changed files with 31 additions and 24 deletions

View File

@@ -63,8 +63,8 @@ void* SHTDCNT::TimeThread(void *)
void SHTDCNT::init() void SHTDCNT::init()
{ {
shutdown_cnt = atoi(g_settings.shutdown_count) * 60; shutdown_cnt = g_settings.shutdown_count * 60;
sleep_cnt = atoi(g_settings.shutdown_min)*60; sleep_cnt = g_settings.shutdown_min * 60;
if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 ) if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 )
{ {
perror("[SHTDCNT]: pthread_create(TimeThread)"); perror("[SHTDCNT]: pthread_create(TimeThread)");
@@ -75,7 +75,7 @@ void SHTDCNT::init()
void SHTDCNT::shutdown_counter() void SHTDCNT::shutdown_counter()
{ {
static bool sleeptimer_active = true; 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)) if ((CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby) && (!CNeutrinoApp::getInstance ()->recordingstatus))
{ {
@@ -95,11 +95,11 @@ void SHTDCNT::shutdown_counter()
else else
{ {
// reset counter // 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) { if(sleep_cnt > 0) {
sleeptimer_active = true; sleeptimer_active = true;
sleep_cnt--; sleep_cnt--;
@@ -118,5 +118,5 @@ void SHTDCNT::shutdown_counter()
void SHTDCNT::resetSleepTimer() void SHTDCNT::resetSleepTimer()
{ {
sleep_cnt = atoi(g_settings.shutdown_min)*60; sleep_cnt = g_settings.shutdown_min * 60;
} }

View File

@@ -34,6 +34,7 @@
#include <mymenu.h> #include <mymenu.h>
#include <neutrino_menue.h> #include <neutrino_menue.h>
#include <system/setting_helpers.h> #include <system/setting_helpers.h>
#include <system/helpers.h>
#include <gui/miscsettings_menu.h> #include <gui/miscsettings_menu.h>
#include <gui/cec_setup.h> #include <gui/cec_setup.h>
@@ -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); 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); 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 "); std::string shutdown_count = to_string(g_settings.shutdown_count);
CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, g_settings.shutdown_count, miscSettings_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); m2->setHint("", LOCALE_MENU_HINT_SHUTDOWN_COUNT);
COnOffNotifier * miscNotifier = new COnOffNotifier(1); COnOffNotifier * miscNotifier = new COnOffNotifier(1);
@@ -347,7 +351,7 @@ int CMiscMenue::showMiscSettingsMenuEnergy()
ms_energy->addItem(m1); ms_energy->addItem(m1);
ms_energy->addItem(m2); 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); m2->setHint("", LOCALE_MENU_HINT_INACT_TIMER);
ms_energy->addItem(m2); ms_energy->addItem(m2);
@@ -362,6 +366,9 @@ int CMiscMenue::showMiscSettingsMenuEnergy()
} }
int res = ms_energy->exec(NULL, ""); int res = ms_energy->exec(NULL, "");
g_settings.shutdown_count = atoi(shutdown_count.c_str());
delete ms_energy; delete ms_energy;
delete miscNotifier; delete miscNotifier;
return res; return res;
@@ -377,7 +384,7 @@ void CMiscMenue::showMiscSettingsMenuEpg(CMenuWidget *ms_epg)
mc1->setHint("", LOCALE_MENU_HINT_EPG_SAVE_STANDBY); 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); 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); 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); 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);

View File

@@ -61,7 +61,7 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey)
parent->hide(); parent->hide();
if(permanent) { if(permanent) {
strcpy(value,g_settings.shutdown_min); sprintf(value,"%03d", g_settings.shutdown_min);
} else { } else {
shutdown_min = g_Timerd->getSleepTimerRemaining(); // remaining shutdown time? shutdown_min = g_Timerd->getSleepTimerRemaining(); // remaining shutdown time?
sprintf(value,"%03d", shutdown_min); sprintf(value,"%03d", shutdown_min);
@@ -100,8 +100,8 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey)
int new_val = atoi(value); int new_val = atoi(value);
if(permanent) { if(permanent) {
sprintf(g_settings.shutdown_min,"%03d", new_val); g_settings.shutdown_min = new_val;
printf("permanent sleeptimer min: %s\n", g_settings.shutdown_min); printf("permanent sleeptimer min: %d\n", g_settings.shutdown_min);
} }
else if(shutdown_min != new_val) { else if(shutdown_min != new_val) {
shutdown_min = new_val; shutdown_min = new_val;

View File

@@ -388,11 +388,11 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.shutdown_real = configfile.getBool("shutdown_real" , false ); g_settings.shutdown_real = configfile.getBool("shutdown_real" , false );
g_settings.shutdown_real_rcdelay = configfile.getBool("shutdown_real_rcdelay", 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) 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.sleeptimer_min = configfile.getInt32("sleeptimer_min", 0);
g_settings.infobar_sat_display = configfile.getBool("infobar_sat_display" , true ); 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.setInt32( "hdd_noise", g_settings.hdd_noise);
configfile.setBool("shutdown_real" , g_settings.shutdown_real ); configfile.setBool("shutdown_real" , g_settings.shutdown_real );
configfile.setBool("shutdown_real_rcdelay", g_settings.shutdown_real_rcdelay); configfile.setBool("shutdown_real_rcdelay", g_settings.shutdown_real_rcdelay);
configfile.setString("shutdown_count" , g_settings.shutdown_count); configfile.setInt32("shutdown_count" , g_settings.shutdown_count);
configfile.setString("shutdown_min" , g_settings.shutdown_min ); configfile.setInt32("shutdown_min" , g_settings.shutdown_min );
configfile.setInt32("sleeptimer_min", g_settings.sleeptimer_min); configfile.setInt32("sleeptimer_min", g_settings.sleeptimer_min);
configfile.setBool("infobar_sat_display" , g_settings.infobar_sat_display ); configfile.setBool("infobar_sat_display" , g_settings.infobar_sat_display );
configfile.setBool("infobar_show_channeldesc" , g_settings.infobar_show_channeldesc ); configfile.setBool("infobar_show_channeldesc" , g_settings.infobar_show_channeldesc );

View File

@@ -68,8 +68,8 @@ struct SNeutrinoSettings
//misc //misc
int shutdown_real; int shutdown_real;
int shutdown_real_rcdelay; int shutdown_real_rcdelay;
char shutdown_count[4]; int shutdown_count;
char shutdown_min[4]; int shutdown_min;
int sleeptimer_min; int sleeptimer_min;
int record_safety_time_before; int record_safety_time_before;
int record_safety_time_after; int record_safety_time_after;
@@ -141,10 +141,10 @@ struct SNeutrinoSettings
// EPG // EPG
int epg_save; int epg_save;
int epg_save_standby; int epg_save_standby;
std::string epg_cache; std::string epg_cache; // FIXME
std::string epg_old_events; std::string epg_old_events; // FIXME
std::string epg_max_events; std::string epg_max_events; // FIXME
std::string epg_extendedcache; std::string epg_extendedcache; // FIXME
std::string epg_dir; std::string epg_dir;
int epg_scan; int epg_scan;