- adzap: add possibility to write status data to /tmp/adzap.data

This commit is contained in:
svenhoefer
2016-02-29 10:31:22 +01:00
parent 1dfc1bc452
commit 00e5cf6759
8 changed files with 64 additions and 9 deletions

View File

@@ -116,6 +116,7 @@ adzap.minute Minute
adzap.minutes Minuten adzap.minutes Minuten
adzap.monitor Ein (dauerhaft) adzap.monitor Ein (dauerhaft)
adzap.switchback Zurückschalten nach adzap.switchback Zurückschalten nach
adzap.writedata Schreibe Status-Daten
apidselector.head Sprachauswahl apidselector.head Sprachauswahl
audio.srs_algo Art audio.srs_algo Art
audio.srs_algo_heavy stark audio.srs_algo_heavy stark
@@ -947,8 +948,10 @@ mbkey.truncate Film kürzen
menu.back Zurück menu.back Zurück
menu.cancel Abbrechen menu.cancel Abbrechen
menu.hint_a_pic Konfigurieren Sie den Audioplayer und den Bildbetrachter 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 Der Werbezapper 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_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 Audioplayer
menu.hint_aplay_setup Ändern Sie Audioplayer-Einstellungen wie Titel-Anzeige, Startverzeichnis oder Bildschirmschoner. 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 menu.hint_audio Audio-Ausgang, Dolby Digital und SRS TruVolume Optionen und mehr

View File

@@ -116,6 +116,7 @@ adzap.minute minute
adzap.minutes minutes adzap.minutes minutes
adzap.monitor On (durable) adzap.monitor On (durable)
adzap.switchback Switch back after adzap.switchback Switch back after
adzap.writedata Write status data
apidselector.head Select language apidselector.head Select language
audio.srs_algo Type audio.srs_algo Type
audio.srs_algo_heavy Heavy audio.srs_algo_heavy Heavy
@@ -949,6 +950,8 @@ menu.cancel Cancel
menu.hint_a_pic Configure audio player and picture viewer 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 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_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 Audio player
menu.hint_aplay_setup Change title display, start directory, screen saver and more menu.hint_aplay_setup Change title display, start directory, screen saver and more
menu.hint_audio Audio output, DD\nSRS True volume options menu.hint_audio Audio output, DD\nSRS True volume options

View File

