make it work on the mecker-compiler
[enigma2.git] / lib / dvb_ci / dvbci_mmi.cpp
index f9179d9..a6a0c8b 100644 (file)
@@ -1,6 +1,8 @@
 /* DVB CI MMI */
 
 #include <lib/dvb_ci/dvbci_mmi.h>
+#include <lib/dvb_ci/dvbci_ui.h>
+#include <lib/base/estring.h>
 
 /*
 PyObject *list = PyList_New(len);
@@ -42,15 +44,52 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i
                                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;
+                       int i;
+
+                       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(0, 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;
+                       int pos = 0;
                        printf("Tmenu_last\n");
                        if (d > max)
                                break;
                        int n=*d++;
+                       
+                       //FIXME: slotid
+                       if(tag[2] == 0x09)      //menu
+                               eDVBCI_UI::getInstance()->mmiScreenBegin(0, 0);
+                       else                                                            //list
+                               eDVBCI_UI::getInstance()->mmiScreenBegin(0, 1);
+                       
                        if (n == 0xFF)
                                n=0;
                        else
@@ -67,10 +106,19 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i
                                printf("%d bytes text\n", textlen);
                                if ((d+textlen) > max)
                                        break;
+                                       
+                               char str[textlen + 1];
+                               memcpy(str, ((char*)d), textlen);
+                               str[textlen] = '\0';
+                               
+                               eDVBCI_UI::getInstance()->mmiScreenAddText(0, pos++, (char*)convertDVBUTF8(str).c_str());
+                                       
                                while (textlen--)
                                        printf("%c", *d++);
                                printf("\n");
                        }
+                       //FIXME: slotid
+                       eDVBCI_UI::getInstance()->mmiScreenFinish(0);
                        break;
                }
                default:
@@ -120,5 +168,30 @@ int eDVBCIMMISession::stopMMI()
        unsigned char tag[]={0x9f, 0x88, 0x00};
        unsigned char data[]={0x00};
        sendAPDU(tag, data, 1);
+       
+       return 0;
+}
+
+int eDVBCIMMISession::answerText(int answer)
+{
+       printf("eDVBCIMMISession::answerText(%d)\n",answer);
+
+       unsigned char tag[]={0x9f, 0x88, 0x0B};
+       unsigned char data[]={0x00};
+       data[0] = answer & 0xff;
+       sendAPDU(tag, data, 1);
+       
+       return 0;
+}
+
+int eDVBCIMMISession::cancelEnq()
+{
+       printf("eDVBCIMMISession::cancelEnq()\n");
+
+       unsigned char tag[]={0x9f, 0x88, 0x08};
+       unsigned char data[]={0x00};
+       sendAPDU(tag, data, 1);
+       
+       return 0;
 }