Merge remote branch 'remotes/origin/bug_135_dvdburn_ts_only' into experimental
[enigma2.git] / main / enigma.cpp
index 5a22110e4e15280050d223d51284559707fae6ea..3f420b4bb6ee2e996e5a863dc42d457fc8073ae5 100644 (file)
@@ -1,9 +1,8 @@
-#ifdef WITH_SDL
-#define SDLDC
-#endif
-
-#include <stdio.h>
 #include <unistd.h>
 #include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
 #include <libsig_comp.h>
 
 #include <lib/actions/action.h>
 #include <libsig_comp.h>
 
 #include <lib/actions/action.h>
@@ -20,7 +19,7 @@
 #include <lib/gdi/sdl.h>
 #endif
 #include <lib/gdi/epng.h>
 #include <lib/gdi/sdl.h>
 #endif
 #include <lib/gdi/epng.h>
-#include <lib/gdi/font.h> 
+#include <lib/gdi/font.h>
 #include <lib/gui/ebutton.h>
 #include <lib/gui/elabel.h>
 #include <lib/gui/elistboxcontent.h>
 #include <lib/gui/ebutton.h>
 #include <lib/gui/elabel.h>
 #include <lib/gui/elistboxcontent.h>
@@ -30,7 +29,7 @@
 #include <lib/python/connections.h>
 #include <lib/python/python.h>
 
 #include <lib/python/connections.h>
 #include <lib/python/python.h>
 
-#include "bsod.h" 
+#include "bsod.h"
 
 #ifdef HAVE_GSTREAMER
 #include <gst/gst.h>
 
 #ifdef HAVE_GSTREAMER
 #include <gst/gst.h>
@@ -58,15 +57,33 @@ int getPrevAsciiCode()
 
 void keyEvent(const eRCKey &key)
 {
 
 void keyEvent(const eRCKey &key)
 {
+       static eRCKey last(0, 0, 0);
+       static int num_repeat;
+
        ePtr<eActionMap> ptr;
        eActionMap::getInstance(ptr);
        ePtr<eActionMap> 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;
        if (key.flags & eRCKey::flagAscii)
        {
                prev_ascii_code = key.code;
-               ptr->keyPressed(0, 510 /* faked KEY_ASCII */, 0);
+               ptr->keyPressed(key.producer->getIdentifier(), 510 /* faked KEY_ASCII */, 0);
        }
        else
        }
        else
-               ptr->keyPressed(0, key.code, key.flags);
+               ptr->keyPressed(key.producer->getIdentifier(), key.code, key.flags);
 }
 
 /************************************************/
 }
 
 /************************************************/
