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/econfig.h>
13 #include <lib/base/eerror.h>
15 eDVBCI_UI *eDVBCI_UI::instance = 0;
17 eDVBCI_UI::eDVBCI_UI()
24 for(int i=0;i<MAX_SLOTS;i++)
25 state[i] = 0; //no module
28 eDVBCI_UI::~eDVBCI_UI()
34 eDVBCI_UI *eDVBCI_UI::getInstance()
39 int eDVBCI_UI::getState(int slot)
41 return state[slot]; //exploit me ;)
44 void eDVBCI_UI::setState(int slot, int newState)
46 state[slot] = newState;
48 if(newState == 2) //enable TS
49 eDVBCIInterfaces::getInstance()->enableTS(slot, 1);
52 std::string eDVBCI_UI::getAppName(int slot)
57 void eDVBCI_UI::setAppName(int slot, const char *name)
59 //printf("set name to -%c-\n", name);
63 void eDVBCI_UI::setReset(int slot)
65 eDVBCIInterfaces::getInstance()->reset(slot);
69 int eDVBCI_UI::startMMI(int slot)
71 eDVBCIInterfaces::getInstance()->startMMI(slot);
75 int eDVBCI_UI::stopMMI(int slot)
77 eDVBCIInterfaces::getInstance()->stopMMI(slot);
81 int eDVBCI_UI::initialize(int slot)
83 eDVBCIInterfaces::getInstance()->initialize(slot);
87 int eDVBCI_UI::answerMenu(int slot, int answer)
89 eDVBCIInterfaces::getInstance()->answerText(slot, answer);
93 int eDVBCI_UI::answerEnq(int slot, char *value)
95 eDVBCIInterfaces::getInstance()->answerEnq(slot, value);
99 int eDVBCI_UI::cancelEnq(int slot)
101 eDVBCIInterfaces::getInstance()->cancelEnq(slot);
105 int eDVBCI_UI::availableMMI(int slot)
107 return mmiScreenReady;
110 int eDVBCI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text)
115 Py_DECREF(mmiScreen);
116 mmiScreen = PyList_New(2);
118 PyObject *tuple = PyTuple_New(1);
119 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("ENQ"));
120 PyList_SET_ITEM(mmiScreen, 0, tuple);
122 tuple = PyTuple_New(4);
123 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("PIN"));
124 PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(answerLen));
125 PyTuple_SET_ITEM(tuple, 2, PyString_FromString(text));
126 PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(blind));
128 PyList_SET_ITEM(mmiScreen, 1, tuple);
135 int eDVBCI_UI::mmiScreenBegin(int slot, int listmenu)
137 printf("eDVBCI_UI::mmiScreenBegin\n");
142 Py_DECREF(mmiScreen);
143 mmiScreen = PyList_New(1);
145 PyObject *tuple = PyTuple_New(1);
146 if(listmenu == 0) //menu
147 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("MENU"));
149 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("LIST"));
151 PyList_SET_ITEM(mmiScreen, 0, tuple);
158 int eDVBCI_UI::mmiScreenAddText(int slot, int type, char *value)
160 eDebug("eDVBCI_UI::mmiScreenAddText(%s)",value);
162 PyObject *tuple = PyTuple_New(3);
164 if(type == 0) //title
165 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TITLE"));
166 else if(type == 1) //subtitle
167 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("SUBTITLE"));
168 else if(type == 2) //bottom
169 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("BOTTOM"));
171 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TEXT"));
173 eDebug("addText %s with id %d", value, type);
175 PyTuple_SET_ITEM(tuple, 1, PyString_FromString(value));
178 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(type-2));
180 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(-1));
182 PyList_Append(mmiScreen, tuple);
188 int eDVBCI_UI::mmiScreenFinish(int slot)
190 printf("eDVBCI_UI::mmiScreenFinish\n");
197 int eDVBCI_UI::getMMIState(int slot)
199 return eDVBCIInterfaces::getInstance()->getMMIState(slot);
202 PyObject *eDVBCI_UI::getMMIScreen(int slot)
207 Py_INCREF(mmiScreen);
214 //FIXME: correct "run/startlevel"
215 eAutoInitP0<eDVBCI_UI> init_dvbciui(eAutoInitNumbers::rc, "DVB-CI UI");