Merge branch 'vuplus_experimental' of code.vuplus.com:/opt/repository/dvbapp into...
authorChang.H.S <jhs@dev3>
Mon, 30 Jan 2012 05:38:15 +0000 (14:38 +0900)
committerChang.H.S <jhs@dev3>
Mon, 30 Jan 2012 05:38:15 +0000 (14:38 +0900)
lib/python/Plugins/Extensions/VuplusEvent/plugin.py
lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py
lib/python/Plugins/SystemPlugins/HDMICEC/plugin.py

index a0fd876..7b1d743 100755 (executable)
@@ -17,6 +17,7 @@ default_email_address = "Please input your E-mail address"
 config.plugins.vuplusauthenticity = ConfigSubsection()
 config.plugins.vuplusauthenticity.sn_a = NoSave(ConfigSelection(default = "MSA", choices = [ ("MSA", _("MSA")), ("MA", _("MA")), ("MB", _("MB")), ("MC", _("MC")), ("MD", _("MD")), ("ME", _("ME")), ("MF", _("MF")), ("MG", _("MG")), ("MH", _("MH"))] ))
 config.plugins.vuplusauthenticity.sn_b = NoSave(ConfigInteger(default = 0,  limits = (1, 999999999)))
+config.plugins.vuplusauthenticity.sn_b_msa = NoSave(ConfigInteger(default = 0,  limits = (1, 9999999)))
 config.plugins.vuplusauthenticity.email = NoSave(ConfigText(default = default_email_address, visible_width = 50, fixed_size = False))
 
 GENUINE_MESSAGES={
@@ -78,7 +79,10 @@ class VuplusAuthenticity(Screen, ConfigListScreen):
        def createSetup(self):
                self.list = []
                self.sn_aEntry = getConfigListEntry(_("1-1. Serial Number (The first two or three letters of SN)"), config.plugins.vuplusauthenticity.sn_a)
-               self.sn_bEntry = getConfigListEntry(_("1-2. Serial Number (The remaining numbers of SN)"), config.plugins.vuplusauthenticity.sn_b)
+               if config.plugins.vuplusauthenticity.sn_a.value == "MSA":
+                       self.sn_bEntry = getConfigListEntry(_("1-2. Serial Number (The remaining numbers of SN)"), config.plugins.vuplusauthenticity.sn_b_msa)
+               else:
+                       self.sn_bEntry = getConfigListEntry(_("1-2. Serial Number (The remaining numbers of SN)"), config.plugins.vuplusauthenticity.sn_b)
                self.emailEntry = getConfigListEntry(_("2. Contact"), config.plugins.vuplusauthenticity.email)
                self.list.append( self.sn_aEntry )
                self.list.append( self.sn_bEntry )
@@ -87,22 +91,27 @@ class VuplusAuthenticity(Screen, ConfigListScreen):
                self["config"].l.setList(self.list)
 
        def confirmValidSN(self):
-               sn = str(config.plugins.vuplusauthenticity.sn_b.value)
-               if len(sn) > 9:
-                       return False
-               elif sn == '0':
+               if config.plugins.vuplusauthenticity.sn_a.value == 'MSA':
+                       sn_length = 7
+                       sn = str(config.plugins.vuplusauthenticity.sn_b_msa.value)
+               else:
+                       sn_length = 9
+                       sn = str(config.plugins.vuplusauthenticity.sn_b.value)
+               if len(sn) > sn_length or sn == '0':
                        return False
                else:
-                       while(len(sn)<9):
+                       while(len(sn)<sn_length):
                                sn = '0'+sn
-                       if int(sn[:2]) not in range(28):
-                               return False
-                       elif int(sn[2:4]) not in range(1,53):
-                               return False
-                       elif int(sn[-5:]) == 0:
-                               return False
+                       if sn_length == 9:
+                               if int(sn[:2]) not in range(28) or int(sn[2:4]) not in range(1,53) or int(sn[-5:]) == 0:
+                                       return False
+                               else:
+                                       return True
                        else:
-                               return True
+                               if int(sn[:2]) not in range(1,53) or int(sn[-5:]) == 0:
+                                       return False
+                               else:
+                                       return True
 
        def displayResult(self, ret = -5):
                global GENUINE_MESSAGES
@@ -133,8 +142,13 @@ class VuplusAuthenticity(Screen, ConfigListScreen):
                if(not self.confirmValidSN()):
                        self.displayResult(-5)
                        return
-               sn_b = str(config.plugins.vuplusauthenticity.sn_b.value)
-               while(len(sn_b)<9):
+               if config.plugins.vuplusauthenticity.sn_a.value == 'MSA':
+                       sn_length = 7
+                       sn_b = str(config.plugins.vuplusauthenticity.sn_b_msa.value)
+               else:
+                       sn_length = 9
+                       sn_b = str(config.plugins.vuplusauthenticity.sn_b.value)
+               while(len(sn_b)<sn_length):
                        sn_b = '0'+sn_b
                serial_number = config.plugins.vuplusauthenticity.sn_a.value + sn_b
                model =self.getModel()
@@ -147,6 +161,14 @@ class VuplusAuthenticity(Screen, ConfigListScreen):
                except :
                        self.displayResult(-6)
 
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.createSetup()
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.createSetup()
+
        def keyExit(self):
                self.close()
 
index 63e9c0c..feeac5a 100755 (executable)
@@ -6,7 +6,7 @@ import Screens.Standby
 from Tools import Notifications
 import time
 from os import system
-
+from Tools.Directories import fileExists
 
 
 class HdmiCec:
@@ -72,19 +72,26 @@ class HdmiCec:
                        ("3", _("HDMI 3")),
                        ("4", _("HDMI 4")),
                        ("5", _("HDMI 5"))])
