allows to configure the path for timeshift recordings via gui, by Moritz Venn. closes...
authorFelix Domke <tmbinc@elitedvb.net>
Sun, 16 Nov 2008 23:00:43 +0000 (00:00 +0100)
committerFelix Domke <tmbinc@elitedvb.net>
Sun, 16 Nov 2008 23:00:43 +0000 (00:00 +0100)
data/menu.xml
lib/python/Components/UsageConfig.py
lib/python/Screens/LocationBox.py
lib/service/servicedvb.cpp

index 93455b2314bcb3ea9fb48474a8c87437cfedb979..369b20e0b9c5cb25600ee3c2f51c7dd67d7d407c 100644 (file)
@@ -70,6 +70,7 @@
                                        <item level="1" text="Device Setup..." entryID="device_setup"><screen module="NetworkSetup" screen="NetworkAdapterSelection"/></item>
                                        <item level="1" text="Nameserver Setup..." entryID="dns_setup"><screen module="NetworkSetup" screen="NameserverSetup"/></item>
                                </menu>-->
                                        <item level="1" text="Device Setup..." entryID="device_setup"><screen module="NetworkSetup" screen="NetworkAdapterSelection"/></item>
                                        <item level="1" text="Nameserver Setup..." entryID="dns_setup"><screen module="NetworkSetup" screen="NameserverSetup"/></item>
                                </menu>-->
+                               <item level="2" text="Timeshift path..." entryId="timeshift_path"><screen module="LocationBox" screen="TimeshiftLocationBox" /></item>
                        </menu>
                        <item level="1" text="Common Interface" entryID="ci_setup" requires="CommonInterface"><screen module="Ci" screen="CiSelection" /></item>
                        <item level="0" text="Parental control" entryID="parental_setup"><screen module="ParentalControlSetup" screen="ParentalControlSetup" /></item>
                        </menu>
                        <item level="1" text="Common Interface" entryID="ci_setup" requires="CommonInterface"><screen module="Ci" screen="CiSelection" /></item>
                        <item level="0" text="Parental control" entryID="parental_setup"><screen module="ParentalControlSetup" screen="ParentalControlSetup" /></item>
index 714d366d01442d2c3a964d8c0e503b767cffffa6..6ed87840981a036fb30c25e12fc5bdef16d32478 100644 (file)
@@ -1,5 +1,5 @@
 from Components.Harddisk import harddiskmanager
 from Components.Harddisk import harddiskmanager
-from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigNumber, ConfigSet
+from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigNumber, ConfigSet, ConfigLocations
 from enigma import Misc_Options, setTunerTypePriorityOrder;
 from SystemInfo import SystemInfo
 import os
 from enigma import Misc_Options, setTunerTypePriorityOrder;
 from SystemInfo import SystemInfo
 import os
@@ -30,6 +30,9 @@ def InitUsageConfig():
                ("standard", _("standard")), ("swap", _("swap PiP and main picture")),
                ("swapstop", _("move PiP to main picture")), ("stop", _("stop PiP")) ])
 
                ("standard", _("standard")), ("swap", _("swap PiP and main picture")),
                ("swapstop", _("move PiP to main picture")), ("stop", _("stop PiP")) ])
 
