+RESULT eServiceEvent::parseFrom(const std::string filename, int tsidonid)
+{
+ if (!filename.empty())
+ {
+ int fd = ::open( filename.c_str(), O_RDONLY );
+ if ( fd > -1 )
+ {
+ __u8 buf[4096];
+ int rd = ::read(fd, buf, 4096);
+ ::close(fd);
+ if ( rd > 12 /*EIT_LOOP_SIZE*/ )
+ {
+ Event ev(buf);
+ parseFrom(&ev, tsidonid);
+ return 0;
+ }
+ }
+ }
+ return -1;
+}
+
+std::string eServiceEvent::getBeginTimeString() const
+{
+ tm t;
+ localtime_r(&m_begin, &t);
+ char tmp[13];
+ snprintf(tmp, 13, "%02d.%02d, %02d:%02d",
+ t.tm_mday, t.tm_mon+1,
+ t.tm_hour, t.tm_min);
+ return std::string(tmp, 12);
+}
+
+RESULT eServiceEvent::getComponentData(ePtr<eComponentData> &dest, int tagnum) const
+{
+ std::list<eComponentData>::const_iterator it =
+ m_component_data.begin();
+ for(;it != m_component_data.end(); ++it)
+ {
+ if ( it->m_componentTag == tagnum )
+ {
+ dest=new eComponentData(*it);
+ return 0;
+ }
+ }
+ dest=0;
+ return -1;
+}
+
+PyObject *eServiceEvent::getComponentData() const
+{
+ ePyObject ret = PyList_New(m_component_data.size());
+ int cnt=0;
+ for (std::list<eComponentData>::const_iterator it(m_component_data.begin()); it != m_component_data.end(); ++it)
+ {
+ ePyObject tuple = PyTuple_New(5);
+ PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(it->m_componentTag));
+ PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(it->m_componentType));
+ PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(it->m_streamContent));
+ PyTuple_SET_ITEM(tuple, 3, PyString_FromString(it->m_iso639LanguageCode.c_str()));
+ PyTuple_SET_ITEM(tuple, 4, PyString_FromString(it->m_text.c_str()));
+ PyList_SET_ITEM(ret, cnt++, tuple);
+ }
+ return ret;
+}
+
+RESULT eServiceEvent::getLinkageService(eServiceReference &service, eServiceReference &parent, int num) const
+{
+ std::list<eServiceReference>::const_iterator it =
+ m_linkage_services.begin();
+ while( it != m_linkage_services.end() && num-- )
+ ++it;
+ if ( it != m_linkage_services.end() )
+ {
+ service = *it;
+ eServiceReferenceDVB &subservice = (eServiceReferenceDVB&) service;
+ eServiceReferenceDVB ¤t = (eServiceReferenceDVB&) parent;
+ subservice.setDVBNamespace(current.getDVBNamespace());
+ if ( current.getParentTransportStreamID().get() )
+ {
+ subservice.setParentTransportStreamID( current.getParentTransportStreamID() );
+ subservice.setParentServiceID( current.getParentServiceID() );
+ }
+ else
+ {
+ subservice.setParentTransportStreamID( current.getTransportStreamID() );
+ subservice.setParentServiceID( current.getServiceID() );
+ }
+ if ( subservice.getParentTransportStreamID() == subservice.getTransportStreamID() &&
+ subservice.getParentServiceID() == subservice.getServiceID() )
+ {
+ subservice.setParentTransportStreamID( eTransportStreamID(0) );
+ subservice.setParentServiceID( eServiceID(0) );
+ }
+ return 0;
+ }
+ service.type = eServiceReference::idInvalid;
+ return -1;
+}
+
+void setServiceEventLanguage(const std::string language)
+{
+ eServiceEvent::setEPGLanguage(language);
+}
+