-               config.hdmicec.devicename = ConfigSelection(
-                       choices = {
-                       "vuduo": _("VU-Duo"),
-                       "vusolo": _("VU-Solo"),
-                       "vuuno": _("VU-Uno"),
-                       "vuultimo":_("VU-Ultimo"),
-                       },
-                       default = "vuduo")
-
+               config.hdmicec.devicename = ConfigText(default = self.getDeviceName(), visible_width = 50, fixed_size = False)
                config.misc.standbyCounter.addNotifier(self.enterStandby, initial_call = False)
                config.misc.DeepStandbyOn.addNotifier(self.enterDeepStandby, initial_call = False)
                self.leaveDeepStandby()
 
+       def getDeviceName(self):
+               deviceList = {
+                       "duo": "VU+ Duo",
+                       "solo": "VU+ Solo",
+                       "uno": "VU+ Uno",
+                       "ultimo": "VU+ Ultimo",
+               }
+               if fileExists("/proc/stb/info/vumodel"):
+                       vumodel = open("/proc/stb/info/vumodel")
+                       info=vumodel.read().strip()
+                       vumodel.close()
+                       return deviceList.setdefault(info, "VU+")
+               else:
+                       return "VU+"
+
        def sendMessages(self, messages):
                for message in messages.split(','):
                        cmd = None
index 329c85a..df595b9 100755 (executable)
@@ -400,21 +400,13 @@ def messageReceived(address, message):
                elif message == 0x46: # request device name
                        address = addresstv
                        cecmessage = setnamemessage
-                       if config.hdmicec.devicename.value == "vuduo":
-                               cecmessagetwo ="VU+ Duo"
-                               cmd = struct.pack('B8s',cecmessage,cecmessagetwo)
-                       elif config.hdmicec.devicename.value == "vusolo":
-                               cecmessagetwo ="VU+ Solo"
-                               cmd = struct.pack('B9s',cecmessage,cecmessagetwo)
-                       elif config.hdmicec.devicename.value == "vuuno":
-                               cecmessagetwo ="VU+ Uno"
-                               cmd = struct.pack('B8s',cecmessage,cecmessagetwo)
-                       elif config.hdmicec.devicename.value == "vuultimo":
-                               cecmessagetwo ="VU+ Ultimo"
-                               cmd = struct.pack('B8s',cecmessage,cecmessagetwo)
-                       else:
+                       name_len = len(config.hdmicec.devicename.value)
+                       if name_len == 0:
                                cecmessagetwo ="VU+"
                                cmd = struct.pack('B4s',cecmessage,cecmessagetwo)
+                       else:
+                               cecmessagetwo = config.hdmicec.devicename.value
+                               cmd = struct.pack('B'+str(name_len+1)+'s',cecmessage,cecmessagetwo)
                        logcmd = "[HDMI-CEC] send cec message %x:%s to %x" % (cecmessage,cecmessagetwo,address)
 
                elif message == 0x85: # request active source