X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/012fff37311d068b932abbdaa517f2c2d7a2836a..75db34c299094d2ae87941ed464e8efa79848e16:/lib/dvb_ci/dvbci_ui.cpp diff --git a/lib/dvb_ci/dvbci_ui.cpp b/lib/dvb_ci/dvbci_ui.cpp index 2bfabf13..ddb42fdb 100644 --- a/lib/dvb_ci/dvbci_ui.cpp +++ b/lib/dvb_ci/dvbci_ui.cpp @@ -9,25 +9,30 @@ #include #include -#include #include -eDVBCI_UI *eDVBCI_UI::instance = 0; +eDVBCI_UI *eDVBCI_UI::instance; eDVBCI_UI::eDVBCI_UI() { - int i; - - for(i=0;iinitialize(slot); } void eDVBCI_UI::setReset(int slot) @@ -64,117 +79,141 @@ void eDVBCI_UI::setReset(int slot) int eDVBCI_UI::startMMI(int slot) { eDVBCIInterfaces::getInstance()->startMMI(slot); + return 0; } int eDVBCI_UI::stopMMI(int slot) { eDVBCIInterfaces::getInstance()->stopMMI(slot); -} - -int eDVBCI_UI::initialize(int slot) -{ - eDVBCIInterfaces::getInstance()->initialize(slot); + return 0; } int eDVBCI_UI::answerMenu(int slot, int answer) { eDVBCIInterfaces::getInstance()->answerText(slot, answer); + return 0; } int eDVBCI_UI::answerEnq(int slot, char *value) { eDVBCIInterfaces::getInstance()->answerEnq(slot, value); + return 0; } int eDVBCI_UI::cancelEnq(int slot) { eDVBCIInterfaces::getInstance()->cancelEnq(slot); + return 0; } int eDVBCI_UI::availableMMI(int slot) { - return mmiScreenReady; + if (slot < MAX_SLOTS) + return slotdata[slot].mmiScreenReady; + return false; } int eDVBCI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text) { - mmiScreenReady = 0; + if (slot >= MAX_SLOTS) + return 0; - mmiScreen = PyList_New(2); + slot_ui_data &data = slotdata[slot]; - PyObject *tuple = PyTuple_New(1); - PyTuple_SetItem(tuple, 0, PyString_FromString("ENQ")); - PyList_SetItem(mmiScreen, 0, tuple); + data.mmiScreenReady = 0; - tuple = PyTuple_New(4); - - PyTuple_SetItem(tuple, 0, PyString_FromString("PIN")); - PyTuple_SetItem(tuple, 1, PyInt_FromLong(answerLen)); - PyTuple_SetItem(tuple, 2, PyString_FromString(text)); - PyTuple_SetItem(tuple, 3, PyInt_FromLong(blind)); - PyList_SetItem(mmiScreen, 1, tuple); + if (data.mmiScreen) + Py_DECREF(data.mmiScreen); + data.mmiScreen = PyList_New(2); - mmiScreenReady = 1; + PyObject *tuple = PyTuple_New(1); + PyTuple_SET_ITEM(tuple, 0, PyString_FromString("ENQ")); + PyList_SET_ITEM(data.mmiScreen, 0, tuple); + + tuple = PyTuple_New(4); + PyTuple_SET_ITEM(tuple, 0, PyString_FromString("PIN")); + PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(answerLen)); + PyTuple_SET_ITEM(tuple, 2, PyString_FromString(text)); + PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(blind)); + + PyList_SET_ITEM(data.mmiScreen, 1, tuple); + + data.mmiScreenReady = 1; return 0; } int eDVBCI_UI::mmiScreenBegin(int slot, int listmenu) { + if (slot >= MAX_SLOTS) + return 0; + printf("eDVBCI_UI::mmiScreenBegin\n"); - mmiScreenReady = 0; - - mmiScreen = PyList_New(1); + slot_ui_data &data = slotdata[slot]; - PyObject *tuple = PyTuple_New(1); - if(listmenu == 0) //menu - PyTuple_SetItem(tuple, 0, PyString_FromString("MENU")); + data.mmiScreenReady = 0; + + if (data.mmiScreen) + Py_DECREF(data.mmiScreen); + + data.mmiScreen = PyList_New(1); + + PyObject *tuple = PyTuple_New(1); + if (listmenu == 0) //menu + PyTuple_SET_ITEM(tuple, 0, PyString_FromString("MENU")); else //list - PyTuple_SetItem(tuple, 0, PyString_FromString("LIST")); - - PyList_SetItem(mmiScreen, 0, tuple); - - mmiTuplePos = 1; - + PyTuple_SET_ITEM(tuple, 0, PyString_FromString("LIST")); + + PyList_SET_ITEM(data.mmiScreen, 0, tuple); + + data.mmiTuplePos = 1; + return 0; } int eDVBCI_UI::mmiScreenAddText(int slot, int type, char *value) { - printf("eDVBCI_UI::mmiScreenAddText(%s)\n",value); + if (slot >= MAX_SLOTS) + return 0; + + eDebug("eDVBCI_UI::mmiScreenAddText(%s)",value ? value : ""); + + slot_ui_data &data = slotdata[slot]; + + PyObject *tuple = PyTuple_New(3); - PyObject *tuple = PyTuple_New(3); - - if(type == 0) //title - PyTuple_SetItem(tuple, 0, PyString_FromString("TITLE")); - else if(type == 1) //subtitle - PyTuple_SetItem(tuple, 0, PyString_FromString("SUBTITLE")); - else if(type == 2) //bottom - PyTuple_SetItem(tuple, 0, PyString_FromString("BOTTOM")); + if (type == 0) //title + PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TITLE")); + else if (type == 1) //subtitle + PyTuple_SET_ITEM(tuple, 0, PyString_FromString("SUBTITLE")); + else if (type == 2) //bottom + PyTuple_SET_ITEM(tuple, 0, PyString_FromString("BOTTOM")); else - PyTuple_SetItem(tuple, 0, PyString_FromString("TEXT")); - - printf("addText %s with id %d\n", value, type); - - PyTuple_SetItem(tuple, 1, PyString_FromString(value)); - - if(type > 2) - PyTuple_SetItem(tuple, 2, PyInt_FromLong(type-2)); - else - PyTuple_SetItem(tuple, 2, PyInt_FromLong(-1)); - - PyList_Append(mmiScreen, tuple); - + PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TEXT")); + + eDebug("addText %s with id %d", value, type); + + PyTuple_SET_ITEM(tuple, 1, PyString_FromString(value)); + + if (type > 2) + PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(type-2)); + else + PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(-1)); + + PyList_Append(data.mmiScreen, tuple); + Py_DECREF(tuple); + return 0; } int eDVBCI_UI::mmiScreenFinish(int slot) { - printf("eDVBCI_UI::mmiScreenFinish\n"); - - mmiScreenReady = 1; - + if (slot < MAX_SLOTS) + { + printf("eDVBCI_UI::mmiScreenFinish\n"); + slotdata[slot].mmiScreenReady = 1; + } return 0; } @@ -185,12 +224,18 @@ int eDVBCI_UI::getMMIState(int slot) PyObject *eDVBCI_UI::getMMIScreen(int slot) { - if(mmiScreenReady != 1) - return Py_None; - - mmiScreenReady = 0; - - return mmiScreen; + if (slot < MAX_SLOTS) + { + slot_ui_data &data = slotdata[slot]; + if (data.mmiScreenReady) + { + data.mmiScreenReady = 0; + Py_INCREF(data.mmiScreen); + return data.mmiScreen; + } + } + Py_INCREF(Py_None); + return Py_None; } //FIXME: correct "run/startlevel"