- actionmap component will not catch (wrong) exceptions anymore
[enigma2.git] / main / enigma.cpp
index 7543e45..258c5ad 100644 (file)
@@ -1,3 +1,4 @@
+#define SDLDC
 #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/gdi/grc.h>
+#include <lib/gdi/gfbdc.h>
+#include <lib/gdi/sdl.h>
+#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 &region)
+{
+       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());
+       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");
+       }
+}
+
+eWidgetDesktop *wdsk;
+
+// 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>
 
 class eMain: public eApplication, public Object
 {
        eInit init;
        
        ePtr<eDVBResourceManager> m_mgr;
-       ePtr<iDVBChannel> m_channel;
        ePtr<eDVBDB> m_dvbdb;
 
-       ePtr<iPlayableService> m_playservice;
+       ePtr<eComponentScan> m_scan;
+       
 public:
        eMain()
        {
                init.setRunlevel(eAutoInitNumbers::main);
+
+                               /* TODO: put into init */
                m_dvbdb = new eDVBDB();
                m_mgr = new eDVBResourceManager();
+               
                m_mgr->setChannelList(m_dvbdb);
                
-               ePtr<eServiceCenter> service_center;
-               eServiceCenter::getInstance(service_center);
+//             m_scan = new eComponentScan();
+//             m_scan->start();
 
-               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());
-                       }
-               }
-               
-               eServiceReference ref("1:0:1:6de2:44d:1:c00000:0:0:0:");
-               
-               if (service_center)
-               {
-                       if (service_center->play(ref, m_playservice))
-                               eDebug("play sucked around!");
-                       else
-                               eDebug("play r00lz!");
-               } else
-                       eDebug("no service center: no play.");
        }
        
        ~eMain()
        {
-               
+               m_scan = 0;
        }
 };
 
-#ifdef OBJECT_DEBUG
-int object_total_remaining;
+/************************************************/
 
-void object_dump()
-{
-       printf("%d items left\n", object_total_remaining);
-}
-#endif
 
-int main()
-{      
+int main(int argc, char **argv)
+{
 #ifdef OBJECT_DEBUG
        atexit(object_dump);
 #endif
-       eMain app;
-       return app.exec();
+
+
+       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);
+#endif
+
+       fontRenderClass::getInstance()->AddFont("/home/tmbinc/enigma2/fonts/arial.ttf", "Arial", 100);
+
+       eWidgetDesktop dsk(eSize(720, 576));
+       
+       wdsk = &dsk;
+
+
+       dsk.setDC(my_dc);
+
+       ePtr<gPixmap> m_pm;
+       loadPNG(m_pm, "data/info-bg.png");
+       if (!m_pm)
+       {
+               eDebug("can't load info-bg :)");
+       } else
+               dsk.setPalette(*m_pm);
+
+       dsk.setBackgroundColor(gRGB(0,0,0,0));
+#endif
+
+               /* redrawing is done in an idle-timer, so we have to set the context */
+       dsk.setRedrawTask(main);
+       
+       eRCInput::getInstance()->keyEvent.connect(slot(keyEvent));
+       
+       printf("executing main\n");
+
+       python.execute("mytest", "__main__");
+
+//     eApp->exec();
+
+       return 0;
+}
+
+eWidgetDesktop *getDesktop()
+{
+       return wdsk;
+}
+
+void runMainloop()
+{
+       eApp->exec();
+}
+
+void quitMainloop()
+{
+       eApp->quit(0);
 }