Support DVB-S2X for uno4k, ultimo4k, uno4kse.
[vuplus_openvuplus_3.0] / meta-bsp / recipes-vuplus / enigma2 / enigma2 / enigma2_vuplus_check_recording.patch
1 diff --git a/RecordTimer.py b/RecordTimer.py
2 index 58ef5b3..6e0862e 100755
3 --- a/RecordTimer.py
4 +++ b/RecordTimer.py
5 @@ -410,6 +410,15 @@ class RecordTimerEntry(timer.TimerEntry, object):
6  
7         record_service = property(lambda self: self.__record_service, setRecordService)
8  
9 +       def checkRecordingPath(self):
10 +               old_Filename = self.Filename
11 +               self.calculateFilename()
12 +               filename = self.Filename
13 +               self.Filename = old_Filename
14 +
15 +               from Components import Harddisk
16 +               return not Harddisk.isUsbStorage(filename)
17 +
18  def createTimer(xml):
19         begin = int(xml.get("begin"))
20         end = int(xml.get("end"))
21 @@ -466,6 +475,16 @@ class RecordTimer(timer.Timer):
22                         print "unable to load timers from file!"
23  
24         def doActivate(self, w):
25 +               if w.state == RecordTimerEntry.StateWaiting and w.checkRecordingPath() is False:
26 +                       service_name = w.service_ref.getServiceName()
27 +                       self.timer_list.remove(w)
28 +                       if w.dontSave is False:
29 +                               w.resetState()
30 +                               w.disable()
31 +                               self.addTimerEntry(w)
32 +                       Notifications.AddNotification(MessageBox, _("Can not recording on a USB storage.\nService name : %s"% service_name), MessageBox.TYPE_ERROR)
33 +                       return
34 +
35                 # when activating a timer which has already passed,
36                 # simply abort the timer. don't run trough all the stages.
37                 if w.shouldSkip():
38 diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py
39 index fe99426..e40f1b5 100755
40 --- a/lib/python/Components/Harddisk.py
41 +++ b/lib/python/Components/Harddisk.py
42 @@ -58,6 +58,30 @@ def enableUdevEvent(enable = True):
43         print "CMD : ", cmd
44         system(cmd)
45  
46 +def getDeviceFile(dev_path):
47 +       for parts in getProcMounts():
48 +               if os.path.realpath(parts[1]).startswith(dev_path):
49 +                       return parts[0]
50 +
51 +def isUsbStorage(filename):
52 +       _dirname = os.path.dirname(filename)
53 +       _dirname = os.path.realpath(_dirname)
54 +       while not os.path.ismount(_dirname):
55 +               _dirname = os.path.dirname(_dirname)
56 +
57 +       if _dirname == '/':
58 +               return False
59 +
60 +       dev = getDeviceFile(_dirname)
61 +       if dev:
62 +               dev = os.path.basename(dev)
63 +               phyPath = os.path.realpath('/sys/block/' + dev[:3])
64 +               for x in glob.glob("/sys/bus/usb/devices/usb*"):
65 +                       if phyPath.find(os.path.realpath(x)) != -1:
66 +                               return True
67 +
68 +       return False
69 +
70  DEVTYPE_UDEV = 0
71  DEVTYPE_DEVFS = 1
72  
73 diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py
74 index baeaacb..cb28ffc 100755
75 --- a/lib/python/Screens/InfoBarGenerics.py
76 +++ b/lib/python/Screens/InfoBarGenerics.py
77 @@ -1239,6 +1239,11 @@ class InfoBarTimeshift:
78                 if self.timeshift_enabled:
79                         print "hu, timeshift already enabled?"
80                 else:
81 +                       from Components import Harddisk
82 +                       if Harddisk.isUsbStorage(config.usage.timeshift_path.value):
83 +                               self.session.open(MessageBox, _("Timeshift not possible on a USB storage."), MessageBox.TYPE_ERROR)
84 +                               return 0
85 +
86                         if not ts.startTimeshift():
87                                 self.timeshift_enabled = 1
88  
89 diff --git a/timer.py b/timer.py
90 index aaae0b2..d58a83e 100644
91 --- a/timer.py
92 +++ b/timer.py
93 @@ -232,6 +232,10 @@ class Timer:
94                 self.setNextActivation(min)
95         
96         def timeChanged(self, timer):
97 +               if timer not in (self.processed_timers + self.timer_list):
98 +                       print "timer not found"
99 +                       return
100 +
101                 print "time changed"
102                 timer.timeChanged()
103                 if timer.state == TimerEntry.StateEnded: