def __init__(self, session, params):
        self.session = session
        self.markerWidth = 100

        self.skin = """
            <screen position="center,center" title="%s" size="500,200">
             <widget name="statustext" position="5,5" zPosition="1" size="490,60" font="Regular;24" transparent="1" halign="center" valign="center" backgroundColor="black"/>
             <widget name="marker"  zPosition="4" position="5,75"  size="100,100" transparent="1" alphatest="blend" />
             <widget name="cover_0" zPosition="2" position="10,80"  size="90,90" transparent="1" alphatest="blend" />
             <widget name="cover_1" zPosition="2" position="115,80" size="90,90" transparent="1" alphatest="blend" />
             <widget name="cover_2" zPosition="2" position="220,80" size="90,90" transparent="1" alphatest="blend" />
             <widget name="cover_3" zPosition="2" position="325,80" size="90,90" transparent="1" alphatest="blend" />
             <widget name="cover"   zPosition="2" position="430,80" size="65,68" transparent="1" alphatest="blend" />
            </screen>""" % (params.get('title', ''))

        Screen.__init__(self, session)

        self["actions"] = ActionMap(
            ["WizardActions", "DirectionActions", "ColorActions"], {
                "left": self.keyLeft,
                "right": self.keyRight,
                "ok": self.keyOK,
                "back": self.keyCancel,
            }, -1)

        self["statustext"] = Label(params.get('challenge', ''))
        self.markerPixmap = LoadPixmap(GetIconDir('markerCaptchaV2.png'))

        self.iconList = params.get('icon_list')

        for i in range(4):
            strIndx = "cover_%d" % i
            self[strIndx] = Cover2()
        self['cover'] = Cover2()
        self["marker"] = Cover3()

        self.selIdx = 0
        self.maxIcons = len(self.iconList) - 1
        self.onLayoutFinish.append(self.onStart)