+       config.usage.allowed_timeshift_paths = ConfigLocations(default = ["/media/hdd/"])
+       config.usage.timeshift_path = ConfigText(default = "/media/hdd")
+
        config.usage.on_movie_start = ConfigSelection(default = "ask", choices = [
                ("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
        config.usage.on_movie_stop = ConfigSelection(default = "ask", choices = [
        config.usage.on_movie_start = ConfigSelection(default = "ask", choices = [
                ("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
        config.usage.on_movie_stop = ConfigSelection(default = "ask", choices = [
index 7cd6cbf9d6a7d0e68873bddd5383a3873491ce3d..68d4f772ca09b79ce78d36ffed764e2a2155a59f 100644 (file)
@@ -503,3 +503,32 @@ class MovieLocationBox(LocationBox):
        def __init__(self, session, text, dir, minFree = None):
                inhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/lib", "/proc", "/sbin", "/sys", "/usr", "/var"]
                LocationBox.__init__(self, session, text = text, currDir = dir, bookmarks = config.movielist.videodirs, autoAdd = True, editDir = True, inhibitDirs = inhibitDirs, minFree = minFree)
        def __init__(self, session, text, dir, minFree = None):
                inhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/lib", "/proc", "/sbin", "/sys", "/usr", "/var"]
                LocationBox.__init__(self, session, text = text, currDir = dir, bookmarks = config.movielist.videodirs, autoAdd = True, editDir = True, inhibitDirs = inhibitDirs, minFree = minFree)
+
+class TimeshiftLocationBox(LocationBox):
+
+       skinName = "LocationBox" # XXX: though we could use a custom skin or inherit the hardcoded one we stick with the original :-)
+
+       def __init__(self, session):
+               inhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/lib", "/proc", "/sbin", "/sys", "/usr", "/var"]
+               LocationBox.__init__(
+                               self,
+                               session,
+                               text = _("Where to save temporary timeshift recordings?"),
+                               currDir = config.usage.timeshift_path.value,
+                               bookmarks = config.usage.allowed_timeshift_paths,
+                               autoAdd = True,
+                               editDir = True,
+                               inhibitDirs = inhibitDirs,
+                               minFree = 1024 # XXX: the same requirement is hardcoded in servicedvb.cpp
+               )
+
+       def cancel(self):
+               config.usage.timeshift_path.cancel()
+               LocationBox.cancel(self)
+
+       def selectConfirmed(self, ret):
+               if ret:
+                       config.usage.timeshift_path.value = self.getPreferredFolder()
+                       config.usage.timeshift_path.save()
+                       LocationBox.selectConfirmed(self, ret)
+
index 6c1e46f7bf472c125cf79e95e7b25303585fbf61..4141236a7df521abde818014e08a5e7ff703890c 100644 (file)
@@ -31,8 +31,6 @@
 #error no byte order defined!
 #endif
 
 #error no byte order defined!
 #endif
 
-#define TSPATH "/media/hdd"
-
 class eStaticServiceDVBInformation: public iStaticServiceInformation
 {
        DECLARE_REF(eStaticServiceDVBInformation);
 class eStaticServiceDVBInformation: public iStaticServiceInformation
 {
        DECLARE_REF(eStaticServiceDVBInformation);
@@ -1494,9 +1492,16 @@ RESULT eDVBServicePlay::timeshift(ePtr<iTimeshiftService> &ptr)
        {
                if (!m_timeshift_enabled)
                {
        {
                if (!m_timeshift_enabled)
                {
-                               /* we need enough diskspace */
+                       /* query config path */
+                       std::string tspath;
+                       if(ePythonConfigQuery::getConfigValue("config.usage.timeshift_path", tspath) == -1){
+                               eDebug("could not query ts path from config");
+                               return -4;
+                       }
+                       tspath.append("/");
+                       /* we need enough diskspace */
                        struct statfs fs;
                        struct statfs fs;
-                       if (statfs(TSPATH "/.", &fs) < 0)
+                       if (statfs(tspath.c_str(), &fs) < 0)
                        {
                                eDebug("statfs failed!");
                                return -2;
                        {
                                eDebug("statfs failed!");
                                return -2;
@@ -2114,12 +2119,23 @@ RESULT eDVBServicePlay::startTimeshift()
        if (!m_record)
                return -3;
 
        if (!m_record)
                return -3;
 
-       char templ[]=TSPATH "/timeshift.XXXXXX";
+       std::string tspath;
+       if(ePythonConfigQuery::getConfigValue("config.usage.timeshift_path", tspath) == -1){ 
+               eDebug("could not query ts path");
+               return -5;
+       }
+       tspath.append("/timeshift.XXXXXX");
+       char* templ;
+       templ = new char[tspath.length() + 1];
+       strcpy(templ, tspath.c_str());
+
        m_timeshift_fd = mkstemp(templ);
        m_timeshift_fd = mkstemp(templ);
-       m_timeshift_file = templ;
-       
+       m_timeshift_file = std::string(templ);
+
        eDebug("recording to %s", templ);
        eDebug("recording to %s", templ);
-       
+
+       delete [] templ;
+
        if (m_timeshift_fd < 0)
        {
                m_record = 0;
        if (m_timeshift_fd < 0)
        {
                m_record = 0;