X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/b7284f749bb4637604e5d4d96272e3f1847055f0..61402686fd1130b5b183fbe853927180be1ba1e1:/lib/dvb_ci/dvbci.cpp diff --git a/lib/dvb_ci/dvbci.cpp b/lib/dvb_ci/dvbci.cpp index 67b2eafa..cb533342 100644 --- a/lib/dvb_ci/dvbci.cpp +++ b/lib/dvb_ci/dvbci.cpp @@ -1,5 +1,8 @@ #include +#include +#include + #include #include #include @@ -9,6 +12,7 @@ eDVBCIInterfaces::eDVBCIInterfaces() int num_ci = 0; eDebug("scanning for common interfaces.."); + while (1) { struct stat s; @@ -29,45 +33,80 @@ eDVBCIInterfaces::eDVBCIInterfaces() eDebug("done, found %d common interfaces"); } -int eDVBCISlot::write(const unsigned char *data, size_t len) +eDVBCIInterfaces::~eDVBCIInterfaces() +{ +} + +int eDVBCISlot::send(const unsigned char *data, size_t len) { - return ::write(fd, data, len); + int res; + int i; + + printf("< "); + for(i=0;isetRequested(eSocketNotifier::Read|eSocketNotifier::Hungup|eSocketNotifier::Write); + + return res; } -void eDVBCISlot::data(int) +void eDVBCISlot::data(int what) { - eDebug("ci talks to us"); + if(what == eSocketNotifier::Hungup) { + if(state != stateRemoved) { + state = stateRemoved; + printf("ci removed\n"); + notifier->setRequested(eSocketNotifier::Read); + } + return; + } + __u8 data[4096]; int r; r = ::read(fd, data, 4096); - if(r < 0) - eWarning("ERROR reading from CI - %m\n"); + //if(r < 0) + // eWarning("ERROR reading from CI - %m\n"); if(state != stateInserted) { state = stateInserted; eDebug("ci inserted"); /* enable HUP to detect removal or errors */ - notifier_event->start(); + //notifier_event->start(); + notifier->setRequested(eSocketNotifier::Read|eSocketNotifier::Hungup|eSocketNotifier::Write); } - if(r > 0) + if(r > 0) { + int i; + printf("> "); + for(i=0;isetRequested(eSocketNotifier::Read|eSocketNotifier::Hungup|eSocketNotifier::Write); + return; + } - eDebug("CI removed"); - - /* kill the TransportConnection */ - - /* we know about and disable HUP */ - notifier_event->stop(); + if(what == eSocketNotifier::Write) { + printf("pollall\n"); + if(eDVBCISession::pollAll() == 0) { + printf("disable pollout\n"); + notifier->setRequested(eSocketNotifier::Read | eSocketNotifier::Hungup); + } + return; + } } +DEFINE_REF(eDVBCISlot); + eDVBCISlot::eDVBCISlot(eMainloop *context, int nr) { char filename[128]; @@ -80,15 +119,16 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr) 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::Hungup); + CONNECT(notifier->activated, eDVBCISlot::data); } else { perror(filename); } } +eDVBCISlot::~eDVBCISlot() +{ +} + +eAutoInitP0 init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");