use local listbox styles for servicelist
[enigma2.git] / lib / dvb_ci / dvbci.h
1 #ifndef __dvbci_dvbci_h
2 #define __dvbci_dvbci_h
3
4 #ifndef SWIG
5
6 #include <lib/base/ebase.h>
7 #include <lib/service/iservice.h>
8 #include <lib/python/python.h>
9 #include <set>
10 #include <queue>
11
12 class eDVBCISession;
13 class eDVBCIApplicationManagerSession;
14 class eDVBCICAManagerSession;
15 class eDVBCIMMISession;
16 class eDVBServicePMTHandler;
17 class eDVBCISlot;
18 class eDVBCIInterfaces;
19
20 struct queueData
21 {
22         __u8 prio;
23         unsigned char *data;
24         unsigned int len;
25         queueData( unsigned char *data, unsigned int len, __u8 prio = 0 )
26                 :prio(prio), data(data), len(len)
27         {
28
29         }
30         bool operator < ( const struct queueData &a ) const
31         {
32                 return prio < a.prio;
33         }
34 };
35
36 enum data_source
37 {
38         TUNER_A, TUNER_B, TUNER_C, TUNER_D, CI_A, CI_B, CI_C, CI_D
39 };
40
41 class eDVBCISlot: public iObject, public Object
42 {
43         friend class eDVBCIInterfaces;
44 DECLARE_REF(eDVBCISlot);
45 private:
46         int slotid;
47         int fd;
48         eSocketNotifier *notifier;
49         int state;
50         std::map<uint16_t, uint8_t> running_services;
51         eDVBCIApplicationManagerSession *application_manager;
52         eDVBCICAManagerSession *ca_manager;
53         eDVBCIMMISession *mmi_session;
54         std::priority_queue<queueData> sendqueue;
55         std::set<uint16_t> possible_caids;
56         std::set<eServiceReference> possible_services;
57         std::set<std::string> possible_providers;
58         int use_count;
59         eDVBCISlot *linked_next; // needed for linked CI handling
60         data_source current_source;
61         int current_tuner;
62         void data(int);
63 public:
64         enum {stateRemoved, stateInserted, stateInvalid, stateResetted};
65         eDVBCISlot(eMainloop *context, int nr);
66         ~eDVBCISlot();
67         
68         int send(const unsigned char *data, size_t len);
69
70         void setAppManager( eDVBCIApplicationManagerSession *session );
71         void setMMIManager( eDVBCIMMISession *session );
72         void setCAManager( eDVBCICAManagerSession *session );
73
74         eDVBCIApplicationManagerSession *getAppManager() { return application_manager; }
75         eDVBCIMMISession *getMMIManager() { return mmi_session; }
76         eDVBCICAManagerSession *getCAManager() { return ca_manager; }
77
78         int getState() { return state; }
79         int getSlotID();
80         int reset();
81         int startMMI();
82         int stopMMI();
83         int answerText(int answer);
84         int answerEnq(char *value);
85         int cancelEnq();
86         int getMMIState();
87         int sendCAPMT(eDVBServicePMTHandler *ptr, const std::vector<uint16_t> &caids=std::vector<uint16_t>());
88         void removeService(uint16_t program_number=0xFFFF);
89         int getNumOfServices() { return running_services.size(); }
90         int setSource(data_source source);
91 };
92
93 struct CIPmtHandler
94 {
95         eDVBServicePMTHandler *pmthandler;
96         eDVBCISlot *cislot;
97         CIPmtHandler()
98                 :pmthandler(NULL), cislot(NULL)
99         {}
100         CIPmtHandler( const CIPmtHandler &x )
101                 :pmthandler(x.pmthandler), cislot(x.cislot)
102         {}
103         CIPmtHandler( eDVBServicePMTHandler *ptr )
104                 :pmthandler(ptr), cislot(NULL)
105         {}
106         bool operator==(const CIPmtHandler &x) const { return x.pmthandler == pmthandler; }
107 };
108
109 typedef std::list<CIPmtHandler> PMTHandlerList;
110
111 #endif // SWIG
112
113 class eDVBCIInterfaces
114 {
115 DECLARE_REF(eDVBCIInterfaces);
116         static eDVBCIInterfaces *instance;
117 private:
118         eSmartPtrList<eDVBCISlot> m_slots;
119         eDVBCISlot *getSlot(int slotid);
120         PMTHandlerList m_pmt_handlers; 
121 #ifndef SWIG
122 public:
123 #endif
124         eDVBCIInterfaces();
125         ~eDVBCIInterfaces();
126
127         void addPMTHandler(eDVBServicePMTHandler *pmthandler);
128         void removePMTHandler(eDVBServicePMTHandler *pmthandler);
129         void recheckPMTHandlers();
130         void gotPMT(eDVBServicePMTHandler *pmthandler);
131         void ciRemoved(eDVBCISlot *slot);
132         int getSlotState(int slot);
133
134         int reset(int slot);
135         int initialize(int slot);
136         int startMMI(int slot);
137         int stopMMI(int slot);
138         int answerText(int slot, int answer);
139         int answerEnq(int slot, char *value);
140         int cancelEnq(int slot);
141         int getMMIState(int slot);
142         int sendCAPMT(int slot);
143         int setInputSource(int tunerno, data_source source);
144 #ifdef SWIG
145 public:
146 #endif
147         static eDVBCIInterfaces *getInstance();
148         int getNumOfSlots() { return m_slots.size(); }
149         PyObject *getDescrambleRules(int slotid);
150         RESULT setDescrambleRules(int slotid, SWIG_PYOBJECT(ePyObject) );
151 };
152
153 #endif