ask to delete unconfigured satellites when leave tuner configuration
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 26 May 2008 22:12:24 +0000 (22:12 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 26 May 2008 22:12:24 +0000 (22:12 +0000)
lib/python/Components/NimManager.py
lib/python/Screens/Satconfig.py

index 471f65b90e64762d8e663c8f3daa4d5a067935d5..9662a10d2a374ed0715b955e4f473db3179b350b 100644 (file)
@@ -12,6 +12,8 @@ from enigma import eDVBSatelliteEquipmentControl as secClass, \
 from time import localtime, mktime
 from datetime import datetime
 
+from sets import Set
+
 def getConfigSatlist(orbpos, satlist):
        default_orbpos = None
        for x in satlist:
@@ -28,6 +30,13 @@ def tryOpen(filename):
        return procFile
 
 class SecConfigure:
+       def getConfiguredSats(self):
+               return self.configuredSatellites
+
+       def addSatellite(self, sec, orbpos):
+               sec.addSatellite(orbpos)
+               self.configuredSatellites.add(orbpos)
+
        def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST, useInputPower=True, inputPowerDelta=50):
                #simple defaults
                sec.addLNB()
@@ -55,8 +64,7 @@ class SecConfigure:
                #print "set orbpos to:" + str(orbpos)
 
                if 0 <= diseqcmode < 3:
-                       sec.addSatellite(orbpos)
-                       self.satList.append(orbpos)
+                       self.addSatellite(sec, orbpos)
                elif (diseqcmode == 3): # diseqc 1.2
                        if self.satposdepends.has_key(slotid):
                                tunermask |= (1 << self.satposdepends[slotid])
@@ -70,11 +78,10 @@ class SecConfigure:
 
                        for x in self.NimManager.satList:
                                print "Add sat " + str(x[0])
-                               sec.addSatellite(int(x[0]))
+                               self.addSatellite(sec, int(x[0]))
                                sec.setVoltageMode(0)
                                sec.setToneMode(0)
                                sec.setRotorPosNum(0) # USALS
-                               self.satList.append(int(x[0]))
 
                sec.setLNBSlotMask(tunermask)
 
@@ -86,14 +93,11 @@ class SecConfigure:
                print "link tuner", nim1, "to tuner", nim2
                sec.setTunerLinked(nim1, nim2)
 
-       def getSatList(self):
-               return self.satList
-
        def update(self):
                sec = secClass.getInstance()
+               self.configuredSatellites = Set()
                sec.clear() ## this do unlinking NIMs too !!
                print "sec config cleared"
-               self.satList = []
 
                self.linked = { }
                self.satposdepends = { }
@@ -323,7 +327,7 @@ class SecConfigure:
 
                                # finally add the orbital positions
                                for y in lnbSat[x]:
-                                       sec.addSatellite(y)
+                                       self.addSatellite(sec, y)
                                        currSat = config.Nims[slotid].advanced.sat[y]
 
                                        if currSat.voltage.value == "polarization":
@@ -347,6 +351,7 @@ class SecConfigure:
 
        def __init__(self, nimmgr):
                self.NimManager = nimmgr
+               self.configuredSatellites = Set()
                self.update()
 
 class NIM(object):
@@ -410,6 +415,9 @@ class NIM(object):
        empty = property(lambda self: self.type is None)
 
 class NimManager:
+       def getConfiguredSats(self):
+               return self.sec.getConfiguredSats()
+
        def getTransponders(self, pos):
                if self.transponders.has_key(pos):
                        return self.transponders[pos]
@@ -437,9 +445,6 @@ class NimManager:
        def getTerrestrialFlags(self, nim):
                return self.terrestrialsList[config.Nims[nim].terrestrial.index][1]
 
-       def getConfiguredSats(self):
-               return self.sec.getSatList()
-
        def getSatDescription(self, pos):
                return self.satellites[pos]
 
index 9f22013dcce3e1ccc3a4344a0789a72cb0c957c8..bd97948f6c23c7950cf55e4b28b7a0b5e9b72b96 100644 (file)
@@ -1,9 +1,11 @@
+from enigma import eDVBDB
 from Screen import Screen
 from Components.ActionMap import ActionMap
 from Components.ConfigList import ConfigListScreen
 from Components.MenuList import MenuList
 from Components.NimManager import nimmanager
 from Components.config import getConfigListEntry, config, ConfigNothing
+from Screens.MessageBox import MessageBox
 
 from time import mktime, localtime
 from datetime import datetime
@@ -147,7 +149,37 @@ class NimSetup(Screen, ConfigListScreen):
                                dt = datetime(1970, 1, 1, tm.tm_hour, tm.tm_min)
                                x[1].value = int(mktime(dt.timetuple()))
                        x[1].save()
+
+               old_configured_sats = nimmanager.getConfiguredSats()
                nimmanager.sec.update()
+               new_configured_sats = nimmanager.getConfiguredSats()
+               self.unconfed_sats = old_configured_sats - new_configured_sats
+               self.satpos_to_remove = None
+               self.deleteConfirmed(False)
+
+       def deleteConfirmed(self, confirmed):
+               if confirmed:
+                       eDVBDB.getInstance().removeServices(-1, -1, -1, self.satpos_to_remove)
+
+               if self.satpos_to_remove is not None:
+                       self.unconfed_sats.remove(self.satpos_to_remove)
+
+               self.satpos_to_remove = None
+               for orbpos in self.unconfed_sats:
+                       self.satpos_to_remove = orbpos
+                       orbpos = self.satpos_to_remove
+                       try:
+                               # why we need this cast?
+                               sat_name = str(nimmanager.getSatDescription(orbpos))
+                       except:
+                               if orbpos > 1800: # west
+                                       orbpos = 3600 - orbpos
+                                       h = _("W")
+                               else:
+                                       h = _("E")
+                               sat_name = ("%d.%d" + h) % (orbpos / 10, orbpos % 10)
+                       self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Delete no more configured satellite\n%s?") %(sat_name))
+                       break
 
        def fillListWithAdvancedSatEntrys(self, Sat):
                currLnb = self.nimConfig.advanced.lnb[int(Sat.lnb.value)]