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)
46 return slotdata[slot].state;
50 void eDVBCI_UI::setState(int slot, int newState)
53 slotdata[slot].state = newState;
56 std::string eDVBCI_UI::getAppName(int slot)
59 return slotdata[slot].appName;
63 void eDVBCI_UI::setAppName(int slot, const char *name)
66 slotdata[slot].appName = name;
69 void eDVBCI_UI::setInit(int slot)
71 eDVBCIInterfaces::getInstance()->initialize(slot);
74 void eDVBCI_UI::setReset(int slot)
76 eDVBCIInterfaces::getInstance()->reset(slot);
79 int eDVBCI_UI::startMMI(int slot)
81 eDVBCIInterfaces::getInstance()->startMMI(slot);
85 int eDVBCI_UI::stopMMI(int slot)
87 eDVBCIInterfaces::getInstance()->stopMMI(slot);
91 int eDVBCI_UI::answerMenu(int slot, int answer)
93 eDVBCIInterfaces::getInstance()->answerText(slot, answer);
97 int eDVBCI_UI::answerEnq(int slot, char *value)
99 eDVBCIInterfaces::getInstance()->answerEnq(slot, value);
103 int eDVBCI_UI::cancelEnq(int slot)
105 eDVBCIInterfaces::getInstance()->cancelEnq(slot);
109 int eDVBCI_UI::availableMMI(int slot)
111 if (slot < MAX_SLOTS)
112 return slotdata[slot].mmiScreenReady;
116 int eDVBCI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text)
118 if (slot >= MAX_SLOTS)
121 slot_ui_data &data = slotdata[slot];
123 data.mmiScreenReady = 0;
126 Py_DECREF(data.mmiScreen);
127 data.mmiScreen = PyList_New(2);
129 PyObject *tuple = PyTuple_New(1);
130 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("ENQ"));
131 PyList_SET_ITEM(data.mmiScreen, 0, tuple);
133 tuple = PyTuple_New(4);
134 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("PIN"));
135 PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(answerLen));
136 PyTuple_SET_ITEM(tuple, 2, PyString_FromString(text));
137 PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(blind));
139 PyList_SET_ITEM(data.mmiScreen, 1, tuple);
141 data.mmiScreenReady = 1;
146 int eDVBCI_UI::mmiScreenBegin(int slot, int listmenu)
148 if (slot >= MAX_SLOTS)
151 printf("eDVBCI_UI::mmiScreenBegin\n");
153 slot_ui_data &data = slotdata[slot];
155 data.mmiScreenReady = 0;
158 Py_DECREF(data.mmiScreen);
160 data.mmiScreen = PyList_New(1);
162 PyObject *tuple = PyTuple_New(1);
163 if (listmenu == 0) //menu
164 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("MENU"));
166 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("LIST"));
168 PyList_SET_ITEM(data.mmiScreen, 0, tuple);
170 data.mmiTuplePos = 1;
175 int eDVBCI_UI::mmiScreenAddText(int slot, int type, char *value)
177 if (slot >= MAX_SLOTS)
180 eDebug("eDVBCI_UI::mmiScreenAddText(%s)",value ? value : "");
182 slot_ui_data &data = slotdata[slot];
184 PyObject *tuple = PyTuple_New(3);
186 if (type == 0) //title
187 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TITLE"));
188 else if (type == 1) //subtitle
189 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("SUBTITLE"));
190 else if (type == 2) //bottom
191 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("BOTTOM"));
193 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TEXT"));
195 eDebug("addText %s with id %d", value, type);
197 PyTuple_SET_ITEM(tuple, 1, PyString_FromString(value));
200 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(type-2));
202 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(-1));
204 PyList_Append(data.mmiScreen, tuple);
210 int eDVBCI_UI::mmiScreenFinish(int slot)
212 if (slot < MAX_SLOTS)
214 printf("eDVBCI_UI::mmiScreenFinish\n");
215 slotdata[slot].mmiScreenReady = 1;
220 int eDVBCI_UI::getMMIState(int slot)
222 return eDVBCIInterfaces::getInstance()->getMMIState(slot);
225 PyObject *eDVBCI_UI::getMMIScreen(int slot)
227 if (slot < MAX_SLOTS)
229 slot_ui_data &data = slotdata[slot];
230 if (data.mmiScreenReady)
232 data.mmiScreenReady = 0;
233 Py_INCREF(data.mmiScreen);
234 return data.mmiScreen;
241 //FIXME: correct "run/startlevel"
242 eAutoInitP0<eDVBCI_UI> init_dvbciui(eAutoInitNumbers::rc, "DVB-CI UI");