use timedifference from eDVBLocalTimeHandler for time() calls in python
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 15 Jan 2007 20:19:14 +0000 (20:19 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 15 Jan 2007 20:19:14 +0000 (20:19 +0000)
lib/dvb/dvbtime.cpp
lib/dvb/dvbtime.h
lib/python/Tools/Makefile.am
lib/python/Tools/RedirectTime.py [new file with mode: 0644]
lib/python/Tools/__init__.py
lib/python/enigma_python.i
mytest.py

index 6c2df6c265c0d5ef98d8359008de102b63cb9b20..7684bfa4b3fe3407eeb9203b1b2fc062bda96d94 100644 (file)
@@ -148,6 +148,11 @@ eDVBLocalTimeHandler::~eDVBLocalTimeHandler()
        instance=0;
        for (std::map<iDVBChannel*, channel_data>::iterator it=m_knownChannels.begin(); it != m_knownChannels.end(); ++it)
                delete it->second.tdt;
        instance=0;
        for (std::map<iDVBChannel*, channel_data>::iterator it=m_knownChannels.begin(); it != m_knownChannels.end(); ++it)
                delete it->second.tdt;
+       if (ready())
+       {
+               eDebug("set RTC to previous valid time");
+               setRTC(nowTime());
+       }
 }
 
 void eDVBLocalTimeHandler::readTimeOffsetData( const char* filename )
 }
 
 void eDVBLocalTimeHandler::readTimeOffsetData( const char* filename )
index 2b07a250c967f761a6b65e2bbdd97b9a20221f90..a5114f82a1eeb063ae287c0e9ab3b43afdd5b8cb 100644 (file)
@@ -73,10 +73,10 @@ class eDVBLocalTimeHandler: public Object
 #endif
 public:
 #ifndef SWIG
 #endif
 public:
 #ifndef SWIG
-       PSignal0<void> m_timeUpdated;
        eDVBLocalTimeHandler();
        ~eDVBLocalTimeHandler();
 #endif
        eDVBLocalTimeHandler();
        ~eDVBLocalTimeHandler();
 #endif
+       PSignal0<void> m_timeUpdated;
        time_t nowTime() const { return m_time_ready ? ::time(0)+m_time_difference : -1; }
        bool ready() const { return m_time_ready; }
        int difference() const { return m_time_difference; }
        time_t nowTime() const { return m_time_ready ? ::time(0)+m_time_difference : -1; }
        bool ready() const { return m_time_ready; }
        int difference() const { return m_time_difference; }
index 4828e1fb9350e6c0f73b1b803f20945aa8a6cfcf..77142a7a024ab5137ab5ef5dfd016854a60d0fb4 100644 (file)
@@ -3,5 +3,6 @@ installdir = $(LIBDIR)/enigma2/python/Tools
 install_DATA = \
        FuzzyDate.py XMLTools.py Directories.py NumericalTextInput.py \
        KeyBindings.py BoundFunction.py ISO639.py Notifications.py __init__.py \
 install_DATA = \
        FuzzyDate.py XMLTools.py Directories.py NumericalTextInput.py \
        KeyBindings.py BoundFunction.py ISO639.py Notifications.py __init__.py \
-       RedirectOutput.py DreamboxHardware.py Import.py Event.py CList.py
+       RedirectOutput.py DreamboxHardware.py Import.py Event.py CList.py \
+       RedirectTime.py
 
 
diff --git a/lib/python/Tools/RedirectTime.py b/lib/python/Tools/RedirectTime.py
new file mode 100644 (file)
index 0000000..91c8002
--- /dev/null
@@ -0,0 +1,18 @@
+import time
+from enigma import eDVBLocalTimeHandler
+
+org_time = time.time
+time_difference = eDVBLocalTimeHandler.getInstance().difference()
+
+def myTime():
+       global time_difference
+       t = org_time()
+       t += time_difference
+       return t
+
+def timeChangedCallback():
+       global time_difference
+       time_difference = eDVBLocalTimeHandler.getInstance().difference()
+
+eDVBLocalTimeHandler.getInstance().m_timeUpdated.get().append(timeChangedCallback)
+time.time = myTime
\ No newline at end of file
index a79bb103a13f739369de67eacfb76ee9e5589db3..df8d8873d726a3cab8922aef7617b57c918fe3e6 100644 (file)
@@ -1,2 +1,2 @@
-all = ["FuzzyDate.py", "XMLTools.py", "Directories.py", "KeyBindings.py", "BoundFunction.py", "ISO639.py", "Notifications",
+all = ["RedirectTime.py", "FuzzyDate.py", "XMLTools.py", "Directories.py", "KeyBindings.py", "BoundFunction.py", "ISO639.py", "Notifications",
        "RedirectOutput.py", "DreamboxHardware.py"]
        "RedirectOutput.py", "DreamboxHardware.py"]
index 8ee7fb3918ce102d00942bde9d7408311cc548af..13eca6b4e2f8af3c6c5fd376acf28e9b08ba9302 100644 (file)
@@ -153,6 +153,7 @@ typedef long time_t;
 %immutable eDVBResourceManager::frontendUseMaskChanged;
 %immutable eAVSwitch::vcr_sb_notifier;
 %immutable ePythonMessagePump::recv_msg;
 %immutable eDVBResourceManager::frontendUseMaskChanged;
 %immutable eAVSwitch::vcr_sb_notifier;
 %immutable ePythonMessagePump::recv_msg;
+%immutable eDVBLocalTimeHandler::m_timeUpdated;
 %include <lib/base/message.h>
 %include <lib/base/console.h>
 %include <lib/base/nconfig.h>
 %include <lib/base/message.h>
 %include <lib/base/console.h>
 %include <lib/base/nconfig.h>
index 0eab8a65ac72df8ebdff30d8e4d45df30217d214..58c5c68039edcc79ffd8b8fdb39ba7ce90341009 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -1,4 +1,4 @@
-from Tools import RedirectOutput
+from Tools import RedirectOutput, RedirectTime
 from enigma import runMainloop, eDVBDB, eTimer, quitMainloop, eDVBVolumecontrol, \
        getDesktop, ePythonConfigQuery, eAVSwitch, eWindow, eServiceEvent
 from tools import *
 from enigma import runMainloop, eDVBDB, eTimer, quitMainloop, eDVBVolumecontrol, \
        getDesktop, ePythonConfigQuery, eAVSwitch, eWindow, eServiceEvent
 from tools import *