diff --git a/src/gui/adzap.cpp b/src/gui/adzap.cpp index 3e87a697d..2fde271b1 100644 --- a/src/gui/adzap.cpp +++ b/src/gui/adzap.cpp @@ -79,6 +79,32 @@ static bool sortByDateTime(const CChannelEvent & a, const CChannelEvent & b) return a.startTime < b.startTime; } +void CAdZapMenu::Init() +{ + CChannelList *channelList = CNeutrinoApp::getInstance()->channelList; + channelId = channelList ? channelList->getActiveChannel_ChannelID() : -1; + channelName = channelList->getActiveChannelName(); + CChannelEventList evtlist; + CEitManager::getInstance()->getEventsServiceKey(channelId & 0xFFFFFFFFFFFFULL, evtlist); + monitorLifeTime.tv_sec = 0; + if (!evtlist.empty()) + { + sort(evtlist.begin(), evtlist.end(), sortByDateTime); + CChannelEventList::iterator eli; + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + for (eli = evtlist.begin(); eli != evtlist.end(); ++eli) + { + if ((u_int) eli->startTime + (u_int) eli->duration > (u_int) ts.tv_sec) + { + monitorLifeTime.tv_sec = (uint) eli->startTime + eli->duration; + Update(); + break; + } + } + } +} + void CAdZapMenu::Update() { clock_gettime(CLOCK_REALTIME, &zapBackTime); @@ -164,7 +190,7 @@ void CAdZapMenu::Run() { alerted = false; if (channelList) - channelList->zapTo_ChannelID(channelId); + channelList->zapTo_ChannelID(channelId); armed = false; } } @@ -174,6 +200,8 @@ void CAdZapMenu::Run() int CAdZapMenu::exec(CMenuTarget *parent, const std::string & actionKey) { + Init(); + int res = menu_return::RETURN_EXIT_ALL; if (actionKey == "enable") @@ -223,6 +251,7 @@ int CAdZapMenu::exec(CMenuTarget *parent, const std::string & actionKey) if (parent) parent->hide(); + monitor = false; Settings(); return res; @@ -230,31 +259,7 @@ int CAdZapMenu::exec(CMenuTarget *parent, const std::string & actionKey) void CAdZapMenu::Settings() { - CChannelList *channelList = CNeutrinoApp::getInstance()->channelList; - channelId = channelList ? channelList->getActiveChannel_ChannelID() : -1; - channelName = channelList->getActiveChannelName(); - CChannelEventList evtlist; - CEitManager::getInstance()->getEventsServiceKey(channelId & 0xFFFFFFFFFFFFULL, evtlist); - monitorLifeTime.tv_sec = 0; - bool show_monitor = false; - if (!evtlist.empty()) - { - sort(evtlist.begin(), evtlist.end(), sortByDateTime); - CChannelEventList::iterator eli; - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - for (eli = evtlist.begin(); eli != evtlist.end(); ++eli) - { - if ((u_int) eli->startTime + (u_int) eli->duration > (u_int) ts.tv_sec) - { - monitorLifeTime.tv_sec = (uint) eli->startTime + eli->duration; - show_monitor = true; - Update(); - break; - } - } - } - monitor = false; + bool show_monitor = monitorLifeTime.tv_sec; CMenuWidget *menu = new CMenuWidget(LOCALE_ADZAP, "settings", width); menu->addKey(CRCInput::RC_red, this, "disable"); diff --git a/src/gui/adzap.h b/src/gui/adzap.h index 842769ae8..ccf6ad7a3 100644 --- a/src/gui/adzap.h +++ b/src/gui/adzap.h @@ -47,6 +47,7 @@ class CAdZapMenu: public CMenuTarget t_channel_id channelId; sem_t sem; CAdZapMenu(); + void Init(); void Settings(); void Update(); void Run(void);