@@ -81,19 +98,17 @@ void keyEvent(const eRCKey &key)
 class eMain: public eApplication, public Object
 {
        eInit init;
 class eMain: public eApplication, public Object
 {
        eInit init;
-       
-       ePtr<eDVBResourceManager> m_mgr;
+
        ePtr<eDVBDB> m_dvbdb;
        ePtr<eDVBDB> m_dvbdb;
+       ePtr<eDVBResourceManager> m_mgr;
        ePtr<eDVBLocalTimeHandler> m_locale_time_handler;
        ePtr<eDVBLocalTimeHandler> m_locale_time_handler;
-       ePtr<eComponentScan> m_scan;
        ePtr<eEPGCache> m_epgcache;
 
 public:
        eMain()
        {
                init.setRunlevel(eAutoInitNumbers::main);
        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();
                m_dvbdb = new eDVBDB();
                m_mgr = new eDVBResourceManager();
                m_locale_time_handler = new eDVBLocalTimeHandler();
@@ -104,7 +119,7 @@ public:
        ~eMain()
        {
                m_dvbdb->saveServicelist();
        ~eMain()
        {
                m_dvbdb->saveServicelist();
-               m_scan = 0;
+               m_mgr->releaseCachedChannel();
        }
 };
 
        }
 };
 
@@ -132,9 +147,9 @@ int main(int argc, char **argv)
 
        ePython python;
        eMain main;
 
        ePython python;
        eMain main;
-       
+
 #if 1
 #if 1
-#ifdef SDLDC
+#ifdef WITH_SDL
        ePtr<gSDLDC> my_dc;
        gSDLDC::getInstance(my_dc);
 #else
        ePtr<gSDLDC> my_dc;
        gSDLDC::getInstance(my_dc);
 #else
@@ -155,11 +170,13 @@ int main(int argc, char **argv)
        eTextPara::forceReplacementGlyph(0xfdf2);
        for (int i = 0xfe80; i < 0xff00; ++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));
        
 
        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.");
 /*     if (double_buffer)
        {
                eDebug(" - double buffering found, enable buffered graphics mode.");
@@ -173,7 +190,7 @@ int main(int argc, char **argv)
        dsk_lcd.setDC(my_lcd_dc);
 
        ePtr<gPixmap> m_pm;
        dsk_lcd.setDC(my_lcd_dc);
 
        ePtr<gPixmap> m_pm;
-       loadPNG(m_pm, DATADIR "/enigma2/pal.png");
+       loadPNG(m_pm, DATADIR "/enigma2/skin_default/pal.png");
        if (!m_pm)
        {
                eFatal("pal.png not found!");
        if (!m_pm)
        {
                eFatal("pal.png not found!");
@@ -186,6 +203,36 @@ 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);
                /* 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) + 41];
+                       sprintf(filename, DATADIR "/enigma2/skin_default/spinner/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));
        
 
        eRCInput::getInstance()->keyEvent.connect(slot(keyEvent));
        
@@ -195,10 +242,17 @@ int main(int argc, char **argv)
 
        setIoPrio(IOPRIO_CLASS_BE, 3);
 
 
        setIoPrio(IOPRIO_CLASS_BE, 3);
 
-       python.execute("mytest", "__main__");
-       
+//     python.execute("mytest", "__main__");
+       python.execFile("/usr/lib/enigma2/python/mytest.py");
+
+       extern void setFullsize(); // definend in lib/gui/evideo.cpp
+       setFullsize();
+
        if (exit_code == 5) /* python crash */
        if (exit_code == 5) /* python crash */
-               bsodFatal();
+       {
+               eDebug("(exit code 5)");
+               bsodFatal(0);
+       }
        
        dsk.paint();
        dsk_lcd.paint();
        
        dsk.paint();
        dsk_lcd.paint();
@@ -207,7 +261,6 @@ int main(int argc, char **argv)
                gPainter p(my_lcd_dc);
                p.resetClip(eRect(0, 0, 132, 64));
                p.clear();
                gPainter p(my_lcd_dc);
                p.resetClip(eRect(0, 0, 132, 64));
                p.clear();
-               p.flush();
        }
 
        return exit_code;
        }
 
        return exit_code;
@@ -230,13 +283,51 @@ void runMainloop()
 
 void quitMainloop(int exitCode)
 {
 
 void quitMainloop(int exitCode)
 {
+       FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "w");
+       if (f)
+       {
+               fprintf(f, "%d", 0);
+               fclose(f);
+       }
+       else
+       {
+               int fd = open("/dev/dbox/fp0", O_WRONLY);
+               if (fd >= 0)
+               {
+                       if (ioctl(fd, 10 /*FP_CLEAR_WAKEUP_TIMER*/) < 0)
+                               eDebug("FP_CLEAR_WAKEUP_TIMER failed (%m)");
+                       close(fd);
+               }
+               else
+                       eDebug("open /dev/dbox/fp0 for wakeup timer clear failed!(%m)");
+       }
        exit_code = exitCode;
        eApp->quit(0);
 }
 
        exit_code = exitCode;
        eApp->quit(0);
 }
 
-void addFont(const char *filename, const char *alias, int scale_factor, int is_replacement)
+#include "version.h"
+
+const char *getEnigmaVersionString()
+{
+       std::string date =
+#ifdef ENIGMA2_LAST_CHANGE_DATE
+               ENIGMA2_LAST_CHANGE_DATE;
+#else
+               __DATE__;
+#endif
+       std::string branch =
+#ifdef ENIGMA2_BRANCH
+               ENIGMA2_BRANCH;
+#else
+               "HEAD";
+#endif
+       return std::string(date + '-' + branch).c_str();
+}
+
+#include <malloc.h>
+
+void dump_malloc_stats(void)
 {
 {
-       fontRenderClass::getInstance()->AddFont(filename, alias, scale_factor);
-       if (is_replacement)
-               eTextPara::setReplacementFont(alias);
+       struct mallinfo mi = mallinfo();
+       eDebug("MALLOC: %d total", mi.uordblks);
 }
 }