3 #include <lib/dvb_ci/dvbci_mmi.h>
4 #include <lib/dvb_ci/dvbci_ui.h>
5 #include <lib/base/estring.h>
8 PyObject *list = PyList_New(len);
9 for (i=0; i<len; ++i) {
10 PyObject *tuple = PyTuple_New(3); // 3 eintrge im tuple
11 PyTuple_SetItem(tuple, 0, PyString_FromString("eintrag 1"))
12 PyTuple_SetItem(tuple, 1, PyInt_FromLong(31337));
13 PyTuple_SetItem(tuple, 2, PyString_FromString("eintrag 3"))
14 PyList_SetItem(list, i, tuple);
19 eDVBCIMMISession::eDVBCIMMISession(eDVBCISlot *tslot)
22 slot->setMMIManager(this);
25 eDVBCIMMISession::~eDVBCIMMISession()
27 slot->setMMIManager(NULL);
28 eDVBCI_UI::getInstance()->mmiSessionDestroyed(slot->getSlotID());
31 int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, int len)
33 eDebugNoNewLine("SESSION(%d)/MMI %02x %02x %02x: ", session_nb, tag[0], tag[1],tag[2]);
34 for (int i=0; i<len; i++)
35 eDebugNoNewLine("%02x ", ((const unsigned char*)data)[i]);
38 if ((tag[0]==0x9f) && (tag[1]==0x88))
42 case 0x00: //Tmmi_close
44 unsigned char *d=(unsigned char*)data;
52 eDebug("mmi close tag incorrect.. no timeout given.. assume 5 seconds");
57 eDebug("mmi close tag incorrect.. byte 4 should be 0 or 1");
58 eDVBCI_UI::getInstance()->mmiScreenClose(slot->getSlotID(), timeout);
62 eDebug("MMI display control");
63 if (((unsigned char*)data)[0] != 1)
64 eDebug("kann ich nicht. aber das sag ich dem modul nicht.");
65 state=stateDisplayReply;
67 case 0x07: //Tmenu_enq
69 unsigned char *d=(unsigned char*)data;
70 unsigned char *max=((unsigned char*)d) + len;
71 int textlen = len - 2;
81 eDebug("%d bytes text", textlen);
82 if ((d+textlen) > max)
85 char str[textlen + 1];
86 memcpy(str, ((char*)d), textlen);
89 eDebug("enq-text: %s",str);
91 eDVBCI_UI::getInstance()->mmiScreenEnq(slot->getSlotID(), blind, alen, (char*)convertDVBUTF8(str).c_str());
95 case 0x09: //Tmenu_last
96 case 0x0c: //Tlist_last
98 unsigned char *d=(unsigned char*)data;
99 unsigned char *max=((unsigned char*)d) + len;
101 eDebug("Tmenu_last");
106 if(tag[2] == 0x09) //menu
107 eDVBCI_UI::getInstance()->mmiScreenBegin(slot->getSlotID(), 0);
109 eDVBCI_UI::getInstance()->mmiScreenBegin(slot->getSlotID(), 1);
115 eDebug("%d texts", n);
116 for (int i=0; i < (n+3); ++i)
121 eDebug("text tag: %02x %02x %02x", d[0], d[1], d[2]);
123 d+=parseLengthField(d, textlen);
124 eDebug("%d bytes text", textlen);
125 if ((d+textlen) > max)
128 char str[textlen + 1];
129 memcpy(str, ((char*)d), textlen);
132 eDVBCI_UI::getInstance()->mmiScreenAddText(slot->getSlotID(), pos++, (char*)convertDVBUTF8(str).c_str());
135 eDebugNoNewLine("%c", *d++);
138 eDVBCI_UI::getInstance()->mmiScreenFinish(slot->getSlotID());
142 eDebug("unknown APDU tag 9F 88 %02x", tag[2]);
149 int eDVBCIMMISession::doAction()
156 case stateDisplayReply:
158 unsigned char tag[]={0x9f, 0x88, 0x02};
159 unsigned char data[]={0x01, 0x01};
160 sendAPDU(tag, data, 2);
168 unsigned char tag[]={0x9f, 0x88, 0x0b};
169 unsigned char data[]={5};
170 sendAPDU(tag, data, 1);
182 int eDVBCIMMISession::stopMMI()
184 eDebug("eDVBCIMMISession::stopMMI()");
186 unsigned char tag[]={0x9f, 0x88, 0x00};
187 unsigned char data[]={0x00};
188 sendAPDU(tag, data, 1);
193 int eDVBCIMMISession::answerText(int answer)
195 eDebug("eDVBCIMMISession::answerText(%d)",answer);
197 unsigned char tag[]={0x9f, 0x88, 0x0B};
198 unsigned char data[]={0x00};
199 data[0] = answer & 0xff;
200 sendAPDU(tag, data, 1);
205 int eDVBCIMMISession::answerEnq(char *answer)
207 unsigned int len = strlen(answer);
208 eDebug("eDVBCIMMISession::answerEnq(%d bytes)", len);
210 unsigned char data[len+1];
211 data[0] = 0x01; // answer ok
212 memcpy(data+1, answer, len);
214 unsigned char tag[]={0x9f, 0x88, 0x08};
215 sendAPDU(tag, data, len+1);
220 int eDVBCIMMISession::cancelEnq()
222 eDebug("eDVBCIMMISession::cancelEnq()");
224 unsigned char tag[]={0x9f, 0x88, 0x08};
225 unsigned char data[]={0x00}; // canceled
226 sendAPDU(tag, data, 1);