let display clock blinking when a recording is in progress
[enigma2.git] / main / enigma.cpp
index 31b81a3f0b98988f444b36d82e5200ba7928854c..631a3fb25561c4d56ae2430546b0080bab2ba64e 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>
@@ -46,20 +47,44 @@ void object_dump()
 
 static eWidgetDesktop *wdsk, *lcddsk;
 
-PSignal1<void,int> keyPressed;
+static int prev_ascii_code;
 
-PSignal1<void,int> &keyPressedSignal()
+int getPrevAsciiCode()
 {
-       return keyPressed;
+       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<eActionMap> ptr;
        eActionMap::getInstance(ptr);
-       ptr->keyPressed(0, key.code, key.flags);
-//     if (!key.flags)
-//             keyPressed(key.code);
+
+       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);
 }
 
 /************************************************/
@@ -74,19 +99,17 @@ void keyEvent(const eRCKey &key)
 class eMain: public eApplication, public Object
 {
        eInit init;
-       
-       ePtr<eDVBResourceManager> m_mgr;
+
        ePtr<eDVBDB> m_dvbdb;
+       ePtr<eDVBResourceManager> m_mgr;
        ePtr<eDVBLocalTimeHandler> m_locale_time_handler;
-       ePtr<eComponentScan> m_scan;
        ePtr<eEPGCache> m_epgcache;
 
 public:
        eMain()
        {
                init.setRunlevel(eAutoInitNumbers::main);
-
-                               /* TODO: put into init */
+               /* TODO: put into init */
                m_dvbdb = new eDVBDB();
                m_mgr = new eDVBResourceManager();
                m_locale_time_handler = new eDVBLocalTimeHandler();
@@ -97,7 +120,7 @@ public:
        ~eMain()
        {
                m_dvbdb->saveServicelist();
-               m_scan = 0;
+               m_mgr->releaseCachedChannel();
        }
 };
 
@@ -125,7 +148,7 @@ int main(int argc, char **argv)
 
        ePython python;
        eMain main;
-       
+
 #if 1
 #ifdef SDLDC
        ePtr<gSDLDC> my_dc;
@@ -140,21 +163,21 @@ 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);
        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.");
@@ -181,13 +204,45 @@ int main(int argc, char **argv)
                /* 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;
+#define MAX_SPINNER 64
+               ePtr<gPixmap> wait[MAX_SPINNER];
+               for (i=0; i<MAX_SPINNER; ++i)
+               {
+                       char filename[strlen(DATADIR) + 20];
+                       sprintf(filename, DATADIR "/enigma2/wait%d.png", i + 1);
+                       loadPNG(wait[i], filename);
+                       
+                       if (!wait[i])
+                       {
+                               if (!i)
+                                       eDebug("failed to load %s! (%m)", filename);
+                               else
+                                       eDebug("found %d spinner!\n", i);
+                               break;
+                       }
+               }
+               if (i)
+                       my_dc->setSpinner(eRect(ePoint(100, 100), wait[0]->size()), wait, i);
+               else
+                       my_dc->setSpinner(eRect(100, 100, 0, 0), wait, 1);
+       }
+       
+       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 */
@@ -226,3 +281,16 @@ void quitMainloop(int exitCode)
        exit_code = exitCode;
        eApp->quit(0);
 }
+
+#include "version.h"
+
+const char *getEnigmaVersionString()
+{
+       return 
+#ifdef ENIGMA2_CHECKOUT_TAG
+               ENIGMA2_CHECKOUT_TAG
+#else
+               "HEAD"
+#endif
+                       "-" __DATE__;
+}