1 #include <lib/dvb/dvb.h>
2 #include <lib/dvb/db.h>
3 #include <lib/components/scan.h>
4 #include <lib/base/eerror.h>
5 #include <lib/dvb/scan.h>
7 DEFINE_REF(eComponentScan);
9 void eComponentScan::scanEvent(int evt)
11 eDebug("scan event %d!", evt);
13 if (evt == eDVBScan::evtFinish)
16 ePtr<iDVBChannelList> db;
17 ePtr<eDVBResourceManager> res;
20 if ((err = eDVBResourceManager::getInstance(res)) != 0)
22 eDebug("no resource manager");
24 } else if ((err = res->getChannelList(db)) != 0)
27 eDebug("no channel list");
30 m_scan->insertInto(db);
36 if (evt == eDVBScan::evtFail)
38 eDebug("scan failed.");
46 eComponentScan::eComponentScan(): m_done(-1), m_failed(0)
50 eComponentScan::~eComponentScan()
54 void eComponentScan::clear()
59 void eComponentScan::addInitial(const eDVBFrontendParametersSatellite &p)
61 ePtr<eDVBFrontendParameters> parm = new eDVBFrontendParameters();
63 m_initial.push_back(parm);
66 void eComponentScan::addInitial(const eDVBFrontendParametersCable &p)
68 ePtr<eDVBFrontendParameters> parm = new eDVBFrontendParameters();
70 m_initial.push_back(parm);
73 void eComponentScan::addInitial(const eDVBFrontendParametersTerrestrial &p)
75 ePtr<eDVBFrontendParameters> parm = new eDVBFrontendParameters();
77 m_initial.push_back(parm);
81 int eComponentScan::start(int feid, int flags)
83 if (m_initial.empty())
90 ePtr<eDVBResourceManager> mgr;
92 eDVBResourceManager::getInstance(mgr);
94 eUsePtr<iDVBChannel> channel;
96 if (mgr->allocateRawChannel(channel, feid))
98 eDebug("scan: allocating raw channel (on frontend %d) failed!", feid);
102 std::list<ePtr<iDVBFrontendParameters> > list;
104 m_scan = new eDVBScan(channel);
105 m_scan->connectEvent(slot(*this, &eComponentScan::scanEvent), m_scan_event_connection);
106 m_scan->start(m_initial, flags);
111 int eComponentScan::getProgress()
115 int done, total, services;
116 m_scan->getStats(done, total, services);
119 return done * 100 / total;
122 int eComponentScan::getNumServices()
126 int done, total, services;
127 m_scan->getStats(done, total, services);
131 int eComponentScan::isDone()
136 int eComponentScan::getError()