eString filter_string(eString string) { string.strReplace("\xc2\x86",""); string.strReplace("\xc2\x87",""); string.strReplace("\xc2\x8a"," "); string.strReplace("\"", "'"); return string; }
bool eMountPoint::isIdentical(eString mountOn, eString mountDev) { bool found = false; if ((mountOn == localDir) || (mountOn.strReplace("/media/", "/mnt/") == localDir)) { switch (fstype) { case nfsMount: found = (eString().sprintf("%s:%s", remoteHost.c_str(), mountDir.c_str()) == mountDev); if (!found) found = (eString().sprintf("%s:/%s", remoteHost.c_str(), mountDir.c_str()) == mountDev); break; case cifsMount: found = (eString().sprintf("//%s/%s", remoteHost.c_str(), mountDir.c_str()) == mountDev); if (!found) found = (eString().sprintf("//%s/%s", remoteIP.c_str(), mountDir.c_str()) == mountDev); break; case smbMount: found = (eString().sprintf("//%s/%s", remoteHost.upper().c_str(), mountDir.upper().c_str()) == mountDev.upper()); if (!found) found = (eString().sprintf("//%s/%s", remoteIP.c_str(), mountDir.upper().c_str()) == mountDev.upper()); break; #ifdef ENABLE_DEVMOUNTS case deviceMount: found = ((mountOn == localDir) && (mountDev == mountDir) && remoteHost == (eString) ""); break; #endif default: break; } } return found; }
eString XMLify(eString s, eString format) { if (format == "XML") s.strReplace("&", "&"); return s; }
eString unHtmlChars(eString s) { s.strReplace("'", "\'"); s.strReplace(""", "\""); return s; }
eString htmlChars(eString s) { s.strReplace("\'", "'"); s.strReplace("\"", """); return s; }
eString getEITC(eString result, eString format) { eString now_start, now_date, now_time, now_duration, now_text, now_longtext, next_start, next_date, next_time, next_duration, next_text, next_longtext; eServiceReferenceDVB &ref = (eServiceReferenceDVB&)eServiceInterface::getInstance()->service; timeMapPtr pMap = eEPGCache::getInstance()->getTimeMapPtr(ref, 0, 0, 2); if (pMap) { int p = 0; int tsidonid = (ref.getTransportStreamID().get() << 16) | ref.getOriginalNetworkID().get(); for (timeMap::const_iterator It = pMap->begin(); It != pMap->end() && p < 2; It++, p++) { EITEvent event(*It->second, tsidonid, It->second->type,It->second->source); if (p == 0) { if (event.start_time) { now_start = eString().sprintf("%d", (int)event.start_time); tm* t = localtime(&event.start_time); now_time = getTimeStr(t, 0); now_date.sprintf("%02d.%02d.%04d", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900); now_duration.sprintf("%d", (int)(event.duration / 60)); } } if (p == 1) { if (event.start_time) { next_start = eString().sprintf("%d", (int)event.start_time); tm* t = localtime(&event.start_time); next_time = getTimeStr(t, 0); next_date.sprintf("%02d.%02d.%04d", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900); next_duration.sprintf("%d", (int)(event.duration / 60)); } } LocalEventData led; switch (p) { case 0: led.getLocalData(&event, &now_text, &now_longtext); now_longtext.strReplace("\n", "<br/>",UTF8_ENCODING); break; case 1: led.getLocalData(&event, &next_text, &next_longtext); next_longtext.strReplace("\n", "<br/>",UTF8_ENCODING); break; } } } result.strReplace("#NOWSTART#", now_start); result.strReplace("#NOWT#", now_time); result.strReplace("#NOWDATE#", now_date); result.strReplace("#NOWDURATION#", now_duration); if (now_duration) now_duration = "(" + now_duration + ")"; result.strReplace("#NOWD#", now_duration); result.strReplace("#NOWST#", XMLify(filter_string(now_text.strReplace("\"", "'",UTF8_ENCODING)), format)); result.strReplace("#NOWLT#", XMLify(filter_string(now_longtext.strReplace("\"", "'",UTF8_ENCODING)), format)); result.strReplace("#NEXTSTART#", next_start); result.strReplace("#NEXTT#", next_time); result.strReplace("#NEXTDATE#", next_date); result.strReplace("#NEXTDURATION#", next_duration); if (next_duration) next_duration = "(" + next_duration + ")"; result.strReplace("#NEXTD#", next_duration); result.strReplace("#NEXTST#", XMLify(filter_string(next_text.strReplace("\"", "'",UTF8_ENCODING)), format)); result.strReplace("#NEXTLT#", XMLify(filter_string(next_longtext.strReplace("\"", "'",UTF8_ENCODING)), format)); eString curService = getCurService(); eString curServiceRef; eDVBServiceController *sapi = eDVB::getInstance()->getServiceAPI(); if (sapi) curServiceRef = ref2string(sapi->service); eString curSubService = getCurrentSubChannel(curServiceRef); if (curSubService) { if (curService) curService += ": " + curSubService; else curService = curSubService; } result.strReplace("#SERVICENAME#", curService); return result; }
eString getEITC(eString result, eString format) { eString now_start, now_date, now_time, now_duration, now_text, now_longtext, next_start, next_date, next_time, next_duration, next_text, next_longtext; EIT *eit = eDVB::getInstance()->getEIT(); if (eit) { int p = 0; for (ePtrList<EITEvent>::iterator event(eit->events); event != eit->events.end(); ++event) { if (*event) { if (p == 0) { if (event->start_time) { now_start = eString().sprintf("%d", (int)event->start_time); tm* t = localtime(&event->start_time); now_time.sprintf("%02d:%02d", t->tm_hour, t->tm_min); now_date.sprintf("%02d.%02d.%04d", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900); now_duration.sprintf("%d", (int)(event->duration / 60)); } } if (p == 1) { if (event->start_time) { next_start = eString().sprintf("%d", (int)event->start_time); tm* t = localtime(&event->start_time); next_time.sprintf("%02d:%02d", t->tm_hour, t->tm_min); next_date.sprintf("%02d.%02d.%04d", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900); next_duration.sprintf("%d", (int)(event->duration / 60)); } } LocalEventData led; switch (p) { case 0: led.getLocalData(event, &now_text, 0, &now_longtext); break; case 1: led.getLocalData(event, &next_text, 0, &next_longtext); break; } p++; } } eit->unlock(); } result.strReplace("#NOWSTART#", now_start); result.strReplace("#NOWT#", now_time); result.strReplace("#NOWDATE#", now_date); result.strReplace("#NOWDURATION#", now_duration); if (now_duration) now_duration = "(" + now_duration + ")"; result.strReplace("#NOWD#", now_duration); result.strReplace("#NOWST#", XMLify(filter_string(now_text.strReplace("\"", "'")), format)); result.strReplace("#NOWLT#", XMLify(filter_string(now_longtext.strReplace("\"", "'")), format)); result.strReplace("#NEXTSTART#", next_start); result.strReplace("#NEXTT#", next_time); result.strReplace("#NEXTDATE#", next_date); result.strReplace("#NEXTDURATION#", next_duration); if (next_duration) next_duration = "(" + next_duration + ")"; result.strReplace("#NEXTD#", next_duration); result.strReplace("#NEXTST#", XMLify(filter_string(next_text.strReplace("\"", "'")), format)); result.strReplace("#NEXTLT#", XMLify(filter_string(next_longtext.strReplace("\"", "'")), format)); eString curService = getCurService(); eString curServiceRef; eDVBServiceController *sapi = eDVB::getInstance()->getServiceAPI(); if (sapi) curServiceRef = ref2string(sapi->service); eString curSubService = getCurrentSubChannel(curServiceRef); if (curSubService) { if (curService) curService += ": " + curSubService; else curService = curSubService; } result.strReplace("#SERVICENAME#", curService); return result; }