1 from Screens.Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.ConfigList import ConfigListScreen
4 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigText, ConfigInteger,NoSave
5 from Components.Sources.StaticText import StaticText
6 from Components.Label import Label
7 from Plugins.Plugin import PluginDescriptor
8 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, fileExists
9 from Screens.MessageBox import MessageBox
10 from enigma import eTimer
16 default_email_address = "Please input your E-mail address"
17 config.plugins.genuinevuplus = ConfigSubsection()
18 config.plugins.genuinevuplus.sn_a = NoSave(ConfigSelection(default = "MA", choices = [ ("MA", _("MA")), ("MB", _("MB")), ("MC", _("MC")), ("MD", _("MD")), ("ME", _("ME")), ("MF", _("MF")), ("MG", _("MG")), ("MH", _("MH"))] ))
19 config.plugins.genuinevuplus.sn_b = NoSave(ConfigInteger(default = 0, limits = (1, 999999999)))
20 config.plugins.genuinevuplus.email = NoSave(ConfigText(default = default_email_address, visible_width = 50, fixed_size = False))
23 -6 : "The server responded with an error message.",
24 -5 : " Connect to server failed, \nplease check your network configuration and retry.",
25 -4 : "UNEXPECTED ERROR.",
26 -3 : "INVALID SERIAL NUMBER.",
27 -2 : "DEVICE OPEN ERROR.",
28 -1 : "AUTHENTICATION FAILED.",
29 0 : "AUTHENTICATION SUCESS."
32 class GenuineVuplus(Screen, ConfigListScreen):
33 def __init__(self,session):
34 if session.desktop.size().width() > 720:
36 <screen name="GenuineVuplus" position="center,center" size="800,370" title="Genuine Vuplus">
37 <ePixmap pixmap="Vu_HD/buttons/red.png" position="250,15" size="25,25" alphatest="on" />
38 <ePixmap pixmap="Vu_HD/buttons/green.png" position="435,15" size="25,25" alphatest="on" />
39 <widget source="key_red" render="Label" position="265,15" zPosition="1" size="140,25" font="Regular;24" halign="center" valign="center" transparent="1" />
40 <widget source="key_green" render="Label" position="450,15" zPosition="1" size="140,25" font="Regular;24" halign="center" valign="center" transparent="1" />
41 <widget name="config" zPosition="2" position="80,70" size="640,80" scrollbarMode="showOnDemand" transparent="1" />
42 <widget name="text1" position="0,165" size="800,90" font="Regular;32" halign="center" valign="center"/>
43 <widget name="text2" position="100,260" size="600,110" font="Regular;24" halign="center" valign="center"/>
47 self.skin="""<screen name="GenuineVuplus" position="center,center" size="600,320" title="Genuine Vuplus">
48 <ePixmap pixmap="Vu_HD/buttons/red.png" position="170,15" size="25,25" alphatest="on" />
49 <ePixmap pixmap="Vu_HD/buttons/green.png" position="355,15" size="25,25" alphatest="on" />
50 <widget source="key_red" render="Label" position="185,15" zPosition="1" size="140,25" font="Regular;24" halign="center" valign="center" transparent="1" />
51 <widget source="key_green" render="Label" position="370,15" zPosition="1" size="140,25" font="Regular;24" halign="center" valign="center" transparent="1" />
52 <widget name="config" zPosition="2" position="10,70" size="580,80" scrollbarMode="showOnDemand" transparent="1" />
53 <widget name="text1" position="10,160" size="580,50" font="Regular;32" halign="center" valign="center"/>
54 <widget name="text2" position="10,220" size="580,100" font="Regular;18" halign="center" valign="center"/>
56 Screen.__init__(self,session)
57 self.session = session
58 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
61 "cancel": self.keyExit,
67 ConfigListScreen.__init__(self, self.list, session = self.session)
68 self["key_red"] = StaticText(_("Exit"))
69 self["key_green"] = StaticText(_("Start"))
70 self["text1"]=Label("Press green button to start")
71 self["text2"]=Label("With this plugin you can verify the authenticity of your Vu+.\nFor more information, please visit our website \nhttp://vuplus.com")
73 self.onLayoutFinish.append(self.checkKernelVer)
74 self.checkTimer = eTimer()
75 self.checkTimer.callback.append(self.invalidKVer)
76 self.connectToServerTimer = eTimer()
77 self.connectToServerTimer.callback.append(self.connectToServer)
79 def checkKernelVer(self):
81 if float(KVer[:3]) < 3.1:
82 self.checkTimer.start(0,True)
84 def invalidKVer(self):
85 self.session.openWithCallback(self.close, MessageBox, _("For use this plugin, you must update the kernel version to 3.1 or later"), MessageBox.TYPE_ERROR)
87 def createSetup(self):
89 self.sn_aEntry = getConfigListEntry(_("1-1. Serial Number (The first two letters of SN)"), config.plugins.genuinevuplus.sn_a)
90 self.sn_bEntry = getConfigListEntry(_("1-2. Serial Number (The remaining numbers of SN)"), config.plugins.genuinevuplus.sn_b)
91 self.emailEntry = getConfigListEntry(_("2. Contact"), config.plugins.genuinevuplus.email)
92 self.list.append( self.sn_aEntry )
93 self.list.append( self.sn_bEntry )
94 self.list.append( self.emailEntry )
95 self["config"].list = self.list
96 self["config"].l.setList(self.list)
98 def confirmValidSN(self):
99 sn = str(config.plugins.genuinevuplus.sn_b.value)
107 if int(sn[:2]) not in range(28):
109 elif int(sn[2:4]) not in range(1,53):
111 elif int(sn[-5:]) == 0:
116 def displayResult(self, ret = -5):
117 global GENUINE_MESSAGES
118 self["text1"].setText(GENUINE_MESSAGES[ret])
119 self["key_green"].text = _("Restart")
122 self["text1"].setText("WAITING......")
123 if(not self.confirmValidSN()):
124 self.displayResult(-3)
127 ret=genuinevuplus.requestauth()
129 self.displayResult(-4)
130 if ret == 0 or ret == -1:
131 # self.connectToServer(ret)
133 self.connectToServerTimer.start(0,True)
135 self.displayResult(-2)
138 if fileExists("/proc/stb/info/vumodel"):
139 vumodel = open("/proc/stb/info/vumodel")
140 info=vumodel.read().strip()
146 def connectToServer(self):
147 sn_b = str(config.plugins.genuinevuplus.sn_b.value)
148 for n in range(9-len(sn_b)):
150 serial_number = config.plugins.genuinevuplus.sn_a.value + sn_b
152 model =self.getModel()
154 email = config.plugins.genuinevuplus.email.value
155 if len(email) == 0 or email == default_email_address:
158 URL = "http://code.vuplus.com/genuine.php?serial=%s&yn=%s&model=%s&email=%s"%(serial_number, self.genuine == 0 and 'y' or self.genuine == -1 and 'n' or 'n' ,model, email)
165 socket.setdefaulttimeout(timeout)
166 response = urllib2.urlopen(URL)
168 except urllib2.URLError, e:
169 if hasattr(e, 'reason'):
170 print '[Genuine vuplus] Failed to reach a server.'
171 print '[Genuine vuplus] Reason : ', e.reason
172 elif hasattr(e, 'code'):
173 print '[Genuine vuplus] The server could not fullfill the request.'
174 print '[Genuine vuplus] Error code: ', e.code
176 print "[Genuine vuplus] retry..."
180 except socket.timeout:
181 print "[Genuine vuplus] Socket time out."
183 print "[Genuine vuplus] retry..."
188 if response is not None:
189 if response.read() == 'YES':
190 self.displayResult(self.genuine)
192 self.displayResult(-6)
194 self.displayResult(-5)
199 def main(session, **kwargs):
200 session.open(GenuineVuplus)
202 def Plugins(**kwargs):
203 return [PluginDescriptor(name=_("Genuine Vuplus"), description="Support for verifying the authenticity of your Vu+.", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)]