void getcurepg(const eServiceReference &ref) { // sorry.. at moment we dont show any directory.. or locked service in webif if (ref.isLocked() && pinCheck::getInstance()->pLockActive()) return; time_t now = time(0) + eDVB::getInstance()->time_difference; std::stringstream result; result << std::setfill('0'); eService* current; // we read the default action on timer end int defaultendaction = 0; eConfig::getInstance()->getKey("/enigma/timerenddefaultaction", defaultendaction); eDVBServiceController *sapi = eDVB::getInstance()->getServiceAPI(); if (sapi) { current = eDVB::getInstance()->settings->getTransponders()->searchService(ref); if (current) { eServiceReferenceDVB &dref = (eServiceReferenceDVB&)ref; timeMapPtr evt = eEPGCache::getInstance()->getTimeMapPtr(dref); if (evt) { int tsidonid = (dref.getTransportStreamID().get() << 16) | dref.getOriginalNetworkID().get(); int tablePos = 0; time_t tableTime = start; result << "<tr>" << "<td id=\"channel\" width=\"" << eString().sprintf("%d", channelWidth) << "\">" << "<span class=\"channel\">" << filter_string(current->service_name) << "</span>" << "</td>"; tablePos += CHANNELWIDTH; timeMap::const_iterator It; for (It = evt->begin(); It != evt->end(); ++It) { eString description; eString details; eString genre; int genreCategory, genreSubCat; EITEvent event(*It->second, tsidonid, It->second->type,It->second->source); LocalEventData led; led.getLocalData(&event, &description, &details); details.strReplace("\n", "<br/>",UTF8_ENCODING); genre = ""; genreCategory = 0; //none genreSubCat = 0; //default for (ePtrList<Descriptor>::iterator d(event.descriptor); d != event.descriptor.end(); ++d) { Descriptor *descriptor = *d; if (descriptor->Tag() == DESCR_CONTENT) { ContentDescriptor *cod = (ContentDescriptor *)descriptor; for (ePtrList<descr_content_entry_struct>::iterator ce(cod->contentList.begin()); ce != cod->contentList.end(); ++ce) { if (genreCategory == 0) genreCategory = ce->content_nibble_level_1; genreSubCat = ce->content_nibble_level_2; if (!genre && eChannelInfo::getGenre(genreCategory << 4 | genreSubCat)) genre = gettext(eChannelInfo::getGenre(genreCategory << 4 | genreSubCat).c_str()); } } } if (!genre) genre = _("n/a"); // genre += eString().sprintf("(%d.%d)", genreCategory, genreSubCat); time_t eventStart = adjust2FifteenMinutes(event.start_time); time_t eventEnd = eventStart + adjust2FifteenMinutes(event.duration); int eventDuration = 0; int colUnits = 0; if ((eventStart > end) || (eventEnd < tableTime)) { eventDuration = 0; } else if ((eventStart < tableTime) && (eventEnd > tableTime)) { eventDuration = eventEnd - tableTime; } else if (eventStart == tableTime) { eventDuration = adjust2FifteenMinutes(event.duration); } else if ((eventStart > tableTime) && (eventStart < end)) { eventDuration = eventStart - tableTime; colUnits = eventDuration / 60 / 15; if (colUnits == 1) { eventStart = tableTime; eventDuration += adjust2FifteenMinutes(event.duration); } else { result << "<td colspan=\"" << colUnits << "\"> </td>"; tableTime = eventStart; tablePos += colUnits * 15 * d_min; eventDuration = adjust2FifteenMinutes(event.duration); } } if ((eventDuration > 0) && (eventDuration < 15 * 60)) eventDuration = 15 * 60; if (tableTime + eventDuration > end) eventDuration = end - tableTime; colUnits = eventDuration / 60 / 15; if (colUnits > 0) { result << "<td class=\"genre" << eString().sprintf("%02d", genreCategory) << "\" colspan=\"" << colUnits << "\">"; #ifndef DISABLE_FILE int timeroffsetstart = 0; eConfig::getInstance()->getKey("/enigma/timeroffsetstart", timeroffsetstart); int timeroffsetstop = 0; eConfig::getInstance()->getKey("/enigma/timeroffsetstop", timeroffsetstop); result << "<a href=\"javascript:record('" << ref2string(ref) << "','" << event.start_time - (timeroffsetstart * 60) << "','" << event.duration + (timeroffsetstart * 60) + (timeroffsetstop * 60) << "','"; eString tmp = filter_string(description); tmp.strReplace("\'", "\\\'",UTF8_ENCODING); tmp.strReplace("\"", "\\\"",UTF8_ENCODING); tmp.strReplace("&", "~",UTF8_ENCODING); result << tmp << "','" << filter_string(current->service_name) << "','" << defaultendaction << "')\"><img src=\"timer.gif\" border=\"0\" /></a>" << "  "; #endif tm* t = localtime(&event.start_time); result << std::setfill('0') << "<span class=\"time\">" << std::setw(2) << t->tm_mday << '.' << std::setw(2) << t->tm_mon+1 << ". - " << getTimeStr(t, 0) << ' ' << "</span>" << "<span class=\"duration\">" << " (" << event.duration / 60 << " min)" << "</span>" << "<br />"; if ((eventStart <= now) && (eventEnd >= now)) result << "<a href=\"javascript:switchChannel('" << ref2string(ref) << "', '0', '-1')\">"; result << "<span class=\"event\">" << "<b>" << description << "</b>" << "</span>"; if ((eventStart <= now) && (eventEnd >= now)) result << "</a>"; result << "<br />" << _("Genre") << ": " << genre << "<br />"; if ((eventDuration >= 15 * 60) && (pdaScreen == 0)) { result << "<span class=\"description\">" << filter_string(details) << "</span>"; } result << "</td>\n"; tablePos += colUnits * 15 * d_min; tableTime += eventDuration; } } if (tablePos < tableWidth) result << "<td colspan=\"" << (tableWidth - tablePos) / d_min / 15 << "\"> </td>"; result << "</tr>\n"; } multiEPG += result.str(); } } }
eString getServiceEPG(eString format, eString opts) { eString result, result1, events; std::map<eString, eString> opt = getRequestOptions(opts, '&'); unsigned int entries = 0xFFFFFFFF; if (opt["entries"] != "") entries = atoi(opt["entries"].c_str()); result1 = readFile(TEMPLATE_DIR + format + "ServiceEPG.tmp"); eService* current; eServiceReference ref; // we read the default action on timer end int defaultendaction = 0; eConfig::getInstance()->getKey("/enigma/timerenddefaultaction", defaultendaction); eDVBServiceController *sapi=eDVB::getInstance()->getServiceAPI(); if (sapi) { eString serviceRef = opt["ref"]; ref = (serviceRef) ? string2ref(serviceRef) : sapi->service; current = eDVB::getInstance()->settings->getTransponders()->searchService(ref); if (current) { result1.strReplace("#REFERENCE#", ref2string(ref)); result1.strReplace("#NAME#", filter_string(current->service_name)); eServiceReferenceDVB &rref = (eServiceReferenceDVB&)ref; timeMapPtr evt = eEPGCache::getInstance()->getTimeMapPtr(rref); if (evt) { eString title, description, details, genre; int genreCategory, genreSubCat; timeMap::const_iterator It; int tsidonid = (rref.getTransportStreamID().get() << 16) | rref.getOriginalNetworkID().get(); unsigned int i = 0; for (It = evt->begin(); It != evt->end() && i < entries; ++It) { EITEvent event(*It->second, tsidonid, It->second->type,It->second->source); genre = ""; genreCategory = 0; genreSubCat = 0; LocalEventData led; led.getLocalData(&event, &description, &details); details.strReplace("\n", "<br/>",UTF8_ENCODING); for (ePtrList<Descriptor>::iterator d(event.descriptor); d != event.descriptor.end(); ++d) { Descriptor *descriptor = *d; if (descriptor->Tag() == DESCR_CONTENT) { ContentDescriptor *cod = (ContentDescriptor *)descriptor; for (ePtrList<descr_content_entry_struct>::iterator ce(cod->contentList.begin()); ce != cod->contentList.end(); ++ce) { if (genreCategory == 0) genreCategory = ce->content_nibble_level_1; genreSubCat = ce->content_nibble_level_2; if (!genre && eChannelInfo::getGenre(genreCategory << 4 | genreSubCat)) genre += gettext(eChannelInfo::getGenre(genreCategory << 4 | genreSubCat).c_str()); } } } if (!genre) genre = _("n/a"); // genre += eString().sprintf("(%d.%d)", genreCategory, genreSubCat); tm* t = localtime(&event.start_time); if (format == "XML") { result = readFile(TEMPLATE_DIR + "XMLEPGEntry.tmp"); result.strReplace("#GENRE#", genre); } else { result = readFile(TEMPLATE_DIR + "HTMLEPGEntry.tmp"); result.strReplace("#DURATION_MINUTS#", (eString)" (" + eString().sprintf("%d", (int)event.duration / 60) + (eString)" min)"); result.strReplace("#GENRE#",(eString)_("Genre") + (eString)": " + genre); } result.strReplace("#DURATION#", eString().sprintf("%d", event.duration)); result.strReplace("#NO#", eString().sprintf("%d", i)); result.strReplace("#DATE#", eString().sprintf("%02d.%02d.%04d", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900)); result.strReplace("#TIME#", getTimeStr(t, 0)); eString tmp = filter_string(description); result.strReplace("#DESCRIPTION#", XMLify(tmp, format)); tmp.strReplace("\'", "\\\'",UTF8_ENCODING); tmp.strReplace("\"", "\\\"",UTF8_ENCODING); tmp.strReplace("&", "~",UTF8_ENCODING); result.strReplace("#DESCRIPTIONJS#", XMLify(tmp, format)); result.strReplace("#TIMERENDACTION#", eString().sprintf("%d", defaultendaction)); tmp = filter_string(details); result.strReplace("#DETAILS#", XMLify(tmp, format)); result.strReplace("#GENRECATEGORY#", eString().sprintf("%02d", genreCategory)); result.strReplace("#START#", eString().sprintf("%d", event.start_time)); result.strReplace("#REFERENCE#", ref2string(ref)); tmp = filter_string(current->service_name); result.strReplace("#NAME#", XMLify(tmp, format)); tmp.strReplace("\'", "\\\'",UTF8_ENCODING); tmp.strReplace("\"", "\\\"",UTF8_ENCODING); tmp.strReplace("&", "~",UTF8_ENCODING); result.strReplace("#NAMEJS#", XMLify(tmp, format)); events += result; i++; } } } } result1.strReplace("#BODY#", events); return result1; }
eString getServiceEPG(eString format, eString opts) { eString result, result1, events; std::map<eString, eString> opt = getRequestOptions(opts, '&'); unsigned int entries = 0xFFFFFFFF; if (opt["entries"] != "") entries = atoi(opt["entries"].c_str()); result1 = readFile(TEMPLATE_DIR + format + "ServiceEPG.tmp"); eString description, ext_description, genre; int genreCategory = 0; eService* current; eServiceReference ref; // we read the default action on timer end int defaultendaction = 0; eConfig::getInstance()->getKey("/enigma/timerenddefaultaction", defaultendaction); eDVBServiceController *sapi=eDVB::getInstance()->getServiceAPI(); if (sapi) { eString serviceRef = opt["ref"]; ref = (serviceRef) ? string2ref(serviceRef) : sapi->service; current = eDVB::getInstance()->settings->getTransponders()->searchService(ref); if (current) { result1.strReplace("#REFERENCE#", ref2string(ref)); result1.strReplace("#NAME#", filter_string(current->service_name)); eServiceReferenceDVB &rref = (eServiceReferenceDVB&)ref; eEPGCache::getInstance()->Lock(); const timeMap* evt = eEPGCache::getInstance()->getTimeMap(rref); if (evt) { timeMap::const_iterator It; int tsidonid = (rref.getTransportStreamID().get() << 16) | rref.getOriginalNetworkID().get(); unsigned int i = 0; for (It = evt->begin(); It != evt->end() && i < entries; ++It) { ext_description = ""; EITEvent event(*It->second, tsidonid); for (ePtrList<Descriptor>::iterator d(event.descriptor); d != event.descriptor.end(); ++d) { Descriptor *descriptor = *d; if (descriptor->Tag() == DESCR_EXTENDED_EVENT) ext_description += ((ExtendedEventDescriptor*)descriptor)->text; else if (descriptor->Tag() == DESCR_SHORT_EVENT) description = ((ShortEventDescriptor*)descriptor)->event_name; else if (descriptor->Tag() == DESCR_CONTENT) { genre = ""; genreCategory = 0; ContentDescriptor *cod = (ContentDescriptor *)descriptor; for (ePtrList<descr_content_entry_struct>::iterator ce(cod->contentList.begin()); ce != cod->contentList.end(); ++ce) { if (genreCategory == 0) genreCategory = ce->content_nibble_level_1; if (eChannelInfo::getGenre(genreCategory * 16 + ce->content_nibble_level_2)) { if (!genre) genre += gettext(eChannelInfo::getGenre(genreCategory * 16 + ce->content_nibble_level_2).c_str()); } } } } if (!genre) genre = "n/a"; tm* t = localtime(&event.start_time); if (format == "XML") result = readFile(TEMPLATE_DIR + "XMLEPGEntry.tmp"); else result = readFile(TEMPLATE_DIR + "HTMLEPGEntry.tmp"); result.strReplace("#NO#", eString().sprintf("%d", i)); result.strReplace("#DATE#", eString().sprintf("%02d.%02d.%04d", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900)); result.strReplace("#TIME#", eString().sprintf("%02d:%02d", t->tm_hour, t->tm_min)); result.strReplace("#DURATION#", eString().sprintf("%d", event.duration)); eString tmp = filter_string(description); result.strReplace("#DESCRIPTION#", XMLify(tmp, format)); tmp.strReplace("\'", "\\\'"); tmp.strReplace("\"", "\\\""); tmp.strReplace("&", "~"); result.strReplace("#DESCRIPTIONJS#", XMLify(tmp, format)); result.strReplace("#TIMERENDACTION#", eString().sprintf("%d", defaultendaction)); tmp = filter_string(ext_description); result.strReplace("#DETAILS#", XMLify(tmp, format)); result.strReplace("#GENRE#", genre); result.strReplace("#GENRECATEGORY#", eString().sprintf("%02d", genreCategory)); result.strReplace("#START#", eString().sprintf("%d", event.start_time)); result.strReplace("#REFERENCE#", ref2string(ref)); result.strReplace("#NAME#", filter_string(current->service_name)); events += result; i++; } } eEPGCache::getInstance()->Unlock(); } } result1.strReplace("#BODY#", events); return result1; }