just show hdd info when there is one
[enigma2.git] / lib / dvb_ci / dvbci_appmgr.cpp
1 /* DVB CI Application Manager */
2
3 #include <lib/dvb_ci/dvbci_appmgr.h>
4 #include <lib/dvb_ci/dvbci_ui.h>
5
6 int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag,const void *data, int len)
7 {
8         printf("SESSION(%d)/APP %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
9         for (int i=0; i<len; i++)
10                 printf("%02x ", ((const unsigned char*)data)[i]);
11         printf("\n");
12
13         if ((tag[0]==0x9f) && (tag[1]==0x80))
14         {
15                 switch (tag[2])
16                 {
17                 case 0x21:
18                 {
19                         int dl;
20                         printf("application info:\n");
21                         printf("  len: %d\n", len);
22                         printf("  application_type: %d\n", ((unsigned char*)data)[0]);
23                         printf("  application_manufacturer: %02x %02x\n", ((unsigned char*)data)[2], ((unsigned char*)data)[1]);
24                         printf("  manufacturer_code: %02x %02x\n", ((unsigned char*)data)[4],((unsigned char*)data)[3]);
25                         printf("  menu string: ");
26                         dl=((unsigned char*)data)[5];
27                         if ((dl + 6) > len)
28                         {
29                                 printf("warning, invalid length (%d vs %d)\n", dl+6, len);
30                                 dl=len-6;
31                         }
32                         char str[dl + 1];
33                         memcpy(str, ((char*)data) + 6, dl);
34                         str[dl] = '\0';
35                         for (int i = 0; i < dl; ++i)
36                                 printf("%c", ((unsigned char*)data)[i+6]);
37                         printf("\n");
38                         
39                         eDVBCI_UI::getInstance()->setState(0,2);
40                         eDVBCI_UI::getInstance()->setAppName(0,str);
41                         break;
42                 }
43                 default:
44                         printf("unknown APDU tag 9F 80 %02x\n", tag[2]);
45                         break;
46                 }
47         }
48         return 0;
49 }
50
51 int eDVBCIApplicationManagerSession::doAction()
52 {
53   switch (state)
54   {
55   case stateStarted:
56   {
57     const unsigned char tag[3]={0x9F, 0x80, 0x20}; // application manager info e    sendAPDU(tag);
58                 sendAPDU(tag);
59     state=stateFinal;
60     return 1;
61   }
62   case stateFinal:
63     printf("in final state.\n");
64                 wantmenu = 0;
65     if (wantmenu)
66     {
67       printf("wantmenu: sending Tenter_menu\n");
68       const unsigned char tag[3]={0x9F, 0x80, 0x22};  // Tenter_menu
69       sendAPDU(tag);
70       wantmenu=0;
71       return 0;
72     } else
73       return 0;
74   default:
75     return 0;
76   }
77 }