X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/02da1f586ef7945fef385e6d4743ef53441bc2fa..6fc7f7eb3df8cf3bed07cf9c2aae843734e87fbd:/main/enigma.cpp diff --git a/main/enigma.cpp b/main/enigma.cpp index 668c7c5a..19e66756 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -1,143 +1,276 @@ +#ifdef WITH_SDL +#define SDLDC +#endif + #include +#include #include + +#include +#include +#include #include #include #include #include +#include +#include +#include +#ifdef WITH_SDL +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bsod.h" + +#ifdef HAVE_GSTREAMER +#include +#endif + +#ifdef OBJECT_DEBUG +int object_total_remaining; + +void object_dump() +{ + printf("%d items left\n", object_total_remaining); +} +#endif + +static eWidgetDesktop *wdsk, *lcddsk; + +static int prev_ascii_code; + +int getPrevAsciiCode() +{ + int ret = prev_ascii_code; + prev_ascii_code = 0; + return ret; +} + +void keyEvent(const eRCKey &key) +{ + static eRCKey last(0, 0, 0); + static int num_repeat; + + ePtr ptr; + eActionMap::getInstance(ptr); + + if ((key.code == last.code) && (key.producer == last.producer) && key.flags & eRCKey::flagRepeat) + num_repeat++; + else + { + num_repeat = 0; + last = key; + } + if (num_repeat == 4) + { + ptr->keyPressed(key.producer->getIdentifier(), key.code, eRCKey::flagLong); + num_repeat++; + } + + 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); +} + +/************************************************/ +#include +#include +#include #include #include -#include -#include -#include -#include -#include - -#include -#include +#include +#include class eMain: public eApplication, public Object { eInit init; ePtr m_mgr; - ePtr m_channel; ePtr m_dvbdb; + ePtr m_locale_time_handler; + ePtr m_scan; + ePtr m_epgcache; - ePtr m_playservice; - ePtr m_nav; - ePtr m_conn_event; - ePtr m_serviceInformation; public: eMain() { init.setRunlevel(eAutoInitNumbers::main); + + /* TODO: put into init */ m_dvbdb = new eDVBDB(); m_mgr = new eDVBResourceManager(); + m_locale_time_handler = new eDVBLocalTimeHandler(); + m_epgcache = new eEPGCache(); m_mgr->setChannelList(m_dvbdb); - - ePtr service_center; - eServiceCenter::getInstance(service_center); - - assert(service_center); - m_nav = new eNavigation(service_center); -#if 0 - if (service_center) - { - eServiceReference ref("2:0:1:0:0:0:0:0:0:0:/"); - ePtr lst; - if (service_center->list(ref, lst)) - eDebug("no list available!"); - else - { - std::list list; - if (lst->getContent(list)) - eDebug("list itself SUCKED AROUND!!!"); - else - for (std::list::const_iterator i(list.begin()); - i != list.end(); ++i) - eDebug("%s", i->toString().c_str()); - } - } -#endif - m_nav->connectEvent(slot(*this, &eMain::event), m_conn_event); - -// eServiceReference ref("1:0:1:6de2:44d:1:c00000:0:0:0:"); - eServiceReference ref("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp3"); - eServiceReference ref1("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp31"); - eServiceReference ref2("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp32"); - - if (m_nav->enqueueService(ref)) - eDebug("play sucked around!"); - else - eDebug("play r00lz!"); - - m_nav->enqueueService(ref1); - m_nav->enqueueService(ref2); - m_nav->enqueueService(ref1); } - void event(eNavigation *nav, int ev) + ~eMain() { - switch (ev) - { - case eNavigation::evStopService: - /* very important: the old service should be deallocated, so clear *all* references to it */ - m_serviceInformation = 0; - eDebug("STOP service!"); - break; - case eNavigation::evNewService: + m_dvbdb->saveServicelist(); + m_scan = 0; + } +}; + +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; + +#if 1 +#ifdef SDLDC + ePtr my_dc; + gSDLDC::getInstance(my_dc); +#else + ePtr my_dc; + gFBDC::getInstance(my_dc); + + int double_buffer = my_dc->haveDoubleBuffering(); +#endif + + ePtr my_lcd_dc; + gLCDDC::getInstance(my_lcd_dc); + + + /* 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)); + + 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; + + dsk.setDC(my_dc); + dsk_lcd.setDC(my_lcd_dc); + + ePtr m_pm; + loadPNG(m_pm, DATADIR "/enigma2/pal.png"); + if (!m_pm) + { + eFatal("pal.png not found!"); + } else + dsk.setPalette(*m_pm); + + dsk.setBackgroundColor(gRGB(0,0,0,0xFF)); +#endif + + /* redrawing is done in an idle-timer, so we have to set the context */ + dsk.setRedrawTask(main); + dsk_lcd.setRedrawTask(main); + + + eDebug("Loading spinners..."); + + { + int i; + ePtr wait[4]; + for (i=0; i<4; ++i) { - ePtr service; - nav->getCurrentService(service); - if (!service) - { - eDebug("no running service!"); - break; - } - if (service->getIServiceInformation(m_serviceInformation)) + char filename[strlen(DATADIR) + 20]; + sprintf(filename, DATADIR "/enigma2/wait%d.png", i + 1); + if (loadPNG(wait[i], filename)) { - eDebug("failed to get iserviceinformation"); - break; + eDebug("failed to load %s! (%m)", filename); + continue; } - eString name; - m_serviceInformation->getName(name); - eDebug("NEW running service: %s", name.c_str()); - break; - } - case eNavigation::evPlayFailed: - eDebug("play failed!"); - break; - case eNavigation::evPlaylistDone: - eDebug("playlist done"); - quit(); - break; - default: - eDebug("Navigation event %d", ev); - break; } + my_dc->setSpinner(eRect(100, 100, 105, 105), wait, 4); } - ~eMain() + gRC::getInstance()->setSpinnerDC(my_dc); + + eRCInput::getInstance()->keyEvent.connect(slot(keyEvent)); + + printf("executing main\n"); + + bsodCatchSignals(); + + setIoPrio(IOPRIO_CLASS_BE, 3); + + python.execute("mytest", "__main__"); + + if (exit_code == 5) /* python crash */ + bsodFatal(); + + dsk.paint(); + dsk_lcd.paint(); + { + gPainter p(my_lcd_dc); + p.resetClip(eRect(0, 0, 132, 64)); + p.clear(); + p.flush(); } -}; -#ifdef OBJECT_DEBUG -int object_total_remaining; + return exit_code; +} -void object_dump() +eWidgetDesktop *getDesktop(int which) { - printf("%d items left\n", object_total_remaining); + return which ? lcddsk : wdsk; } -#endif -int main() +eApplication *getApplication() { -#ifdef OBJECT_DEBUG - atexit(object_dump); -#endif - eMain app; - int res = app.exec(); - eDebug("after exec"); + return eApp; +} + +void runMainloop() +{ + eApp->runLoop(); +} + +void quitMainloop(int exitCode) +{ + exit_code = exitCode; + eApp->quit(0); }