From 54bd4123728628a6f77bad2584b70d1353a91666 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Wed, 9 Feb 2005 22:59:04 +0000 Subject: [PATCH] - fixed console input mode restore - added "scan" component - scan possible from main menu --- components.py | 85 +++++++++++++++++++++++++++-- configure.ac | 2 +- lib/components/Makefile.am | 7 +++ lib/components/scan.cpp | 109 +++++++++++++++++++++++++++++++++++++ lib/components/scan.h | 35 ++++++++++++ lib/driver/rcconsole.cpp | 4 +- lib/dvb/idvb.h | 6 ++ lib/dvb/scan.cpp | 9 ++- lib/dvb/scan.h | 6 +- lib/gui/elistbox.cpp | 1 - lib/python/enigma_python.i | 8 +++ main/Makefile.am | 1 + main/enigma.cpp | 57 +++++-------------- screens.py | 22 ++++++++ skin.py | 7 ++- 15 files changed, 305 insertions(+), 54 deletions(-) create mode 100644 lib/components/Makefile.am create mode 100644 lib/components/scan.cpp create mode 100644 lib/components/scan.h diff --git a/components.py b/components.py index 48bcdaf5..ac4262ea 100644 --- a/components.py +++ b/components.py @@ -27,12 +27,18 @@ class GUISkin: def createGUIScreen(self, parent): for (name, val) in self.items(): self.data[name] = { } - val.GUIcreate(self.data[name], parent, None) + if isinstance(val, GUIComponent): + val.GUIcreate(self.data[name], parent, None) def deleteGUIScreen(self): for (name, val) in self.items(): - w = self.data[name]["instance"] - val.GUIdelete(self.data[name]) + if isinstance(val, GUIComponent): + w = self.data[name]["instance"] + val.GUIdelete(self.data[name]) + try: + val.fix() + except: + pass del self.data[name] # note: you'll probably run into this assert. if this happens, don't panic! @@ -185,7 +191,13 @@ class Button(HTMLComponent, GUIComponent, VariableText): x() return 0 -# html: + def disable(self): + pass + + def enable(self): + pass + +# html: def produceHTML(self): return "\n" @@ -198,6 +210,21 @@ class Button(HTMLComponent, GUIComponent, VariableText): def GUIdeleteInstance(self, g): g.selected.get().remove(self.push) +class Label(HTMLComponent, GUIComponent, VariableText): + def __init__(self, text=""): + GUIComponent.__init__(self) + VariableText.__init__(self) + self.setText(text) + +# html: + def produceHTML(self): + return self.getText() + +# GUI: + def GUIcreateInstance(self, priv, parent, skindata): + g = eLabel(parent) + return g + class Header(HTMLComponent, GUIComponent, VariableText): def __init__(self, message): @@ -224,6 +251,17 @@ class VolumeBar(HTMLComponent, GUIComponent, VariableValue): g.setRange(0, 100) return g +# a general purpose progress bar +class ProgressBar(HTMLComponent, GUIComponent, VariableValue): + def __init__(self): + GUIComponent.__init__(self) + VariableValue.__init__(self) + + def GUIcreateInstance(self, priv, parent, skindata): + g = eSlider(parent) + g.setRange(0, 100) + return g + class MenuList(HTMLComponent, GUIComponent): def __init__(self, list): GUIComponent.__init__(self) @@ -256,3 +294,42 @@ class ServiceList(HTMLComponent, GUIComponent): def setRoot(self, root): self.l.setRoot(root) + +class ServiceScan: + + Idle = 1 + Running = 2 + Done = 3 + Error = 4 + + def scanStatusChanged(self): + if self.state == self.Running: + self.progressbar.setValue(self.scan.getProgress()) + if self.scan.isDone(): + self.state = self.Done + else: + self.text.setText("scan in progress - %d %% done!\n%d services found!" % (self.scan.getProgress(), self.scan.getNumServices())) + + if self.state == self.Done: + self.text.setText("scan done!") + + if self.state == self.Error: + self.text.setText("ERROR - failed to scan!") + + def __init__(self, progressbar, text): + self.progressbar = progressbar + self.text = text + self.scan = eComponentScan() + if self.scan.start(): + self.state = self.Error + else: + self.state = self.Running + self.scan.statusChanged.get().append(self.scanStatusChanged) + self.scanStatusChanged() + + def isDone(self): + return self.state == self.Done + + def fix(self): + self.scan.statusChanged.get().remove(self.scanStatusChanged) + \ No newline at end of file diff --git a/configure.ac b/configure.ac index 5f118f8c..ca7a7064 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,6 @@ lib/nav/Makefile lib/network/Makefile lib/python/Makefile lib/service/Makefile +lib/components/Makefile main/Makefile ]) - diff --git a/lib/components/Makefile.am b/lib/components/Makefile.am new file mode 100644 index 00000000..d40a1667 --- /dev/null +++ b/lib/components/Makefile.am @@ -0,0 +1,7 @@ +INCLUDES = \ + -I$(top_srcdir)/include + +noinst_LIBRARIES = libenigma_components.a + +libenigma_components_a_SOURCES = scan.cpp + \ No newline at end of file diff --git a/lib/components/scan.cpp b/lib/components/scan.cpp new file mode 100644 index 00000000..4d8d8b78 --- /dev/null +++ b/lib/components/scan.cpp @@ -0,0 +1,109 @@ +#include +#include +#include +#include +#include + +DEFINE_REF(eComponentScan); + +void eComponentScan::scanEvent(int evt) +{ + eDebug("scan event %d!", evt); + + if (evt == eDVBScan::evtFinish) + { + m_done = 1; + ePtr db; + ePtr res; + + int err; + if ((err = eDVBResourceManager::getInstance(res)) != 0) + { + eDebug("no resource manager"); + return; + } + if ((err = res->getChannelList(db)) != 0) + { + eDebug("no channel list"); + return; + } + + m_scan->insertInto(db); + + eDebug("scan done!"); + } + + statusChanged(); +} + +eComponentScan::eComponentScan(): m_done(-1) +{ +} + +eComponentScan::~eComponentScan() +{ +} + +int eComponentScan::start() +{ + if (m_done != -1) + return -1; + + m_done = 0; + ePtr mgr; + + eDVBResourceManager::getInstance(mgr); + + 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); + + ePtr channel; + + if (mgr->allocateRawChannel(channel)) + eDebug("scan: allocating raw channel failed!"); + + std::list > list; + + list.push_back(fe); + + m_scan = new eDVBScan(channel); + m_scan->start(list); + m_scan->connectEvent(slot(*this, &eComponentScan::scanEvent), m_scan_event_connection); + + return 0; +} + +int eComponentScan::getProgress() +{ + if (!m_scan) + return 0; + int done, total, services; + m_scan->getStats(done, total, services); + if (!total) + return 0; + return done * 100 / total; +} + +int eComponentScan::getNumServices() +{ + if (!m_scan) + return 0; + int done, total, services; + m_scan->getStats(done, total, services); + return services; +} + +int eComponentScan::isDone() +{ + return m_done; +} diff --git a/lib/components/scan.h b/lib/components/scan.h new file mode 100644 index 00000000..afa68689 --- /dev/null +++ b/lib/components/scan.h @@ -0,0 +1,35 @@ +#ifndef __lib_components_scan_h +#define __lib_components_scan_h + +#include + +class eDVBScan; + +class eComponentScan: public Object, public iObject +{ +DECLARE_REF; +private: + void scanEvent(int event); + ePtr m_scan_event_connection; + ePtr m_scan; + + int m_done; +public: + eComponentScan(); + ~eComponentScan(); + + PSignal0 statusChanged; + + /* progress between 0 and 100 */ + int getProgress(); + + /* get number of services */ + int getNumServices(); + + /* true when done. */ + int isDone(); + + int start(); +}; + +#endif diff --git a/lib/driver/rcconsole.cpp b/lib/driver/rcconsole.cpp index ec759164..f662b2b1 100644 --- a/lib/driver/rcconsole.cpp +++ b/lib/driver/rcconsole.cpp @@ -20,10 +20,10 @@ eRCConsoleDriver::eRCConsoleDriver(const char *filename): eRCDriver(eRCInput::ge } /* set console mode */ - struct termios t,ot; + struct termios t; tcgetattr(handle, &t); - t.c_lflag &= ~(ECHO | ICANON | ECHOK | ECHOE | ECHONL); ot = t; + t.c_lflag &= ~(ECHO | ICANON | ECHOK | ECHOE | ECHONL); tcsetattr(handle, TCSANOW,&t); } diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h index 15796166..4d728b4c 100644 --- a/lib/dvb/idvb.h +++ b/lib/dvb/idvb.h @@ -223,8 +223,14 @@ public: class iDVBChannelList: public iObject { public: + virtual RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm)=0; + virtual RESULT removeChannel(const eDVBChannelID &id)=0; + virtual RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr &parm)=0; + + virtual RESULT addService(const eServiceReferenceDVB &service, eDVBService *service)=0; virtual RESULT getService(const eServiceReferenceDVB &reference, ePtr &service)=0; + virtual RESULT startQuery(ePtr &query, eDVBChannelQuery *query)=0; }; diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index 322f35c3..65eb053c 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -298,7 +298,7 @@ void eDVBScan::start(const std::list > &known_trans nextChannel(); } -void eDVBScan::insertInto(eDVBDB *db) +void eDVBScan::insertInto(iDVBChannelList *db) { for (std::map >::const_iterator ch(m_new_channels.begin()); ch != m_new_channels.end(); ++ch) @@ -377,3 +377,10 @@ RESULT eDVBScan::connectEvent(const Slot1 &event, ePtr &c connection = new eConnection(this, m_event.connect(event)); return 0; } + +void eDVBScan::getStats(int &transponders_done, int &transponders_total, int &services) +{ + transponders_done = m_ch_scanned.size() + m_ch_unavailable.size(); + transponders_total = m_ch_toScan.size() + transponders_done; + services = m_new_services.size(); +} diff --git a/lib/dvb/scan.h b/lib/dvb/scan.h index f7cb5d26..3556eb20 100644 --- a/lib/dvb/scan.h +++ b/lib/dvb/scan.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include class eDVBScan: public Object, public iObject @@ -65,7 +67,9 @@ public: enum { evtUpdate, evtFinish }; RESULT connectEvent(const Slot1 &event, ePtr &connection); - void insertInto(eDVBDB *db); + void insertInto(iDVBChannelList *db); + + void getStats(int &transponders_done, int &transponders_total, int &services); }; #endif diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp index f530019d..361d7b99 100644 --- a/lib/gui/elistbox.cpp +++ b/lib/gui/elistbox.cpp @@ -1,4 +1,3 @@ - /* written by: Felix Domke */ #include #include diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 4bd0cdcb..270dd7f4 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -59,14 +59,17 @@ is usually caused by not marking PSignals as immutable. #include #include #include +#include extern void runMainloop(); +extern void quitMainloop(); extern PSignal1 &keyPressedSignal(); %} RefCount(eListboxPythonStringContent) RefCount(eListboxServiceContent) +RefCount(eComponentScan) #define DEBUG %include "stl.i" @@ -78,7 +81,10 @@ RefCount(eListboxServiceContent) %include %template(eServiceCenterPtr) ePtr; + +// TODO: embed these... %immutable eButton::selected; +%immutable eComponentScan::statusChanged; %include %include @@ -93,6 +99,7 @@ RefCount(eListboxServiceContent) %include %include %include +%include template class PSignal0 { @@ -143,5 +150,6 @@ public: /************** debug **************/ void runMainloop(); +void quitMainloop(); %immutable keyPressed; PSignal1 &keyPressedSignal(); diff --git a/main/Makefile.am b/main/Makefile.am index 98c0472e..a8ecca4f 100644 --- a/main/Makefile.am +++ b/main/Makefile.am @@ -9,6 +9,7 @@ enigma2_SOURCES = \ enigma2_LDADD_WHOLE = \ $(top_builddir)/lib/base/libenigma_base.a \ + $(top_builddir)/lib/components/libenigma_components.a \ $(top_builddir)/lib/driver/libenigma_driver.a \ $(top_builddir)/lib/dvb/libenigma_dvb.a \ $(top_builddir)/lib/dvb_si/libenigma_dvb_si.a \ diff --git a/main/enigma.cpp b/main/enigma.cpp index 60bea8f5..b055619e 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -76,69 +76,35 @@ void keyEvent(const eRCKey &key) } /************************************************/ +#include +#include +#include #include #include -#include -#include -#include -#include -#include class eMain: public eApplication, public Object { eInit init; - ePtr m_scan; - ePtr m_mgr; - ePtr m_channel; ePtr m_dvbdb; - void scanEvent(int evt) - { - eDebug("scan event %d!", evt); - if (evt == eDVBScan::evtFinish) - { - m_scan->insertInto(m_dvbdb); - quit(0); - } - } - ePtr m_scan_event_connection; + ePtr m_scan; + public: eMain() { init.setRunlevel(eAutoInitNumbers::main); -#if 0 + /* TODO: put into init */ 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(); + m_mgr->setChannelList(m_dvbdb); - fe->setDVBS(fesat); +// m_scan = new eComponentScan(); +// m_scan->start(); - if (m_mgr->allocateRawChannel(m_channel)) - eDebug("shit it failed!"); - - eDebug("starting scan..."); - - std::list > 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() @@ -213,3 +179,8 @@ void runMainloop() { eApp->exec(); } + +void quitMainloop() +{ + eApp->quit(0); +} diff --git a/screens.py b/screens.py index 9148f25f..72f0946d 100644 --- a/screens.py +++ b/screens.py @@ -1,5 +1,6 @@ from components import * import sys +from enigma import quitMainloop # some screens def doGlobal(screen): @@ -26,6 +27,9 @@ class mainMenu(Screen): def goHDTV(self): self["title"].setText("HDTV GREEN FLASHES: ENABLED") + def goScan(self): + self.session.open(serviceScan()) + def goClock(self): self.session.open(clockDisplay(Clock())) @@ -42,6 +46,9 @@ class mainMenu(Screen): self["title"] = Header("Main Menu! - press ok to leave!") self["menu"] = MenuList( [ + ("Close Main Menu", self.close), + ("Service Scan", self.goScan), + ("Quit", quitMainloop), ("EMU SETUP", self.goEmu), ("TIMESHIFT SETUP", self.goTimeshift), ("HDTV PIP CONFIG", self.goHDTV), @@ -95,3 +102,18 @@ class clockDisplay(Screen): self["okbutton"] = b self["title"] = Header("clock dialog: here you see the current uhrzeit!") + +class serviceScan(Screen): + def ok(self): + if self["scan"].isDone(): + self.close() + + def __init__(self): + GUISkin.__init__(self) + + self["scan_progress"] = ProgressBar() + self["scan_state"] = Label("scan state") + self["scan"] = ServiceScan(self["scan_progress"], self["scan_state"]) + + self["okbutton"] = Button("ok", [self.ok]) + self["okbutton"].disable() diff --git a/skin.py b/skin.py index 687d8085..936dcc96 100644 --- a/skin.py +++ b/skin.py @@ -23,13 +23,18 @@ dom = xml.dom.minidom.parseString( - + + + + + + """) -- 2.30.2