Example #2
0
 def __init__(self, session, title = '', text = '', additionalParams={}):
     
     self.skin='''  <screen name="IPTVVirtualKeyBoardWithCaptcha" position="fill" zPosition="99" title="Virtual KeyBoard">
                         <widget name="captcha" position="%d,%d" size="%d,%d" zPosition="2" transparent="1" alphatest="on" />
                         <ePixmap pixmap="skin_default/vkey_text.png" position="300,245" zPosition="-4" size="542,52" alphatest="on" />
                         <widget name="header" position="300,210" size="500,30" font="Regular;20" transparent="1" noWrap="1" />
                         <widget name="text" position="302,250" size="536,46" font="Regular;42" transparent="1" noWrap="1" halign="right" />
                         <widget name="list" position="300,300" size="680,240" selectionDisabled="1" transparent="1" />
                    </screen>
         ''' % (300, 200 -  additionalParams['captcha_size'][1], additionalParams['captcha_size'][0], additionalParams['captcha_size'][1])
     #300 + (536 - additionalParams['captcha_size'][0])/2
     VirtualKeyBoard.__init__(self, session, title = title, text = text)
     self.captchaPath = additionalParams['captcha_path']
     self['captcha'] = Cover2()
     self.onShown.append(self.loadCaptcha)
     printDBG(">>>>>>>>>>>>>>>>>>> IPTVVirtualKeyBoardWithCaptcha title[%s]" % title)
    def __init__(self,
                 session,
                 imgFilePath,
                 message,
                 title,
                 additionalParams={}):
        printDBG(
            "UnCaptchaReCaptchaWidget.__init__ --------------------------")

        self.params = additionalParams
        self.imgFilePath = imgFilePath
        self.numOfRow = self.params.get('rows', 3)
        self.numOfCol = self.params.get('cols', 3)
        self.markerWidth = self.params.get('marker_width', 100)
        self.markerHeight = self.params.get('marker_height', 100)
        self.offsetCoverX = 100
        self.offsetCoverY = 100

        windowWidth = self.markerWidth * self.numOfCol + self.offsetCoverX * 2
        windowHeight = self.markerWidth * self.numOfRow + self.offsetCoverY + 70

        coversSkin = ''
        self.coversSelection = []
        for x in range(self.numOfCol):
            self.coversSelection.append([])
            for y in range(self.numOfRow):
                coversSkin += """<widget name="cover_%s%s" zPosition="5" position="%d,%d" size="%d,%d" transparent="1" alphatest="blend" />""" % (
                    x,
                    y,
                    (self.offsetCoverX + self.markerWidth * x),  # pos X image
                    (self.offsetCoverY + self.markerHeight * y),  # pos Y image
                    self.markerWidth,
                    self.markerHeight)
                self.coversSelection[x].append(
                    False)  # at start no icon is selected

        self.skin = """
        <screen position="center,center" size="%d,%d" title="%s">
            <widget name="statustext"   position="0,10"  zPosition="2" size="%d,80"  valign="center" halign="center" font="Regular;22" transparent="1" />
            <widget name="puzzle_image" position="%d,%d" size="%d,%d" zPosition="3" transparent="1" alphatest="blend" />
            <widget name="marker"       position="%d,%d" size="%d,%d" zPosition="4" transparent="1" alphatest="blend" />
            <widget name="accept"       position="10,%d"  zPosition="2" size="%d,50"  valign="center" halign="center" font="Regular;22" foregroundColor="#00FFFFFF" backgroundColor="#FFFFFFFF" />
            %s
        </screen>
        """ % (
            windowWidth,
            windowHeight,
            title,
            windowWidth,
            self.offsetCoverX,  # puzzle x
            self.offsetCoverY,  # puzzle y
            self.markerWidth * self.numOfCol,  # puzzle image width
            self.markerHeight * self.numOfRow,  # puzzle image height
            self.offsetCoverX,
            self.offsetCoverY,
            self.markerWidth,
            self.markerHeight,
            self.offsetCoverY + self.markerWidth * self.numOfCol + 10,
            windowWidth - 20,
            coversSkin)

        self.session = session
        Screen.__init__(self, session)

        self["actions"] = ActionMap(
            ["WizardActions", "DirectionActions", "ColorActions"], {
                "left": self.keyLeft,
                "right": self.keyRight,
                "up": self.keyUp,
                "down": self.keyDown,
                "ok": self.keyOK,
                "back": self.keyCancel,
            }, -1)

        self.markerPixmap = LoadPixmap(GetIconDir('markerCaptchaV2.png'))
        self.selectPixmap = LoadPixmap(GetIconDir('selectCaptchaV2.png'))

        self["statustext"] = Label(str(message))
        self["accept"] = Label(self.params.get('accep_label', _("Verify")))

        self['puzzle_image'] = Cover2()
        self["marker"] = Cover3()

        for x in range(self.numOfCol):
            for y in range(self.numOfRow):
                strIndex = "cover_%s%s" % (x, y)
                self[strIndex] = Cover3()

        self.currX = 0
        self.currY = 0
        self.focusOnAcceptButton = False
        self.onLayoutFinish.append(self.onStart)
    def __init__(self, session, params={}):

        # Skin generator
        maxWidth = 0
        pX = 40
        pY = 60
        dY = 10
        skinItems = ''
        self.icons = []
        self.list = params['list']
        self.withAcceptButton = params.get('with_accept_button', False)
        self.statusText = params.get('status_text', '')
        statusTextHight = params.get('status_text_hight', 80)
        # calcl maxWidth size
        for idx in range(len(self.list)):
            item = self.list[idx]
            if item['label_size'][0] > maxWidth:
                maxWidth = item['label_size'][0]
            if item['input_size'][0] > maxWidth:
                maxWidth = item['input_size'][0]
        maxWidth += pX * 2

        if len(self.statusText):
            skinItems = '<widget name="statustext"   position="10,%d"  zPosition="2" size="%d,%d"  valign="center" halign="center" font="Regular;22" transparent="1" />' % (pY + dY, maxWidth - 20, statusTextHight)
            pY += statusTextHight + dY * 2

        for idx in range(len(self.list)):
            item = self.list[idx]
            if 'icon_path' in item:
                self["cover_%d" % idx] = Cover2()
                self.icons.append({'name': "cover_%d" % idx, 'path': item['icon_path']})
            else:
                self["text_%d" % idx] = Label(item.get('title', ''))
            self["input_%d" % idx] = Input(**item['input'])
            self["border_%d" % idx] = Label("")
            if item.get('useable_chars', None) is not None:
                self["input_%d" % idx].setUseableChars(item['useable_chars'])

            if 'icon_path' in item:
                skinItems += '<widget name="cover_%d" position="%d,%d" size="%d,%d" zPosition="8" />' % (idx, (maxWidth - item['label_size'][0]) / 2, pY, item['label_size'][0], item['label_size'][1])
            else:
                skinItems += '<widget name="text_%d" position="%d,%d" size="%d,%d" font="%s" zPosition="2" />' % (idx, 10, pY, item['label_size'][0], item['label_size'][1], item['label_font'])

            pY += dY + item['label_size'][1]
            skinItems += '<widget name="input_%d" position="%d,%d" size="%d,%d" font="%s" zPosition="2" />' % (idx, pX, pY, item['input_size'][0], item['input_size'][1], item['input_font'])
            skinItems += '<widget name="border_%d" position="%d,%d" size="%d,%d" font="%s" zPosition="1" transparent="0" backgroundColor="#331F93B9" />' % (idx, pX - 5, pY - 5, item['input_size'][0] + 10, item['input_size'][1] + 10, item['input_font'])
            if 0 == idx:
                self['marker'] = Cover3()
                skinItems += '<widget name="marker" zPosition="2" position="10,%d" size="16,16" transparent="1" alphatest="blend" />' % (pY + (item['input_size'][1] - 16) / 2)
            skinItems += '<widget name="marker_%d" zPosition="1" position="10,%d" size="16,16" transparent="1" alphatest="blend" />' % (idx, pY + (item['input_size'][1] - 16) / 2)
            self['marker_%d' % idx] = Cover3()
            pY += dY * 2 + item['input_size'][1]

        if self.withAcceptButton:
            skinItems += '<widget name="accept_button"  position="10,%d"  zPosition="2" size="%d,50"  valign="center" halign="center" font="Regular;22" foregroundColor="#00FFFFFF" backgroundColor="#320F0F0F" />' % (pY, maxWidth - 20)
            pY += dY * 2 + 50
        self.skin = """
        <screen name="IPTVMultipleInputBox" position="center,center" size="%d,%d" title="%s">
            <widget name="key_red"   position="10,10" zPosition="2" size="%d,35" valign="center" halign="left"   font="Regular;22" transparent="1" foregroundColor="red" />
            <widget name="key_ok"    position="10,10" zPosition="2" size="%d,35" valign="center" halign="center" font="Regular;22" transparent="1" foregroundColor="white" />
            <widget name="key_green" position="10,10" zPosition="2" size="%d,35" valign="center" halign="right"  font="Regular;22" transparent="1" foregroundColor="green" />
            %s
        </screen>
        """ % (maxWidth, pY, params.get('title', _("Input")), maxWidth - 20, maxWidth - 20, maxWidth - 20, skinItems)

        self["key_green"] = Label(params.get('accep_label', _("Save")))
        self["key_ok"] = Label(_("OK"))
        self["key_red"] = Label(_("Cancel"))
        if len(self.statusText):
            self["statustext"] = Label(str(self.statusText))
        if self.withAcceptButton:
            self["accept_button"] = Label(params.get('accep_label', _("Verify")))

        self.params = params

        Screen.__init__(self, session)
        self.onShown.append(self.onStart)
        self.onClose.append(self.__onClose)

        self["actions"] = NumberActionMap(["ColorActions", "WizardActions", "InputBoxActions", "InputAsciiActions", "KeyboardInputActions"],
        {
            "gotAsciiCode": self.gotAsciiCode,
            "green": self.keySave,
            "ok": self.keyOK,
            "red": self.keyCancel,
            "back": self.keyCancel,
            "left": self.keyLeft,
            "right": self.keyRight,
            "up": self.keyUp,
            "down": self.keyDown,
            "right": self.keyRight,
            "home": self.keyHome,
            "end": self.keyEnd,
            "deleteForward": self.keyDelete,
            "deleteBackward": self.keyBackspace,
            "tab": self.keyTab,
            "toggleOverwrite": self.keyInsert,
            "1": self.keyNumberGlobal,
            "2": self.keyNumberGlobal,
            "3": self.keyNumberGlobal,
            "4": self.keyNumberGlobal,
            "5": self.keyNumberGlobal,
            "6": self.keyNumberGlobal,
            "7": self.keyNumberGlobal,
            "8": self.keyNumberGlobal,
            "9": self.keyNumberGlobal,
            "0": self.keyNumberGlobal
        }, -1)

        self.idx = 0
        self.activeInput = "input_0"
        self.markerPixmap = [LoadPixmap(GetIconDir('radio_button_on.png')), LoadPixmap(GetIconDir('radio_button_off.png'))]

        self.started = False
