diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 0c168d971..b4fd30f25 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1633,12 +1633,11 @@ bool CRecordManager::RunStartScript(void) if(RecordingStatus()) return false; - puts("[neutrino.cpp] executing " NEUTRINO_RECORDING_START_SCRIPT "."); - if (my_system(NEUTRINO_RECORDING_START_SCRIPT) != 0) { - perror(NEUTRINO_RECORDING_START_SCRIPT " failed"); - return false; - } - return true; +#if 0 + printf("CRecordManager::%s: wakeup hdd...\n", __func__); + wakeup_hdd(g_settings.network_nfs_recordingdir.c_str(),true); +#endif + return exec_controlscript(NEUTRINO_RECORDING_START_SCRIPT); } bool CRecordManager::RunStopScript(void) @@ -1647,12 +1646,7 @@ bool CRecordManager::RunStopScript(void) if(RecordingStatus()) return false; - puts("[neutrino.cpp] executing " NEUTRINO_RECORDING_ENDED_SCRIPT "."); - if (my_system(NEUTRINO_RECORDING_ENDED_SCRIPT) != 0) { - perror(NEUTRINO_RECORDING_ENDED_SCRIPT " failed"); - return false; - } - return true; + return exec_controlscript(NEUTRINO_RECORDING_ENDED_SCRIPT); } /* diff --git a/src/driver/shutdown_count.cpp b/src/driver/shutdown_count.cpp index 3fd2c5585..1da83723b 100644 --- a/src/driver/shutdown_count.cpp +++ b/src/driver/shutdown_count.cpp @@ -125,9 +125,7 @@ void SHTDCNT::shutdown_counter() } else if(sleeptimer_active && !CNeutrinoApp::getInstance ()->recordingstatus) { sleeptimer_active = false; - puts("[SHTDCNT] executing " NEUTRINO_ENTER_INACTIVITY_SCRIPT "."); - if (my_system(NEUTRINO_ENTER_INACTIVITY_SCRIPT) != 0) - perror(NEUTRINO_ENTER_INACTIVITY_SCRIPT " failed"); + exec_controlscript(NEUTRINO_ENTER_INACTIVITY_SCRIPT); printf("[SHTDCNT] sleep-timer send NeutrinoMessages::SLEEPTIMER\n"); g_RCInput->postMsg(NeutrinoMessages::SLEEPTIMER, 1); diff --git a/src/global.h b/src/global.h index f864dd14e..f2af65cce 100644 --- a/src/global.h +++ b/src/global.h @@ -29,25 +29,26 @@ #define NEUTRINO_CPP extern #endif -#define NEUTRINO_SETTINGS_FILE CONFIGDIR "/neutrino.conf" +#define NEUTRINO_SETTINGS_FILE CONFIGDIR "/neutrino.conf" +#define NEUTRINO_SCAN_SETTINGS_FILE CONFIGDIR "/scan.conf" +#define NEUTRINO_PARENTALLOCKED_FILE DATADIR "/neutrino/.plocked" -#define NEUTRINO_RECORDING_TIMER_SCRIPT CONTROLDIR "/recording.timer" -#define NEUTRINO_RECORDING_START_SCRIPT CONTROLDIR "/recording.start" -#define NEUTRINO_RECORDING_ENDED_SCRIPT CONTROLDIR "/recording.end" -#define NEUTRINO_ENTER_STANDBY_SCRIPT CONTROLDIR "/standby.on" -#define NEUTRINO_LEAVE_STANDBY_SCRIPT CONTROLDIR "/standby.off" -#define NEUTRINO_ENTER_INACTIVITY_SCRIPT CONTROLDIR "/inactivity.on" -#define NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT CONTROLDIR "/deepstandby.on" -#define NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT CONTROLDIR "/deepstandby.off" +// control scripts +#define NEUTRINO_RECORDING_TIMER_SCRIPT "recording.timer" +#define NEUTRINO_RECORDING_START_SCRIPT "recording.start" +#define NEUTRINO_RECORDING_ENDED_SCRIPT "recording.end" +#define NEUTRINO_ENTER_STANDBY_SCRIPT "standby.on" +#define NEUTRINO_LEAVE_STANDBY_SCRIPT "standby.off" +#define NEUTRINO_ENTER_INACTIVITY_SCRIPT "inactivity.on" +#define NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT "deepstandby.on" +#define NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT "deepstandby.off" +#define NEUTRINO_APP_START_SCRIPT "neutrino.start" + +// control scripts w/o counterparts in /var #define NEUTRINO_ENTER_FLASH_SCRIPT CONTROLDIR "/flash.start" -#define NEUTRINO_APP_START_SCRIPT CONTROLDIR "/neutrino.start" -#define NEUTRINO_SCAN_SETTINGS_FILE CONFIGDIR "/scan.conf" -#define NEUTRINO_PARENTALLOCKED_FILE DATADIR "/neutrino/.plocked" - #define COVERDIR_TMP "/tmp/.cover" - #define LOGODIR ICONSDIR "/logo" #define LOGODIR_VAR ICONSDIR_VAR "/logo" #define LOGODIR_TMP "/tmp/.logo" diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 1a0212ec1..bf78b6946 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -90,8 +90,8 @@ extern cVideo * videoDecoder; // check if files to be added are already in the playlist #define AUDIOPLAYER_CHECK_FOR_DUPLICATES -#define AUDIOPLAYER_START_SCRIPT CONTROLDIR "/audioplayer.start" -#define AUDIOPLAYER_END_SCRIPT CONTROLDIR "/audioplayer.end" +#define AUDIOPLAYER_START_SCRIPT "audioplayer.start" +#define AUDIOPLAYER_END_SCRIPT "audioplayer.end" #define DEFAULT_RADIOSTATIONS_XMLFILE CONFIGDIR "/radio-stations.xml" #define DEFAULT_RADIOFAVORITES_XMLFILE CONFIGDIR "/radio-favorites.xml" @@ -316,9 +316,7 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) printf("[audioplayer.cpp] wakeup_hdd(%s)\n", g_settings.network_nfs_audioplayerdir.c_str()); wakeup_hdd(g_settings.network_nfs_audioplayerdir.c_str()/*,true*/); - puts("[audioplayer.cpp] executing " AUDIOPLAYER_START_SCRIPT "."); - if (my_system(AUDIOPLAYER_START_SCRIPT) != 0) - perror(AUDIOPLAYER_START_SCRIPT " failed"); + exec_controlscript(AUDIOPLAYER_START_SCRIPT); int res = show(); @@ -328,9 +326,7 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) m_frameBuffer->useBackground(usedBackground); m_frameBuffer->paintBackground(); - puts("[audioplayer.cpp] executing " AUDIOPLAYER_END_SCRIPT "."); - if (my_system(AUDIOPLAYER_END_SCRIPT) != 0) - perror(AUDIOPLAYER_END_SCRIPT " failed"); + exec_controlscript(AUDIOPLAYER_END_SCRIPT); //g_Zapit->unlockPlayBack(); CZapit::getInstance()->EnablePlayback(true); diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index a614d6f3e..65dfa2970 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -91,8 +91,8 @@ #define LCD_MODE CVFD::MODE_MOVIE #endif -#define MOVIEPLAYER_START_SCRIPT CONTROLDIR "/movieplayer.start" -#define MOVIEPLAYER_END_SCRIPT CONTROLDIR "/movieplayer.end" +#define MOVIEPLAYER_START_SCRIPT "movieplayer.start" +#define MOVIEPLAYER_END_SCRIPT "movieplayer.end" extern cVideo * videoDecoder; extern CRemoteControl *g_RemoteControl; /* neutrino.cpp */ @@ -389,11 +389,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) } } - if (!access(MOVIEPLAYER_START_SCRIPT, X_OK)) { - puts("[movieplayer.cpp] executing " MOVIEPLAYER_START_SCRIPT "."); - if (my_system(MOVIEPLAYER_START_SCRIPT) != 0) - perror(MOVIEPLAYER_START_SCRIPT " failed"); - } + exec_controlscript(MOVIEPLAYER_START_SCRIPT); Cleanup(); ClearFlags(); @@ -481,11 +477,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) bookmarkmanager->flush(); - if (!access(MOVIEPLAYER_END_SCRIPT, X_OK)) { - puts("[movieplayer.cpp] executing " MOVIEPLAYER_END_SCRIPT "."); - if (my_system(MOVIEPLAYER_END_SCRIPT) != 0) - perror(MOVIEPLAYER_END_SCRIPT " failed"); - } + exec_controlscript(MOVIEPLAYER_END_SCRIPT); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index dfa1f6f0d..25103b77c 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -82,8 +82,8 @@ extern cVideo * videoDecoder; -#define PICTUREVIEWER_START_SCRIPT CONTROLDIR "/pictureviewer.start" -#define PICTUREVIEWER_END_SCRIPT CONTROLDIR "/pictureviewer.end" +#define PICTUREVIEWER_START_SCRIPT "pictureviewer.start" +#define PICTUREVIEWER_END_SCRIPT "pictureviewer.end" //------------------------------------------------------------------------ bool comparePictureByDate (const CPicture& a, const CPicture& b) @@ -194,9 +194,7 @@ int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey) if (parent) parent->hide(); - puts("[pictureviewer.cpp] executing " PICTUREVIEWER_START_SCRIPT "."); - if (my_system(PICTUREVIEWER_START_SCRIPT) != 0) - perror(PICTUREVIEWER_START_SCRIPT " failed"); + exec_controlscript(PICTUREVIEWER_START_SCRIPT); // remember last mode m_LastMode = CNeutrinoApp::getInstance()->getMode(); @@ -227,9 +225,7 @@ int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey) CZapit::getInstance()->EnablePlayback(true); } - puts("[pictureviewer.cpp] executing " PICTUREVIEWER_END_SCRIPT "."); - if (my_system(PICTUREVIEWER_END_SCRIPT) != 0) - perror(PICTUREVIEWER_END_SCRIPT " failed"); + exec_controlscript(PICTUREVIEWER_END_SCRIPT); // Restore previous background if (usedBackground) { diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 3d2591f97..44e89f460 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -59,8 +59,8 @@ extern cVideo * videoDecoder; -#define NEUTRINO_SCAN_START_SCRIPT CONFIGDIR "/scan.start" -#define NEUTRINO_SCAN_STOP_SCRIPT CONFIGDIR "/scan.stop" +#define NEUTRINO_SCAN_START_SCRIPT "scan.start" +#define NEUTRINO_SCAN_STOP_SCRIPT "scan.stop" #define BAR_BORDER 2 #define BAR_WIDTH 150 @@ -291,10 +291,8 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) } success = false; - if(!manual) { - if (my_system(NEUTRINO_SCAN_START_SCRIPT) != 0) - perror(NEUTRINO_SCAN_START_SCRIPT " failed"); - } + if (!manual) + exec_controlscript(NEUTRINO_SCAN_START_SCRIPT); g_Zapit->setScanBouquetMode( (CZapitClient::bouquetMode)scansettings.bouquetMode); @@ -359,10 +357,9 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) /* to join scan thread */ g_Zapit->stopScan(); - if(!manual) { - if (my_system(NEUTRINO_SCAN_STOP_SCRIPT) != 0) - perror(NEUTRINO_SCAN_STOP_SCRIPT " failed"); - } + if (!manual) + exec_controlscript(NEUTRINO_SCAN_STOP_SCRIPT); + if(!test) { CComponentsHeader header(x, y, width, hheight, success ? LOCALE_SCANTS_FINISHED : (canceled ? LOCALE_SCANTS_CANCELED : LOCALE_SCANTS_FAILED)); header.paint(CC_SAVE_SCREEN_NO); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index bb69031e0..9f613bf6b 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -330,8 +330,11 @@ std::string ttx_font_file = ""; int CNeutrinoApp::loadSetup(const char * fname) { char cfg_key[81]; + int erg = 0; + + configfile.clear(); // load settings; setup defaults if (!configfile.loadConfig(fname)) @@ -2434,11 +2437,7 @@ bool is_wakeup() printf("[timerd] wakeup from standby: %s\n", wakeup ? "yes" : "no"); if (!wakeup) - { - puts("[neutrino.cpp] executing " NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT "."); - if (my_system(NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT) != 0) - perror(NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT " failed"); - } + exec_controlscript(NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT); return wakeup; } @@ -2447,9 +2446,7 @@ int CNeutrinoApp::run(int argc, char **argv) { neutrino_start_time = time_monotonic(); - puts("[neutrino] executing " NEUTRINO_APP_START_SCRIPT "."); - if (my_system(NEUTRINO_APP_START_SCRIPT) != 0) - perror(NEUTRINO_APP_START_SCRIPT " failed"); + exec_controlscript(NEUTRINO_APP_START_SCRIPT); CmdParser(argc, argv); @@ -3753,7 +3750,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) return messages_return::handled; } else if( msg == NeutrinoMessages::ANNOUNCE_RECORD) { - my_system(NEUTRINO_RECORDING_TIMER_SCRIPT); + exec_controlscript(NEUTRINO_RECORDING_TIMER_SCRIPT); CTimerd::RecordingInfo * eventinfo = (CTimerd::RecordingInfo *) data; if (g_settings.recording_type == RECORDING_FILE) { char * recordingDir = eventinfo->recordingDir; @@ -4091,9 +4088,7 @@ void CNeutrinoApp::ExitRun(int exit_code) g_settings.shutdown_timer_record_type = timer_is_rec; saveSetup(NEUTRINO_SETTINGS_FILE); - puts("[neutrino.cpp] executing " NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT "."); - if (my_system(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT) != 0) - perror(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT " failed"); + exec_controlscript(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT); printf("entering off state\n"); mode = NeutrinoModes::mode_off; @@ -4387,9 +4382,8 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) //remember tuned channel-id standby_channel_id = CZapit::getInstance()->GetCurrentChannelID(); - puts("[neutrino.cpp] executing " NEUTRINO_ENTER_STANDBY_SCRIPT "."); - if (my_system(NEUTRINO_ENTER_STANDBY_SCRIPT) != 0) - perror(NEUTRINO_ENTER_STANDBY_SCRIPT " failed"); + exec_controlscript(NEUTRINO_ENTER_STANDBY_SCRIPT); + CEpgScan::getInstance()->Start(true); bool alive = recordingstatus || CEpgScan::getInstance()->Running() || CStreamManager::getInstance()->StreamStatus(); @@ -4440,9 +4434,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) if (g_info.hw_caps->has_fan) CFanControlNotifier::setSpeed(g_settings.fan_speed); - puts("[neutrino.cpp] executing " NEUTRINO_LEAVE_STANDBY_SCRIPT "."); - if (my_system(NEUTRINO_LEAVE_STANDBY_SCRIPT) != 0) - perror(NEUTRINO_LEAVE_STANDBY_SCRIPT " failed"); + exec_controlscript(NEUTRINO_LEAVE_STANDBY_SCRIPT); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); CVFD::getInstance()->setBacklight(g_settings.backlight_tv);