@@ -31,14 +31,17 @@
#include <stdlib.h> #include <stdlib.h>
#include <global.h> #include <global.h>
#include <neutrino.h> #include <neutrino.h>
#include <mymenu.h>
#include <algorithm> #include <algorithm>
#include <gui/adzap.h> #include <gui/adzap.h>
#include <gui/widget/hintbox.h> #include <gui/widget/hintbox.h>
#include <eitd/sectionsd.h> #include <eitd/sectionsd.h>
#include <driver/screen_max.h> #include <driver/screen_max.h>
#include <system/helpers.h>
#include <system/set_threadname.h> #include <system/set_threadname.h>
#define ZAPBACK_ALERT_PERIOD 15 // seconds #define ZAPBACK_ALERT_PERIOD 15 // seconds
#define ADZAP_DATA "/tmp/adzap.data"
static const struct button_label CAdZapMenuFooterButtons[] = { static const struct button_label CAdZapMenuFooterButtons[] = {
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_ADZAP_DISABLE }, { NEUTRINO_ICON_BUTTON_RED, LOCALE_ADZAP_DISABLE },
@@ -167,9 +170,41 @@ void CAdZapMenu::Run()
} }
} }
else if (armed) 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 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); sem_wait(&sem);
}
if (armed) if (armed)
{ {
@@ -262,20 +297,26 @@ int CAdZapMenu::exec(CMenuTarget *parent, const std::string & actionKey)
parent->hide(); parent->hide();
monitor = false; monitor = false;
Settings(); ShowMenu();
return res; return res;
} }
void CAdZapMenu::Settings() void CAdZapMenu::ShowMenu()
{ {
bool show_monitor = monitorLifeTime.tv_sec; 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_red, this, "disable");
menu->addKey(CRCInput::RC_green, this, "enable"); menu->addKey(CRCInput::RC_green, this, "enable");
menu->addKey(CRCInput::RC_blue, this, "monitor"); 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; neutrino_locale_t minute = LOCALE_ADZAP_MINUTE;
for (int shortcut = 1; shortcut < 10; shortcut++) { for (int shortcut = 1; shortcut < 10; shortcut++) {

View File

@@ -50,7 +50,7 @@ class CAdZapMenu: public CMenuTarget
CAdZapMenu(); CAdZapMenu();
void Init(); void Init();
time_t getMonitorLifeTime(); time_t getMonitorLifeTime();
void Settings(); void ShowMenu();
void Update(); void Update();
void Run(void); void Run(void);
static void *Run(void *arg); static void *Run(void *arg);

View File

@@ -830,6 +830,7 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.epg_search_history_size = g_settings.epg_search_history.size(); g_settings.epg_search_history_size = g_settings.epg_search_history.size();
g_settings.adzap_zapBackPeriod = configfile.getInt32("adzap_zapBackPeriod", 180); g_settings.adzap_zapBackPeriod = configfile.getInt32("adzap_zapBackPeriod", 180);
g_settings.adzap_writeData = configfile.getInt32("adzap_writeData", 0);
// USERMENU -> in system/settings.h // USERMENU -> in system/settings.h
//------------------------------------------- //-------------------------------------------
@@ -1317,6 +1318,7 @@ void CNeutrinoApp::saveSetup(const char * fname)
configfile.setInt64("startchannelradio_id", g_settings.startchannelradio_id); configfile.setInt64("startchannelradio_id", g_settings.startchannelradio_id);
configfile.setInt32("uselastchannel", g_settings.uselastchannel); configfile.setInt32("uselastchannel", g_settings.uselastchannel);
configfile.setInt32("adzap_zapBackPeriod", g_settings.adzap_zapBackPeriod); configfile.setInt32("adzap_zapBackPeriod", g_settings.adzap_zapBackPeriod);
configfile.setInt32("adzap_writeData", g_settings.adzap_writeData);
//epg search //epg search
g_settings.epg_search_history_size = g_settings.epg_search_history.size(); 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) if (g_settings.epg_search_history_size > g_settings.epg_search_history_max)

View File

@@ -143,6 +143,7 @@ typedef enum
LOCALE_ADZAP_MINUTES, LOCALE_ADZAP_MINUTES,
LOCALE_ADZAP_MONITOR, LOCALE_ADZAP_MONITOR,
LOCALE_ADZAP_SWITCHBACK, LOCALE_ADZAP_SWITCHBACK,
LOCALE_ADZAP_WRITEDATA,
LOCALE_APIDSELECTOR_HEAD, LOCALE_APIDSELECTOR_HEAD,
LOCALE_AUDIO_SRS_ALGO, LOCALE_AUDIO_SRS_ALGO,
LOCALE_AUDIO_SRS_ALGO_HEAVY, LOCALE_AUDIO_SRS_ALGO_HEAVY,
@@ -976,6 +977,8 @@ typedef enum
LOCALE_MENU_HINT_A_PIC, LOCALE_MENU_HINT_A_PIC,
LOCALE_MENU_HINT_ADZAP, LOCALE_MENU_HINT_ADZAP,
LOCALE_MENU_HINT_ADZAP_ACTIVE, LOCALE_MENU_HINT_ADZAP_ACTIVE,
LOCALE_MENU_HINT_ADZAP_SETUP,
LOCALE_MENU_HINT_ADZAP_WRITEDATA,
LOCALE_MENU_HINT_APLAY, LOCALE_MENU_HINT_APLAY,
LOCALE_MENU_HINT_APLAY_SETUP, LOCALE_MENU_HINT_APLAY_SETUP,
LOCALE_MENU_HINT_AUDIO, LOCALE_MENU_HINT_AUDIO,

View File

@@ -143,6 +143,7 @@ const char * locale_real_names[] =
"adzap.minutes", "adzap.minutes",
"adzap.monitor", "adzap.monitor",
"adzap.switchback", "adzap.switchback",
"adzap.writedata",
"apidselector.head", "apidselector.head",
"audio.srs_algo", "audio.srs_algo",
"audio.srs_algo_heavy", "audio.srs_algo_heavy",
@@ -976,6 +977,8 @@ const char * locale_real_names[] =
"menu.hint_a_pic", "menu.hint_a_pic",
"menu.hint_adzap", "menu.hint_adzap",
"menu.hint_adzap_active", "menu.hint_adzap_active",
"menu.hint_adzap_setup",
"menu.hint_adzap_writedata",
"menu.hint_aplay", "menu.hint_aplay",
"menu.hint_aplay_setup", "menu.hint_aplay_setup",
"menu.hint_audio", "menu.hint_audio",

View File

@@ -731,6 +731,7 @@ struct SNeutrinoSettings
//adzap //adzap
int adzap_zapBackPeriod; int adzap_zapBackPeriod;
int adzap_writeData;
int power_standby; int power_standby;
int hdd_sleep; int hdd_sleep;
@@ -884,7 +885,6 @@ const int PARENTALLOCK_PROMPT_ONSTART = 1;
const int PARENTALLOCK_PROMPT_CHANGETOLOCKED = 2; const int PARENTALLOCK_PROMPT_CHANGETOLOCKED = 2;
const int PARENTALLOCK_PROMPT_ONSIGNAL = 3; const int PARENTALLOCK_PROMPT_ONSIGNAL = 3;
class CScanSettings class CScanSettings
{ {
public: public: