X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/682b9158bbddde229a2559365aa108812b15de61..8f01a41693ff4b01a224e9ea2f9a26538ec20414:/lib/dvb_ci/dvbci.cpp diff --git a/lib/dvb_ci/dvbci.cpp b/lib/dvb_ci/dvbci.cpp index d76cd341..72dfd388 100644 --- a/lib/dvb_ci/dvbci.cpp +++ b/lib/dvb_ci/dvbci.cpp @@ -1,14 +1,20 @@ #include +#include +#include + #include #include #include +#include + eDVBCIInterfaces::eDVBCIInterfaces() { int num_ci = 0; eDebug("scanning for common interfaces.."); + while (1) { struct stat s; @@ -26,47 +32,81 @@ eDVBCIInterfaces::eDVBCIInterfaces() ++num_ci; } - eDebug("done, found %d common interfaces"); + eDebug("done, found %d common interface slots", num_ci); } -int eDVBCISlot::write(const unsigned char *data, size_t len) +eDVBCIInterfaces::~eDVBCIInterfaces() { - return ::write(fd, data, len); } -void eDVBCISlot::data(int) +int eDVBCISlot::send(const unsigned char *data, size_t len) { - eDebug("ci talks to us"); + int res; + //int i; + //printf("< "); + //for(i=0;isetRequested(eSocketNotifier::Read | eSocketNotifier::Priority | eSocketNotifier::Write); + + return res; +} + +void eDVBCISlot::data(int what) +{ + if(what == eSocketNotifier::Priority) { + if(state != stateRemoved) { + state = stateRemoved; + printf("ci removed\n"); + notifier->setRequested(eSocketNotifier::Read); + //HACK + eDVBCI_UI::getInstance()->setState(0,0); + } + return; + } + __u8 data[4096]; int r; r = ::read(fd, data, 4096); - if(r < 0) - eWarning("ERROR reading from CI - %m\n"); - if(!se) { + if(state != stateInserted) { + state = stateInserted; eDebug("ci inserted"); - se = new eDVBCISession(this); - - /* enable HUP to detect removal or errors */ - notifier_event->start(); + + //HACK + eDVBCI_UI::getInstance()->setState(0,1); + + /* enable PRI to detect removal or errors */ + notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write); } - if(r > 0) - se->receiveData(data, r); -} + if(r > 0) { + //int i; + //printf("> "); + //for(i=0;isetRequested(eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Write); + return; + } -void eDVBCISlot::event(int) -{ - eDebug("CI removed"); - - /* kill the TransportConnection */ - - /* we know about and disable HUP */ - notifier_event->stop(); + if(what == eSocketNotifier::Write) { + if(eDVBCISession::pollAll() == 0) { + notifier->setRequested(eSocketNotifier::Read | eSocketNotifier::Priority); + } + } } -eDVBCISlot::eDVBCISlot(eMainloop *context, int nr): se(0) +DEFINE_REF(eDVBCISlot); + +eDVBCISlot::eDVBCISlot(eMainloop *context, int nr) { char filename[128]; @@ -78,15 +118,16 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr): se(0) if (fd >= 0) { - //read callback - notifier_data = new eSocketNotifier(context, fd, eSocketNotifier::Read); - CONNECT(notifier_data->activated, eDVBCISlot::data); - //remove callback - notifier_event = new eSocketNotifier(context, fd, eSocketNotifier::Hungup); - CONNECT(notifier_event->activated, eDVBCISlot::event); + notifier = new eSocketNotifier(context, fd, eSocketNotifier::Read | eSocketNotifier::Priority); + CONNECT(notifier->activated, eDVBCISlot::data); } else { perror(filename); } } +eDVBCISlot::~eDVBCISlot() +{ +} + +eAutoInitP0 init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");