Merge branch 'vuplus_experimental' of code.vuplus.com:/opt/repository/dvbapp into...
[vuplus_dvbapp] / lib / python / Plugins / Extensions / VuplusEvent / plugin.py
index 03a9283..fa476ea 100755 (executable)
@@ -15,8 +15,9 @@ 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_a = NoSave(ConfigSelection(default = "MSA", choices = [ ("MSA", _("MSA")), ("MA", _("MA")), ("MB", _("MB")), ("MC", _("MC")), ("C", _("C")), ("D", _("D")), ("E", _("E")), ("F", _("F")), ("G", _("G"))] ))
+config.plugins.vuplusauthenticity.sn_b = NoSave(ConfigInteger(default = 0,  limits = (1, 9999999999)))
+config.plugins.vuplusauthenticity.sn_b_mx = 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))
 
@@ -31,29 +32,20 @@ GENUINE_MESSAGES={
 }
 
 class VuplusAuthenticity(Screen, ConfigListScreen):
-       def __init__(self,session):
-               if session.desktop.size().width() > 720:
-                       self.skin = """
-                       <screen name="VuplusAuthenticity" position="center,center" size="800,370" title="Return the Love Event (only for genuine box)">
-                       <ePixmap pixmap="Vu_HD/buttons/red.png" position="250,15" size="25,25" alphatest="on" />
-                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="435,15" size="25,25" alphatest="on" />
-                       <widget source="key_red" render="Label" position="265,15" zPosition="1" size="140,25" font="Regular;24" halign="center" valign="center" transparent="1" />
-                       <widget source="key_green" render="Label" position="450,15" zPosition="1" size="140,25" font="Regular;24" halign="center" valign="center" transparent="1" />
-                       <widget name="config" zPosition="2" position="80,70" size="640,80" scrollbarMode="showOnDemand" transparent="1" />
-                       <widget name="text1" position="0,165" size="800,90" font="Regular;32" halign="center" valign="center"/>
-                       <widget name="text2" position="100,260" size="600,110" font="Regular;24" halign="center" valign="center"/>
-                       </screen>"""
+       skin =  """
+               <screen name="VuplusAuthenticity" position="center,center" size="600,320" title="Return the Love Event (only for genuine box)">
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="140,15" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="320,15" size="140,40" alphatest="on" />
+
+                       <widget source="key_red" render="Label" position="140,15" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
+                       <widget source="key_green" render="Label" position="320,15" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
 
-               else:
-                       self.skin="""<screen name="VuplusAuthenticity" position="center,center" size="600,320" title="Return the Love Event (only for genuine box)">
-                       <ePixmap pixmap="Vu_HD/buttons/red.png" position="170,15" size="25,25" alphatest="on" />
-                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="355,15" size="25,25" alphatest="on" />
-                       <widget source="key_red" render="Label" position="185,15" zPosition="1" size="140,25" font="Regular;24" halign="center" valign="center" transparent="1" />
-                       <widget source="key_green" render="Label" position="370,15" zPosition="1" size="140,25" font="Regular;24" halign="center" valign="center" transparent="1" />
                        <widget name="config" zPosition="2" position="10,70" size="580,80" scrollbarMode="showOnDemand" transparent="1" />
                        <widget name="text1" position="10,160" size="580,50" font="Regular;32" halign="center" valign="center"/>
                        <widget name="text2" position="10,220" size="580,100" font="Regular;18" halign="center" valign="center"/>
-                       </screen>"""
+               </screen>
+               """
+       def __init__(self,session):
                Screen.__init__(self,session)
                self.session = session
                self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
@@ -90,6 +82,8 @@ class VuplusAuthenticity(Screen, ConfigListScreen):
                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)
+               elif config.plugins.vuplusauthenticity.sn_a.value in [ 'MA', 'MB', 'MC' ]:
+                       self.sn_bEntry = getConfigListEntry(_("1-2. Serial Number (The remaining numbers of SN)"), config.plugins.vuplusauthenticity.sn_b_mx)
                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)
@@ -103,14 +97,22 @@ class VuplusAuthenticity(Screen, ConfigListScreen):
                if config.plugins.vuplusauthenticity.sn_a.value == 'MSA':
                        sn_length = 7
                        sn = str(config.plugins.vuplusauthenticity.sn_b_msa.value)
-               else:
+               elif config.plugins.vuplusauthenticity.sn_a.value in [ 'MA', 'MB', 'MC' ]:
                        sn_length = 9
+                       sn = str(config.plugins.vuplusauthenticity.sn_b_mx.value)
+               else:
+                       sn_length = 10
                        sn = str(config.plugins.vuplusauthenticity.sn_b.value)
                if len(sn) > sn_length or sn == '0':
                        return False
                else:
                        while(len(sn)<sn_length):
                                sn = '0'+sn
+                       if sn_length == 10:
+                               if int(sn[:3]) == 0 or int(sn[3:5]) not in range(1,53) or int(sn[-5:]) == 0:
+                                       return False
+                               else:
+                                       return True
                        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
@@ -154,8 +156,11 @@ class VuplusAuthenticity(Screen, ConfigListScreen):
                if config.plugins.vuplusauthenticity.sn_a.value == 'MSA':
                        sn_length = 7
                        sn_b = str(config.plugins.vuplusauthenticity.sn_b_msa.value)
-               else:
+               if config.plugins.vuplusauthenticity.sn_a.value in [ 'MA', 'MB', 'MC' ]:
                        sn_length = 9
+                       sn_b = str(config.plugins.vuplusauthenticity.sn_b_mx.value)
+               else:
+                       sn_length = 10
                        sn_b = str(config.plugins.vuplusauthenticity.sn_b.value)
                while(len(sn_b)<sn_length):
                        sn_b = '0'+sn_b
@@ -183,12 +188,12 @@ class VuplusAuthenticity(Screen, ConfigListScreen):
 
 class MessageBoxGenuine(MessageBox):
        skin = """
-               <screen position="center,center" size="600,10" title="Message">
+               <screen name="MessageBoxGenuine" position="center,center" size="600,10" title="Message">
                <widget name="text" position="65,8" size="420,0" font="Regular;22" />
                <widget name="ErrorPixmap" pixmap="Vu_HD/icons/input_error.png" position="5,5" size="53,53" alphatest="blend" />
                <widget name="QuestionPixmap" pixmap="Vu_HD/icons/input_question.png" position="5,5" size="53,53" alphatest="blend" />
                <widget name="InfoPixmap" pixmap="Vu_HD/icons/input_info.png" position="5,5" size="53,53" alphatest="blend" />
-               <widget name="list" position="100,100" size="380,375" transparent="1" backgroundColor="darkgrey" />
+               <widget name="list" position="100,100" size="380,375" transparent="1" />
                <applet type="onLayoutFinish">
 # this should be factored out into some helper code, but currently demonstrates applets.
 from enigma import eSize, ePoint