servicemp3.cpp: more simple/flexible streaming detection
[enigma2.git] / lib / dvb_ci / dvbci_appmgr.cpp
index f07ea9997a550f6aa0f8abacdc2486b61f1aae44..b3e9ca14cbc735dd26440f0fe7b4ba170b4a1b05 100644 (file)
@@ -1,14 +1,26 @@
 /* DVB CI Application Manager */
 
+#include <lib/base/eerror.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)
 {
-       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++)
-               printf("%02x ", ((const unsigned char*)data)[i]);
-       printf("\n");
+               eDebugNoNewLine("%02x ", ((const unsigned char*)data)[i]);
+       eDebug("");
 
        if ((tag[0]==0x9f) && (tag[1]==0x80))
        {
@@ -17,31 +29,32 @@ int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag,const
                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)
                        {
-                               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)
-                               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:
-                       printf("unknown APDU tag 9F 80 %02x\n", tag[2]);
+                       eDebug("unknown APDU tag 9F 80 %02x", tag[2]);
                        break;
                }
        }
@@ -60,11 +73,11 @@ int eDVBCIApplicationManagerSession::doAction()
     return 1;
   }
   case stateFinal:
-    printf("in final state.\n");
+    eDebug("in final state.");
                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;
@@ -78,8 +91,9 @@ int eDVBCIApplicationManagerSession::doAction()
 
 int eDVBCIApplicationManagerSession::startMMI()
 {
-       printf("in appmanager -> startmmi()\n");
+       eDebug("in appmanager -> startmmi()");
        const unsigned char tag[3]={0x9F, 0x80, 0x22};  // Tenter_menu
        sendAPDU(tag);
+       return 0;
 }