mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
- neutrino: add exit codes to handle some actions in neutrino's start script
EXIT_REBOOT is inactive yet; see comment in ExitRun() Conflicts: src/neutrino.cpp Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -137,6 +137,11 @@
|
|||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
#include <sys/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 <compatibility.h>
|
||||||
|
|
||||||
#include <lib/libdvbsub/dvbsub.h>
|
#include <lib/libdvbsub/dvbsub.h>
|
||||||
@@ -1929,7 +1934,7 @@ void CNeutrinoApp::CmdParser(int argc, char **argv)
|
|||||||
else {
|
else {
|
||||||
dprintf(DEBUG_NORMAL, "Usage: neutrino [-u | --enable-update] "
|
dprintf(DEBUG_NORMAL, "Usage: neutrino [-u | --enable-update] "
|
||||||
"[-v | --verbose 0..3]\n");
|
"[-v | --verbose 0..3]\n");
|
||||||
exit(1);
|
exit(CNeutrinoApp::EXIT_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1947,7 +1952,7 @@ void CNeutrinoApp::SetupFrameBuffer()
|
|||||||
frameBuffer->setOsdResolutions();
|
frameBuffer->setOsdResolutions();
|
||||||
if (frameBuffer->osd_resolutions.empty()) {
|
if (frameBuffer->osd_resolutions.empty()) {
|
||||||
dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
|
dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
|
||||||
exit(-1);
|
exit(CNeutrinoApp::EXIT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ort;
|
uint32_t ort;
|
||||||
@@ -1977,7 +1982,7 @@ void CNeutrinoApp::SetupFrameBuffer()
|
|||||||
|
|
||||||
if (setFbMode == -1) {
|
if (setFbMode == -1) {
|
||||||
dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
|
dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
|
||||||
exit(-1);
|
exit(CNeutrinoApp::EXIT_ERROR);
|
||||||
}
|
}
|
||||||
frameBuffer->Clear();
|
frameBuffer->Clear();
|
||||||
frameBufferInitialized = true;
|
frameBufferInitialized = true;
|
||||||
@@ -2483,8 +2488,8 @@ TIMER_STOP("################################## after all #######################
|
|||||||
hintBox->hide();
|
hintBox->hide();
|
||||||
delete hintBox;
|
delete hintBox;
|
||||||
}
|
}
|
||||||
RealRun();
|
|
||||||
|
|
||||||
|
RealRun();
|
||||||
ExitRun(g_info.hw_caps->can_shutdown);
|
ExitRun(g_info.hw_caps->can_shutdown);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3628,9 +3633,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
|
|||||||
return messages_return::handled;
|
return messages_return::handled;
|
||||||
}
|
}
|
||||||
else if( msg == NeutrinoMessages::REBOOT ) {
|
else if( msg == NeutrinoMessages::REBOOT ) {
|
||||||
FILE *f = fopen("/tmp/.reboot", "w");
|
ExitRun(CNeutrinoApp::EXIT_REBOOT);
|
||||||
fclose(f);
|
|
||||||
ExitRun();
|
|
||||||
}
|
}
|
||||||
else if (msg == NeutrinoMessages::EVT_POPUP || msg == NeutrinoMessages::EVT_EXTMSG) {
|
else if (msg == NeutrinoMessages::EVT_POPUP || msg == NeutrinoMessages::EVT_EXTMSG) {
|
||||||
if (mode != NeutrinoModes::mode_scart && mode != NeutrinoModes::mode_standby) {
|
if (mode != NeutrinoModes::mode_scart && mode != NeutrinoModes::mode_standby) {
|
||||||
@@ -3796,22 +3799,35 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
|
|||||||
extern time_t timer_minutes;//timermanager.cpp
|
extern time_t timer_minutes;//timermanager.cpp
|
||||||
extern bool timer_is_rec;//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 */
|
bool do_exiting = true;
|
||||||
printf("[neutrino] %s can_shutdown: %d\n", __func__, can_shutdown);
|
|
||||||
|
|
||||||
bool do_shutdown = true;
|
|
||||||
CRecordManager::getInstance()->StopAutoRecord();
|
CRecordManager::getInstance()->StopAutoRecord();
|
||||||
if(CRecordManager::getInstance()->RecordingStatus() || cYTCache::getInstance()->isActive())
|
if(CRecordManager::getInstance()->RecordingStatus() || cYTCache::getInstance()->isActive())
|
||||||
{
|
{
|
||||||
do_shutdown =
|
do_exiting = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo,
|
||||||
(ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo,
|
|
||||||
CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, DEFAULT_TIMEOUT, true) == CMsgBox::mbrYes);
|
CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, DEFAULT_TIMEOUT, true) == CMsgBox::mbrYes);
|
||||||
}
|
}
|
||||||
if (!do_shutdown)
|
if (!do_exiting)
|
||||||
return;
|
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);
|
||||||
|
|
||||||
if (SDTreloadChannels)
|
if (SDTreloadChannels)
|
||||||
SDT_ReloadChannels();
|
SDT_ReloadChannels();
|
||||||
|
|
||||||
@@ -3833,7 +3849,7 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* on shutdown force load new fst */
|
/* on shutdown force load new fst */
|
||||||
if (can_shutdown)
|
if (exit_code == CNeutrinoApp::EXIT_SHUTDOWN)
|
||||||
CheckFastScan(true, false);
|
CheckFastScan(true, false);
|
||||||
|
|
||||||
CVFD::getInstance()->setMode(CVFD::MODE_SHUTDOWN);
|
CVFD::getInstance()->setMode(CVFD::MODE_SHUTDOWN);
|
||||||
@@ -3847,15 +3863,17 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
|
|||||||
perror(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT " failed");
|
perror(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT " failed");
|
||||||
|
|
||||||
printf("entering off state\n");
|
printf("entering off state\n");
|
||||||
printf("timer_minutes: %ld\n", timer_minutes);
|
|
||||||
mode = NeutrinoModes::mode_off;
|
mode = NeutrinoModes::mode_off;
|
||||||
|
|
||||||
|
printf("timer_minutes: %ld\n", timer_minutes);
|
||||||
int leds = 0;
|
int leds = 0;
|
||||||
int bright = 0;
|
int bright = 0;
|
||||||
#if HAVE_COOL_HARDWARE
|
#if HAVE_COOL_HARDWARE
|
||||||
if (can_shutdown) {
|
if (exit_code == CNeutrinoApp::EXIT_SHUTDOWN)
|
||||||
|
{
|
||||||
leds = 0x40;
|
leds = 0x40;
|
||||||
switch (g_settings.led_deep_mode){
|
switch (g_settings.led_deep_mode)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
leds = 0x0; // leds off
|
leds = 0x0; // leds off
|
||||||
break;
|
break;
|
||||||
@@ -3921,14 +3939,10 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
|
|||||||
delete SHTDCNT::getInstance();
|
delete SHTDCNT::getInstance();
|
||||||
stop_video();
|
stop_video();
|
||||||
|
|
||||||
printf("[neutrino] This is the end. exiting with code %d\n", can_shutdown);
|
|
||||||
Cleanup();
|
Cleanup();
|
||||||
#ifdef __sh__
|
|
||||||
/* the sh4 gcc seems to dislike someting about openthreads... */
|
printf("[neutrino] This is the end. Exiting with code %d\n", exit_code);
|
||||||
_exit(can_shutdown);
|
exit(exit_code);
|
||||||
#else
|
|
||||||
exit(can_shutdown);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNeutrinoApp::saveEpg(int _mode)
|
void CNeutrinoApp::saveEpg(int _mode)
|
||||||
@@ -4333,15 +4347,13 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
|
|||||||
if(actionKey == "help_recording") {
|
if(actionKey == "help_recording") {
|
||||||
ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMsgBox::mbrBack, CMsgBox::mbBack);
|
ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMsgBox::mbrBack, CMsgBox::mbBack);
|
||||||
}
|
}
|
||||||
else if(actionKey=="shutdown") {
|
else if(actionKey=="shutdown")
|
||||||
ExitRun(1);
|
{
|
||||||
|
ExitRun(g_info.hw_caps->can_shutdown);
|
||||||
}
|
}
|
||||||
else if(actionKey=="reboot")
|
else if(actionKey=="reboot")
|
||||||
{
|
{
|
||||||
FILE *f = fopen("/tmp/.reboot", "w");
|
ExitRun(CNeutrinoApp::EXIT_REBOOT);
|
||||||
fclose(f);
|
|
||||||
ExitRun();
|
|
||||||
unlink("/tmp/.reboot");
|
|
||||||
returnval = menu_return::RETURN_NONE;
|
returnval = menu_return::RETURN_NONE;
|
||||||
}
|
}
|
||||||
else if (actionKey=="clock_switch")
|
else if (actionKey=="clock_switch")
|
||||||
@@ -4457,7 +4469,8 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
|
|||||||
for(int i = 3; i < 256; i++)
|
for(int i = 3; i < 256; i++)
|
||||||
close(i);
|
close(i);
|
||||||
execvp(global_argv[0], global_argv); // no return if successful
|
execvp(global_argv[0], global_argv); // no return if successful
|
||||||
exit(1);
|
|
||||||
|
exit(CNeutrinoApp::EXIT_REBOOT); // should never be reached
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(actionKey == "moviedir") {
|
else if(actionKey == "moviedir") {
|
||||||
@@ -4605,11 +4618,7 @@ void sighandler (int signum)
|
|||||||
delete CVFD::getInstance();
|
delete CVFD::getInstance();
|
||||||
delete SHTDCNT::getInstance();
|
delete SHTDCNT::getInstance();
|
||||||
stop_video();
|
stop_video();
|
||||||
#ifdef __sh__
|
exit(CNeutrinoApp::EXIT_NORMAL);
|
||||||
_exit(0);
|
|
||||||
#else
|
|
||||||
exit(0);
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,14 @@ class CScanSettings;
|
|||||||
class CNeutrinoApp : public CMenuTarget, CChangeObserver, public sigc::trackable
|
class CNeutrinoApp : public CMenuTarget, CChangeObserver, public sigc::trackable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum // Neutrino's exit codes to be handled in it's start script
|
||||||
|
{
|
||||||
|
EXIT_ERROR = -1,
|
||||||
|
EXIT_NORMAL = 0, // g_info.hw_caps->can_shutdown == 0
|
||||||
|
EXIT_SHUTDOWN = 1, // g_info.hw_caps->can_shutdown == 1
|
||||||
|
EXIT_REBOOT = 2
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
RECORDING_OFF = 0,
|
RECORDING_OFF = 0,
|
||||||
@@ -67,8 +75,6 @@ public:
|
|||||||
RECORDING_VCR = 2,
|
RECORDING_VCR = 2,
|
||||||
RECORDING_FILE = 3
|
RECORDING_FILE = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CFrameBuffer * frameBuffer;
|
CFrameBuffer * frameBuffer;
|
||||||
|
Reference in New Issue
Block a user