diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index eaf0a8bfb..703247ef4 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -73,6 +73,8 @@ #include +#include + extern CBouquetList * bouquetList; /* neutrino.cpp */ extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ extern CPictureViewer * g_PicViewer; @@ -90,6 +92,8 @@ extern bool autoshift; extern CBouquetManager *g_bouquetManager; extern int old_b_id; +extern cVideo * videoDecoder; + CChannelList::CChannelList(const char * const pName, bool phistoryMode, bool _vlist, bool ) { frameBuffer = CFrameBuffer::getInstance(); @@ -460,7 +464,12 @@ void CChannelList::calcSize() const int pic_h = 39; int fw = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getWidth(); width = w_max (((g_settings.channellist_extended)?(frameBuffer->getScreenWidth() / 20 * (fw+6)):(frameBuffer->getScreenWidth() / 20 * (fw+5))), 100); + widthDetails = width; + if (g_settings.channellist_minitv) + widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); height = h_max ((frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20 * 2)); + if (g_settings.channellist_minitv) + height = h_max ((frameBuffer->getScreenHeight() / 20 * 18), 0); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, name.c_str()); @@ -492,8 +501,22 @@ void CChannelList::calcSize() height = theight + footerHeight + listmaxshow * fheight; info_height = 2*fheight + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 10; + if (g_settings.channellist_minitv) + { + width = frameBuffer->getScreenWidth() / 3 * 2; + x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - widthDetails) / 2; + y = frameBuffer->getScreenY(); + pig_width = widthDetails / 3 - 16; + pig_height = pig_width / 16 * 9; + + infozone_width = pig_width - 8; + infozone_height = height - theight - pig_height; + } + else + { x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height+ info_height)) / 2; + } } bool CChannelList::updateSelection(int newpos) @@ -545,6 +568,11 @@ int CChannelList::show() COSDFader fader(g_settings.menu_Content_alpha); fader.StartFadeIn(); + if (g_settings.channellist_minitv) + { + frameBuffer->paintBoxRel(x,y,widthDetails,height + info_height,COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_ALL); + } + paintHead(); paint(); @@ -876,7 +904,12 @@ int CChannelList::show() void CChannelList::hide() { - frameBuffer->paintBackgroundBoxRel(x, y, width, height+ info_height+ 5); + if (g_settings.channellist_minitv) + { + widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); + videoDecoder->Pig(-1, -1, -1, -1); + } + frameBuffer->paintBackgroundBoxRel(x, y, widthDetails, height+ info_height+ 5); clearItem2DetailsLine(); } @@ -1465,7 +1498,7 @@ void CChannelList::paintDetails(int index) p_event = &chanlist[index]->currentEvent; } - frameBuffer->paintBoxRel(x+2, y + height + 2, width-4, info_height - 4, COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE);//round + frameBuffer->paintBoxRel(x+2, y + height + 2, widthDetails-4, info_height - 4, COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE);//round if (!p_event->description.empty()) { char cNoch[50] = {0}; // UTF-8 @@ -1489,7 +1522,7 @@ void CChannelList::paintDetails(int index) std::string text2= p_event->text; int xstart = 10; - if (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1, true) > (width - 30 - seit_len) ) + if (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1, true) > (widthDetails - 30 - seit_len) ) { // zu breit, Umbruch versuchen... int pos; @@ -1497,7 +1530,7 @@ void CChannelList::paintDetails(int index) pos = text1.find_last_of("[ -.]+"); if ( pos!=-1 ) text1 = text1.substr( 0, pos ); - } while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1, true) > (width - 30 - seit_len) ) ); + } while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1, true) > (widthDetails - 30 - seit_len) ) ); std::string text3 = ""; /* not perfect, but better than crashing... */ if (p_event->description.length() > text1.length()) @@ -1507,7 +1540,7 @@ void CChannelList::paintDetails(int index) text3= text3+ " - "; xstart += g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text3, true); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 2* fheight, width - 30- noch_len, text3, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 2* fheight, widthDetails - 30- noch_len, text3, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); } if (!(text2.empty())) { @@ -1516,7 +1549,7 @@ void CChannelList::paintDetails(int index) text2 = text2.substr( 0, text2.find('\n') ); #if 0 //FIXME: to discuss, eat too much cpu time if string long enough int pos = 0; - while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text2, true) > (width - 30 - noch_len) ) ) { + while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text2, true) > (widthDetails - 30 - noch_len) ) ) { pos = text2.find_last_of(" "); if ( pos!=-1 ) { @@ -1524,12 +1557,12 @@ void CChannelList::paintDetails(int index) } } #endif - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ xstart, y+ height+ 5+ 2* fheight, width- xstart- 30- noch_len, text2, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ xstart, y+ height+ 5+ 2* fheight, widthDetails- xstart- 30- noch_len, text2, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); } - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ fheight, width - 30 - seit_len, text1, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ width- 10- seit_len, y+ height+ 5+ fheight, seit_len, cSeit, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ width- 10- noch_len, y+ height+ 5+ 2* fheight, noch_len, cNoch, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ fheight, widthDetails - 30 - seit_len, text1, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ widthDetails- 10- seit_len, y+ height+ 5+ fheight, seit_len, cSeit, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ widthDetails- 10- noch_len, y+ height+ 5+ 2* fheight, noch_len, cNoch, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 } if(g_settings.channellist_foot == 0) { transponder t; @@ -1541,7 +1574,7 @@ void CChannelList::paintDetails(int index) else desc = desc + " (" + CServiceManager::getInstance()->GetSatelliteName(chanlist[index]->getSatellitePosition()) + ")"; - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 3*fheight, width - 30, desc.c_str(), COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 3*fheight, widthDetails - 30, desc.c_str(), COL_MENUCONTENTDARK, 0, true); } else if( !displayNext && g_settings.channellist_foot == 1) { // next Event char buf[128] = {0}; @@ -1554,10 +1587,12 @@ void CChannelList::paintDetails(int index) snprintf(buf, sizeof(buf), "%s", CurrentNext.next_name.c_str()); int from_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(cFrom, true); // UTF-8 - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 3*fheight, width - 30 - from_len, buf, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST :COL_MENUCONTENTDARK, 0, true); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ width- 10- from_len, y+ height+ 5+ 3*fheight, from_len, cFrom, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 3*fheight, widthDetails - 30 - from_len, buf, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST :COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ widthDetails- 10- from_len, y+ height+ 5+ 3*fheight, from_len, cFrom, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 } } + if ((g_settings.channellist_minitv) && (p_event != NULL)) + paint_events(index); } void CChannelList::clearItem2DetailsLine() @@ -1575,7 +1610,6 @@ void CChannelList::paintItem2DetailsLine (int pos, int /*ch_index*/) int ypos1a = ypos1 + (fheight/2)-2; int ypos2a = ypos2 + (info_height/2)-2; fb_pixel_t col1 = COL_MENUCONTENT_PLUS_6; - // Clear frameBuffer->paintBackgroundBoxRel(xpos,y, ConnectLineBox_Width, height+info_height + 1); @@ -1588,13 +1622,15 @@ void CChannelList::paintItem2DetailsLine (int pos, int /*ch_index*/) details_line.paint(); //info box frame - frameBuffer->paintBoxFrame(x, ypos2, width, info_height, 2, col1, RADIUS_LARGE); + frameBuffer->paintBoxFrame(x, ypos2, widthDetails, info_height, 2, col1, RADIUS_LARGE); } } } void CChannelList::showChannelLogo() { + if (g_settings.channellist_minitv) + return; if(g_settings.infobar_show_channellogo){ static int logo_w = 0; static int logo_h = 0; @@ -1921,7 +1957,6 @@ void CChannelList::paintHead() char timestr[10] = {0}; time_t now = time(NULL); struct tm *tm = localtime(&now); - bool gotTime = g_Sectionsd->getIsTimeSet(); if(gotTime) { @@ -1936,7 +1971,7 @@ void CChannelList::paintHead() frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE_ZAP_ACTIVE, &iw3, &ih); // head - frameBuffer->paintBoxRel(x,y, width,theight+0, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);//round + frameBuffer->paintBoxRel(x,y, widthDetails,theight+0, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);//round frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_INFO, x + width - iw1 - 4, y, theight); //y+ 5 ); frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_MENU, x + width - iw1 - iw2 - 8, y, theight);//y + 5); // icon for bouquet list button @@ -1947,6 +1982,10 @@ void CChannelList::paintHead() if (gotTime) { int iw3x = (g_settings.channellist_new_zap_mode) ? iw3 : -4; + if (g_settings.channellist_minitv) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + widthDetails - 16 -timestr_len, + y+theight, timestr_len, timestr, COL_MENUHEAD, 0, true); // UTF-8 + else g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + width - iw1 - iw2 - iw3x - 16 -timestr_len, y+theight, timestr_len, timestr, COL_MENUHEAD, 0, true); // UTF-8 timestr_len += 4; @@ -1956,11 +1995,16 @@ void CChannelList::paintHead() if (g_settings.channellist_new_zap_mode) timestr_len += iw3 + 4; logo_off = timestr_len + 4; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+theight+0, width - timestr_len, name, COL_MENUHEAD, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+theight+0, widthDetails - timestr_len, name, COL_MENUHEAD, 0, true); // UTF-8 } void CChannelList::paint() { + if (g_settings.channellist_minitv) + { + paint_pig(x+width, y+theight+1, pig_width, pig_height); + } + numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(MaxChanNr().c_str()); liststart = (selected/listmaxshow)*listmaxshow; @@ -2044,3 +2088,83 @@ std::string CChannelList::MaxChanNr() ss >> maxchansize; return maxchansize; } + +void CChannelList::paint_pig (int x, int y, int w, int h) +{ + frameBuffer->paintBackgroundBoxRel (x, y, w, h); + printf("CChannelList::paint_pig x %d y %d w %d h %d osd_w %d osd_w %d\n", x, y, w, h, frameBuffer->getScreenWidth(true), frameBuffer->getScreenHeight(true)); + videoDecoder->Pig(x, y, w, h, frameBuffer->getScreenWidth(true), frameBuffer->getScreenHeight(true)); +} + +void CChannelList::paint_events(int index) +{ + readEvents(chanlist[index]->channel_id); + frameBuffer->paintBoxRel(x+ width,y+ theight+pig_height, infozone_width, infozone_height,COL_MENUHEAD_PLUS_0); + char text1[10]; + CChannelEventList::iterator e; + time_t azeit; + time(&azeit); + int ffheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight(); + + if ( evtlist.size() == 0 ) + { + CChannelEvent evt; + + evt.description = g_Locale->getText(LOCALE_EPGLIST_NOEVENTS); + evt.eventID = 0; + evtlist.push_back(evt); + + } + + int i=1; + for (e=evtlist.begin(); e!=evtlist.end(); ++e ) + { + //Remove events in the past + time_t dif = azeit - e->startTime; + if ( (dif > 0) && (!(e->eventID == 0))) + { + do + { + //printf("%d seconds in the past - deleted %s\n", dif, e->description.c_str()); + e = evtlist.erase(e); + dif = azeit - e->startTime; + } + while ( dif > 0 ); + } + //Display the remaining events + struct tm *tmStartZeit = localtime(&e->startTime); + strftime(text1, sizeof(text1), "%H:%M", tmStartZeit ); + //printf("%s %s\n", text1, e->description.c_str()); + int timewidth = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getRenderWidth(text1, true); + if ((y+ theight+ pig_height + i*ffheight) < (y+ height)) + { + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->RenderString(x+ width+5, y+ theight+ pig_height + i*ffheight, timewidth, text1, COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->RenderString(x+ width+5+timewidth+5, y+ theight+ pig_height + i*ffheight, infozone_width - timewidth - 20, e->description, COL_MENUCONTENTDARK, 0, true); + } + else break; + i++; + } + evtlist.clear(); +} + +static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent& b) +{ + return a.startTime < b.startTime; +} + +void CChannelList::readEvents(const t_channel_id channel_id) +{ + CEitManager::getInstance()->getEventsServiceKey(channel_id , evtlist); + + if ( evtlist.empty() ) + { + CChannelEvent evt; + evt.description = g_Locale->getText(LOCALE_EPGLIST_NOEVENTS); + evt.eventID = 0; + evtlist.push_back(evt); + } + else + sort(evtlist.begin(),evtlist.end(),sortByDateTime); + + return; +} diff --git a/src/gui/channellist.cpp.rej b/src/gui/channellist.cpp.rej new file mode 100644 index 000000000..244e147aa --- /dev/null +++ b/src/gui/channellist.cpp.rej @@ -0,0 +1,27 @@ +diff a/src/gui/channellist.cpp b/src/gui/channellist.cpp (rejected hunks) +@@ -553,6 +576,11 @@ int CChannelList::show() + COSDFader fader(g_settings.menu_Content_alpha); + fader.StartFadeIn(); + ++ if (g_settings.channellist_minitv) ++ { ++ frameBuffer->paintBoxRel(x,y,widthDetails,height + info_height,COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_ALL); ++ } ++ + paintHead(); + paint(); + frameBuffer->blit(); +@@ -886,7 +914,12 @@ int CChannelList::show() + + void CChannelList::hide() + { +- frameBuffer->paintBackgroundBoxRel(x, y, width, height+ info_height+ 5); ++ if (g_settings.channellist_minitv) ++ { ++ widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); ++ videoDecoder->Pig(-1, -1, -1, -1); ++ } ++ frameBuffer->paintBackgroundBoxRel(x, y, widthDetails, height+ info_height+ 5); + clearItem2DetailsLine(); + frameBuffer->blit(); + } diff --git a/src/gui/channellist.cpp~ b/src/gui/channellist.cpp~ new file mode 100644 index 000000000..7270ae3d8 --- /dev/null +++ b/src/gui/channellist.cpp~ @@ -0,0 +1,2160 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2001 Steffen Hehn 'McClean' + Homepage: http://dbox.cyberphoria.org/ + + Kommentar: + + Diese GUI wurde von Grund auf neu programmiert und sollte nun vom + Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert + auf der Client-Server Idee, diese GUI ist also von der direkten DBox- + Steuerung getrennt. Diese wird dann von Daemons uebernommen. + + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + +extern CBouquetList * bouquetList; /* neutrino.cpp */ +extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ +extern CPictureViewer * g_PicViewer; +extern CBouquetList * TVbouquetList; +extern CBouquetList * TVsatList; +extern CBouquetList * TVfavList; +extern CBouquetList * TVallList; +extern CBouquetList * RADIObouquetList; +extern CBouquetList * RADIOsatList; +extern CBouquetList * RADIOfavList; +extern CBouquetList * RADIOallList; + +extern bool autoshift; + +extern CBouquetManager *g_bouquetManager; +extern int old_b_id; + +extern cVideo * videoDecoder; + +CChannelList::CChannelList(const char * const pName, bool phistoryMode, bool _vlist, bool ) +{ + frameBuffer = CFrameBuffer::getInstance(); + name = pName; + selected = 0; + selected_in_new_mode = 0; + liststart = 0; + tuned = 0xfffffff; + zapProtection = NULL; + this->historyMode = phistoryMode; + vlist = _vlist; + selected_chid = 0; + this->new_mode_active = false; + footerHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+6; //initial height value for buttonbar +//printf("************ NEW LIST %s : %x\n", name.c_str(), (int) this);fflush(stdout); +} + +CChannelList::~CChannelList() +{ +//printf("************ DELETE LIST %s : %x\n", name.c_str(), this);fflush(stdout); + chanlist.clear(); +} + +void CChannelList::ClearList(void) +{ +//printf("************ CLEAR LIST %s : %x\n", name.c_str(), this);fflush(stdout); + chanlist.clear(); + chanlist.resize(1); +} + +void CChannelList::setSize(int newsize) +{ + //chanlist.reserve(newsize); + chanlist.resize(newsize); +} + +void CChannelList::SetChannelList(ZapitChannelList* channels) +{ + chanlist = *channels; +} + +void CChannelList::addChannel(CZapitChannel* channel, int num) +{ +//printf("************ %s : addChannel: %s %x\n", name.c_str(), channel->getName().c_str(), channel);fflush(stdout); + if(num) + channel->number = num; + chanlist.push_back(channel); +} + +void CChannelList::putChannel(CZapitChannel* channel) +{ + int num = channel->number - 1; + if(num < 0) { + printf("%s error inserting at %d\n", __FUNCTION__, num); + return; + } + if(num >= (int) chanlist.size()) { + chanlist.resize((unsigned) num + 1); + } + chanlist[num] = channel; +//printf("************ %s : me %x putChannel: %d: %s %x -> %x [0] %x\n", name.c_str(), this, num, channel->getName().c_str(), channel, chanlist[num], chanlist[0]);fflush(stdout); +} + +/* uodate the events for the visible channel list entries + from = start entry, to = end entry. If both = zero, update all */ +void CChannelList::updateEvents(unsigned int from, unsigned int to) +{ + CChannelEventList events; + + if (to == 0 || to > chanlist.size()) + to = chanlist.size(); + + size_t chanlist_size = to - from; + if (chanlist_size <= 0) // WTF??? + return; + + if (displayNext) { + time_t atime = time(NULL); + unsigned int count; + for (count = from; count < to; count++) { + events.clear(); + CEitManager::getInstance()->getEventsServiceKey(chanlist[count]->channel_id, events); + chanlist[count]->nextEvent.startTime = (long)0x7fffffff; + for ( CChannelEventList::iterator e= events.begin(); e != events.end(); ++e ) { + if ((long)e->startTime > atime && + (e->startTime < (long)chanlist[count]->nextEvent.startTime)) + { + chanlist[count]->nextEvent = *e; + break; + } + } + } + } else { + t_channel_id *p_requested_channels; + p_requested_channels = new t_channel_id[chanlist_size]; + if (! p_requested_channels) { + fprintf(stderr,"%s:%d allocation failed!\n", __FUNCTION__, __LINE__); + return; + } + for (uint32_t count = 0; count < chanlist_size; count++) + p_requested_channels[count] = chanlist[count + from]->channel_id; + + CChannelEventList levents; + CEitManager::getInstance()->getChannelEvents(levents, p_requested_channels, chanlist_size); + for (uint32_t count=0; count < chanlist_size; count++) { + chanlist[count]->currentEvent = CChannelEvent(); + for (CChannelEventList::iterator e = levents.begin(); e != levents.end(); ++e) { + if ((chanlist[count + from]->channel_id&0xFFFFFFFFFFFFULL) == e->get_channel_id()) { + chanlist[count + from]->currentEvent = *e; + break; + } + } + } + delete[] p_requested_channels; + } + events.clear(); +} + +void CChannelList::SortAlpha(void) +{ + sort(chanlist.begin(), chanlist.end(), CmpChannelByChName()); +} + +void CChannelList::SortSat(void) +{ + sort(chanlist.begin(), chanlist.end(), CmpChannelBySat()); +} + +void CChannelList::SortTP(void) +{ + sort(chanlist.begin(), chanlist.end(), CmpChannelByFreq()); +} + +void CChannelList::SortChNumber(void) +{ + sort(chanlist.begin(), chanlist.end(), CmpChannelByChNum()); +} + +CZapitChannel* CChannelList::getChannel(int number) +{ + for (uint32_t i=0; i< chanlist.size(); i++) { + if (chanlist[i]->number == number) + return chanlist[i]; + } + return(NULL); +} + +CZapitChannel* CChannelList::getChannel(t_channel_id channel_id) +{ + for (uint32_t i=0; i< chanlist.size(); i++) { + if (chanlist[i]->channel_id == channel_id) + return chanlist[i]; + } + return(NULL); +} + +int CChannelList::getKey(int id) +{ + return chanlist[id]->number; +} + +static const std::string empty_string; + +const std::string CChannelList::getActiveChannelName(void) const +{ + if (selected < chanlist.size()) + return chanlist[selected]->getName(); + else + return empty_string; +} + +t_satellite_position CChannelList::getActiveSatellitePosition(void) const +{ + if (selected < chanlist.size()) + return chanlist[selected]->getSatellitePosition(); + else + return 0; +} + +t_channel_id CChannelList::getActiveChannel_ChannelID(void) const +{ + if (selected < chanlist.size()) { +//printf("CChannelList::getActiveChannel_ChannelID me %x selected = %d %llx\n", (int) this, selected, chanlist[selected]->channel_id); + return chanlist[selected]->channel_id; + } else + return 0; +} + +int CChannelList::getActiveChannelNumber(void) const +{ + //return (selected + 1); + if (selected < chanlist.size()) + return chanlist[selected]->number; + return 0; +} + +CZapitChannel * CChannelList::getActiveChannel(void) const +{ + static CZapitChannel channel("Channel not found", 0, 0, 0, 0); + if (selected < chanlist.size()) + return chanlist[selected]; + return &channel; +} + +int CChannelList::doChannelMenu(void) +{ + int i = 0; + int select = -1; + static int old_selected = 0; + char cnt[5]; + bool enabled = true; + + if(g_settings.minimode) + return 0; + + if(vlist) + { + enabled = false; + if(old_selected < 2)//FIXME take care if some items added before 0, 1 + old_selected = 2; + } + + CMenuWidget* menu = new CMenuWidget(LOCALE_CHANNELLIST_EDIT, NEUTRINO_ICON_SETTINGS); + menu->enableFade(false); + menu->enableSaveScreen(true); + CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); + + snprintf(cnt, sizeof(cnt), "%d", i); + menu->addItem(new CMenuForwarder(LOCALE_BOUQUETEDITOR_DELETE, enabled, NULL, selector, cnt, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED), old_selected == i++); + snprintf(cnt, sizeof(cnt), "%d", i); + menu->addItem(new CMenuForwarder(LOCALE_BOUQUETEDITOR_MOVE, enabled, NULL, selector, cnt, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN), old_selected == i++); + snprintf(cnt, sizeof(cnt), "%d", i); + menu->addItem(new CMenuForwarder(LOCALE_EXTRA_ADD_TO_BOUQUET, true, NULL, selector, cnt, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW), old_selected == i++); + snprintf(cnt, sizeof(cnt), "%d", i); + menu->addItem(new CMenuForwarder(LOCALE_FAVORITES_MENUEADD, true, NULL, selector, cnt, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE), old_selected == i++); + snprintf(cnt, sizeof(cnt), "%d", i); + bool reset_enabled = chanlist[selected]->flags & CZapitChannel::NEW; + menu->addItem(new CMenuForwarder(LOCALE_CHANNELLIST_RESET_FLAGS, reset_enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(0)), old_selected == i++); + snprintf(cnt, sizeof(cnt), "%d", i); + menu->addItem(new CMenuForwarder(LOCALE_MAINMENU_SETTINGS, true, NULL, selector, cnt, CRCInput::convertDigitToKey(0)), old_selected == i++); + menu->exec(NULL, ""); + delete menu; + delete selector; + + if(select >= 0) { + signed int bouquet_id = 0, old_bouquet_id = 0, new_bouquet_id = 0; + old_selected = select; + t_channel_id channel_id = chanlist[selected]->channel_id; + switch(select) { + case 0: { + hide(); + int result = ShowMsgUTF ( LOCALE_BOUQUETEDITOR_DELETE, g_Locale->getText(LOCALE_BOUQUETEDITOR_DELETE_QUESTION), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); + + if(result == CMessageBox::mbrYes) { + bouquet_id = bouquetList->getActiveBouquetNumber(); + /* FIXME if bouquet name not unique, this is bad, + * existsBouquet can find wrong bouquet */ + if(!strcmp(bouquetList->Bouquets[bouquet_id]->channelList->getName(), g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME))) + bouquet_id = g_bouquetManager->existsUBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); + else + bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[bouquet_id]->channelList->getName()); + + if (bouquet_id == -1) + return 0; + if(g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) { + g_bouquetManager->Bouquets[bouquet_id]->removeService(channel_id); + return 1; + } + } + break; + } + case 1: // move + old_bouquet_id = bouquetList->getActiveBouquetNumber(); + old_bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[old_bouquet_id]->channelList->getName()); + do { + new_bouquet_id = bouquetList->exec(false); + } while(new_bouquet_id == -3); + + hide(); + if(new_bouquet_id < 0) + return 0; + new_bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[new_bouquet_id]->channelList->getName()); + if ((new_bouquet_id == -1) || (new_bouquet_id == old_bouquet_id)) + return 0; + + if(!g_bouquetManager->existsChannelInBouquet(new_bouquet_id, channel_id)) { + CZapit::getInstance()->addChannelToBouquet(new_bouquet_id, channel_id); + } + if(g_bouquetManager->existsChannelInBouquet(old_bouquet_id, channel_id)) { + g_bouquetManager->Bouquets[old_bouquet_id]->removeService(channel_id); + } + return 1; + + break; + case 2: // add to + do { + bouquet_id = bouquetList->exec(false); + } while(bouquet_id == -3); + hide(); + if(bouquet_id < 0) + return 0; + + if(!strcmp(bouquetList->Bouquets[bouquet_id]->channelList->getName(), g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME))) + bouquet_id = g_bouquetManager->existsUBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); + else + bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[bouquet_id]->channelList->getName()); + + if (bouquet_id == -1) + return 0; + if(!g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) { + CZapit::getInstance()->addChannelToBouquet(bouquet_id, channel_id); + return 1; + } + break; + case 3: // add to my favorites + bouquet_id = g_bouquetManager->existsUBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); + if(bouquet_id == -1) { + g_bouquetManager->addBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); + bouquet_id = g_bouquetManager->existsUBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); + } + if(!g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) { + CZapit::getInstance()->addChannelToBouquet(bouquet_id, channel_id); + return 1; + } + + break; + case 4: // reset new + chanlist[selected]->flags &= ~CZapitChannel::NEW; + CServiceManager::getInstance()->SetServicesChanged(true); + /* if make_new_list == ON, signal to re-init services */ + if(g_settings.make_new_list) + return 1; + break; + case 5: // settings + { + COsdSetup osd_setup; + osd_setup.showContextChanlistMenu(); + //FIXME check font/options changed ? + hide(); + calcSize(); + } + break; + default: + break; + } + } + return 0; +} + +int CChannelList::exec() +{ + displayNext = 0; // always start with current events + int nNewChannel = show(); + if ( nNewChannel > -1 && nNewChannel < (int) chanlist.size()) { + if(this->historyMode && chanlist[nNewChannel]) { + int new_mode = CNeutrinoApp::getInstance()->channelList->getLastChannels().get_mode(chanlist[nNewChannel]->channel_id); + if(new_mode >= 0) + CNeutrinoApp::getInstance()->SetChannelMode(new_mode); + } + CNeutrinoApp::getInstance()->channelList->zapToChannel(chanlist[nNewChannel]); + } + + return nNewChannel; +} + +void CChannelList::calcSize() +{ + const int pic_h = 39; + int fw = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getWidth(); + width = w_max (((g_settings.channellist_extended)?(frameBuffer->getScreenWidth() / 20 * (fw+6)):(frameBuffer->getScreenWidth() / 20 * (fw+5))), 100); + widthDetails = width; + if (g_settings.channellist_minitv) + widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); + height = h_max ((frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20 * 2)); + if (g_settings.channellist_minitv) + height = h_max ((frameBuffer->getScreenHeight() / 20 * 18), 0); + + CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, name.c_str()); + + /* assuming all color icons must have same size */ + int icol_w, icol_h; + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icol_w, &icol_h); + + theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + + theight = std::max(theight, pic_h); + + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_HELP, &icol_w, &icol_h); + theight = std::max(theight, icol_h); + + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MENU, &icol_w, &icol_h); + theight = std::max(theight, icol_h); + + if(g_settings.channellist_new_zap_mode) + { + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE_ZAP_ACTIVE, &icol_w, &icol_h); + theight = std::max(theight, icol_h); + } + + fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); + if (fheight == 0) + fheight = 1; /* avoid crash on invalid font */ + + listmaxshow = (height - theight - footerHeight -0)/fheight; + height = theight + footerHeight + listmaxshow * fheight; + info_height = 2*fheight + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 10; + + if (g_settings.channellist_minitv) + { + width = frameBuffer->getScreenWidth() / 3 * 2; + x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - widthDetails) / 2; + y = frameBuffer->getScreenY(); + pig_width = widthDetails / 3 - 16; + pig_height = pig_width / 16 * 9; + + infozone_width = pig_width - 8; + infozone_height = height - theight - pig_height; + } + else + { + x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; + y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height+ info_height)) / 2; + } +} + +bool CChannelList::updateSelection(int newpos) +{ + bool actzap = false; + if((int) selected != newpos) { + int prev_selected = selected; + unsigned int oldliststart = liststart; + + selected = newpos; + liststart = (selected/listmaxshow)*listmaxshow; + if (oldliststart != liststart) + paint(); + else { + paintItem(prev_selected - liststart); + paintItem(selected - liststart); + showChannelLogo(); + } + + if(this->new_mode_active && SameTP()) { + actzap = true; + zapTo(selected); + } + } + return actzap; +} + +#define CHANNEL_SMSKEY_TIMEOUT 800 +/* return: >= 0 to zap, -1 on cancel, -3 on list mode change, -4 list edited, -2 zap but no restore old list/chan ?? */ +int CChannelList::show() +{ + /* temporary debugging stuff */ + struct timeval t1, t2; + gettimeofday(&t1, NULL); + + neutrino_msg_t msg; + neutrino_msg_data_t data; + bool actzap = 0; + int res = -1; + if (chanlist.empty()) { + return res; + } + + this->new_mode_active = 0; + + calcSize(); + displayNext = false; + + COSDFader fader(g_settings.menu_Content_alpha); + fader.StartFadeIn(); + + paintHead(); + paint(); + + gettimeofday(&t2, NULL); + fprintf(stderr, "CChannelList::show(): %llu ms to paint channellist\n", + ((t2.tv_sec * 1000000ULL + t2.tv_usec) - (t1.tv_sec * 1000000ULL + t1.tv_usec)) / 1000ULL); + + int oldselected = selected; + int zapOnExit = false; + bool bShowBouquetList = false; + + uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); + + bool loop=true; + while (loop) { + g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true); + if ( msg <= CRCInput::RC_MaxRC ) + timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); + + if((msg == NeutrinoMessages::EVT_TIMER) && (data == fader.GetTimer())) { + if(fader.Fade()) { + loop = false; + } + } + else if ( ( msg == CRCInput::RC_timeout ) || ( msg == (neutrino_msg_t)g_settings.key_channelList_cancel) ) { + res = -1; + if(!actzap) { + selected = oldselected; + } + else { + res = -4; + selected = selected_in_new_mode; + } + if(fader.StartFadeOut()) { + timeoutEnd = CRCInput::calcTimeoutEnd( 1 ); + msg = 0; + } else + loop=false; + } + else if( msg == CRCInput::RC_record) { //start direct recording from channellist +#if 0 + if(!CRecordManager::getInstance()->RecordingStatus(chanlist[selected]->channel_id)) + { + printf("[neutrino channellist] start direct recording...\n"); + hide(); + if (CRecordManager::getInstance()->Record(chanlist[selected]->channel_id)) + { + if(SameTP()) + { + zapOnExit = true; + loop=false; + } + else + DisplayInfoMessage(g_Locale->getText(LOCALE_CHANNELLIST_RECORDING_NOT_POSSIBLE)); // UTF-8 + } + + } +#endif + if(SameTP()) { + printf("[neutrino channellist] start direct recording...\n"); + hide(); + if (!CRecordManager::getInstance()->Record(chanlist[selected]->channel_id)) { + paintHead(); + paint(); + } else + loop=false; + + } + } + else if( msg == CRCInput::RC_stop ) { //stopp recording + if(CRecordManager::getInstance()->RecordingStatus(chanlist[selected]->channel_id)) + { + if (CRecordManager::getInstance()->AskToStop(chanlist[selected]->channel_id)) + { + CRecordManager::getInstance()->Stop(chanlist[selected]->channel_id); + paint(); + } + } + } + else if ((msg == CRCInput::RC_red) || (msg == CRCInput::RC_epg)) { + hide(); + + /* RETURN_EXIT_ALL on FAV/SAT buttons or messages_return::cancel_all from CNeutrinoApp::getInstance()->handleMsg() */ + if ( g_EventList->exec(chanlist[selected]->channel_id, chanlist[selected]->getName()) == menu_return::RETURN_EXIT_ALL) { + res = -2; + loop = false; + } else { + paintHead(); + paint(); + timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); + } + } + else if (msg == CRCInput::RC_yellow) { + bShowBouquetList = true; + loop=false; + } + else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) { + g_RCInput->postMsg (msg, 0); + loop = false; + res = -1; + } + else if ( msg == CRCInput::RC_setup) { + old_b_id = bouquetList->getActiveBouquetNumber(); + fader.Stop(); + CNeutrinoApp::getInstance()->g_channel_list_changed = doChannelMenu(); + if(CNeutrinoApp::getInstance()->g_channel_list_changed) { + res = -4; + loop = false; + } else { + old_b_id = -1; + paintHead(); + paint(); + } + timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); + } + else if (msg == (neutrino_msg_t) g_settings.key_list_start) { + actzap = updateSelection(0); + } + else if (msg == (neutrino_msg_t) g_settings.key_list_end) { + actzap = updateSelection(chanlist.size()-1); + } + else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_channelList_pageup) + { + int step = ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1; // browse or step 1 + int new_selected = selected - step; + if (new_selected < 0) { + if (selected != 0 && step != 1) + new_selected = 0; + else + new_selected = chanlist.size() - 1; + } + actzap = updateSelection(new_selected); + } + else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown) + { + int step = ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1; // browse or step 1 + int new_selected = selected + step; + if (new_selected >= (int) chanlist.size()) { + if ((chanlist.size() - listmaxshow -1 < selected) && (selected != (chanlist.size() - 1)) && (step != 1)) + new_selected = chanlist.size() - 1; + else if (((chanlist.size() / listmaxshow) + 1) * listmaxshow == chanlist.size() + listmaxshow) // last page has full entries + new_selected = 0; + else + new_selected = ((step == (int) listmaxshow) && (new_selected < (int) (((chanlist.size() / listmaxshow)+1) * listmaxshow))) ? (chanlist.size() - 1) : 0; + } + actzap = updateSelection(new_selected); + } + else if (msg == (neutrino_msg_t)g_settings.key_bouquet_up) { + if (!bouquetList->Bouquets.empty()) { + bool found = true; + uint32_t nNext = (bouquetList->getActiveBouquetNumber()+1) % bouquetList->Bouquets.size(); + if(bouquetList->Bouquets[nNext]->channelList->isEmpty() ) { + found = false; + nNext = nNext < bouquetList->Bouquets.size()-1 ? nNext+1 : 0; + for(uint32_t i = nNext; i < bouquetList->Bouquets.size(); i++) { + if( !bouquetList->Bouquets[i]->channelList->isEmpty() ) { + found = true; + nNext = i; + break; + } + } + } + if(found) { + bouquetList->activateBouquet(nNext, false); + res = bouquetList->showChannelList(); + loop = false; + } + } + } + else if (msg == (neutrino_msg_t)g_settings.key_bouquet_down) { + if (!bouquetList->Bouquets.empty()) { + bool found = true; + int nNext = (bouquetList->getActiveBouquetNumber()+bouquetList->Bouquets.size()-1) % bouquetList->Bouquets.size(); + if(bouquetList->Bouquets[nNext]->channelList->isEmpty() ) { + found = false; + nNext = nNext > 0 ? nNext-1 : bouquetList->Bouquets.size()-1; + for(int i = nNext; i > 0; i--) { + if(!bouquetList->Bouquets[i]->channelList->isEmpty()) { + found = true; + nNext = i; + break; + } + } + } + if(found) { + bouquetList->activateBouquet(nNext, false); + res = bouquetList->showChannelList(); + loop = false; + } + } + } + else if ( msg == CRCInput::RC_ok ) { + if(SameTP()) { + zapOnExit = true; + loop=false; + } + } + else if (( msg == CRCInput::RC_spkr ) && g_settings.channellist_new_zap_mode ) { + if(CNeutrinoApp::getInstance()->getMode() != NeutrinoMessages::mode_ts) { + this->new_mode_active = (this->new_mode_active ? 0 : 1); + paintHead(); + showChannelLogo(); + } + } + else if (CRCInput::isNumeric(msg) && (this->historyMode || g_settings.sms_channel)) { + if (this->historyMode) { //numeric zap + selected = CRCInput::getNumericValue(msg); + zapOnExit = true; + loop = false; + } + else if(g_settings.sms_channel) { + unsigned char smsKey = 0; + SMSKeyInput smsInput; + smsInput.setTimeout(CHANNEL_SMSKEY_TIMEOUT); + + do { + smsKey = smsInput.handleMsg(msg); + //printf("SMS new key: %c\n", smsKey); + g_RCInput->getMsg_ms(&msg, &data, CHANNEL_SMSKEY_TIMEOUT-100); + } while ((msg >= CRCInput::RC_1) && (msg <= CRCInput::RC_9)); + + if (msg == CRCInput::RC_timeout || msg == CRCInput::RC_nokey) { + uint32_t i; + for(i = selected+1; i < chanlist.size(); i++) { + char firstCharOfTitle = chanlist[i]->getName().c_str()[0]; + if(tolower(firstCharOfTitle) == smsKey) { + //printf("SMS chan found was= %d selected= %d i= %d %s\n", was_sms, selected, i, chanlist[i]->channel->getName().c_str()); + break; + } + } + if(i >= chanlist.size()) { + for(i = 0; i < chanlist.size(); i++) { + char firstCharOfTitle = chanlist[i]->getName().c_str()[0]; + if(tolower(firstCharOfTitle) == smsKey) { + //printf("SMS chan found was= %d selected= %d i= %d %s\n", was_sms, selected, i, chanlist[i]->channel->getName().c_str()); + break; + } + } + } + if(i < chanlist.size()) { + int prevselected=selected; + selected=i; + + paintItem(prevselected - liststart); + unsigned int oldliststart = liststart; + liststart = (selected/listmaxshow)*listmaxshow; + if(oldliststart!=liststart) { + paint(); + } else { + paintItem(selected - liststart); + showChannelLogo(); + } + } + smsInput.resetOldKey(); + } + } + } + else if(CRCInput::isNumeric(msg)) { + //pushback key if... + selected = oldselected; + g_RCInput->postMsg( msg, data ); + loop=false; + } + else if ( msg == CRCInput::RC_blue ) + { + displayNext = !displayNext; + paintHead(); // update button bar + paint(); + } + else if ( msg == CRCInput::RC_green ) + { + int mode = CNeutrinoApp::getInstance()->GetChannelMode(); + if(mode != LIST_MODE_FAV) { + g_settings.channellist_sort_mode++; + if(g_settings.channellist_sort_mode > SORT_MAX-1) + g_settings.channellist_sort_mode = SORT_ALPHA; + CNeutrinoApp::getInstance()->SetChannelMode(mode); + paintHead(); // update button bar + paint(); + } + } + + else if ((msg == CRCInput::RC_info) || (msg == CRCInput::RC_help)) { + hide(); + CChannelEvent *p_event=NULL; + if (displayNext) + { + p_event = &(chanlist[selected]->nextEvent); + } + + if(p_event && p_event->eventID) + { + g_EpgData->show(chanlist[selected]->channel_id,p_event->eventID,&(p_event->startTime)); + } + else + { + g_EpgData->show(chanlist[selected]->channel_id); + } + paintHead(); + paint(); + } else { + if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { + loop = false; + res = - 2; + } + } + } + hide(); + + fader.Stop(); + + if (bShowBouquetList) { + res = bouquetList->exec(true); + printf("CChannelList:: bouquetList->exec res %d\n", res); + } + this->new_mode_active = 0; + + if(NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode()) + return -1; + + if(zapOnExit) { + res = selected; + //selected_chid = chanlist[selected]->channel_id; + } + + printf("CChannelList::show *********** res %d\n", res); + return(res); +} + +void CChannelList::hide() +{ + frameBuffer->paintBackgroundBoxRel(x, y, width, height+ info_height+ 5); + clearItem2DetailsLine(); +} + +bool CChannelList::showInfo(int number, int epgpos) +{ + CZapitChannel* channel = getChannel(number); + if(channel == NULL) + return false; + + g_InfoViewer->showTitle(channel, true, epgpos); // UTF-8 + return true; +} + +int CChannelList::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) +{ + bool startvideo = true; + + if (msg != NeutrinoMessages::EVT_PROGRAMLOCKSTATUS) // right now the only message handled here. + return messages_return::unhandled; + + //printf("===> program-lock-status: %d zp: %d\n", data, zapProtection != NULL); + + if (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_NEVER) + goto out; + + // 0x100 als FSK-Status zeigt an, dass (noch) kein EPG zu einem Kanal der NICHT angezeigt + // werden sollte (vorgesperrt) da ist + // oder das bouquet des Kanals ist vorgesperrt + + if (zapProtection != NULL) { + zapProtection->fsk = data; + startvideo = false; + goto out; + } + + // require password if either + // CHANGETOLOCK mode and channel/bouquet is pre locked (0x100) + // ONSIGNAL mode and fsk(data) is beyond configured value + // if program has already been unlocked, dont require pin + if (data < (neutrino_msg_data_t)g_settings.parentallock_lockage) + goto out; + + /* already unlocked */ + if (chanlist[selected]->last_unlocked_EPGid == g_RemoteControl->current_EPGid && g_RemoteControl->current_EPGid != 0) + goto out; + + /* PARENTALLOCK_PROMPT_CHANGETOLOCKED: only pre-locked channels, don't care for fsk sent in SI */ + if (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED && data < 0x100) + goto out; + + /* if a pre-locked channel is inside the zap time, open it. Hardcoded to one hour for now. */ + if (data >= 0x100 && chanlist[selected]->last_unlocked_time + 3600 > time_monotonic()) + goto out; + + /* OK, let's ask for a PIN */ + g_RemoteControl->stopvideo(); + //printf("stopped video\n"); + zapProtection = new CZapProtection(g_settings.parentallock_pincode, data); + + if (zapProtection->check()) + { + // remember it for the next time + /* data < 0x100: lock age -> remember EPG ID */ + if (data < 0x100) + chanlist[selected]->last_unlocked_EPGid = g_RemoteControl->current_EPGid; + else + { + /* data >= 0x100: pre locked bouquet -> remember unlock time */ + chanlist[selected]->last_unlocked_time = time_monotonic(); + int bnum = bouquetList->getActiveBouquetNumber(); + if (bnum >= 0) + { + /* unlock the whole bouquet */ + int i; + for (i = 0; i < bouquetList->Bouquets[bnum]->channelList->getSize(); i++) + bouquetList->Bouquets[bnum]->channelList->getChannelFromIndex(i)->last_unlocked_time = chanlist[selected]->last_unlocked_time; + } + } + } + else + { + /* last_unlocked_time == 0 is the magic to tell zapTo() to not record the time. + Without that, zapping to a locked channel twice would open it without the PIN */ + chanlist[selected]->last_unlocked_time = 0; + startvideo = false; + } + delete zapProtection; + zapProtection = NULL; + +out: + if (startvideo) + g_RemoteControl->startvideo(); + + return messages_return::handled; +} + +/* bToo default to true */ +/* TODO make this member of CNeutrinoApp, because this only called from "whole" list ? */ +bool CChannelList::adjustToChannelID(const t_channel_id channel_id, bool bToo) +{ + unsigned int i; + + selected_chid = channel_id; + printf("CChannelList::adjustToChannelID me %p [%s] list size %d channel_id %llx\n", this, getName(), chanlist.size(), channel_id); + fflush(stdout); + for (i = 0; i < chanlist.size(); i++) { + if(chanlist[i] == NULL) { + printf("CChannelList::adjustToChannelID REPORT BUG !! ******************************** %d is NULL !!\n", i); + continue; + } + if (chanlist[i]->channel_id == channel_id) { + selected = i; + tuned = i; + + lastChList.store (selected, channel_id, false); + + if (bToo) { + int old_mode = CNeutrinoApp::getInstance()->GetChannelMode(); + int new_mode = old_mode; + bool has_channel; + if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_tv) { + has_channel = TVfavList->adjustToChannelID(channel_id); + if(!has_channel && old_mode == LIST_MODE_FAV) + new_mode = LIST_MODE_PROV; + has_channel = TVbouquetList->adjustToChannelID(channel_id); + if(!has_channel && old_mode == LIST_MODE_PROV) { + new_mode = LIST_MODE_SAT; + } + has_channel = TVsatList->adjustToChannelID(channel_id); + if(!has_channel && old_mode == LIST_MODE_SAT) + new_mode = LIST_MODE_ALL; + has_channel = TVallList->adjustToChannelID(channel_id); + } + else if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_radio) { + has_channel = RADIOfavList->adjustToChannelID(channel_id); + if(!has_channel && old_mode == LIST_MODE_FAV) + new_mode = LIST_MODE_PROV; + has_channel = RADIObouquetList->adjustToChannelID(channel_id); + if(!has_channel && old_mode == LIST_MODE_PROV) + new_mode = LIST_MODE_SAT; + has_channel = RADIOsatList->adjustToChannelID(channel_id); + if(!has_channel && old_mode == LIST_MODE_SAT) + new_mode = LIST_MODE_ALL; + has_channel = RADIOallList->adjustToChannelID(channel_id); + } + if(old_mode != new_mode) + CNeutrinoApp::getInstance()->SetChannelMode(new_mode); + } +//printf("CChannelList::adjustToChannelID me %x to %llx bToo %s OK: %d\n", (int) this, channel_id, bToo ? "yes" : "no", i);fflush(stdout); + return true; + } + } +//printf("CChannelList::adjustToChannelID me %x to %llx bToo %s FAILED\n", (int) this, channel_id, bToo ? "yes" : "no");fflush(stdout); + + return false; +} + +#if 0 +int CChannelList::hasChannel(int nChannelNr) +{ + for (uint32_t i=0; ichannel_id == channel_id) + return i; + } + return -1; +} + +// for adjusting bouquet's channel list after numzap or quickzap +void CChannelList::setSelected( int nChannelNr) +{ +//printf("CChannelList::setSelected me %s %d -> %s\n", name.c_str(), nChannelNr, (nChannelNr < chanlist.size() && chanlist[nChannelNr] != NULL) ? chanlist[nChannelNr]->getName().c_str() : "********* NONE *********"); + //FIXME real difference between tuned and selected ?! + selected_chid = 0; + tuned = nChannelNr; + if (nChannelNr < (int) chanlist.size()) { + selected = nChannelNr; + selected_chid = chanlist[tuned]->getChannelID(); + } +} + +// -- Zap to channel with channel_id +bool CChannelList::zapTo_ChannelID(const t_channel_id channel_id) +{ + printf("**************************** CChannelList::zapTo_ChannelID %llx\n", channel_id); + for (unsigned int i = 0; i < chanlist.size(); i++) { + if (chanlist[i]->channel_id == channel_id) { + zapTo(i); + return true; + } + } + return false; +} + +bool CChannelList::showEmptyError() +{ + if (chanlist.empty()) { + DisplayErrorMessage(g_Locale->getText(LOCALE_CHANNELLIST_NONEFOUND)); // UTF-8 + return true; + } + return false; +} + +/* forceStoreToLastChannels defaults to false */ +/* TODO make this private to call only from "current" list, where selected/pos not means channel number */ +void CChannelList::zapTo(int pos, bool /* forceStoreToLastChannels */) +{ + if(showEmptyError()) + return; + + if ( (pos >= (signed int) chanlist.size()) || (pos < 0) ) { + pos = 0; + } + CZapitChannel* chan = chanlist[pos]; + + zapToChannel(chan); + tuned = pos; + if(this->new_mode_active) + selected_in_new_mode = pos; + else + selected = pos; +} + +/* to replace zapTo_ChannelID and zapTo from "whole" list ? */ +void CChannelList::zapToChannel(CZapitChannel *channel) +{ + if(showEmptyError()) + return; + + if(channel == NULL) + return; + + /* we record when we switched away from a channel, so that the parental-PIN code can + check for timeout. last_unlocked_time == 0 means: the PIN was not entered + "tuned" is the *old* channel, before zap */ + if (tuned < chanlist.size() && chanlist[tuned]->last_unlocked_time != 0) + chanlist[tuned]->last_unlocked_time = time_monotonic(); + + printf("**************************** CChannelList::zapToChannel me %p %s tuned %d new %s -> %llx\n", this, name.c_str(), tuned, channel->getName().c_str(), channel->channel_id); + if(tuned < chanlist.size()) + selected_chid = chanlist[tuned]->getChannelID(); + + if(selected_chid != channel->getChannelID()) { + if ((g_settings.radiotext_enable) && ((CNeutrinoApp::getInstance()->getMode()) == NeutrinoMessages::mode_radio) && (g_Radiotext)) + { + // stop radiotext PES decoding before zapping + g_Radiotext->radiotext_stop(); + } + + selected_chid = channel->getChannelID(); + g_RemoteControl->zapTo_ChannelID(channel->getChannelID(), channel->getName(), !channel->bAlwaysLocked); + CNeutrinoApp::getInstance()->channelList->adjustToChannelID(channel->getChannelID()); + } + if(!this->new_mode_active) { + /* remove recordModeActive from infobar */ + if(g_settings.auto_timeshift && !CNeutrinoApp::getInstance()->recordingstatus) { + g_InfoViewer->handleMsg(NeutrinoMessages::EVT_RECORDMODE, 0); + } + g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 ); + CNeutrinoApp::getInstance()->channelList->getLastChannels().set_mode(channel->channel_id); + } +} + +/* Called only from "all" channel list */ +int CChannelList::numericZap(int key) +{ + neutrino_msg_t msg; + neutrino_msg_data_t data; + + int res = -1; + + if(showEmptyError()) + return res; + + // -- quickzap "0" to last seen channel... + if (key == g_settings.key_lastchannel) { + t_channel_id channel_id = lastChList.getlast(1); + if(channel_id && SameTP(channel_id)) { + lastChList.clear_storedelay(); // ignore store delay + int new_mode = lastChList.get_mode(channel_id); + if(new_mode >= 0) + CNeutrinoApp::getInstance()->SetChannelMode(new_mode); + zapTo_ChannelID(channel_id); + res = 0; + } + return res; + } + if ((key == g_settings.key_zaphistory) || (key == CRCInput::RC_games)) { + if((!autoshift && CNeutrinoApp::getInstance()->recordingstatus) || (key == CRCInput::RC_games)) { + CChannelList * orgList = CNeutrinoApp::getInstance()->channelList; + CChannelList * channelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_CURRENT_TP), false, true); + + if(key == CRCInput::RC_games) { + t_channel_id recid = chanlist[selected]->channel_id >> 16; + for ( unsigned int i = 0 ; i < orgList->chanlist.size(); i++) { + if((orgList->chanlist[i]->channel_id >> 16) == recid) + channelList->addChannel(orgList->chanlist[i]); + } + } else { + for ( unsigned int i = 0 ; i < orgList->chanlist.size(); i++) { + if(SameTP(orgList->chanlist[i])) + channelList->addChannel(orgList->chanlist[i]); + } + } + if ( !channelList->isEmpty()) { + channelList->adjustToChannelID(orgList->getActiveChannel_ChannelID(), false); + this->frameBuffer->paintBackground(); + res = channelList->exec(); + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + } + delete channelList; + return res; + } + // -- zap history bouquet, similar to "0" quickzap, but shows a menue of last channels + if (this->lastChList.size() > 1) { + CChannelList * channelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_HISTORY), true, true); + + for(unsigned int i = 1; i < this->lastChList.size() ; ++i) { + t_channel_id channel_id = this->lastChList.getlast(i); + if(channel_id) { + CZapitChannel* channel = getChannel(channel_id); + if(channel) channelList->addChannel(channel); + } + } + if ( !channelList->isEmpty() ) { + this->frameBuffer->paintBackground(); + res = channelList->exec(); + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + } + delete channelList; + } + return res; + } + size_t maxchansize = MaxChanNr().size(); + int fw = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(widest_number); + int sx = maxchansize * fw + (fw/2); + int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6; + + int ox = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - sx)/2; + int oy = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - sy)/2; + char valstr[10]; + int chn = CRCInput::getNumericValue(key); + int pos = 1; + int lastchan= -1; + bool doZap = false; + bool showEPG = false; + + while(1) { + if (lastchan != chn) { + snprintf((char*) &valstr, sizeof(valstr), "%d", chn); + + while(strlen(valstr) < maxchansize) + strcat(valstr,"-"); //"_" + frameBuffer->paintBoxRel(ox, oy, sx, sy, COL_INFOBAR_PLUS_0); + + for (int i = maxchansize-1; i >= 0; i--) { + valstr[i+ 1] = 0; + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->RenderString(ox+fw/3+ i*fw, oy+sy-3, sx, &valstr[i], COL_INFOBAR); + } + + showInfo(chn); + lastchan = chn; + } + + g_RCInput->getMsg( &msg, &data, g_settings.timing[SNeutrinoSettings::TIMING_NUMERICZAP] * 10 ); + + if (msg == CRCInput::RC_timeout || msg == CRCInput::RC_ok) { + doZap = true; + break; + } + else if (msg == CRCInput::RC_favorites || msg == CRCInput::RC_sat || msg == CRCInput::RC_right) { + } + else if (CRCInput::isNumeric(msg)) { + if (pos == 4) { + chn = 0; + pos = 1; + } else { + chn *= 10; + pos++; + } + chn += CRCInput::getNumericValue(msg); + } + else if (msg == (neutrino_msg_t)g_settings.key_quickzap_down) { + if(chn > 1) + chn--; + } + else if (msg == (neutrino_msg_t)g_settings.key_quickzap_up) { + chn++; + } + else if (msg == CRCInput::RC_left) { + /* "backspace" */ + if(pos > 0) { + pos--; + if(chn > 10) + chn /= 10; + } + } + else if (msg == CRCInput::RC_home) + { + break; + } + else if (msg == CRCInput::RC_red) { + showEPG = true; + break; + } + else if (CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all) { + break; + } + } + + frameBuffer->paintBackgroundBoxRel(ox, oy, sx, sy); + + CZapitChannel* chan = getChannel(chn); + if (doZap) { + if(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] == 0) + g_InfoViewer->killTitle(); + + if(chan && SameTP(chan)) { + zapToChannel(chan); + res = 0; + } else + g_InfoViewer->killTitle(); + + } else { + g_InfoViewer->showTitle(getActiveChannel(), true); + g_InfoViewer->killTitle(); + if (chan && showEPG) + g_EventList->exec(chan->channel_id, chan->getName()); + } + return res; +} + +CZapitChannel* CChannelList::getPrevNextChannel(int key, unsigned int &sl) +{ + CZapitChannel* channel = chanlist[sl]; + int bsize = bouquetList->Bouquets.size(); + int bactive = bouquetList->getActiveBouquetNumber(); + + if(!g_settings.zap_cycle && bsize > 1) { + size_t cactive = sl; + + printf("CChannelList::getPrevNextChannel: selected %d total %d active bouquet %d total %d\n", cactive, chanlist.size(), bactive, bsize); + if ((key == g_settings.key_quickzap_down) || (key == CRCInput::RC_left)) { + if(cactive == 0) { + if(bactive == 0) + bactive = bsize - 1; + else + bactive--; + bouquetList->activateBouquet(bactive, false); + cactive = bouquetList->Bouquets[bactive]->channelList->getSize() - 1; + } else + --cactive; + } + else if ((key == g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) { + cactive++; + if(cactive >= chanlist.size()) { + bactive = (bactive + 1) % bsize; + bouquetList->activateBouquet(bactive, false); + cactive = 0; + } + } + sl = cactive; + channel = bouquetList->Bouquets[bactive]->channelList->getChannelFromIndex(cactive); + printf("CChannelList::getPrevNextChannel: selected %d total %d active bouquet %d total %d channel %x (%s)\n", + cactive, chanlist.size(), bactive, bsize, (int) channel, channel ? channel->getName().c_str(): ""); + } else { + if ((key == g_settings.key_quickzap_down) || (key == CRCInput::RC_left)) { + if(sl == 0) + sl = chanlist.size()-1; + else + sl--; + } + else if ((key==g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) { + sl = (sl+1)%chanlist.size(); + } + channel = chanlist[sl]; + } + return channel; +} + +void CChannelList::virtual_zap_mode(bool up) +{ + neutrino_msg_t msg; + neutrino_msg_data_t data; + + if(showEmptyError()) + return; + + unsigned int sl = selected; + int old_bactive = bouquetList->getActiveBouquetNumber(); + int bactive = old_bactive; + + CZapitChannel* channel = getPrevNextChannel(up ? CRCInput::RC_right : CRCInput::RC_left, sl); + + bool doZap = false; + bool showEPG = false; + int epgpos = 0; + + while(1) { + if (channel) + g_InfoViewer->showTitle(channel, true, epgpos); + + epgpos = 0; + g_RCInput->getMsg(&msg, &data, 15*10); // 15 seconds, not user changable + + if ((msg == CRCInput::RC_left) || (msg == CRCInput::RC_right)) { + channel = bouquetList->Bouquets[bactive]->channelList->getPrevNextChannel(msg, sl); + bactive = bouquetList->getActiveBouquetNumber(); + } + else if (msg == CRCInput::RC_up || msg == CRCInput::RC_down) { + epgpos = (msg == CRCInput::RC_up) ? -1 : 1; + } + else if ((msg == CRCInput::RC_ok) || (msg == CRCInput::RC_home) || (msg == CRCInput::RC_timeout)) { + if(msg == CRCInput::RC_ok) + doZap = true; + break; + } + else if (msg == CRCInput::RC_red) { + showEPG = true; + break; + } + else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) { + break; + } + } + g_InfoViewer->clearVirtualZapMode(); + + if (doZap) { + if(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] == 0) + g_InfoViewer->killTitle(); + if(channel && SameTP(channel)) + zapToChannel(channel); + else + g_InfoViewer->killTitle(); + } else { + g_InfoViewer->showTitle(getActiveChannel(), true); + g_InfoViewer->killTitle(); + bouquetList->activateBouquet(old_bactive, false); + + if (showEPG && channel) + g_EventList->exec(channel->channel_id, channel->getName()); + } +} + +void CChannelList::quickZap(int key, bool /* cycle */) +{ + if(chanlist.empty()) + return; + + unsigned int sl = selected; + /* here selected value doesnt matter, zap will do adjust */ + CZapitChannel* channel = getPrevNextChannel(key, sl); + if(channel) + CNeutrinoApp::getInstance()->channelList->zapToChannel(channel); + g_RCInput->clearRCMsg(); //FIXME test for n.103 +} + +void CChannelList::paintDetails(int index) +{ + CChannelEvent *p_event = NULL; + + //colored_events init + bool colored_event_C = false; + bool colored_event_N = false; + if (g_settings.colored_events_channellist == 1) + colored_event_C = true; + if (g_settings.colored_events_channellist == 2) + colored_event_N = true; + + if (displayNext) { + p_event = &chanlist[index]->nextEvent; + } else { + p_event = &chanlist[index]->currentEvent; + } + + frameBuffer->paintBoxRel(x+2, y + height + 2, widthDetails-4, info_height - 4, COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE);//round + + if (!p_event->description.empty()) { + char cNoch[50] = {0}; // UTF-8 + char cSeit[50] = {0}; // UTF-8 + + struct tm *pStartZeit = localtime(&p_event->startTime); + unsigned seit = ( time(NULL) - p_event->startTime ) / 60; + snprintf(cSeit, sizeof(cSeit), "%s %02d:%02d",(displayNext) ? g_Locale->getText(LOCALE_CHANNELLIST_START):g_Locale->getText(LOCALE_CHANNELLIST_SINCE), pStartZeit->tm_hour, pStartZeit->tm_min); + if (displayNext) { + snprintf(cNoch, sizeof(cNoch), "(%d min)", p_event->duration / 60); + } else { + int noch = (p_event->startTime + p_event->duration - time(NULL)) / 60; + if ((noch< 0) || (noch>=10000)) + noch= 0; + snprintf(cNoch, sizeof(cNoch), "(%d / %d min)", seit, noch); + } + int seit_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(cSeit, true); // UTF-8 + int noch_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(cNoch, true); // UTF-8 + + std::string text1= p_event->description; + std::string text2= p_event->text; + + int xstart = 10; + if (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1, true) > (widthDetails - 30 - seit_len) ) + { + // zu breit, Umbruch versuchen... + int pos; + do { + pos = text1.find_last_of("[ -.]+"); + if ( pos!=-1 ) + text1 = text1.substr( 0, pos ); + } while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1, true) > (widthDetails - 30 - seit_len) ) ); + + std::string text3 = ""; /* not perfect, but better than crashing... */ + if (p_event->description.length() > text1.length()) + text3 = p_event->description.substr(text1.length()+ 1); + + if (!text2.empty() && !text3.empty()) + text3= text3+ " - "; + + xstart += g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text3, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 2* fheight, widthDetails - 30- noch_len, text3, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); + } + + if (!(text2.empty())) { + while ( text2.find_first_of("[ -.+*#?=!$%&/]+") == 0 ) + text2 = text2.substr( 1 ); + text2 = text2.substr( 0, text2.find('\n') ); +#if 0 //FIXME: to discuss, eat too much cpu time if string long enough + int pos = 0; + while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text2, true) > (widthDetails - 30 - noch_len) ) ) { + pos = text2.find_last_of(" "); + + if ( pos!=-1 ) { + text2 = text2.substr( 0, pos ); + } + } +#endif + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ xstart, y+ height+ 5+ 2* fheight, widthDetails- xstart- 30- noch_len, text2, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); + } + + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ fheight, widthDetails - 30 - seit_len, text1, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ widthDetails- 10- seit_len, y+ height+ 5+ fheight, seit_len, cSeit, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ widthDetails- 10- noch_len, y+ height+ 5+ 2* fheight, noch_len, cNoch, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 + } + if(g_settings.channellist_foot == 0) { + transponder t; + CServiceManager::getInstance()->GetTransponder(chanlist[index]->getTransponderId(), t); + + std::string desc = t.description(); + if(chanlist[index]->pname) + desc = desc + " (" + std::string(chanlist[index]->pname) + ")"; + else + desc = desc + " (" + CServiceManager::getInstance()->GetSatelliteName(chanlist[index]->getSatellitePosition()) + ")"; + + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 3*fheight, widthDetails - 30, desc.c_str(), COL_MENUCONTENTDARK, 0, true); + } + else if( !displayNext && g_settings.channellist_foot == 1) { // next Event + char buf[128] = {0}; + char cFrom[50] = {0}; // UTF-8 + CSectionsdClient::CurrentNextInfo CurrentNext; + CEitManager::getInstance()->getCurrentNextServiceKey(chanlist[index]->channel_id, CurrentNext); + if (!CurrentNext.next_name.empty()) { + struct tm *pStartZeit = localtime (& CurrentNext.next_zeit.startzeit); + snprintf(cFrom, sizeof(cFrom), "%s %02d:%02d",g_Locale->getText(LOCALE_WORD_FROM),pStartZeit->tm_hour, pStartZeit->tm_min ); + snprintf(buf, sizeof(buf), "%s", CurrentNext.next_name.c_str()); + int from_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(cFrom, true); // UTF-8 + + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 3*fheight, widthDetails - 30 - from_len, buf, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST :COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ widthDetails- 10- from_len, y+ height+ 5+ 3*fheight, from_len, cFrom, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 + } + } + if ((g_settings.channellist_minitv) && (p_event != NULL)) + paint_events(index); +} + +void CChannelList::clearItem2DetailsLine() +{ + paintItem2DetailsLine (-1, 0); +} + +void CChannelList::paintItem2DetailsLine (int pos, int /*ch_index*/) +{ +#define ConnectLineBox_Width 16 + + int xpos = x - ConnectLineBox_Width; + int ypos1 = y + theight+0 + pos*fheight; + int ypos2 = y + height; + int ypos1a = ypos1 + (fheight/2)-2; + int ypos2a = ypos2 + (info_height/2)-2; + fb_pixel_t col1 = COL_MENUCONTENT_PLUS_6; + // Clear + frameBuffer->paintBackgroundBoxRel(xpos,y, ConnectLineBox_Width, height+info_height + 1); + + // paint Line if detail info (and not valid list pos) + if (pos >= 0) { //pos >= 0 && chanlist[ch_index]->currentEvent.description != "") { + if(1) // FIXME why -> ? (!g_settings.channellist_extended) + { + //details line + CComponentsDetailLine details_line(xpos, ypos1a, ypos2a, fheight/2+1, info_height-RADIUS_LARGE*2); + details_line.paint(); + + //info box frame + frameBuffer->paintBoxFrame(x, ypos2, widthDetails, info_height, 2, col1, RADIUS_LARGE); + } + } +} + +void CChannelList::showChannelLogo() +{ + if (g_settings.channellist_minitv) + return; + if(g_settings.infobar_show_channellogo){ + static int logo_w = 0; + static int logo_h = 0; + int logo_w_max = width / 4; + frameBuffer->paintBoxRel(x + width - logo_off - logo_w, y+(theight-logo_h)/2, logo_w, logo_h, COL_MENUHEAD_PLUS_0); + + std::string lname; + if(g_PicViewer->GetLogoName(chanlist[selected]->channel_id, chanlist[selected]->getName(), lname, &logo_w, &logo_h)) { + if((logo_h > theight) || (logo_w > logo_w_max)) + g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, logo_w_max, theight); + g_PicViewer->DisplayImage(lname, x + width - logo_off - logo_w, y+(theight-logo_h)/2, logo_w, logo_h); + } + } +} + +#define NUM_LIST_BUTTONS 4 +struct button_label SChannelListButtons[NUM_LIST_BUTTONS] = +{ + { NEUTRINO_ICON_BUTTON_RED, LOCALE_INFOVIEWER_EVENTLIST}, + { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOUQUETLIST_HEAD}, + { NEUTRINO_ICON_BUTTON_BLUE, LOCALE_INFOVIEWER_NEXT}, + { NEUTRINO_ICON_BUTTON_RECORD_INACTIVE, NONEXISTANT_LOCALE} +}; +#define NUM_LIST_BUTTONS_SORT 5 +struct button_label SChannelListButtons_SMode[NUM_LIST_BUTTONS_SORT] = +{ + { NEUTRINO_ICON_BUTTON_RED, LOCALE_INFOVIEWER_EVENTLIST}, + { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_CHANNELLIST_FOOT_SORT_ALPHA}, + { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOUQUETLIST_HEAD}, + { NEUTRINO_ICON_BUTTON_BLUE, LOCALE_INFOVIEWER_NEXT}, + { NEUTRINO_ICON_BUTTON_RECORD_INACTIVE, NONEXISTANT_LOCALE} +}; + +void CChannelList::paintButtonBar(bool is_current) +{ + //printf("[neutrino channellist] %s...%d, selected %d\n", __FUNCTION__, __LINE__, selected); + unsigned int smode = CNeutrinoApp::getInstance()->GetChannelMode(); + int num_buttons = smode != LIST_MODE_FAV ? NUM_LIST_BUTTONS_SORT : NUM_LIST_BUTTONS; + + struct button_label Button[num_buttons]; + const neutrino_locale_t button_ids[] = {LOCALE_INFOVIEWER_NOW,LOCALE_INFOVIEWER_NEXT,LOCALE_MAINMENU_RECORDING,LOCALE_MAINMENU_RECORDING_STOP,NONEXISTANT_LOCALE, + LOCALE_CHANNELLIST_FOOT_SORT_ALPHA,LOCALE_CHANNELLIST_FOOT_SORT_FREQ,LOCALE_CHANNELLIST_FOOT_SORT_SAT,LOCALE_CHANNELLIST_FOOT_SORT_CHNUM}; + const std::vector buttonID_rest (button_ids, button_ids + sizeof(button_ids) / sizeof(neutrino_locale_t) ); + + for (int i = 0;iRecordingStatus(getActiveChannel_ChannelID()); + + if (g_settings.recording_type != RECORDING_OFF && !displayNext){ + if (is_current && !do_record){ + Button[Bindex].locale = LOCALE_MAINMENU_RECORDING; + Button[Bindex].button = NEUTRINO_ICON_BUTTON_RECORD_ACTIVE; + }else if (do_record){ + Button[Bindex].locale = LOCALE_MAINMENU_RECORDING_STOP; + Button[Bindex].button = NEUTRINO_ICON_BUTTON_STOP; + }else{ + Button[Bindex].locale = NONEXISTANT_LOCALE; + Button[Bindex].button = NEUTRINO_ICON_BUTTON_RECORD_INACTIVE; + } + } + if(smode) + { + switch (g_settings.channellist_sort_mode) + { + case SORT_ALPHA: + Button[1].locale = LOCALE_CHANNELLIST_FOOT_SORT_ALPHA; + break; + case SORT_TP: + Button[1].locale = LOCALE_CHANNELLIST_FOOT_SORT_FREQ; + break; + case SORT_SAT: + Button[1].locale = LOCALE_CHANNELLIST_FOOT_SORT_SAT; + break; + case SORT_CH_NUMBER: + Button[1].locale = LOCALE_CHANNELLIST_FOOT_SORT_CHNUM; + break; + default: + break; + } + } + + //paint buttons + int y_foot = y + (height - footerHeight); + ::paintButtons(x, y_foot, width,num_buttons, Button, footerHeight,0,false,COL_INFOBAR_SHADOW,NULL,0,true, buttonID_rest); +} + +void CChannelList::paintItem(int pos) +{ + int ypos = y+ theight+0 + pos*fheight; + uint8_t color; + fb_pixel_t bgcolor; + bool iscurrent = true; + bool paintbuttons = false; + unsigned int curr = liststart + pos; + int rec_mode; + +#if 0 + if(CNeutrinoApp::getInstance()->recordingstatus && !autoshift && curr < chanlist.size()) { + iscurrent = (chanlist[curr]->channel_id >> 16) == (rec_channel_id >> 16); + //printf("recording %llx current %llx current = %s\n", rec_channel_id, chanlist[liststart + pos]->channel_id, iscurrent? "yes" : "no"); + } +#endif + if(curr < chanlist.size()) + iscurrent = SameTP(chanlist[curr]); + + if (curr == selected) { + color = COL_MENUCONTENTSELECTED; + bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; + paintItem2DetailsLine (pos, curr); + paintDetails(curr); + frameBuffer->paintBoxRel(x,ypos, width- 15, fheight, bgcolor, RADIUS_LARGE); + paintbuttons = true; + } else { + color = iscurrent ? COL_MENUCONTENT : COL_MENUCONTENTINACTIVE; + bgcolor = iscurrent ? COL_MENUCONTENT_PLUS_0 : COL_MENUCONTENTINACTIVE_PLUS_0; + frameBuffer->paintBoxRel(x,ypos, width- 15, fheight, bgcolor, 0); + } + + if(curr < chanlist.size()) { + char nameAndDescription[255]; + char tmp[10]; + CZapitChannel* chan = chanlist[curr]; + int prg_offset=0; + int title_offset=0; + uint8_t tcolor=(liststart + pos == selected) ? color : COL_MENUCONTENTINACTIVE; + int xtheight=fheight-2; + + if(g_settings.channellist_extended) + { + prg_offset = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("00:00"); + title_offset=6; + } + + snprintf((char*) tmp, sizeof(tmp), "%d", this->historyMode ? pos : chan->number); + + CChannelEvent *p_event=NULL; + if (displayNext) { + p_event = &chan->nextEvent; + } else { + p_event = &chan->currentEvent; + } + + if (pos == 0) + { + /* FIXME move to calcSize() ? */ + int w_max, w_min, h; + ChannelList_Rec = 0; + int recmode_icon_max = CRecordManager::RECMODE_REC, recmode_icon_min = CRecordManager::RECMODE_TSHIFT; + frameBuffer->getIconSize(NEUTRINO_ICON_REC, &w_max, &h); + frameBuffer->getIconSize(NEUTRINO_ICON_AUTO_SHIFT, &w_min, &h); + if (w_max < w_min) + { + recmode_icon_max = CRecordManager::RECMODE_TSHIFT; + recmode_icon_min = CRecordManager::RECMODE_REC; + h = w_max; + w_max = w_min; + w_min = h; + } + for (uint32_t i = 0; i < chanlist.size(); i++) + { + rec_mode = CRecordManager::getInstance()->GetRecordMode(chanlist[i]->channel_id); + if (rec_mode & recmode_icon_max) + { + ChannelList_Rec = w_max; + break; + } else if (rec_mode & recmode_icon_min) + ChannelList_Rec = w_min; + } + if (ChannelList_Rec > 0) + ChannelList_Rec += 8; + } + + //record check + rec_mode = CRecordManager::getInstance()->GetRecordMode(chanlist[curr]->channel_id); + + //set recording icon + const char * rec_icon = ""; + if (rec_mode & CRecordManager::RECMODE_REC) + rec_icon = NEUTRINO_ICON_REC; + else if (rec_mode & CRecordManager::RECMODE_TSHIFT) + rec_icon = NEUTRINO_ICON_AUTO_SHIFT; + + //calculating icons + int icon_x = (x+width-15-2) - RADIUS_LARGE/2; + int r_icon_w=0; int s_icon_h=0; int s_icon_w=0; + frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED, &s_icon_w, &s_icon_h); + r_icon_w = ChannelList_Rec; + int r_icon_x = icon_x; + + //paint scramble icon + if(chan->scrambled) + if (frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, icon_x - s_icon_w, ypos, fheight))//ypos + (fheight - 16)/2); + r_icon_x = r_icon_x - s_icon_w; + + //paint recording icon + if (rec_mode != CRecordManager::RECMODE_OFF) + frameBuffer->paintIcon(rec_icon, r_icon_x - r_icon_w, ypos, fheight);//ypos + (fheight - 16)/2); + + //paint buttons + if (paintbuttons) + paintButtonBar(iscurrent); + + int icon_space = r_icon_w+s_icon_w; + + //number + int numpos = x+5+numwidth- g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(tmp); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(numpos,ypos+fheight, numwidth+5, tmp, color, fheight); + + int l=0; + if (this->historyMode) + l = snprintf(nameAndDescription, sizeof(nameAndDescription), ": %d %s", chan->number, chan->getName().c_str()); + else + l = snprintf(nameAndDescription, sizeof(nameAndDescription), "%s", chan->getName().c_str()); + + CProgressBar pb(false); /* never colored */ + int pb_space = prg_offset - title_offset; + int pb_max = pb_space - 4; + if (!(p_event->description.empty())) { + snprintf(nameAndDescription+l, sizeof(nameAndDescription)-l,g_settings.channellist_epgtext_align_right ? " ":" - "); + unsigned int ch_name_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(nameAndDescription, true); + unsigned int ch_desc_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(p_event->description, true); + + int max_desc_len = width - numwidth - prg_offset - ch_name_len - 15 - 20; // 15 = scrollbar, 20 = spaces + if (chan->scrambled || (g_settings.channellist_extended ||g_settings.channellist_epgtext_align_right)) + max_desc_len -= icon_space; /* do we need space for the lock/rec icon? */ + + if (max_desc_len < 0) + max_desc_len = 0; + if ((int) ch_desc_len > max_desc_len) + ch_desc_len = max_desc_len; + + if(g_settings.channellist_extended) { + if(displayNext) + { + struct tm *pStartZeit = localtime(&p_event->startTime); + + snprintf((char*) tmp, sizeof(tmp), "%02d:%02d", pStartZeit->tm_hour, pStartZeit->tm_min); +// g_Font[SNeutrinoSettings::FONT_TYPE_IMAGEINFO_SMALL]->RenderString(x+ 5+ numwidth+ 6, ypos+ xtheight, width- numwidth- 20- 15 -poffs, tmp, COL_MENUCONTENT, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(x+ 5+ numwidth+ 6, ypos+ xtheight, width- numwidth- 20- 15 -prg_offset, tmp, tcolor, 0, true); + } + else + { + time_t jetzt=time(NULL); + int runningPercent = 0; + + if (((jetzt - p_event->startTime + 30) / 60) < 0 ) + { + runningPercent= 0; + } + else + { + runningPercent=(jetzt-p_event->startTime) * pb_max / p_event->duration; + if (runningPercent > pb_max) // this would lead to negative value in paintBoxRel + runningPercent = pb_max; // later on which can be fatal... + } + + int pb_activeCol , pb_passiveCol; + if (liststart + pos != selected) { + pb_activeCol = COL_MENUCONTENT_PLUS_3; + pb_passiveCol = COL_MENUCONTENT_PLUS_1; + } else { + pb_activeCol = COL_MENUCONTENTSELECTED_PLUS_2; + pb_passiveCol = COL_MENUCONTENTSELECTED_PLUS_0; + } + pb.paintProgressBar(x+5+numwidth + title_offset, ypos + fheight/4, pb_space + 2, fheight/2, runningPercent, pb_max, pb_activeCol, pb_passiveCol, pb_activeCol); + } + } + + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 5+ numwidth+ 10+prg_offset, ypos+ fheight, width- numwidth- 40- 15-prg_offset, nameAndDescription, color, 0, true); + if (g_settings.channellist_epgtext_align_right) { + // align right + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + width - 20 - ch_desc_len - icon_space - 4, ypos + fheight, ch_desc_len, p_event->description, (curr == selected)?COL_MENUCONTENTSELECTED:(!displayNext ? COL_MENUCONTENT : COL_MENUCONTENTINACTIVE) , 0, true); + } + else { + // align left + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ 5+ numwidth+ 10+ ch_name_len+ 5+prg_offset, ypos+ fheight, ch_desc_len, p_event->description, (curr == selected)?COL_MENUCONTENTSELECTED:(!displayNext ? COL_MENUCONTENT : COL_MENUCONTENTINACTIVE) , 0, true); + } + } + else { + if(g_settings.channellist_extended) { + int pbz_activeCol, pbz_passiveCol; + if (liststart + pos != selected) { + pbz_activeCol = COL_MENUCONTENT_PLUS_1; + pbz_passiveCol = COL_MENUCONTENT_PLUS_0; + } else { + pbz_activeCol = COL_MENUCONTENTSELECTED_PLUS_2; + pbz_passiveCol = COL_MENUCONTENTSELECTED_PLUS_0; + } + pb.paintProgressBar(x+5+numwidth + title_offset, ypos + fheight/4, pb_space + 2, fheight/2, 0, pb_max, pbz_activeCol, pbz_passiveCol, pbz_activeCol, 0, NULL, 0, NULL, true); + } + //name + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 5+ numwidth+ 10+prg_offset, ypos+ fheight, width- numwidth- 40- 15-prg_offset, nameAndDescription, color, 0, true); // UTF-8 + } + if (curr == selected) { + if (!(chan->currentEvent.description.empty())) { + snprintf(nameAndDescription, sizeof(nameAndDescription), "%s - %s", + chan->getName().c_str(), p_event->description.c_str()); + CVFD::getInstance()->showMenuText(0, nameAndDescription, -1, true); // UTF-8 + } else + CVFD::getInstance()->showMenuText(0, chan->getName().c_str(), -1, true); // UTF-8 + } + } +} + +void CChannelList::paintHead() +{ + int timestr_len = 0; + char timestr[10] = {0}; + time_t now = time(NULL); + struct tm *tm = localtime(&now); + bool gotTime = g_Sectionsd->getIsTimeSet(); + + if(gotTime) { + strftime(timestr, 10, "%H:%M", tm); + timestr_len = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(timestr, true); // UTF-8 + } + + int iw1, iw2, iw3, ih = 0; + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_INFO, &iw1, &ih); + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MENU, &iw2, &ih); + if (g_settings.channellist_new_zap_mode) + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE_ZAP_ACTIVE, &iw3, &ih); + + // head + frameBuffer->paintBoxRel(x,y, widthDetails,theight+0, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);//round + + frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_INFO, x + width - iw1 - 4, y, theight); //y+ 5 ); + frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_MENU, x + width - iw1 - iw2 - 8, y, theight);//y + 5); // icon for bouquet list button + if (g_settings.channellist_new_zap_mode) + frameBuffer->paintIcon(this->new_mode_active ? + NEUTRINO_ICON_BUTTON_MUTE_ZAP_ACTIVE : NEUTRINO_ICON_BUTTON_MUTE_ZAP_INACTIVE, + x + width - iw1 - iw2 - iw3 - 12, y, theight); + + if (gotTime) { + int iw3x = (g_settings.channellist_new_zap_mode) ? iw3 : -4; + if (g_settings.channellist_minitv) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + widthDetails - 16 -timestr_len, + y+theight, timestr_len, timestr, COL_MENUHEAD, 0, true); // UTF-8 + else + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + width - iw1 - iw2 - iw3x - 16 -timestr_len, + y+theight, timestr_len, timestr, COL_MENUHEAD, 0, true); // UTF-8 + timestr_len += 4; + } + + timestr_len += iw1 + iw2 + 12; + if (g_settings.channellist_new_zap_mode) + timestr_len += iw3 + 4; + logo_off = timestr_len + 4; + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+theight+0, widthDetails - timestr_len, name, COL_MENUHEAD, 0, true); // UTF-8 +} + +void CChannelList::paint() +{ + if (g_settings.channellist_minitv) + { + paint_pig(x+width, y+theight+1, pig_width, pig_height); + } + + numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(MaxChanNr().c_str()); + + liststart = (selected/listmaxshow)*listmaxshow; + updateEvents(this->historyMode ? 0:liststart, this->historyMode ? 0:(liststart + listmaxshow)); + + frameBuffer->paintBoxRel(x, y+theight, width, height-footerHeight-theight, COL_MENUCONTENT_PLUS_0, 0, CORNER_BOTTOM); + for(unsigned int count = 0; count < listmaxshow; count++) { + paintItem(count); + } + const int ypos = y+ theight; + const int sb = fheight* listmaxshow; + frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); + + const int sbc= ((chanlist.size()- 1)/ listmaxshow)+ 1; + const int sbs= (selected/listmaxshow); + + frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs*(sb-4)/sbc, 11, (sb-4)/sbc, COL_MENUCONTENT_PLUS_3); + showChannelLogo(); +} + +bool CChannelList::isEmpty() const +{ + return this->chanlist.empty(); +} + +int CChannelList::getSize() const +{ + return this->chanlist.size(); +} + +int CChannelList::getSelectedChannelIndex() const +{ + return this->selected; +} + +bool CChannelList::SameTP(t_channel_id channel_id) +{ + bool iscurrent = true; + +#if 0 + if(CNeutrinoApp::getInstance()->recordingstatus && !autoshift) + iscurrent = (channel_id >> 16) == (rec_channel_id >> 16); +#endif + if(CNeutrinoApp::getInstance()->recordingstatus) { +#if 0 + if(channel_id == 0) + channel_id = chanlist[selected]->channel_id; + iscurrent = CRecordManager::getInstance()->SameTransponder(channel_id); +#endif + CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id); + if(channel) + iscurrent = SameTP(channel); + else + iscurrent = false; + } + return iscurrent; +} + +bool CChannelList::SameTP(CZapitChannel * channel) +{ + bool iscurrent = true; + + if(CNeutrinoApp::getInstance()->recordingstatus) { + if(channel == NULL) + channel = chanlist[selected]; + iscurrent = CFEManager::getInstance()->canTune(channel); + } + return iscurrent; +} +std::string CChannelList::MaxChanNr() +{ + zapit_list_it_t chan_it; + std::stringstream ss; + std::string maxchansize; + int chan_nr_max = 1; + unsigned int nr = 0; + for (chan_it=chanlist.begin(); chan_it!=chanlist.end(); ++chan_it) { + chan_nr_max = std::max(chan_nr_max, chanlist[nr++]->number); + } + ss << chan_nr_max; + ss >> maxchansize; + return maxchansize; +} + +void CChannelList::paint_pig (int x, int y, int w, int h) +{ + frameBuffer->paintBackgroundBoxRel (x, y, w, h); + printf("CChannelList::paint_pig x %d y %d w %d h %d osd_w %d osd_w %d\n", x, y, w, h, frameBuffer->getScreenWidth(true), frameBuffer->getScreenHeight(true)); + videoDecoder->Pig(x, y, w, h, frameBuffer->getScreenWidth(true), frameBuffer->getScreenHeight(true)); +} + +void CChannelList::paint_events(int index) +{ + readEvents(chanlist[index]->channel_id); + frameBuffer->paintBoxRel(x+ width,y+ theight+pig_height, infozone_width, infozone_height,COL_MENUHEAD_PLUS_0); + char text1[10]; + CChannelEventList::iterator e; + time_t azeit; + time(&azeit); + int ffheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight(); + + if ( evtlist.size() == 0 ) + { + CChannelEvent evt; + + evt.description = g_Locale->getText(LOCALE_EPGLIST_NOEVENTS); + evt.eventID = 0; + evtlist.push_back(evt); + + } + + int i=1; + for (e=evtlist.begin(); e!=evtlist.end(); ++e ) + { + //Remove events in the past + time_t dif = azeit - e->startTime; + if ( (dif > 0) && (!(e->eventID == 0))) + { + do + { + //printf("%d seconds in the past - deleted %s\n", dif, e->description.c_str()); + e = evtlist.erase(e); + dif = azeit - e->startTime; + } + while ( dif > 0 ); + } + //Display the remaining events + struct tm *tmStartZeit = localtime(&e->startTime); + strftime(text1, sizeof(text1), "%H:%M", tmStartZeit ); + //printf("%s %s\n", text1, e->description.c_str()); + int timewidth = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getRenderWidth(text1, true); + if ((y+ theight+ pig_height + i*ffheight) < (y+ height)) + { + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->RenderString(x+ width+5, y+ theight+ pig_height + i*ffheight, timewidth, text1, COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->RenderString(x+ width+5+timewidth+5, y+ theight+ pig_height + i*ffheight, infozone_width - timewidth - 20, e->description, COL_MENUCONTENTDARK, 0, true); + } + else break; + i++; + } + evtlist.clear(); +} + +static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent& b) +{ + return a.startTime < b.startTime; +} + +void CChannelList::readEvents(const t_channel_id channel_id) +{ + CEitManager::getInstance()->getEventsServiceKey(channel_id , evtlist); + + if ( evtlist.empty() ) + { + CChannelEvent evt; + evt.description = g_Locale->getText(LOCALE_EPGLIST_NOEVENTS); + evt.eventID = 0; + evtlist.push_back(evt); + } + else + sort(evtlist.begin(),evtlist.end(),sortByDateTime); + + return; +} diff --git a/src/gui/channellist.h b/src/gui/channellist.h index d96e22a3a..4cc43c068 100644 --- a/src/gui/channellist.h +++ b/src/gui/channellist.h @@ -73,10 +73,15 @@ private: CZapProtection* zapProtection; int width; + int widthDetails; int height; int x; int y; int logo_off; + int pig_width; + int pig_height; + int infozone_width; + int infozone_height; bool historyMode; bool vlist; // "virtual" list, not bouquet @@ -98,6 +103,10 @@ private: void showChannelLogo(); void calcSize(); std::string MaxChanNr(); + void paint_pig(int x, int y, int w, int h); + void paint_events(int index); + CChannelEventList evtlist; + void readEvents(const t_channel_id channel_id); public: CChannelList(const char * const Name, bool historyMode = false, bool _vlist = false, bool new_mode_active = false ); diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 5df9e9a6b..3fd4e292d 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -796,6 +796,11 @@ void COsdSetup::showOsdChanlistSetup(CMenuWidget *menu_chanlist) CMenuOptionChooser * mc; menu_chanlist->addIntroItems(LOCALE_MISCSETTINGS_CHANNELLIST); + // channel list with minitv + mc = new CMenuOptionChooser(LOCALE_CHANNELLIST_MINITV, &g_settings.channellist_minitv, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_MINITV); + menu_chanlist->addItem(mc); + // epg align mc = new CMenuOptionChooser(LOCALE_MISCSETTINGS_CHANNELLIST_EPGTEXT_ALIGN, &g_settings.channellist_epgtext_align_right, CHANNELLIST_EPGTEXT_ALIGN_RIGHT_OPTIONS, CHANNELLIST_EPGTEXT_ALIGN_RIGHT_OPTIONS_COUNT, true); mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_EPG_ALIGN); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index beec61763..3974c1178 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -610,6 +610,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.channellist_foot = configfile.getInt32("channellist_foot" , 1);//default next Event g_settings.channellist_new_zap_mode = configfile.getInt32("channellist_new_zap_mode", 1); g_settings.channellist_sort_mode = configfile.getInt32("channellist_sort_mode", 0);//sort mode: alpha, freq, sat + g_settings.channellist_minitv = configfile.getInt32("channellist_minitv", 0); //default off //screen configuration g_settings.screen_xres = configfile.getInt32("screen_xres", 100); @@ -1030,6 +1031,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setBool("channellist_extended" , g_settings.channellist_extended); configfile.setInt32("channellist_foot" , g_settings.channellist_foot); configfile.setInt32("channellist_new_zap_mode", g_settings.channellist_new_zap_mode); + configfile.setInt32("channellist_minitv", g_settings.channellist_minitv); configfile.setInt32("remote_control_hardware", g_settings.remote_control_hardware); configfile.setBool ( "audiochannel_up_down_enable", g_settings.audiochannel_up_down_enable ); configfile.setInt32("channellist_sort_mode", g_settings.channellist_sort_mode); diff --git a/src/neutrino.cpp.rej b/src/neutrino.cpp.rej new file mode 100644 index 000000000..80d3ad113 --- /dev/null +++ b/src/neutrino.cpp.rej @@ -0,0 +1,9 @@ +diff a/src/neutrino.cpp b/src/neutrino.cpp (rejected hunks) +@@ -690,6 +690,7 @@ int CNeutrinoApp::loadSetup(const char * fname) + g_settings.channellist_foot = configfile.getInt32("channellist_foot" , 1);//default next Event + g_settings.channellist_new_zap_mode = configfile.getInt32("channellist_new_zap_mode", 1); + g_settings.channellist_sort_mode = configfile.getInt32("channellist_sort_mode", 0);//sort mode: alpha, freq, sat ++ g_settings.channellist_minitv = configfile.getInt32("channellist_minitv", 0); //default off + + //screen configuration + g_settings.screen_xres = configfile.getInt32("screen_xres", 100); diff --git a/src/neutrino.cpp~ b/src/neutrino.cpp~ new file mode 100644 index 000000000..7dc872044 --- /dev/null +++ b/src/neutrino.cpp~ @@ -0,0 +1,3881 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2001 Steffen Hehn 'McClean' + and some other guys + Homepage: http://dbox.cyberphoria.org/ + + Copyright (C) 2011 CoolStream International Ltd + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#define NEUTRINO_CPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "global.h" +#include "neutrino.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gui/audioplayer.h" +#include "gui/bouquetlist.h" +#include "gui/cam_menu.h" +#include "gui/cec_setup.h" +#include "gui/channellist.h" +#include "gui/epgview.h" +#include "gui/eventlist.h" +#include "gui/favorites.h" +#include "gui/filebrowser.h" +#include "gui/hdd_menu.h" +#include "gui/infoviewer.h" +#include "gui/mediaplayer.h" +#include "gui/movieplayer.h" +#include "gui/osd_setup.h" +#include "gui/osdlang_setup.h" +#include "gui/pictureviewer.h" +#include "gui/plugins.h" +#include "gui/rc_lock.h" +#include "gui/scan_setup.h" +#include "gui/start_wizard.h" +#include "gui/videosettings.h" + +#include "gui/widget/hintbox.h" +#include "gui/widget/icons.h" +#include "gui/widget/menue.h" +#include "gui/widget/messagebox.h" +#include "gui/infoclock.h" + +#if HAVE_COOL_HARDWARE +#include "gui/widget/progressbar.h" +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +int old_b_id = -1; +CHintBox * reloadhintBox = 0; +bool has_hdd; + +CInfoClock *InfoClock; +int allow_flash = 1; +Zapit_config zapitCfg; +char zapit_lat[20]; +char zapit_long[20]; +bool autoshift = false; +uint32_t scrambled_timer; +t_channel_id standby_channel_id; + +//NEW +static pthread_t timer_thread; +void * timerd_main_thread(void *data); + +void * nhttpd_main_thread(void *data); +static pthread_t nhttpd_thread ; + +//#define DISABLE_SECTIONSD + +extern cVideo * videoDecoder; +extern cDemux *videoDemux; +extern cAudio * audioDecoder; +cPowerManager *powerManager; +cCpuFreqManager * cpuFreq; + +void stop_daemons(bool stopall = true); +void stop_video(void); +// uncomment if you want to have a "test" menue entry (rasc) + +//#define __EXPERIMENTAL_CODE__ +#ifdef __EXPERIMENTAL_CODE__ +#include "gui/ch_mosaic.h" +#endif + +CAudioSetupNotifier * audioSetupNotifier; +CBouquetList * bouquetList; // current list + +CBouquetList * TVbouquetList; +CBouquetList * TVsatList; +CBouquetList * TVfavList; +CBouquetList * TVallList; + +CBouquetList * RADIObouquetList; +CBouquetList * RADIOsatList; +CBouquetList * RADIOfavList; +CBouquetList * RADIOallList; + +CPlugins * g_PluginList; +CRemoteControl * g_RemoteControl; +CPictureViewer * g_PicViewer; +CCAMMenuHandler * g_CamHandler; +CVolume * g_volume; + +// Globale Variablen - to use import global.h + +// I don't like globals, I would have hidden them in classes, +// but if you wanna do it so... ;) +bool parentallocked = false; +static char **global_argv; + +extern const char * locale_real_names[]; /* #include */ + +// USERMENU +const char* usermenu_button_def[SNeutrinoSettings::BUTTON_MAX]={"red","green","yellow","blue"}; + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ CNeutrinoApp - Constructor, initialize g_fontRenderer + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +CNeutrinoApp::CNeutrinoApp() +: configfile('\t') +{ + standby_pressed_at.tv_sec = 0; + + frameBuffer = CFrameBuffer::getInstance(); + frameBuffer->setIconBasePath(DATADIR "/neutrino/icons/"); + + SetupFrameBuffer(); + + mode = mode_unknown; + channelList = NULL; + TVchannelList = NULL; + RADIOchannelList = NULL; + skipShutdownTimer = false; + skipSleepTimer = false; + lockStandbyCall = false; + current_muted = 0; + recordingstatus = 0; + g_channel_list_changed = 0; + memset(&font, 0, sizeof(neutrino_font_descr_struct)); +} + +/*------------------------------------------------------------------------------------- +- CNeutrinoApp - Destructor - +-------------------------------------------------------------------------------------*/ +CNeutrinoApp::~CNeutrinoApp() +{ + if (channelList) + delete channelList; +} + +CNeutrinoApp* CNeutrinoApp::getInstance() +{ + static CNeutrinoApp* neutrinoApp = NULL; + + if(!neutrinoApp) { + neutrinoApp = new CNeutrinoApp(); + dprintf(DEBUG_DEBUG, "NeutrinoApp Instance created\n"); + } + return neutrinoApp; +} + + +#define FONT_STYLE_REGULAR 0 +#define FONT_STYLE_BOLD 1 +#define FONT_STYLE_ITALIC 2 + +extern font_sizes_groups_struct font_sizes_groups[]; +extern font_sizes_struct neutrino_font[]; + +const font_sizes_struct signal_font = {LOCALE_FONTSIZE_INFOBAR_SMALL , 14, FONT_STYLE_REGULAR, 1}; + +typedef struct lcd_setting_t +{ + const char * const name; + const unsigned int default_value; +} lcd_setting_struct_t; + +const lcd_setting_struct_t lcd_setting[SNeutrinoSettings::LCD_SETTING_COUNT] = +{ + {"lcd_brightness" , DEFAULT_VFD_BRIGHTNESS }, + {"lcd_standbybrightness", DEFAULT_VFD_STANDBYBRIGHTNESS}, + {"lcd_contrast" , DEFAULT_LCD_CONTRAST }, + {"lcd_power" , DEFAULT_LCD_POWER }, + {"lcd_inverse" , DEFAULT_LCD_INVERSE }, + {"lcd_show_volume" , DEFAULT_LCD_SHOW_VOLUME }, + {"lcd_autodimm" , DEFAULT_LCD_AUTODIMM }, + {"lcd_deepbrightness" , DEFAULT_VFD_STANDBYBRIGHTNESS } +#if HAVE_TRIPLEDRAGON + ,{ "lcd_epgmode" , 0 /*DEFAULT_LCD_EPGMODE*/ } +#endif +}; + +/************************************************************************************** +* CNeutrinoApp - loadSetup, load the application-settings * +**************************************************************************************/ +#define DEFAULT_X_START_SD 60 +#define DEFAULT_Y_START_SD 20 +#define DEFAULT_X_END_SD 1220 +#define DEFAULT_Y_END_SD 560 + +#define DEFAULT_X_START_HD 40 //5 +#define DEFAULT_Y_START_HD 25 //5 +#define DEFAULT_X_END_HD 1235 //1275 +#define DEFAULT_Y_END_HD 690 //715 + +std::string ttx_font_file = ""; + +int CNeutrinoApp::loadSetup(const char * fname) +{ + char cfg_key[81]; + int erg = 0; + + configfile.clear(); + //settings laden - und dabei Defaults setzen! + if(!configfile.loadConfig(fname)) { + //file existiert nicht + erg = 1; + } else { + /* try to detect bad / broken config file */ + if (!configfile.getInt32("screen_EndX_crt", 0) || + !configfile.getInt32("screen_EndY_crt", 0) || + !configfile.getInt32("screen_EndX_lcd", 0) || + !configfile.getInt32("screen_EndY_lcd", 0)) { + printf("[neutrino] config file %s is broken, using defaults\n", fname); + configfile.clear(); + } + } + std::ifstream checkParentallocked(NEUTRINO_PARENTALLOCKED_FILE); + if(checkParentallocked) { + parentallocked = true; + checkParentallocked.close(); + } + // video + g_settings.video_Mode = configfile.getInt32("video_Mode", VIDEO_STD_1080I50); // VIDEO_STD_720P50 + g_settings.analog_mode1 = configfile.getInt32("analog_mode1", (int)ANALOG_SD_RGB_SCART); // default RGB + g_settings.analog_mode2 = configfile.getInt32("analog_mode2", (int)ANALOG_SD_YPRPB_CINCH); // default YPBPR + g_settings.hdmi_cec_mode = configfile.getInt32("hdmi_cec_mode", 0); // default off + g_settings.hdmi_cec_view_on = configfile.getInt32("hdmi_cec_view_on", 0); // default off + g_settings.hdmi_cec_standby = configfile.getInt32("hdmi_cec_standby", 0); // default off + + g_settings.video_Format = configfile.getInt32("video_Format", DISPLAY_AR_16_9); + g_settings.video_43mode = configfile.getInt32("video_43mode", DISPLAY_AR_MODE_LETTERBOX); + g_settings.current_volume = configfile.getInt32("current_volume", 50); + g_settings.current_volume_step = configfile.getInt32("current_volume_step", 2); + g_settings.channel_mode = configfile.getInt32("channel_mode", LIST_MODE_PROV); + g_settings.channel_mode_radio = configfile.getInt32("channel_mode_radio", LIST_MODE_PROV); + + g_settings.fan_speed = configfile.getInt32( "fan_speed", 1); + if(g_settings.fan_speed < 1) g_settings.fan_speed = 1; + + g_settings.srs_enable = configfile.getInt32( "srs_enable", 0); + g_settings.srs_algo = configfile.getInt32( "srs_algo", 1); + g_settings.srs_ref_volume = configfile.getInt32( "srs_ref_volume", 40); + g_settings.srs_nmgr_enable = configfile.getInt32( "srs_nmgr_enable", 0); + g_settings.hdmi_dd = configfile.getInt32( "hdmi_dd", 0); + g_settings.spdif_dd = configfile.getInt32( "spdif_dd", 1); + g_settings.analog_out = configfile.getInt32( "analog_out", 1); + g_settings.avsync = configfile.getInt32( "avsync", 1); + g_settings.clockrec = configfile.getInt32( "clockrec", 1); + g_settings.video_dbdr = configfile.getInt32("video_dbdr", 0); + + for(int i = 0; i < VIDEOMENU_VIDEOMODE_OPTION_COUNT; i++) { + sprintf(cfg_key, "enabled_video_mode_%d", i); + g_settings.enabled_video_modes[i] = configfile.getInt32(cfg_key, 0); + } + g_settings.enabled_video_modes[3] = 1; // 720p 50Hz + g_settings.enabled_video_modes[4] = 1; // 1080i 50Hz + + g_settings.cpufreq = configfile.getInt32("cpufreq", 0); + g_settings.standby_cpufreq = configfile.getInt32("standby_cpufreq", 100); + g_settings.rounded_corners = configfile.getInt32("rounded_corners", 1); + g_settings.ci_standby_reset = configfile.getInt32("ci_standby_reset", 0); + g_settings.ci_clock = configfile.getInt32("ci_clock", 7); + +#ifndef CPU_FREQ + g_settings.cpufreq = 0; + g_settings.standby_cpufreq = 50; +#endif + + g_settings.make_hd_list = configfile.getInt32("make_hd_list", 1); + g_settings.make_new_list = configfile.getInt32("make_new_list", 1); + g_settings.make_removed_list = configfile.getInt32("make_removed_list", 1); + g_settings.keep_channel_numbers = configfile.getInt32("keep_channel_numbers", 0); + + //misc + g_settings.power_standby = configfile.getInt32( "power_standby", 0); + g_settings.rotor_swap = configfile.getInt32( "rotor_swap", 0); + + //led + g_settings.led_tv_mode = configfile.getInt32( "led_tv_mode", 1); + g_settings.led_standby_mode = configfile.getInt32( "led_standby_mode", 1); + g_settings.led_deep_mode = configfile.getInt32( "led_deep_mode", 1); + g_settings.led_rec_mode = configfile.getInt32( "led_rec_mode", 1); + g_settings.led_blink = configfile.getInt32( "led_blink", 1); + + g_settings.hdd_fs = configfile.getInt32( "hdd_fs", 0); + g_settings.hdd_sleep = configfile.getInt32( "hdd_sleep", 120); + g_settings.hdd_noise = configfile.getInt32( "hdd_noise", 254); + + g_settings.shutdown_real = configfile.getBool("shutdown_real" , false ); + g_settings.shutdown_real_rcdelay = configfile.getBool("shutdown_real_rcdelay", false ); + strcpy(g_settings.shutdown_count, configfile.getString("shutdown_count","0").c_str()); + + strcpy(g_settings.shutdown_min, "000"); + if(cs_get_revision() > 7) + strcpy(g_settings.shutdown_min, configfile.getString("shutdown_min","180").c_str()); + + g_settings.infobar_sat_display = configfile.getBool("infobar_sat_display" , true ); + g_settings.infobar_show_channeldesc = configfile.getBool("infobar_show_channeldesc" , false ); + g_settings.infobar_subchan_disp_pos = configfile.getInt32("infobar_subchan_disp_pos" , 0 ); + g_settings.progressbar_color = configfile.getBool("progressbar_color", true ); + g_settings.infobar_show = configfile.getInt32("infobar_show", 1); + g_settings.infobar_show_channellogo = configfile.getInt32("infobar_show_channellogo" , 3 ); + g_settings.casystem_display = configfile.getInt32("casystem_display", 2 );//mini ca mode default + g_settings.scrambled_message = configfile.getBool("scrambled_message", true ); + g_settings.volume_pos = configfile.getInt32("volume_pos", 0 ); + g_settings.volume_digits = configfile.getBool("volume_digits", true); + g_settings.menu_pos = configfile.getInt32("menu_pos", CMenuWidget::MENU_POS_CENTER); + g_settings.show_menu_hints = configfile.getBool("show_menu_hints", true); + g_settings.infobar_show_sysfs_hdd = configfile.getBool("infobar_show_sysfs_hdd" , true ); + g_settings.show_mute_icon = configfile.getInt32("show_mute_icon" ,0); + g_settings.infobar_show_res = configfile.getInt32("infobar_show_res", 0 ); + g_settings.infobar_show_dd_available = configfile.getInt32("infobar_show_dd_available", 1 ); + g_settings.infobar_show_tuner = configfile.getInt32("infobar_show_tuner", 1 ); + g_settings.radiotext_enable = configfile.getBool("radiotext_enable" , false); + //audio + g_settings.audio_AnalogMode = configfile.getInt32( "audio_AnalogMode", 0 ); + g_settings.audio_DolbyDigital = configfile.getBool("audio_DolbyDigital" , false); + + g_settings.auto_lang = configfile.getInt32( "auto_lang", 0 ); + g_settings.auto_subs = configfile.getInt32( "auto_subs", 0 ); + + for(int i = 0; i < 3; i++) { + sprintf(cfg_key, "pref_lang_%d", i); + strncpy(g_settings.pref_lang[i], configfile.getString(cfg_key, "none").c_str(), 30); + sprintf(cfg_key, "pref_subs_%d", i); + strncpy(g_settings.pref_subs[i], configfile.getString(cfg_key, "none").c_str(), 30); + } + g_settings.zap_cycle = configfile.getInt32( "zap_cycle", 0 ); + strcpy( g_settings.audio_PCMOffset, configfile.getString( "audio_PCMOffset", "0" ).c_str() ); + + //vcr + g_settings.vcr_AutoSwitch = configfile.getBool("vcr_AutoSwitch" , true ); + + //language + strcpy(g_settings.language, configfile.getString("language", "").c_str()); + strcpy(g_settings.timezone, configfile.getString("timezone", "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Vienna").c_str()); + //epg dir + g_settings.epg_cache = configfile.getString("epg_cache_time", "14"); + g_settings.epg_extendedcache = configfile.getString("epg_extendedcache_time", "360"); + g_settings.epg_old_events = configfile.getString("epg_old_events", "1"); + g_settings.epg_max_events = configfile.getString("epg_max_events", "30000"); + g_settings.epg_dir = configfile.getString("epg_dir", "/media/sda1/epg"); + // NTP-Server for sectionsd + g_settings.network_ntpserver = configfile.getString("network_ntpserver", "time.fu-berlin.de"); + g_settings.network_ntprefresh = configfile.getString("network_ntprefresh", "30" ); + g_settings.network_ntpenable = configfile.getBool("network_ntpenable", false); + + snprintf(g_settings.ifname, sizeof(g_settings.ifname), "%s", configfile.getString("ifname", "eth0").c_str());; + + g_settings.epg_save = configfile.getBool("epg_save", false); + g_settings.epg_save_standby = configfile.getBool("epg_save_standby", true); + //widget settings + g_settings.widget_fade = false; + g_settings.widget_fade = configfile.getBool("widget_fade" , false ); + + //colors (neutrino defaultcolors) + g_settings.menu_Head_alpha = configfile.getInt32( "menu_Head_alpha", 0x00 ); + g_settings.menu_Head_red = configfile.getInt32( "menu_Head_red", 0x00 ); + g_settings.menu_Head_green = configfile.getInt32( "menu_Head_green", 0x0A ); + g_settings.menu_Head_blue = configfile.getInt32( "menu_Head_blue", 0x19 ); + + g_settings.menu_Head_Text_alpha = configfile.getInt32( "menu_Head_Text_alpha", 0x00 ); + g_settings.menu_Head_Text_red = configfile.getInt32( "menu_Head_Text_red", 0x5f ); + g_settings.menu_Head_Text_green = configfile.getInt32( "menu_Head_Text_green", 0x46 ); + g_settings.menu_Head_Text_blue = configfile.getInt32( "menu_Head_Text_blue", 0x00 ); + + g_settings.menu_Content_alpha = configfile.getInt32( "menu_Content_alpha", 0x14 ); + g_settings.menu_Content_red = configfile.getInt32( "menu_Content_red", 0x00 ); + g_settings.menu_Content_green = configfile.getInt32( "menu_Content_green", 0x0f ); + g_settings.menu_Content_blue = configfile.getInt32( "menu_Content_blue", 0x23 ); + g_settings.menu_Content_Text_alpha = configfile.getInt32( "menu_Content_Text_alpha", 0x00 ); + g_settings.menu_Content_Text_red = configfile.getInt32( "menu_Content_Text_red", 0x64 ); + g_settings.menu_Content_Text_green = configfile.getInt32( "menu_Content_Text_green", 0x64 ); + g_settings.menu_Content_Text_blue = configfile.getInt32( "menu_Content_Text_blue", 0x64 ); + + g_settings.menu_Content_Selected_alpha = configfile.getInt32( "menu_Content_Selected_alpha", 0x14 ); + g_settings.menu_Content_Selected_red = configfile.getInt32( "menu_Content_Selected_red", 0x19 ); + g_settings.menu_Content_Selected_green = configfile.getInt32( "menu_Content_Selected_green", 0x37 ); + g_settings.menu_Content_Selected_blue = configfile.getInt32( "menu_Content_Selected_blue", 0x64 ); + + g_settings.menu_Content_Selected_Text_alpha = configfile.getInt32( "menu_Content_Selected_Text_alpha", 0x00 ); + g_settings.menu_Content_Selected_Text_red = configfile.getInt32( "menu_Content_Selected_Text_red", 0x00 ); + g_settings.menu_Content_Selected_Text_green = configfile.getInt32( "menu_Content_Selected_Text_green", 0x00 ); + g_settings.menu_Content_Selected_Text_blue = configfile.getInt32( "menu_Content_Selected_Text_blue", 0x00 ); + + g_settings.menu_Content_inactive_alpha = configfile.getInt32( "menu_Content_inactive_alpha", 0x14 ); + g_settings.menu_Content_inactive_red = configfile.getInt32( "menu_Content_inactive_red", 0x00 ); + g_settings.menu_Content_inactive_green = configfile.getInt32( "menu_Content_inactive_green", 0x0f ); + g_settings.menu_Content_inactive_blue = configfile.getInt32( "menu_Content_inactive_blue", 0x23 ); + + g_settings.menu_Content_inactive_Text_alpha = configfile.getInt32( "menu_Content_inactive_Text_alpha", 0x00 ); + g_settings.menu_Content_inactive_Text_red = configfile.getInt32( "menu_Content_inactive_Text_red", 55 ); + g_settings.menu_Content_inactive_Text_green = configfile.getInt32( "menu_Content_inactive_Text_green", 70 ); + g_settings.menu_Content_inactive_Text_blue = configfile.getInt32( "menu_Content_inactive_Text_blue", 85 ); + + g_settings.infobar_alpha = configfile.getInt32( "infobar_alpha", 0x14 ); + g_settings.infobar_red = configfile.getInt32( "infobar_red", 0x00 ); + g_settings.infobar_green = configfile.getInt32( "infobar_green", 0x0e ); + g_settings.infobar_blue = configfile.getInt32( "infobar_blue", 0x23 ); + + g_settings.infobar_Text_alpha = configfile.getInt32( "infobar_Text_alpha", 0x00 ); + g_settings.infobar_Text_red = configfile.getInt32( "infobar_Text_red", 0x64 ); + g_settings.infobar_Text_green = configfile.getInt32( "infobar_Text_green", 0x64 ); + g_settings.infobar_Text_blue = configfile.getInt32( "infobar_Text_blue", 0x64 ); + + //personalize + strcpy( g_settings.personalize_pincode, configfile.getString( "personalize_pincode", "0000" ).c_str() ); + for (int i = 0; i < SNeutrinoSettings::P_SETTINGS_MAX; i++)//settings.h, settings.cpp + g_settings.personalize[i] = configfile.getInt32( personalize_settings[i].personalize_settings_name, personalize_settings[i].personalize_default_val ); + + g_settings.colored_events_channellist = configfile.getInt32( "colored_events_channellist" , 0 ); + g_settings.colored_events_infobar = configfile.getInt32( "colored_events_infobar" , 0 ); + g_settings.colored_events_alpha = configfile.getInt32( "colored_events_alpha", 0x00 ); + g_settings.colored_events_red = configfile.getInt32( "colored_events_red", 95 ); + g_settings.colored_events_green = configfile.getInt32( "colored_events_green", 70 ); + g_settings.colored_events_blue = configfile.getInt32( "colored_events_blue", 0 ); + + g_settings.contrast_fonts = configfile.getInt32("contrast_fonts", 0); + + //network + for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { + sprintf(cfg_key, "network_nfs_ip_%d", i); + g_settings.network_nfs_ip[i] = configfile.getString(cfg_key, ""); + sprintf(cfg_key, "network_nfs_dir_%d", i); + strcpy( g_settings.network_nfs_dir[i], configfile.getString( cfg_key, "" ).c_str() ); + sprintf(cfg_key, "network_nfs_local_dir_%d", i); + strcpy( g_settings.network_nfs_local_dir[i], configfile.getString( cfg_key, "" ).c_str() ); + sprintf(cfg_key, "network_nfs_automount_%d", i); + g_settings.network_nfs_automount[i] = configfile.getInt32( cfg_key, 0); + sprintf(cfg_key, "network_nfs_type_%d", i); + g_settings.network_nfs_type[i] = configfile.getInt32( cfg_key, 0); + sprintf(cfg_key,"network_nfs_username_%d", i); + strcpy( g_settings.network_nfs_username[i], configfile.getString( cfg_key, "" ).c_str() ); + sprintf(cfg_key, "network_nfs_password_%d", i); + strcpy( g_settings.network_nfs_password[i], configfile.getString( cfg_key, "" ).c_str() ); + sprintf(cfg_key, "network_nfs_mount_options1_%d", i); + strcpy( g_settings.network_nfs_mount_options1[i], configfile.getString( cfg_key, "ro,soft,udp" ).c_str() ); + sprintf(cfg_key, "network_nfs_mount_options2_%d", i); + strcpy( g_settings.network_nfs_mount_options2[i], configfile.getString( cfg_key, "nolock,rsize=8192,wsize=8192" ).c_str() ); + sprintf(cfg_key, "network_nfs_mac_%d", i); + strcpy( g_settings.network_nfs_mac[i], configfile.getString( cfg_key, "11:22:33:44:55:66").c_str() ); + } + strcpy( g_settings.network_nfs_audioplayerdir, configfile.getString( "network_nfs_audioplayerdir", "/media/sda1/music" ).c_str() ); + strcpy( g_settings.network_nfs_picturedir, configfile.getString( "network_nfs_picturedir", "/media/sda1/pictures" ).c_str() ); + strcpy( g_settings.network_nfs_moviedir, configfile.getString( "network_nfs_moviedir", "/media/sda1/movies" ).c_str() ); + strcpy( g_settings.network_nfs_recordingdir, configfile.getString( "network_nfs_recordingdir", "/media/sda1/movies" ).c_str() ); + strcpy( g_settings.timeshiftdir, configfile.getString( "timeshiftdir", "" ).c_str() ); + + g_settings.temp_timeshift = configfile.getInt32( "temp_timeshift", 0 ); + g_settings.auto_timeshift = configfile.getInt32( "auto_timeshift", 0 ); + g_settings.auto_delete = configfile.getInt32( "auto_delete", 1 ); + + char timeshiftDir[255]; + if(strlen(g_settings.timeshiftdir) == 0) { + sprintf(timeshiftDir, "%s/.timeshift", g_settings.network_nfs_recordingdir); + safe_mkdir(timeshiftDir); + } else { + if(strcmp(g_settings.timeshiftdir, g_settings.network_nfs_recordingdir)) + strncpy(timeshiftDir, g_settings.timeshiftdir, sizeof(timeshiftDir)); + else + sprintf(timeshiftDir, "%s/.timeshift", g_settings.network_nfs_recordingdir); + } + printf("***************************** rec dir %s timeshift dir %s\n", g_settings.network_nfs_recordingdir, timeshiftDir); + CRecordManager::getInstance()->SetTimeshiftDirectory(timeshiftDir); + + if(g_settings.auto_delete) { + if(strcmp(g_settings.timeshiftdir, g_settings.network_nfs_recordingdir)) { + DIR *d = opendir(timeshiftDir); + if(d){ + while (struct dirent *e = readdir(d)) + { + std::string filename = e->d_name; + if ((filename.find("_temp.ts") == filename.size() - 8) || (filename.find("_temp.xml") == filename.size() - 9)) + { + std::string timeshiftDir_filename= timeshiftDir; + timeshiftDir_filename+= "/" + filename; + remove(timeshiftDir_filename.c_str()); + } + } + closedir(d); + } + } + } + g_settings.record_hours = configfile.getInt32( "record_hours", 4 ); + g_settings.filesystem_is_utf8 = configfile.getBool("filesystem_is_utf8" , true ); + + //recording (server + vcr) + g_settings.recording_type = configfile.getInt32("recording_type", RECORDING_FILE); + g_settings.recording_stopsectionsd = configfile.getBool("recording_stopsectionsd" , false ); + g_settings.recording_audio_pids_default = configfile.getInt32("recording_audio_pids_default", TIMERD_APIDS_STD | TIMERD_APIDS_AC3); + g_settings.recording_zap_on_announce = configfile.getBool("recording_zap_on_announce" , false); + g_settings.shutdown_timer_record_type = configfile.getBool("shutdown_timer_record_type" , false); + + g_settings.recording_stream_vtxt_pid = configfile.getBool("recordingmenu.stream_vtxt_pid" , false); + g_settings.recording_stream_pmt_pid = configfile.getBool("recordingmenu.stream_pmt_pid" , false); + g_settings.recording_choose_direct_rec_dir = configfile.getInt32( "recording_choose_direct_rec_dir", 0 ); + g_settings.recording_epg_for_filename = configfile.getBool("recording_epg_for_filename" , true); + g_settings.recording_epg_for_end = configfile.getBool("recording_epg_for_end" , false); + g_settings.recording_save_in_channeldir = configfile.getBool("recording_save_in_channeldir" , false); + g_settings.recording_slow_warning = configfile.getBool("recording_slow_warning" , true); + + // default plugin for movieplayer + g_settings.movieplayer_plugin = configfile.getString( "movieplayer_plugin", "Teletext" ); + g_settings.onekey_plugin = configfile.getString( "onekey_plugin", "noplugin" ); + g_settings.plugin_hdd_dir = configfile.getString( "plugin_hdd_dir", "/hdd/tuxbox/plugins" ); + g_settings.logo_hdd_dir = configfile.getString( "logo_hdd_dir", "/var/share/icons/logo" ); + + loadKeys(); + + g_settings.timeshift_pause = configfile.getInt32( "timeshift_pause", 1 ); + + g_settings.screenshot_count = configfile.getInt32( "screenshot_count", 1); + g_settings.screenshot_format = configfile.getInt32( "screenshot_format", 1); + g_settings.screenshot_cover = configfile.getInt32( "screenshot_cover", 0); + g_settings.screenshot_mode = configfile.getInt32( "screenshot_mode", 0); + g_settings.screenshot_video = configfile.getInt32( "screenshot_video", 1); + g_settings.screenshot_scale = configfile.getInt32( "screenshot_scale", 0); + + g_settings.screenshot_dir = configfile.getString( "screenshot_dir", "/media/sda1/movies" ); + g_settings.cacheTXT = configfile.getInt32( "cacheTXT", 0); + g_settings.minimode = configfile.getInt32( "minimode", 0); + g_settings.mode_clock = configfile.getInt32( "mode_clock", 0); + g_settings.zapto_pre_time = configfile.getInt32( "zapto_pre_time", 0); + g_settings.spectrum = configfile.getBool("spectrum" , false); + g_settings.channellist_epgtext_align_right = configfile.getBool("channellist_epgtext_align_right" , false); + g_settings.channellist_extended = configfile.getBool("channellist_extended" , true); + g_settings.channellist_foot = configfile.getInt32("channellist_foot" , 1);//default next Event + g_settings.channellist_new_zap_mode = configfile.getInt32("channellist_new_zap_mode", 1); + g_settings.channellist_sort_mode = configfile.getInt32("channellist_sort_mode", 0);//sort mode: alpha, freq, sat + + //screen configuration + g_settings.screen_xres = configfile.getInt32("screen_xres", 100); + g_settings.screen_yres = configfile.getInt32("screen_yres", 100); + g_settings.screen_StartX_crt = configfile.getInt32( "screen_StartX_crt", DEFAULT_X_START_SD); + g_settings.screen_StartY_crt = configfile.getInt32( "screen_StartY_crt", DEFAULT_Y_START_SD ); + g_settings.screen_EndX_crt = configfile.getInt32( "screen_EndX_crt", DEFAULT_X_END_SD); + g_settings.screen_EndY_crt = configfile.getInt32( "screen_EndY_crt", DEFAULT_Y_END_SD); + g_settings.screen_StartX_lcd = configfile.getInt32( "screen_StartX_lcd", DEFAULT_X_START_HD); + g_settings.screen_StartY_lcd = configfile.getInt32( "screen_StartY_lcd", DEFAULT_Y_START_HD ); + g_settings.screen_EndX_lcd = configfile.getInt32( "screen_EndX_lcd", DEFAULT_X_END_HD); + g_settings.screen_EndY_lcd = configfile.getInt32( "screen_EndY_lcd", DEFAULT_Y_END_HD); + g_settings.screen_preset = configfile.getInt32( "screen_preset", 1); + + g_settings.screen_StartX = g_settings.screen_preset ? g_settings.screen_StartX_lcd : g_settings.screen_StartX_crt; + g_settings.screen_StartY = g_settings.screen_preset ? g_settings.screen_StartY_lcd : g_settings.screen_StartY_crt; + g_settings.screen_EndX = g_settings.screen_preset ? g_settings.screen_EndX_lcd : g_settings.screen_EndX_crt; + g_settings.screen_EndY = g_settings.screen_preset ? g_settings.screen_EndY_lcd : g_settings.screen_EndY_crt; + + g_settings.screen_width = configfile.getInt32("screen_width", 0); + g_settings.screen_height = configfile.getInt32("screen_height", 0); + + g_settings.bigFonts = configfile.getInt32("bigFonts", 0); + g_settings.big_windows = configfile.getInt32("big_windows", 0); + + g_settings.remote_control_hardware = configfile.getInt32( "remote_control_hardware", CRCInput::RC_HW_COOLSTREAM); + g_settings.audiochannel_up_down_enable = configfile.getBool("audiochannel_up_down_enable", false); + + //Software-update + g_settings.softupdate_mode = configfile.getInt32( "softupdate_mode", 1 ); + + strcpy(g_settings.softupdate_url_file, configfile.getString("softupdate_url_file", "/var/etc/update.urls").c_str()); + strcpy(g_settings.softupdate_proxyserver, configfile.getString("softupdate_proxyserver", "" ).c_str()); + strcpy(g_settings.softupdate_proxyusername, configfile.getString("softupdate_proxyusername", "" ).c_str()); + strcpy(g_settings.softupdate_proxypassword, configfile.getString("softupdate_proxypassword", "" ).c_str()); + // + strcpy( g_settings.font_file, configfile.getString( "font_file", FONTDIR"/neutrino.ttf" ).c_str() ); + strcpy( g_settings.ttx_font_file, configfile.getString( "ttx_font_file", FONTDIR"/DejaVuLGCSansMono-Bold.ttf" ).c_str() ); + ttx_font_file = g_settings.ttx_font_file; + strcpy( g_settings.update_dir, configfile.getString( "update_dir", "/tmp" ).c_str() ); + + // parentallock + if (!parentallocked) { + g_settings.parentallock_prompt = configfile.getInt32( "parentallock_prompt", 0 ); + g_settings.parentallock_lockage = configfile.getInt32( "parentallock_lockage", 12 ); + } else { + g_settings.parentallock_prompt = 3; + g_settings.parentallock_lockage = 18; + } + strcpy( g_settings.parentallock_pincode, configfile.getString( "parentallock_pincode", "0000" ).c_str() ); + + for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) + g_settings.timing[i] = configfile.getInt32(locale_real_names[timing_setting[i].name], timing_setting[i].default_timing); + + for (int i = 0; i < SNeutrinoSettings::LCD_SETTING_COUNT; i++) + g_settings.lcd_setting[i] = configfile.getInt32(lcd_setting[i].name, lcd_setting[i].default_value); + strcpy(g_settings.lcd_setting_dim_time, configfile.getString("lcd_dim_time","0").c_str()); + g_settings.lcd_setting_dim_brightness = configfile.getInt32("lcd_dim_brightness", 0); + g_settings.lcd_info_line = configfile.getInt32("lcd_info_line", 0);//channel name or clock + + //Picture-Viewer + strcpy( g_settings.picviewer_slide_time, configfile.getString( "picviewer_slide_time", "10" ).c_str() ); + g_settings.picviewer_scaling = configfile.getInt32("picviewer_scaling", 1 /*(int)CPictureViewer::SIMPLE*/); + g_settings.picviewer_decode_server_ip = configfile.getString("picviewer_decode_server_ip", ""); + + //Audio-Player + g_settings.audioplayer_display = configfile.getInt32("audioplayer_display",(int)CAudioPlayerGui::ARTIST_TITLE); + g_settings.audioplayer_follow = configfile.getInt32("audioplayer_follow",0); + strcpy( g_settings.audioplayer_screensaver, configfile.getString( "audioplayer_screensaver", "1" ).c_str() ); + g_settings.audioplayer_highprio = configfile.getInt32("audioplayer_highprio",0); + g_settings.audioplayer_select_title_by_name = configfile.getInt32("audioplayer_select_title_by_name",0); + g_settings.audioplayer_repeat_on = configfile.getInt32("audioplayer_repeat_on",0); + g_settings.audioplayer_show_playlist = configfile.getInt32("audioplayer_show_playlist",1); + g_settings.audioplayer_enable_sc_metadata = configfile.getInt32("audioplayer_enable_sc_metadata",1); + g_settings.shoutcast_dev_id = configfile.getString("shoutcast_dev_id","XXXXXXXXXXXXXXXX"); + + //Filebrowser + g_settings.filebrowser_showrights = configfile.getInt32("filebrowser_showrights", 1); + g_settings.filebrowser_sortmethod = configfile.getInt32("filebrowser_sortmethod", 0); + if ((g_settings.filebrowser_sortmethod < 0) || (g_settings.filebrowser_sortmethod >= FILEBROWSER_NUMBER_OF_SORT_VARIANTS)) + g_settings.filebrowser_sortmethod = 0; + g_settings.filebrowser_denydirectoryleave = configfile.getBool("filebrowser_denydirectoryleave", false); + //zapit setup + g_settings.StartChannelTV = configfile.getString("startchanneltv",""); + g_settings.StartChannelRadio = configfile.getString("startchannelradio",""); + g_settings.startchanneltv_id = configfile.getInt64("startchanneltv_id", 0); + g_settings.startchannelradio_id = configfile.getInt64("startchannelradio_id", 0); + g_settings.uselastchannel = configfile.getInt32("uselastchannel" , 1); + + + // USERMENU -> in system/settings.h + //------------------------------------------- + // this is as the current neutrino usermen + const char* usermenu_default[SNeutrinoSettings::BUTTON_MAX]={ + "2,3,4,13", // RED + "6", // GREEN + "7", // YELLOW + "12,11,20,21,19,14,15" // BLUE + }; + char txt1[81]; + std::string txt2; + const char* txt2ptr; + for(int button = 0; button < SNeutrinoSettings::BUTTON_MAX; button++) + { + snprintf(txt1,80,"usermenu_tv_%s_text",usermenu_button_def[button]); + txt1[80] = 0; // terminate for sure + g_settings.usermenu_text[button] = configfile.getString(txt1, ""); + + snprintf(txt1,80,"usermenu_tv_%s",usermenu_button_def[button]); + txt2 = configfile.getString(txt1,usermenu_default[button]); + txt2ptr = txt2.c_str(); + for( int pos = 0; pos < SNeutrinoSettings::ITEM_MAX; pos++) + { + // find next comma or end of string - if it's not the first round + if(pos != 0) + { + while(*txt2ptr != 0 && *txt2ptr != ',') + txt2ptr++; + if(*txt2ptr != 0) + txt2ptr++; + } + if(*txt2ptr != 0) + { + g_settings.usermenu[button][pos] = atoi(txt2ptr); // there is still a string + if(g_settings.usermenu[button][pos] >= SNeutrinoSettings::ITEM_MAX) + g_settings.usermenu[button][pos] = 0; + } + else + g_settings.usermenu[button][pos] = 0; // string empty, fill up with 0 + + } + } + + if(configfile.getUnknownKeyQueryedFlag() && (erg==0)) { + erg = 2; + } + + /* in case FB resolution changed */ + if((g_settings.screen_width && g_settings.screen_width != (int) frameBuffer->getScreenWidth(true)) + || (g_settings.screen_height && g_settings.screen_height != (int) frameBuffer->getScreenHeight(true))) { + g_settings.screen_StartX = g_settings.screen_preset ? DEFAULT_X_START_HD : DEFAULT_X_START_SD; + g_settings.screen_StartY = g_settings.screen_preset ? DEFAULT_Y_START_HD : DEFAULT_Y_START_SD; + g_settings.screen_EndX = g_settings.screen_preset ? DEFAULT_X_END_HD : DEFAULT_X_END_SD; + g_settings.screen_EndY = g_settings.screen_preset ? DEFAULT_Y_END_HD : DEFAULT_Y_END_SD; + + g_settings.screen_width = frameBuffer->getScreenWidth(true); + g_settings.screen_height = frameBuffer->getScreenHeight(true); + } + if(erg) + configfile.setModifiedFlag(true); + return erg; +} + +/************************************************************************************** +* CNeutrinoApp - saveSetup, save the application-settings * +**************************************************************************************/ +void CNeutrinoApp::saveSetup(const char * fname) +{ + char cfg_key[81]; + //scansettings + if(!scansettings.saveSettings(NEUTRINO_SCAN_SETTINGS_FILE)) { + dprintf(DEBUG_NORMAL, "error while saving scan-settings!\n"); + } + + //video + configfile.setInt32( "video_Mode", g_settings.video_Mode ); + configfile.setInt32( "analog_mode1", g_settings.analog_mode1 ); + configfile.setInt32( "analog_mode2", g_settings.analog_mode2 ); + configfile.setInt32( "video_Format", g_settings.video_Format ); + configfile.setInt32( "video_43mode", g_settings.video_43mode ); + configfile.setInt32( "hdmi_cec_mode", g_settings.hdmi_cec_mode ); + configfile.setInt32( "hdmi_cec_view_on", g_settings.hdmi_cec_view_on ); + configfile.setInt32( "hdmi_cec_standby", g_settings.hdmi_cec_standby ); + + configfile.setInt32( "current_volume", g_settings.current_volume ); + configfile.setInt32( "current_volume_step", g_settings.current_volume_step ); + configfile.setInt32( "channel_mode", g_settings.channel_mode ); + configfile.setInt32( "channel_mode_radio", g_settings.channel_mode_radio ); + + configfile.setInt32( "fan_speed", g_settings.fan_speed); + + configfile.setInt32( "srs_enable", g_settings.srs_enable); + configfile.setInt32( "srs_algo", g_settings.srs_algo); + configfile.setInt32( "srs_ref_volume", g_settings.srs_ref_volume); + configfile.setInt32( "srs_nmgr_enable", g_settings.srs_nmgr_enable); + configfile.setInt32( "hdmi_dd", g_settings.hdmi_dd); + configfile.setInt32( "analog_out", g_settings.analog_out); + configfile.setInt32( "spdif_dd", g_settings.spdif_dd); + configfile.setInt32( "avsync", g_settings.avsync); + configfile.setInt32( "clockrec", g_settings.clockrec); + configfile.setInt32( "video_dbdr", g_settings.video_dbdr); + for(int i = 0; i < VIDEOMENU_VIDEOMODE_OPTION_COUNT; i++) { + sprintf(cfg_key, "enabled_video_mode_%d", i); + configfile.setInt32(cfg_key, g_settings.enabled_video_modes[i]); + } + configfile.setInt32( "cpufreq", g_settings.cpufreq); + configfile.setInt32( "standby_cpufreq", g_settings.standby_cpufreq); + configfile.setInt32("rounded_corners", g_settings.rounded_corners); + configfile.setInt32("ci_standby_reset", g_settings.ci_standby_reset); + configfile.setInt32("ci_clock", g_settings.ci_clock); + + configfile.setInt32( "make_hd_list", g_settings.make_hd_list); + configfile.setInt32( "make_new_list", g_settings.make_new_list); + configfile.setInt32( "make_removed_list", g_settings.make_removed_list); + configfile.setInt32( "keep_channel_numbers", g_settings.keep_channel_numbers); + //led + configfile.setInt32( "led_tv_mode", g_settings.led_tv_mode); + configfile.setInt32( "led_standby_mode", g_settings.led_standby_mode); + configfile.setInt32( "led_deep_mode", g_settings.led_deep_mode); + configfile.setInt32( "led_rec_mode", g_settings.led_rec_mode); + configfile.setInt32( "led_blink", g_settings.led_blink); + + //misc + configfile.setInt32( "power_standby", g_settings.power_standby); + configfile.setInt32( "rotor_swap", g_settings.rotor_swap); + configfile.setInt32( "zap_cycle", g_settings.zap_cycle ); + configfile.setInt32( "hdd_fs", g_settings.hdd_fs); + configfile.setInt32( "hdd_sleep", g_settings.hdd_sleep); + configfile.setInt32( "hdd_noise", g_settings.hdd_noise); + configfile.setBool("shutdown_real" , g_settings.shutdown_real ); + configfile.setBool("shutdown_real_rcdelay", g_settings.shutdown_real_rcdelay); + configfile.setString("shutdown_count" , g_settings.shutdown_count); + configfile.setString("shutdown_min" , g_settings.shutdown_min ); + configfile.setBool("infobar_sat_display" , g_settings.infobar_sat_display ); + configfile.setBool("infobar_show_channeldesc" , g_settings.infobar_show_channeldesc ); + configfile.setInt32("infobar_subchan_disp_pos" , g_settings.infobar_subchan_disp_pos ); + configfile.setBool("progressbar_color" , g_settings.progressbar_color ); + configfile.setInt32("infobar_show", g_settings.infobar_show); + configfile.setInt32("infobar_show_channellogo" , g_settings.infobar_show_channellogo ); + configfile.setInt32("casystem_display" , g_settings.casystem_display ); + configfile.setBool("scrambled_message" , g_settings.scrambled_message ); + configfile.setInt32("volume_pos" , g_settings.volume_pos ); + configfile.setBool("volume_digits", g_settings.volume_digits); + configfile.setInt32("menu_pos" , g_settings.menu_pos); + configfile.setBool("show_menu_hints" , g_settings.show_menu_hints); + configfile.setInt32("infobar_show_sysfs_hdd" , g_settings.infobar_show_sysfs_hdd ); + configfile.setInt32("show_mute_icon" , g_settings.show_mute_icon); + configfile.setInt32("infobar_show_res" , g_settings.infobar_show_res ); + configfile.setInt32("infobar_show_dd_available" , g_settings.infobar_show_dd_available ); + configfile.setInt32("infobar_show_tuner" , g_settings.infobar_show_tuner ); + configfile.setBool("radiotext_enable" , g_settings.radiotext_enable); + //audio + configfile.setInt32( "audio_AnalogMode", g_settings.audio_AnalogMode ); + configfile.setBool("audio_DolbyDigital" , g_settings.audio_DolbyDigital ); + configfile.setInt32( "auto_lang", g_settings.auto_lang ); + configfile.setInt32( "auto_subs", g_settings.auto_subs ); + for(int i = 0; i < 3; i++) { + sprintf(cfg_key, "pref_lang_%d", i); + configfile.setString(cfg_key, g_settings.pref_lang[i]); + sprintf(cfg_key, "pref_subs_%d", i); + configfile.setString(cfg_key, g_settings.pref_subs[i]); + } + configfile.setString( "audio_PCMOffset", g_settings.audio_PCMOffset ); + + //vcr + configfile.setBool("vcr_AutoSwitch" , g_settings.vcr_AutoSwitch ); + + //language + configfile.setString("language", g_settings.language); + configfile.setString("timezone", g_settings.timezone); + // epg + configfile.setBool("epg_save", g_settings.epg_save); + configfile.setBool("epg_save_standby", g_settings.epg_save_standby); + configfile.setString("epg_cache_time" ,g_settings.epg_cache ); + configfile.setString("epg_extendedcache_time" ,g_settings.epg_extendedcache); + configfile.setString("epg_old_events" ,g_settings.epg_old_events ); + configfile.setString("epg_max_events" ,g_settings.epg_max_events ); + configfile.setString("epg_dir" ,g_settings.epg_dir); + + // NTP-Server for sectionsd + configfile.setString( "network_ntpserver", g_settings.network_ntpserver); + configfile.setString( "network_ntprefresh", g_settings.network_ntprefresh); + configfile.setBool( "network_ntpenable", g_settings.network_ntpenable); + + configfile.setString("ifname", g_settings.ifname); + + //widget settings + configfile.setBool("widget_fade" , g_settings.widget_fade ); + + //colors + configfile.setInt32( "menu_Head_alpha", g_settings.menu_Head_alpha ); + configfile.setInt32( "menu_Head_red", g_settings.menu_Head_red ); + configfile.setInt32( "menu_Head_green", g_settings.menu_Head_green ); + configfile.setInt32( "menu_Head_blue", g_settings.menu_Head_blue ); + + configfile.setInt32( "menu_Head_Text_alpha", g_settings.menu_Head_Text_alpha ); + configfile.setInt32( "menu_Head_Text_red", g_settings.menu_Head_Text_red ); + configfile.setInt32( "menu_Head_Text_green", g_settings.menu_Head_Text_green ); + configfile.setInt32( "menu_Head_Text_blue", g_settings.menu_Head_Text_blue ); + + configfile.setInt32( "menu_Content_alpha", g_settings.menu_Content_alpha ); + configfile.setInt32( "menu_Content_red", g_settings.menu_Content_red ); + configfile.setInt32( "menu_Content_green", g_settings.menu_Content_green ); + configfile.setInt32( "menu_Content_blue", g_settings.menu_Content_blue ); + + configfile.setInt32( "menu_Content_Text_alpha", g_settings.menu_Content_Text_alpha ); + configfile.setInt32( "menu_Content_Text_red", g_settings.menu_Content_Text_red ); + configfile.setInt32( "menu_Content_Text_green", g_settings.menu_Content_Text_green ); + configfile.setInt32( "menu_Content_Text_blue", g_settings.menu_Content_Text_blue ); + + configfile.setInt32( "menu_Content_Selected_alpha", g_settings.menu_Content_Selected_alpha ); + configfile.setInt32( "menu_Content_Selected_red", g_settings.menu_Content_Selected_red ); + configfile.setInt32( "menu_Content_Selected_green", g_settings.menu_Content_Selected_green ); + configfile.setInt32( "menu_Content_Selected_blue", g_settings.menu_Content_Selected_blue ); + + configfile.setInt32( "menu_Content_Selected_Text_alpha", g_settings.menu_Content_Selected_Text_alpha ); + configfile.setInt32( "menu_Content_Selected_Text_red", g_settings.menu_Content_Selected_Text_red ); + configfile.setInt32( "menu_Content_Selected_Text_green", g_settings.menu_Content_Selected_Text_green ); + configfile.setInt32( "menu_Content_Selected_Text_blue", g_settings.menu_Content_Selected_Text_blue ); + + configfile.setInt32( "menu_Content_inactive_alpha", g_settings.menu_Content_inactive_alpha ); + configfile.setInt32( "menu_Content_inactive_red", g_settings.menu_Content_inactive_red ); + configfile.setInt32( "menu_Content_inactive_green", g_settings.menu_Content_inactive_green ); + configfile.setInt32( "menu_Content_inactive_blue", g_settings.menu_Content_inactive_blue ); + + configfile.setInt32( "menu_Content_inactive_Text_alpha", g_settings.menu_Content_inactive_Text_alpha ); + configfile.setInt32( "menu_Content_inactive_Text_red", g_settings.menu_Content_inactive_Text_red ); + configfile.setInt32( "menu_Content_inactive_Text_green", g_settings.menu_Content_inactive_Text_green ); + configfile.setInt32( "menu_Content_inactive_Text_blue", g_settings.menu_Content_inactive_Text_blue ); + + configfile.setInt32( "infobar_alpha", g_settings.infobar_alpha ); + configfile.setInt32( "infobar_red", g_settings.infobar_red ); + configfile.setInt32( "infobar_green", g_settings.infobar_green ); + configfile.setInt32( "infobar_blue", g_settings.infobar_blue ); + + configfile.setInt32( "infobar_Text_alpha", g_settings.infobar_Text_alpha ); + configfile.setInt32( "infobar_Text_red", g_settings.infobar_Text_red ); + configfile.setInt32( "infobar_Text_green", g_settings.infobar_Text_green ); + configfile.setInt32( "infobar_Text_blue", g_settings.infobar_Text_blue ); + + //personalize + configfile.setString("personalize_pincode", g_settings.personalize_pincode); + for (int i = 0; i < SNeutrinoSettings::P_SETTINGS_MAX; i++) //settings.h, settings.cpp + configfile.setInt32(personalize_settings[i].personalize_settings_name, g_settings.personalize[i]); + + configfile.setInt32( "colored_events_channellist", g_settings.colored_events_channellist ); + configfile.setInt32( "colored_events_infobar", g_settings.colored_events_infobar ); + configfile.setInt32( "colored_events_alpha", g_settings.colored_events_alpha ); + configfile.setInt32( "colored_events_red", g_settings.colored_events_red ); + configfile.setInt32( "colored_events_green", g_settings.colored_events_green ); + configfile.setInt32( "colored_events_blue", g_settings.colored_events_blue ); + + configfile.setInt32( "contrast_fonts", g_settings.contrast_fonts ); + //network + for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { + sprintf(cfg_key, "network_nfs_ip_%d", i); + configfile.setString( cfg_key, g_settings.network_nfs_ip[i] ); + sprintf(cfg_key, "network_nfs_dir_%d", i); + configfile.setString( cfg_key, g_settings.network_nfs_dir[i] ); + sprintf(cfg_key, "network_nfs_local_dir_%d", i); + configfile.setString( cfg_key, g_settings.network_nfs_local_dir[i] ); + sprintf(cfg_key, "network_nfs_automount_%d", i); + configfile.setInt32( cfg_key, g_settings.network_nfs_automount[i]); + sprintf(cfg_key, "network_nfs_type_%d", i); + configfile.setInt32( cfg_key, g_settings.network_nfs_type[i]); + sprintf(cfg_key,"network_nfs_username_%d", i); + configfile.setString( cfg_key, g_settings.network_nfs_username[i] ); + sprintf(cfg_key, "network_nfs_password_%d", i); + configfile.setString( cfg_key, g_settings.network_nfs_password[i] ); + sprintf(cfg_key, "network_nfs_mount_options1_%d", i); + configfile.setString( cfg_key, g_settings.network_nfs_mount_options1[i]); + sprintf(cfg_key, "network_nfs_mount_options2_%d", i); + configfile.setString( cfg_key, g_settings.network_nfs_mount_options2[i]); + sprintf(cfg_key, "network_nfs_mac_%d", i); + configfile.setString( cfg_key, g_settings.network_nfs_mac[i]); + } + configfile.setString( "network_nfs_audioplayerdir", g_settings.network_nfs_audioplayerdir); + configfile.setString( "network_nfs_picturedir", g_settings.network_nfs_picturedir); + configfile.setString( "network_nfs_moviedir", g_settings.network_nfs_moviedir); + configfile.setString( "network_nfs_recordingdir", g_settings.network_nfs_recordingdir); + configfile.setString( "timeshiftdir", g_settings.timeshiftdir); + configfile.setBool ("filesystem_is_utf8" , g_settings.filesystem_is_utf8 ); + + //recording (server + vcr) + configfile.setInt32 ("recording_type", g_settings.recording_type); + configfile.setBool ("recording_stopsectionsd" , g_settings.recording_stopsectionsd ); + + configfile.setInt32 ("recording_audio_pids_default" , g_settings.recording_audio_pids_default); + configfile.setBool ("recording_zap_on_announce" , g_settings.recording_zap_on_announce ); + configfile.setBool ("shutdown_timer_record_type" , g_settings.shutdown_timer_record_type ); + + configfile.setBool ("recordingmenu.stream_vtxt_pid" , g_settings.recording_stream_vtxt_pid ); + configfile.setBool ("recordingmenu.stream_pmt_pid" , g_settings.recording_stream_pmt_pid ); + configfile.setInt32 ("recording_choose_direct_rec_dir" , g_settings.recording_choose_direct_rec_dir); + configfile.setBool ("recording_epg_for_filename" , g_settings.recording_epg_for_filename ); + configfile.setBool ("recording_epg_for_end" , g_settings.recording_epg_for_end ); + configfile.setBool ("recording_save_in_channeldir" , g_settings.recording_save_in_channeldir ); + configfile.setBool ("recording_slow_warning" , g_settings.recording_slow_warning ); + + // default plugin for movieplayer + configfile.setString ( "movieplayer_plugin", g_settings.movieplayer_plugin ); + configfile.setString ( "onekey_plugin", g_settings.onekey_plugin ); + configfile.setString ( "plugin_hdd_dir", g_settings.plugin_hdd_dir ); + configfile.setString ( "logo_hdd_dir", g_settings.logo_hdd_dir ); + + saveKeys(); + + configfile.setInt32( "timeshift_pause", g_settings.timeshift_pause ); + configfile.setInt32( "temp_timeshift", g_settings.temp_timeshift ); + configfile.setInt32( "auto_timeshift", g_settings.auto_timeshift ); + configfile.setInt32( "auto_delete", g_settings.auto_delete ); + configfile.setInt32( "record_hours", g_settings.record_hours ); + //printf("set: key_unlock =============== %d\n", g_settings.key_unlock); + configfile.setInt32( "screenshot_count", g_settings.screenshot_count ); + configfile.setInt32( "screenshot_format", g_settings.screenshot_format ); + configfile.setInt32( "screenshot_cover", g_settings.screenshot_cover ); + configfile.setInt32( "screenshot_mode", g_settings.screenshot_mode ); + configfile.setInt32( "screenshot_video", g_settings.screenshot_video ); + configfile.setInt32( "screenshot_scale", g_settings.screenshot_scale ); + + configfile.setString( "screenshot_dir", g_settings.screenshot_dir); + configfile.setInt32( "cacheTXT", g_settings.cacheTXT ); + configfile.setInt32( "minimode", g_settings.minimode ); + configfile.setInt32( "mode_clock", g_settings.mode_clock ); + configfile.setInt32( "zapto_pre_time", g_settings.zapto_pre_time ); + configfile.setBool("spectrum", g_settings.spectrum); + configfile.setBool("channellist_epgtext_align_right", g_settings.channellist_epgtext_align_right); + configfile.setBool("channellist_extended" , g_settings.channellist_extended); + configfile.setInt32("channellist_foot" , g_settings.channellist_foot); + configfile.setInt32("channellist_new_zap_mode", g_settings.channellist_new_zap_mode); + configfile.setInt32("channellist_minitv", g_settings.channellist_minitv); + configfile.setInt32("remote_control_hardware", g_settings.remote_control_hardware); + configfile.setBool ( "audiochannel_up_down_enable", g_settings.audiochannel_up_down_enable ); + configfile.setInt32("channellist_sort_mode", g_settings.channellist_sort_mode); + + //screen configuration + configfile.setInt32( "screen_xres", g_settings.screen_xres); + configfile.setInt32( "screen_yres", g_settings.screen_yres); + configfile.setInt32( "screen_StartX_lcd", g_settings.screen_StartX_lcd ); + configfile.setInt32( "screen_StartY_lcd", g_settings.screen_StartY_lcd ); + configfile.setInt32( "screen_EndX_lcd", g_settings.screen_EndX_lcd ); + configfile.setInt32( "screen_EndY_lcd", g_settings.screen_EndY_lcd ); + configfile.setInt32( "screen_StartX_crt", g_settings.screen_StartX_crt ); + configfile.setInt32( "screen_StartY_crt", g_settings.screen_StartY_crt ); + configfile.setInt32( "screen_EndX_crt", g_settings.screen_EndX_crt ); + configfile.setInt32( "screen_EndY_crt", g_settings.screen_EndY_crt ); + configfile.setInt32( "screen_preset", g_settings.screen_preset ); + configfile.setInt32( "screen_width", g_settings.screen_width); + configfile.setInt32( "screen_height", g_settings.screen_height); + + //Software-update + configfile.setInt32 ("softupdate_mode" , g_settings.softupdate_mode ); + configfile.setString("softupdate_url_file" , g_settings.softupdate_url_file ); + + configfile.setString("softupdate_proxyserver" , g_settings.softupdate_proxyserver ); + configfile.setString("softupdate_proxyusername" , g_settings.softupdate_proxyusername ); + configfile.setString("softupdate_proxypassword" , g_settings.softupdate_proxypassword ); + + configfile.setString("update_dir", g_settings.update_dir); + configfile.setString("font_file", g_settings.font_file); + configfile.setString("ttx_font_file", g_settings.ttx_font_file); + + //parentallock + configfile.setInt32( "parentallock_prompt", g_settings.parentallock_prompt ); + configfile.setInt32( "parentallock_lockage", g_settings.parentallock_lockage ); + configfile.setString( "parentallock_pincode", g_settings.parentallock_pincode ); + + //timing + for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) + configfile.setInt32(locale_real_names[timing_setting[i].name], g_settings.timing[i]); + + for (int i = 0; i < SNeutrinoSettings::LCD_SETTING_COUNT; i++) + configfile.setInt32(lcd_setting[i].name, g_settings.lcd_setting[i]); + configfile.setString("lcd_dim_time", g_settings.lcd_setting_dim_time); + configfile.setInt32("lcd_dim_brightness", g_settings.lcd_setting_dim_brightness); + configfile.setInt32("lcd_info_line", g_settings.lcd_info_line);//channel name or clock + + //Picture-Viewer + configfile.setString( "picviewer_slide_time", g_settings.picviewer_slide_time ); + configfile.setInt32( "picviewer_scaling", g_settings.picviewer_scaling ); + configfile.setString( "picviewer_decode_server_ip", g_settings.picviewer_decode_server_ip ); + configfile.setString( "picviewer_decode_server_port", g_settings.picviewer_decode_server_port); + + //Audio-Player + configfile.setInt32( "audioplayer_display", g_settings.audioplayer_display ); + configfile.setInt32( "audioplayer_follow", g_settings.audioplayer_follow ); + configfile.setString( "audioplayer_screensaver", g_settings.audioplayer_screensaver ); + configfile.setInt32( "audioplayer_highprio", g_settings.audioplayer_highprio ); + configfile.setInt32( "audioplayer_select_title_by_name", g_settings.audioplayer_select_title_by_name ); + configfile.setInt32( "audioplayer_repeat_on", g_settings.audioplayer_repeat_on ); + configfile.setInt32( "audioplayer_show_playlist", g_settings.audioplayer_show_playlist ); + configfile.setInt32( "audioplayer_enable_sc_metadata", g_settings.audioplayer_enable_sc_metadata ); + configfile.setString( "shoutcast_dev_id", g_settings.shoutcast_dev_id ); + + //Filebrowser + configfile.setInt32("filebrowser_showrights", g_settings.filebrowser_showrights); + configfile.setInt32("filebrowser_sortmethod", g_settings.filebrowser_sortmethod); + configfile.setBool("filebrowser_denydirectoryleave", g_settings.filebrowser_denydirectoryleave); + + //zapit setup + configfile.setString( "startchanneltv", g_settings.StartChannelTV ); + configfile.setString( "startchannelradio", g_settings.StartChannelRadio ); + configfile.setInt64("startchanneltv_id", g_settings.startchanneltv_id); + configfile.setInt64("startchannelradio_id", g_settings.startchannelradio_id); + configfile.setInt32("uselastchannel", g_settings.uselastchannel); + + // USERMENU + //--------------------------------------- + char txt1[81]; + char txt2[81]; + for(int button = 0; button < SNeutrinoSettings::BUTTON_MAX; button++) { + snprintf(txt1,80,"usermenu_tv_%s_text",usermenu_button_def[button]); + txt1[80] = 0; // terminate for sure + configfile.setString(txt1,g_settings.usermenu_text[button]); + + char* txt2ptr = txt2; + snprintf(txt1,80,"usermenu_tv_%s",usermenu_button_def[button]); + for(int pos = 0; pos < SNeutrinoSettings::ITEM_MAX; pos++) { + if( g_settings.usermenu[button][pos] != 0) { + if(pos != 0) + *txt2ptr++ = ','; + txt2ptr += snprintf(txt2ptr,80,"%d",g_settings.usermenu[button][pos]); + } + } + configfile.setString(txt1,txt2); + } + + configfile.setInt32("bigFonts", g_settings.bigFonts); + configfile.setInt32("big_windows", g_settings.big_windows); +#if 0 + configfile.setInt32("pip_x", g_settings.pip_x); + configfile.setInt32("pip_y", g_settings.pip_y); + configfile.setInt32("pip_width", g_settings.pip_width); + configfile.setInt32("pip_height", g_settings.pip_height); +#endif + if(strcmp(fname, NEUTRINO_SETTINGS_FILE)) + configfile.saveConfig(fname); + + else if (configfile.getModifiedFlag()) + { + configfile.saveConfig(fname); + configfile.setModifiedFlag(false); + } +} + +/************************************************************************************** +* CNeutrinoApp - channelsInit, get the Channellist from daemon * +**************************************************************************************/ +extern CBouquetManager *g_bouquetManager; + +void CNeutrinoApp::channelsInit(bool bOnly) +{ + int bnum; + CBouquet* tmp; + + printf("[neutrino] Creating channels lists...\n"); + TIMER_START(); + + if(!reloadhintBox) + reloadhintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_RELOAD_HINT)); + reloadhintBox->paint(); + + memset(tvsort, -1, sizeof(tvsort)); + memset(radiosort, -1, sizeof(tvsort)); + + const char * fav_bouquetname = g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME); + if(g_bouquetManager->existsUBouquet(fav_bouquetname, true) == -1) + g_bouquetManager->addBouquet(fav_bouquetname, true, true); + + + if(TVbouquetList) delete TVbouquetList; + if(RADIObouquetList) delete RADIObouquetList; + + if(TVfavList) delete TVfavList; + if(RADIOfavList) delete RADIOfavList; + + if(TVchannelList) delete TVchannelList; + if(RADIOchannelList) delete RADIOchannelList; + + TVchannelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD), false, true); + RADIOchannelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD), false, true); + + TVbouquetList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_PROVS)); + TVfavList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_FAVS)); + + RADIObouquetList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_PROVS)); + RADIOfavList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_FAVS)); + + uint32_t i; + i = 1; + + int tvi = 0, ri = 0; + + ZapitChannelList zapitList; + + /* all TV channels */ + CServiceManager::getInstance()->GetAllTvChannels(zapitList); + tvi = zapitList.size(); + TVchannelList->SetChannelList(&zapitList); + + /* all RADIO channels */ + CServiceManager::getInstance()->GetAllRadioChannels(zapitList); + ri = zapitList.size(); + + RADIOchannelList->SetChannelList(&zapitList); + + printf("[neutrino] got %d TV and %d RADIO channels\n", tvi, ri); fflush(stdout); + TIMER_STOP("[neutrino] all channels took"); + + /* unless we will do real channel delete from allchans, needed once ? */ + if(!bOnly) { + if(TVallList) delete TVallList; + if(RADIOallList) delete RADIOallList; + + TVallList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); + tmp = TVallList->addBouquet(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); + delete tmp->channelList; + tmp->channelList = new CChannelList(*TVchannelList); + //tmp->channelList->SortAlpha(); + + RADIOallList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); + tmp = RADIOallList->addBouquet(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); + delete tmp->channelList; + tmp->channelList = new CChannelList(*RADIOchannelList); + //tmp->channelList->SortAlpha(); + + TIMER_STOP("[neutrino] sort took"); + + if(TVsatList) delete TVsatList; + TVsatList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_SATS)); + if(RADIOsatList) delete RADIOsatList; + RADIOsatList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_SATS)); + + /* all TV / RADIO channels per satellite */ + sat_iterator_t sit; + satellite_map_t satlist = CServiceManager::getInstance()->SatelliteList(); + for(sit = satlist.begin(); sit != satlist.end(); sit++) { + CServiceManager::getInstance()->GetAllSatelliteChannels(zapitList, sit->first); + if( zapitList.empty() ) + continue; + + tvi = 0, ri = 0; + CBouquet* tmp1 = TVsatList->addBouquet(sit->second.name.c_str()); + CBouquet* tmp2 = RADIOsatList->addBouquet(sit->second.name.c_str()); + + for(zapit_list_it_t it = zapitList.begin(); it != zapitList.end(); it++) { + if ((*it)->getServiceType() == ST_DIGITAL_TELEVISION_SERVICE) { + tmp1->channelList->addChannel(*it); + tvi++; + } + else if ((*it)->getServiceType() == ST_DIGITAL_RADIO_SOUND_SERVICE) { + tmp2->channelList->addChannel(*it); + ri++; + } + } + printf("[neutrino] created %s bouquet with %d TV and %d RADIO channels\n", sit->second.name.c_str(), tvi, ri); + if(!tvi) + TVsatList->deleteBouquet(tmp1); + if(!ri) + RADIOsatList->deleteBouquet(tmp2); + + TIMER_STOP("[neutrino] sat took"); + } + /* new channels */ + if (g_settings.make_new_list) { + CServiceManager::getInstance()->GetAllTvChannels(zapitList, CZapitChannel::NEW); + if (!zapitList.empty()) { + CBouquet* newBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_NEW), false, true); + newBouquet->channelList->SetChannelList(&zapitList); + TVallList->Bouquets.push_back(newBouquet); + printf("[neutrino] got %d new TV channels\n", zapitList.size()); fflush(stdout); + } + CServiceManager::getInstance()->GetAllRadioChannels(zapitList, CZapitChannel::NEW); + if (!zapitList.empty()) { + CBouquet* newBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_NEW), false, true); + newBouquet->channelList->SetChannelList(&zapitList); + RADIOallList->Bouquets.push_back(newBouquet); + printf("[neutrino] got %d new RADIO channels\n", zapitList.size()); fflush(stdout); + } + } + if (g_settings.make_removed_list) { + CServiceManager::getInstance()->GetAllTvChannels(zapitList, CZapitChannel::REMOVED); + if (!zapitList.empty()) { + CBouquet* newBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_REMOVED), false, true); + newBouquet->channelList->SetChannelList(&zapitList); + TVallList->Bouquets.push_back(newBouquet); + printf("[neutrino] got %d removed TV channels\n", zapitList.size()); fflush(stdout); + } + CServiceManager::getInstance()->GetAllRadioChannels(zapitList, CZapitChannel::REMOVED); + if (!zapitList.empty()) { + CBouquet* newBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_REMOVED), false, true); + newBouquet->channelList->SetChannelList(&zapitList); + RADIOallList->Bouquets.push_back(newBouquet); + printf("[neutrino] got %d removed RADIO channels\n", zapitList.size()); fflush(stdout); + } + } + TIMER_STOP("[neutrino] sats took"); + } + + /* Favorites and providers TV bouquets */ + bnum = 0; + for (i = 0; i < g_bouquetManager->Bouquets.size(); i++) { + if (!g_bouquetManager->Bouquets[i]->bHidden && !g_bouquetManager->Bouquets[i]->tvChannels.empty()) + { + if(g_bouquetManager->Bouquets[i]->bUser) + tmp = TVfavList->addBouquet(g_bouquetManager->Bouquets[i]); + else + tmp = TVbouquetList->addBouquet(g_bouquetManager->Bouquets[i]); + + ZapitChannelList* channels = &(g_bouquetManager->Bouquets[i]->tvChannels); + tmp->channelList->SetChannelList(channels); + bnum++; + } + } + printf("[neutrino] got %d TV bouquets\n", bnum); fflush(stdout); + + /* all HD channels */ + if (g_settings.make_hd_list) { + CServiceManager::getInstance()->GetAllHDChannels(zapitList); + if (!zapitList.empty()) { + CBouquet* hdBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_HDTV), false, true); + hdBouquet->channelList->SetChannelList(&zapitList); + hdBouquet->channelList->SortSat(); + TVfavList->Bouquets.push_back(hdBouquet); + printf("[neutrino] got %d HD channels\n", zapitList.size()); fflush(stdout); + } + } + TIMER_STOP("[neutrino] tv took"); + + /* Favorites and provides RADIO bouquets */ + bnum = 0; + for (i = 0; i < g_bouquetManager->Bouquets.size(); i++) { + if (!g_bouquetManager->Bouquets[i]->bHidden && !g_bouquetManager->Bouquets[i]->radioChannels.empty() ) + { + if(g_bouquetManager->Bouquets[i]->bUser) + tmp = RADIOfavList->addBouquet(g_bouquetManager->Bouquets[i]); + else + tmp = RADIObouquetList->addBouquet(g_bouquetManager->Bouquets[i]); + + ZapitChannelList* channels = &(g_bouquetManager->Bouquets[i]->radioChannels); + tmp->channelList->SetChannelList(channels); + bnum++; + } + } + printf("[neutrino] got %d RADIO bouquets\n", bnum); fflush(stdout); + TIMER_STOP("[neutrino] took"); + + SetChannelMode(lastChannelMode); + + dprintf(DEBUG_DEBUG, "\nAll bouquets-channels received\n"); +#ifdef DEBUG + struct mallinfo myinfo = mallinfo(); + printf("[neutrino] total memory allocated by malloc, in bytes: %d (%dkb), chunks %d\n", + myinfo.arena, myinfo.arena / 1024, myinfo.uordblks); +#endif + + reloadhintBox->hide(); +} + +void CNeutrinoApp::SetChannelMode(int newmode) +{ + printf("CNeutrinoApp::SetChannelMode %d [%s]\n", newmode, mode == mode_radio ? "radio" : "tv"); + int *sortmode; + + if(mode == mode_radio) { + channelList = RADIOchannelList; + g_settings.channel_mode_radio = newmode; + sortmode = radiosort; + } else { + channelList = TVchannelList; + g_settings.channel_mode = newmode; + sortmode = tvsort; + } + + switch(newmode) { + case LIST_MODE_FAV: + if(mode == mode_radio) { + bouquetList = RADIOfavList; + } else { + bouquetList = TVfavList; + } + break; + case LIST_MODE_SAT: + if(mode == mode_radio) { + bouquetList = RADIOsatList; + } else { + bouquetList = TVsatList; + } + break; + case LIST_MODE_ALL: + if(mode == mode_radio) { + bouquetList = RADIOallList; + } else { + bouquetList = TVallList; + } + break; + default: + newmode = LIST_MODE_PROV; + case LIST_MODE_PROV: + if(mode == mode_radio) { + bouquetList = RADIObouquetList; + } else { + bouquetList = TVbouquetList; + } + break; + } + INFO("newmode %d sort old %d new %d", newmode, sortmode[newmode], g_settings.channellist_sort_mode); + if(newmode != LIST_MODE_FAV && sortmode[newmode] != g_settings.channellist_sort_mode && g_settings.channellist_sort_mode < CChannelList::SORT_MAX) { + sortmode[newmode] = g_settings.channellist_sort_mode; + INFO("sorting, mode %d, %d bouquets\n", g_settings.channellist_sort_mode, bouquetList->Bouquets.size()); + for (uint32_t i = 0; i < bouquetList->Bouquets.size(); i++) { + if(g_settings.channellist_sort_mode == CChannelList::SORT_ALPHA) + bouquetList->Bouquets[i]->channelList->SortAlpha(); + if(g_settings.channellist_sort_mode == CChannelList::SORT_TP) + bouquetList->Bouquets[i]->channelList->SortTP(); + if(g_settings.channellist_sort_mode == CChannelList::SORT_SAT) + bouquetList->Bouquets[i]->channelList->SortSat(); + if(g_settings.channellist_sort_mode == CChannelList::SORT_CH_NUMBER) + bouquetList->Bouquets[i]->channelList->SortChNumber(); + } + channelList->adjustToChannelID(channelList->getActiveChannel_ChannelID()); + } + lastChannelMode = newmode; +} + +/************************************************************************************** +* CNeutrinoApp - run, the main runloop * +**************************************************************************************/ +extern int cnxt_debug; +extern bool sections_debug; +extern int zapit_debug; + +void CNeutrinoApp::CmdParser(int argc, char **argv) +{ + global_argv = new char *[argc+1]; + for (int i = 0; i < argc; i++) + global_argv[i] = argv[i]; + global_argv[argc] = NULL; + + sections_debug = false; + softupdate = false; + //fromflash = false; + + font.name = NULL; + + for(int x=1; xinit(); + if(frameBuffer->setMode(720, 576, 8 * sizeof(fb_pixel_t))) { + dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n"); + exit(-1); + } + frameBuffer->Clear(); +} + +/************************************************************************************** +* CNeutrinoApp - setup fonts * +**************************************************************************************/ + +void CNeutrinoApp::SetupFonts() +{ + const char * style[3]; + + if (g_fontRenderer != NULL) + delete g_fontRenderer; + + g_fontRenderer = new FBFontRenderClass(72 * g_settings.screen_xres / 100, 72 * g_settings.screen_yres / 100); + + if(font.filename != NULL) + free((void *)font.filename); + + printf("[neutrino] settings font file %s\n", g_settings.font_file); + + if(access(g_settings.font_file, F_OK)) { + if(!access(FONTDIR"/neutrino.ttf", F_OK)){ + font.filename = strdup(FONTDIR"/neutrino.ttf"); + strcpy(g_settings.font_file, font.filename); + } + else{ + fprintf( stderr,"[neutrino] font file [%s] not found\n neutrino exit\n",FONTDIR"/neutrino.ttf"); + _exit(0); + } + + } + else{ + font.filename = strdup(g_settings.font_file); + } + style[0] = g_fontRenderer->AddFont(font.filename); + + if(font.name != NULL) + free((void *)font.name); + + font.name = strdup(g_fontRenderer->getFamily(font.filename).c_str()); + + printf("[neutrino] font family %s\n", font.name); + + style[1] = "Bold Regular"; + + g_fontRenderer->AddFont(font.filename, true); // make italics + style[2] = "Italic"; + + for (int i = 0; i < FONT_TYPE_COUNT; i++) + { + if(g_Font[i]) delete g_Font[i]; + g_Font[i] = g_fontRenderer->getFont(font.name, style[neutrino_font[i].style], configfile.getInt32(locale_real_names[neutrino_font[i].name], neutrino_font[i].defaultsize) + neutrino_font[i].size_offset * font.size_offset); + } + g_SignalFont = g_fontRenderer->getFont(font.name, style[signal_font.style], signal_font.defaultsize + signal_font.size_offset * font.size_offset); + /* recalculate infobar position */ + if (g_InfoViewer) + g_InfoViewer->start(); +} + +/************************************************************************************** +* CNeutrinoApp - setup the menu timouts * +**************************************************************************************/ +void CNeutrinoApp::SetupTiming() +{ + for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) + sprintf(g_settings.timing_string[i], "%d", g_settings.timing[i]); +} + + +#define LCD_UPDATE_TIME_RADIO_MODE (6 * 1000 * 1000) +#define LCD_UPDATE_TIME_TV_MODE (60 * 1000 * 1000) + +void CNeutrinoApp::MakeSectionsdConfig(CSectionsdClient::epg_config& config) +{ + config.epg_cache = atoi(g_settings.epg_cache.c_str()); + config.epg_old_events = atoi(g_settings.epg_old_events.c_str()); + config.epg_max_events = atoi(g_settings.epg_max_events.c_str()); + config.epg_extendedcache = atoi(g_settings.epg_extendedcache.c_str()); + config.epg_dir = g_settings.epg_dir; + config.network_ntpserver = g_settings.network_ntpserver; + config.network_ntprefresh = atoi(g_settings.network_ntprefresh.c_str()); + config.network_ntpenable = g_settings.network_ntpenable; +} + +void CNeutrinoApp::SendSectionsdConfig(void) +{ + CSectionsdClient::epg_config config; + MakeSectionsdConfig(config); + g_Sectionsd->setConfig(config); +} + +void CNeutrinoApp::InitZapper() +{ + struct stat my_stat; + + g_InfoViewer->start(); + if (g_settings.epg_save){ + if(stat(g_settings.epg_dir.c_str(), &my_stat) == 0) + g_Sectionsd->readSIfromXML(g_settings.epg_dir.c_str()); + } + int tvmode = CZapit::getInstance()->getMode() & CZapitClient::MODE_TV; + lastChannelMode = tvmode ? g_settings.channel_mode : g_settings.channel_mode_radio; + mode = tvmode ? mode_tv : mode_radio; + + SDTreloadChannels = false; + channelsInit(); + + if(tvmode) + tvMode(true); + else + radioMode(true); + + if(g_settings.cacheTXT) + tuxtxt_init(); + + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + if(channelList->getSize() && live_channel_id) + g_Sectionsd->setServiceChanged(live_channel_id, true ); +} + +void CNeutrinoApp::setupRecordingDevice(void) +{ + CRecordManager::getInstance()->SetDirectory(g_settings.network_nfs_recordingdir); + CRecordManager::getInstance()->Config(g_settings.recording_stopsectionsd, g_settings.recording_stream_vtxt_pid, g_settings.recording_stream_pmt_pid); +} + +static void CSSendMessage(uint32_t msg, uint32_t data) +{ + if (g_RCInput) + g_RCInput->postMsg(msg, data); +} + +void CNeutrinoApp::InitTimerdClient() +{ + g_Timerd = new CTimerdClient; + g_Timerd->registerEvent(CTimerdClient::EVT_ANNOUNCE_SHUTDOWN, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_SHUTDOWN, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_ANNOUNCE_NEXTPROGRAM, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_NEXTPROGRAM, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_STANDBY_ON, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_STANDBY_OFF, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_ANNOUNCE_RECORD, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_RECORD_START, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_RECORD_STOP, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_ANNOUNCE_ZAPTO, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_ZAPTO, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_SLEEPTIMER, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_ANNOUNCE_SLEEPTIMER, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_REMIND, 222, NEUTRINO_UDS_NAME); + g_Timerd->registerEvent(CTimerdClient::EVT_EXEC_PLUGIN, 222, NEUTRINO_UDS_NAME); +} + +void CNeutrinoApp::InitZapitClient() +{ + g_Zapit = new CZapitClient; +#define ZAPIT_EVENT_COUNT 27 + const CZapitClient::events zapit_event[ZAPIT_EVENT_COUNT] = + { + CZapitClient::EVT_ZAP_COMPLETE, + CZapitClient::EVT_ZAP_COMPLETE_IS_NVOD, + CZapitClient::EVT_ZAP_FAILED, + CZapitClient::EVT_ZAP_SUB_COMPLETE, + CZapitClient::EVT_ZAP_SUB_FAILED, + CZapitClient::EVT_ZAP_MOTOR, + CZapitClient::EVT_ZAP_CA_ID, + CZapitClient::EVT_RECORDMODE_ACTIVATED, + CZapitClient::EVT_RECORDMODE_DEACTIVATED, + CZapitClient::EVT_SCAN_COMPLETE, + CZapitClient::EVT_SCAN_FAILED, + CZapitClient::EVT_SCAN_NUM_TRANSPONDERS, + CZapitClient::EVT_SCAN_REPORT_NUM_SCANNED_TRANSPONDERS, + CZapitClient::EVT_SCAN_REPORT_FREQUENCY, + CZapitClient::EVT_SCAN_REPORT_FREQUENCYP, + CZapitClient::EVT_SCAN_SATELLITE, + CZapitClient::EVT_SCAN_NUM_CHANNELS, + CZapitClient::EVT_SCAN_PROVIDER, + CZapitClient::EVT_BOUQUETS_CHANGED, + CZapitClient::EVT_SERVICES_CHANGED, + CZapitClient::EVT_SCAN_SERVICENAME, + CZapitClient::EVT_SCAN_FOUND_TV_CHAN, + CZapitClient::EVT_SCAN_FOUND_RADIO_CHAN, + CZapitClient::EVT_SCAN_FOUND_DATA_CHAN, + CZapitClient::EVT_SDT_CHANGED, + CZapitClient::EVT_PMT_CHANGED, + CZapitClient::EVT_TUNE_COMPLETE, + }; + + for (int i = 0; i < ZAPIT_EVENT_COUNT; i++) + g_Zapit->registerEvent(zapit_event[i], 222, NEUTRINO_UDS_NAME); +} + +void CNeutrinoApp::InitSectiondClient() +{ + g_Sectionsd = new CSectionsdClient; + g_Sectionsd->registerEvent(CSectionsdClient::EVT_TIMESET, 222, NEUTRINO_UDS_NAME); + g_Sectionsd->registerEvent(CSectionsdClient::EVT_GOT_CN_EPG, 222, NEUTRINO_UDS_NAME); + g_Sectionsd->registerEvent(CSectionsdClient::EVT_WRITE_SI_FINISHED, 222, NEUTRINO_UDS_NAME); +} + +#if HAVE_COOL_HARDWARE +#include +#endif + +void wake_up( bool &wakeup) +{ +#if HAVE_COOL_HARDWARE +#ifndef FP_IOCTL_CLEAR_WAKEUP_TIMER +#define FP_IOCTL_CLEAR_WAKEUP_TIMER 10 +#endif + +#define FP_IOCTL_SET_RTC 0x101 +#define FP_IOCTL_GET_RTC 0x102 + + int fd = open("/dev/display", O_RDONLY); + if (fd < 0) { + perror("/dev/display"); + } else { + wakeup_data_t wk; + memset(&wk, 0, sizeof(wk)); + int ret = ioctl(fd, IOC_VFD_GET_WAKEUP, &wk); + if(ret >= 0) + wakeup = ((wk.source == WAKEUP_SOURCE_TIMER) /* || (wk.source == WAKEUP_SOURCE_PWLOST)*/); + close(fd); + } + 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"); + } +#endif + +} + +int CNeutrinoApp::run(int argc, char **argv) +{ + CmdParser(argc, argv); + +TIMER_START(); + cs_api_init(); + cs_register_messenger(CSSendMessage); + + g_Locale = new CLocaleManager; + + int loadSettingsErg = loadSetup(NEUTRINO_SETTINGS_FILE); + + initialize_iso639_map(); + + bool show_startwizard = false; + CLocaleManager::loadLocale_ret_t loadLocale_ret = g_Locale->loadLocale(g_settings.language); + if (loadLocale_ret == CLocaleManager::NO_SUCH_LOCALE) + { + strcpy(g_settings.language, "english"); + loadLocale_ret = g_Locale->loadLocale(g_settings.language); + show_startwizard = true; + } + /* setup GUI */ + SetupFonts(); + SetupTiming(); + g_PicViewer = new CPictureViewer(); + CColorSetupNotifier::setPalette(); + + CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_NEUTRINO_STARTING)); + hintBox->paint(); + + CVFD::getInstance()->init(font.filename, font.name); + CVFD::getInstance()->Clear(); + CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_NEUTRINO_STARTING)); + + /* set service manager options before starting zapit */ + CServiceManager::getInstance()->KeepNumbers(g_settings.keep_channel_numbers); + //zapit start parameters + Z_start_arg ZapStart_arg; + ZapStart_arg.startchanneltv_id = g_settings.startchanneltv_id; + ZapStart_arg.startchannelradio_id = g_settings.startchannelradio_id; + ZapStart_arg.uselastchannel = g_settings.uselastchannel; + ZapStart_arg.video_mode = g_settings.video_Mode; + ZapStart_arg.ci_clock = g_settings.ci_clock; + ZapStart_arg.volume = g_settings.current_volume; + + /* create decoders, read channels */ + bool zapit_init = CZapit::getInstance()->Start(&ZapStart_arg); + // init audio settings + audioDecoder->SetSRS(g_settings.srs_enable, g_settings.srs_nmgr_enable, g_settings.srs_algo, g_settings.srs_ref_volume); + //audioDecoder->setVolume(g_settings.current_volume, g_settings.current_volume); + audioDecoder->SetHdmiDD((HDMI_ENCODED_MODE)g_settings.hdmi_dd); + audioDecoder->SetSpdifDD(g_settings.spdif_dd ? true : false); + audioDecoder->EnableAnalogOut(g_settings.analog_out ? true : false); + audioSetupNotifier = new CAudioSetupNotifier; + // trigger a change + if(g_settings.avsync != (AVSYNC_TYPE) AVSYNC_ENABLED) + audioSetupNotifier->changeNotify(LOCALE_AUDIOMENU_AVSYNC, NULL); + + //init video settings + g_videoSettings = new CVideoSettings; + g_videoSettings->setVideoSettings(); + + g_RCInput = new CRCInput(); + + /* later on, we'll crash anyway, so tell about it. */ + if (! zapit_init) + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, + "Zapit initialization failed.\nThis is a fatal error, sorry.", + CMessageBox::mbrBack, CMessageBox::mbBack); + + InitZapitClient(); + g_Zapit->setStandby(false); + + //timer start + bool timer_wakeup = false; + wake_up( timer_wakeup ); + pthread_create (&timer_thread, NULL, timerd_main_thread, (void *) timer_wakeup); + + init_cec_setting = true; + if(!(g_settings.shutdown_timer_record_type && timer_wakeup && g_settings.hdmi_cec_mode)){ + //init cec settings + CCECSetup cecsetup; + cecsetup.setCECSettings(); + init_cec_setting = false; + } + g_settings.shutdown_timer_record_type = false; + timer_wakeup = false; + + powerManager = new cPowerManager; + powerManager->Open(); + + cpuFreq = new cCpuFreqManager(); + cpuFreq->SetCpuFreq(g_settings.cpufreq * 1000 * 1000); + + g_info.delivery_system = CFEManager::getInstance()->getLiveFE()->getInfo()->type == FE_QPSK ? DVB_S : DVB_C; + + g_info.delivery_system = CFEManager::getInstance()->getLiveFE()->getInfo()->type == FE_QPSK ? DVB_S : DVB_C; +#if HAVE_TRIPLEDRAGON + /* only SAT-hd1 before rev 8 has fan, rev 1 is TD (compat hack) */ + g_info.has_fan = (cs_get_revision() > 1 && cs_get_revision() < 8 && g_info.delivery_system == DVB_S); +#else + g_info.has_fan = (cs_get_revision() < 8 && g_info.delivery_system == DVB_S); +#endif + dprintf(DEBUG_NORMAL, "g_info.has_fan: %d\n", g_info.has_fan); + //fan speed + if (g_info.has_fan) + CFanControlNotifier::setSpeed(g_settings.fan_speed); + + dvbsub_init(); + + pthread_create (&nhttpd_thread, NULL, nhttpd_main_thread, (void *) NULL); + + CStreamManager::getInstance()->Start(); + +#ifndef DISABLE_SECTIONSD + CSectionsdClient::epg_config config; + MakeSectionsdConfig(config); + CEitManager::getInstance()->SetConfig(config); + CEitManager::getInstance()->Start(); +#endif + + if (!scanSettings.loadSettings(NEUTRINO_SCAN_SETTINGS_FILE, g_info.delivery_system)) { + dprintf(DEBUG_NORMAL, "Loading of scan settings failed. Using defaults.\n"); + } + + CVFD::getInstance()->showVolume(g_settings.current_volume); + CVFD::getInstance()->setMuted(current_muted); + + g_RemoteControl = new CRemoteControl; + g_EpgData = new CEpgData; + g_InfoViewer = new CInfoViewer; + g_EventList = new CNeutrinoEventList; + + g_CamHandler = new CCAMMenuHandler(); + g_CamHandler->init(); + +#ifndef ASSUME_MDEV + mkdir("/media/sda1", 0755); + mkdir("/media/sdb1", 0755); + my_system("mount", "/dev/sda1", "/media/sda1"); + my_system("mount", "/dev/sdb1", "/media/sdb1"); +#endif + + CFSMounter::automount(); + g_PluginList = new CPlugins; + g_PluginList->setPluginDir(PLUGINDIR); + //load Pluginlist before main menu (only show script menu if at least one script is available + g_PluginList->loadPlugins(); + + MoviePluginChanger = new CMoviePluginChangeExec; + + // setup recording device + setupRecordingDevice(); + + dprintf( DEBUG_NORMAL, "menue setup\n"); + //init Menues + InitMenu(); + + dprintf( DEBUG_NORMAL, "registering as event client\n"); + +#ifndef DISABLE_SECTIONSD + InitSectiondClient(); +#endif + + InitTimerdClient(); + + g_volume = CVolume::getInstance(); + + if (show_startwizard) { + hintBox->hide(); + CStartUpWizard startwizard; + startwizard.exec(NULL, ""); + } + + if(loadSettingsErg) { + hintBox->hide(); + dprintf(DEBUG_INFO, "config file or options missing\n"); + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, loadSettingsErg == 1 ? g_Locale->getText(LOCALE_SETTINGS_NOCONFFILE) + : g_Locale->getText(LOCALE_SETTINGS_MISSINGOPTIONSCONFFILE)); + configfile.setModifiedFlag(true); + saveSetup(NEUTRINO_SETTINGS_FILE); + } + + CHDDDestExec * hdd = new CHDDDestExec(); + hdd->exec(NULL, ""); + delete hdd; + + cCA::GetInstance()->Ready(true); + InitZapper(); + + g_volume->AudioMute(current_muted, true); + SHTDCNT::getInstance()->init(); + + hintBox->hide(); + delete hintBox; + +TIMER_STOP("################################## after all ##################################"); + RealRun(personalize.getWidget(0)/**main**/); + + ExitRun(true, (cs_get_revision() > 7)); + + return 0; +} + +void CNeutrinoApp::quickZap(int msg) +{ + int res; + + StopSubtitles(); + printf("CNeutrinoApp::quickZap haveFreeFrontend %d\n", CFEManager::getInstance()->haveFreeFrontend()); + if(!CFEManager::getInstance()->haveFreeFrontend()) + { + res = channelList->numericZap(g_settings.key_zaphistory); + StartSubtitles(res < 0); + return; + } + if(!bouquetList->Bouquets.empty()) + bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->quickZap(msg, g_settings.zap_cycle); + else + channelList->quickZap(msg); +} + +void CNeutrinoApp::numericZap(int msg) +{ + StopSubtitles(); + int res = channelList->numericZap( msg ); + StartSubtitles(res < 0); +} + +void CNeutrinoApp::showInfo() +{ + StopSubtitles(); + + char *pname = NULL; + if(g_settings.infobar_show_channeldesc){ + CZapitChannel* channel = channelList->getActiveChannel(); + if(channel->pname){ + pname = channel->pname; + } + } + + g_InfoViewer->showTitle(channelList->getActiveChannelNumber(), channelList->getActiveChannelName(), channelList->getActiveSatellitePosition(), channelList->getActiveChannel_ChannelID(), false, 0, pname); + StartSubtitles(); +} + +void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) +{ + neutrino_msg_t msg; + neutrino_msg_data_t data; + + dprintf(DEBUG_NORMAL, "initialized everything\n"); + + g_PluginList->startPlugin("startup.cfg"); + if (!g_PluginList->getScriptOutput().empty()) { + ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + } + g_RCInput->clearRCMsg(); + if(g_settings.power_standby || init_cec_setting) + standbyMode(true, true); + + InfoClock = CInfoClock::getInstance(); + if(g_settings.mode_clock) + InfoClock->StartClock(); + + //cCA::GetInstance()->Ready(true); + + while( true ) { + g_RCInput->getMsg(&msg, &data, 100, ((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) && (g_RemoteControl->subChannels.size() < 1)) ? true : false); // 10 secs.. + + if( ( mode == mode_tv ) || ( ( mode == mode_radio ) ) ) { + if( (msg == NeutrinoMessages::SHOW_EPG) /* || (msg == CRCInput::RC_info) */ ) { + StopSubtitles(); + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + g_EpgData->show(live_channel_id); + StartSubtitles(); + } + else if( msg == CRCInput::RC_epg ) { + StopSubtitles(); + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + g_EventList->exec(live_channel_id, channelList->getActiveChannelName()); + StartSubtitles(); + } + else if( ( msg == (neutrino_msg_t) g_settings.key_quickzap_up ) || ( msg == (neutrino_msg_t) g_settings.key_quickzap_down ) ) + { + //quickzap + quickZap(msg); + } + + else if( msg == CRCInput::RC_text) { + g_RCInput->clearRCMsg(); + if(g_settings.mode_clock) + InfoClock->StopClock(); + StopSubtitles(); + tuxtx_stop_subtitle(); + + tuxtx_main(g_RCInput->getFileHandle(), g_RemoteControl->current_PIDs.PIDs.vtxtpid); + + frameBuffer->paintBackground(); + //if(!g_settings.cacheTXT) + // tuxtxt_stop(); + g_RCInput->clearRCMsg(); + // restore mute symbol + if (current_muted) + g_volume->AudioMute(current_muted, true); + if(g_settings.mode_clock) + InfoClock->StartClock(); + StartSubtitles(); + } + else if( msg == CRCInput::RC_setup ) { + if(!g_settings.minimode) { + StopSubtitles(); + if(g_settings.mode_clock) + InfoClock->StopClock(); + mainMenu.exec(NULL, ""); + // restore mute symbol + if (current_muted) + g_volume->AudioMute(current_muted, true); + if(g_settings.mode_clock) + InfoClock->StartClock(); + StartSubtitles(); + saveSetup(NEUTRINO_SETTINGS_FILE); + } + } + else if( ((msg == CRCInput::RC_tv) || (msg == CRCInput::RC_radio)) && ((neutrino_msg_t)g_settings.key_tvradio_mode == CRCInput::RC_nokey)) { + switchTvRadioMode();//used with defined default tv/radio rc key + } + else if( msg == (neutrino_msg_t) g_settings.key_tvradio_mode ) { + switchTvRadioMode(); //used with defined rc key TODO: do we really need this, because we already have a specified key on the remote control + } + else if( msg == (neutrino_msg_t) g_settings.key_subchannel_up || msg == (neutrino_msg_t) g_settings.key_subchannel_down) { + if( !g_RemoteControl->subChannels.empty() ) { + StopSubtitles(); + if( msg == (neutrino_msg_t) g_settings.key_subchannel_up ) + g_RemoteControl->subChannelUp(); + else if( msg == (neutrino_msg_t) g_settings.key_subchannel_down ) + g_RemoteControl->subChannelDown(); + g_InfoViewer->showSubchan(); + } + else if ( msg == CRCInput::RC_left || msg == CRCInput::RC_right) { + if (g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) { + g_volume->setVolume(msg, true); + } + else if((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) + || (g_settings.mode_left_right_key_tv == SNeutrinoSettings::INFOBAR)) { + if(channelList->getSize()) { + showInfo(); + } + } + } + else + quickZap( msg ); + } + /* in case key_subchannel_up/down redefined */ + else if( msg == CRCInput::RC_left || msg == CRCInput::RC_right) { + if(g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) { + g_volume->setVolume(msg, true); + } else if(channelList->getSize()) { + showInfo(); + } + } + else if( msg == (neutrino_msg_t) g_settings.key_zaphistory ) { + // Zap-History "Bouquet" + if(g_settings.mode_clock && g_settings.key_zaphistory == CRCInput::RC_home) { + g_settings.mode_clock=false; + InfoClock->StopClock(); + } else { + numericZap( msg ); + } + } + else if (msg == (neutrino_msg_t) g_settings.key_screenshot) { + for(int i = 0; i < g_settings.screenshot_count; i++) { + CScreenShot * sc = new CScreenShot("", (CScreenShot::screenshot_format_t)g_settings.screenshot_format); + sc->MakeFileName(CZapit::getInstance()->GetCurrentChannelID()); + sc->Start(); + } + } + else if( msg == (neutrino_msg_t) g_settings.key_lastchannel ) { + // Quick Zap + numericZap( msg ); + } + else if( msg == (neutrino_msg_t) g_settings.key_plugin ) { + g_PluginList->start_plugin_by_name(g_settings.onekey_plugin.c_str(), 0); + } + else if(msg == (neutrino_msg_t) g_settings.key_timeshift) { + CRecordManager::getInstance()->StartTimeshift(); + } + else if (msg == (neutrino_msg_t) g_settings.key_current_transponder){ + numericZap( msg ); + } + else if (CRCInput::isNumeric(msg)) { + numericZap( msg ); + } + else if(msg == CRCInput::RC_rewind) { + if(g_RemoteControl->is_video_started) { + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + if(CRecordManager::getInstance()->RecordingStatus(live_channel_id)) + CMoviePlayerGui::getInstance().exec(NULL, "rtimeshift"); + } + } + else if( msg == CRCInput::RC_record) { + CRecordManager::getInstance()->exec(NULL, "Record"); + } + else if( msg == CRCInput::RC_stop ) { + CRecordManager::getInstance()->exec(NULL, "Stop_record"); + } + else if( msg == CRCInput::RC_red ) { + // eventlist + if (g_settings.personalize[SNeutrinoSettings::P_MAIN_RED_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED)// EventList Menu - Personalization Check + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_RED); + StartSubtitles(); + } + else + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + } + else if ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_GREEN); + StartSubtitles(); + } + else if( msg == CRCInput::RC_green) + { + if (g_settings.personalize[SNeutrinoSettings::P_MAIN_GREEN_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED) + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_GREEN); + StartSubtitles(); + } + else + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + } + else if( msg == CRCInput::RC_yellow ) { // NVODs + if (g_settings.personalize[SNeutrinoSettings::P_MAIN_YELLOW_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED) + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_YELLOW); + StartSubtitles(); + } + else + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + } + else if( (msg == CRCInput::RC_green) || ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) ) + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_GREEN); + StartSubtitles(); + } + else if( msg == CRCInput::RC_yellow ) { // NVODs + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_YELLOW); + StartSubtitles(); + } + else if( msg == CRCInput::RC_blue ) { + if (g_settings.personalize[SNeutrinoSettings::P_MAIN_BLUE_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED)// Features Menu - Personalization Check + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_BLUE); + StartSubtitles(); + } + else + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT), 450, 10); + } + else if( (msg == CRCInput::RC_audio) && g_settings.audio_run_player) { + //open mediaplayer menu in audio mode, user can select between audioplayer and internetradio + CMediaPlayerMenu * media = CMediaPlayerMenu::getInstance(); + media->setMenuTitel(LOCALE_MAINMENU_AUDIOPLAYER); + media->setUsageMode(CMediaPlayerMenu::MODE_AUDIO); + media->exec(NULL, ""); + } + else if( msg == CRCInput::RC_video || msg == CRCInput::RC_play ) { + //open moviebrowser via media player menu object + CMediaPlayerMenu::getInstance()->exec(NULL,"movieplayer"); + } + else if (CRCInput::isNumeric(msg) && g_RemoteControl->director_mode ) { + g_RemoteControl->setSubChannel(CRCInput::getNumericValue(msg)); + g_InfoViewer->showSubchan(); + } + else if( ( msg == CRCInput::RC_help ) || ( msg == CRCInput::RC_info) || + ( msg == NeutrinoMessages::SHOW_INFOBAR ) ) + { + bool show_info = ((msg != NeutrinoMessages::SHOW_INFOBAR) || (g_InfoViewer->is_visible || g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] != 0)); + // turn on LCD display + CVFD::getInstance()->wake_up(); + + // show Infoviewer + if(show_info && channelList->getSize()) { + showInfo(); + } + } + else if (msg == CRCInput::RC_timer) + { + CTimerList Timerlist; + Timerlist.exec(NULL, ""); + } + else { + if (msg == CRCInput::RC_home) { + if(g_settings.mode_clock && g_settings.key_zaphistory == CRCInput::RC_home) { + g_settings.mode_clock=false; + InfoClock->StopClock(); + } + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + } + handleMsg(msg, data); + } + } + else { + // mode == mode_scart + if( msg == CRCInput::RC_home ) { + if( mode == mode_scart ) { + // Scart-Mode verlassen + scartMode( false ); + } + } + else { + handleMsg(msg, data); + } + } + } +} + +int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) +{ + int res = 0; + neutrino_msg_t msg = _msg; + + if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) { + CZapit::getInstance()->GetAudioMode(g_settings.audio_AnalogMode); + if(g_settings.audio_AnalogMode < 0 || g_settings.audio_AnalogMode > 2) + g_settings.audio_AnalogMode = 0; + + g_RCInput->killTimer(scrambled_timer); + + scrambled_timer = g_RCInput->addTimer(10*1000*1000, true); + SelectSubtitles(); + StartSubtitles(!g_InfoViewer->is_visible); + + /* update scan settings for manual scan to current channel */ + CScanSetup::getInstance()->updateManualSettings(); + } + if ((msg == NeutrinoMessages::EVT_TIMER)) { + if(data == scrambled_timer) { + scrambled_timer = 0; + if(g_settings.scrambled_message && videoDecoder->getBlank() && videoDecoder->getPlayState()) { + const char * text = g_Locale->getText(LOCALE_SCRAMBLED_CHANNEL); + ShowHintUTF (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, 5); + } + return messages_return::handled; + } + } + + res = res | g_RemoteControl->handleMsg(msg, data); + res = res | g_InfoViewer->handleMsg(msg, data); + res = res | channelList->handleMsg(msg, data); + res = res | CRecordManager::getInstance()->handleMsg(msg, data); + + if( res != messages_return::unhandled ) { + if( ( msg>= CRCInput::RC_WithData ) && ( msg< CRCInput::RC_WithData+ 0x10000000 ) ) + delete[] (unsigned char*) data; + return( res & ( 0xFFFFFFFF - messages_return::unhandled ) ); + } + + /* we assume g_CamHandler free/delete data if needed */ + res = g_CamHandler->handleMsg(msg, data); + if( res != messages_return::unhandled ) { + return(res & (0xFFFFFFFF - messages_return::unhandled)); + } + + /* ================================== KEYS ================================================ */ + if( msg == CRCInput::RC_ok || (!g_InfoViewer->virtual_zap_mode && (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites))) { + if( (mode == mode_tv) || (mode == mode_radio) || (mode == mode_ts)) { + if(g_settings.mode_clock) + InfoClock->StopClock(); + + StopSubtitles(); + +_show: + int nNewChannel = -1; + int old_num = 0; + int old_b = bouquetList->getActiveBouquetNumber(); + //int old_mode = g_settings.channel_mode; + int old_mode = GetChannelMode(); + printf("************************* ZAP START: bouquetList %p size %d old_b %d\n", bouquetList, bouquetList->Bouquets.size(), old_b);fflush(stdout); + + if(!bouquetList->Bouquets.empty()) { + old_num = bouquetList->Bouquets[old_b]->channelList->getSelected(); + } +//_show: + if(msg == CRCInput::RC_ok) + { + if( !bouquetList->Bouquets.empty() && bouquetList->Bouquets[old_b]->channelList->getSize() > 0) + nNewChannel = bouquetList->Bouquets[old_b]->channelList->exec();//with ZAP! + else + nNewChannel = bouquetList->exec(true); + // restore mute symbol + if (current_muted) + g_volume->AudioMute(current_muted, true); + } else if(msg == CRCInput::RC_sat) { + SetChannelMode(LIST_MODE_SAT); + nNewChannel = bouquetList->exec(true); + } else if(msg == CRCInput::RC_favorites) { + SetChannelMode(LIST_MODE_FAV); + nNewChannel = bouquetList->exec(true); + } +_repeat: + CVFD::getInstance ()->showServicename(channelList->getActiveChannelName()); + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + printf("************************* ZAP RES: nNewChannel %d\n", nNewChannel);fflush(stdout); + if(nNewChannel == -1) { // restore orig. bouquet and selected channel on cancel + /* FIXME if mode was changed while browsing, + * other modes selected bouquet not restored */ + SetChannelMode(old_mode); + bouquetList->activateBouquet(old_b, false); + if(!bouquetList->Bouquets.empty()) + bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->setSelected(old_num); + StartSubtitles(mode == mode_tv); + } + else if(nNewChannel == -3) { // list mode changed + printf("************************* ZAP NEW MODE: bouquetList %p size %d\n", bouquetList, bouquetList->Bouquets.size());fflush(stdout); + nNewChannel = bouquetList->exec(true); + goto _repeat; + } + //else if(nNewChannel == -4) + if(g_channel_list_changed) + { + SetChannelMode(old_mode); + g_channel_list_changed = 0; + if(old_b_id < 0) old_b_id = old_b; + //g_Zapit->saveBouquets(); + /* lets do it in sync */ + reloadhintBox->paint(); + g_bouquetManager->saveBouquets(); + g_bouquetManager->saveUBouquets(); + g_bouquetManager->renumServices(); + channelsInit(/*true*/); + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + channelList->adjustToChannelID(live_channel_id);//FIXME what if deleted ? + bouquetList->activateBouquet(old_b_id, false); + msg = CRCInput::RC_ok; + goto _show; + } + + if(g_settings.mode_clock) + InfoClock->StartClock(); + + return messages_return::handled; + } + } + else if (msg == CRCInput::RC_standby_on) { + if (data == 0) + g_RCInput->postMsg(NeutrinoMessages::STANDBY_ON, 0); + return messages_return::cancel_all | messages_return::handled; + } + else if ((msg == CRCInput::RC_standby_off) || (msg == CRCInput::RC_power_on)) { + if (data == 0) + g_RCInput->postMsg(NeutrinoMessages::STANDBY_OFF, 0); + return messages_return::handled; + } + else if (msg == CRCInput::RC_power_off) { + g_RCInput->postMsg(NeutrinoMessages::SHUTDOWN, 0); + return messages_return::cancel_all | messages_return::handled; + } + else if (msg == (neutrino_msg_t) g_settings.key_power_off /*CRCInput::RC_standby*/) { + if (data == 0) { + neutrino_msg_t new_msg; + + /* Note: pressing the power button on the dbox (not the remote control) over 1 second */ + /* shuts down the system even if !g_settings.shutdown_real_rcdelay (see below) */ + gettimeofday(&standby_pressed_at, NULL); + + if ((mode != mode_standby) && (g_settings.shutdown_real) && !recordingstatus) { + new_msg = NeutrinoMessages::SHUTDOWN; + } + else { + new_msg = (mode == mode_standby) ? NeutrinoMessages::STANDBY_OFF : NeutrinoMessages::STANDBY_ON; + //printf("standby: new msg %X\n", new_msg); + if ((g_settings.shutdown_real_rcdelay)) { + neutrino_msg_t _msg_; + neutrino_msg_data_t mdata; + struct timeval endtime; + time_t seconds; + + int timeout = 0; + int timeout1 = 0; + + sscanf(g_settings.repeat_blocker, "%d", &timeout); + sscanf(g_settings.repeat_genericblocker, "%d", &timeout1); + + if (timeout1 > timeout) + timeout = timeout1; + + timeout += 500; + //printf("standby: timeout %d\n", timeout); + + while(true) { + g_RCInput->getMsg_ms(&_msg_, &mdata, timeout); + + //printf("standby: input msg %X\n", msg); + if (_msg_ == CRCInput::RC_timeout) + break; + + gettimeofday(&endtime, NULL); + seconds = endtime.tv_sec - standby_pressed_at.tv_sec; + if (endtime.tv_usec < standby_pressed_at.tv_usec) + seconds--; + //printf("standby: input seconds %d\n", seconds); + if (seconds >= 1) { + if (_msg_ == CRCInput::RC_standby) + new_msg = NeutrinoMessages::SHUTDOWN; + break; + } + } + } + } + g_RCInput->postMsg(new_msg, 0); + return messages_return::cancel_all | messages_return::handled; + } + return messages_return::handled; +#if 0 + else /* data == 1: KEY_POWER released */ + if (standby_pressed_at.tv_sec != 0) /* check if we received a KEY_POWER pressed event before */ + { /* required for correct handling of KEY_POWER events of */ + /* the power button on the dbox (not the remote control) */ + struct timeval endtime; + gettimeofday(&endtime, NULL); + time_t seconds = endtime.tv_sec - standby_pressed_at.tv_sec; + if (endtime.tv_usec < standby_pressed_at.tv_usec) + seconds--; + if (seconds >= 1) { + g_RCInput->postMsg(NeutrinoMessages::SHUTDOWN, 0); + return messages_return::cancel_all | messages_return::handled; + } + } +#endif + } + else if ((msg == CRCInput::RC_plus) || (msg == CRCInput::RC_minus)) + { + g_volume->setVolume(msg, (mode != mode_scart)); + return messages_return::handled; + } + else if( msg == CRCInput::RC_spkr ) { + if( mode == mode_standby ) { + //switch lcd off/on + CVFD::getInstance()->togglePower(); + } + else { + //mute + g_volume->AudioMute(!current_muted, true); + } + return messages_return::handled; + } + else if( msg == CRCInput::RC_mute_on ) { + g_volume->AudioMute(true, true); + return messages_return::handled; + } + else if( msg == CRCInput::RC_mute_off ) { + g_volume->AudioMute(false, true); + return messages_return::handled; + } + else if( msg == CRCInput::RC_analog_on ) { + g_settings.analog_out = 1; + audioDecoder->EnableAnalogOut(true); + return messages_return::handled; + } + else if( msg == CRCInput::RC_analog_off ) { + g_settings.analog_out = 0; + audioDecoder->EnableAnalogOut(false); + return messages_return::handled; + } + else if( msg == CRCInput::RC_mode ) { + g_videoSettings->nextMode(); + return messages_return::handled; + } + else if( msg == CRCInput::RC_next ) { + g_videoSettings->next43Mode(); + return messages_return::handled; + } + else if( msg == CRCInput::RC_prev ) { + g_videoSettings->SwitchFormat(); + return messages_return::handled; + } + else if (msg == (neutrino_msg_t) g_settings.key_screenshot) { + //video+osd scaled to osd size + CScreenShot * sc = new CScreenShot("", (CScreenShot::screenshot_format_t)g_settings.screenshot_format); + sc->EnableOSD(true); + sc->MakeFileName(CZapit::getInstance()->GetCurrentChannelID()); + sc->Start(); + } + + /* ================================== MESSAGES ================================================ */ + else if (msg == NeutrinoMessages::EVT_VOLCHANGED) { + //setVolume(msg, false, true); + return messages_return::handled; + } +#ifdef HAVE_CONTROLD + else if( msg == NeutrinoMessages::EVT_VCRCHANGED ) { + if (g_settings.vcr_AutoSwitch) { + if( data != VCR_STATUS_OFF ) + g_RCInput->postMsg( NeutrinoMessages::VCR_ON, 0 ); + else + g_RCInput->postMsg( NeutrinoMessages::VCR_OFF, 0 ); + } + return messages_return::handled | messages_return::cancel_info; + } +#endif + else if( msg == NeutrinoMessages::EVT_MUTECHANGED ) { + //FIXME unused ? + return messages_return::handled; + } + else if( msg == NeutrinoMessages::EVT_SERVICESCHANGED ) { + printf("NeutrinoMessages::EVT_SERVICESCHANGED\n");fflush(stdout); + channelsInit(); + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + channelList->adjustToChannelID(live_channel_id);//FIXME what if deleted ? + if(old_b_id >= 0) { + bouquetList->activateBouquet(old_b_id, false); + old_b_id = -1; + g_RCInput->postMsg(CRCInput::RC_ok, 0); + } + } + else if( msg == NeutrinoMessages::EVT_BOUQUETSCHANGED ) { + printf("NeutrinoMessages::EVT_BOUQUETSCHANGED\n");fflush(stdout); + channelsInit(); + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + channelList->adjustToChannelID(live_channel_id);//FIXME what if deleted ? + return messages_return::handled; + } + else if( msg == NeutrinoMessages::EVT_RECORDMODE ) { + /* sent by rcinput, when got msg from zapit about record activated/deactivated */ + /* should be sent when no record running */ + printf("NeutrinoMessages::EVT_RECORDMODE: %s\n", ( data ) ? "on" : "off"); + //if(!CRecordManager::getInstance()->RecordingStatus() && was_record && (!data)) + + /* no records left and record mode off FIXME check !*/ + if(!CRecordManager::getInstance()->RecordingStatus() && (!data)) + { + if(mode == mode_standby) { + g_Zapit->setStandby(true); + cpuFreq->SetCpuFreq(g_settings.standby_cpufreq * 1000 * 1000); + } + } + recordingstatus = data; + autoshift = CRecordManager::getInstance()->TimeshiftOnly(); + CVFD::getInstance()->ShowIcon(VFD_ICON_CAM1, recordingstatus != 0); + + if( ( !g_InfoViewer->is_visible ) && data && !autoshift) + g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 ); + + return messages_return::handled; + } + else if (msg == NeutrinoMessages::RECORD_START) { + //FIXME better at announce ? + if( mode == mode_standby ) { + cpuFreq->SetCpuFreq(g_settings.cpufreq * 1000 * 1000); + if(!recordingstatus && g_settings.ci_standby_reset) { + g_CamHandler->exec(NULL, "ca_ci_reset0"); + g_CamHandler->exec(NULL, "ca_ci_reset1"); + } + } + CRecordManager::getInstance()->Record((CTimerd::RecordingInfo *) data); + autoshift = CRecordManager::getInstance()->TimeshiftOnly(); + + delete[] (unsigned char*) data; + return messages_return::handled | messages_return::cancel_all; + } + else if( msg == NeutrinoMessages::RECORD_STOP) { + CTimerd::RecordingStopInfo* recinfo = (CTimerd::RecordingStopInfo*)data; + printf("NeutrinoMessages::RECORD_STOP: eventID %d channel_id %llx\n", recinfo->eventID, recinfo->channel_id); + CRecordManager::getInstance()->Stop(recinfo); + autoshift = CRecordManager::getInstance()->TimeshiftOnly(); + + delete[] (unsigned char*) data; + return messages_return::handled; + } + else if( msg == NeutrinoMessages::EVT_PMT_CHANGED) { + res = messages_return::handled; + t_channel_id channel_id = *(t_channel_id*) data; + CRecordManager::getInstance()->Update(channel_id); + return res; + } + + else if( msg == NeutrinoMessages::ZAPTO) { + CTimerd::EventInfo * eventinfo = (CTimerd::EventInfo *) data; + if (eventinfo->channel_id != CZapit::getInstance()->GetCurrentChannelID()){ + if( (recordingstatus == 0) || (recordingstatus && CRecordManager::getInstance()->TimeshiftOnly()) || (recordingstatus && CFEManager::getInstance()->haveFreeFrontend()) || + (recordingstatus && channelList->SameTP(eventinfo->channel_id)) ) { + bool isTVMode = CServiceManager::getInstance()->IsChannelTVChannel(eventinfo->channel_id); + + dvbsub_stop(); + + if ((!isTVMode) && (mode != mode_radio)) { + radioMode(false); + } + else if (isTVMode && (mode != mode_tv)) { + tvMode(false); + } + channelList->zapTo_ChannelID(eventinfo->channel_id); + } + } + delete[] (unsigned char*) data; + return messages_return::handled; + } + else if( msg == NeutrinoMessages::ANNOUNCE_ZAPTO) { + if( mode == mode_standby ) { + standbyMode( false ); + } + if( mode != mode_scart ) { + CTimerd::RecordingInfo * eventinfo = (CTimerd::RecordingInfo *) data; + std::string name = g_Locale->getText(LOCALE_ZAPTOTIMER_ANNOUNCE); + getAnnounceEpgName( eventinfo, name); + ShowHintUTF( LOCALE_MESSAGEBOX_INFO, name.c_str() ); + } + delete [] (unsigned char*) data; + return messages_return::handled; + } + else if( msg == NeutrinoMessages::ANNOUNCE_RECORD) { + my_system(NEUTRINO_RECORDING_TIMER_SCRIPT); + CTimerd::RecordingInfo * eventinfo = (CTimerd::RecordingInfo *) data; + if (g_settings.recording_type == RECORDING_FILE) { + char * recordingDir = eventinfo->recordingDir; + for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { + if (strcmp(g_settings.network_nfs_local_dir[i],recordingDir) == 0) { + printf("[neutrino] waking up %s (%s)\n",g_settings.network_nfs_ip[i].c_str(),recordingDir); + if(my_system("ether-wake",g_settings.network_nfs_mac[i]) != 0) + perror("ether-wake failed"); + break; + } + } + if(has_hdd) { + wakeup_hdd(g_settings.network_nfs_recordingdir); + } + } + + if( g_settings.recording_zap_on_announce && (mode != mode_standby) && (eventinfo->channel_id != CZapit::getInstance()->GetCurrentChannelID())) { + CRecordManager::getInstance()->StopAutoRecord(); + bool recordingStatus = CRecordManager::getInstance()->RecordingStatus(); + if ( !recordingStatus || (recordingStatus && CRecordManager::getInstance()->TimeshiftOnly()) || (recordingStatus && CFEManager::getInstance()->haveFreeFrontend()) || + (recordingStatus && channelList->SameTP(eventinfo->channel_id)) ){ + dvbsub_stop(); + t_channel_id channel_id=eventinfo->channel_id; + g_Zapit->zapTo_serviceID_NOWAIT(channel_id); + } + } + if(( mode != mode_scart ) && ( mode != mode_standby )){ + std::string name = g_Locale->getText(LOCALE_RECORDTIMER_ANNOUNCE); + getAnnounceEpgName(eventinfo, name); + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, name.c_str()); + } + delete[] (unsigned char*) data; + return messages_return::handled; + } + else if( msg == NeutrinoMessages::ANNOUNCE_SLEEPTIMER) { + if( mode != mode_scart && mode != mode_standby) + skipSleepTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); + return messages_return::handled; + } + else if( msg == NeutrinoMessages::SLEEPTIMER) { + if(data) {//INACTIVITY SLEEPTIMER + skipShutdownTimer = + (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE, + CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);//FIXME + if(skipShutdownTimer) { + printf("NeutrinoMessages::INACTIVITY SLEEPTIMER: skiping\n"); + skipShutdownTimer = false; + return messages_return::handled; + } + }else{ //MAIN-MENU SLEEPTIMER + if(skipSleepTimer) { + printf("NeutrinoMessages::SLEEPTIMER: skiping\n"); + skipSleepTimer = false; + return messages_return::handled; + } + } + if(g_settings.shutdown_real) + ExitRun(true, (cs_get_revision() > 7)); + else if(mode != mode_standby) + standbyMode( true ); + return messages_return::handled; + } + else if( msg == NeutrinoMessages::RELOAD_SETUP ) { + bool tmp = g_settings.make_hd_list; + loadSetup(NEUTRINO_SETTINGS_FILE); + if(tmp != g_settings.make_hd_list) + g_Zapit->reinitChannels(); + + return messages_return::handled; + } + else if( msg == NeutrinoMessages::STANDBY_TOGGLE ) { + standbyMode( !(mode & mode_standby) ); + g_RCInput->clearRCMsg(); + return messages_return::handled; + } + else if( msg == NeutrinoMessages::STANDBY_ON ) { + if( mode != mode_standby ) { + standbyMode( true ); + } + g_RCInput->clearRCMsg(); + return messages_return::handled; + } + else if( msg == NeutrinoMessages::STANDBY_OFF ) { + if( mode == mode_standby ) { + standbyMode( false ); + } + g_RCInput->clearRCMsg(); + return messages_return::handled; + } + else if( msg == NeutrinoMessages::ANNOUNCE_SHUTDOWN) { + if( mode != mode_scart ) + skipShutdownTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 5) == CMessageBox::mbrYes); + } + else if( msg == NeutrinoMessages::SHUTDOWN ) { + if(!skipShutdownTimer) { + ExitRun(true, (cs_get_revision() > 7)); + } + else { + skipShutdownTimer=false; + } + return messages_return::handled; + } + else if( msg == NeutrinoMessages::REBOOT ) { + FILE *f = fopen("/tmp/.reboot", "w"); + fclose(f); + ExitRun(true); + } + else if (msg == NeutrinoMessages::EVT_POPUP || msg == NeutrinoMessages::EVT_EXTMSG) { + if (mode != mode_scart) { + std::string timeout="-1"; + std::string text = (char*)data; + std::string::size_type pos; + + pos = text.find("&timeout=", 0); + if (pos != std::string::npos) { + timeout = text.substr( pos+9, text.length()+1 ); + text[pos] = '\0'; + } + + if (msg == NeutrinoMessages::EVT_POPUP) + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, text.c_str(), 0, atoi(timeout.c_str())); + else if (msg == NeutrinoMessages::EVT_EXTMSG) + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO, 0, atoi(timeout.c_str())); + + } + delete[] (unsigned char*) data; + return messages_return::handled; + } + else if (msg == NeutrinoMessages::EVT_RECORDING_ENDED) { + /* FIXME TODO, when/if needed, monitor record status somewhere + * and report possible error to user if any with this message ? + * not used/not supported for now */ + //delete[] (unsigned char*) data; + + return messages_return::handled; + } + else if( msg == NeutrinoMessages::REMIND) { + std::string text = (char*)data; + std::string::size_type pos; + while((pos=text.find('/'))!= std::string::npos) + { + text[pos] = '\n'; + } + if( mode != mode_scart ) + ShowMsgUTF(LOCALE_TIMERLIST_TYPE_REMIND, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + delete[] (unsigned char*) data; + return messages_return::handled; + } + else if (msg == NeutrinoMessages::LOCK_RC) + { + CRCLock rcLock; + rcLock.exec(NULL,CRCLock::NO_USER_INPUT); + return messages_return::handled; + } + else if( msg == NeutrinoMessages::CHANGEMODE ) { + + if((data & mode_mask)== mode_radio) { + if( mode != mode_radio ) { + radioMode((data & norezap) != norezap); + } + } + if((data & mode_mask)== mode_tv) { + if( mode != mode_tv ) { + tvMode((data & norezap) != norezap); + } + } + if((data & mode_mask)== mode_standby) { + if(mode != mode_standby) + standbyMode( true ); + } + if((data & mode_mask)== mode_audio) { + lastMode=mode; + mode=mode_audio; + } + if((data & mode_mask)== mode_pic) { + lastMode=mode; + mode=mode_pic; + } + if((data & mode_mask)== mode_ts && CMoviePlayerGui::getInstance().Playing()) { + if(mode == mode_radio) + videoDecoder->StopPicture(); + lastMode=mode; + mode=mode_ts; + } + } + else if( msg == NeutrinoMessages::VCR_ON ) { + if( mode != mode_scart ) { + scartMode( true ); + } + else + CVFD::getInstance()->setMode(CVFD::MODE_SCART); + } + + else if( msg == NeutrinoMessages::VCR_OFF ) { + if( mode == mode_scart ) { + scartMode( false ); + } + } + else if (msg == NeutrinoMessages::EVT_START_PLUGIN) { + g_PluginList->startPlugin((const char *)data); + if (!g_PluginList->getScriptOutput().empty()) { + ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + } + + delete[] (unsigned char*) data; + return messages_return::handled; + } + else if (msg == NeutrinoMessages::EVT_SERVICES_UPD) { + SDTreloadChannels = true; + g_InfoViewer->SDT_freq_update = true; + if( !g_InfoViewer->is_visible && !autoshift){ + g_RCInput->postMsg(NeutrinoMessages::SHOW_INFOBAR , 0); + } + return messages_return::handled; +// ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EXTRA_ZAPIT_SDT_CHANGED), +// CMessageBox::mbrBack,CMessageBox::mbBack, NEUTRINO_ICON_INFO); + } + if ((msg >= CRCInput::RC_WithData) && (msg < CRCInput::RC_WithData + 0x10000000)) + delete [] (unsigned char*) data; + + return messages_return::unhandled; +} + +extern time_t timer_minutes;//timermanager.cpp +extern bool timer_is_rec;//timermanager.cpp + +void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode) +{ + bool do_shutdown = true; + + CRecordManager::getInstance()->StopAutoRecord(); + if(CRecordManager::getInstance()->RecordingStatus()) { + do_shutdown = + (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECODING_QUERY, CMessageBox::mbrNo, + CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); + } + + if(do_shutdown) { + if(SDTreloadChannels){ + SDT_ReloadChannels(); + //SDTreloadChannels = false; + } + + + delete CRecordManager::getInstance(); + + dprintf(DEBUG_INFO, "exit\n"); + StopSubtitles(); + g_Zapit->stopPlayBack(); + + frameBuffer->paintBackground(); + videoDecoder->ShowPicture(DATADIR "/neutrino/icons/shutdown.jpg"); + + if(g_settings.epg_save /* && timeset && g_Sectionsd->getIsTimeSet ()*/) { + saveEpg(true);// true CVFD::MODE_SHUTDOWN + } + CVFD::getInstance()->setMode(CVFD::MODE_SHUTDOWN); + + stop_daemons(true /*retcode*/);//need here for timer_is_rec before saveSetup + g_settings.shutdown_timer_record_type = timer_is_rec; + saveSetup(NEUTRINO_SETTINGS_FILE); + + if(retcode) { + puts("[neutrino.cpp] executing " NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT "."); + if (my_system(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT) != 0) + perror(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT " failed"); + + printf("entering off state\n"); + mode = mode_off; + //CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_MAINMENU_SHUTDOWN)); + + my_system("/etc/init.d/rcK"); + sync(); + my_system("/bin/umount", "-a"); + sleep(1); + { + standby_data_t standby; + time_t mtime = time(NULL); + struct tm *tmtime = localtime(&mtime); + time_t fp_timer = 0; + + if(timer_minutes) { + fp_timer = timer_minutes - mtime/60; + if(fp_timer < 1) + fp_timer = 1; + } + printf("now: %ld, timer %ld, FP timer %ldmin\n", mtime/60, timer_minutes, fp_timer);fflush(stdout); + int leds = 0x40; + switch(g_settings.led_deep_mode){ + case 0: + leds = 0x0;//off leds + break; + case 1: + leds = 0x60;//on led1 & 2 + break; + case 2: + leds = 0x20;//led1 on , 2 off + break; + case 3: + leds = 0x40;//led2 off, 2 on + break; + default: + break; + } + if(leds && g_settings.led_blink && fp_timer) + leds |= 0x80; + + standby.brightness = cs_get_revision() == 10 ? 0 : g_settings.lcd_setting[SNeutrinoSettings::LCD_DEEPSTANDBY_BRIGHTNESS]; + standby.flags = leds; + standby.current_hour = tmtime->tm_hour; + standby.current_minute = tmtime->tm_min; + standby.timer_minutes_hi = fp_timer >> 8;; + standby.timer_minutes_lo = fp_timer & 0xFF; + + stop_video(); + + int fd = open("/dev/display", O_RDONLY); + if (fd < 0) { + perror("/dev/display"); + reboot(LINUX_REBOOT_CMD_RESTART); + } else { + + if (ioctl(fd, IOC_VFD_STANDBY, (standby_data_t *) &standby)) { + perror("IOC_VFD_STANDBY"); + reboot(LINUX_REBOOT_CMD_RESTART); + } else { + while(true) sleep(1); + } + } + } + } else { + delete g_RCInput; + //fan speed + if (g_info.has_fan) { + CFanControlNotifier::setSpeed(0); + } + //CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_MAINMENU_REBOOT)); + stop_video(); + Cleanup(); + //_exit(retcode); + exit(retcode); + } + } +} + +void CNeutrinoApp::saveEpg(bool cvfd_mode) +{ + struct stat my_stat; + if(stat(g_settings.epg_dir.c_str(), &my_stat) == 0){ + if(!cvfd_mode){//skip saveepg in standby mode, if last saveepg time < 15 Min. + std::string index_xml = g_settings.epg_dir.c_str(); + index_xml += "/index.xml"; + time_t t=0; + if(stat(index_xml.c_str(), &my_stat) == 0){ + if(difftime(time(&t), my_stat.st_ctime) < 900){ + return; + } + } + } + printf("[neutrino] Saving EPG to %s...\n", g_settings.epg_dir.c_str()); + + CVFD::getInstance()->Clear(); + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_EPG_SAVING)); + + g_Sectionsd->writeSI2XML(g_settings.epg_dir.c_str()); + + neutrino_msg_t msg; + neutrino_msg_data_t data; + while( true ) { + g_RCInput->getMsg(&msg, &data, 1200); // 120 secs.. + if (( msg == CRCInput::RC_timeout ) || (msg == NeutrinoMessages::EVT_SI_FINISHED)) { + //printf("Msg %x timeout %d EVT_SI_FINISHED %x\n", msg, CRCInput::RC_timeout, NeutrinoMessages::EVT_SI_FINISHED); + CVFD::getInstance()->Clear(); + CVFD::getInstance()->setMode(cvfd_mode ? CVFD::MODE_SHUTDOWN : CVFD::MODE_STANDBY);// true CVFD::MODE_SHUTDOWN , false CVFD::MODE_STANDBY + break; + } else if (!cvfd_mode){ + printf("wait for epg saving, Msg %x \n", (int) msg); + handleMsg(msg, data); + } + } + } +} + +void CNeutrinoApp::tvMode( bool rezap ) +{ + INFO("rezap %d current mode %d", rezap, mode); + if (mode == mode_radio) { + if (g_settings.radiotext_enable && g_Radiotext) { + delete g_Radiotext; + g_Radiotext = NULL; + } + + videoDecoder->StopPicture(); + CVFD::getInstance()->ShowIcon(VFD_ICON_RADIO, false); + StartSubtitles(!rezap); + } + g_InfoViewer->setUpdateTimer(LCD_UPDATE_TIME_TV_MODE); + + g_volume->Init(); + + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + CVFD::getInstance()->ShowIcon(VFD_ICON_TV, true); + + if( mode == mode_standby ) { + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + videoDecoder->Standby(false); + } + + bool stopauto = (mode != mode_ts); + mode = mode_tv; + if(stopauto /*&& autoshift*/) { + //printf("standby on: autoshift ! stopping ...\n"); + CRecordManager::getInstance()->StopAutoRecord(); + //recordingstatus = 0; + } + + frameBuffer->useBackground(false); + frameBuffer->paintBackground(); + + g_RemoteControl->tvMode(); + SetChannelMode(g_settings.channel_mode); + if( rezap ) { + t_channel_id last_chid = CZapit::getInstance()->GetLastTVChannel(); + channelList->setSelected(0xfffffff); /* make sure that zapTo_ChannelID will zap */ + if(CServiceManager::getInstance()->FindChannel(last_chid)) + channelList->zapTo_ChannelID(last_chid); + else + channelList->zapTo(0); + } +#ifdef USEACTIONLOG + g_ActionLog->println("mode: tv"); +#endif +} + +void CNeutrinoApp::scartMode( bool bOnOff ) +{ + //printf( ( bOnOff ) ? "mode: scart on\n" : "mode: scart off\n" ); + + if( bOnOff ) { + // SCART AN + frameBuffer->useBackground(false); + frameBuffer->paintBackground(); + + //g_Controld->setScartMode( 1 ); + CVFD::getInstance()->setMode(CVFD::MODE_SCART); + lastMode = mode; + mode = mode_scart; + } else { + // SCART AUS + //g_Controld->setScartMode( 0 ); + + mode = mode_unknown; + //re-set mode + if( lastMode == mode_radio ) { + radioMode( false ); + } + else if( lastMode == mode_tv ) { + tvMode( false ); + } + else if( lastMode == mode_standby ) { + standbyMode( true ); + } + } +} + +void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) +{ + //static bool wasshift = false; + INFO("%s", bOnOff ? "ON" : "OFF" ); + + if(lockStandbyCall) + return; + + lockStandbyCall = true; + + if( bOnOff ) { + if( mode == mode_scart ) { + //g_Controld->setScartMode( 0 ); + } + g_InfoViewer->setUpdateTimer(0); // delete timer + StopSubtitles(); + if(SDTreloadChannels && !CRecordManager::getInstance()->RecordingStatus()){ + SDT_ReloadChannels(); + //SDTreloadChannels = false; + } + frameBuffer->useBackground(false); + frameBuffer->paintBackground(); + + /* wasshift = */ CRecordManager::getInstance()->StopAutoRecord(); + + if(mode == mode_radio && g_Radiotext) + g_Radiotext->radiotext_stop(); + + + bool stream_status = CStreamManager::getInstance()->StreamStatus(); + if(!fromDeepStandby && !CRecordManager::getInstance()->RecordingStatus() && !stream_status) { + g_Zapit->setStandby(true); + } else { + g_Zapit->stopPlayBack(); + } + + videoDecoder->Standby(true); + + g_Sectionsd->setPauseScanning(!fromDeepStandby); + g_Sectionsd->setServiceChanged(0, false); + + lastMode = mode; + mode = mode_standby; + + if(!CRecordManager::getInstance()->RecordingStatus() ) { + //only save epg when not recording + if(g_settings.epg_save && !fromDeepStandby && g_settings.epg_save_standby) { + saveEpg(false);//false CVFD::MODE_STANDBY + } + } + + if(CVFD::getInstance()->getMode() != CVFD::MODE_STANDBY){ + CVFD::getInstance()->Clear(); + CVFD::getInstance()->setMode(CVFD::MODE_STANDBY); + } + + if(g_settings.mode_clock) { + InfoClock->StopClock(); + } + + //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"); + + if(!CRecordManager::getInstance()->RecordingStatus()) + cpuFreq->SetCpuFreq(g_settings.standby_cpufreq * 1000 * 1000); + + //fan speed + if (g_info.has_fan) + CFanControlNotifier::setSpeed(1); + + frameBuffer->setActive(false); + // Active standby on + powerManager->SetStandby(true, false); + } else { + // Active standby off + cpuFreq->SetCpuFreq(g_settings.cpufreq * 1000 * 1000); + powerManager->SetStandby(false, false); + videoDecoder->Standby(false); + + if(init_cec_setting){ + //init cec settings + CCECSetup cecsetup; + cecsetup.setCECSettings(); + init_cec_setting = false; + } + + if(!recordingstatus && g_settings.ci_standby_reset) { + g_CamHandler->exec(NULL, "ca_ci_reset0"); + g_CamHandler->exec(NULL, "ca_ci_reset1"); + } + frameBuffer->setActive(true); + //fan speed + if (g_info.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"); + + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + g_Zapit->setStandby(false); + /* the old code did: + if(was_record) g_Zapit->startPlayBack() + unfortunately this bypasses the parental PIN code check if a record timer + was set on a locked channel, then the box put in standby and after the + recording started, the box was woken up. + The channelList->setSelected(); channelList->zapTo_ChannelID() sequence + does trigger the PIN check + If the channel is the same (as during a recording), then it will only + check PIN and not zap, so we should be fine here + */ + mode = mode_unknown; + if( lastMode == mode_radio ) { + radioMode( false ); + } else { + /* for standby -> tv mode from radio mode in case of record */ + videoDecoder->StopPicture(); + tvMode( false ); + } + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + if(!recordingstatus) { //only switch to standby_channel_id when not recording + live_channel_id = standby_channel_id; + } + channelList->setSelected(0xfffffff); /* make sure that zapTo_ChannelID will zap */ + channelList->zapTo_ChannelID(live_channel_id); + + g_Sectionsd->setPauseScanning(false); + //g_Sectionsd->setServiceChanged(live_channel_id, true ); + + if(g_settings.mode_clock) + InfoClock->StartClock(); + + g_volume->AudioMute(current_muted, true); + StartSubtitles(); + } + lockStandbyCall = false; +} + +void CNeutrinoApp::radioMode( bool rezap) +{ + //printf("radioMode: rezap %s\n", rezap ? "yes" : "no"); + INFO("rezap %d current mode %d", rezap, mode); + if (mode == mode_tv) { + CVFD::getInstance()->ShowIcon(VFD_ICON_TV, false); + StopSubtitles(); + } + g_InfoViewer->setUpdateTimer(LCD_UPDATE_TIME_RADIO_MODE); + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + CVFD::getInstance()->ShowIcon(VFD_ICON_RADIO, true); + + if( mode == mode_standby ) { + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + videoDecoder->Standby(false); + } + mode = mode_radio; + + CRecordManager::getInstance()->StopAutoRecord(); + + g_RemoteControl->radioMode(); + SetChannelMode(g_settings.channel_mode_radio); + + if (g_settings.radiotext_enable && !g_Radiotext) + g_Radiotext = new CRadioText; + + if( rezap ) { + t_channel_id last_chid = CZapit::getInstance()->GetLastRADIOChannel(); + channelList->setSelected(0xfffffff); /* make sure that zapTo_ChannelID will zap */ + if(CServiceManager::getInstance()->FindChannel(last_chid)) + channelList->zapTo_ChannelID(last_chid); + else + channelList->zapTo(0); + } + videoDecoder->ShowPicture(DATADIR "/neutrino/icons/radiomode.jpg"); +} + +//switching from current mode to tv or radio mode or to optional parameter prev_mode +void CNeutrinoApp::switchTvRadioMode(const int prev_mode) +{ + if (prev_mode != mode_unknown){ + if (prev_mode == mode_tv && mode != mode_tv ) + tvMode(); + else if(prev_mode == mode_radio && mode != mode_radio) + radioMode(); + }else { + if (mode == mode_radio ) + tvMode(); + else if(mode == mode_tv) + radioMode(); + } +} + +//switching clock on or off depends of current displayed or not +void CNeutrinoApp::switchClockOnOff() +{ + if(g_settings.mode_clock) { + g_settings.mode_clock=false; + InfoClock->StopClock(); + } else { + g_settings.mode_clock=true; + InfoClock->StartClock(); + } +} + +/************************************************************************************** +* CNeutrinoApp - exec, menuitem callback (shutdown) * +**************************************************************************************/ + +int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) +{ + // printf("ac: %s\n", actionKey.c_str()); + int returnval = menu_return::RETURN_REPAINT; + + if(actionKey == "help_recording") { + ShowLocalizedMessage(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); + } + else if(actionKey=="shutdown") { + ExitRun(true, 1); + } + else if(actionKey=="reboot") + { + FILE *f = fopen("/tmp/.reboot", "w"); + fclose(f); + ExitRun(true); + unlink("/tmp/.reboot"); + returnval = menu_return::RETURN_NONE; + } + else if (actionKey=="clock_switch") + { + switchClockOnOff(); + returnval = menu_return::RETURN_EXIT_ALL; + } + else if (actionKey=="tv_radio_switch")//used in mainmenu + { + switchTvRadioMode(); + returnval = menu_return::RETURN_EXIT_ALL; + } + else if (actionKey=="tv")//used in mainmenu + { + switchTvRadioMode(mode_tv); + returnval = menu_return::RETURN_EXIT_ALL; + } + else if (actionKey=="radio")//used in mainmenu + { + switchTvRadioMode(mode_radio); + returnval = menu_return::RETURN_EXIT_ALL; + } + else if(actionKey=="scart") { + g_RCInput->postMsg( NeutrinoMessages::VCR_ON, 0 ); + returnval = menu_return::RETURN_EXIT_ALL; + } + else if(actionKey=="savesettings") { + CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MAINSETTINGS_SAVESETTINGSNOW_HINT)); // UTF-8 + hintBox->paint(); + + saveSetup(NEUTRINO_SETTINGS_FILE); + + if(g_settings.cacheTXT) { + tuxtxt_init(); + } else + tuxtxt_close(); + + //g_Sectionsd->setEventsAreOldInMinutes((unsigned short) (g_settings.epg_old_hours*60)); + //g_Sectionsd->setHoursToCache((unsigned short) (g_settings.epg_cache_days*24)); + + hintBox->hide(); + delete hintBox; + } + else if(actionKey=="recording") { + setupRecordingDevice(); + } + else if(actionKey=="reloadplugins") { + CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_GETPLUGINS_HINT)); + hintBox->paint(); + + g_PluginList->loadPlugins(); + + hintBox->hide(); + delete hintBox; + } + else if(actionKey=="restart") { + if (recordingstatus) + DisplayErrorMessage(g_Locale->getText(LOCALE_SERVICEMENU_RESTART_REFUSED_RECORDING)); + else { + CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_RESTART_HINT)); + hintBox->paint(); + + saveSetup(NEUTRINO_SETTINGS_FILE); + + /* this is an ugly mess :-( */ + delete g_RCInput; + delete g_Sectionsd; + delete g_RemoteControl; + delete g_fontRenderer; + + delete hintBox; + + stop_daemons(true); + stop_video(); + /* g_Timerd, g_Zapit and CVFD are used in stop_daemons */ + delete g_Timerd; + delete g_Zapit; //do we really need this? + delete CVFD::getInstance(); + + for(int i = 3; i < 256; i++) + close(i); + execvp(global_argv[0], global_argv); // no return if successful + exit(1); + } + } + else if(actionKey == "moviedir") { + parent->hide(); + + chooserDir(g_settings.network_nfs_moviedir, false, NULL, sizeof(g_settings.network_nfs_moviedir)-1); + + return menu_return::RETURN_REPAINT; + } + else if(actionKey == "movieplugin") { + parent->hide(); + CMenuWidget MoviePluginSelector(LOCALE_MOVIEPLAYER_DEFPLUGIN, NEUTRINO_ICON_FEATURES); + MoviePluginSelector.addItem(GenericMenuSeparator); + + char id[5]; + int cnt = 0; + int enabled_count = 0; + for(unsigned int count=0;count < (unsigned int) g_PluginList->getNumberOfPlugins();count++) { + if (g_PluginList->getType(count)== CPlugins::P_TYPE_TOOL && !g_PluginList->isHidden(count)) { + // zB vtxt-plugins + sprintf(id, "%d", count); + enabled_count++; + MoviePluginSelector.addItem(new CMenuForwarderNonLocalized(g_PluginList->getName(count), true, NULL, MoviePluginChanger, id, CRCInput::convertDigitToKey(count)), (cnt == 0)); + cnt++; + } + } + + MoviePluginSelector.exec(NULL, ""); + return menu_return::RETURN_REPAINT; + } + else if(actionKey == "clearSectionsd") + { + g_Sectionsd->freeMemory(); + } + + return returnval; +} + +/************************************************************************************** +* changeNotify - features menu recording start / stop * +**************************************************************************************/ +bool CNeutrinoApp::changeNotify(const neutrino_locale_t OptionName, void * /*data*/) +{ + if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LANGUAGESETUP_SELECT)) + { + g_Locale->loadLocale(g_settings.language); + return true; + } + return false; +} + +/************************************************************************************** +* Main programm - no function here * +**************************************************************************************/ +void stop_daemons(bool stopall) +{ + dvbsub_close(); + tuxtxt_stop(); + tuxtxt_close(); + + if (g_Radiotext) { + delete g_Radiotext; + g_Radiotext = NULL; + } + printf("httpd shutdown\n"); + pthread_cancel(nhttpd_thread); + pthread_join(nhttpd_thread, NULL); + printf("httpd shutdown done\n"); + CStreamManager::getInstance()->Stop(); + if(stopall) { + printf("timerd shutdown\n"); + g_Timerd->shutdown(); + pthread_join(timer_thread, NULL); + printf("timerd shutdown done\n"); + } +#ifndef DISABLE_SECTIONSD + printf("sectionsd shutdown\n"); + CEitManager::getInstance()->Stop(); + printf("sectionsd shutdown done\n"); +#endif + tuxtx_stop_subtitle(); + printf("zapit shutdown\n"); + if(!stopall && g_settings.hdmi_cec_mode && g_settings.hdmi_cec_standby){ + videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)0); + } + + delete &CMoviePlayerGui::getInstance(); + CZapit::getInstance()->Stop(); + printf("zapit shutdown done\n"); + CVFD::getInstance()->Clear(); + if(stopall) { + if (cpuFreq) + cpuFreq->SetCpuFreq(g_settings.cpufreq * 1000 * 1000); + if (powerManager) { + /* if we were in standby, leave it otherwise, the next + start of neutrino will fail in "_write_gxa" in + framebuffer.cpp + => this is needed because the drivers are crap :( */ + powerManager->SetStandby(false, false); + powerManager->Close(); + delete powerManager; + } + cs_deregister_messenger(); + } +} + +void stop_video() +{ + delete videoDecoder; + delete videoDemux; + delete CFrameBuffer::getInstance(); + cs_api_exit(); +} + +void sighandler (int signum) +{ + signal (signum, SIG_IGN); + switch (signum) { + case SIGTERM: + case SIGINT: + delete CRecordManager::getInstance(); + //CNeutrinoApp::getInstance()->saveSetup(NEUTRINO_SETTINGS_FILE); + stop_daemons(); + stop_video(); + //_exit(0); + exit(0); + default: + break; + } +} + +int main(int argc, char **argv) +{ + setDebugLevel(DEBUG_NORMAL); + signal(SIGTERM, sighandler); // TODO: consider the following + signal(SIGINT, sighandler); // NOTES: The effects of signal() in a multithreaded + signal(SIGHUP, SIG_IGN); // process are unspecified (signal(2)) + /* don't die in streamts.cpp from a SIGPIPE if client disconnects */ + signal(SIGPIPE, SIG_IGN); + + tzset(); + + return CNeutrinoApp::getInstance()->run(argc, argv); +} + +void CNeutrinoApp::loadKeys(const char * fname) +{ + bool res; + CConfigFile & tconfig = configfile; + + if(fname) { + CConfigFile newconfig(',', true); + + res = newconfig.loadConfig(fname); + if(!res) return; + tconfig = newconfig; + } + + //rc-key configuration + g_settings.key_tvradio_mode = tconfig.getInt32( "key_tvradio_mode", CRCInput::RC_nokey ); + g_settings.key_power_off = tconfig.getInt32( "key_power_off", CRCInput::RC_standby ); + + g_settings.key_channelList_pageup = tconfig.getInt32( "key_channelList_pageup", CRCInput::RC_page_up ); + g_settings.key_channelList_pagedown = tconfig.getInt32( "key_channelList_pagedown", CRCInput::RC_page_down ); + g_settings.key_channelList_cancel = tconfig.getInt32( "key_channelList_cancel", CRCInput::RC_home ); + g_settings.key_channelList_sort = tconfig.getInt32( "key_channelList_sort", CRCInput::RC_blue ); + g_settings.key_channelList_addrecord = tconfig.getInt32( "key_channelList_addrecord", CRCInput::RC_red ); + g_settings.key_channelList_addremind = tconfig.getInt32( "key_channelList_addremind", CRCInput::RC_yellow ); + + g_settings.key_list_start = tconfig.getInt32( "key_list_start", CRCInput::RC_nokey ); + g_settings.key_list_end = tconfig.getInt32( "key_list_end", CRCInput::RC_nokey ); + g_settings.key_timeshift = tconfig.getInt32( "key_timeshift", CRCInput::RC_pause ); + g_settings.key_plugin = tconfig.getInt32( "key_plugin", CRCInput::RC_nokey ); + g_settings.key_unlock = tconfig.getInt32( "key_unlock", CRCInput::RC_setup ); + g_settings.key_screenshot = tconfig.getInt32( "key_screenshot", CRCInput::RC_nokey ); + g_settings.key_current_transponder = tconfig.getInt32( "key_current_transponder", CRCInput::RC_games ); + + g_settings.key_quickzap_up = tconfig.getInt32( "key_quickzap_up", CRCInput::RC_up ); + g_settings.key_quickzap_down = tconfig.getInt32( "key_quickzap_down", CRCInput::RC_down ); + g_settings.key_subchannel_up = tconfig.getInt32( "key_subchannel_up", CRCInput::RC_right ); + g_settings.key_subchannel_down = tconfig.getInt32( "key_subchannel_down", CRCInput::RC_left ); + g_settings.key_zaphistory = tconfig.getInt32( "key_zaphistory", CRCInput::RC_home ); + g_settings.key_lastchannel = tconfig.getInt32( "key_lastchannel", CRCInput::RC_0 ); + + g_settings.key_bouquet_up = tconfig.getInt32( "key_bouquet_up", CRCInput::RC_right); + g_settings.key_bouquet_down = tconfig.getInt32( "key_bouquet_down", CRCInput::RC_left); + + g_settings.mpkey_rewind = tconfig.getInt32( "mpkey.rewind", CRCInput::RC_rewind ); + g_settings.mpkey_forward = tconfig.getInt32( "mpkey.forward", CRCInput::RC_forward ); + g_settings.mpkey_pause = tconfig.getInt32( "mpkey.pause", CRCInput::RC_pause ); + g_settings.mpkey_stop = tconfig.getInt32( "mpkey.stop", CRCInput::RC_stop ); + g_settings.mpkey_play = tconfig.getInt32( "mpkey.play", CRCInput::RC_play ); + g_settings.mpkey_audio = tconfig.getInt32( "mpkey.audio", CRCInput::RC_green ); + g_settings.mpkey_time = tconfig.getInt32( "mpkey.time", CRCInput::RC_setup ); + g_settings.mpkey_bookmark = tconfig.getInt32( "mpkey.bookmark", CRCInput::RC_blue ); + g_settings.mpkey_plugin = tconfig.getInt32( "mpkey.plugin", CRCInput::RC_red ); + + /* options */ + g_settings.menu_left_exit = tconfig.getInt32( "menu_left_exit", 0 ); + g_settings.audio_run_player = tconfig.getInt32( "audio_run_player", 1 ); + g_settings.key_click = tconfig.getInt32( "key_click", 1 ); + strcpy(g_settings.repeat_blocker, tconfig.getString("repeat_blocker", "150").c_str()); + strcpy(g_settings.repeat_genericblocker, tconfig.getString("repeat_genericblocker", "100").c_str()); + + g_settings.bouquetlist_mode = tconfig.getInt32( "bouquetlist_mode", 0 ); + g_settings.sms_channel = tconfig.getInt32( "sms_channel", 0 ); + g_settings.mode_left_right_key_tv = tconfig.getInt32( "mode_left_right_key_tv", SNeutrinoSettings::ZAP); +} + +void CNeutrinoApp::saveKeys(const char * fname) +{ + CConfigFile & tconfig = configfile; + if(fname) { + CConfigFile newconfig(',', true); + tconfig = newconfig; + } + //rc-key configuration + tconfig.setInt32( "key_tvradio_mode", g_settings.key_tvradio_mode ); + tconfig.setInt32( "key_power_off", g_settings.key_power_off ); + + tconfig.setInt32( "key_channelList_pageup", g_settings.key_channelList_pageup ); + tconfig.setInt32( "key_channelList_pagedown", g_settings.key_channelList_pagedown ); + tconfig.setInt32( "key_channelList_cancel", g_settings.key_channelList_cancel ); + tconfig.setInt32( "key_channelList_sort", g_settings.key_channelList_sort ); + tconfig.setInt32( "key_channelList_addrecord", g_settings.key_channelList_addrecord ); + tconfig.setInt32( "key_channelList_addremind", g_settings.key_channelList_addremind ); + + tconfig.setInt32( "key_list_start", g_settings.key_list_start ); + tconfig.setInt32( "key_list_end", g_settings.key_list_end ); + tconfig.setInt32( "key_timeshift", g_settings.key_timeshift ); + tconfig.setInt32( "key_plugin", g_settings.key_plugin ); + tconfig.setInt32( "key_unlock", g_settings.key_unlock ); + tconfig.setInt32( "key_screenshot", g_settings.key_screenshot ); + tconfig.setInt32( "key_current_transponder", g_settings.key_current_transponder ); + + tconfig.setInt32( "key_quickzap_up", g_settings.key_quickzap_up ); + tconfig.setInt32( "key_quickzap_down", g_settings.key_quickzap_down ); + tconfig.setInt32( "key_subchannel_up", g_settings.key_subchannel_up ); + tconfig.setInt32( "key_subchannel_down", g_settings.key_subchannel_down ); + tconfig.setInt32( "key_zaphistory", g_settings.key_zaphistory ); + tconfig.setInt32( "key_lastchannel", g_settings.key_lastchannel ); + + tconfig.setInt32( "key_bouquet_up", g_settings.key_bouquet_up ); + tconfig.setInt32( "key_bouquet_down", g_settings.key_bouquet_down ); + + tconfig.setInt32( "mpkey.rewind", g_settings.mpkey_rewind ); + tconfig.setInt32( "mpkey.forward", g_settings.mpkey_forward ); + tconfig.setInt32( "mpkey.pause", g_settings.mpkey_pause ); + tconfig.setInt32( "mpkey.stop", g_settings.mpkey_stop ); + tconfig.setInt32( "mpkey.play", g_settings.mpkey_play ); + tconfig.setInt32( "mpkey.audio", g_settings.mpkey_audio ); + tconfig.setInt32( "mpkey.time", g_settings.mpkey_time ); + tconfig.setInt32( "mpkey.bookmark", g_settings.mpkey_bookmark ); + tconfig.setInt32( "mpkey.plugin", g_settings.mpkey_plugin ); + + tconfig.setInt32( "menu_left_exit", g_settings.menu_left_exit ); + tconfig.setInt32( "audio_run_player", g_settings.audio_run_player ); + tconfig.setInt32( "key_click", g_settings.key_click ); + tconfig.setString( "repeat_blocker", g_settings.repeat_blocker ); + tconfig.setString( "repeat_genericblocker", g_settings.repeat_genericblocker ); + + tconfig.setInt32( "bouquetlist_mode", g_settings.bouquetlist_mode ); + tconfig.setInt32( "sms_channel", g_settings.sms_channel ); + tconfig.setInt32( "mode_left_right_key_tv", g_settings.mode_left_right_key_tv ); + + if(fname) + tconfig.saveConfig(fname); +} + +void CNeutrinoApp::StopSubtitles() +{ + printf("[neutrino] %s\n", __FUNCTION__); + int ttx, dvbpid, ttxpid, ttxpage; + + dvbpid = dvbsub_getpid(); + tuxtx_subtitle_running(&ttxpid, &ttxpage, &ttx); + + if(dvbpid) + dvbsub_pause(); + if(ttx) { + tuxtx_pause_subtitle(true); + frameBuffer->paintBackground(); + } +} + +void CNeutrinoApp::StartSubtitles(bool show) +{ + printf("%s: %s\n", __FUNCTION__, show ? "Show" : "Not show"); + if(!show) + return; + dvbsub_start(0); + tuxtx_pause_subtitle(false); +} + +void CNeutrinoApp::SelectSubtitles() +{ + /* called on NeutrinoMessages::EVT_ZAP_COMPLETE, should be safe to use zapit current channel */ + CZapitChannel * cc = CZapit::getInstance()->GetCurrentChannel(); + + if(!g_settings.auto_subs || cc == NULL) + return; + + for(int i = 0; i < 3; i++) { + if(strlen(g_settings.pref_subs[i]) == 0 || !strcmp(g_settings.pref_subs[i], "none")) + continue; + + std::string temp(g_settings.pref_subs[i]); + + for(int j = 0 ; j < (int)cc->getSubtitleCount() ; j++) { + CZapitAbsSub* s = cc->getChannelSub(j); + if (s->thisSubType == CZapitAbsSub::DVB) { + CZapitDVBSub* sd = reinterpret_cast(s); + std::map::const_iterator it; + for(it = iso639.begin(); it != iso639.end(); ++it) { + if(temp == it->second && sd->ISO639_language_code == it->first) { + printf("CNeutrinoApp::SelectSubtitles: found DVB %s, pid %x\n", sd->ISO639_language_code.c_str(), sd->pId); + dvbsub_stop(); + dvbsub_setpid(sd->pId); + return; + } + } + } + } + for(int j = 0 ; j < (int)cc->getSubtitleCount() ; j++) { + CZapitAbsSub* s = cc->getChannelSub(j); + if (s->thisSubType == CZapitAbsSub::TTX) { + CZapitTTXSub* sd = reinterpret_cast(s); + std::map::const_iterator it; + for(it = iso639.begin(); it != iso639.end(); ++it) { + if(temp == it->second && sd->ISO639_language_code == it->first) { + int page = ((sd->teletext_magazine_number & 0xFF) << 8) | sd->teletext_page_number; + printf("CNeutrinoApp::SelectSubtitles: found TTX %s, pid %x page %03X\n", sd->ISO639_language_code.c_str(), sd->pId, page); + tuxtx_stop_subtitle(); + tuxtx_set_pid(sd->pId, page, (char *) sd->ISO639_language_code.c_str()); + return; + } + } + } + } + } +} + +void CNeutrinoApp::SDT_ReloadChannels() +{ + SDTreloadChannels = false; + //g_Zapit->reinitChannels(); + channelsInit(); + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + channelList->adjustToChannelID(live_channel_id);//FIXME what if deleted ? + if(old_b_id >= 0) { + bouquetList->activateBouquet(old_b_id, false); + old_b_id = -1; + g_RCInput->postMsg(CRCInput::RC_ok, 0); + } +} + +void CNeutrinoApp::getAnnounceEpgName(CTimerd::RecordingInfo * eventinfo, std::string &name) +{ + + name += "\n"; + + std::string zAddData = CServiceManager::getInstance()->GetServiceName(eventinfo->channel_id); + if( zAddData.empty()) { + zAddData = g_Locale->getText(LOCALE_TIMERLIST_PROGRAM_UNKNOWN); + } + + if(eventinfo->epgID!=0) { + CEPGData epgdata; + zAddData += " :\n"; + if (CEitManager::getInstance()->getEPGid(eventinfo->epgID, eventinfo->epg_starttime, &epgdata)) { + zAddData += epgdata.title; + } + else if(strlen(eventinfo->epgTitle)!=0) { + zAddData += eventinfo->epgTitle; + } + } + else if(strlen(eventinfo->epgTitle)!=0) { + zAddData += " :\n"; + zAddData += eventinfo->epgTitle; + } + + name += zAddData; +} + +void CNeutrinoApp::Cleanup() +{ +#ifdef EXIT_CLEANUP + INFO("cleanup..."); + printf("cleanup 10\n");fflush(stdout); + delete g_Sectionsd; g_Sectionsd = NULL; + delete g_Timerd; g_Timerd = NULL; + delete g_Zapit; g_Zapit = NULL; + delete g_RemoteControl; g_RemoteControl = NULL; + + printf("cleanup 11\n");fflush(stdout); + delete g_fontRenderer; g_fontRenderer = NULL; + printf("cleanup 12\n");fflush(stdout); + delete g_PicViewer; g_PicViewer = NULL; + printf("cleanup 13\n");fflush(stdout); + delete g_PluginList; g_PluginList = NULL; + printf("cleanup 16\n");fflush(stdout); + delete g_CamHandler; g_CamHandler = NULL; + printf("cleanup 17\n");fflush(stdout); + delete g_volume; g_volume = NULL; + printf("cleanup 18\n");fflush(stdout); + delete g_EpgData; g_EpgData = NULL; + printf("cleanup 19\n");fflush(stdout); + delete g_InfoViewer; g_InfoViewer = NULL; + printf("cleanup 11\n");fflush(stdout); + delete g_EventList; g_EventList = NULL; + printf("cleanup 12\n");fflush(stdout); + delete g_Locale; g_Locale = NULL; + delete g_videoSettings; g_videoSettings = NULL; + delete g_Radiotext; g_Radiotext = NULL; + + printf("cleanup 13\n");fflush(stdout); + delete audioSetupNotifier; audioSetupNotifier = NULL; + delete MoviePluginChanger; MoviePluginChanger = NULL; + printf("cleanup 14\n");fflush(stdout); + + delete TVbouquetList; TVbouquetList = NULL; + delete RADIObouquetList; RADIObouquetList = NULL; + + delete TVfavList; TVfavList = NULL; + delete RADIOfavList; RADIOfavList = NULL; + + delete TVchannelList; TVchannelList = NULL; + delete RADIOchannelList; RADIOchannelList = NULL; + delete TVallList; TVallList = NULL; + delete RADIOallList; RADIOallList = NULL; + delete TVsatList; TVsatList = NULL; + delete RADIOsatList; RADIOsatList = NULL; + + printf("cleanup 1\n");fflush(stdout); + for (int i = 0; i < FONT_TYPE_COUNT; i++) { + delete g_Font[i]; + g_Font[i] = NULL; + } + printf("cleanup 2\n");fflush(stdout); + delete g_SignalFont; g_SignalFont = NULL; + printf("cleanup 3\n");fflush(stdout); + configfile.clear(); + + printf("cleanup 4\n");fflush(stdout); + delete CZapit::getInstance(); + printf("cleanup 5\n");fflush(stdout); + delete CEitManager::getInstance(); + printf("cleanup 6\n");fflush(stdout); + delete CVFD::getInstance(); + malloc_stats(); +#endif +} diff --git a/src/system/locals.h b/src/system/locals.h index 0ecf8dd6f..01aa97c15 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -232,6 +232,7 @@ typedef enum LOCALE_CHANNELLIST_EPGTEXT_ALIGN_LEFT, LOCALE_CHANNELLIST_EPGTEXT_ALIGN_RIGHT, LOCALE_CHANNELLIST_EXTENDED, + LOCALE_CHANNELLIST_MINITV, LOCALE_CHANNELLIST_FAVS, LOCALE_CHANNELLIST_FOOT, LOCALE_CHANNELLIST_FOOT_FREQ, @@ -763,6 +764,7 @@ typedef enum LOCALE_MENU_HINT_CHANNELLIST_COLORED, LOCALE_MENU_HINT_CHANNELLIST_EPG_ALIGN, LOCALE_MENU_HINT_CHANNELLIST_EXTENDED, + LOCALE_MENU_HINT_CHANNELLIST_MINITV, LOCALE_MENU_HINT_CHANNELLIST_FONTS, LOCALE_MENU_HINT_CHANNELLIST_FOOT, LOCALE_MENU_HINT_CHANNELLIST_SETUP, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 81125c8cf..1e5fd4c65 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -232,6 +232,7 @@ const char * locale_real_names[] = "channellist.epgtext_align_left", "channellist.epgtext_align_right", "channellist.extended", + "channellist.minitv", "channellist.favs", "channellist.foot", "channellist.foot_freq", @@ -763,6 +764,7 @@ const char * locale_real_names[] = "menu.hint_channellist_colored", "menu.hint_channellist_epg_align", "menu.hint_channellist_extended", + "menu.hint_channellist_minitv", "menu.hint_channellist_fonts", "menu.hint_channellist_foot", "menu.hint_channellist_setup", diff --git a/src/system/settings.h b/src/system/settings.h index 29c9ee2fb..cb6261825 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -421,6 +421,7 @@ struct SNeutrinoSettings int channellist_foot; int channellist_new_zap_mode; int channellist_sort_mode; + int channellist_minitv; char repeat_blocker[4]; char repeat_genericblocker[4]; int remote_control_hardware;