diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 41d361536..3aadf2bed 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -116,6 +116,7 @@ adzap.minute Minute adzap.minutes Minuten adzap.monitor Ein (dauerhaft) adzap.switchback Zurückschalten nach +adzap.writedata Schreibe Status-Daten apidselector.head Sprachauswahl audio.srs_algo Art audio.srs_algo_heavy stark @@ -947,8 +948,10 @@ mbkey.truncate Film kürzen menu.back Zurück menu.cancel Abbrechen menu.hint_a_pic Konfigurieren Sie den Audioplayer und den Bildbetrachter -menu.hint_adzap Der Werbe-Zapper schaltet nach der eingestellten Zeit wieder auf den ursprünglichen Kanal zurück -menu.hint_adzap_active Der Werbe-Zapper ist aktiv. Mit einem erneuten Aufruf wird er deaktiviert. +menu.hint_adzap Der Werbezapper schaltet nach der eingestellten Zeit wieder auf den ursprünglichen Kanal zurück +menu.hint_adzap_active Der Werbezapper ist aktiv. Mit einem erneuten Aufruf wird er deaktiviert. +menu.hint_adzap_setup Einstellungen für den Werbezapper +menu.hint_adzap_writedata Schreibe Daten über den Status des Werbezappers nach /tmp/adzap.data menu.hint_aplay Audioplayer menu.hint_aplay_setup Ändern Sie Audioplayer-Einstellungen wie Titel-Anzeige, Startverzeichnis oder Bildschirmschoner. menu.hint_audio Audio-Ausgang, Dolby Digital und SRS TruVolume Optionen und mehr diff --git a/data/locale/english.locale b/data/locale/english.locale index df7a3336b..36e9e06c2 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -116,6 +116,7 @@ adzap.minute minute adzap.minutes minutes adzap.monitor On (durable) adzap.switchback Switch back after +adzap.writedata Write status data apidselector.head Select language audio.srs_algo Type audio.srs_algo_heavy Heavy @@ -949,6 +950,8 @@ menu.cancel Cancel menu.hint_a_pic Configure audio player and picture viewer menu.hint_adzap AdZap will switch back to the current channel when the selected time is up menu.hint_adzap_active AdZap is active. With a new call it will be deactivated. +menu.hint_adzap_setup Settings for the AdZap service +menu.hint_adzap_writedata Write data according to adzap status to /tmp/adzap.data menu.hint_aplay Audio player menu.hint_aplay_setup Change title display, start directory, screen saver and more menu.hint_audio Audio output, DD\nSRS True volume options diff --git a/src/gui/adzap.cpp b/src/gui/adzap.cpp index 902efddba..70022a9b8 100644 --- a/src/gui/adzap.cpp +++ b/src/gui/adzap.cpp @@ -31,14 +31,17 @@ #include #include #include +#include #include #include #include #include #include +#include #include #define ZAPBACK_ALERT_PERIOD 15 // seconds +#define ADZAP_DATA "/tmp/adzap.data" static const struct button_label CAdZapMenuFooterButtons[] = { { NEUTRINO_ICON_BUTTON_RED, LOCALE_ADZAP_DISABLE }, @@ -167,9 +170,41 @@ void CAdZapMenu::Run() } } else if (armed) - sem_timedwait(&sem, &zapBackTime); + { + if (g_settings.adzap_writeData) + { + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += 1; + + sem_timedwait(&sem, &ts); + + int zp = g_settings.adzap_zapBackPeriod; + long int zb = zapBackTime.tv_sec + ZAPBACK_ALERT_PERIOD - ts.tv_sec; + + if (FILE *f = fopen(ADZAP_DATA, "w")) + { + fprintf(f, "%" PRIx64 "\n%s\n%d\n%d:%02d\n%ld\n%ld:%02ld\n", + channelId, + channelName.c_str(), + zp, + zp / 60, zp % 60, + zb, + zb / 60, zb % 60); + fclose(f); + } + else + printf("CAdZapMenu::%s: write data failed.\n", __func__); + } + else + sem_timedwait(&sem, &zapBackTime); + } else + { + if (access(ADZAP_DATA, F_OK) == 0) + unlink(ADZAP_DATA); sem_wait(&sem); + } if (armed) { @@ -262,20 +297,26 @@ int CAdZapMenu::exec(CMenuTarget *parent, const std::string & actionKey) parent->hide(); monitor = false; - Settings(); + ShowMenu(); return res; } -void CAdZapMenu::Settings() +void CAdZapMenu::ShowMenu() { bool show_monitor = monitorLifeTime.tv_sec; - CMenuWidget *menu = new CMenuWidget(LOCALE_ADZAP, "settings", width); + CMenuWidget *menu = new CMenuWidget(LOCALE_ADZAP, NEUTRINO_ICON_SETTINGS, width); menu->addKey(CRCInput::RC_red, this, "disable"); menu->addKey(CRCInput::RC_green, this, "enable"); menu->addKey(CRCInput::RC_blue, this, "monitor"); - menu->addIntroItems(NONEXISTANT_LOCALE, LOCALE_ADZAP_SWITCHBACK); + menu->addIntroItems(); + + CMenuOptionChooser *oc = new CMenuOptionChooser(LOCALE_ADZAP_WRITEDATA, &g_settings.adzap_writeData, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + oc->setHint("", LOCALE_MENU_HINT_ADZAP_WRITEDATA); + menu->addItem(oc); + + menu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_ADZAP_SWITCHBACK)); neutrino_locale_t minute = LOCALE_ADZAP_MINUTE; for (int shortcut = 1; shortcut < 10; shortcut++) { diff --git a/src/gui/adzap.h b/src/gui/adzap.h index f68b39721..26b2eea62 100644 --- a/src/gui/adzap.h +++ b/src/gui/adzap.h @@ -50,7 +50,7 @@ class CAdZapMenu: public CMenuTarget CAdZapMenu(); void Init(); time_t getMonitorLifeTime(); - void Settings(); + void ShowMenu(); void Update(); void Run(void); static void *Run(void *arg); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 0a581c21f..1a35f4d59 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -830,6 +830,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.epg_search_history_size = g_settings.epg_search_history.size(); g_settings.adzap_zapBackPeriod = configfile.getInt32("adzap_zapBackPeriod", 180); + g_settings.adzap_writeData = configfile.getInt32("adzap_writeData", 0); // USERMENU -> in system/settings.h //------------------------------------------- @@ -1317,6 +1318,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt64("startchannelradio_id", g_settings.startchannelradio_id); configfile.setInt32("uselastchannel", g_settings.uselastchannel); configfile.setInt32("adzap_zapBackPeriod", g_settings.adzap_zapBackPeriod); + configfile.setInt32("adzap_writeData", g_settings.adzap_writeData); //epg search g_settings.epg_search_history_size = g_settings.epg_search_history.size(); if (g_settings.epg_search_history_size > g_settings.epg_search_history_max) diff --git a/src/system/locals.h b/src/system/locals.h index 331a9fff6..dfac7511d 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -143,6 +143,7 @@ typedef enum LOCALE_ADZAP_MINUTES, LOCALE_ADZAP_MONITOR, LOCALE_ADZAP_SWITCHBACK, + LOCALE_ADZAP_WRITEDATA, LOCALE_APIDSELECTOR_HEAD, LOCALE_AUDIO_SRS_ALGO, LOCALE_AUDIO_SRS_ALGO_HEAVY, @@ -976,6 +977,8 @@ typedef enum LOCALE_MENU_HINT_A_PIC, LOCALE_MENU_HINT_ADZAP, LOCALE_MENU_HINT_ADZAP_ACTIVE, + LOCALE_MENU_HINT_ADZAP_SETUP, + LOCALE_MENU_HINT_ADZAP_WRITEDATA, LOCALE_MENU_HINT_APLAY, LOCALE_MENU_HINT_APLAY_SETUP, LOCALE_MENU_HINT_AUDIO, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index f33bb62ab..47237fb20 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -143,6 +143,7 @@ const char * locale_real_names[] = "adzap.minutes", "adzap.monitor", "adzap.switchback", + "adzap.writedata", "apidselector.head", "audio.srs_algo", "audio.srs_algo_heavy", @@ -976,6 +977,8 @@ const char * locale_real_names[] = "menu.hint_a_pic", "menu.hint_adzap", "menu.hint_adzap_active", + "menu.hint_adzap_setup", + "menu.hint_adzap_writedata", "menu.hint_aplay", "menu.hint_aplay_setup", "menu.hint_audio", diff --git a/src/system/settings.h b/src/system/settings.h index c254c7184..0c0b86f01 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -731,6 +731,7 @@ struct SNeutrinoSettings //adzap int adzap_zapBackPeriod; + int adzap_writeData; int power_standby; int hdd_sleep; @@ -884,7 +885,6 @@ const int PARENTALLOCK_PROMPT_ONSTART = 1; const int PARENTALLOCK_PROMPT_CHANGETOLOCKED = 2; const int PARENTALLOCK_PROMPT_ONSIGNAL = 3; - class CScanSettings { public: