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