add function to get a comparable service reference string (useable to
[enigma2.git] / main / enigma.cpp
index a370d55..5a22110 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <lib/actions/action.h>
 #include <lib/driver/rc.h>
+#include <lib/base/ioprio.h>
 #include <lib/base/ebase.h>
 #include <lib/base/eerror.h>
 #include <lib/base/init.h>
@@ -29,6 +30,8 @@
 #include <lib/python/connections.h>
 #include <lib/python/python.h>
 
+#include "bsod.h" 
+
 #ifdef HAVE_GSTREAMER
 #include <gst/gst.h>
 #endif
@@ -42,51 +45,28 @@ void object_dump()
 }
 #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());
-#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;
+static eWidgetDesktop *wdsk, *lcddsk;
 
-// typedef struct _object PyObject;
+static int prev_ascii_code;
 
-void print(int i)
+int getPrevAsciiCode()
 {
-       printf("C++ says: it's a %d!!!\n", i);
-}
-
-PSignal1<void,int> keyPressed;
-
-PSignal1<void,int> &keyPressedSignal()
-{
-       return keyPressed;
+       int ret = prev_ascii_code;
+       prev_ascii_code = 0;
+       return ret;
 }
 
 void keyEvent(const eRCKey &key)
 {
        ePtr<eActionMap> 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(0, 510 /* faked KEY_ASCII */, 0);
+       }
+       else
+               ptr->keyPressed(0, key.code, key.flags);
 }
 
 /************************************************/
@@ -128,12 +108,14 @@ public:
        }
 };
 
-/************************************************/
-
 int exit_code;
 
 int main(int argc, char **argv)
 {
+#ifdef MEMLEAK_CHECK
+       atexit(DumpUnfreed);
+#endif
+
 #ifdef OBJECT_DEBUG
        atexit(object_dump);
 #endif
@@ -145,7 +127,8 @@ int main(int argc, char **argv)
        // set pythonpath if unset
        setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0);
        printf("PYTHONPATH: %s\n", getenv("PYTHONPATH"));
-
+       
+       bsodLogInit();
 
        ePython python;
        eMain main;
@@ -164,10 +147,8 @@ int main(int argc, char **argv)
        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");
-       
+
+               /* 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);
@@ -209,9 +190,16 @@ int main(int argc, char **argv)
        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();
 
@@ -246,10 +234,9 @@ void quitMainloop(int exitCode)
        eApp->quit(0);
 }
 
-void setLCD(const char *string)
-{
-}
-
-void setLCDClock(const char *string)
+void addFont(const char *filename, const char *alias, int scale_factor, int is_replacement)
 {
+       fontRenderClass::getInstance()->AddFont(filename, alias, scale_factor);
+       if (is_replacement)
+               eTextPara::setReplacementFont(alias);
 }