def GUIdeleteInstance(self, g):
g.setContent(None)
+
+class ServiceList(HTMLComponent, GUIComponent):
+ def __init__(self):
+ GUIComponent.__init__(self)
+ self.l = eListboxServiceContent()
+
+ def GUIcreateInstance(self, priv, parent, skindata):
+ g = eListbox(parent)
+ g.setContent(self.l)
+ return g
+
+ def GUIdeleteInstance(self, g):
+ g.setContent(None)
+
+ def setRoot(self, root):
+ self.l.setRoot(root)
class eConnection: public iObject, public Connection
{
- int ref;
+DECLARE_REF;
+private:
ePtr<iObject> m_owner;
public:
-DEFINE_REF(eConnection);
-public:
eConnection(iObject *owner, const Connection &conn): Connection(conn), m_owner(owner) { };
virtual ~eConnection() { disconnect(); }
};
libenigma_base_a_SOURCES = \
buffer.cpp ebase.cpp econfig.cpp eerror.cpp elock.cpp \
init.cpp message.cpp thread.cpp \
- smartptr.cpp estring.cpp
+ smartptr.cpp estring.cpp connection.cpp
class iObject
{
+private:
+ /* we don't allow the default operator here, as it would break the refcount. */
+ void operator=(const iObject &);
+protected:
+ virtual ~iObject() { }
public:
virtual void AddRef()=0;
virtual void Release()=0;
public:
oRefCount(): ref(0) { }
operator int&() { return ref; }
+ ~oRefCount() {
+#ifdef OBJECT_DEBUG
+ if (ref) eDebug("OBJECT_DEBUG FATAL: %p has %d references!", this, ref); else eDebug("OBJECT_DEBUG refcount ok! (%p)", this);
+#endif
+ }
};
#define DECLARE_REF private: oRefCount ref; public: void AddRef(); void Release();
{
}
+eDVBService &eDVBService::operator=(const eDVBService &s)
+{
+ m_service_name = s.m_service_name;
+ m_provider_name = s.m_provider_name;
+ m_flags = s.m_flags;
+ m_ca = s.m_ca;
+ m_cache = s.m_cache;
+ return *this;
+}
+
DEFINE_REF(eDVBDB);
eDVBDB::eDVBDB()
{
eDVBFrontendParametersSatellite sat;
int frequency, symbol_rate, polarisation, fec, orbital_position, inversion;
- sscanf(line+2, "%d:%d:%d:%d:%d:%d", &frequency, &symbol_rate, &polarisation, &fec, &orbital_position, &inversion);
+ sscanf(line+2, "%d:%d:%d:%d:%d:%d", &frequency, &symbol_rate, &polarisation, &fec, &inversion, &orbital_position);
sat.frequency = frequency;
sat.symbol_rate = symbol_rate;
sat.polarisation = polarisation;
const eServiceReferenceDVB &s = i->first;
fprintf(f, "%04x:%08x:%04x:%04x:%d:%d\n",
s.getServiceID().get(), s.getDVBNamespace().get(),
- s.getOriginalNetworkID().get(), s.getTransportStreamID().get(),
+ s.getTransportStreamID().get(),s.getOriginalNetworkID().get(),
s.getServiceType(),
0);
fprintf(f, "%s\n", i->second->m_service_name.c_str());
- fprintf(f, "p=%s", i->second->m_provider_name.c_str());
+ fprintf(f, "p:%s", i->second->m_provider_name.c_str());
for (std::set<int>::const_iterator ca(i->second->m_ca.begin());
ca != i->second->m_ca.end(); ++ca)
- fprintf(f, ",C=%04x", *ca);
+ fprintf(f, ",C:%04x", *ca);
fprintf(f, "\n");
services++;
}
std::set<int> m_ca;
std::map<int,int> m_cache;
virtual ~eDVBService();
+
+ eDVBService &operator=(const eDVBService &);
};
class ServiceDescriptionTable;
#endif
fd = ::open(filename, O_RDWR);
+ eDebug("eDVBSectionReader has fd %d", fd);
+
if (fd >= 0)
{
notifier=new eSocketNotifier(context, fd, eSocketNotifier::Read);
void eGTable::timeout()
{
- eDebug("timeout!");
+ printf("timeout!\n");
+// eDebug("timeout!");
m_reader->stop();
ready = 1;
error = -1;
else
printf("-");
- printf(" %d/%d\n", avail.size(), max);
+ printf(" %d/%d TID %02x\n", avail.size(), max, data[0]);
if (avail.size() == max)
+ {
+ printf("done!\n");
return 1;
- else
+ } else
return 0;
}
public:
virtual RESULT start(const eDVBSectionFilterMask &mask)=0;
virtual RESULT stop()=0;
virtual RESULT connectRead(const Slot1<void,const __u8*> &read, ePtr<eConnection> &conn)=0;
+ virtual ~iDVBSectionReader() { };
};
#endif
#include <lib/base/eerror.h>
#include <errno.h>
+#define SCAN_eDebug(x...)
+#define SCAN_eDebugNoNewLine(x...)
+
+DEFINE_REF(eDVBScan);
+
eDVBScan::eDVBScan(iDVBChannel *channel): m_channel(channel)
{
if (m_channel->getDemux(m_demux))
- eDebug("scan: failed to allocate demux!");
+ SCAN_eDebug("scan: failed to allocate demux!");
m_channel->connectStateChange(slot(*this, &eDVBScan::stateChange), m_stateChanged_connection);
}
void eDVBScan::SDTready(int err)
{
- eDebug("got sdt");
+ SCAN_eDebug("got sdt");
m_ready |= readySDT;
if (!err)
m_ready |= validSDT;
void eDVBScan::NITready(int err)
{
- eDebug("got nit, err %d", err);
+ SCAN_eDebug("got nit, err %d", err);
m_ready |= readyNIT;
if (!err)
m_ready |= validNIT;
void eDVBScan::BATready(int err)
{
- eDebug("got bat");
+ SCAN_eDebug("got bat");
m_ready |= readyBAT;
if (!err)
m_ready |= validBAT;
(**m_SDT->getSections().begin()).getTransportStreamId(),
hash);
- eDebug("SDT: ");
+ SCAN_eDebug("SDT: ");
ServiceDescriptionTableConstIterator i;
for (i = m_SDT->getSections().begin(); i != m_SDT->getSections().end(); ++i)
processSDT(dvbnamespace, **i);
if (m_ready & validNIT)
{
- eDebug("dumping NIT");
+ SCAN_eDebug("dumping NIT");
NetworkInformationTableConstIterator i;
for (i = m_NIT->getSections().begin(); i != m_NIT->getSections().end(); ++i)
{
for (TransportStreamInfoConstIterator tsinfo(tsinfovec.begin());
tsinfo != tsinfovec.end(); ++tsinfo)
{
- eDebug("TSID: %04x ONID: %04x", (*tsinfo)->getTransportStreamId(),
+ SCAN_eDebug("TSID: %04x ONID: %04x", (*tsinfo)->getTransportStreamId(),
(*tsinfo)->getOriginalNetworkId());
eOriginalNetworkID onid = (*tsinfo)->getOriginalNetworkId();
case SATELLITE_DELIVERY_SYSTEM_DESCRIPTOR:
{
SatelliteDeliverySystemDescriptor &d = (SatelliteDeliverySystemDescriptor&)**desc;
- eDebug("%d kHz, %d%d%d.%d%c %s MOD:%d %d symb/s, fec %d",
+ SCAN_eDebug("%d kHz, %d%d%d.%d%c %s MOD:%d %d symb/s, fec %d",
d.getFrequency(),
(d.getOrbitalPosition()>>12)&0xF,
(d.getOrbitalPosition()>>8)&0xF,
break;
}
default:
- eDebug("descr<%x>", (*desc)->getTag());
+ SCAN_eDebug("descr<%x>", (*desc)->getTag());
break;
}
}
if ((m_ready & readyAll) != readyAll)
return;
- eDebug("channel done!");
+ SCAN_eDebug("channel done!");
m_ch_scanned.push_back(m_ch_current);
nextChannel();
}
RESULT eDVBScan::processSDT(eDVBNamespace dvbnamespace, const ServiceDescriptionTable &sdt)
{
const ServiceDescriptionVector &services = *sdt.getDescriptions();
- eDebug("ONID: %04x", sdt.getOriginalNetworkId());
+ SCAN_eDebug("ONID: %04x", sdt.getOriginalNetworkId());
eDVBChannelID chid(dvbnamespace, sdt.getTransportStreamId(), sdt.getOriginalNetworkId());
for (ServiceDescriptionConstIterator s(services.begin()); s != services.end(); ++s)
{
- eDebugNoNewLine("SID %04x: ", (*s)->getServiceId());
+ SCAN_eDebugNoNewLine("SID %04x: ", (*s)->getServiceId());
eServiceReferenceDVB ref;
ePtr<eDVBService> service = new eDVBService;
case SERVICE_DESCRIPTOR:
{
ServiceDescriptor &d = (ServiceDescriptor&)**desc;
- eDebug("name '%s', provider_name '%s'", d.getServiceName().c_str(), d.getServiceProviderName().c_str());
+ SCAN_eDebug("name '%s', provider_name '%s'", d.getServiceName().c_str(), d.getServiceProviderName().c_str());
service->m_service_name = d.getServiceName();
service->m_provider_name = d.getServiceProviderName();
break;
{
CaIdentifierDescriptor &d = (CaIdentifierDescriptor&)**desc;
const CaSystemIdVector &caids = *d.getCaSystemIds();
- eDebugNoNewLine("CA ");
+ SCAN_eDebugNoNewLine("CA ");
for (CaSystemIdVector::const_iterator i(caids.begin()); i != caids.end(); ++i)
{
- eDebugNoNewLine("%04x ", *i);
+ SCAN_eDebugNoNewLine("%04x ", *i);
service->m_ca.insert(*i);
}
- eDebug("");
+ SCAN_eDebug("");
break;
}
default:
- eDebug("descr<%x>", (*desc)->getTag());
+ SCAN_eDebug("descr<%x>", (*desc)->getTag());
break;
}
}
class eDVBScan: public Object, public iObject
{
+DECLARE_REF;
+private:
/* chid helper functions: */
/* heuristically determine if onid/tsid is valid */
to stay on the same data, however when the current
item is removed, this won't work. you'll be notified
anyway. */
-
+#ifndef SWIG
+protected:
+ friend class eListbox;
virtual void cursorHome()=0;
virtual void cursorEnd()=0;
virtual int cursorMove(int count=1)=0;
/* the following functions always refer to the selected item */
virtual void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)=0;
+#endif
};
class eListbox: public eWidget
#define __lib_gui_elistboxcontent_h
#include <lib/python/python.h>
+#include <lib/gui/elistbox.h>
class eListboxTestContent: public virtual iListboxContent
{
DECLARE_REF;
public:
+
+#ifndef SWIG
+protected:
void cursorHome();
void cursorEnd();
int cursorMove(int count=1);
private:
int m_cursor, m_saved_cursor;
eSize m_size;
+#endif
};
class eListboxStringContent: public virtual iListboxContent
DECLARE_REF;
public:
eListboxStringContent();
+ void setList(std::list<std::string> &list);
+#ifndef SWI
+protected:
void cursorHome();
void cursorEnd();
/* the following functions always refer to the selected item */
void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected);
-
- void setList(std::list<std::string> &list);
private:
typedef std::list<std::string> list;
int m_size;
eSize m_itemsize;
+#endif
};
class eListboxPythonStringContent: public virtual iListboxContent
public:
eListboxPythonStringContent();
~eListboxPythonStringContent();
+
+ void setList(PyObject *list);
+ PyObject *getCurrentSelection();
+#ifndef SWIG
+protected:
void cursorHome();
void cursorEnd();
int cursorMove(int count=1);
/* the following functions always refer to the selected item */
void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected);
-
- void setList(PyObject *list);
-
- PyObject *getCurrentSelection();
-
+
private:
PyObject *m_list;
int m_cursor, m_saved_cursor;
eSize m_itemsize;
+#endif
};
#endif
#include <lib/python/connections.h>
#include <lib/gui/elistbox.h>
#include <lib/gui/elistboxcontent.h>
+#include <lib/service/listboxservice.h>
extern void runMainloop();
%include <lib/gui/ewidgetdesktop.h>
%include <lib/gui/elistbox.h>
%include <lib/gui/elistboxcontent.h>
+%include <lib/service/listboxservice.h>
template<class R> class PSignal0
{
noinst_LIBRARIES = libenigma_service.a
libenigma_service_a_SOURCES = \
- service.cpp servicemp3.cpp servicedvb.cpp servicefs.cpp
+ listboxservice.cpp service.cpp servicemp3.cpp servicedvb.cpp servicefs.cpp
}
};
+ /* the reason we have the servicereference as additional argument is
+ that we don't have to create one object for every entry in a possibly
+ large list, provided that no state information is nessesary to deliver
+ the required information. Anyway - ref *must* be the same as the argument
+ to the info() or getIServiceInformation call! */
class iServiceInformation: public iObject
{
public:
- virtual RESULT getName(std::string &name)=0;
+ virtual RESULT getName(const eServiceReference &ref, std::string &name)=0;
};
typedef ePtr<iServiceInformation> iServiceInformationPtr;
virtual RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr)=0;
virtual RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr)=0;
virtual RESULT list(const eServiceReference &, ePtr<iListableService> &ptr)=0;
+ virtual RESULT info(const eServiceReference &, ePtr<iServiceInformation> &ptr);
};
typedef ePtr<iServiceHandler> iServiceHandlerPtr;
return i->second->list(ref, ptr);
}
+RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iServiceInformation> &ptr)
+{
+ std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
+ if (i == handler.end())
+ {
+ ptr = 0;
+ return -1;
+ }
+ return i->second->info(ref, ptr);
+}
+
RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd)
{
handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
return 0;
}
+ /* default handlers */
+RESULT iServiceHandler::info(const eServiceReference &, ePtr<iServiceInformation> &ptr)
+{
+ ptr = 0;
+ return -1;
+}
+
eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");
RESULT play(const eServiceReference &, iPlayableServicePtr &ptr);
RESULT record(const eServiceReference &, iRecordableServicePtr &ptr);
RESULT list(const eServiceReference &, iListableServicePtr &ptr);
+ RESULT info(const eServiceReference &, ePtr<iServiceInformation> &ptr);
// eServiceCenter
static RESULT getInstance(eServiceCenterPtr &ptr) { ptr = instance; return 0; }
return 0;
}
-RESULT eDVBServicePlay::getName(std::string &name)
+RESULT eDVBServicePlay::getName(const eServiceReference &ref, std::string &name)
{
name = "DVB service";
return 0;
RESULT getIServiceInformation(ePtr<iServiceInformation> &ptr);
// iServiceInformation
- RESULT getName(std::string &name);
+ RESULT getName(const eServiceReference &ref, std::string &name);
};
#endif
#include <sys/stat.h>
#include <unistd.h>
+
+class eServiceFSInformation: public iServiceInformation
+{
+ DECLARE_REF;
+public:
+ RESULT getName(const eServiceReference &ref, std::string &name);
+};
+
+DEFINE_REF(eServiceFSInformation);
+
+RESULT eServiceFSInformation::getName(const eServiceReference &ref, std::string &name)
+{
+ name = ref.path;
+}
+
// eServiceFactoryFS
eServiceFactoryFS::eServiceFactoryFS()
eServiceCenter::getInstance(sc);
if (sc)
sc->addServiceFactory(eServiceFactoryFS::id, this);
+
+ m_service_information = new eServiceFSInformation();
}
eServiceFactoryFS::~eServiceFactoryFS()
return 0;
}
+RESULT eServiceFactoryFS::info(const eServiceReference &ref, ePtr<iServiceInformation> &ptr)
+{
+ ptr = m_service_information;
+ return 0;
+}
+
// eServiceFS
DEFINE_REF(eServiceFS);
RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
+ RESULT info(const eServiceReference &, ePtr<iServiceInformation> &ptr);
+private:
+ ePtr<iServiceInformation> m_service_information;
};
class eServiceFS: public iListableService
eServiceCenter::getInstance(sc);
if (sc)
sc->addServiceFactory(eServiceFactoryMP3::id, this);
+
+ m_service_info = new eServiceMP3Info();
}
eServiceFactoryMP3::~eServiceFactoryMP3()
return -1;
}
-// eServiceMP3
+RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iServiceInformation> &ptr)
+{
+ ptr = m_service_info;
+ return 0;
+}
+
+// eServiceMP3Info
+
+
+// eServiceMP3Info is seperated from eServiceMP3 to give information
+// about unopened files.
+
+// probably eServiceMP3 should use this class as well, and eServiceMP3Info
+// should have a database backend where ID3-files etc. are cached.
+// this would allow listing the mp3 database based on certain filters.
+DEFINE_REF(eServiceMP3Info)
+
+eServiceMP3Info::eServiceMP3Info()
+{
+}
+
+RESULT eServiceMP3Info::getName(const eServiceReference &ref, std::string &name)
+{
+ name = "MP3 file: " + ref.path;
+ return 0;
+}
+
+// eServiceMP3
void eServiceMP3::test_end()
{
RESULT eServiceMP3::getIServiceInformation(ePtr<iServiceInformation>&i) { i = this; return 0; }
-RESULT eServiceMP3::getName(std::string &name)
+RESULT eServiceMP3::getName(const eServiceReference &ref, std::string &name)
{
name = "MP3 File: " + filename;
return 0;
#include <lib/service/iservice.h>
+class eServiceMP3Info ;
+
class eServiceFactoryMP3: public iServiceHandler
{
DECLARE_REF;
RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
+ RESULT info(const eServiceReference &, ePtr<iServiceInformation> &ptr);
+private:
+ ePtr<eServiceMP3Info> m_service_info;
+};
+
+class eServiceMP3Info: public iServiceInformation
+{
+ DECLARE_REF;
+ friend class eServiceFactoryMP3;
+ eServiceMP3Info();
+public:
+ RESULT getName(const eServiceReference &ref, std::string &name);
};
class eServiceMP3: public iPlayableService, public iPauseableService, public iServiceInformation, public Object
RESULT getIServiceInformation(ePtr<iServiceInformation>&);
// iServiceInformation
- RESULT getName(std::string &name);
+ RESULT getName(const eServiceReference &ref, std::string &name);
};
#endif
#include <lib/python/python.h>
#include <lib/python/connections.h>
+#include <lib/gui/elistboxcontent.h>
+
#include <lib/driver/rc.h>
#ifdef OBJECT_DEBUG
}
}
-
-class eMain: public eApplication, public Object
-{
- eInit init;
-public:
- eMain()
- {
- init.setRunlevel(eAutoInitNumbers::main);
- }
-};
-
eWidgetDesktop *wdsk;
// typedef struct _object PyObject;
keyPressed(key.code);
}
+/************************************************/
+#include <lib/dvb/dvb.h>
+#include <lib/dvb/db.h>
+#include <lib/dvb/isection.h>
+#include <lib/dvb/esection.h>
+#include <lib/dvb_si/pmt.h>
+#include <lib/dvb/scan.h>
+#include <unistd.h>
+
+class eMain: public eApplication, public Object
+{
+ eInit init;
+
+ ePtr<eDVBScan> m_scan;
+
+ ePtr<eDVBResourceManager> m_mgr;
+ ePtr<iDVBChannel> m_channel;
+ ePtr<eDVBDB> m_dvbdb;
+
+ void scanEvent(int evt)
+ {
+ eDebug("scan event %d!", evt);
+ if (evt == eDVBScan::evtFinish)
+ {
+ m_scan->insertInto(m_dvbdb);
+ quit(0);
+ }
+ }
+ ePtr<eConnection> m_scan_event_connection;
+public:
+ eMain()
+ {
+ init.setRunlevel(eAutoInitNumbers::main);
+
+#if 0
+ m_dvbdb = new eDVBDB();
+ m_mgr = new eDVBResourceManager();
+
+ eDVBFrontendParametersSatellite fesat;
+
+ fesat.frequency = 11817000; // 12070000;
+ fesat.symbol_rate = 27500000;
+ fesat.polarisation = eDVBFrontendParametersSatellite::Polarisation::Vertical;
+ fesat.fec = eDVBFrontendParametersSatellite::FEC::f3_4;
+ fesat.inversion = eDVBFrontendParametersSatellite::Inversion::Off;
+ fesat.orbital_position = 192;
+
+ eDVBFrontendParameters *fe = new eDVBFrontendParameters();
+
+ fe->setDVBS(fesat);
+
+ if (m_mgr->allocateRawChannel(m_channel))
+ eDebug("shit it failed!");
+
+ eDebug("starting scan...");
+
+ std::list<ePtr<iDVBFrontendParameters> > list;
+
+ list.push_back(fe);
+
+ m_scan = new eDVBScan(m_channel);
+ m_scan->start(list);
+ m_scan->connectEvent(slot(*this, &eMain::scanEvent), m_scan_event_connection);
+#endif
+ }
+
+ ~eMain()
+ {
+ m_scan = 0;
+ }
+};
+
+/************************************************/
+
+
int main(int argc, char **argv)
{
#ifdef OBJECT_DEBUG
#endif
-#if 1
+ ePython python;
eMain main;
+#if 1
ePtr<gFBDC> my_dc;
gFBDC::getInstance(my_dc);
eRCInput::getInstance()->keyEvent.connect(slot(keyEvent));
- ePython python;
-
printf("executing main\n");
python.execute("mytest", "__main__");
+// eApp->exec();
+
return 0;
}
self.session.open(screens["mainMenu"]())
def goEmu(self):
-# self.close(1)
self["title"].setText("EMUs ARE ILLEGAL AND NOT SUPPORTED!")
def goTimeshift(self):
-# self.close(2)
self["title"].setText("JUST PRESS THE YELLOW BUTTON!")
def goHDTV(self):
-# self.close(3)
self["title"].setText("HDTV GREEN FLASHES: ENABLED")
def goClock(self):
b.onClick = [ self.testDialogClick ]
self["okbutton"] = b
self["title"] = Header("Test Dialog - press ok to leave!")
- self["menu"] = MenuList(
- [
- ("MAIN MENU", self.goMain),
- ("EMU SETUP", self.goEmu),
- ("TIMESHIFT SETUP", self.goTimeshift),
- ("HDTV PIP CONFIG", self.goHDTV),
- ("wie spaet ists?!", self.goClock)
- ])
+# self["menu"] = MenuList(
+# [
+# ("MAIN MENU", self.goMain),
+# ("EMU SETUP", self.goEmu),
+# ("TIMESHIFT SETUP", self.goTimeshift),
+# ("HDTV PIP CONFIG", self.goHDTV),
+# ("wie spaet ists?!", self.goClock)
+# ])
+ self["menu"] = ServiceList()
+
+ self["menu"].setRoot(eServiceReference("2:0:1:0:0:0:0:0:0:0:/"))
class mainMenu(Screen):
def __init__(self):