lib/dvb/frontend.cpp: DTV frontend api support is now working (DVB-S2 is also working...
[enigma2.git] / lib / dvb_ci / dvbci_appmgr.cpp
index 5aad5b6..b3e9ca1 100644 (file)
@@ -1,14 +1,26 @@
 /* DVB CI Application Manager */
 
 /* DVB CI Application Manager */
 
+#include <lib/base/eerror.h>
 #include <lib/dvb_ci/dvbci_appmgr.h>
 #include <lib/dvb_ci/dvbci_ui.h>
 
 #include <lib/dvb_ci/dvbci_appmgr.h>
 #include <lib/dvb_ci/dvbci_ui.h>
 
+eDVBCIApplicationManagerSession::eDVBCIApplicationManagerSession(eDVBCISlot *tslot)
+{
+       slot = tslot;
+       slot->setAppManager(this);
+}
+
+eDVBCIApplicationManagerSession::~eDVBCIApplicationManagerSession()
+{
+       slot->setAppManager(NULL);
+}
+
 int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag,const void *data, int len)
 {
 int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag,const void *data, int len)
 {
-       printf("SESSION(%d)/APP %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
+       eDebugNoNewLine("SESSION(%d)/APP %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
        for (int i=0; i<len; i++)
        for (int i=0; i<len; i++)
-               printf("%02x ", ((const unsigned char*)data)[i]);
-       printf("\n");
+               eDebugNoNewLine("%02x ", ((const unsigned char*)data)[i]);
+       eDebug("");
 
        if ((tag[0]==0x9f) && (tag[1]==0x80))
        {
 
        if ((tag[0]==0x9f) && (tag[1]==0x80))
        {
@@ -17,31 +29,32 @@ int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag,const
                case 0x21:
                {
                        int dl;
                case 0x21:
                {
                        int dl;
-                       printf("application info:\n");
-                       printf("  len: %d\n", len);
-                       printf("  application_type: %d\n", ((unsigned char*)data)[0]);
-                       printf("  application_manufacturer: %02x %02x\n", ((unsigned char*)data)[2], ((unsigned char*)data)[1]);
-                       printf("  manufacturer_code: %02x %02x\n", ((unsigned char*)data)[4],((unsigned char*)data)[3]);
-                       printf("  menu string: ");
+                       eDebug("application info:");
+                       eDebug("  len: %d", len);
+                       eDebug("  application_type: %d", ((unsigned char*)data)[0]);
+                       eDebug("  application_manufacturer: %02x %02x", ((unsigned char*)data)[2], ((unsigned char*)data)[1]);
+                       eDebug("  manufacturer_code: %02x %02x", ((unsigned char*)data)[4],((unsigned char*)data)[3]);
+                       eDebugNoNewLine("  menu string: ");
                        dl=((unsigned char*)data)[5];
                        if ((dl + 6) > len)
                        {
                        dl=((unsigned char*)data)[5];
                        if ((dl + 6) > len)
                        {
-                               printf("warning, invalid length (%d vs %d)\n", dl+6, len);
+                               eDebug("warning, invalid length (%d vs %d)", dl+6, len);
                                dl=len-6;
                        }
                        char str[dl + 1];
                        memcpy(str, ((char*)data) + 6, dl);
                        str[dl] = '\0';
                        for (int i = 0; i < dl; ++i)
                                dl=len-6;
                        }
                        char str[dl + 1];
                        memcpy(str, ((char*)data) + 6, dl);
                        str[dl] = '\0';
                        for (int i = 0; i < dl; ++i)
-                               printf("%c", ((unsigned char*)data)[i+6]);
-                       printf("\n");
-                       
-                       eDVBCI_UI::getInstance()->setState(0,2);
-                       eDVBCI_UI::getInstance()->setAppName(0,str);
+                               eDebugNoNewLine("%c", ((unsigned char*)data)[i+6]);
+                       eDebug("");
+
+                       eDVBCI_UI::getInstance()->setAppName(slot->getSlotID(), str);
+
+                       eDVBCI_UI::getInstance()->setState(slot->getSlotID(), 2);
                        break;
                }
                default:
                        break;
                }
                default:
-                       printf("unknown APDU tag 9F 80 %02x\n", tag[2]);
+                       eDebug("unknown APDU tag 9F 80 %02x", tag[2]);
                        break;
                }
        }
                        break;
                }
        }
@@ -60,11 +73,11 @@ int eDVBCIApplicationManagerSession::doAction()
     return 1;
   }
   case stateFinal:
     return 1;
   }
   case stateFinal:
-    printf("in final state.\n");
+    eDebug("in final state.");
                wantmenu = 0;
     if (wantmenu)
     {
                wantmenu = 0;
     if (wantmenu)
     {
-      printf("wantmenu: sending Tenter_menu\n");
+      eDebug("wantmenu: sending Tenter_menu");
       const unsigned char tag[3]={0x9F, 0x80, 0x22};  // Tenter_menu
       sendAPDU(tag);
       wantmenu=0;
       const unsigned char tag[3]={0x9F, 0x80, 0x22};  // Tenter_menu
       sendAPDU(tag);
       wantmenu=0;
@@ -75,3 +88,12 @@ int eDVBCIApplicationManagerSession::doAction()
     return 0;
   }
 }
     return 0;
   }
 }
+
+int eDVBCIApplicationManagerSession::startMMI()
+{
+       eDebug("in appmanager -> startmmi()");
+       const unsigned char tag[3]={0x9F, 0x80, 0x22};  // Tenter_menu
+       sendAPDU(tag);
+       return 0;
+}
+