HDMICEC : fix default device name
authorChang.H.S <jhs@dev3>
Mon, 30 Jan 2012 04:23:48 +0000 (13:23 +0900)
committerChang.H.S <jhs@dev3>
Mon, 30 Jan 2012 04:23:48 +0000 (13:23 +0900)
lib/python/Plugins/SystemPlugins/HDMICEC/components/HdmiCec.py
lib/python/Plugins/SystemPlugins/HDMICEC/plugin.py

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 9603d14..a0c2823 100755 (executable)
@@ -411,21 +411,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