eString readFile(eString filename) { eString result; eString line; if (strstr(filename.c_str(), (TEMPLATE_DIR).c_str()) != 0) { const char *pch = strrchr(filename.c_str(), '/'); eString filename2 = TEMPLATE_DIR2 + eString(strdup(pch + 1)); if (access(filename2.c_str(), R_OK) == 0) filename = filename2; } if (strstr(filename.c_str(), (HTDOCS_DIR).c_str()) != 0) { const char *pch = strrchr(filename.c_str(), '/'); eString filename2 = HTDOCS_DIR2 + eString(strdup(pch + 1)); if (access(filename2.c_str(), R_OK) == 0) filename = filename2; } ifstream infile(filename.c_str()); if (infile) while (getline(infile, line, '\n')) result += line + "\n"; return result; }
eString eMountPoint::tryCifsMount(const eString& cmd, int linuxExt) { eString rc; if(linuxExt == 0) { // If we don't want linux extensions on cifs, disable it first eDebug("[MOUNT] disabling linux extensions"); eString procCommand = "echo 0 > /proc/fs/cifs/LinuxExtensionsEnabled"; system(procCommand.c_str()); } // Execute the mount command eDebug("[MOUNT] mounting: %s", cmd.c_str()); if(system(cmd.c_str()) != 0) { rc = _("Mount failed"); } if(linuxExt == 0) { // Enable linux extensions afterwards eDebug("[MOUNT] enabling linux extensions"); eString procCommand = "echo 1 > /proc/fs/cifs/LinuxExtensionsEnabled"; system(procCommand.c_str()); } return rc; }
static eString wapEPGDetails(eString serviceRef, eString eventID) { eString result; eService *current = NULL; eString ext_description; std::stringstream record; int eventid; eString description = "No description available"; sscanf(eventID.c_str(), "%x", &eventid); eDebug("[ENIGMA_DYN] getEPGDetails: serviceRef = %s, ID = %04x", serviceRef.c_str(), eventid); // search for the event... to get the description... eDVBServiceController *sapi=eDVB::getInstance()->getServiceAPI(); if (sapi) { eServiceReference ref(string2ref(serviceRef)); current = eDVB::getInstance()->settings->getTransponders()->searchService((eServiceReferenceDVB&)ref); if (current) { EITEvent *event = eEPGCache::getInstance()->lookupEvent((eServiceReferenceDVB&)ref, eventid); if (event) { LocalEventData led; led.getLocalData(event, &description, &ext_description); ext_description.strReplace("\n", "<br/>"); if (!ext_description) ext_description = "No detailed information available"; #ifndef DISABLE_FILE record << "<a href=\"/wap?mode=addTimerEvent" << ",path=" << ref2string(ref) << ",ID=" << std::hex << event->event_id << std::dec << ",start=" << event->start_time << ",duration=" << event->duration << ",descr=" << filter_string(description) << ",channel=" << filter_string(current->service_name) << "\">Record</a>"; #endif delete event; } } } result = readFile(TEMPLATE_DIR + "wapEPGDetails.tmp"); result.strReplace("#EVENT#", filter_string(description)); result.strReplace("#RECORD#", record.str()); result.strReplace("#BODY#", filter_string(ext_description)); return result; }
int eSocket::connectToHost(eString hostname, int port) { sockaddr_in serv_addr; struct hostent *server; int res; if (mystate == Invalid) { /* the socket has been closed, create a new socket descriptor */ int s=socket(AF_INET, SOCK_STREAM, 0); mystate=Idle; setSocket(s, 1, mainloop); } if(socketdesc < 0){ error_(errno); return(-1); } server=gethostbyname(hostname.c_str()); if(server==NULL) { eDebug("can't resolve %s", hostname.c_str()); error_(errno); return(-2); } memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_family=AF_INET; memmove(&serv_addr.sin_addr.s_addr, server->h_addr, server->h_length); serv_addr.sin_port=htons(port); res=::connect(socketdesc, (const sockaddr*)&serv_addr, sizeof(serv_addr)); if ((res < 0) && (errno != EINPROGRESS) && (errno != EINTR)) { eDebug("can't connect to host: %s", hostname.c_str()); close(); error_(errno); return(-3); } if (res < 0) // EINPROGRESS or EINTR { rsn->setRequested(rsn->getRequested()|eSocketNotifier::Write); mystate=Connecting; } else { mystate=Connection; connected_(); } return(0); }
static eString getWapZapContent(eString path) { eString tpath, result; unsigned int pos = 0, lastpos = 0, temp = 0; if ((path.find(";", 0)) == eString::npos) path = ";" + path; while ((pos = path.find(";", lastpos)) != eString::npos) { lastpos = pos + 1; if ((temp = path.find(";", lastpos)) != eString::npos) tpath = path.mid(lastpos, temp - lastpos); else tpath = path.mid(lastpos, strlen(path.c_str()) - lastpos); eServiceReference current_service = string2ref(tpath); eServiceInterface *iface = eServiceInterface::getInstance(); // first pass thru is to get all user bouquets eWapNavigatorListDirectory navlist(result, path, tpath, *iface); Signal1<void, const eServiceReference&> signal; signal.connect(slot(navlist, &eWapNavigatorListDirectory::addEntry)); iface->enterDirectory(current_service, signal); eDebug("entered"); iface->leaveDirectory(current_service); eDebug("exited"); } return result; }
int tcpOpen(eString serverIP, int serverPort, int i) { struct sockaddr_in ads; socklen_t adsLen; int fd = -1; int rc = -1; int retry = 0; memset((char *)&ads, 0, sizeof(ads)); ads.sin_family = AF_INET; ads.sin_addr.s_addr = inet_addr(serverIP.c_str()); ads.sin_port = htons(serverPort); adsLen = sizeof(ads); if ((fd = socket(AF_INET, SOCK_STREAM, 0)) != -1) { fcntl(fd, F_SETFL, O_NONBLOCK); retry = 100 * i; while (retry-- > 0 && rc < 0) { if ((rc = connect(fd, (struct sockaddr *)&ads, adsLen)) < 0) usleep(10000); // 10 milliseconds } if (rc < 0) { close(fd); fd = -1; } } eDebug("[MOVIEPLAYER] tcpOpen: socket fd = %d, waited %d milliseconds", fd, (100 * i - retry) * 10); return fd; }
int eListBoxBase::setProperty(const eString &prop, const eString &value) { if (prop == "noPageMovement") { if (value == "off") flags &= ~flagNoPageMovement; else flags |= flagNoPageMovement; } else if (prop == "noUpDownMovement") { if (value == "off") flags &= ~flagNoUpDownMovement; else flags |= flagNoUpDownMovement; } else if (prop=="activeForegroundColor") colorActiveF=eSkin::getActive()->queryScheme(value); else if (prop=="activeBackgroundColor") colorActiveB=eSkin::getActive()->queryScheme(value); else if (prop=="showEntryHelp") setFlags( flagShowEntryHelp ); else if (prop=="columns") setColumns( value?atoi(value.c_str()):1 ); else return eDecoWidget::setProperty(prop, value); return 0; }
void eWidget::setShortcut(const eString &shortcutname) { if (shortcut) getTLW()->actionListener.remove(this); shortcut=i_shortcutActions->map.findAction(shortcutname.c_str()); if (shortcut) getTLW()->actionListener.push_back(this); }
// Converts non recommended mountpoints like /mnt/server to /media/server and so on eString eNetworkMountMgr::fixNonRecommendedMountpoint(const eString& _mountpoint) { eString fixedMountpoint; eString mountpoint = _mountpoint; // Add leading slash if(mountpoint.left(1) != "/") { // xxx -> /xxx mountpoint = "/" + mountpoint; } // Remove trailing slash if(mountpoint.right(1) == "/") { // /xxx/ -> /xxx mountpoint = mountpoint.left(mountpoint.length() - 1); } if(mountpoint.left(9) == "/var/mnt/") { // /var/mnt/xxx -> /media/xxx fixedMountpoint = "/media/" + mountpoint.mid(9); } else if(mountpoint == "/hdd") { // /hdd -> /media/hdd fixedMountpoint = "/media/hdd"; } else if((mountpoint == "/mnt") || (mountpoint == "/media") || (mountpoint == "/var/mnt")) { // /mnt, /media, /var/mnt -> /media/server1 // Yes, I've seen people mounting on /mnt or /media fixedMountpoint = "/media/server1"; } else if(mountpoint.left(5) == "/hdd/") { // /hdd/xxx -> /media/hdd/xxx fixedMountpoint = "/media/hdd/" + mountpoint.mid(5); } else if(mountpoint.left(5) == "/mnt/") { // /mnt/xxx -> /media/xxx fixedMountpoint = "/media/" + mountpoint.mid(5); } else { // All other mountpoints are right fixedMountpoint = mountpoint; } eDebug("[MOUNT] original mountpoint '%s' -> recommended '%s'", _mountpoint.c_str(), fixedMountpoint.c_str()); return fixedMountpoint; }
int eProgress::setProperty(const eString &prop, const eString &value) { if (prop == "leftColor") left = eSkin::getActive()->queryColor(value); else if (prop == "rightColor") right = eSkin::getActive()->queryColor(value); else if (prop == "start") start = atoi(value.c_str()); else if (prop == "border") border = atoi(value.c_str()); else if (prop == "direction") direction = atoi(value.c_str()); else if (prop == "alphatest" && value == "on") left = gColor(-1); /* make 'left' transparent */ else if (prop == "sliderpixmap") setSliderPixmap(eSkin::getActive()->queryImage(value)); else return eWidget::setProperty(prop, value); return 0; }
off64_t getMovieSize(eString filename) { off64_t size = 0; int slice = 0; struct stat64 s; while (!stat64((filename + (slice ? eString().sprintf(".%03d", slice) : eString(""))).c_str(), &s)) { size += s.st_size; ++slice; } eDebug("[GETMOVIESIZE] %s: %lld", filename.c_str(), size); return size; }
eServerSocket::eServerSocket(eString path, eMainloop *ml) : eSocket(ml, AF_LOCAL) { struct sockaddr_un serv_addr; strRemoteHost = ""; bzero(&serv_addr, sizeof(serv_addr)); serv_addr.sun_family = AF_LOCAL; strcpy(serv_addr.sun_path, path.c_str()); okflag=1; unlink(path.c_str()); if(bind(getDescriptor(), (struct sockaddr *) &serv_addr, sizeof(serv_addr))<0) { eDebug("[SERVERSOCKET] ERROR on bind() (%m)"); okflag=0; } listen(getDescriptor(), 0); rsn->setRequested(eSocketNotifier::Read); }
int eSkin::parseColor(const eString &name, const char* color, gRGB &col) { if (color[0]=='#') { unsigned long vcol=0; if (sscanf(color+1, "%lx", &vcol)!=1) { eDebug("invalid color named \"%s\" (value: %s)", name.c_str(), color+1); return -1; } col.r=(vcol>>16)&0xFF; col.g=(vcol>>8)&0xFF; col.b=vcol&0xFF; col.a=(vcol>>24)&0xFF; } else
void eServiceHandlerExternal::addDirectory(void *node, const eString &filename) { for (unsigned int i = 0; i < extensionDirectoryList.size(); i++) { int matchsize = extensionDirectoryList[i].pattern.length(); if (filename.right(matchsize).upper() == extensionDirectoryList[i].pattern.upper()) { eServiceReference ref(id, 0, filename); ref.descr = _("Start player"); eServiceFileHandler::getInstance()->addReference(node, ref); eDebug("Add directory: %s", filename.c_str()); return; } } }
eLanguageEntry(eListBox<eLanguageEntry>* lb, eString id, eString name) : eListBoxEntry( (eListBox<eListBoxEntry>*)lb), id(id), name(name) { eString language=id; if (id.find('_') != eString::npos) id=id.left(id.find('_')); eString str("country_"); str+=getCountry(id.c_str()); pixmap=eSkin::getActive()->queryImage(str); if (!pixmap) { eDebug("dont find %s use country_missing", str.c_str() ); pixmap=eSkin::getActive()->queryImage(eString("country_missing")); } if (!font.pointSize) font = eSkin::getActive()->queryFont("eListBox.EntryText.normal"); para=0; }
static bool fileSystemIsSupported(eString fsname) { eString s; bool found = false; fsname = fsname.upper(); std::ifstream in("/proc/filesystems", std::ifstream::in); // Note /proc/filesystems has two columns, first column could be "nodev", // the second the real fs. We check both here which doesn't harm eDebug("[MOUNT] looking for %s", fsname.c_str()); while (in >> s) { if (found = (s.upper() == fsname)) break; } in.close(); return found; }
void eMountSelectionComboBox::addCustomDirectory(const eString& directory) { eDebug("eMountSelectionComboBox::addCustomDirectory directory=%s", directory.c_str()); if(customLocationCreated) { removeEntry((void *)(customLocationIndex + 2)); mountInfoList.pop_back(); } new eListBoxEntryText( *this, directory, (void *)(customLocationIndex + 2)); eMountPoint mnt; mnt.localDir = directory; mountInfoList.push_back(mnt); customLocationCreated = true; }
eString getAttribute(eString filename, eString attribute) { eString result = " "; ifstream infile(filename.c_str()); if (infile) { eString buffer; while (getline(infile, buffer, '\n')) { if (buffer.find(attribute + "=") == 0) { result = getRight(buffer, '='); if (result == "") result = " "; break; } } } return result; }
void eServiceHandlerExternal::addFile(void *node, const eString &filename) { for (unsigned int i = 0; i < extensionFileList.size(); i++) { int matchsize = extensionFileList[i].pattern.length(); if (filename.right(matchsize).upper() == extensionFileList[i].pattern.upper()) { eServiceReference ref(id, 0, filename); eString filenamestripped = filename; uint i = filename.find_last_of('/'); if (i != eString::npos) { filenamestripped = filename.mid(i + 1, filename.length()); } ref.descr = filenamestripped.c_str(); eServiceFileHandler::getInstance()->addReference(node, ref); eDebug("Add file: %s", filename.c_str()); return; } } }
int eUnixDomainSocket::connectToPath(eString path) { sockaddr_un serv_addr_un; int res; if (mystate == Invalid) { /* the socket has been closed, create a new socket descriptor */ int s=socket(AF_LOCAL, SOCK_STREAM, 0); mystate=Idle; setSocket(s, 1, mainloop); } if(socketdesc < 0){ error_(errno); return(-1); } memset(&serv_addr_un, 0, sizeof(serv_addr_un)); serv_addr_un.sun_family = AF_LOCAL; strcpy(serv_addr_un.sun_path, path.c_str()); res=::connect(socketdesc, (const sockaddr*)&serv_addr_un, sizeof(serv_addr_un)); if ((res < 0) && (errno != EINPROGRESS) && (errno != EINTR)) { close(); error_(errno); return(-3); } if (res < 0) // EINPROGRESS or EINTR { rsn->setRequested(rsn->getRequested()|eSocketNotifier::Write); mystate=Connecting; } else { mystate=Connection; connected_(); } return(0); }
void eServiceHandlerDVB::startPlayback(const eString &filename, int livemode, bool startpaused) { stopPlayback(); decoder=new eDVRPlayerThread(filename.c_str(), this, livemode,playingPermanentTimeshift); if (startpaused) { decoder->messages.send(eDVRPlayerThread::eDVRPlayerThreadMessage(eDVRPlayerThread::eDVRPlayerThreadMessage::startPaused, livemode)); } else { decoder->messages.send(eDVRPlayerThread::eDVRPlayerThreadMessage(eDVRPlayerThread::eDVRPlayerThreadMessage::start, livemode)); } flags=flagIsSeekable|flagSupportPosition; state= statePlaying; if ( livemode ) flags|=flagStartTimeshift; pcrpid = Decoder::current.pcrpid; // stop pcrpid Decoder::parms.pcrpid = -1; Decoder::Set(); serviceEvent(eServiceEvent(eServiceEvent::evtFlagsChanged) ); if ( livemode ) flags&=~flagStartTimeshift; }
void eMountSelectionComboBox::setCurrentLocation(const eString& directory) { int comboboxIndex = -1; eDebug("eMountSelectionComboBox::setCurrentLocation directory=%s", directory.c_str()); for(unsigned int i=0; i<mountInfoList.size(); ++i) { if(directory == mountInfoList[i].localDir) { comboboxIndex = i; break; } } if(comboboxIndex == -1) { // Directory not found, add a new location addCustomDirectory(directory); comboboxIndex = customLocationIndex + 1; } currentLocation = directory; setCurrent(comboboxIndex); }
eString eMoviePlayer::sout(eString mrl) { eString soutURL = "#"; unsigned int pos = mrl.find_last_of('.'); eString extension = mrl.right(mrl.length() - pos - 1); eString name = "File"; if (mrl.find("dvdsimple:") != eString::npos) { name = "DVD"; extension = "NONE"; } else if (mrl.find("vcd:") != eString::npos) { name = "VCD"; extension = "NONE"; } struct serverConfig server = mpconfig.getServerConfig(); struct videoTypeParms video = mpconfig.getVideoParms(name, extension); eDebug("[MOVIEPLAYER] determine ?sout for mrl: %s", mrl.c_str()); eDebug("[MOVIEPLAYER] transcoding audio: %d, video: %d, subtitles: %d" , video.transcodeAudio, video.transcodeVideo, status.PLG ? status.SUBT : video.soutadd); // add sout (URL encoded) // example (with transcode to mpeg1): // ?sout=#transcode{vcodec=mpgv,vb=2000,acodec=mpga,ab=192,channels=2}:duplicate{dst=std{access=http,mux=ts,url=:8080/dboxstream}} // example (without transcode to mpeg1): // ?sout=#duplicate{dst=std{access=http,mux=ts,url=:8080/dboxstream}} pos = video.videoRatio.find("x"); eString res_horiz = video.videoRatio.left(pos); eString res_vert = video.videoRatio.right(video.videoRatio.length() - pos - 1); eDebug("[MOVIEPLAYER] res_horiz = %s, res_vert = %s", res_horiz.c_str(), res_vert.c_str()); if (video.transcodeVideo || video.transcodeAudio) { soutURL += "transcode{"; if (video.transcodeVideo) { soutURL += "vcodec=" + video.videoCodec; soutURL += ",vb=" + video.videoRate; soutURL += ",width=" + res_horiz; soutURL += ",height=" + res_vert; soutURL += ",fps=" + video.fps; if(status.PLG) { if(status.SUBT) soutURL += ",soverlay"; } else { if (video.soutadd) soutURL += ",soverlay"; } } if (video.transcodeAudio) { if (video.transcodeVideo) soutURL += ","; soutURL += "acodec=mpga,ab=" + video.audioRate + ",channels=2"; } if(status.PLG) { if(status.A_SYNC) soutURL += ",audio-sync"; } else soutURL += ",audio-sync"; soutURL += "}:"; } //soutURL += "duplicate{dst=std{access=http,mux=ts,dst=:" + server.streamingPort + "/dboxstream}}"; soutURL += "standard{access=http,mux=ts,dst=:" + server.streamingPort + "/dboxstream}"; status.A_SYNC=true; status.SUBT = true; eDebug("[MOVIEPLAYER] sout = %s", soutURL.c_str()); return soutURL; }
static int searchforEvent(EITEvent *ev, const eString &search, eString &titlefound, eServiceReferenceDVB &new_ref, int intExactMatch, int intCaseSensitive, int genre) { eString title; eString sFind; int intFound = 0; // Genre Suchkriterium schlägt immer Titelsuche ;) if ( genre != 0) { int Range = 0; switch (genre) { case 32: Range = 36; break; case 48: Range = 51; break; case 64: Range = 75; break; case 80: Range = 85; break; case 96: Range = 102; break; case 112: Range = 123; break; case 128: Range = 131; break; case 144: Range = 151; break; case 160: Range = 167; break; case 176: Range = 179; break; default: break; } for (ePtrList<Descriptor>::iterator d(ev->descriptor); d != ev->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 ( genre < 32 ) { if (genre == ce->content_nibble_level_1*16+ce->content_nibble_level_2) intFound = 1; } else { int genreID = ce->content_nibble_level_1*16+ce->content_nibble_level_2; if ( (genreID >= genre) && (genreID <= Range)) intFound = 1; } } } } if (intFound) { LocalEventData led; led.getLocalData(ev, &title, 0); titlefound = title; } } else { if (search != "") { LocalEventData led; led.getLocalData(ev, &title, 0); titlefound = title; if (intExactMatch || intCaseSensitive) sFind = title; else sFind = title.upper(); if (!intExactMatch) { if (sFind.find(search) != eString::npos) intFound = 1; } else { if (!strcmp(search.c_str(),sFind.c_str())) intFound = 1; } } } if (intFound) { for (ePtrList<Descriptor>::iterator d(ev->descriptor); d != ev->descriptor.end(); ++d) { Descriptor *descriptor=*d; if (descriptor->Tag() == DESCR_LINKAGE) { LinkageDescriptor *ld=(LinkageDescriptor*)descriptor; if (ld->linkage_type==0xB0) { eServiceReferenceDVB MySubService(new_ref.getDVBNamespace(), eTransportStreamID(ld->transport_stream_id), eOriginalNetworkID(ld->original_network_id), eServiceID(ld->service_id), 7); new_ref = MySubService; break; } } } } return intFound; }
const char *getMappingFile() { return mapping_file.c_str(); }
int eWidget::setProperty(const eString &prop, const eString &value) { if (prop=="position") { int v[2], e[2]={0, 0}; if (parent) { e[0]=parent->clientrect.width(); e[1]=parent->clientrect.height(); } int err=parse(value.c_str(), v, e, 2); if (err) return err; move(ePoint(v[0], v[1])); } else if (prop=="cposition") { int v[2], e[2]; e[0]=e[1]=0; if (parent) { e[0]=parent->clientrect.width(); e[1]=parent->clientrect.height(); } int err=parse(value.c_str(), v, e, 2); if (err) return err; cmove(ePoint(v[0], v[1])); } else if (prop=="size") { int v[2], e[2]; e[0]=e[1]=0; if (parent) { e[0]=parent->clientrect.width()-position.x(); e[1]=parent->clientrect.height()-position.y(); } int err=parse(value.c_str(), v, e, 2); if (err) return err; resize(eSize(v[0], v[1])); } else if (prop=="csize") { int v[2], e[2]; e[0]=e[1]=0; if (parent) { e[0]=parent->clientrect.width()-position.x(); e[1]=parent->clientrect.height()-position.y(); } int err=parse(value.c_str(), v, e, 2); if (err) return err; cresize(eSize(v[0], v[1])); } else if (prop=="text") /* { eString text; std::string::const_iterator p(value.begin()); while(*p) { if (*p=='\\') { switch (*(++p)) { case 'n': text+='\n'; break; case 'r': text+='\r'; break; case 't': text+='\t'; break; case 'b': text+='\b'; break; case '\\': text+='\\'; break; default: text+='?'; break; } } else text+=*p; p++; } setText(text); }*/ setText(::gettext(value.c_str())); else if (prop=="helptext") setHelpText(::gettext(value.c_str())); else if (prop=="font") setFont(eSkin::getActive()->queryFont(value)); else if (prop=="name") name=value; else if (prop=="pixmap") { setPixmap(eSkin::getActive()->queryImage(value)); if (pixmap) pixmap->uncompressdata(); } else if (prop=="foregroundColor") setForegroundColor(eSkin::getActive()->queryColor(value)); else if (prop=="backgroundColor") setBackgroundColor(eSkin::getActive()->queryColor(value)); else if (prop=="shortcut") setShortcut(value); else if (prop=="shortcutFocus") setShortcutFocus(parent ? parent->search(value) : 0); else { eFatal("skin property %s does not exist", prop.c_str()); return -ENOENT; } return 0; }
eWapNavigatorListDirectory(eString &result, eString origpath, eString path, eServiceInterface &iface): result(result), origpath(origpath), path(path), iface(iface) { eDebug("path: %s", path.c_str()); }