1 #include <lib/dvb_ci/dvbci_ui.h>
2 #include <lib/dvb_ci/dvbci.h>
10 #include <lib/base/init.h>
11 #include <lib/base/init_num.h>
12 #include <lib/base/eerror.h>
14 eDVBCI_UI *eDVBCI_UI::instance;
16 eDVBCI_UI::eDVBCI_UI()
20 for(int i=0;i<MAX_SLOTS;++i)
22 slotdata[i].mmiScreen=NULL;
23 slotdata[i].mmiScreenReady=0;
24 slotdata[i].mmiTuplePos=0;
29 eDVBCI_UI::~eDVBCI_UI()
31 for(int i=0;i<MAX_SLOTS;++i)
33 if (slotdata[i].mmiScreen)
34 Py_DECREF(slotdata[i].mmiScreen);
38 eDVBCI_UI *eDVBCI_UI::getInstance()
43 int eDVBCI_UI::getState(int slot)
47 if (eDVBCIInterfaces::getInstance()->getSlotState(slot) == eDVBCISlot::stateInvalid)
48 eDVBCIInterfaces::getInstance()->reset(slot);
49 return slotdata[slot].state;
54 void eDVBCI_UI::setState(int slot, int newState)
57 slotdata[slot].state = newState;
60 std::string eDVBCI_UI::getAppName(int slot)
63 return slotdata[slot].appName;
67 void eDVBCI_UI::setAppName(int slot, const char *name)
70 slotdata[slot].appName = name;
73 void eDVBCI_UI::setInit(int slot)
75 eDVBCIInterfaces::getInstance()->initialize(slot);
78 void eDVBCI_UI::setReset(int slot)
80 eDVBCIInterfaces::getInstance()->reset(slot);
83 int eDVBCI_UI::startMMI(int slot)
85 eDVBCIInterfaces::getInstance()->startMMI(slot);
89 int eDVBCI_UI::stopMMI(int slot)
91 eDVBCIInterfaces::getInstance()->stopMMI(slot);
95 int eDVBCI_UI::answerMenu(int slot, int answer)
97 eDVBCIInterfaces::getInstance()->answerText(slot, answer);
101 int eDVBCI_UI::answerEnq(int slot, char *value)
103 eDVBCIInterfaces::getInstance()->answerEnq(slot, value);
107 int eDVBCI_UI::cancelEnq(int slot)
109 eDVBCIInterfaces::getInstance()->cancelEnq(slot);
113 int eDVBCI_UI::availableMMI(int slot)
115 if (slot < MAX_SLOTS)
116 return slotdata[slot].mmiScreenReady;
120 int eDVBCI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text)
122 if (slot >= MAX_SLOTS)
125 slot_ui_data &data = slotdata[slot];
127 data.mmiScreenReady = 0;
130 Py_DECREF(data.mmiScreen);
131 data.mmiScreen = PyList_New(2);
133 PyObject *tuple = PyTuple_New(1);
134 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("ENQ"));
135 PyList_SET_ITEM(data.mmiScreen, 0, tuple);
137 tuple = PyTuple_New(4);
138 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("PIN"));
139 PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(answerLen));
140 PyTuple_SET_ITEM(tuple, 2, PyString_FromString(text));
141 PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(blind));
143 PyList_SET_ITEM(data.mmiScreen, 1, tuple);
145 data.mmiScreenReady = 1;
150 int eDVBCI_UI::mmiScreenBegin(int slot, int listmenu)
152 if (slot >= MAX_SLOTS)
155 printf("eDVBCI_UI::mmiScreenBegin\n");
157 slot_ui_data &data = slotdata[slot];
159 data.mmiScreenReady = 0;
162 Py_DECREF(data.mmiScreen);
164 data.mmiScreen = PyList_New(1);
166 PyObject *tuple = PyTuple_New(1);
167 if (listmenu == 0) //menu
168 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("MENU"));
170 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("LIST"));
172 PyList_SET_ITEM(data.mmiScreen, 0, tuple);
174 data.mmiTuplePos = 1;
179 int eDVBCI_UI::mmiScreenAddText(int slot, int type, char *value)
181 if (slot >= MAX_SLOTS)
184 eDebug("eDVBCI_UI::mmiScreenAddText(%s)",value ? value : "");
186 slot_ui_data &data = slotdata[slot];
188 PyObject *tuple = PyTuple_New(3);
190 if (type == 0) //title
191 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TITLE"));
192 else if (type == 1) //subtitle
193 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("SUBTITLE"));
194 else if (type == 2) //bottom
195 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("BOTTOM"));
197 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TEXT"));
199 eDebug("addText %s with id %d", value, type);
201 PyTuple_SET_ITEM(tuple, 1, PyString_FromString(value));
204 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(type-2));
206 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(-1));
208 PyList_Append(data.mmiScreen, tuple);
214 int eDVBCI_UI::mmiScreenFinish(int slot)
216 if (slot < MAX_SLOTS)
218 printf("eDVBCI_UI::mmiScreenFinish\n");
219 slotdata[slot].mmiScreenReady = 1;
224 int eDVBCI_UI::getMMIState(int slot)
226 return eDVBCIInterfaces::getInstance()->getMMIState(slot);
229 PyObject *eDVBCI_UI::getMMIScreen(int slot)
231 if (slot < MAX_SLOTS)
233 slot_ui_data &data = slotdata[slot];
234 if (data.mmiScreenReady)
236 data.mmiScreenReady = 0;
237 Py_INCREF(data.mmiScreen);
238 return data.mmiScreen;
245 //FIXME: correct "run/startlevel"
246 eAutoInitP0<eDVBCI_UI> init_dvbciui(eAutoInitNumbers::rc, "DVB-CI UI");