X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/bb9abed29ca9126cc2b8a0fa3d76ea2e7245cee7..0528c4567801f2ca68168d3f9a9d3771ca2eec5c:/lib/dvb_ci/dvbci_mmi.cpp diff --git a/lib/dvb_ci/dvbci_mmi.cpp b/lib/dvb_ci/dvbci_mmi.cpp index b652da89..29710660 100644 --- a/lib/dvb_ci/dvbci_mmi.cpp +++ b/lib/dvb_ci/dvbci_mmi.cpp @@ -2,6 +2,7 @@ #include #include +#include /* PyObject *list = PyList_New(len); @@ -18,12 +19,13 @@ return list; eDVBCIMMISession::eDVBCIMMISession(eDVBCISlot *tslot) { slot = tslot; - slot->mmi_session = this; + slot->setMMIManager(this); } eDVBCIMMISession::~eDVBCIMMISession() { - slot->mmi_session = 0; + slot->setMMIManager(NULL); + eDVBCI_UI::getInstance()->mmiSessionDestroyed(slot->getSlotID()); } int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, int len) @@ -37,14 +39,61 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i { switch (tag[2]) { - case 0x01: + case 0x00: //Tmmi_close + { + unsigned char *d=(unsigned char*)data; + int timeout=0; + if (d[3] == 1) + { + if (len > 4) + timeout = d[4]; + else + { + eDebug("mmi close tag incorrect.. no timeout given.. assume 5 seconds"); + timeout = 5; + } + } + else if (timeout>1) + eDebug("mmi close tag incorrect.. byte 4 should be 0 or 1"); + eDVBCI_UI::getInstance()->mmiScreenClose(slot->getSlotID(), timeout); + break; + } + case 0x01: printf("MMI display control\n"); if (((unsigned char*)data)[0] != 1) printf("kann ich nicht. aber das sag ich dem modul nicht.\n"); state=stateDisplayReply; return 1; - case 0x09: - case 0x0c: + case 0x07: //Tmenu_enq + { + unsigned char *d=(unsigned char*)data; + unsigned char *max=((unsigned char*)d) + len; + int textlen = len - 2; + + printf("in enq\n"); + + if ((d+2) > max) + break; + + int blind = *d++ & 1; + int alen = *d++; + + printf("%d bytes text\n", textlen); + if ((d+textlen) > max) + break; + + char str[textlen + 1]; + memcpy(str, ((char*)d), textlen); + str[textlen] = '\0'; + + printf("enq-text: %s\n",str); + + eDVBCI_UI::getInstance()->mmiScreenEnq(slot->getSlotID(), blind, alen, (char*)convertDVBUTF8(str).c_str()); + + break; + } + case 0x09: //Tmenu_last + case 0x0c: //Tlist_last { unsigned char *d=(unsigned char*)data; unsigned char *max=((unsigned char*)d) + len; @@ -54,11 +103,10 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i break; int n=*d++; - //FIXME: slotid - if(tag[2] == 0x09) - eDVBCI_UI::getInstance()->mmiScreenBegin(0, 0); - else - eDVBCI_UI::getInstance()->mmiScreenBegin(0, 1); + if(tag[2] == 0x09) //menu + eDVBCI_UI::getInstance()->mmiScreenBegin(slot->getSlotID(), 0); + else //list + eDVBCI_UI::getInstance()->mmiScreenBegin(slot->getSlotID(), 1); if (n == 0xFF) n=0; @@ -81,14 +129,13 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i memcpy(str, ((char*)d), textlen); str[textlen] = '\0'; - eDVBCI_UI::getInstance()->mmiScreenAddText(0, pos++, str); + eDVBCI_UI::getInstance()->mmiScreenAddText(slot->getSlotID(), pos++, (char*)convertDVBUTF8(str).c_str()); while (textlen--) printf("%c", *d++); printf("\n"); } - //FIXME: slotid - eDVBCI_UI::getInstance()->mmiScreenFinish(0); + eDVBCI_UI::getInstance()->mmiScreenFinish(slot->getSlotID()); break; } default: @@ -111,8 +158,9 @@ int eDVBCIMMISession::doAction() unsigned char tag[]={0x9f, 0x88, 0x02}; unsigned char data[]={0x01, 0x01}; sendAPDU(tag, data, 2); - state=stateFakeOK; - return 1; + state=stateIdle; + //state=stateFakeOK; + //return 1; break; } case stateFakeOK: @@ -138,6 +186,8 @@ int eDVBCIMMISession::stopMMI() unsigned char tag[]={0x9f, 0x88, 0x00}; unsigned char data[]={0x00}; sendAPDU(tag, data, 1); + + return 0; } int eDVBCIMMISession::answerText(int answer) @@ -148,5 +198,33 @@ int eDVBCIMMISession::answerText(int answer) unsigned char data[]={0x00}; data[0] = answer & 0xff; sendAPDU(tag, data, 1); + + return 0; +} + +int eDVBCIMMISession::answerEnq(char *answer) +{ + unsigned int len = strlen(answer); + printf("eDVBCIMMISession::answerEnq(%d bytes)\n", len); + + unsigned char data[len+1]; + data[0] = 0x01; // answer ok + memcpy(data+1, answer, len); + + unsigned char tag[]={0x9f, 0x88, 0x08}; + sendAPDU(tag, data, len+1); + + return 0; +} + +int eDVBCIMMISession::cancelEnq() +{ + printf("eDVBCIMMISession::cancelEnq()\n"); + + unsigned char tag[]={0x9f, 0x88, 0x08}; + unsigned char data[]={0x00}; // canceled + sendAPDU(tag, data, 1); + + return 0; }