MoviePlayer: offer "help"
[enigma2.git] / lib / dvb_ci / dvbci.cpp
index 014d51a5a74a55b8ae9223d147d8c9f0db6885f0..cf7acde6130bafb186ed9be3efd0567ebb776196 100644 (file)
@@ -1,18 +1,26 @@
 #include <fcntl.h>
+#include <sys/ioctl.h>
 
 #include <lib/base/init.h>
 #include <lib/base/init_num.h>
+#include <lib/base/ebase.h>
 
 #include <lib/base/eerror.h>
 #include <lib/dvb_ci/dvbci.h>
 #include <lib/dvb_ci/dvbci_session.h>
 
 #include <lib/dvb_ci/dvbci_ui.h>
+#include <lib/dvb_ci/dvbci_appmgr.h>
+#include <lib/dvb_ci/dvbci_mmi.h>
+
+eDVBCIInterfaces *eDVBCIInterfaces::instance = 0;
 
 eDVBCIInterfaces::eDVBCIInterfaces()
 {
        int num_ci = 0;
        
+       instance = this;
+       
        eDebug("scanning for common interfaces..");
 
        while (1)
@@ -39,6 +47,82 @@ eDVBCIInterfaces::~eDVBCIInterfaces()
 {
 }
 
+eDVBCIInterfaces *eDVBCIInterfaces::getInstance()
+{
+       return instance;
+}
+
+eDVBCISlot *eDVBCIInterfaces::getSlot(int slotid)
+{
+       for(eSmartPtrList<eDVBCISlot>::iterator i(m_slots.begin()); i != m_slots.end(); ++i)
+               if(i->getSlotID() == slotid)
+                       return i;
+
+       printf("FIXME: request for unknown slot\n");
+                       
+       return 0;
+}
+
+int eDVBCIInterfaces::reset(int slotid)
+{
+       eDVBCISlot *slot;
+
+       if( (slot = getSlot(slotid)) == 0 )
+               return -1;
+       
+       return slot->reset();
+}
+
+int eDVBCIInterfaces::initialize(int slotid)
+{
+       eDVBCISlot *slot;
+
+       if( (slot = getSlot(slotid)) == 0 )
+               return -1;
+       
+       return slot->initialize();
+}
+
+int eDVBCIInterfaces::startMMI(int slotid)
+{
+       eDVBCISlot *slot;
+
+       if( (slot = getSlot(slotid)) == 0 )
+               return -1;
+       
+       return slot->startMMI();
+}
+
+int eDVBCIInterfaces::stopMMI(int slotid)
+{
+       eDVBCISlot *slot;
+
+       if( (slot = getSlot(slotid)) == 0 )
+               return -1;
+       
+       return slot->stopMMI();
+}
+
+int eDVBCIInterfaces::answerText(int slotid, int answer)
+{
+       eDVBCISlot *slot;
+
+       if( (slot = getSlot(slotid)) == 0 )
+               return -1;
+       
+       return slot->answerText(answer);
+}
+
+int eDVBCIInterfaces::answerEnq(int slotid, int answer, char *value)
+{
+       eDVBCISlot *slot;
+
+       if( (slot = getSlot(slotid)) == 0 )
+               return -1;
+       
+       return slot->answerEnq(answer, value);
+}
+
 int eDVBCISlot::send(const unsigned char *data, size_t len)
 {
        int res;
@@ -109,6 +193,11 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
 {
        char filename[128];
 
+       application_manager = 0;
+       mmi_session = 0;
+       
+       slotid = nr;
+
        sprintf(filename, "/dev/ci%d", nr);
 
        fd = ::open(filename, O_RDWR | O_NONBLOCK);
@@ -131,4 +220,60 @@ eDVBCISlot::~eDVBCISlot()
 {
 }
 
+int eDVBCISlot::getSlotID()
+{
+       return slotid;
+}
+
+int eDVBCISlot::reset()
+{
+       printf("edvbcislot: reset requested\n");
+
+       ioctl(fd, 0);
+
+       return 0;
+}
+
+int eDVBCISlot::initialize()
+{
+       printf("edvbcislot: initialize()\n");
+       return 0;
+}
+
+int eDVBCISlot::startMMI()
+{
+       printf("edvbcislot: startMMI()\n");
+       
+       if(application_manager)
+               application_manager->startMMI();
+       
+       return 0;
+}
+
+int eDVBCISlot::stopMMI()
+{
+       printf("edvbcislot: stopMMI()\n");
+
+       if(mmi_session)
+               mmi_session->stopMMI();
+       
+       return 0;
+}
+
+int eDVBCISlot::answerText(int answer)
+{
+       printf("edvbcislot: answerText(%d)\n", answer);
+
+       if(mmi_session)
+               mmi_session->answerText(answer);
+
+       return 0;
+}
+
+int eDVBCISlot::answerEnq(int answer, char *value)
+{
+       printf("edvbcislot: answerMMI(%d,%s)\n", answer, value);
+       return 0;
+}
+
 eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");