Example #5
0
    def __init__(self, session, title="", text="", additionalParams={}):
        winWidth = 590
        self.skin = '''<screen position="center,center" size="%d,500" title="" >
                           <widget name="captcha" position="%d,%d" size="%d,%d" zPosition="2" transparent="1" alphatest="on" />
                           
                           <widget name="key_red"   position="10,10" zPosition="2" size="%d,35" valign="center" halign="left"   font="Regular;22" transparent="1" foregroundColor="red" />
                           <widget name="key_ok"    position="10,10" zPosition="2" size="%d,35" valign="center" halign="center" font="Regular;22" transparent="1" foregroundColor="white" />
                           <widget name="key_green" position="10,10" zPosition="2" size="%d,35" valign="center" halign="right"  font="Regular;22" transparent="1" foregroundColor="green" />
                           
                           <ePixmap pixmap="%s"  position="25,195" size="542,80" zPosition="-4" alphatest="on" />
                           <widget name="header" position="25,160" size="500,26" transparent="1" noWrap="1" font="Regular;20" valign="top"/>
                           <widget name="text"   position="25,200" size="536,34" transparent="1" noWrap="1" font="Regular;26" valign="center" halign="right" />
                           <widget name="list"   position="25,250" size="550,225" selectionDisabled="1" transparent="1" />
                       </screen>
                    ''' % ( winWidth, 10, 55, \
                            winWidth - 20, 100, \
                            winWidth-20, \
                            winWidth-20, \
                            winWidth-20, \
                            GetIconDir("vk/vkey_text.png"))

        Screen.__init__(self, session)
        self.keys_list = []
        self.shiftkeys_list = []
        self.shiftMode = additionalParams.get('shift_mode', False)
        self.selectedKey = 0
        self.smsChar = None
        self.sms = NumericalTextInput(self.smsOK)

        self.key_bg = LoadPixmap(GetIconDir("vk/vkey_bg.png"))
        self.key_sel = LoadPixmap(GetIconDir("vk/vkey_sel.png"))
        self.key_backspace = LoadPixmap(GetIconDir("vk/vkey_backspace.png"))
        self.key_all = LoadPixmap(GetIconDir("vk/vkey_all.png"))
        self.key_clr = LoadPixmap(GetIconDir("vk/vkey_clr.png"))
        self.key_esc = LoadPixmap(GetIconDir("vk/vkey_esc.png"))
        self.key_ok = LoadPixmap(GetIconDir("vk/vkey_ok.png"))
        self.key_shift = LoadPixmap(GetIconDir("vk/vkey_shift.png"))
        self.key_shift_sel = LoadPixmap(GetIconDir("vk/vkey_shift_sel.png"))
        self.key_space = LoadPixmap(GetIconDir("vk/vkey_space.png"))
        self.key_left = LoadPixmap(GetIconDir("vk/vkey_left.png"))
        self.key_right = LoadPixmap(GetIconDir("vk/vkey_right.png"))

        self.keyImages = {
            "BACKSPACE": self.key_backspace,
            "CLEAR": self.key_clr,
            "ALL": self.key_all,
            "EXIT": self.key_esc,
            "OK": self.key_ok,
            "SHIFT": self.key_shift,
            "SPACE": self.key_space,
            "LEFT": self.key_left,
            "RIGHT": self.key_right
        }
        self.keyImagesShift = {
            "BACKSPACE": self.key_backspace,
            "CLEAR": self.key_clr,
            "ALL": self.key_all,
            "EXIT": self.key_esc,
            "OK": self.key_ok,
            "SHIFT": self.key_shift_sel,
            "SPACE": self.key_space,
            "LEFT": self.key_left,
            "RIGHT": self.key_right
        }

        self["key_green"] = Label(_("Accept"))
        self["key_ok"] = Label(_("OK"))
        self["key_red"] = Label(_("Cancel"))

        self["header"] = Label(title)
        self["text"] = Input(text=text.decode("utf-8", 'ignore'))
        self["list"] = VirtualKeyBoardList([])

        self["actions"] = NumberActionMap(
            [
                "OkCancelActions", "WizardActions", "ColorActions",
                "KeyboardInputActions", "InputBoxActions", "InputAsciiActions"
            ], {
                "gotAsciiCode": self.keyGotAscii,
                "ok": self.okClicked,
                "cancel": self.exit,
                "left": self.left,
                "right": self.right,
                "up": self.up,
                "down": self.down,
                "red": self.exit,
                "green": self.ok,
                "yellow": self.switchLang,
                "blue": self.shiftClicked,
                "deleteBackward": self.backClicked,
                "deleteForward": self.forwardClicked,
                "back": self.exit,
                "pageUp": self.cursorRight,
                "pageDown": self.cursorLeft,
                "1": self.keyNumberGlobal,
                "2": self.keyNumberGlobal,
                "3": self.keyNumberGlobal,
                "4": self.keyNumberGlobal,
                "5": self.keyNumberGlobal,
                "6": self.keyNumberGlobal,
                "7": self.keyNumberGlobal,
                "8": self.keyNumberGlobal,
                "9": self.keyNumberGlobal,
                "0": self.keyNumberGlobal,
            }, -2)
        self.startText = text
        self.setLang(additionalParams)
        self.onExecBegin.append(self.setKeyboardModeAscii)
        self.onLayoutFinish.append(self.buildVirtualKeyBoard)

        self.captchaPath = additionalParams['captcha_path']
        self['captcha'] = Cover2()
        self.onShown.append(self.loadCaptcha)
