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::setInit(int slot)
65 eDVBCIInterfaces::getInstance()->sendCAPMT(slot);
68 void eDVBCI_UI::setReset(int slot)
70 eDVBCIInterfaces::getInstance()->reset(slot);
73 int eDVBCI_UI::startMMI(int slot)
75 eDVBCIInterfaces::getInstance()->startMMI(slot);
79 int eDVBCI_UI::stopMMI(int slot)
81 eDVBCIInterfaces::getInstance()->stopMMI(slot);
85 int eDVBCI_UI::initialize(int slot)
87 eDVBCIInterfaces::getInstance()->initialize(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 return mmiScreenReady;
114 int eDVBCI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text)
119 Py_DECREF(mmiScreen);
120 mmiScreen = PyList_New(2);
122 PyObject *tuple = PyTuple_New(1);
123 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("ENQ"));
124 PyList_SET_ITEM(mmiScreen, 0, tuple);
126 tuple = PyTuple_New(4);
127 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("PIN"));
128 PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(answerLen));
129 PyTuple_SET_ITEM(tuple, 2, PyString_FromString(text));
130 PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(blind));
132 PyList_SET_ITEM(mmiScreen, 1, tuple);
139 int eDVBCI_UI::mmiScreenBegin(int slot, int listmenu)
141 printf("eDVBCI_UI::mmiScreenBegin\n");
146 Py_DECREF(mmiScreen);
147 mmiScreen = PyList_New(1);
149 PyObject *tuple = PyTuple_New(1);
150 if(listmenu == 0) //menu
151 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("MENU"));
153 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("LIST"));
155 PyList_SET_ITEM(mmiScreen, 0, tuple);
162 int eDVBCI_UI::mmiScreenAddText(int slot, int type, char *value)
164 eDebug("eDVBCI_UI::mmiScreenAddText(%s)",value);
166 PyObject *tuple = PyTuple_New(3);
168 if(type == 0) //title
169 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TITLE"));
170 else if(type == 1) //subtitle
171 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("SUBTITLE"));
172 else if(type == 2) //bottom
173 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("BOTTOM"));
175 PyTuple_SET_ITEM(tuple, 0, PyString_FromString("TEXT"));
177 eDebug("addText %s with id %d", value, type);
179 PyTuple_SET_ITEM(tuple, 1, PyString_FromString(value));
182 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(type-2));
184 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(-1));
186 PyList_Append(mmiScreen, tuple);
192 int eDVBCI_UI::mmiScreenFinish(int slot)
194 printf("eDVBCI_UI::mmiScreenFinish\n");
201 int eDVBCI_UI::getMMIState(int slot)
203 return eDVBCIInterfaces::getInstance()->getMMIState(slot);
206 PyObject *eDVBCI_UI::getMMIScreen(int slot)
211 Py_INCREF(mmiScreen);
218 //FIXME: correct "run/startlevel"
219 eAutoInitP0<eDVBCI_UI> init_dvbciui(eAutoInitNumbers::rc, "DVB-CI UI");