Extrenal srt problem gst-1 solved.
[openblackhole/openblackhole-enigma2.git] / lib / dvb_ci / dvbci_appmgr.cpp
1 /* DVB CI Application Manager */
2
3 #include <lib/base/eerror.h>
4 #include <lib/dvb_ci/dvbci_appmgr.h>
5 #include <lib/dvb_ci/dvbci_ui.h>
6
7 eDVBCIApplicationManagerSession::eDVBCIApplicationManagerSession(eDVBCISlot *tslot)
8 {
9         slot = tslot;
10         slot->setAppManager(this);
11 }
12
13 eDVBCIApplicationManagerSession::~eDVBCIApplicationManagerSession()
14 {
15         slot->setAppManager(NULL);
16 }
17
18 int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag,const void *data, int len)
19 {
20         eDebugNoNewLine("[CI AM] SESSION(%d)/APP %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
21         for (int i=0; i<len; i++)
22                 eDebugNoNewLine("%02x ", ((const unsigned char*)data)[i]);
23         eDebugNoNewLine("\n");
24
25         if ((tag[0]==0x9f) && (tag[1]==0x80))
26         {
27                 switch (tag[2])
28                 {
29                 case 0x21:
30                 {
31                         int dl;
32                         eDebug("[CI AM] application info:");
33                         eDebug("[CI AM]   len: %d", len);
34                         eDebug("[CI AM]   application_type: %d", ((unsigned char*)data)[0]);
35                         eDebug("[CI AM]   application_manufacturer: %02x %02x", ((unsigned char*)data)[2], ((unsigned char*)data)[1]);
36                         eDebug("[CI AM]   manufacturer_code: %02x %02x", ((unsigned char*)data)[4],((unsigned char*)data)[3]);
37                         dl=((unsigned char*)data)[5];
38                         if ((dl + 6) > len)
39                         {
40                                 eDebug("[CI AM] warning, invalid length (%d vs %d)", dl+6, len);
41                                 dl=len-6;
42                         }
43                         char str[dl + 1];
44                         memcpy(str, ((char*)data) + 6, dl);
45                         str[dl] = '\0';
46                         eDebugNoNewLine("[CI AM]   menu string: ");
47                         for (int i = 0; i < dl; ++i)
48                                 eDebugNoNewLine("%c", ((unsigned char*)data)[i+6]);
49                         eDebugNoNewLine("\n");
50
51                         eDVBCI_UI::getInstance()->setAppName(slot->getSlotID(), str);
52
53                         eDVBCI_UI::getInstance()->setState(slot->getSlotID(), 2);
54                         break;
55                 }
56                 default:
57                         eDebug("[CI AM] unknown APDU tag 9F 80 %02x", tag[2]);
58                         break;
59                 }
60         }
61         return 0;
62 }
63
64 int eDVBCIApplicationManagerSession::doAction()
65 {
66   switch (state)
67   {
68   case stateStarted:
69   {
70     const unsigned char tag[3]={0x9F, 0x80, 0x20}; // application manager info e    sendAPDU(tag);
71                 sendAPDU(tag);
72     state=stateFinal;
73     return 1;
74   }
75   case stateFinal:
76     eDebug("[CI AM] in final state.");
77                 wantmenu = 0;
78     if (wantmenu)
79     {
80       eDebug("[CI AM] wantmenu: sending Tenter_menu");
81       const unsigned char tag[3]={0x9F, 0x80, 0x22};  // Tenter_menu
82       sendAPDU(tag);
83       wantmenu=0;
84       return 0;
85     } else
86       return 0;
87   default:
88     return 0;
89   }
90 }
91
92 int eDVBCIApplicationManagerSession::startMMI()
93 {
94         eDebug("[CI AM] in appmanager -> startmmi()");
95         const unsigned char tag[3]={0x9F, 0x80, 0x22};  // Tenter_menu
96         sendAPDU(tag);
97         return 0;
98 }
99