fix bluescreen in ci menu when no entries in a menulist an ok is pressed
[enigma2.git] / lib / dvb_ci / dvbci.h
index 1576b4f..7605a6d 100644 (file)
@@ -4,6 +4,7 @@
 #include <lib/base/ebase.h>
 
 #include <set>
+#include <queue>
 
 class eDVBCISession;
 class eDVBCIApplicationManagerSession;
@@ -12,6 +13,22 @@ class eDVBCIMMISession;
 class eDVBServicePMTHandler;
 class eDVBCISlot;
 
+struct queueData
+{
+       __u8 prio;
+       unsigned char *data;
+       unsigned int len;
+       queueData( unsigned char *data, unsigned int len, __u8 prio = 0 )
+               :prio(prio), data(data), len(len)
+       {
+
+       }
+       bool operator < ( const struct queueData &a ) const
+       {
+               return prio < a.prio;
+       }
+};
+
 class eDVBCISlot: public iObject, public Object
 {
 DECLARE_REF(eDVBCISlot);
@@ -22,23 +39,31 @@ private:
        eSocketNotifier *notifier;
 
        int state;
-       enum {stateRemoved, stateInserted};
-       uint8_t prev_sent_capmt_version;
+       std::map<uint16_t, uint8_t> running_services;
+       eDVBCIApplicationManagerSession *application_manager;
+       eDVBCICAManagerSession *ca_manager;
+       eDVBCIMMISession *mmi_session;
+       std::priority_queue<queueData> sendqueue;
 public:
+       enum {stateRemoved, stateInserted, stateInvalid, stateResetted};
        int use_count;
 
        eDVBCISlot(eMainloop *context, int nr);
        ~eDVBCISlot();
        
        int send(const unsigned char *data, size_t len);
-       
-       eDVBCIApplicationManagerSession *application_manager;
-       eDVBCICAManagerSession *ca_manager;
-       eDVBCIMMISession *mmi_session;
-       
+
+       void setAppManager( eDVBCIApplicationManagerSession *session );
+       void setMMIManager( eDVBCIMMISession *session );
+       void setCAManager( eDVBCICAManagerSession *session );
+
+       eDVBCIApplicationManagerSession *getAppManager() { return application_manager; }
+       eDVBCIMMISession *getMMIManager() { return mmi_session; }
+       eDVBCICAManagerSession *getCAManager() { return ca_manager; }
+
+       int getState() { return state; }
        int getSlotID();
        int reset();
-       int initialize();
        int startMMI();
        int stopMMI();
        int answerText(int answer);
@@ -46,10 +71,10 @@ public:
        int cancelEnq();
        int getMMIState();
        int sendCAPMT(eDVBServicePMTHandler *ptr, const std::vector<uint16_t> &caids=std::vector<uint16_t>());
-       uint8_t getPrevSentCAPMTVersion() const { return prev_sent_capmt_version; }
-       void resetPrevSentCAPMTVersion() { prev_sent_capmt_version = 0xFF; }
+       void removeService(uint16_t program_number=0xFFFF);
+       int getNumOfServices() { return running_services.size(); }
        
-       enableTS(int enable);
+       int enableTS(int enable, int tuner=0);
 
 };
 
@@ -76,7 +101,7 @@ class eDVBCIInterfaces
 DECLARE_REF(eDVBCIInterfaces);
        static eDVBCIInterfaces *instance;
 private:
-       eSmartPtrList<eDVBCISlot>       m_slots;
+       eSmartPtrList<eDVBCISlot> m_slots;
        eDVBCISlot *getSlot(int slotid);
 
        PMTHandlerList m_pmt_handlers; 
@@ -86,7 +111,10 @@ public:
 
        void addPMTHandler(eDVBServicePMTHandler *pmthandler);
        void removePMTHandler(eDVBServicePMTHandler *pmthandler);
+       void recheckPMTHandlers();
        void gotPMT(eDVBServicePMTHandler *pmthandler);
+       void ciRemoved(eDVBCISlot *slot);
+       int getSlotState(int slot);
 
        static eDVBCIInterfaces *getInstance();
        
@@ -99,6 +127,7 @@ public:
        int cancelEnq(int slot);
        int getMMIState(int slot);
        int enableTS(int slot, int enable);
+       int sendCAPMT(int slot);
 };
 
 #endif