X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/0d59650e25c7f1176346bfdfe2186aba9ee7089c..20730720b81b480b96070d3a20065a18f3ff0f6b:/main/enigma.cpp diff --git a/main/enigma.cpp b/main/enigma.cpp index 2d258d98..cc9781cc 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -1,46 +1,40 @@ -#undef WITH_SDL - #ifdef WITH_SDL -#error #define SDLDC #endif #include +#include #include + +#include +#include +#include #include #include #include #include - -#include - -#include #include #include - +#include #ifdef WITH_SDL -#error #include #endif +#include #include - +#include +#include +#include #include #include -#include -#include - #include - -#include #include +#include -#include - -#include - -#include +#include "bsod.h" -#include +#ifdef HAVE_GSTREAMER +#include +#endif #ifdef OBJECT_DEBUG int object_total_remaining; @@ -51,51 +45,28 @@ void object_dump() } #endif -void dumpRegion(const gRegion ®ion) -{ - fprintf(stderr, "extends: %d %d -> %d %d (%d rects)\n", - region.extends.left(), region.extends.top(), - region.extends.right(), region.extends.bottom(), region.rects.size()); -#if 0 - for (int y=0; y keyPressed; - -PSignal1 &keyPressedSignal() -{ - return keyPressed; + int ret = prev_ascii_code; + prev_ascii_code = 0; + return ret; } void keyEvent(const eRCKey &key) { ePtr ptr; eActionMap::getInstance(ptr); - ptr->keyPressed(0, key.code, key.flags); -// if (!key.flags) -// keyPressed(key.code); + if (key.flags & eRCKey::flagAscii) + { + prev_ascii_code = key.code; + ptr->keyPressed(key.producer->getIdentifier(), 510 /* faked KEY_ASCII */, 0); + } + else + ptr->keyPressed(key.producer->getIdentifier(), key.code, key.flags); } /************************************************/ @@ -115,7 +86,7 @@ class eMain: public eApplication, public Object ePtr m_dvbdb; ePtr m_locale_time_handler; ePtr m_scan; -// ePtr m_epgcache; + ePtr m_epgcache; public: eMain() @@ -126,36 +97,42 @@ public: m_dvbdb = new eDVBDB(); m_mgr = new eDVBResourceManager(); m_locale_time_handler = new eDVBLocalTimeHandler(); -// m_epgcache = new eEPGCache(); + m_epgcache = new eEPGCache(); m_mgr->setChannelList(m_dvbdb); - -// m_scan = new eComponentScan(); -// m_scan->start(); - } ~eMain() { + m_dvbdb->saveServicelist(); m_scan = 0; } }; -/************************************************/ - -eLabel *lcd_label, *lcd_clock; +int exit_code; int main(int argc, char **argv) { +#ifdef MEMLEAK_CHECK + atexit(DumpUnfreed); +#endif + #ifdef OBJECT_DEBUG atexit(object_dump); #endif +#ifdef HAVE_GSTREAMER + gst_init(&argc, &argv); +#endif + + // set pythonpath if unset + setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0); + printf("PYTHONPATH: %s\n", getenv("PYTHONPATH")); + + bsodLogInit(); ePython python; eMain main; - int double_buffer = 0; - #if 1 #ifdef SDLDC ePtr my_dc; @@ -164,22 +141,33 @@ int main(int argc, char **argv) ePtr my_dc; gFBDC::getInstance(my_dc); - double_buffer = my_dc->haveDoubleBuffering(); + int double_buffer = my_dc->haveDoubleBuffering(); #endif ePtr my_lcd_dc; gLCDDC::getInstance(my_lcd_dc); - fontRenderClass::getInstance()->AddFont(FONTDIR "/arial.ttf", "Arial", 100); + + /* ok, this is currently hardcoded for arabic. */ + /* some characters are wrong in the regular font, force them to use the replacement font */ + for (int i = 0x60c; i <= 0x66d; ++i) + eTextPara::forceReplacementGlyph(i); + eTextPara::forceReplacementGlyph(0xfdf2); + for (int i = 0xfe80; i < 0xff00; ++i) + eTextPara::forceReplacementGlyph(i); + eWidgetDesktop dsk(eSize(720, 576)); eWidgetDesktop dsk_lcd(eSize(132, 64)); - if (double_buffer) + dsk.setStyleID(0); + dsk_lcd.setStyleID(1); + +/* if (double_buffer) { eDebug(" - double buffering found, enable buffered graphics mode."); dsk.setCompositionMode(eWidgetDesktop::cmBuffered); - } + } */ wdsk = &dsk; lcddsk = &dsk_lcd; @@ -188,10 +176,10 @@ int main(int argc, char **argv) dsk_lcd.setDC(my_lcd_dc); ePtr m_pm; - loadPNG(m_pm, "data/pal.png"); + loadPNG(m_pm, DATADIR "/enigma2/pal.png"); if (!m_pm) { - eFatal("hi ghost, please copy pal.png into your ./data, thanks!"); + eFatal("pal.png not found!"); } else dsk.setPalette(*m_pm); @@ -202,62 +190,49 @@ int main(int argc, char **argv) dsk.setRedrawTask(main); dsk_lcd.setRedrawTask(main); - eWindow *lcd_win = new eWindow(&dsk_lcd); - - lcd_win->setFlag(eWindow::wfNoBorder); - - lcd_win->move(ePoint(0, 0)); - lcd_win->resize(eSize(132, 64)); - - lcd_label = new eLabel(lcd_win); - lcd_label->move(ePoint(0, 10)); - lcd_label->resize(eSize(132, 36)); - ePtr font = new gFont("Arial", 16); - lcd_label->setFont(font); - - lcd_clock = new eLabel(lcd_win); - lcd_clock->move(ePoint(50, 46)); - lcd_clock->resize(eSize(132, 20)); - //ePtr clkfont = new gFont("Arial", 18); - lcd_clock->setFont(font); - - //lcd_label->setText("bla bla bla, this lcd\nSUCKS!"); - //lcd_clock->setText("88:88:88"); - - lcd_win->show(); - eRCInput::getInstance()->keyEvent.connect(slot(keyEvent)); printf("executing main\n"); + + bsodCatchSignals(); - python.execute("mytest", "__main__"); + setIoPrio(IOPRIO_CLASS_BE, 3); -// eApp->exec(); + python.execute("mytest", "__main__"); + + if (exit_code == 5) /* python crash */ + bsodFatal(); + + dsk.paint(); + dsk_lcd.paint(); - return 0; -} + { + gPainter p(my_lcd_dc); + p.resetClip(eRect(0, 0, 132, 64)); + p.clear(); + p.flush(); + } -eWidgetDesktop *getDesktop() -{ - return wdsk; + return exit_code; } -void runMainloop() +eWidgetDesktop *getDesktop(int which) { - eApp->exec(); + return which ? lcddsk : wdsk; } -void quitMainloop() +eApplication *getApplication() { - eApp->quit(0); + return eApp; } -void setLCD(const char *string) +void runMainloop() { - lcd_label->setText(string); + eApp->runLoop(); } -void setLCDClock(const char *string) +void quitMainloop(int exitCode) { - lcd_clock->setText(string); + exit_code = exitCode; + eApp->quit(0); }