diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 3a886560c..d30399526 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -1150,12 +1150,12 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) if (n < 0) return menu_return::RETURN_NONE; - const char hdidle[] = "/sbin/hd-idle"; - bool have_hdidle = !access(hdidle, X_OK); - if (g_settings.hdd_sleep > 0 && g_settings.hdd_sleep < 60) g_settings.hdd_sleep = 60; + const char hdidle[] = "/sbin/hd-idle"; + bool have_hdidle = !access(hdidle, X_OK); + if (have_hdidle) { system("kill $(pidof hd-idle)"); int sleep_seconds = g_settings.hdd_sleep; @@ -1171,12 +1171,22 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) } if (sleep_seconds) my_system(3, hdidle, "-i", to_string(sleep_seconds).c_str()); + + while (n--) + free(namelist[i]); + free(namelist); + return menu_return::RETURN_NONE; } const char hdparm[] = "/sbin/hdparm"; bool have_hdparm = !access(hdparm, X_OK); if (!have_hdparm) + { + while (n--) + free(namelist[i]); + free(namelist); return menu_return::RETURN_NONE; + } struct stat stat_buf; bool have_nonbb_hdparm = !::lstat(hdparm, &stat_buf) && !S_ISLNK(stat_buf.st_mode); @@ -1190,12 +1200,11 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) snprintf(M_opt, sizeof(M_opt), "-M%d", g_settings.hdd_noise); snprintf(opt, sizeof(opt), "/dev/%s",namelist[i]->d_name); - if (have_hdidle) - my_system(3, hdparm, M_opt, opt); - else if (have_nonbb_hdparm) + if (have_nonbb_hdparm) my_system(4, hdparm, M_opt, S_opt, opt); else // busybox hdparm doesn't support "-M" my_system(3, hdparm, S_opt, opt); + free(namelist[i]); } free(namelist); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index ed620ae6e..3b786e5ac 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -439,14 +439,16 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "send_remotetimer") == 0) && RemoteBoxChanExists(timerlist[selected].channel_id)) { + int pre,post; + Timer->getRecordingSafety(pre,post); CHTTPTool httpTool; std::string r_url; r_url = "http://"; r_url += RemoteBoxConnectUrl(timerlist[selected].remotebox_name); r_url += "/control/timer?action=new"; - r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + timerlist[selected].rem_pre); - r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - timerlist[selected].rem_post); - r_url += "&announce=" + to_string((int)timerlist[selected].announceTime); + r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + pre); + r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - post); + r_url += "&announce=" + to_string((int)timerlist[selected].announceTime + pre); r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id); r_url += "&aj=on"; r_url += "&rs=on"; @@ -458,13 +460,11 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "fetch_remotetimer") == 0) && LocalBoxChanExists(timerlist[selected].channel_id)) { - int pre,post; - Timer->getRecordingSafety(pre,post); std::string remotebox_name = timerlist[selected].remotebox_name; std::string eventID = to_string((int)timerlist[selected].eventID); - int res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre, - timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime, + int res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + timerlist[selected].rem_pre, + timerlist[selected].stopTime - timerlist[selected].rem_post, 0, 0, timerlist[selected].announceTime + timerlist[selected].rem_pre, TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",false); if (res == -1) @@ -473,8 +473,8 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) if (forceAdd) { - res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre, - timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime, + res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + timerlist[selected].rem_pre, + timerlist[selected].stopTime - timerlist[selected].rem_post, 0, 0, timerlist[selected].announceTime + timerlist[selected].rem_pre, TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",true); } } @@ -703,16 +703,19 @@ void CTimerList::updateEvents(void) void CTimerList::RemoteBoxSelect() { int select = 0; - CMenuWidget *m = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER); - CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) - m->addItem(new CMenuForwarder(it->rbname, true, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); + if (g_settings.timer_remotebox_ip.size() > 1) { + CMenuWidget *m = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER); + CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - m->enableSaveScreen(true); - m->exec(NULL, ""); + for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) + m->addItem(new CMenuForwarder(it->rbname, it->online, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); - delete selector; + m->enableSaveScreen(true); + m->exec(NULL, ""); + + delete selector; + } std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); std::advance(it,select); @@ -801,7 +804,10 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) { printf("Failed to parse JSON\n"); printf("%s\n", reader.getFormattedErrorMessages().c_str()); - } + it->online = false; + } else + it->online = true; + Json::Value delays = root["data"]["timer"][0]; rem_pre = atoi(delays["config"].get("pre_delay","0").asString()); diff --git a/src/system/settings.h b/src/system/settings.h index 1eefccd77..a18658c2c 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -168,6 +168,7 @@ struct timer_remotebox_item std::string pass; std::string rbname; std::string rbaddress; + bool online; }; struct SNeutrinoSettings