initialize self.list
[enigma2.git] / lib / dvb_ci / dvbci_ui.cpp
index 239114534cd4529b824b3e3ce94dabc9cc35212d..47eb13d257047cb0ead72bab32992877a79e63bf 100644 (file)
@@ -19,10 +19,9 @@ eDVBCI_UI::eDVBCI_UI()
        instance = this;
        for(int i=0;i<MAX_SLOTS;++i)
        {
-               slotdata[i].mmiScreen=NULL;
                slotdata[i].mmiScreenReady=0;
                slotdata[i].mmiTuplePos=0;
-               slotdata[i].state=0;
+               slotdata[i].state=-1;
        }
 }
 
@@ -43,18 +42,17 @@ eDVBCI_UI *eDVBCI_UI::getInstance()
 int eDVBCI_UI::getState(int slot)
 {
        if (slot < MAX_SLOTS)
-       {
-               if (eDVBCIInterfaces::getInstance()->getSlotState(slot) == eDVBCISlot::stateInvalid)
-                       eDVBCIInterfaces::getInstance()->reset(slot);
                return slotdata[slot].state;
-       }
        return 0;
 }
 
 void eDVBCI_UI::setState(int slot, int newState)
 {
        if (slot < MAX_SLOTS)
+       {
                slotdata[slot].state = newState;
+               /*emit*/ ciStateChanged(slot);
+       }
 }
 
 std::string eDVBCI_UI::getAppName(int slot)
@@ -117,6 +115,28 @@ int eDVBCI_UI::availableMMI(int slot)
        return false;
 }
 
+int eDVBCI_UI::mmiScreenClose(int slot, int timeout)
+{
+       if (slot >= MAX_SLOTS)
+               return 0;
+
+       slot_ui_data &data = slotdata[slot];
+
+       data.mmiScreenReady = 0;
+
+       if (data.mmiScreen)
+               Py_DECREF(data.mmiScreen);
+       data.mmiScreen = PyList_New(1);
+
+       ePyObject tuple = PyTuple_New(2);
+       PyTuple_SET_ITEM(tuple, 0, PyString_FromString("CLOSE"));
+       PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong(timeout));
+       PyList_SET_ITEM(data.mmiScreen, 0, tuple);
+       data.mmiScreenReady = 1;
+       /*emit*/ ciStateChanged(slot);
+       return 0;
+}
+
 int eDVBCI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text)
 {
        if (slot >= MAX_SLOTS)
@@ -130,7 +150,7 @@ int eDVBCI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text)
                Py_DECREF(data.mmiScreen);
        data.mmiScreen = PyList_New(2);
 
-       PyObject *tuple = PyTuple_New(1);
+       ePyObject tuple = PyTuple_New(1);
        PyTuple_SET_ITEM(tuple, 0, PyString_FromString("ENQ"));
        PyList_SET_ITEM(data.mmiScreen, 0, tuple);
 
@@ -144,6 +164,8 @@ int eDVBCI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text)
 
        data.mmiScreenReady = 1;
 
+       /*emit*/ ciStateChanged(slot);
+
        return 0;
 }
 
@@ -152,7 +174,7 @@ int eDVBCI_UI::mmiScreenBegin(int slot, int listmenu)
        if (slot >= MAX_SLOTS)
                return 0;
 
-       printf("eDVBCI_UI::mmiScreenBegin\n");
+       eDebug("eDVBCI_UI::mmiScreenBegin");
 
        slot_ui_data &data = slotdata[slot];
 
@@ -163,7 +185,7 @@ int eDVBCI_UI::mmiScreenBegin(int slot, int listmenu)
 
        data.mmiScreen = PyList_New(1);
 
-       PyObject *tuple = PyTuple_New(1);
+       ePyObject tuple = PyTuple_New(1);
        if (listmenu == 0)                              //menu
                PyTuple_SET_ITEM(tuple, 0, PyString_FromString("MENU"));
        else    //list
@@ -185,7 +207,7 @@ int eDVBCI_UI::mmiScreenAddText(int slot, int type, char *value)
 
        slot_ui_data &data = slotdata[slot];
 
-       PyObject *tuple = PyTuple_New(3);
+       ePyObject tuple = PyTuple_New(3);
 
        if (type == 0)                                  //title
                PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TITLE"));
@@ -215,12 +237,18 @@ int eDVBCI_UI::mmiScreenFinish(int slot)
 {
        if (slot < MAX_SLOTS)
        {
-               printf("eDVBCI_UI::mmiScreenFinish\n");
+               eDebug("eDVBCI_UI::mmiScreenFinish");
                slotdata[slot].mmiScreenReady = 1;
+               /*emit*/ ciStateChanged(slot);
        }
        return 0;
 }
 
+void eDVBCI_UI::mmiSessionDestroyed(int slot)
+{
+       /*emit*/ ciStateChanged(slot);
+}
+
 int eDVBCI_UI::getMMIState(int slot)
 {
        return eDVBCIInterfaces::getInstance()->getMMIState(slot);
@@ -238,8 +266,7 @@ PyObject *eDVBCI_UI::getMMIScreen(int slot)
                        return data.mmiScreen;
                }
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 //FIXME: correct "run/startlevel"