6 #include <libsig_comp.h>
8 #include <lib/actions/action.h>
9 #include <lib/driver/rc.h>
10 #include <lib/base/ioprio.h>
11 #include <lib/base/ebase.h>
12 #include <lib/base/eenv.h>
13 #include <lib/base/eerror.h>
14 #include <lib/base/init.h>
15 #include <lib/base/init_num.h>
16 #include <lib/gdi/gmaindc.h>
17 #include <lib/gdi/glcddc.h>
18 #include <lib/gdi/grc.h>
19 #include <lib/gdi/epng.h>
20 #include <lib/gdi/font.h>
21 #include <lib/gui/ebutton.h>
22 #include <lib/gui/elabel.h>
23 #include <lib/gui/elistboxcontent.h>
24 #include <lib/gui/ewidget.h>
25 #include <lib/gui/ewidgetdesktop.h>
26 #include <lib/gui/ewindow.h>
27 #include <lib/python/connections.h>
28 #include <lib/python/python.h>
31 #include "version_info.h"
36 int object_total_remaining;
40 printf("%d items left\n", object_total_remaining);
44 static eWidgetDesktop *wdsk, *lcddsk;
46 static int prev_ascii_code;
48 int getPrevAsciiCode()
50 int ret = prev_ascii_code;
55 void keyEvent(const eRCKey &key)
57 static eRCKey last(0, 0, 0);
58 static int num_repeat;
61 eActionMap::getInstance(ptr);
63 if ((key.code == last.code) && (key.producer == last.producer) && key.flags & eRCKey::flagRepeat)
73 ptr->keyPressed(key.producer->getIdentifier(), key.code, eRCKey::flagLong);
77 if (key.flags & eRCKey::flagAscii)
79 prev_ascii_code = key.code;
80 ptr->keyPressed(key.producer->getIdentifier(), 510 /* faked KEY_ASCII */, 0);
83 ptr->keyPressed(key.producer->getIdentifier(), key.code, key.flags);
86 /************************************************/
88 #include <lib/components/scan.h>
89 #include <lib/dvb/idvb.h>
90 #include <lib/dvb/dvb.h>
91 #include <lib/dvb/db.h>
92 #include <lib/dvb/dvbtime.h>
93 #include <lib/dvb/epgcache.h>
95 class eMain: public eApplication, public Object
100 ePtr<eDVBResourceManager> m_mgr;
101 ePtr<eDVBLocalTimeHandler> m_locale_time_handler;
102 ePtr<eEPGCache> m_epgcache;
107 init.setRunlevel(eAutoInitNumbers::main);
108 /* TODO: put into init */
109 m_dvbdb = new eDVBDB();
110 m_mgr = new eDVBResourceManager();
111 m_locale_time_handler = new eDVBLocalTimeHandler();
112 m_epgcache = new eEPGCache();
113 m_mgr->setChannelList(m_dvbdb);
118 m_dvbdb->saveServicelist();
119 m_mgr->releaseCachedChannel();
125 int main(int argc, char **argv)
135 gst_init(&argc, &argv);
137 // set pythonpath if unset
138 setenv("PYTHONPATH", eEnv::resolve("${libdir}/enigma2/python").c_str(), 0);
139 printf("PYTHONPATH: %s\n", getenv("PYTHONPATH"));
148 gMainDC::getInstance(my_dc);
150 //int double_buffer = my_dc->haveDoubleBuffering();
152 ePtr<gLCDDC> my_lcd_dc;
153 gLCDDC::getInstance(my_lcd_dc);
156 /* ok, this is currently hardcoded for arabic. */
157 /* some characters are wrong in the regular font, force them to use the replacement font */
158 for (int i = 0x60c; i <= 0x66d; ++i)
159 eTextPara::forceReplacementGlyph(i);
160 eTextPara::forceReplacementGlyph(0xfdf2);
161 for (int i = 0xfe80; i < 0xff00; ++i)
162 eTextPara::forceReplacementGlyph(i);
164 eWidgetDesktop dsk(eSize(720, 576));
165 eWidgetDesktop dsk_lcd(my_lcd_dc->size());
168 dsk_lcd.setStyleID(my_lcd_dc->size().width() == 96 ? 2 : 1);
170 /* if (double_buffer)
172 eDebug(" - double buffering found, enable buffered graphics mode.");
173 dsk.setCompositionMode(eWidgetDesktop::cmBuffered);
180 dsk_lcd.setDC(my_lcd_dc);
183 loadPNG(m_pm, eEnv::resolve("${datadir}/enigma2/skin_default/pal.png").c_str());
186 eFatal("pal.png not found!");
188 dsk.setPalette(*m_pm);
190 dsk.setBackgroundColor(gRGB(0,0,0,0xFF));
193 /* redrawing is done in an idle-timer, so we have to set the context */
194 dsk.setRedrawTask(main);
195 dsk_lcd.setRedrawTask(main);
198 eDebug("Loading spinners...");
202 #define MAX_SPINNER 64
203 ePtr<gPixmap> wait[MAX_SPINNER];
204 for (i=0; i<MAX_SPINNER; ++i)
207 std::string rfilename;
208 snprintf(filename, sizeof(filename), "${datadir}/enigma2/skin_default/spinner/wait%d.png", i + 1);
209 rfilename = eEnv::resolve(filename);
210 loadPNG(wait[i], rfilename.c_str());
215 eDebug("failed to load %s! (%m)", rfilename.c_str());
217 eDebug("found %d spinner!\n", i);
222 my_dc->setSpinner(eRect(ePoint(100, 100), wait[0]->size()), wait, i);
224 my_dc->setSpinner(eRect(100, 100, 0, 0), wait, 1);
227 gRC::getInstance()->setSpinnerDC(my_dc);
229 eRCInput::getInstance()->keyEvent.connect(slot(keyEvent));
231 printf("executing main\n");
235 setIoPrio(IOPRIO_CLASS_BE, 3);
237 // python.execute("mytest", "__main__");
238 python.execFile(eEnv::resolve("${libdir}/enigma2/python/mytest.py").c_str());
240 extern void setFullsize(); // definend in lib/gui/evideo.cpp
243 if (exit_code == 5) /* python crash */
245 eDebug("(exit code 5)");
253 gPainter p(my_lcd_dc);
254 p.resetClip(eRect(0, 0, 132, 64));
261 eWidgetDesktop *getDesktop(int which)
263 return which ? lcddsk : wdsk;
266 eApplication *getApplication()
276 void quitMainloop(int exitCode)
278 FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "w");
286 int fd = open("/dev/dbox/fp0", O_WRONLY);
289 if (ioctl(fd, 10 /*FP_CLEAR_WAKEUP_TIMER*/) < 0)
290 eDebug("FP_CLEAR_WAKEUP_TIMER failed (%m)");
294 eDebug("open /dev/dbox/fp0 for wakeup timer clear failed!(%m)");
296 exit_code = exitCode;
300 const char *getEnigmaVersionString()
302 std::string date = enigma2_date;
303 std::string branch = enigma2_branch;
304 return std::string(date + '-' + branch).c_str();
309 void dump_malloc_stats(void)
311 struct mallinfo mi = mallinfo();
312 eDebug("MALLOC: %d total", mi.uordblks);