from Screens.Screen import Screen
from Components.ActionMap import ActionMap
from Components.ConfigList import ConfigListScreen
from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigText, ConfigInteger,NoSave
from Components.Sources.StaticText import StaticText
from Components.Label import Label
from Plugins.Plugin import PluginDescriptor
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, fileExists
from Screens.MessageBox import MessageBox
from enigma import eTimer
import vuplusauthenticity
import os
import socket
import urllib2
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={
-6 : "UNEXPECTED ERROR(2).",
-5 : "INVALID SERIAL NUMBER.",
-4 : " Connect to server failed, \nplease check your network configuration and retry.",
-3 : "UNEXPECTED ERROR(1).",
-2 : "DEVICE OPEN ERROR.",
-1 : "AUTHENTICATION FAILED.",
0 : "AUTHENTICATION SUCCESS."
}
class VuplusAuthenticity(Screen, ConfigListScreen):
def __init__(self,session):
if session.desktop.size().width() > 720:
self.skin = """
"""
else:
self.skin="""
"""
Screen.__init__(self,session)
self.session = session
self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
{
"ok": self.Start,
"cancel": self.keyExit,
"red": self.keyExit,
"green": self.Start,
}, -2)
self.genuine = None
self.list = []
ConfigListScreen.__init__(self, self.list, session = self.session)
self["key_red"] = StaticText(_("Exit"))
self["key_green"] = StaticText(_("Start"))
self["text1"]=Label("Press green button to start")
self["text2"]=Label("With this plugin you can verify the authenticity of your Vu+.\nFor more information, please visit our website \nhttp://vuplus.com")
self.createSetup()
self.onLayoutFinish.append(self.checkKernelVer)
self.checkTimer = eTimer()
self.checkTimer.callback.append(self.invalidKVer)
self.requestauth_timer = eTimer()
self.requestauth_timer.callback.append(self.requestauth)
def checkKernelVer(self):
KVer = os.uname()[2]
if float(KVer[:3]) < 3.1:
self.checkTimer.start(0,True)
def invalidKVer(self):
self.session.openWithCallback(self.close, MessageBox, _("For use this plugin, you must update the kernel version to 3.1 or later"), MessageBox.TYPE_ERROR)
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)
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 )
self.list.append( self.emailEntry )
self["config"].list = self.list
self["config"].l.setList(self.list)
def confirmValidSN(self):
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)
"""
def __init__(self, session, text, type = MessageBox.TYPE_YESNO, timeout = -1, close_on_any_key = False, default = True, enable_input = True, msgBoxID = None):
MessageBox.__init__(self,session, text, type, timeout, close_on_any_key, default, enable_input,msgBoxID)
if type == MessageBox.TYPE_YESNO:
self.list = [ (_("Agree"), 0), (_("Exit"), 1) ]
self["list"].setList(self.list)
def main(session, **kwargs):
session.open(VuplusAuthenticity)
def Plugins(**kwargs):
return [PluginDescriptor(name=_("Return the Love Event"), description="Don't lose the chance to get the gift.", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)]