+#ifdef WITH_SDL
+#define SDLDC
+#endif
+
#include <stdio.h>
#include <libsig_comp.h>
#include <lib/base/ebase.h>
#include <lib/base/init.h>
#include <lib/base/init_num.h>
-#include <lib/dvb/dvb.h>
-#include <lib/dvb/db.h>
-#include <lib/dvb/isection.h>
-#include <lib/dvb/esection.h>
-#include <lib/dvb_si/pmt.h>
-#include <lib/dvb/scan.h>
#include <unistd.h>
-#include <lib/service/iservice.h>
-#include <lib/nav/core.h>
+#include <lib/gdi/grc.h>
+#include <lib/gdi/gfbdc.h>
+#include <lib/gdi/glcddc.h>
+
+#ifdef WITH_SDL
+#include <lib/gdi/sdl.h>
+#endif
+#include <lib/gdi/font.h>
+
+#include <lib/gui/ewidget.h>
+#include <lib/gui/ewidgetdesktop.h>
+#include <lib/gui/elabel.h>
+#include <lib/gui/ebutton.h>
+
+#include <lib/gui/ewindow.h>
+
+#include <lib/python/python.h>
+#include <lib/python/connections.h>
+
+#include <lib/gui/elistboxcontent.h>
+
+#include <lib/driver/rc.h>
+
+#include <lib/actions/action.h>
+
+#include <lib/gdi/epng.h>
+
+#ifdef OBJECT_DEBUG
+int object_total_remaining;
+
+void object_dump()
+{
+ printf("%d items left\n", object_total_remaining);
+}
+#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<region.extends.bottom(); ++y)
+ {
+ for (int x=0; x<region.extends.right(); ++x)
+ {
+ unsigned char res = ' ';
+ for (unsigned int i=0; i < region.rects.size(); ++i)
+ if (region.rects[i].contains(ePoint(x, y)))
+ res = '0' + i;
+ fprintf(stderr, "%c", res);
+ }
+ fprintf(stderr, "\n");
+ }
+#endif
+
+}
+
+eWidgetDesktop *wdsk, *lcddsk;
+
+// typedef struct _object PyObject;
+
+void print(int i)
+{
+ printf("C++ says: it's a %d!!!\n", i);
+}
+
+PSignal1<void,int> keyPressed;
+
+PSignal1<void,int> &keyPressedSignal()
+{
+ return keyPressed;
+}
+
+void keyEvent(const eRCKey &key)
+{
+ ePtr<eActionMap> ptr;
+ eActionMap::getInstance(ptr);
+ ptr->keyPressed(0, key.code, key.flags);
+// if (!key.flags)
+// keyPressed(key.code);
+}
+
+/************************************************/
+#include <unistd.h>
+#include <lib/components/scan.h>
+#include <lib/dvb/idvb.h>
+#include <lib/dvb/dvb.h>
+#include <lib/dvb/db.h>
+#include <lib/dvb/dvbtime.h>
+#include <lib/dvb/epgcache.h>
class eMain: public eApplication, public Object
{
eInit init;
ePtr<eDVBResourceManager> m_mgr;
- ePtr<iDVBChannel> m_channel;
ePtr<eDVBDB> m_dvbdb;
+ ePtr<eDVBLocalTimeHandler> m_locale_time_handler;
+ ePtr<eComponentScan> m_scan;
+ ePtr<eEPGCache> m_epgcache;
- ePtr<iPlayableService> m_playservice;
- ePtr<eNavigation> m_nav;
- ePtr<eConnection> m_conn_event;
- ePtr<iServiceInformation> 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<eServiceCenter> 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<iListableService> lst;
- if (service_center->list(ref, lst))
- eDebug("no list available!");
- else
- {
- std::list<eServiceReference> list;
- if (lst->getContent(list))
- eDebug("list itself SUCKED AROUND!!!");
- else
- for (std::list<eServiceReference>::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)
- {
- 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:
- {
- ePtr<iPlayableService> service;
- nav->getCurrentService(service);
- if (!service)
- {
- eDebug("no running service!");
- break;
- }
- if (service->getIServiceInformation(m_serviceInformation))
- {
- eDebug("failed to get iserviceinformation");
- break;
- }
- 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;
- }
}
~eMain()
{
+ m_dvbdb->saveServicelist();
+ m_scan = 0;
}
};
-#ifdef OBJECT_DEBUG
-int object_total_remaining;
+/************************************************/
-void object_dump()
-{
- printf("%d items left\n", object_total_remaining);
-}
-#endif
+eLabel *lcd_label, *lcd_clock;
-int main()
+int exit_code;
+
+int main(int argc, char **argv)
{
#ifdef OBJECT_DEBUG
atexit(object_dump);
#endif
- eMain app;
- int res = app.exec();
- eDebug("after exec");
+
+ // set pythonpath if unset
+ setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0);
+ printf("PYTHONPATH: %s\n", getenv("PYTHONPATH"));
+
+
+ ePython python;
+ eMain main;
+
+#if 1
+#ifdef SDLDC
+ ePtr<gSDLDC> my_dc;
+ gSDLDC::getInstance(my_dc);
+#else
+ ePtr<gFBDC> my_dc;
+ gFBDC::getInstance(my_dc);
+
+ int double_buffer = my_dc->haveDoubleBuffering();
+#endif
+
+ ePtr<gLCDDC> my_lcd_dc;
+ gLCDDC::getInstance(my_lcd_dc);
+
+ fontRenderClass::getInstance()->AddFont(FONTDIR "/md_khmurabi_10.ttf", "Regular", 100);
+ fontRenderClass::getInstance()->AddFont(FONTDIR "/ae_AlMateen.ttf", "Replacement", 90);
+ eTextPara::setReplacementFont("Replacement");
+
+ /* 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)
+ {
+ 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<gPixmap> 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);
+
+ 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, 4));
+ lcd_label->resize(eSize(132, 42));
+ ePtr<gFont> font = new gFont("Regular", 19);
+ //ePtr<gFont> font = new gFont("Regular", 16);
+ lcd_label->setFont(font);
+
+ lcd_clock = new eLabel(lcd_win);
+ lcd_clock->move(ePoint(50, 46));
+ lcd_clock->resize(eSize(132, 18));
+ ePtr<gFont> clkfont = new gFont("Regular", 16);
+ lcd_clock->setFont(clkfont);
+
+ //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");
+
+ python.execute("mytest", "__main__");
+
+ return exit_code;
+}
+
+eWidgetDesktop *getDesktop()
+{
+ return wdsk;
+}
+
+eApplication *getApplication()
+{
+ return eApp;
+}
+
+void runMainloop()
+{
+ exit_code = eApp->runLoop();
+}
+
+void quitMainloop(int exitCode)
+{
+ eApp->quit(exitCode);
+}
+
+void setLCD(const char *string)
+{
+ lcd_label->setText(string);
+}
+
+void setLCDClock(const char *string)
+{
+ lcd_clock->setText(string);
}