neutrino: add exit codes to handle some actions in neutrino's start script

EXIT_REBOOT is inactive yet; see comment in ExitRun()


Origin commit data
------------------
Branch: ni/coolstream
Commit: 30128901db
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-11-21 (Tue, 21 Nov 2017)

Origin message was:
------------------
- neutrino: add exit codes to handle some actions in neutrino's start script

EXIT_REBOOT is inactive yet; see comment in ExitRun()


------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2017-11-21 11:58:25 +01:00
parent 0931959c98
commit 5b657b84ec
2 changed files with 55 additions and 40 deletions

View File

@@ -139,6 +139,11 @@
#include <linux/reboot.h>
#include <sys/reboot.h>
#ifdef __sh__
/* the sh4 gcc seems to dislike someting about openthreads... */
#define exit _exit
#endif
#include <compatibility.h>
#include <lib/libdvbsub/dvbsub.h>
@@ -2071,7 +2076,7 @@ void CNeutrinoApp::CmdParser(int argc, char **argv)
else {
dprintf(DEBUG_NORMAL, "Usage: neutrino [-u | --enable-update] "
"[-v | --verbose 0..3]\n");
exit(1);
exit(CNeutrinoApp::EXIT_ERROR);
}
}
}
@@ -2089,7 +2094,7 @@ void CNeutrinoApp::SetupFrameBuffer()
frameBuffer->setOsdResolutions();
if (frameBuffer->osd_resolutions.empty()) {
dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
exit(-1);
exit(CNeutrinoApp::EXIT_ERROR);
}
uint32_t ort;
@@ -2119,7 +2124,7 @@ void CNeutrinoApp::SetupFrameBuffer()
if (setFbMode == -1) {
dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
exit(-1);
exit(CNeutrinoApp::EXIT_ERROR);
}
frameBuffer->Clear();
frameBufferInitialized = true;
@@ -2664,8 +2669,8 @@ TIMER_STOP("################################## after all #######################
#endif
CFlashUpdateCheck::getInstance()->startThread();
}
RealRun();
RealRun();
ExitRun(g_info.hw_caps->can_shutdown);
return 0;
@@ -3857,9 +3862,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
return messages_return::handled;
}
else if( msg == NeutrinoMessages::REBOOT ) {
FILE *f = fopen("/tmp/.reboot", "w");
fclose(f);
ExitRun();
ExitRun(CNeutrinoApp::EXIT_REBOOT);
}
else if (msg == NeutrinoMessages::EVT_POPUP || msg == NeutrinoMessages::EVT_EXTMSG) {
if (mode != NeutrinoModes::mode_scart && mode != NeutrinoModes::mode_standby) {
@@ -4025,22 +4028,35 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
extern time_t timer_minutes;//timermanager.cpp
extern bool timer_is_rec;//timermanager.cpp
void CNeutrinoApp::ExitRun(int can_shutdown)
void CNeutrinoApp::ExitRun(int exit_code)
{
/* can_shutdown is actually our exit code */
printf("[neutrino] %s can_shutdown: %d\n", __func__, can_shutdown);
bool do_shutdown = true;
bool do_exiting = true;
CRecordManager::getInstance()->StopAutoRecord();
if(CRecordManager::getInstance()->RecordingStatus() || cYTCache::getInstance()->isActive())
{
do_shutdown =
(ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo,
do_exiting = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo,
CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, DEFAULT_TIMEOUT, true) == CMsgBox::mbrYes);
}
if (!do_shutdown)
if (!do_exiting)
return;
/*
For compatibility: /tmp/.reboot is not really needed anymore
if we use the defined exit code 2 instead of this flagfile.
Next block is just to avoid force changes in start scripts.
*/
if (exit_code == CNeutrinoApp::EXIT_REBOOT)
{
exit_code = CNeutrinoApp::EXIT_NORMAL;
FILE *f = fopen("/tmp/.reboot", "w");
fclose(f);
}
else
unlink("/tmp/.reboot");
printf("[neutrino] %s(int %d)\n", __func__, exit_code);
printf("[neutrino] hw_caps->can_shutdown: %d\n", g_info.hw_caps->can_shutdown);
stop_lcd4l_support(); //NI lcd4l-support
//NI InfoIcons
@@ -4068,7 +4084,7 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
}
/* on shutdown force load new fst */
if (can_shutdown)
if (exit_code == CNeutrinoApp::EXIT_SHUTDOWN)
CheckFastScan(true, false);
CVFD::getInstance()->setMode(CVFD::MODE_SHUTDOWN);
@@ -4082,15 +4098,17 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
perror(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT " failed");
printf("entering off state\n");
printf("timer_minutes: %ld\n", timer_minutes);
mode = NeutrinoModes::mode_off;
printf("timer_minutes: %ld\n", timer_minutes);
int leds = 0;
int bright = 0;
#if HAVE_COOL_HARDWARE
if (can_shutdown) {
if (exit_code == CNeutrinoApp::EXIT_SHUTDOWN)
{
leds = 0x40;
switch (g_settings.led_deep_mode){
switch (g_settings.led_deep_mode)
{
case 0:
leds = 0x0; // leds off
break;
@@ -4156,14 +4174,10 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
delete SHTDCNT::getInstance();
stop_video();
printf("[neutrino] This is the end. exiting with code %d\n", can_shutdown);
Cleanup();
#ifdef __sh__
/* the sh4 gcc seems to dislike someting about openthreads... */
_exit(can_shutdown);
#else
exit(can_shutdown);
#endif
printf("[neutrino] This is the end. Exiting with code %d\n", exit_code);
exit(exit_code);
}
void CNeutrinoApp::saveEpg(int _mode)
@@ -4583,8 +4597,9 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
if(actionKey == "help_recording") {
ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMsgBox::mbrBack, CMsgBox::mbBack);
}
else if(actionKey=="shutdown") {
ExitRun(1);
else if(actionKey=="shutdown")
{
ExitRun(g_info.hw_caps->can_shutdown);
}
else if(actionKey=="need_reboot")
{
@@ -4594,10 +4609,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
}
else if(actionKey=="reboot")
{
FILE *f = fopen("/tmp/.reboot", "w");
fclose(f);
ExitRun();
unlink("/tmp/.reboot");
ExitRun(CNeutrinoApp::EXIT_REBOOT);
returnval = menu_return::RETURN_NONE;
}
else if (actionKey=="clock_switch")
@@ -4773,7 +4785,8 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
for(int i = 3; i < 256; i++)
close(i);
execvp(global_argv[0], global_argv); // no return if successful
exit(1);
exit(CNeutrinoApp::EXIT_REBOOT); // should never be reached
}
}
else if(actionKey == "moviedir") {
@@ -4948,11 +4961,7 @@ void sighandler (int signum)
delete CVFD::getInstance();
delete SHTDCNT::getInstance();
stop_video();
#ifdef __sh__
_exit(0);
#else
exit(0);
#endif
exit(CNeutrinoApp::EXIT_NORMAL);
default:
break;
}