#define __STL_CONFIG_H #include #include "../services/scraper2vdr.h" #include "displaychannelview.h" #include "displayviewelements.h" #include "../libcore/timers.h" #include "../libcore/helpers.h" cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplView) { lastScreenWidth = 0; lastScreenHeight = 0; lastNumAudioTracks = 0; lastAudioChannel = -1; lastTracDesc = ""; lastTrackLang = ""; InitDevices(); DeleteOsdOnExit(); } cDisplayChannelView::~cDisplayChannelView() { } bool cDisplayChannelView::createOsd(void) { cRect osdSize = tmplView->GetOsdSize(); bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(), cOsd::OsdTop() + osdSize.Y(), osdSize.Width(), osdSize.Height()); return ok; } void cDisplayChannelView::DrawBackground(void) { map < string, string > stringTokens; map < string, int > intTokens; DrawViewElement(veBackground, &stringTokens, &intTokens); } void cDisplayChannelView::DrawChannel(cString &number, cString &name, cString &id, bool switching) { map < string, string > stringTokens; map < string, int > intTokens; stringTokens.insert(pair("channelname", *name)); stringTokens.insert(pair("channelnumber", *number)); stringTokens.insert(pair("channelid", *id)); intTokens.insert(pair("switching", switching)); bool logoExisis = imgCache->LogoExists(*id); intTokens.insert(pair("channellogoexists", logoExisis)); DrawViewElement(veChannelInfo, &stringTokens, &intTokens); } void cDisplayChannelView::ClearChannel(void) { ClearViewElement(veChannelInfo); } void cDisplayChannelView::DrawDate(void) { if (!ExecuteViewElement(veDateTime)) { return; } if (DetachViewElement(veDateTime)) { cViewElement *viewElement = GetViewElement(veDateTime); if (!viewElement) { viewElement = new cViewElement(tmplView->GetViewElement(veDateTime), this); viewElement->SetCallback(veDateTime, &cDisplayChannelView::SetDate); AddViewElement(veDateTime, viewElement); viewElement->Start(); } else { if (!viewElement->Starting()) viewElement->Render(); } } else { map < string, string > stringTokens; map < string, int > intTokens; if (!SetDate(false, stringTokens, intTokens)) { return; } ClearViewElement(veDateTime); DrawViewElement(veDateTime, &stringTokens, &intTokens); } } void cDisplayChannelView::DrawTime(void) { if (!ExecuteViewElement(veTime)) { return; } if (DetachViewElement(veTime)) { cViewElement *viewElement = GetViewElement(veTime); if (!viewElement) { viewElement = new cViewElement(tmplView->GetViewElement(veTime), this); viewElement->SetCallback(veTime, &cDisplayChannelView::SetTime); AddViewElement(veTime, viewElement); viewElement->Start(); } else { if (!viewElement->Starting()) viewElement->Render(); } } else { map < string, string > stringTokens; map < string, int > intTokens; if (!SetTime(false, stringTokens, intTokens)) { return; } ClearViewElement(veTime); DrawViewElement(veTime, &stringTokens, &intTokens); } } void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Current, int Total) { if (!ExecuteViewElement(veProgressBar)) { return; } map < string, string > stringTokens; map < string, int > intTokens; stringTokens.insert(pair("start", *start)); stringTokens.insert(pair("stop", *stop)); intTokens.insert(pair("duration", Total)); intTokens.insert(pair("elapsed", Current)); intTokens.insert(pair("remaining", Total - Current)); int liveBuffer = GetLiveBuffer(); if (liveBuffer >= 0) { intTokens.insert(pair("permashift", 1)); intTokens.insert(pair("livebuffer", liveBuffer)); } else { intTokens.insert(pair("permashift", 0)); intTokens.insert(pair("livebuffer", 0)); } ClearProgressBar(); DrawViewElement(veProgressBar, &stringTokens, &intTokens); } void cDisplayChannelView::ClearProgressBar(void) { ClearViewElement(veProgressBar); } void cDisplayChannelView::DrawProgressBarBack(void) { DrawViewElement(veProgressBarBack); } void cDisplayChannelView::ClearProgressBarBack(void) { ClearViewElement(veProgressBarBack); } void cDisplayChannelView::DrawEPGInfo(const cEvent *present, const cEvent *next, bool presentRecording, bool nextRecording) { map < string, string > stringTokens; map < string, int > intTokens; if (present) { stringTokens.insert(pair("currenttitle", (present->Title())?present->Title():"")); stringTokens.insert(pair("currentsubtitle", (present->ShortText())?present->ShortText():"")); stringTokens.insert(pair("currentstart", *present->GetTimeString())); stringTokens.insert(pair("currentstop", *present->GetEndTimeString())); intTokens.insert(pair("currentduration", present->Duration() / 60)); intTokens.insert(pair("currentdurationhours", present->Duration() / 3600)); stringTokens.insert(pair("currentdurationminutes", *cString::sprintf("%.2d", (present->Duration() / 60)%60))); intTokens.insert(pair("currentelapsed", (int)round((time(NULL) - present->StartTime())/60))); intTokens.insert(pair("currentremaining", (int)round((present->EndTime() - time(NULL))/60))); intTokens.insert(pair("currentrecording", presentRecording ? 1 : 0)); intTokens.insert(pair("hasVPS", (bool)present->Vps())); } else { stringTokens.insert(pair("currenttitle", "")); stringTokens.insert(pair("currentsubtitle", "")); stringTokens.insert(pair("currentstart", "")); stringTokens.insert(pair("currentstop", "")); intTokens.insert(pair("currentduration", 0)); intTokens.insert(pair("currentdurationhours", 0)); stringTokens.insert(pair("currentdurationminutes", "")); intTokens.insert(pair("currentelapsed", 0)); intTokens.insert(pair("currentremaining", 0)); intTokens.insert(pair("currentrecording", 0)); intTokens.insert(pair("hasVPS", 0)); } if (next) { stringTokens.insert(pair("nexttitle", (next->Title())?next->Title():"")); stringTokens.insert(pair("nextsubtitle", (next->ShortText())?next->ShortText():"")); stringTokens.insert(pair("nextstart", *next->GetTimeString())); stringTokens.insert(pair("nextstop", *next->GetEndTimeString())); intTokens.insert(pair("nextduration", next->Duration() / 60)); intTokens.insert(pair("nextdurationhours", next->Duration() / 3600)); stringTokens.insert(pair("nextdurationminutes", *cString::sprintf("%.2d", (next->Duration() / 60)%60))); intTokens.insert(pair("nextrecording", nextRecording ? 1 : 0)); } else { stringTokens.insert(pair("nexttitle", "")); stringTokens.insert(pair("nextsubtitle", "")); stringTokens.insert(pair("nextstart", "")); stringTokens.insert(pair("nextstop", "")); intTokens.insert(pair("nextduration", 0)); intTokens.insert(pair("nextdurationhours", 0)); stringTokens.insert(pair("nextdurationminutes", "")); intTokens.insert(pair("nextrecording", 0)); } DrawViewElement(veEpgInfo, &stringTokens, &intTokens); } void cDisplayChannelView::ClearEPGInfo(void) { ClearViewElement(veEpgInfo); } void cDisplayChannelView::DrawStatusIcons(const cChannel *Channel) { if (!ExecuteViewElement(veStatusInfo)) { return; } map < string, int > intTokens; map < string, string > stringTokens; bool isRadio = !Channel->Vpid() && Channel->Apid(0); bool hasVT = Channel->Vpid() && Channel->Tpid(); bool isStereo = Channel->Apid(0); bool isDolby = Channel->Dpid(0); bool isEncrypted = Channel->Ca(); bool isRecording = cRecordControls::Active(); cGlobalSortedTimers SortedTimers;// local and remote timers for (int i = 0; i < SortedTimers.Size() && !isRecording; i++) if (const cTimer *Timer = SortedTimers[i]) if (Timer->Recording()) isRecording = true; intTokens.insert(pair("isRadio", isRadio)); intTokens.insert(pair("hasVT", hasVT)); intTokens.insert(pair("isStereo", isStereo)); intTokens.insert(pair("isDolby", isDolby)); intTokens.insert(pair("isEncrypted", isEncrypted)); intTokens.insert(pair("isRecording", isRecording)); intTokens.insert(pair("newmails", CheckNewMails())); DrawViewElement(veStatusInfo, &stringTokens, &intTokens); } void cDisplayChannelView::ClearStatusIcons(void) { ClearViewElement(veStatusInfo); } void cDisplayChannelView::DrawAudioInfo(void) { if (!ExecuteViewElement(veAudioInfo)) { return; } int numAudioTracks = 0; int audioChannel = -1; string trackDescription = ""; string trackLanguage = ""; cDevice *device = cDevice::PrimaryDevice(); if (device) { numAudioTracks = device->NumAudioTracks(); audioChannel = device->GetAudioChannel(); if (numAudioTracks > 0) { const tTrackId *track = device->GetTrack(device->GetCurrentAudioTrack()); if (track) { trackDescription = track->description ? track->description : ""; trackLanguage = track->language ? track->language : ""; } } } if (lastNumAudioTracks != numAudioTracks || lastAudioChannel != audioChannel || lastTracDesc.compare(trackDescription) || lastTrackLang.compare(trackLanguage)) { lastNumAudioTracks = numAudioTracks; lastAudioChannel = audioChannel; lastTracDesc = trackDescription; lastTrackLang = trackLanguage; map < string, int > intTokens; map < string, string > stringTokens; intTokens.insert(pair("numaudiotracks", numAudioTracks)); intTokens.insert(pair("audiochannel", audioChannel)); stringTokens.insert(pair("trackdesc", trackDescription)); stringTokens.insert(pair("tracklang", trackLanguage)); ClearAudioInfo(); DrawViewElement(veAudioInfo, &stringTokens, &intTokens); } } void cDisplayChannelView::ClearAudioInfo(void) { ClearViewElement(veAudioInfo); } void cDisplayChannelView::DrawEncryptionInfo(int channelSid) { if (!ExecuteViewElement(veEcmInfo)) { return; } map < string, int > intTokens; map < string, string > stringTokens; if (SetEcmInfos(channelSid, stringTokens, intTokens)) { ClearEncryptionInfo(); DrawViewElement(veEcmInfo, &stringTokens, &intTokens); } } void cDisplayChannelView::ClearEncryptionInfo(void) { ClearViewElement(veEcmInfo); } void cDisplayChannelView::DrawScreenResolution(void) { if (!ExecuteViewElement(veScreenResolution)) { return; } int screenWidth = 0; int screenHeight = 0; double aspect = 0; cDevice::PrimaryDevice()->GetVideoSize(screenWidth, screenHeight, aspect); if ((lastScreenWidth == screenWidth) && (lastScreenHeight == screenHeight)) return; if ((screenWidth == 0) && (screenHeight == 0)) return; lastScreenWidth = screenWidth; lastScreenHeight = screenHeight; bool isHD = false; string resName = GetScreenResolutionString(screenWidth, screenHeight, &isHD); bool isWideScreen = false; string aspectName = GetScreenAspectString(aspect, &isWideScreen); map < string, string > stringTokens; map < string, int > intTokens; intTokens.insert(pair("screenwidth", screenWidth)); intTokens.insert(pair("screenheight", screenHeight)); intTokens.insert(pair("isHD", isHD)); intTokens.insert(pair("isWideScreen", isWideScreen)); stringTokens.insert(pair("resolution", resName)); stringTokens.insert(pair("aspect", aspectName)); ClearViewElement(veScreenResolution); DrawViewElement(veScreenResolution, &stringTokens, &intTokens); } void cDisplayChannelView::ClearScreenResolution(void) { ClearViewElement(veScreenResolution); lastScreenWidth = 0; lastScreenHeight = 0; } void cDisplayChannelView::DrawScraperContent(const cEvent *event) { if (!event) { return; } if (!ExecuteViewElement(veScraperContent)) { return; } if (DetachViewElement(veScraperContent)) { cViewElementScraperContent *viewElement = dynamic_cast(GetViewElement(veScraperContent)); if (!viewElement) { viewElement = new cViewElementScraperContent(event, ctPosterBanner, tmplView->GetViewElement(veScraperContent)); AddViewElement(veScraperContent, viewElement); viewElement->Start(); } else { if (!viewElement->Starting()) { viewElement->SetEvent(event); viewElement->Render(); } } } else { map < string, string > stringTokens; map < string, int > intTokens; SetPosterBanner(event, stringTokens, intTokens); ClearScraperContent(); DrawViewElement(veScraperContent, &stringTokens, &intTokens); } } void cDisplayChannelView::ClearScraperContent(void) { ClearViewElement(veScraperContent); } void cDisplayChannelView::DrawSignal(void) { if (!ExecuteViewElement(veSignalQuality)) { return; } if (DetachViewElement(veSignalQuality)) { cViewElement *viewElement = GetViewElement(veSignalQuality); if (!viewElement) { viewElement = new cViewElement(tmplView->GetViewElement(veSignalQuality), this); viewElement->SetCallback(veSignalQuality, &cDisplayChannelView::SetSignal); AddViewElement(veSignalQuality, viewElement); viewElement->Start(); } else { if (!viewElement->Starting()) viewElement->Render(); } } else { map < string, string > stringTokens; map < string, int > intTokens; bool changed = SetSignal(false, stringTokens, intTokens); if (!changed) return; ClearSignal(); DrawViewElement(veSignalQuality, &stringTokens, &intTokens); } } void cDisplayChannelView::DrawSignalBackground(void) { if (!ExecuteViewElement(veSignalQualityBack)) { return; } DrawViewElement(veSignalQualityBack); } void cDisplayChannelView::ClearSignal(void) { ClearViewElement(veSignalQuality); } void cDisplayChannelView::ClearSignalBackground(void) { ClearViewElement(veSignalQualityBack); } void cDisplayChannelView::DrawDevices(bool initial) { if (!ExecuteViewElement(veDevices)) { return; } string mode = tmplView->GetViewElementMode(veDevices); bool light = false; if (!mode.compare("light")) { light = true; } if (DetachViewElement(veDevices)) { cViewElement *viewElement = GetViewElement(veDevices); if (!viewElement) { viewElement = new cViewElementDevices(light, tmplView->GetViewElement(veDevices)); AddViewElement(veDevices, viewElement); viewElement->Start(); } else { if (!viewElement->Starting()) viewElement->Render(); } } else { map < string, string > stringTokens; map < string, int > intTokens; map < string, vector< map< string, string > > > deviceLoopTokens; vector< map< string, string > > devices; bool changed = SetDevices(initial, light, &intTokens, &devices); if (!changed) return; deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices)); ClearDevices(); DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens); } } void cDisplayChannelView::ClearDevices(void) { ClearViewElement(veDevices); } void cDisplayChannelView::DrawChannelGroups(const cChannel *Channel, cString ChannelName) { if (!ExecuteViewElement(veChannelGroup)) { return; } bool separatorExists = imgCache->SeparatorLogoExists(*ChannelName); string separatorPath = separatorExists ? *ChannelName : ""; string prevChannelSep = GetChannelSep(Channel, true); string nextChannelSep = GetChannelSep(Channel, false); bool prevAvailable = (prevChannelSep.size() > 0)?true:false; bool nextAvailable = (nextChannelSep.size() > 0)?true:false; map < string, string > stringTokens; map < string, int > intTokens; intTokens.insert(pair("sepexists", separatorExists)); intTokens.insert(pair("prevAvailable", prevAvailable)); intTokens.insert(pair("nextAvailable", nextAvailable)); stringTokens.insert(pair("group", *ChannelName)); stringTokens.insert(pair("nextgroup", nextChannelSep)); stringTokens.insert(pair("prevgroup", prevChannelSep)); stringTokens.insert(pair("seppath", separatorPath)); ClearViewElement(veChannelGroup); DrawViewElement(veChannelGroup, &stringTokens, &intTokens); } void cDisplayChannelView::ClearChannelGroups(void) { ClearViewElement(veChannelGroup); } string cDisplayChannelView::GetChannelSep(const cChannel *channel, bool prev) { string sepName = ""; const cChannel *sep = prev ? Channels.Prev(channel) : Channels.Next(channel); for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) { if (sep->GroupSep()) { sepName = sep->Name(); break; } } return sepName; } void cDisplayChannelView::DisplayMessage(eMessageType Type, const char *Text) { if (!Text) { ClearViewElement(veMessage); return; } map < string, string > stringTokens; map < string, int > intTokens; stringTokens.insert(pair("text", Text)); intTokens.insert(pair("status", (Type == mtStatus) ? true : false)); intTokens.insert(pair("info", (Type == mtInfo) ? true : false)); intTokens.insert(pair("warning", (Type == mtWarning) ? true : false)); intTokens.insert(pair("error", (Type == mtError) ? true : false)); ClearViewElement(veMessage); DrawViewElement(veMessage, &stringTokens, &intTokens); } void cDisplayChannelView::DrawCustomTokens(void) { if (!ExecuteViewElement(veCustomTokens)) { return; } if (!tmplView) return; if (DetachViewElement(veCustomTokens)) { cViewElement *viewElement = GetViewElement(veCustomTokens); if (!viewElement) { viewElement = new cViewElementCustomTokens(tmplView->GetViewElement(veCustomTokens), tmplView); AddViewElement(veCustomTokens, viewElement); viewElement->Start(); } else { if (!viewElement->Starting()) viewElement->Render(); } } else { map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens(); ClearViewElement(veCustomTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens); } } bool cDisplayChannelView::CustomTokenChange(void) { if (!tmplView) return false; return tmplView->CustomTokenChange(); } void cDisplayChannelView::DrawCurrentWeather(void) { if (!ExecuteViewElement(veCurrentWeather)) { return; } if (DetachViewElement(veCurrentWeather)) { cViewElement *viewElement = GetViewElement(veCurrentWeather); if (!viewElement) { viewElement = new cViewElement(tmplView->GetViewElement(veCurrentWeather), this); viewElement->SetCallback(veCurrentWeather, &cDisplayChannelView::SetCurrentWeatherTokens); AddViewElement(veCurrentWeather, viewElement); viewElement->Start(); } else { if (!viewElement->Starting()) viewElement->Render(); } } else { map < string, string > stringTokens; map < string, int > intTokens; ClearViewElement(veCurrentWeather); if (!SetCurrentWeatherTokens(false, stringTokens, intTokens)){ return; } DrawViewElement(veCurrentWeather, &stringTokens, &intTokens); } }