Example #6
0
    def __init__(self, session, hCaptcha, additionalParams={}):
        printDBG("UnCaptchahCaptchaWidget.__init__ --------------------------")

        self.params = additionalParams
        self.imgFilePath = GetTmpDir('.iptvplayer_hcaptcha_0.jpg')
        self.numOfImg = hCaptcha['imgNumber']

        self.numOfCol = self.numOfImg / 3
        self.numOfRow = 3

        self.markerWidth = self.params.get('marker_width', 100)
        self.markerHeight = self.params.get('marker_height', 100)
        self.offsetCoverX = 100
        self.offsetCoverY = 100

        windowWidth = self.markerWidth * self.numOfCol + self.offsetCoverX * 2
        windowHeight = self.markerWidth * self.numOfRow + self.offsetCoverY + 70

        coversSkin = ''
        self.coversSelection = []
        for x in range(self.numOfCol):
            self.coversSelection.append([])
            for y in range(self.numOfRow):
                coversSkin += """<widget name="cover_%s%s" zPosition="5" position="%d,%d" size="%d,%d" transparent="1" alphatest="blend" />""" % (
                    x,
                    y,
                    (self.offsetCoverX + self.markerWidth * x),  # pos X image
                    (self.offsetCoverY + self.markerHeight * y),  # pos Y image
                    self.markerWidth,
                    self.markerHeight)
                self.coversSelection[x].append(
                    False)  # at start no icon is selected

        skin_puzzle_part = ""
        for n_img in range(self.numOfImg):
            r = n_img / self.numOfCol
            c = n_img % self.numOfCol
            skin_puzzle_part += "            <widget name=\"puzzle_image_%d\" position=\"%d,%d\" size=\"%d,%d\" zPosition=\"3\" transparent=\"1\" alphatest=\"blend\" />\n" % (
                n_img, self.offsetCoverX + c * self.markerWidth,
                self.offsetCoverY + r * self.markerHeight, self.markerWidth,
                self.markerHeight)

        self.skin = """
        <screen position="center,center" size="%d,%d" title="%s">
            <widget name="statustext"   position="0,10"  zPosition="2" size="%d,80"  valign="center" halign="center" font="Regular;22" transparent="1" />
#puzzle_part#
            <widget name="marker"       position="%d,%d" size="%d,%d" zPosition="4" transparent="1" alphatest="blend" />
            <widget name="accept"       position="10,%d"  zPosition="2" size="%d,50"  valign="center" halign="center" font="Regular;22" foregroundColor="#00FFFFFF" backgroundColor="#FFFFFFFF" />
            %s
        </screen>
        """ % (windowWidth, windowHeight, "hCaptcha", windowWidth,
               self.offsetCoverX, self.offsetCoverY, self.markerWidth,
               self.markerHeight, self.offsetCoverY + self.markerHeight *
               self.numOfRow + 10, windowWidth - 20, coversSkin)

        self.skin = self.skin.replace("#puzzle_part#", skin_puzzle_part)
        self.session = session
        Screen.__init__(self, session)

        self["actions"] = ActionMap(
            ["WizardActions", "DirectionActions", "ColorActions"], {
                "left": self.keyLeft,
                "right": self.keyRight,
                "up": self.keyUp,
                "down": self.keyDown,
                "ok": self.keyOK,
                "back": self.keyCancel,
            }, -1)

        self.markerPixmap = LoadPixmap(GetIconDir('markerCaptchaV2.png'))
        self.selectPixmap = LoadPixmap(GetIconDir('selectCaptchaV2.png'))

        self["statustext"] = Label(str(hCaptcha['question']))
        self["accept"] = Label(self.params.get('accep_label', _("Verify")))

        for n_img in range(self.numOfImg):
            self['puzzle_image_%d' % n_img] = Cover2()

        self["marker"] = Cover3()

        for x in range(self.numOfCol):
            for y in range(self.numOfRow):
                strIndex = "cover_%s%s" % (x, y)
                self[strIndex] = Cover3()

        self.currX = 0
        self.currY = 0
        self.focusOnAcceptButton = False
        self.onLayoutFinish.append(self.onStart)