def __init__(self, enableWrapAround = False):
         MenuList.__init__(self, playlist, enableWrapAround, eListboxPythonMultiContent)
         self.l.setFont(0, gFont("Regular", 18))
         self.l.setItemHeight(23)
         MC_AudioPlayer.currPlaying = -1
         self.oldCurrPlaying = -1
         self.serviceHandler = eServiceCenter.getInstance()
	def __init__(self, directory, showDirectories = True, showFiles = True, showMountpoints = True, matchingPattern = None, useServiceRef = False, inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = False, additionalExtensions = None, sort = "default"):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		self.additional_extensions = additionalExtensions
		self.mountpoints = []
		self.current_directory = None
		self.current_mountpoint = None
		self.useServiceRef = useServiceRef
		self.showDirectories = showDirectories
		self.showMountpoints = showMountpoints
		self.showFiles = showFiles
		self.isTop = isTop
		# example: matching .nfi and .ts files: "^.*\.(nfi|ts)"
		self.matchingPattern = matchingPattern
		self.sort = sort
		self.inhibitDirs = inhibitDirs or []
		self.inhibitMounts = inhibitMounts or []
		self.refreshMountpoints()
		self.changeDir(directory, sort = sort)
		if getDesktop(0).size().width() == 1920:
			self.l.setFont(0, gFont("Regular", 26))
			self.l.setItemHeight(36)
		else:
			self.l.setFont(0, gFont("Regular", 18))
			self.l.setItemHeight(21)
		self.serviceHandler = eServiceCenter.getInstance()
	def __init__(self, getPlaylistEntriesCB):
		MenuList.__init__(self, list, False, eListboxPythonMultiContent)
		tlf = TemplatedListFonts()
		self.l.setFont(0, gFont(tlf.face(tlf.MEDIUM), tlf.size(tlf.MEDIUM)))
		self.l.setItemHeight(25)
		self.l.setBuildFunc(self.buildListboxEntry)
		self.getPlaylistEntriesCB = getPlaylistEntriesCB
Beispiel #4
0
 def __init__(self, list):
     MenuList.__init__(self, list, False, eListboxPythonMultiContent)
     self.l.setItemHeight(45)
     self.l.setFont(0, gFont('SetrixHD', 24))
     self.l.setFont(1, gFont('Regular', 22))
     if 1 == 2:
         cat = _('Education')
         cat = _('Movie & Media')
         cat = _('Network & Streaming')
         cat = _('News')
         cat = _('Program Guide')
         cat = _('Social')
         cat = _('Spinners')
         cat = _('Sports')
         cat = _('Radio')
         cat = _('Tweaks')
         cat = _('Recordings')
         cat = _('Communication')
         cat = _('System Extensions')
         cat = _('Utilities')
         cat = _('Development')
         cat = _('Picons')
         cat = _('Skin Extensions')
         cat = _('SkinParts Collections')
         cat = _('Drivers')
         cat = _('Channellists')
         cat = _('Kernel Modules')
         cat = _('Language Packs')
         cat = _('Weather')
         cat = _('Various')
         cat = _('My SkinParts')
         cat = _('Default Bugfixes')
         cat = _('VTI Specific')
         cat = _('OpenPLi Specific')
         cat = _('MetrixHD Default')
	def __init__(self, session):
		self.session = session
		path = "%s/skins/%s/screen_archiv.xml" % (getPluginPath(), config.plugins.skyrecorder.anytime_skin.value)
		with open(path, "r") as f:
			self.skin = f.read()
			f.close()
		
		Screen.__init__(self, session)
		
		pluginName = config.plugins.skyrecorder.pluginname.value
		contentSize = config.plugins.skyrecorder.contentsize.value
		
		# try to get the ayntimefolder
		try:
			anytimefolder = config.plugins.skyrecorder.anytimefolder.value
		except Exception:
			sys.exc_clear()
			anytimefolder = resolveFilename(SCOPE_HDD)
		
		self.anytimefolder = anytimefolder
		
		self.serviceHandler = eServiceCenter.getInstance()
		
		self["actions"]  = ActionMap(["OkCancelActions", "ShortcutActions", "EPGSelectActions", "WizardActions", "ColorActions", "NumberActions", "MenuActions", "MoviePlayerActions"], {
			"ok" : self.keyOK,
			"cancel" : self.keyCancel,
			"up" : self.keyUp,
			"down" : self.keyDown,
			"right" : self.keySwitchList,
			"left" : self.keySwitchList,
			"red": self.keyRed,
			"green": self.keyGreen,
			"prevBouquet" : self.keyPageDown,
			"nextBouquet" : self.keyPageUp
		}, -1)
		
		# Genrelist
		self.showGenreList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
		self.showGenreList.l.setFont(0, gFont('Regular', contentSize))
		self.showGenreList.l.setItemHeight(25)
		self['genreselect'] = self.showGenreList
		self['genreselect'].setList([])
		
		#Movielist
		self.showMovieList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
		self.showMovieList.l.setFont(0, gFont('Regular', contentSize))
		self.showMovieList.l.setItemHeight(25)
		self['movieselect'] = self.showMovieList
		self['movieselect'].setList([])
		
		# Auswahl der liste welche als erstes angezeigt werden soll
		self["genreselect"].selectionEnabled(0)
		self["movieselect"].selectionEnabled(1)
		self.currentList = "movieselect"
		
		self['mainselect'] = Label("SkyRecorder Archiv")
		self['handlung'] = Label("")
		
		self.onLayoutFinish.append(self.getGenreList)
		self['movieselect'].onSelectionChanged.append(self.showDetails)
	def __init__(self, entries):
		MenuList.__init__(self, entries, False, content = eListboxPythonMultiContent)

		self.l.setFont(0, gFont("Regular", 22))
		self.l.setBuildFunc(self.buildListboxEntry)
		self.l.setItemHeight(25)
		self.colorDisabled = 12368828
 def build(self):
    
   self["myMenu"] = MenuList(self.buildlist(), False, eListboxPythonMultiContent)
   self["myMenu"].onSelectionChanged = [self.Changed]
   
   self["myMenu"].l.setFont(0, gFont("Regular", 20))
   self["myMenu"].l.setFont(1, gFont("Regular", 14))
   self["myMenu"].l.setItemHeight(40)
   
   
   self["Description"] = Label("/var")
   
   self["red"] = Label("")
   self["green"] = Label("")
   self["yellow"] = Label("")
   self["blue"] = Label("Delete")    
   
   self.actions['red'] = lambda: self.action('create')
   self.actions['green'] = lambda: self.action('upload')
   self.actions['yellow'] = lambda: self.action()
   self.actions['blue'] = lambda: self.action('delete')
   self.actions['ok'] = lambda: self.action('ok')
   #self.actions["up"] = lambda: self.Changed('up')
   #self.actions["down"] = self.Changed('down')
   
   self.context = ["ChannelSelectBaseActions","WizardActions", "DirectionActions","MenuActions","NumberActions","ColorActions"]
 def __init__(
     self,
     directory,
     showDirectories=True,
     showFiles=True,
     showMountpoints=True,
     matchingPattern=None,
     useServiceRef=False,
     inhibitDirs=False,
     inhibitMounts=False,
     isTop=False,
     enableWrapAround=True,
     additionalExtensions=None,
 ):
     MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
     self.additional_extensions = additionalExtensions
     self.mountpoints = []
     self.current_directory = None
     self.current_mountpoint = None
     self.useServiceRef = useServiceRef
     self.showDirectories = showDirectories
     self.showMountpoints = showMountpoints
     self.showFiles = showFiles
     self.isTop = isTop
     self.matchingPattern = matchingPattern
     self.inhibitDirs = inhibitDirs or []
     self.inhibitMounts = inhibitMounts or []
     self.refreshMountpoints()
     self.changeDir(directory)
     font = skin.fonts.get("Dreamexplorer", ("Regular", 18, 26))
     self.l.setFont(0, gFont(font[0], font[1]))
     self.l.setItemHeight(font[2])
     self.serviceHandler = eServiceCenter.getInstance()
	def __init__(self, directory, showDirectories = True, showFiles = True, showMountpoints = True, matchingPattern = None, useServiceRef = False, inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = True, additionalExtensions = None):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		self.additional_extensions = additionalExtensions
		self.mountpoints = []
		self.current_directory = None
		self.current_mountpoint = None
		self.useServiceRef = useServiceRef
		self.showDirectories = showDirectories
		self.showMountpoints = showMountpoints
		self.showFiles = showFiles
		self.isTop = isTop
		self.matchingPattern = matchingPattern
		self.inhibitDirs = inhibitDirs or []
		self.inhibitMounts = inhibitMounts or []
		self.refreshMountpoints()
		direct = directory
		if directory.endswith("/"):
			se = directory
		else:
			se = os_path.basename(directory)
			direct = directory+"/"
#		print "direct,se",direct,se
		self.changeDir(direct,se)
		self.l.setFont(0, gFont("Regular", 18))
		self.l.setItemHeight(26)
		self.serviceHandler = eServiceCenter.getInstance()
Beispiel #10
0
 def __init__(self, list, itemHeight=29):
     MenuList.__init__(self, list, False, eListboxPythonMultiContent)
     self.l.setItemHeight(itemHeight)
     self.l.setFont(0, gFont("Regular", 21))
     self.l.setFont(1, gFont("Regular", 23))
     self.l.setFont(2, gFont("Regular", 18))
     self.l.setFont(3, gFont("Regular", 19))
Beispiel #11
0
    def __init__(self, directory, showDirectories = True, showFiles = True, showMountpoints = True, matchingPattern = None, useServiceRef = False, inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = False, additionalExtensions = None, sortDate=False):
        MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
        GUIComponent.__init__(self)

        self.additional_extensions = additionalExtensions
        self.mountpoints = []
        self.current_directory = None
        self.current_mountpoint = None
        self.useServiceRef = useServiceRef
        self.showDirectories = showDirectories
        self.showMountpoints = showMountpoints
        self.showFiles = showFiles
        self.isTop = isTop
        # example: matching .nfi and .ts files: "^.*\.(nfi|ts)"
        self.matchingPattern = matchingPattern
        self.inhibitDirs = inhibitDirs or []
        self.inhibitMounts = inhibitMounts or []
        self.sortDate = sortDate

        self.refreshMountpoints()
        #self.changeDir(directory)
        #self.l.setFont(0, gFont("Regular", int(config.plugins.AdvancedFreePlayer.FileListFontSize.value)))
        #self.l.setItemHeight(35)
        self.serviceHandler = eServiceCenter.getInstance()

        #default values:
        self.font0 = gFont("Regular",22)
        self.font1 = gFont("Regular",16)
        self.itemHeight = 35
        self.DimText0 = (45, 1, 1020, 35, 0)
        self.DimText1 = (0, 0, 0, 0) # not used here
        self.DimPIC = (5, 4, 25, 25)
	def __init__(self, getPlaylistEntriesCB):
		MenuList.__init__(self, list, False, eListboxPythonMultiContent)
		self.font = gFont("Regular", 18)
		self.l.setFont(0, self.font)
		self.l.setItemHeight(23)
		self.l.setBuildFunc(self.buildListboxEntry)
		self.getPlaylistEntriesCB = getPlaylistEntriesCB
Beispiel #13
0
	def postWidgetCreate(self, instance):
		printl("", self, "S")
		
		MenuList.postWidgetCreate(self, instance)
		instance.setItemHeight(20)

		printl("", self, "C")
Beispiel #14
0
	def __init__(self):
		MenuList.__init__(self, [], False, eListboxPythonMultiContent)
		self.l.setItemHeight(20)
		self.l.setFont(0, gFont("Regular", 18))
		self.menu = []
		self.active = True
		self.current = 0
Beispiel #15
0
    def __init__(self, directory, showDirectories=True, showFiles=True, showMountpoints=True, matchingPattern=None, useServiceRef=False, inhibitDirs=False, inhibitMounts=False, isTop=False, enableWrapAround=False, additionalExtensions=None):
        MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
        self.additional_extensions = additionalExtensions
        self.mountpoints = []
        self.current_directory = None
        self.current_mountpoint = None
        self.useServiceRef = useServiceRef
        self.showDirectories = showDirectories
        self.showMountpoints = showMountpoints
        self.showFiles = showFiles
        if isTop:
            self.topDirectory = directory
        else:
            self.topDirectory = "/"
        # example: matching .nfi and .ts files: "^.*\.(nfi|ts)"
        if matchingPattern:
            self.matchingPattern = re.compile(matchingPattern)
        else:
            self.matchingPattern = None
        self.inhibitDirs = inhibitDirs or []
        self.inhibitMounts = inhibitMounts or []

        self.refreshMountpoints()
        self.changeDir(directory)
        self.l.setFont(0, gFont("Regular", 18))
        self.l.setItemHeight(23)
        self.serviceHandler = eServiceCenter.getInstance()
	def __init__(self, list, enableWrapAround = True):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		font = skin.fonts.get("PartnerBoxEntryList0", ("Regular", 20, 20))
		self.l.setFont(0, gFont(font[0], font[1]))
		self.ItemHeight = int(font[2])
		font = skin.fonts.get("PartnerBoxEntryList1", ("Regular", 18))
		self.l.setFont(1, gFont(font[0], font[1]))
Beispiel #17
0
	def __init__(self, list, itemH = 30):
		MenuList.__init__(self, list, False, eListboxPythonMultiContent)
		self.l.setItemHeight(int(itemH*f))
		self.l.setFont(0, gFont("Regular", int(20*f)))
		self.l.setFont(1, gFont("Regular", int(18*f)))
		self.clientFont = gFont("Regular", int(16*f))
		self.l.setFont(2, self.clientFont)
		self.l.setFont(3, gFont("Regular", int(12*f)))
Beispiel #18
0
	def __init__(self, list, itemH = 25):
		MenuList.__init__(self, list, False, eListboxPythonMultiContent)
		self.l.setItemHeight(itemH)
		self.l.setFont(0, gFont("Regular", 18))
		self.l.setFont(1, gFont("Regular", 16))
		self.clientFont = gFont("Regular", 14)
		self.l.setFont(2, self.clientFont)
		self.l.setFont(3, gFont("Regular", 12))
Beispiel #19
0
	def __init__(self):
		MenuList.__init__(self, [], False, eListboxPythonMultiContent)
		self.l.setFont(0, gFont("Regular", 18))
		self.l.setFont(1, gFont("Regular", 16))
		self.listCompleted = []
		self.callback = None
		self.idx = 0
		self.thumb = ""
Beispiel #20
0
	def __init__(self, menuList, enableWrapAround = True):
		printl("", self, "S")
		
		MenuList.__init__(self, menuList, enableWrapAround, eListboxPythonMultiContent)
		self.l.setFont(0, gFont("Regular", 20))
		self.l.setFont(1, gFont("Regular", 18))
		
		printl("", self, "C")
	def __init__(self, tree = None, enableWrapAround = False):
		'tree is expected to be a list of categories'
		MenuList.__init__(self, [], enableWrapAround, content = eListboxPythonMultiContent)
		font = skin.fonts.get("SelectionList", ("Regular", 20, 30))
		self.l.setFont(0, gFont(font[0], font[1]))
		self.l.setItemHeight(font[2])
		self.tree = tree or []
		self.updateFlatList()
	def __init__(self, list):
		MenuList.__init__(self, list, False, eListboxPythonMultiContent)
		self.l.setFont(0, gFont("Regular", 14))
		self.l.setFont(1, gFont("Regular", 16))
		self.l.setFont(2, gFont("Regular", 18))
		self.l.setFont(3, gFont("Regular", 20))
		self.l.setFont(4, gFont("Regular", 22))
		self.l.setFont(5, gFont("Regular", 24))
Beispiel #23
0
	def __init__(self, list):
		MenuList.__init__(self, list, False, content=eListboxPythonMultiContent)

		l = self.l
		l.setFont(0, gFont("Regular", 22))
		l.setBuildFunc(self.buildListboxEntry)
		self.selected = None
		self.selectedColor = 8388608
	def __init__(self, list, enableWrapAround = True):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		if getDesktop(0).size().width() == 1920:
			self.l.setFont(0, gFont("Regular", 28))
			self.l.setFont(1, gFont("Regular", 26))
		else:
			self.l.setFont(0, gFont("Regular", 20))
			self.l.setFont(1, gFont("Regular", 18))
Beispiel #25
0
	def __init__(self, entries):
		MenuList.__init__(self, entries, False, content = eListboxPythonMultiContent)

		l = self.l
		l.setFont(0, gFont("Regular", 22))
		self.descriptionFont = gFont("Regular", 18)
		l.setFont(1, self.descriptionFont)
		l.setItemHeight(100)
		l.setBuildFunc(self.buildListboxEntry)
Beispiel #26
0
	def __init__(self, directory, matchingPattern = None, enableWrapAround = False):
		MenuList.__init__(self, None, enableWrapAround, eListboxPythonMultiContent)
		self.showDirectories = True
		self.showFiles = True
		self.isTop = False
		self.matchingPattern = matchingPattern
		self.changeDir(directory)
		self.l.setFont(0, gFont("Regular", 18))
		self.currentDir = directory
Beispiel #27
0
 def __init__(self, list):
     MenuList.__init__(self, list, True, eListboxPythonMultiContent)
     try:
         font = skin.fonts.get('fstabMenuList', ('Regular', 20, 220))
         self.l.setFont(0, gFont(font[0], font[1]))
         self.l.setItemHeight(font[2])
     except:
         self.l.setFont(0, gFont('Regular', 20))
         self.l.setItemHeight(220)
Beispiel #28
0
	def __init__(self, getFilesAndDirsCB, baseDir, matchingPattern):
		MenuList.__init__(self, list, False, eListboxPythonMultiContent)
		tlf = TemplatedListFonts()
		self.l.setFont(0, gFont(tlf.face(tlf.MEDIUM), tlf.size(tlf.MEDIUM)))
		self.l.setItemHeight(25)
		self.l.setBuildFunc(self.buildListboxEntry)
		self.currentDirectory = baseDir
		self.getFilesAndDirsCB = getFilesAndDirsCB
		self.changeRegex(matchingPattern)
	def __init__(self, entries):
		MenuList.__init__(self, entries, False, content = eListboxPythonMultiContent)

		self.l.setFont(0, gFont("Regular", 22))
		self.l.setBuildFunc(self.buildListboxEntry)
		self.l.setItemHeight(25)
		self.colorDisabled = 12368828
		tlf = TemplatedListFonts()
		self.l.setFont(0, gFont(tlf.face(tlf.BIG), tlf.size(tlf.BIG)))
Beispiel #30
0
	def __init__(self):
		MenuList.__init__(self, [], False, eListboxPythonMultiContent)
		self.l.setItemHeight(75)
		if WIDTH == 720:
			self.l.setFont(0, gFont("Regular", 30))
			self.center_up = 22
		else:
			self.l.setFont(0, gFont("Regular", 40))
			self.center_up = 15
Beispiel #31
0
                def __init__(self, list, font0 = 24, font1 = 16, itemHeight = 50, enableWrapAround = True):	        
		        MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
                        self.l.setFont(0, gFont("Regular", font0))
		        self.l.setFont(1, gFont("Regular", font1))
		        self.l.setItemHeight(itemHeight)
 def __init__(self, list, enableWrapAround=False):
     MenuList.__init__(self, list, enableWrapAround,
                       eListboxPythonMultiContent)
     font = skin.fonts.get("VirtualKeyboard", ("Regular", 28, 45))
     self.l.setFont(0, gFont(font[0], font[1]))
     self.l.setItemHeight(font[2])
    def __init__(self,
                 session,
                 text='',
                 filename='',
                 currDir=None,
                 location=None,
                 userMode=False,
                 windowTitle=_('Choose Download location'),
                 minFree=None,
                 autoAdd=False,
                 editDir=False,
                 inhibitDirs=[],
                 inhibitMounts=[]):
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)
        self['text'] = StaticText(_('Selected memory place:'))
        self['oktext'] = StaticText(_('for select sublist!'))
        self.text = text
        self.filename = filename
        self.minFree = minFree
        self.reallocation = location
        self.location = location and location.value[:] or []
        self.userMode = userMode
        self.autoAdd = autoAdd
        self.editDir = editDir
        self.inhibitDirs = inhibitDirs
        self.inhibitMounts = inhibitMounts
        inhibitDirs = [
            '/bin', '/boot', '/dev', '/lib', '/proc', '/sbin', '/sys', '/mnt',
            '/var', '/home', '/tmp', '/srv', '/etc', '/share', '/usr', '/ba',
            '/MB_Images'
        ]
        inhibitMounts = ['/mnt', '/ba', '/MB_Images']
        self['filelist'] = FileList(currDir,
                                    showDirectories=True,
                                    showFiles=False,
                                    inhibitMounts=inhibitMounts,
                                    inhibitDirs=inhibitDirs)
        self['mountlist'] = MenuList(mountedDevs)
        self['key_green'] = Button(_('Save'))
        self['key_red'] = Button(_('Close'))
        self['green'] = Pixmap()
        self['red'] = Pixmap()
        self['target'] = Label()
        if self.userMode:
            self.usermodeOn()

        class DownloadLocationActionMap(HelpableActionMap):
            def __init__(self, parent, context, actions={}, prio=0):
                HelpableActionMap.__init__(self, parent, context, actions,
                                           prio)

        self['WizardActions'] = DownloadLocationActionMap(
            self, 'WizardActions', {
                'left': self.left,
                'right': self.right,
                'up': self.up,
                'down': self.down,
                'ok': (self.ok, _('Select')),
                'back': (self.cancel, _('Cancel'))
            }, -2)
        self['ColorActions'] = DownloadLocationActionMap(
            self, 'ColorActions', {
                'red': self.cancel,
                'green': self.select
            }, -2)
        self.setWindowTitle()
        self.onLayoutFinish.append(self.switchToFileListOnStart)
Beispiel #34
0
	def postWidgetCreate(self, instance):
		MenuList.postWidgetCreate(self, instance)
		self.moveToIndex(self.selection)
Beispiel #35
0
class LastFMScreenMain(Screen, HelpableScreen, LastFM):
    skin = """
        <screen name="LastFM" position="center,center" size="600,440" title="%s" >
            
            <widget name="artist" position="0,5" size="100,30" valign=\"center\" halign=\"left\" zPosition=\"2\"  foregroundColor=\"white\" font=\"Regular;18\" />          
            <widget name="album" position="0,45" size="100,30" valign=\"center\" halign=\"left\" zPosition=\"2\"  foregroundColor=\"white\" font=\"Regular;18\" />          
            <widget name="track" position="0,85" size="100,30" valign=\"center\" halign=\"left\" zPosition=\"2\"  foregroundColor=\"white\" font=\"Regular;18\" />          
            
            <widget name="info_artist" position="105,5" size="300,30" valign=\"center\" halign=\"left\" zPosition=\"2\"  foregroundColor=\"white\" font=\"Regular;18\" />          
            <widget name="duration" position="420,5" size="60,30" valign=\"center\" halign=\"right\" zPosition=\"2\"  foregroundColor=\"white\" font=\"Regular;18\" />          
            <widget name="info_album" position="105,45" size="370,30" valign=\"center\" halign=\"left\" zPosition=\"2\"  foregroundColor=\"white\" font=\"Regular;18\" />          
            <widget name="info_track" position="105,85" size="370,30" valign=\"center\" halign=\"left\" zPosition=\"2\"  foregroundColor=\"white\" font=\"Regular;18\" />          
            <widget name="info_cover" position="484,5" size="116,116" />          
            
            <widget name="tablist" position="0,140" size="210,205" scrollbarMode="showOnDemand" />            
            <widget name="streamlist" position="220,140" size="380,205" scrollbarMode="showOnDemand" />            
            
            <widget name="button_red" position="0,360" size="140,40" valign=\"center\" halign=\"center\" zPosition=\"3\" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" font=\"Regular;18\" />          
            <widget name="button_green" position="140,360" size="140,40" valign=\"center\" halign=\"center\" zPosition=\"3\" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" font=\"Regular;18\"/>            
            <widget name="button_yellow" position="280,360" size="140,40" valign=\"center\" halign=\"center\" zPosition=\"3\" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" font=\"Regular;18\" />            
            <widget name="button_blue" position="420,360" size="140,40" valign=\"center\" halign=\"center\" zPosition=\"3\" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" font=\"Regular;18\" />             
            <ePixmap pixmap="skin_default/buttons/red.png" position="0,360" zPosition="2" size="140,40" transparent="1" alphatest="on" />
            <ePixmap pixmap="skin_default/buttons/green.png" position="140,360" zPosition="2" size="140,40" transparent="1" alphatest="on" />
            <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,360" zPosition="2" size="140,40" transparent="1" alphatest="on" />
            <ePixmap pixmap="skin_default/buttons/blue.png" position="420,360" zPosition="2" size="140,40" transparent="1" alphatest="on" />
            <ePixmap position="570,370" size="35,25" pixmap="skin_default/buttons/key_menu.png" alphatest="on" />
            <widget name="infolabel" position="10,410" size="500,20" valign=\"center\" halign=\"left\" zPosition=\"2\"  foregroundColor=\"white\" font=\"Regular;16\" />           
        </screen>""" % (config.plugins.LastFM.name.value + " " + _("Ver.") +
                        " " + lastfm_pluginversion)  # title

    noCoverArtPNG = "/usr/share/enigma2/skin_default/no_coverArt.png"

    def __init__(self, session, streamplayer, args=0):
        self.skin = LastFMScreenMain.skin
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)
        LastFM.__init__(self)
        self.session = session
        self.streamplayer = streamplayer  #StreamPlayer(session)
        self.streamplayer.onStateChanged.append(
            self.onStreamplayerStateChanged)
        self.imageconverter = ImageConverter(116, 116, self.setCoverArt)
        Screen.__init__(self, session)

        self.tabs = [(_("Personal Stations"), self.loadPersonalStations),
                     (_("Global Tags"), self.loadGlobalTags),
                     (_("Top Tracks"), self.loadTopTracks),
                     (_("Recent Tracks"), self.loadRecentTracks),
                     (_("Loved Tracks"), self.loadLovedTracks),
                     (_("Banned Tracks"), self.loadBannedTracks),
                     (_("Friends"), self.loadFriends),
                     (_("Neighbours"), self.loadNeighbours)]
        tablist = []
        for tab in self.tabs:
            tablist.append((tab[0], tab))
        self.tablist = MenuList(tablist)
        self.tablist.onSelectionChanged.append(self.action_TabChanged)

        self["artist"] = Label(_("Artist") + ":")
        self["duration"] = Label("-00:00")
        self["album"] = Label(_("Album") + ":")
        self["track"] = Label(_("Track") + ":")

        self["info_artist"] = Label("N/A")
        self["info_album"] = Label("N/A")
        self["info_track"] = Label("N/A")
        self["info_cover"] = Pixmap()

        self["tablist"] = self.tablist
        self["streamlist"] = MenuList([])

        self["button_red"] = Label(_("Play"))
        self["button_green"] = Label(_("Skip"))
        self["button_yellow"] = Label(_("Love"))
        self["button_blue"] = Label(_("Ban"))
        self["infolabel"] = Label("")

        self["actions"] = ActionMap(
            [
                "InfobarChannelSelection", "WizardActions", "DirectionActions",
                "MenuActions", "ShortcutActions", "GlobalActions",
                "HelpActions", "NumberActions"
            ], {
                "ok": self.action_ok,
                "back": self.action_exit,
                "red": self.action_startstop,
                "green": self.skipTrack,
                "yellow": self.love,
                "blue": self.banTrack,
                "historyNext": self.action_nextTab,
                "historyBack": self.action_prevTab,
                "menu": self.action_menu,
            }, -1)

        self.helpList.append((self["actions"], "WizardActions",
                              [("ok", _("Switch to selected Station"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("historyNext", _("Select next Tab"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("historyBack", _("Select prev Tab"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("switchChannelDown", _("Next Selection"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("switchChannelUp", _("Previous Selection"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("zapDown", _("Page forward Selections"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("zapUp", _("Page backward Selections"))]))
        self.helpList.append((self["actions"], "ShortcutActions",
                              [("red", _("Start/stop streaming"))]))
        self.helpList.append(
            (self["actions"], "ShortcutActions", [("green",
                                                   _("Skip current Track"))]))
        self.helpList.append(
            (self["actions"], "ShortcutActions", [("yellow",
                                                   _("Mark Track as loved"))]))
        self.helpList.append((self["actions"], "ShortcutActions",
                              [("blue", _("Ban Track, never play"))]))
        self.helpList.append((self["actions"], "MenuActions",
                              [("menu", _("Open") + " " + _("Setup"))]))
        self.helpList.append((self["actions"], "WizardActions", [
            ("back", _("Quit") + " " + config.plugins.LastFM.name.value)
        ]))

        self.onLayoutFinish.append(self.initLastFM)
        self.onLayoutFinish.append(self.tabchangedtimerFired)
        self.onLayoutFinish.append(self.setCoverArt)

        self.guiupdatetimer = eTimer()
        self.guiupdatetimer_conn = self.guiupdatetimer.timeout.connect(
            self.guiupdatetimerFired)
        self.guiupdatetimer.start(
            config.plugins.LastFM.metadatarefreshinterval.value * 1000)

        self.tabchangetimer = eTimer()
        self.tabchangetimer_conn = self.tabchangetimer.timeout.connect(
            self.tabchangedtimerFired)

        self.infolabelcleartimer = eTimer()
        self.infolabelcleartimer_conn = self.infolabelcleartimer.timeout.connect(
            self.clearInfoLabel)

        self.screensavertimer = eTimer()
        self.screensavertimer_conn = self.screensavertimer.timeout.connect(
            self.startScreensaver)
        self.onShown.append(self.startScreensaverTimer)

    def initLastFM(self):
        self.setInfoLabel(_("logging into last.FM"))
        self.connect(config.plugins.LastFM.username.value,
                     config.plugins.LastFM.password.value)

    def onStreamplayerStateChanged(self, reason):
        if reason is self.streamplayer.STATE_PLAYLISTENDS:
            self.loadPlaylist()
        else:
            pass

    def onConnectSuccessful(self, text):
        self.setInfoLabel(_("login successful"))

    def onConnectFailed(self, text):
        self.setInfoLabel(_("login failed! ") + text, timeout=False)

    def onTrackSkiped(self, reason):
        self.setInfoLabel(_("Track skipped"))

    def onTrackLoved(self, reason):
        self.setInfoLabel(_("Track loved"))

    def onTrackBanned(self, reason):
        self.setInfoLabel(_("Track banned"))

    def onCommandFailed(self, reason):
        self.setInfoLabel(reason)

    def onGlobalTagsLoaded(self, tags):
        self.setInfoLabel(_("Global Tags loaded"))
        self.buildMenuList(tags)

    def onTopTracksLoaded(self, tracks):
        self.setInfoLabel(_("Top Tracks loaded"))
        self.buildMenuList(tracks)

    def onRecentTracksLoaded(self, tracks):
        self.setInfoLabel(_("Recent Tracks loaded"))
        self.buildMenuList(tracks)

    def onRecentBannedTracksLoaded(self, tracks):
        self.setInfoLabel(_("Banned Tracks loaded"))
        self.buildMenuList(tracks)

    def onRecentLovedTracksLoaded(self, tracks):
        self.setInfoLabel(_("Loved Tracks loaded"))
        self.buildMenuList(tracks)

    def onNeighboursLoaded(self, user):
        self.setInfoLabel(_("Neighbours loaded"))
        self.buildMenuList(user)

    def onFriendsLoaded(self, user):
        self.setInfoLabel(_("Friends loaded"))
        self.buildMenuList(user)

    def onStationChanged(self, reason):
        self.setInfoLabel(reason)
        self.loadPlaylist()

    def onMetadataLoaded(self, metadata):
        self.updateGUI()
        self.guiupdatetimer.start(
            config.plugins.LastFM.metadatarefreshinterval.value * 1000)

    def onPlaylistLoaded(self, reason):
        self.streamplayer.setPlaylist(self.playlist)
        self.streamplayer.play()

    def skipTrack(self):
        self.streamplayer.skip()
        self.updateGUI()

    def banTrack(self):
        self.ban()
        self.streamplayer.skip()
        self.updateGUI()

    def action_TabChanged(self):
        self.tabchangetimer.stop()
        self.tabchangetimer.start(
            config.plugins.LastFM.timeouttabselect.value * 1000)

    def guiupdatetimerFired(self):
        self.updateGUI()
        self.guiupdatetimer.start(
            config.plugins.LastFM.metadatarefreshinterval.value * 1000)

    def tabchangedtimerFired(self):
        self.tablist.getCurrent()[1][1]()
        self.tabchangetimer.stop()

    def startScreensaverTimer(self):
        self.screensavertimer.start(
            config.plugins.LastFM.sreensaver.wait.value * 1000)

    def resetScreensaverTimer(self):
        self.screensavertimer.stop()
        self.screensavertimer.start(
            config.plugins.LastFM.sreensaver.wait.value * 1000)

    def startScreensaver(self):
        if config.plugins.LastFM.sreensaver.use.value:
            self.screensavertimer.stop()
            self.session.openWithCallback(self.updateGUI, LastFMSaveScreen,
                                          self)

    def action_nextTab(self):
        self.tablist.down()
        self.resetScreensaverTimer()

    def action_prevTab(self):
        self.tablist.up()
        self.resetScreensaverTimer()

    def action_menu(self):
        self.session.open(LastFMConfigScreen)
        self.resetScreensaverTimer()

    def action_exit(self):
        self.screensavertimer.stop()
        self.guiupdatetimer.stop()
        self.streamplayer.stop(force=True)
        self.streamplayer.onStateChanged = []

        self.close()

    def action_ok(self):
        x = self["streamlist"].l.getCurrentSelection()
        if x is None:
            pass
        elif len(x) > 1:
            if not x[1].startswith('lastfm://'):
                self.customstationtype = x[1]
                text = _("please enter an %s name to listen to" % x[1])
                texts = _("%s name" % x[1])
                self.session.openWithCallback(
                    self.onTextForCustomStationEntered,
                    InputBox,
                    windowTitle=text,
                    title=texts)
            else:
                self.changeStation(x[1])
                self.resetScreensaverTimer()

    def onTextForCustomStationEntered(self, text):
        print "onTextForCustomStationEntered", text, self.customstationtype
        if text is not None:
            if self.customstationtype == "artist":
                self.changeStation(
                    urllib2_qoute("lastfm://artist/%s/similarartists" % text))
            elif self.customstationtype == "groupe":
                self.changeStation(urllib2_qoute("lastfm://group/%s" % text))
            elif self.customstationtype == "tag":
                self.changeStation(
                    urllib2_qoute("lastfm://globaltags/%s" % text))

    def action_startstop(self):
        self.resetScreensaverTimer()
        if self.streamplayer.is_playing:
            self.streamplayer.stop(force=True)
            self.setInfoLabel(_("Stream stopped"))
        else:
            self.setInfoLabel(_("Starting stream"), timeout=True)
            self.loadPlaylist()
            self.updateGUI(
            )  #forcing guiupdate, so we dont wait till guiupdatetimer fired
            self.guiupdatetimer.start(
                config.plugins.LastFM.metadatarefreshinterval.value * 1000)

    def setInfoLabel(self, text, timeout=True):
        self.infolabelcleartimer.stop()
        self["infolabel"].setText(text)
        if timeout is True:
            self.infolabelcleartimer.start(
                config.plugins.LastFM.timeoutstatustext.value * 1000)

    def clearInfoLabel(self):
        self["infolabel"].setText("")

    def updateGUI(self):

        if self.streamplayer.is_playing is True:
            self["duration"].setText(self.streamplayer.getRemaining())
            self["button_red"].setText(_("Stop"))
        else:
            self["duration"].setText("00:00")
            self["button_red"].setText(_("Play"))

        if self.streamplayer.is_playing is not True or self.shown is not True:
            return None

        if self.streamplayer.is_playing is True:
            self.setTitle(config.plugins.LastFM.name.value + " " + _("Ver.") +
                          lastfm_pluginversion + " " +
                          self.streamplayer.getMetadata("station"))
            self["info_artist"].setText(
                self.streamplayer.getMetadata("creator"))
            self["info_album"].setText(self.streamplayer.getMetadata("album"))
            self["info_track"].setText(self.streamplayer.getMetadata("title"))
            self.summaries.setText(
                self.streamplayer.getMetadata("creator") + " - " +
                self.streamplayer.getMetadata("title"))
        else:
            self.setTitle("Last.FM")
            self["info_artist"].setText("N/A")
            self["info_album"].setText("N/A")
            self["info_track"].setText("N/A")
            self.summaries.setText("N/A")

        if self.streamplayer.getMetadata("image").startswith(
                "http") and config.plugins.LastFM.showcoverart.value:
            self.imageconverter.convert(self.streamplayer.getMetadata("image"))
        else:
            self.setCoverArt()

        if self.streamplayer.is_playing is not True:
            self.setTitle(myname)
            self.setCoverArt()
            self["info_artist"].setText("N/A")
            self["info_album"].setText("N/A")
            self["info_track"].setText("N/A")

    def setCoverArt(self, pixmap=None):
        if pixmap is None:
            self["info_cover"].instance.setPixmapFromFile(self.noCoverArtPNG)
        else:
            self["info_cover"].instance.setPixmap(pixmap)

    def loadPersonalStations(self):
        tags = []
        x = {}
        x["_display"] = _("Personal Recommendations")
        x["stationurl"] = self.getPersonalURL(
            config.plugins.LastFM.username.value,
            level=config.plugins.LastFM.recommendedlevel.value)
        tags.append(x)

        x = {}
        x["_display"] = _("Neighbours Tracks")
        x["stationurl"] = self.getNeighboursURL(
            config.plugins.LastFM.username.value)
        tags.append(x)

        x = {}
        x["_display"] = _("Loved Tracks")
        x["stationurl"] = self.getLovedURL(
            config.plugins.LastFM.username.value)
        tags.append(x)

        x = {}
        x["_display"] = _("Play Artist Radio...")
        x["stationurl"] = 'artist'
        tags.append(x)

        x = {}
        x["_display"] = _("Play Group Radio...")
        x["stationurl"] = 'groupe'
        tags.append(x)

        x = {}
        x["_display"] = _("Play Tag Radio...")
        x["stationurl"] = 'tag'
        tags.append(x)

        creator = self.streamplayer.getMetadata("creator")
        if creator != "no creator" and creator != "N/A":
            x = {}
            x["_display"] = _(
                "Tracks similar to") + " " + self.streamplayer.getMetadata(
                    "creator")
            x["stationurl"] = self.getSimilarArtistsURL(artist=creator)
            tags.append(x)

            x = {}
            x["_display"] = _("Tracks liked by Fans of"
                              ) + " " + self.streamplayer.getMetadata(
                                  "creator")
            x["stationurl"] = self.getArtistsLikedByFans(artist=creator)
            tags.append(x)

            x = {}
            x["_display"] = _(
                "Group of") + " " + self.streamplayer.getMetadata("creator")
            x["stationurl"] = self.getArtistGroup(artist=creator)
            tags.append(x)

        self.buildMenuList(tags)

    def loadGlobalTags(self):
        self.setInfoLabel(_("Loading Global Tags"))
        tags = self.getGlobalTags()

    def loadTopTracks(self):
        self.setInfoLabel(_("Loading Top Tacks"))
        tracks = self.getTopTracks(config.plugins.LastFM.username.value)

    def loadRecentTracks(self):
        self.setInfoLabel(_("Loading Recent Tracks"))
        tracks = self.getRecentTracks(config.plugins.LastFM.username.value)

    def loadLovedTracks(self):
        self.setInfoLabel(_("Loading Loved Tracks"))
        tracks = self.getRecentLovedTracks(
            config.plugins.LastFM.username.value)

    def loadBannedTracks(self):
        self.setInfoLabel(_("Loading Loved Tracks"))
        tracks = self.getRecentBannedTracks(
            config.plugins.LastFM.username.value)

    def loadNeighbours(self):
        self.setInfoLabel(_("Loading Neighbours"))
        tracks = self.getNeighbours(config.plugins.LastFM.username.value)

    def loadFriends(self):
        self.setInfoLabel(_("Loading Friends"))
        tracks = self.getFriends(config.plugins.LastFM.username.value)

    def buildMenuList(self, items):
        menuliste = []
        for i in items:
            menuliste.append((i['_display'], i['stationurl']))
        self["streamlist"].l.setList(menuliste)

    def createSummary(self):
        return lastfmLCDScreen
 def __init__(self, list):
     MenuList.__init__(self, list, False, eListboxPythonMultiContent)
     self.l.setItemHeight(100)
     self.l.setFont(0, gFont('Regular', 25))
Beispiel #37
0
class VpnScreen(Screen):
    def __init__(self, session):
        self.skin = """
              <screen name="Vpn Menu" backgroundColor="#00000000" position="center,center" size="666,420" title="Vpn" flags="wfNoBorder">
              <widget name="countryPng" position="30,5" alphatest="blend" size="50,33" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VpnChanger/icon/default.png" zPosition="2" />
              <widget name="list" position="center,70" size="600,160" backgroundColor="#00000000" scrollbarMode="showOnDemand" zPosition="2" transparent="1" />
              <widget name="vpnLoad" position="center,70" size="600,160" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <widget name="ipLabel" position="80,5" size="600,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <eLabel position="30,253" size="5,33" zPosition="2" backgroundColor="#00ff0000" />
              <eLabel text="Start/Stop OpenVpn" position="40,253" size="333,33" backgroundColor="#00000000" transparent="1" foregroundColor="#00B8B8B8" zPosition="2" font="Regular; 24" valign="top" halign="left" />
              <widget name="vpnStatus" position="303,253" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <widget name="vpnInfo" position="303,293" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <eLabel position="30,293" size="5,33" zPosition="2" backgroundColor="#0000ff00" />
              <widget name="vpnDir" position="40,293" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <eLabel position="30,333" size="5,33" zPosition="2" backgroundColor="#00ebff00" />
              <widget name="check" position="40,333" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <widget name="checkLabel" position="303,333" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <eLabel position="30,373" size="5,33" zPosition="2" backgroundColor="#003000ff" />
              <widget name="network" position="40,373" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              </screen>"""


        Screen.__init__(self, session)

        self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "SetupActions"], {
            "ok": self.keyOK,
            "red": self.keyRed,
            "green": self.keyGreen,
            "yellow": self.keyYellow,
            "blue": self.keyBlue,
            "cancel": self.keyCancel
        }, -1)

        self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
        if DESKTOPSIZE.width() == 1920:
            self.chooseMenuList.l.setFont(0, gFont('Regular', 29))
            self.chooseMenuList.l.setItemHeight(31)
        else:
            self.chooseMenuList.l.setFont(0, gFont('Regular', 19))
            self.chooseMenuList.l.setItemHeight(22)

        self['countryPng'] = Pixmap()
        self["ipLabel"] = Label("")
        self["check"] = Label("Start/Stop Check Vpn")
        self["network"] = Label(_("Restart Network"))
        if config.vpnChanger.vpnCheck.value:
            text = "Vpn Check is Enabled"
        else:
            text = "Vpn Check is Disabled"
        self["checkLabel"] = Label(text)
        self['vpnInfo'] = Label(config.vpnChanger.lastVpn.value)
        self['vpnDir'] = Label(config.vpnChanger.dir.value)
        self['list'] = self.chooseMenuList
        self['vpnLoad'] = Label("OpenVpn is Loading.....")
        if "openvpn" in str(os.listdir("/var/run")):
            text = "OpenVpn is Running"
        else:
            text = "OpenVpn is not Running"
        self['vpnStatus'] = Label(text)

        self['vpnLoad'].hide()
        self.Timer = 0
        self.StatusTimer = eTimer()
        self.StatusTimer.callback.append(self.statusVpn)

        self.onLayoutFinish.append(self.setList)

    def setList(self):
        self.vpnList = []
        if os.path.exists(config.vpnChanger.dir.value):
           for i in os.listdir(config.vpnChanger.dir.value):
               self.vpnList.append((i,))

        if self.vpnList:
           self.vpnList.sort()
           self.chooseMenuList.setList(map(enterListEntry, self.vpnList))
        threading.Thread(target=self.readIP).start()

    def keyOK(self):
        if self.vpnList:
           vpn = self['list'].getCurrent()[0][0]
           #Check Vpn running
           if "openvpn" in str(os.listdir("/var/run")):
                try:
                    f = open(LOGFILE, "a")
                    f.write(time.strftime("%d.%m.%Y %H:%M:%S") + " Stopping OpenVpn\n")
                    f.close()
                except:
                    print "Log File Error"
                os.system("/etc/init.d/openvpn stop")

           # Alte OpenVpn configs loeschen so wie das Log File
           if os.path.exists("/etc/openvpn"):
               for i in os.listdir("/etc/openvpn"):
                   if i.split('.')[-1] == 'conf':
                       f = open("/etc/openvpn/%s" % i, "r")
                       for line in f:
                           if "log" in line:
                               try:
                                   f = open(LOGFILE, "a")
                                   f.write(time.strftime("%d.%m.%Y %H:%M:%S") + " Delet Vpn Log " + line[4:].strip() + "\n")
                                   f.close()
                               except:
                                   print "Log File Error"
                               os.system("rm %s" % line[4:].strip())
                       f.close()
               try:
                   f = open(LOGFILE, "a")
                   f.write(time.strftime("%d.%m.%Y %H:%M:%S") + " Delet Vpn Configs\n")
                   f.close()
               except:
                   print "Log File Error"
               os.system("rm -R /etc/openvpn/*")

           #Neue Configs in openvpn erstellen
           try:
               f = open(LOGFILE, "a")
               f.write(time.strftime("%d.%m.%Y %H:%M:%S") + " cp new Vpn Configs " + str(vpn) + "\n")
               f.close()
           except:
               print "Log File Error"
           os.system("cp -R %s%s/* /etc/openvpn" % (config.vpnChanger.dir.value, vpn))

           #Lesen der neuen Config und wenn kein log file angegeben ist eins hinzufuegen
           if os.path.exists("/etc/openvpn"):
               log = True
               confData = []
               for i in os.listdir("/etc/openvpn"):
                   if i.split('.')[-1] == 'conf':
                       new = open("/etc/openvpn/%snew" % i, "a")
                       old = open("/etc/openvpn/%s" % i, "r")
                       for line in old:
                           if "log" in line:
                               if not line[0] == "#":
                                  print "Vpn LogFile OK ", line[4:].strip()
                                  log = False
                                  confData.append((line))
                           else:
                               confData.append((line))
                       if log:
                          new.write("log /etc/openvpn/openvpn.log\n")
                       if confData:
                           for line in confData:
                               new.write(str(line))
                           if fileExists("/etc/openvpn/%snew" % i):
                               os.system("mv /etc/openvpn/%snew /etc/openvpn/%s" % (i, i))
                       old.close()
                       new.close()

           else:
               try:
                   f = open(LOGFILE, "a")
                   f.write(time.strftime("%d.%m.%Y %H:%M:%S") + " /etc/openvpn not found\n")
                   f.close()
               except:
                   print "Log File Error"
               self.session.open(MessageBox, _("/etc/openvpn not found!\nIs OpenVpn installed?"),
                                 MessageBox.TYPE_ERROR, timeout=10)
               return
           #Vpn config chmod 755
           try:
               f = open(LOGFILE, "a")
               f.write(time.strftime("%d.%m.%Y %H:%M:%S") + " chmod 755 /etc/openvpn/\n")
               f.close()
           except:
               print "Log File Error"
           os.system("chmod 755 /etc/openvpn/*")

           #Neustarten von Vpn
           try:
               f = open(LOGFILE, "a")
               f.write(time.strftime("%d.%m.%Y %H:%M:%S") + " OpenVpn Starting\n")
               f.close()
           except:
               print "Log File Error"
           os.system("/etc/init.d/openvpn start")
           #Check running openVpn
           if "openvpn" in str(os.listdir("/var/run")):
               config.vpnChanger.lastVpn.value = vpn + " is Enabled"
               self['vpnStatus'].setText("OpenVpn is Running")
               self['list'].hide()
               self['vpnLoad'].show()
               self.statusVpn()
               try:
                   f = open(LOGFILE, "a")
                   f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + str(vpn) + " is Running\n")
                   f.close()
               except:
                   print "Log File Error"
           else:
               config.vpnChanger.lastVpn.value = vpn + " Error"
               self['vpnStatus'].setText("OpenVpn is not Running")
               self.session.open(MessageBox, _("Vpn Config %s konnte nicht gestartet werden!" % vpn), MessageBox.TYPE_ERROR, timeout=10)
               try:
                   f = open(LOGFILE, "a")
                   f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + str(vpn) + " is not Running\n")
                   f.close()
               except:
                   print "Log File Error"
           self['vpnInfo'].setText(config.vpnChanger.lastVpn.value)
           config.vpnChanger.lastVpn.save()
           configfile.save()

    def keyRed(self):
        if "openvpn" in str(os.listdir("/var/run")):
            os.system("/etc/init.d/openvpn stop")
            self['vpnStatus'].setText("OpenVpn is not Running")
            self.session.open(MessageBox, _("OpneVpn wurde gestoppt!"), MessageBox.TYPE_INFO, timeout=10)
            threading.Thread(target=self.readIP).start()
            try:
                f = open(LOGFILE, "a")
                f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "OpenVpn Stopping\n")
                f.close()
            except:
                print "Log File Error"
        else:
            os.system("/etc/init.d/openvpn start")
            if "openvpn" in str(os.listdir("/var/run")):
                self['vpnStatus'].setText("OpenVpn is Running")
                self['list'].hide()
                self['vpnLoad'].show()
                self.statusVpn()
                try:
                    f = open(LOGFILE, "a")
                    f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "OpenVpn is Running\n")
                    f.close()
                except:
                    print "Log File Error"
            else:
                try:
                    f = open(LOGFILE, "a")
                    f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "OpenVpn Starting Error\n")
                    f.close()
                except:
                    print "Log File Error"
                self['vpnStatus'].setText("OpenVpn is not Running")
                self.session.open(MessageBox, _("OpneVpn konnte nicht gestartet werden!"), MessageBox.TYPE_ERROR, timeout=10)

    def keyYellow(self):
        if config.vpnChanger.vpnCheck.value:
            config.vpnChanger.vpnCheck.value = False
            self["checkLabel"].setText("Vpn Check is Disabled")
            try:
                f = open(LOGFILE, "a")
                f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Vpn Check Disabled\n")
                f.close()
            except:
                print "Log File Error"
        else:
            config.vpnChanger.vpnCheck.value = True
            self["checkLabel"].setText("Vpn Check is Enabled")
            self.session.openWithCallback(self.readAnswer, MessageBox, _('Netzwerkverbindung trenne wenn die Vpn Verbindung\nnicht mehr besteht? '), MessageBox.TYPE_YESNO)
            try:
                f = open(LOGFILE, "a")
                f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Vpn Check Enabled\n")
                f.close()
            except:
                print "Log File Error"
        config.vpnChanger.vpnCheck.save()
        configfile.save()

    def keyBlue(self):
        print "Restart Network"
        self.session.openWithCallback(self.readIP, RestartNetwork)

    def readAnswer(self, answer):
        if answer is False:
            config.vpnChanger.setNetwork.value = False
            try:
                f = open(LOGFILE, "a")
                f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Vpn Check Network is Disabled\n")
                f.close()
            except:
                print "Log File Error"
        else:
            config.vpnChanger.setNetwork.value = True
            try:
                f = open(LOGFILE, "a")
                f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Vpn Check Network is Enabled\n")
                f.close()
            except:
                print "Log File Error"
        config.vpnChanger.setNetwork.save()
        configfile.save()

    def keyGreen(self):
        self.session.openWithCallback(self.reload, FolderScreen, config.vpnChanger.dir.value)

    def reload(self):
        self['vpnDir'].setText(config.vpnChanger.dir.value)
        self.vpnList = []
        if os.path.exists(config.vpnChanger.dir.value):
           for i in os.listdir(config.vpnChanger.dir.value):
               self.vpnList.append((i,))

        if self.vpnList:
            self.vpnList.sort()
            self.chooseMenuList.setList(map(enterListEntry, self.vpnList))

    def statusVpn(self):
        logFile = None
        if os.path.exists("/etc/openvpn"):
          for i in os.listdir("/etc/openvpn"):
            if i.split('.')[-1] == 'conf':
                f = open("/etc/openvpn/%s" % i, "r")
                for line in f:
                    if "log" in line:
                       logFile = line[4:].strip()
                       break
                       f.close()
                f.close()

        if logFile:
          if fileExists(logFile):
             f = open(logFile, "r")
             for line in f:
               if re.search("Initialization Sequence Completed", line):
                   self['vpnLoad'].hide()
                   self['list'].show()
                   threading.Thread(target=self.readIP).start()
                   f.close()
                   try:
                       f = open(LOGFILE, "a")
                       f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "OpenVpn Initialization Sequence Completed\n")
                       f.close()
                   except:
                       print "Log File Error"
                   if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/VpnChanger/script/myStart.sh"):
                       try:
                           os.system("/usr/lib/enigma2/python/Plugins/Extensions/VpnChanger/script/myStart.sh")
                           f = open(LOGFILE, "a")
                           f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Start myStart Script\n")
                           f.close()
                       except:
                           try:
                               f = open(LOGFILE, "a")
                               f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Start myStart Script Error\n")
                               f.close()
                           except:
                               print "Log File Error"
                   self.Timer = 0
                   return
               if re.search("VERIFY ERROR", line):
                   self['vpnLoad'].hide()
                   self['list'].show()
                   threading.Thread(target=self.readIP).start()
                   f.close()
                   try:
                       f = open(LOGFILE, "a")
                       f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "OpenVpn VERIFY ERROR\n")
                       f.close()
                   except:
                       print "Log File Error"
                   if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/VpnChanger/script/myStart.sh"):
                       try:
                           os.system("/usr/lib/enigma2/python/Plugins/Extensions/VpnChanger/script/myStart.sh")
                           f = open(LOGFILE, "a")
                           f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Start myStart Script\n")
                           f.close()
                       except:
                           try:
                               f = open(LOGFILE, "a")
                               f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Start myStart Script Error\n")
                               f.close()
                           except:
                               print "Log File Error"
                   self.Timer = 0
                   return
             if not self.Timer == 7:
                self.Timer = self.Timer + 1
                self.StatusTimer.start(3000, True)
                f.close()
             else:
                 self.Timer = 0
                 self['vpnLoad'].hide()
                 self['list'].show()
                 threading.Thread(target=self.readIP).start()
                 f.close()
                 try:
                     f = open(LOGFILE, "a")
                     f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Load OpenVpn Loading to long\n")
                     f.close()
                 except:
                     print "Log File Error"
                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/VpnChanger/script/myStart.sh"):
                     try:
                         os.system("/usr/lib/enigma2/python/Plugins/Extensions/VpnChanger/script/myStart.sh")
                         f = open(LOGFILE, "a")
                         f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Start myStart Script\n")
                         f.close()
                     except:
                         try:
                             f = open(LOGFILE, "a")
                             f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Start myStart Script Error\n")
                             f.close()
                         except:
                             print "Log File Error"
          else:
              self['vpnLoad'].hide()
              self['list'].show()
              threading.Thread(target=self.readIP).start()
              try:
                  f = open(LOGFILE, "a")
                  f.write(time.strftime("%d.%m.%Y %H:%M:%S ") + "Load OpenVpn Log File ERROR\n")
                  f.close()
              except:
                  print "Log File Error"

    def readIP(self):
        print "[Vpn] read IP"
        ipData = []
        pngData = []
        try:
            response = urllib2.urlopen(IPCHECK)
            data = response.read()
            response.close()
        except:
            print "Read Url Error"
        else:
            # IP
            ipData = re.findall('<strong>([0-9]+.[0-9]+.[0-9]+.[0-9]+)</strong></div>', data, re.S)
            # png
            pngData = re.findall('<div class="location"><img src="(https://.*?/img/country/.*?png)"'
                                 ' alt="(.*?)" />.*?</div>', data, re.S)
        if ipData:
            ip = "IP: " + str(ipData[0])
        else:
            try:
                response = urllib2.urlopen("https://api.ipify.org/")
                data = response.read()
                response.close()
            except:
                ip = "IP: No Data Found!"
            else:
                ip = "IP: " + str(data).strip()

        if pngData:
            (Url, Land) = pngData[0]
            ip = str(Land) + "  " + ip
            pngUrl = Url
        else:
            ip = "Country: ?  " + ip
            pngUrl = DEFAULTCOUNTRY

        self['ipLabel'].setText(ip)
        self.loadPic(pngUrl)

    def loadPic(self, pngUrl):
           downloadPage(pngUrl, "/tmp/country.png").addCallback(self.ShowPng)

    def ShowPng(self, Data):
        if fileExists("/tmp/country.png"):
            self['countryPng'].instance.setPixmap(gPixmapPtr())
            self.scale = AVSwitch().getFramebufferScale()
            self.picload = ePicLoad()
            size = self['countryPng'].instance.size()
            self.picload.setPara((size.width(), size.height(), self.scale[0], self.scale[1], False, 1, "#00000000"))
            if self.picload.startDecode("/tmp/country.png", 0, 0, False) == 0:
                ptr = self.picload.getData()
                if ptr != None:
                    self['countryPng'].instance.setPixmap(ptr)
                    self['countryPng'].show()
                    del self.picload

    def keyCancel(self):
        self.close()
Beispiel #38
0
	def postWidgetCreate(self, instance):
		MenuList.postWidgetCreate(self, instance)
		self.moveToIndex(self.selection)
		self.instance.setWrapAround(True)
Beispiel #39
0
    def __init__(self, session, timer, menu_path=""):
        Screen.__init__(self, session)
        screentitle = _("Timer sanity error")
        self.menu_path = menu_path
        if config.usage.show_menupath.value == 'large':
            self.menu_path += screentitle
            title = self.menu_path
            self["menu_path_compressed"] = StaticText("")
            self.menu_path += ' / '
        elif config.usage.show_menupath.value == 'small':
            title = screentitle
            condtext = ""
            if self.menu_path and not self.menu_path.endswith(' / '):
                condtext = self.menu_path + " >"
            elif self.menu_path:
                condtext = self.menu_path[:-3] + " >"
            self["menu_path_compressed"] = StaticText(condtext)
            self.menu_path += screentitle + ' / '
        else:
            title = screentitle
            self["menu_path_compressed"] = StaticText("")
        Screen.setTitle(self, title)

        self.timer = timer
        print "[TimerEdit] TimerSanityConflict"

        self["timer1"] = TimerList(self.getTimerList(timer[0]))
        self.list = []
        self.list2 = []
        count = 0
        for x in timer:
            if count != 0:
                self.list.append(
                    (_("Conflicting timer") + " " + str(count), x))
                self.list2.append((timer[count], False))
            count += 1
        if count == 1:
            self.list.append((_("Channel not in services list")))

        self["list"] = MenuList(self.list)
        self["timer2"] = TimerList(self.list2)

        self["key_red"] = StaticText(_("Edit new entry"))
        # 		self["key_green"] = StaticText("")
        self["key_yellow"] = StaticText("")
        self["key_blue"] = StaticText("")

        self.key_green_choice = self.EMPTY
        self.key_yellow_choice = self.EMPTY
        self.key_blue_choice = self.EMPTY

        self["actions"] = ActionMap(
            [
                "OkCancelActions", "DirectionActions", "ShortcutActions",
                "TimerEditActions"
            ], {
                "ok": self.leave_ok,
                "cancel": self.leave_cancel,
                "red": self.editTimer1,
                "up": self.up,
                "down": self.down
            }, -1)
        self.onShown.append(self.updateState)
Beispiel #40
0
 def __init__(self):
     MenuList.__init__(self, [], False, eListboxPythonMultiContent)
     self.l.setItemHeight(25)
     self.l.setFont(0, gFont("Regular", 20))
Beispiel #41
0
class BrowserMenu(Screen):
    ACTION_BOOKMARK = 0
    ACTION_COOKIES = 1
    ACTION_STORAGE_PATH = 2

    MENU_BOOKMARKS = 0
    MENU_SETTINGS = 1
    MENU_HISTORY = 2
    MENU_DOWNLOADS = 3
    MENU_CERTS = 4
    MENU_COOKIES = 5

    size = getDesktop(0).size()
    width = int(size.width() * 0.9)
    height = int(size.height() * 0.85)
    bof = height - 35  #Button-Offset

    skin = """
		<screen name="BrowserMenu" position="center,center" size="%(w)d,%(h)d" title="Web Browser - Menu" >
			<widget name="menu" position="0,0" zPosition="1" size="200,%(h)d" backgroundColor="#000000" transparent="1" />
			<widget source="line" render="Canvas" position="203,0" zPosition="2" size="4,%(h)d" backgroundColor="#000000" transparent="1" alphatest="on"/>
			<widget source="list" render="Listbox" position="210,0" zPosition="1" size="%(listW)d,%(listH)d" backgroundColor="#000000" transparent="1">
				<convert type="TemplatedMultiContent">
					{"templates":
						{"default": (55, [
							MultiContentEntryText(pos = (10, 1), size = (920, 25), font = 0, flags = RT_VALIGN_CENTER, text = 1),
							MultiContentEntryText(pos = (10, 30), size = (920, 25), font = 1, flags = RT_VALIGN_CENTER, text = 2),
						]),
						"history": (55, [
							MultiContentEntryText(pos = (10, 1), size = (150, 25), font = 1, flags = RT_VALIGN_CENTER, text = 1),
							MultiContentEntryText(pos = (10, 28), size = (150, 25), font = 1, flags = RT_VALIGN_CENTER, text = 2),
							MultiContentEntryText(pos = (190, 1), size = (690, 25), font = 0, flags = RT_VALIGN_CENTER, text = 3),
							MultiContentEntryText(pos = (190, 28), size = (690, 25), font = 1, flags = RT_VALIGN_CENTER, text = 4),
						]),
						"downloads": (25, [
							MultiContentEntryText(pos = (0, 1), size = (600, 24), font=1, flags = RT_HALIGN_LEFT, text = 1),
							MultiContentEntryText(pos = (610, 1), size = (150, 24), font=1, flags = RT_HALIGN_RIGHT, text = 2),
							MultiContentEntryProgress(pos = (760, 1), size = (100, 24), percent = 3),
							MultiContentEntryText(pos = (870, 1), size = (70, 24), font=1, flags = RT_HALIGN_RIGHT, text = 4),
						]),
						"certificates": (85, [
							MultiContentEntryText(pos = (10, 1), size = (150, 25), font = 1, flags = RT_VALIGN_CENTER, text = 1),
							MultiContentEntryText(pos = (10, 28), size = (150, 25), font = 1, flags = RT_VALIGN_CENTER, text = 2),
							MultiContentEntryText(pos = (190, 1), size = (690, 25), font = 0, flags = RT_VALIGN_CENTER, text = 3),
							MultiContentEntryText(pos = (190, 28), size = (690, 25), font = 1, flags = RT_VALIGN_CENTER, text = 4),
							MultiContentEntryText(pos = (10, 60), size = (900, 25), font = 0, flags = RT_VALIGN_CENTER, text = 5),
						]),
						"cookies": (75, [
							MultiContentEntryText(pos = (10, 1), size = (150, 25), font = 1, flags = RT_VALIGN_CENTER, text = 1),
							MultiContentEntryText(pos = (10, 28), size = (150, 25), font = 1, flags = RT_VALIGN_CENTER, text = 2),
							MultiContentEntryText(pos = (180, 1), size = (720, 25), font = 0, flags = RT_VALIGN_CENTER, text = 3),
							MultiContentEntryText(pos = (180, 28), size = (625, 25), font = 1, flags = RT_VALIGN_CENTER, text = 4),
							MultiContentEntryText(pos = (10, 60), size = (900, 15), font = 2, flags = RT_VALIGN_CENTER, text = 5),
						])
						},
					"fonts": [gFont("Regular", 22), gFont("Regular", 16), gFont("Regular", 13)]
					}
				</convert>
			</widget>
			<widget name="statuslabel" position="210,%(inputY)d" size="%(listW)d,25" font="Regular;20"  zPosition="2" halign="center" valign="center" backgroundColor="#000000" transparent="0" />
			<widget name="input" position="210,%(inputY)d" zPosition="1" size="%(listW)d,25" font="Regular;20" halign="left" valign="bottom" backgroundColor="#000000" transparent="1"/>
			<widget name="config" position="210,0" zPosition="2" size="%(listW)d,%(configH)d" backgroundColor="background" transparent="0" />

			<ePixmap pixmap="skin_default/buttons/button_red_off.png" position="210,%(btnY)d" size="15,16" alphatest="on" />
			<widget source="button_red" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_red.png" position="210,%(btnY)d" size="15,16" alphatest="on">
				<convert type="ConditionalShowHide" />
			</widget>
			<widget name="red" position="230,%(btnTxtY)d" size="100,20" foregroundColor="white" backgroundColor="background" font="Regular;18" transparent="1" halign="left" valign="top"/>

			<ePixmap pixmap="skin_default/buttons/button_green_off.png" position="340,%(btnY)d" size="15,16" zPosition="1" alphatest="on" />
			<widget source="button_green" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_green.png" position="340,%(btnY)d" size="15,16" alphatest="on">
				<convert type="ConditionalShowHide" />
			</widget>
			<widget name="green" position="360,%(btnTxtY)d" size="100,20" foregroundColor="white" backgroundColor="background" font="Regular;18" transparent="1" halign="left" valign="top"/>

			<ePixmap pixmap="skin_default/buttons/button_yellow_off.png" position="470,%(btnY)d" size="15,16" alphatest="on" />
			<widget source="button_yellow" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_yellow.png" position="470,%(btnY)d" size="15,16" alphatest="on">
				<convert type="ConditionalShowHide" />
			</widget>
			<widget name="yellow" position="490,%(btnTxtY)d" size="100,20" foregroundColor="white" backgroundColor="background" font="Regular;18" transparent="1" halign="left" valign="top"/>

			<ePixmap pixmap="skin_default/buttons/button_blue_off.png" position="600,%(btnY)d" size="15,16" alphatest="on" />
			<widget source="button_blue" zPosition="2" render="Pixmap" pixmap="skin_default/buttons/button_blue.png" position="600,%(btnY)d" size="15,16" alphatest="on">
				<convert type="ConditionalShowHide" />
			</widget>
			<widget name="blue" position="620,%(btnTxtY)d" size="200,20" foregroundColor="white" backgroundColor="background" font="Regular;18" transparent="1" halign="left" valign="top"/>
		</screen>
		""" % {
        "w": width,
        "h": height,
        "listW": width - 210,
        "listH": height - 90,
        "inputY": height - 80,
        "configH": height - 90,
        "btnY": bof + 2,
        "btnTxtY": bof
    }

    def __init__(self, session, currentTitle, currentUrl, menulist=None):
        Screen.__init__(self, session)

        self.currentUrl = currentUrl
        self.currentTitle = currentTitle

        #Menu
        if menulist is None:
            self.menu = MenuList([
                (_("Bookmarks"), self.MENU_BOOKMARKS),
                (_("History"), self.MENU_HISTORY),
                (_("Downloads"), self.MENU_DOWNLOADS),
                (_("Certificates"), self.MENU_CERTS),
                (_("Cookies"), self.MENU_COOKIES),
                (_("Settings"), self.MENU_SETTINGS),
            ],
                                 enableWrapAround=True)
        else:
            self.menu = MenuList(menulist, enableWrapAround=True)
        self["menu"] = self.menu

        self["statuslabel"] = Label("")
        self["statuslabel"].hide()

        #Color Buttons
        self["button_red"] = Boolean(False)
        self["button_green"] = Boolean(False)
        self["button_yellow"] = Boolean(False)
        self["button_blue"] = Boolean(False)
        self.red = Label("")
        self.green = Label("")
        self.yellow = Label("")
        self.blue = Label("")
        self["red"] = self.red
        self["green"] = self.green
        self["yellow"] = self.yellow
        self["blue"] = self.blue

        #Lists
        self.detailList = List([], enableWrapAround=True)
        self.detailConfigList = ConfigList([])
        self.detailConfigList.l.setSeperation((BrowserMenu.width - 210) / 2)
        config.plugins.WebBrowser.storage.enabled.addNotifier(
            self.__cfgExpandableElementChanged, initial_call=False)
        config.plugins.WebBrowser.storage.enabled.addNotifier(
            self.__cfgStoragePathChanged, initial_call=False)
        config.plugins.WebBrowser.storage.path.addNotifier(
            self.__cfgStoragePathChanged, initial_call=False)

        self.detailInput = EnhancedInput()

        self["list"] = self.detailList
        self["config"] = self.detailConfigList
        self["input"] = self.detailInput
        self["line"] = CanvasSource()

        self.__cfgCreateSetup()

        self.__db = BrowserDB.getInstance()
        self.__curMenu = self.MENU_BOOKMARKS
        self.__bmList = None
        self.__hisList = None
        self.__crtList = None
        self.__ckList = None
        self.__bmNeedle = ""
        self.__bmFilterTimer = eTimer()
        self.__bmFilterTimer_conn = self.__bmFilterTimer.timeout.connect(
            self.__bmFilterCB)
        self.__hisNeedle = ""
        self.__hisFilterTimer = eTimer()
        self.__hisFilterTimer_conn = self.__hisFilterTimer.timeout.connect(
            self.__hisFilterCB)
        self.__dlRefreshTimer = eTimer()
        self.__dlRefreshTimer_conn = self.__dlRefreshTimer.timeout.connect(
            self.__dlBuildList)
        self.__statusTimer = eTimer()
        self.__statusTimer_conn = self.__statusTimer.timeout.connect(
            self.__hideStatus)
        self.__actions = []

        self.onFirstExecBegin.append(self.__drawSeparator)
        self.onFirstExecBegin.append(self.__onMenuChanged)
        self.onExecBegin.append(self.__reloadData)
        self.onShow.append(self.setKeyboardModeAscii)

        self["actions"] = ActionMap(
            ["BrowserActions", "ColorActions"],
            {
                "ok": self.__actionOk,
                "enter": self.__actionOk,
                "exit": self.__actionExit,
                "pageUp": self.__actionMenuUp,
                "pageDown": self.__actionMenuDown,
                "up": boundFunction(self.__action, "up"),
                "down": boundFunction(self.__action, "down"),
                "left": boundFunction(self.__action, "left"),
                "right": boundFunction(self.__action, "right"),
                "red": boundFunction(self.__action, "red"),
                "green": boundFunction(self.__action, "green"),
                "yellow": boundFunction(self.__action, "yellow"),
                "blue": boundFunction(self.__action, "blue"),
                "backspace": boundFunction(self.__action, "backspace"),
                "delete": boundFunction(self.__action, "delete"),
                "ascii": boundFunction(self.__action, "ascii"),
                # TODO "text" : self.__text
            },
            -2)

        self["numberactions"] = NumberActionMap(
            ["NumberActions"], {
                "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.__actionFuncs = {
            self.MENU_BOOKMARKS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.selectPrevious,
                "right": self.detailList.pageDown,
                "ok": self.__bmOk,
                "enter": self.__bmOk,
                "red": self.__bmDelete,
                "green": self.__bmAdd,
                "yellow": self.__bmEdit,
                "blue": self.__bmSetCurrentAsHome,
                "backspace": self.__bmKeyBackspace,
                "delete": self.__bmKeyDelete,
                "ascii": self.__bmKeyAscii,
            },
            self.MENU_HISTORY: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "ok": self.__hisOk,
                "enter": self.__hisOk,
                "red": self.__hisClear,
                "blue": self.__hisSetCurrentAsHome,
                "backspace": self.__hisKeyBackspace,
                "delete": self.__hisKeyDelete,
                "ascii": self.__hisKeyAscii,
            },
            self.MENU_SETTINGS: {
                "up": self.__cfgKeyUp,
                "down": self.__cfgKeyDown,
                "left": self.__cfgKeyLeft,
                "right": self.__cfgKeyRight,
                "ok": self.__cfgKeyOK,
                "enter": self.__cfgKeyOK,
                "red": self.__cfgCancel,
                "green": self.__cfgSave,
                "backspace": self.__cfgKeyBackspace,
                "delete": self.__cfgKeyDelete,
                "ascii": self.__cfgKeyAscii,
            },
            self.MENU_DOWNLOADS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__dlAbort,
            },
            self.MENU_CERTS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__crtDelete,
                "green": self.__crtDetails,
            },
            self.MENU_COOKIES: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__ckDelete,
                "blue": self.__ckDeleteAll,
            }
        }

    def _close(self):
        config.plugins.WebBrowser.storage.enabled.removeNotifier(
            self.__cfgExpandableElementChanged)
        config.plugins.WebBrowser.storage.enabled.removeNotifier(
            self.__cfgStoragePathChanged)
        config.plugins.WebBrowser.storage.path.removeNotifier(
            self.__cfgStoragePathChanged)
        self.close(self.__actions)

    def __actionOk(self):
        if self["statuslabel"].visible:
            self["statuslabel"].hide()
        else:
            self.__action("ok")

    def __actionExit(self):
        if self["statuslabel"].visible:
            self["statuslabel"].hide()
        else:
            if self.detailConfigList.isChanged():
                self.__cfgSave()
            self._close()

    def __actionMenuUp(self):
        self.menu.up()
        self.__onMenuChanged()

    def __actionMenuDown(self):
        self.menu.down()
        self.__onMenuChanged()

    def __reloadData(self):
        self.__bmList = self.__db.getBookmarks()
        self.__hisList = self.__db.getHistory()
        self.__crtList = self.__db.getCerts()
        self.__ckList = self.__db.getCookies()

    def __action(self, action):
        print "[BrowserMenu].__action :: action='%s'" % action
        fnc = self.__actionFuncs[self.__curMenu].get(action, None)
        if fnc != None:
            fnc()

    def __text(self):
        if self.__curMenu == self.MENU_SETTINGS:
            self.__cfgKeyText()
        elif self.__curMenu == self.MENU_BOOKMARKS:
            pass

    def __keyNumberGlobal(self, number):
        if self.__curMenu == self.MENU_SETTINGS:
            self.__cfgKeyNumberGlobal(number)
        elif self.__curMenu == self.MENU_BOOKMARKS:
            self.__bmKeyNumberGlobal(number)
        elif self.__curMenu == self.MENU_HISTORY:
            self.__hisKeyNumberGlobal(number)

    def __onMenuChanged(self):
        self.__bmFilterTimer.stop()
        self.__hisFilterTimer.stop()
        self.__dlRefreshTimer.stop()

        self.__curMenu = self.menu.getCurrent()[1]
        if self.__curMenu == self.MENU_BOOKMARKS:
            self.__showMenuList(True)
            self.__setButtons(_("Delete"), _("Add"), _("Edit"),
                              _("Set as Startpage"))
            self.detailList.style = "default"
            self.__bmBuildList()
            self.detailInput.setText(self.__bmNeedle)
        elif self.__curMenu == self.MENU_HISTORY:
            self.__showMenuList(True)
            self.__setButtons(_("Clear"), "", "", _("Set as Startpage"))
            self.detailList.style = "history"
            self.__hisBuildList()
            self.detailInput.setText(self.__hisNeedle)
        elif self.__curMenu == self.MENU_SETTINGS:
            self.__showConfigList()
            self.__setButtons(_("Cancel"), _("Save"), "", "")
        elif self.__curMenu == self.MENU_DOWNLOADS:
            self.__showMenuList()
            self.__setButtons(_("Abort"), "", "", "")
            self.detailList.style = "downloads"
            self.__dlBuildList()
        elif self.__curMenu == self.MENU_CERTS:
            self.__showMenuList()
            self.__setButtons(_("Delete"), _("Details"), "", "")
            self.detailList.style = "certificates"
            self.__crtBuildList()
        elif self.__curMenu == self.MENU_COOKIES:
            self.__showMenuList()
            self.__setButtons(_("Delete"), "", "", _("Delete All"))
            self.detailList.style = "cookies"
            self.__ckBuildList()

    def __setButtons(self, red, green, yellow, blue):
        self.red.setText(red)
        self.__setButtonPixmapVisible(self["button_red"], red)
        self.green.setText(green)
        self.__setButtonPixmapVisible(self["button_green"], green)
        self.yellow.setText(yellow)
        self.__setButtonPixmapVisible(self["button_yellow"], yellow)
        self.blue.setText(blue)
        self.__setButtonPixmapVisible(self["button_blue"], blue)

    def __setButtonPixmapVisible(self, B, label):
        show = True
        if label == "":
            show = False
        B.setBoolean(show)

    def __showMenuList(self, hasFilter=False):
        if self.detailConfigList.visible:
            self.detailConfigList.hide()

# 		if not self.detailList.instance.visible:
# 			self.detailList.instance.show()
        if hasFilter:
            self.detailInput.show()
        else:
            self.detailInput.hide()

    def __showConfigList(self):
        # 		if self.detailList.instance.visible == 1:
        # 			self.detailList.instance.hide()
        self.detailInput.hide()
        if self.detailConfigList.visible == 0:
            self.detailConfigList.show()

    def __drawSeparator(self):
        self["line"].fill(0, 0, 4, BrowserMenu.height, 0xFF9900)
        self["line"].flush()

    def __setStatus(self, text):
        print "[BrowserMenu].__setStatus"
        self["statuslabel"].setText(text)
        self["statuslabel"].show()
        self.__statusTimer.startLongTimer(3)

    def __hideStatus(self):
        self["statuslabel"].hide()
        self.__statusTimer.stop()

    # Config List Methods
    def __cfgCreateSetup(self):
        list = [
            getConfigListEntry(_("Home Page"), config.plugins.WebBrowser.home),
            getConfigListEntry(_("Page to load on startup"),
                               config.plugins.WebBrowser.startPage),
            getConfigListEntry(_("Search Provider"),
                               config.plugins.WebBrowser.searchProvider),
            getConfigListEntry(_("Run fullscreen"),
                               config.plugins.WebBrowser.fullscreen),
            getConfigListEntry(_("Offset in scroll mode (px)"),
                               config.plugins.WebBrowser.scrollOffset),
            getConfigListEntry(_("Target directory for downloads"),
                               config.plugins.WebBrowser.downloadpath),
            getConfigListEntry(_("Enable persistent storage"),
                               config.plugins.WebBrowser.storage.enabled),
        ]
        if config.plugins.WebBrowser.storage.enabled.value:
            list.append(
                getConfigListEntry(_("Path for persistent storage"),
                                   config.plugins.WebBrowser.storage.path))

        self.detailConfigList.setList(list)

    def __cfgExpandableElementChanged(self, element):
        self.__cfgCreateSetup()

    def __cfgSave(self):
        for x in self.detailConfigList.list:
            x[1].save()
        self.__setStatus(_("Settings have been saved successfully!"))

    def __cfgStoragePathChanged(self, element):
        action = [self.ACTION_STORAGE_PATH, True]
        if not action in self.__actions:
            self.__actions.append(action)

    def __cfgCancel(self):
        dlg = self.session.openWithCallback(
            self.__cfgCancelCB,
            MessageBox,
            _("Do you really want to discard all changes?"),
            type=MessageBox.TYPE_YESNO)
        dlg.setTitle(_("Discard changed settings?"))

    def __cfgCancelCB(self, confirmed):
        for x in self.detailConfigList.list:
            x[1].cancel()
        self.__setStatus(_("All changes to the settings have been discarded!"))

    def __cfgKeyText(self):
        from Screens.VirtualKeyBoard import VirtualKeyBoard
        self.session.openWithCallback(
            self.__cfgVirtualKeyBoardCallback,
            VirtualKeyBoard,
            title=self.detailConfigList.getCurrent()[0],
            text=self.detailConfigList.getCurrent()[1].getValue())

    def __cfgVirtualKeyBoardCallback(self, callback=None):
        if callback is not None and len(callback):
            self.detailConfigList.getCurrent()[1].setValue(callback)
            self.detailConfigList.invalidate(
                self.detailConfigList.getCurrent())

    def __cfgKeyOK(self):
        self.detailConfigList.handleKey(KEY_OK)

    def __cfgKeyUp(self):
        self.detailConfigList.instance.moveSelection(eListbox.moveUp)

    def __cfgKeyDown(self):
        self.detailConfigList.instance.moveSelection(eListbox.moveDown)

    def __cfgKeyLeft(self):
        self.detailConfigList.handleKey(KEY_LEFT)

    def __cfgKeyRight(self):
        self.detailConfigList.handleKey(KEY_RIGHT)

    def __cfgKeyHome(self):
        self.detailConfigList.handleKey(KEY_HOME)

    def __cfgKeyEnd(self):
        self.detailConfigList.handleKey(KEY_END)

    def __cfgKeyDelete(self):
        self.detailConfigList.handleKey(KEY_DELETE)

    def __cfgKeyBackspace(self):
        self.detailConfigList.handleKey(KEY_BACKSPACE)

    def __cfgKeyToggleOW(self):
        self.detailConfigList.handleKey(KEY_TOGGLEOW)

    def __cfgKeyAscii(self):
        self.detailConfigList.handleKey(KEY_ASCII)

    def __cfgKeyNumberGlobal(self, number):
        self.detailConfigList.handleKey(KEY_0 + number)

    #Bookmark List Methods
    def __bmOk(self):
        print "[BrowserMenu].__bmOk"
        if self.detailList.index > 0 and self.detailList.getCurrent() != None:
            current = self.detailList.getCurrent()[0]
            print "[BrowserMenu].__bmOk, current = '%s'" % current
            self.__actions.append((self.ACTION_BOOKMARK, current.url))
            self.close(self.__actions)
        else:
            self.__bmAdd(Bookmark(-1, self.currentTitle, self.currentUrl))

    def __bmAdd(self, bookmark=None):
        self.session.openWithCallback(self.__bmEditCB, BookmarkEditor,
                                      bookmark)

    def __bmEdit(self):
        if self.detailList.index > 0 and self.detailList.getCurrent() != None:
            cur = self.detailList.getCurrent()[0]
            self.session.openWithCallback(self.__bmEditCB, BookmarkEditor, cur)

    def __bmEditCB(self, bookmark):
        if bookmark != None:
            self.__db.setBookmark(bookmark)
            self.__bmReload()
            self.__setStatus(
                _("Bookmark '%s' saved succesfully!" % bookmark.name))

    def __bmDelete(self):
        if self.detailList.getCurrent() != None:
            name = self.detailList.getCurrent()[0].name
            print "[BrowserMenu].__bmDelete, name='%s'" % name
            dlg = self.session.openWithCallback(
                self.__bmDeleteCB,
                MessageBox,
                _("Do you really want to delete the bookmark '%s'?") % name,
                type=MessageBox.TYPE_YESNO)
            dlg.setTitle(_("Delete Bookmark?"))

    def __bmDeleteCB(self, confirmed):
        if confirmed:
            self.__db.deleteBookmark(self.detailList.getCurrent()[0])
            name = self.detailList.getCurrent()[0]
            self.__setStatus(_("Bookmark '%s' deleted!" % name))
            self.__bmReload()

    def __bmSetCurrentAsHome(self):
        cur = self.detailList.getCurrent()[0]
        self.__setUrlAsHome(cur.url)

    def __bmGetEntryComponent(self, bookmark):
        return (bookmark, bookmark.name, bookmark.url)

    def __bmBuildList(self):
        print "[BrowserMenu].__bmBuildList"
        list = []
        #Suggest current page for adding

        default = Bookmark(-2, _("Add '%s' to Bookmarks" % self.currentTitle),
                           self.currentUrl)
        list.append(self.__bmGetEntryComponent(default))
        for b in self.__bmList:
            list.append(self.__bmGetEntryComponent(b))
        self.detailList.setList(list)

    def __bmReload(self, needle=""):
        print "[BrowserMenu].__bmReload"
        self.__bmNeedle = needle
        self.__bmList = self.__db.getBookmarks(needle)
        self.__bmBuildList()

    def __bmFilterCB(self):
        print "[BrowserMenu].__bmFilterCB"
        needle = self.detailInput.getText()
        if needle != self.__bmNeedle:
            self.__bmReload(needle)
        else:
            self.__bmFilterTimer.stop()

    def __bmKeyNumberGlobal(self, number):
        self.detailInput.number(number)
        self.__bmFilterTimer.startLongTimer(1)

    def __bmKeyAscii(self):
        self.detailInput.handleAscii(getPrevAsciiCode())
        self.__bmFilterTimer.startLongTimer(1)

    def __bmKeyDelete(self):
        self.detailInput.delete()
        self.__bmFilterTimer.startLongTimer(1)

    def __bmKeyBackspace(self):
        self.detailInput.deleteBackward()
        self.__bmFilterTimer.startLongTimer(1)

    #History list methods
    def __hisSetCurrentAsHome(self):
        if self.detailList.getCurrent() != None:
            cur = self.detailList.getCurrent()[0]
            self.__setUrlAsHome(cur.url)

    def __setUrlAsHome(self, url):
        config.plugins.WebBrowser.home.value = url
        config.plugins.WebBrowser.home.save()
        self.__setStatus(_("Home page has been set to '%s'" % url))

    def __hisClear(self):
        dlg = self.session.openWithCallback(
            self.__hisClearCB,
            MessageBox,
            _("Do you really want to clear the History?"),
            type=MessageBox.TYPE_YESNO)
        dlg.setTitle(_("Clear History?"))

    def __hisClearCB(self, confirmed):
        if confirmed:
            self.__db.clearHistory()
            self.__hisReload()
            self.__setStatus(_("History cleared!"))

    def __hisGetEntryComponent(self, historyItem):
        date = strftime("%Y-%m-%d", localtime(historyItem.timestamp))
        time = strftime("%H:%M:%S", localtime(historyItem.timestamp))
        return (historyItem, date, time, historyItem.title, historyItem.url)

    def __hisReload(self, needle=""):
        print "[BrowserMenu].__hisReload"
        self.__hisNeedle = needle
        self.__hisList = self.__db.getHistory(needle)
        self.__hisBuildList()

    def __hisBuildList(self):
        print "[BrowserMenu].__hisBuildList"
        history = []
        for h in self.__hisList:
            history.append(self.__hisGetEntryComponent(h))
        self.detailList.setList(history)

    def __hisOk(self):
        if self.detailList.getCurrent() != None:
            current = self.detailList.getCurrent()[0]
            self.__actions.append((self.ACTION_BOOKMARK, current.url))
            self.close(self.__actions)

    def __hisFilterCB(self):
        needle = self.detailInput.getText()
        if needle != self.__hisNeedle:
            self.__hisReload(needle)
        else:
            self.__hisFilterTimer.stop()

    def __hisKeyNumberGlobal(self, number):
        self.detailInput.number(number)
        self.__hisFilterTimer.startLongTimer(1)

    def __hisKeyAscii(self):
        self.detailInput.handleAscii(getPrevAsciiCode())
        self.__hisFilterTimer.startLongTimer(1)

    def __hisKeyDelete(self):
        self.detailInput.delete()
        self.__hisFilterTimer.startLongTimer(1)

    def __hisKeyBackspace(self):
        self.detailInput.deleteBackward()
        self.__hisFilterTimer.startLongTimer(1)

    #Download list methods
    def __dlGetEntryComponent(self, job):
        return (job, job.name, job.getStatustext(),
                int(100 * job.progress / float(job.end)),
                str(100 * job.progress / float(job.end)) + "%")

    def __dlBuildList(self):
        print "[BrowserMenu].__dlBuildList"
        downloads = []
        for job in downloadManager.getPendingJobs():
            downloads.append(self.__dlGetEntryComponent(job))
        self.detailList.setList(downloads)
        if not self.__dlRefreshTimer.isActive():
            self.__dlRefreshTimer.startLongTimer(3)

    def __dlAbort(self):
        print "[BrowserMenu].__dlAbort"
        cur = self.detailList.getCurrent()
        if cur != None:
            job = cur[0]
            dlg = self.session.openWithCallback(
                self.__dlAbortCB,
                MessageBox,
                _("Do you really want to abort downloading '%s'?") % job.name,
                type=MessageBox.TYPE_YESNO)
            dlg.setTitle(_("Abort Download?"))

    #Certificate list methods
    def __dlAbortCB(self, confirmed):
        if confirmed:
            self.detailList.getCurrent()[0].remove(downloadManager.jobDone)
            self.__dlBuildList()

    def __crtGetEntryComponent(self, cert):
        cn = "CN: %s" % (str(cert.cert.get_subject().commonName))
        return (cert, str(cert.notBefore()), str(cert.notAfter()),
                str(cert.host), cn, str(cert.cert.digest("sha1")))

    def __crtReload(self):
        print "[BrowserMenu].__crtReload"
        self.__crtList = self.__db.getCerts()
        self.__crtBuildList()

    def __crtBuildList(self):
        print "[BrowserMenu].__crtBuildList"
        certs = []
        for c in self.__crtList:
            certs.append(self.__crtGetEntryComponent(c))
        self.detailList.setList(certs)

    def __crtDelete(self):
        if self.detailList.index >= 0 and self.detailList.getCurrent() != None:
            cert = self.detailList.getCurrent()[0]
            print "[BrowserMenu].__crtDelete, host=%s,SHA1 fingerprint=%s" % (
                cert.host, cert.cert.digest("sha1"))
            text = _(
                "Do you really want to remove the following certificate from the list of trusted certificates?\n\nHostname: %s\nSHA1-Fingerprint: %s"
            ) % (cert.host, cert.cert.digest("sha1"))
            dlg = self.session.openWithCallback(self.__crtDeleteCB,
                                                MessageBox,
                                                text,
                                                type=MessageBox.TYPE_YESNO)
            dlg.setTitle(_("Remove trusted certificate?"))

    def __crtDeleteCB(self, confirmed):
        print "[BrowserMenu].__crtDeleteCB"
        if confirmed:
            cert = self.detailList.getCurrent()[0]
            self.__db.deleteCert(cert)
            self.__crtReload()

    def __crtDetails(self):
        print "[BrowserMenu].__crtDetails"
        if self.detailList.index >= 0 and self.detailList.getCurrent() != None:
            cert = self.detailList.getCurrent()[0]

            text = _("Issued for:")
            for item in cert.cert.get_subject().get_components():
                text += "\n%s : %s" % (item[0], item[1])
            text += _("\n\nIssued from:")
            for item in cert.cert.get_issuer().get_components():
                text += "\n%s : %s" % (item[0], item[1])

            text += _("\n\nValidity:\n")
            text += _("From: %s\n") % cert.notBefore()
            text += _("Until: %s\n") % cert.notAfter()
            text += _("Expired: %s\n") % (_("Yes") if cert.cert.has_expired()
                                          else _("No"))

            dlg = self.session.open(MessageBox,
                                    text,
                                    type=MessageBox.TYPE_INFO)
            dlg.setTitle(_("Certificate Details (%s)") % cert.host)

    def __ckReload(self):
        print "[BrowserMenu].__ckReload"
        self.__ckList = self.__db.getCookies()
        self.__ckBuildList()

    def __ckBuildList(self):
        print "[BrowserMenu].__ckBuildList"
        cookies = []
        for c in self.__ckList:
            cookies.append(self.__ckGetEntryComponent(c))
        self.detailList.setList(cookies)

    def __ckGetEntryComponent(self, cookie):
        try:
            date = strftime("%Y-%m-%d", localtime(cookie.expires))
            time = strftime("%H:%M:%S", localtime(cookie.expires))
        except:
            date = _("never")
            time = _("never")
        return (cookie, date, time, cookie.domain, cookie.path, cookie.raw)

    def __ckDelete(self):
        if self.detailList.index >= 0 and self.detailList.getCurrent() != None:
            cookie = self.detailList.getCurrent()[0]
            text = _(
                "Do you really want to delete the following cookie?\nDomain: %s\nPath: %s\nKey: %s\nRaw-Content:\n%s"
            ) % (cookie.domain, cookie.path, cookie.key, cookie.raw)
            dlg = self.session.openWithCallback(self.__ckDeleteCB,
                                                MessageBox,
                                                text,
                                                type=MessageBox.TYPE_YESNO)
            dlg.setTitle(_("Delete Cookie?"))

    def __ckDeleteCB(self, confirmed):
        print "[BrowserMenu].__ckDeleteCB"
        if confirmed:
            self.__db.deleteCookie(self.detailList.getCurrent()[0])
            self.__ckReload()
            action = [self.ACTION_COOKIES, True]
            if not action in self.__actions:
                self.__actions.append(action)

    def __ckDeleteAll(self):
        if self.detailList.index >= 0 and self.detailList.getCurrent() != None:
            text = _("Do you really want to delete ALL cookies?")
            dlg = self.session.openWithCallback(self.__ckDeleteAllCB,
                                                MessageBox,
                                                text,
                                                type=MessageBox.TYPE_YESNO)
            dlg.setTitle(_("Delete Cookie?"))

    def __ckDeleteAllCB(self, confirmed):
        print "[BrowserMenu].__ckDeleteCB"
        if confirmed:
            self.__db.deleteAllCookies()
            self.__ckReload()
            action = [self.ACTION_COOKIES, True]
            if not action in self.__actions:
                self.__actions.append(action)
Beispiel #42
0
    def __init__(self, session, currentTitle, currentUrl, menulist=None):
        Screen.__init__(self, session)

        self.currentUrl = currentUrl
        self.currentTitle = currentTitle

        #Menu
        if menulist is None:
            self.menu = MenuList([
                (_("Bookmarks"), self.MENU_BOOKMARKS),
                (_("History"), self.MENU_HISTORY),
                (_("Downloads"), self.MENU_DOWNLOADS),
                (_("Certificates"), self.MENU_CERTS),
                (_("Cookies"), self.MENU_COOKIES),
                (_("Settings"), self.MENU_SETTINGS),
            ],
                                 enableWrapAround=True)
        else:
            self.menu = MenuList(menulist, enableWrapAround=True)
        self["menu"] = self.menu

        self["statuslabel"] = Label("")
        self["statuslabel"].hide()

        #Color Buttons
        self["button_red"] = Boolean(False)
        self["button_green"] = Boolean(False)
        self["button_yellow"] = Boolean(False)
        self["button_blue"] = Boolean(False)
        self.red = Label("")
        self.green = Label("")
        self.yellow = Label("")
        self.blue = Label("")
        self["red"] = self.red
        self["green"] = self.green
        self["yellow"] = self.yellow
        self["blue"] = self.blue

        #Lists
        self.detailList = List([], enableWrapAround=True)
        self.detailConfigList = ConfigList([])
        self.detailConfigList.l.setSeperation((BrowserMenu.width - 210) / 2)
        config.plugins.WebBrowser.storage.enabled.addNotifier(
            self.__cfgExpandableElementChanged, initial_call=False)
        config.plugins.WebBrowser.storage.enabled.addNotifier(
            self.__cfgStoragePathChanged, initial_call=False)
        config.plugins.WebBrowser.storage.path.addNotifier(
            self.__cfgStoragePathChanged, initial_call=False)

        self.detailInput = EnhancedInput()

        self["list"] = self.detailList
        self["config"] = self.detailConfigList
        self["input"] = self.detailInput
        self["line"] = CanvasSource()

        self.__cfgCreateSetup()

        self.__db = BrowserDB.getInstance()
        self.__curMenu = self.MENU_BOOKMARKS
        self.__bmList = None
        self.__hisList = None
        self.__crtList = None
        self.__ckList = None
        self.__bmNeedle = ""
        self.__bmFilterTimer = eTimer()
        self.__bmFilterTimer_conn = self.__bmFilterTimer.timeout.connect(
            self.__bmFilterCB)
        self.__hisNeedle = ""
        self.__hisFilterTimer = eTimer()
        self.__hisFilterTimer_conn = self.__hisFilterTimer.timeout.connect(
            self.__hisFilterCB)
        self.__dlRefreshTimer = eTimer()
        self.__dlRefreshTimer_conn = self.__dlRefreshTimer.timeout.connect(
            self.__dlBuildList)
        self.__statusTimer = eTimer()
        self.__statusTimer_conn = self.__statusTimer.timeout.connect(
            self.__hideStatus)
        self.__actions = []

        self.onFirstExecBegin.append(self.__drawSeparator)
        self.onFirstExecBegin.append(self.__onMenuChanged)
        self.onExecBegin.append(self.__reloadData)
        self.onShow.append(self.setKeyboardModeAscii)

        self["actions"] = ActionMap(
            ["BrowserActions", "ColorActions"],
            {
                "ok": self.__actionOk,
                "enter": self.__actionOk,
                "exit": self.__actionExit,
                "pageUp": self.__actionMenuUp,
                "pageDown": self.__actionMenuDown,
                "up": boundFunction(self.__action, "up"),
                "down": boundFunction(self.__action, "down"),
                "left": boundFunction(self.__action, "left"),
                "right": boundFunction(self.__action, "right"),
                "red": boundFunction(self.__action, "red"),
                "green": boundFunction(self.__action, "green"),
                "yellow": boundFunction(self.__action, "yellow"),
                "blue": boundFunction(self.__action, "blue"),
                "backspace": boundFunction(self.__action, "backspace"),
                "delete": boundFunction(self.__action, "delete"),
                "ascii": boundFunction(self.__action, "ascii"),
                # TODO "text" : self.__text
            },
            -2)

        self["numberactions"] = NumberActionMap(
            ["NumberActions"], {
                "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.__actionFuncs = {
            self.MENU_BOOKMARKS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.selectPrevious,
                "right": self.detailList.pageDown,
                "ok": self.__bmOk,
                "enter": self.__bmOk,
                "red": self.__bmDelete,
                "green": self.__bmAdd,
                "yellow": self.__bmEdit,
                "blue": self.__bmSetCurrentAsHome,
                "backspace": self.__bmKeyBackspace,
                "delete": self.__bmKeyDelete,
                "ascii": self.__bmKeyAscii,
            },
            self.MENU_HISTORY: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "ok": self.__hisOk,
                "enter": self.__hisOk,
                "red": self.__hisClear,
                "blue": self.__hisSetCurrentAsHome,
                "backspace": self.__hisKeyBackspace,
                "delete": self.__hisKeyDelete,
                "ascii": self.__hisKeyAscii,
            },
            self.MENU_SETTINGS: {
                "up": self.__cfgKeyUp,
                "down": self.__cfgKeyDown,
                "left": self.__cfgKeyLeft,
                "right": self.__cfgKeyRight,
                "ok": self.__cfgKeyOK,
                "enter": self.__cfgKeyOK,
                "red": self.__cfgCancel,
                "green": self.__cfgSave,
                "backspace": self.__cfgKeyBackspace,
                "delete": self.__cfgKeyDelete,
                "ascii": self.__cfgKeyAscii,
            },
            self.MENU_DOWNLOADS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__dlAbort,
            },
            self.MENU_CERTS: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__crtDelete,
                "green": self.__crtDetails,
            },
            self.MENU_COOKIES: {
                "up": self.detailList.selectPrevious,
                "down": self.detailList.selectNext,
                "left": self.detailList.pageUp,
                "right": self.detailList.pageDown,
                "red": self.__ckDelete,
                "blue": self.__ckDeleteAll,
            }
        }
	def __init__(self, list, enableWrapAround = False):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		tlf = TemplatedListFonts()
		self.l.setFont(0, gFont(tlf.face(tlf.BIG), tlf.size(tlf.BIG)))
		itemHeight = componentSizes.itemHeight(componentSizes.PARENTAL_CONTROL_LIST, 32)
		self.l.setItemHeight(itemHeight)
Beispiel #44
0
	def __init__(self, list, enableWrapAround = True):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		self.l.setFont(0, gFont("Regular", 20))
		self.l.setFont(1, gFont("Regular", 18))
Beispiel #45
0
    def __init__(self, session):
        self.skin = """
              <screen name="Vpn Menu" backgroundColor="#00000000" position="center,center" size="666,420" title="Vpn" flags="wfNoBorder">
              <widget name="countryPng" position="30,5" alphatest="blend" size="50,33" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VpnChanger/icon/default.png" zPosition="2" />
              <widget name="list" position="center,70" size="600,160" backgroundColor="#00000000" scrollbarMode="showOnDemand" zPosition="2" transparent="1" />
              <widget name="vpnLoad" position="center,70" size="600,160" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <widget name="ipLabel" position="80,5" size="600,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <eLabel position="30,253" size="5,33" zPosition="2" backgroundColor="#00ff0000" />
              <eLabel text="Start/Stop OpenVpn" position="40,253" size="333,33" backgroundColor="#00000000" transparent="1" foregroundColor="#00B8B8B8" zPosition="2" font="Regular; 24" valign="top" halign="left" />
              <widget name="vpnStatus" position="303,253" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <widget name="vpnInfo" position="303,293" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <eLabel position="30,293" size="5,33" zPosition="2" backgroundColor="#0000ff00" />
              <widget name="vpnDir" position="40,293" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <eLabel position="30,333" size="5,33" zPosition="2" backgroundColor="#00ebff00" />
              <widget name="check" position="40,333" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <widget name="checkLabel" position="303,333" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              <eLabel position="30,373" size="5,33" zPosition="2" backgroundColor="#003000ff" />
              <widget name="network" position="40,373" size="290,33" backgroundColor="#00000000" foregroundColor="#00B8B8B8" font="Regular; 24" valign="top" halign="left"  zPosition="2" transparent="1" />
              </screen>"""


        Screen.__init__(self, session)

        self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "SetupActions"], {
            "ok": self.keyOK,
            "red": self.keyRed,
            "green": self.keyGreen,
            "yellow": self.keyYellow,
            "blue": self.keyBlue,
            "cancel": self.keyCancel
        }, -1)

        self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
        if DESKTOPSIZE.width() == 1920:
            self.chooseMenuList.l.setFont(0, gFont('Regular', 29))
            self.chooseMenuList.l.setItemHeight(31)
        else:
            self.chooseMenuList.l.setFont(0, gFont('Regular', 19))
            self.chooseMenuList.l.setItemHeight(22)

        self['countryPng'] = Pixmap()
        self["ipLabel"] = Label("")
        self["check"] = Label("Start/Stop Check Vpn")
        self["network"] = Label(_("Restart Network"))
        if config.vpnChanger.vpnCheck.value:
            text = "Vpn Check is Enabled"
        else:
            text = "Vpn Check is Disabled"
        self["checkLabel"] = Label(text)
        self['vpnInfo'] = Label(config.vpnChanger.lastVpn.value)
        self['vpnDir'] = Label(config.vpnChanger.dir.value)
        self['list'] = self.chooseMenuList
        self['vpnLoad'] = Label("OpenVpn is Loading.....")
        if "openvpn" in str(os.listdir("/var/run")):
            text = "OpenVpn is Running"
        else:
            text = "OpenVpn is not Running"
        self['vpnStatus'] = Label(text)

        self['vpnLoad'].hide()
        self.Timer = 0
        self.StatusTimer = eTimer()
        self.StatusTimer.callback.append(self.statusVpn)

        self.onLayoutFinish.append(self.setList)
Beispiel #46
0
	def __init__(self, list, enableWrapAround=False):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		self.l.setFont(0, gFont("Regular", 28))
		self.l.setItemHeight(45)
Beispiel #47
0
	def __init__(self, session, action, value):

		self.imagedir = "/tmp/onDemandImg/"
		self.session = session
		self.action = action
		self.value = value
		self.url = "http://m.channel4.com/4od/tags"
		osdList = []

		osdList.append((_("Search"), "search"))
		if self.action is "start":
			# Read the URL for the selected category on the Main Menu.
			try:
				(data, isUK) = wgetUrl(self.url)

				if data:
					soup = BeautifulSoup(data)
					categoriesSection = soup.find('section', id="categories")
					entries = categoriesSection.find('nav').findAll('a')

					pattern = u'/4od/tags/(.+)'

					for entry in entries:
						"""
						  <section id="categories" class="clearfix">

						    <aside class="catNav clearfix">
							<nav>
							    <h2>Most popular</h2>
							    <ul>

								<li class="active">
								    <span class="chevron"></span>
								    <a href="/4od/tags/comedy">Comedy (100)</a>
								</li>
							    </ul>

							    <h2>More categories</h2>

							    <ul>
								<li>
								    <span class="chevron"></span>
								    <a href="/4od/tags/animals">Animals (4)</a>
								</li>

						"""

						id = entry['href']
						match = re.search(pattern, id, re.DOTALL | re.IGNORECASE)

						categoryName = match.group(1)
						label = unicode(entry.text).replace('\r\n', '')
						label = re.sub(' +', ' ', label)

						osdList.append((_(str(label)), str(categoryName)))

			except (Exception) as exception:
				print __plugin__, __version__,'StreamsMenu: Error parsing feed: ', exception

			osdList.append((_("Back"), "exit"))

		Screen.__init__(self, session)
		self["fourODMainMenu"] = MenuList(osdList)
		self["myActionMap"] = ActionMap(["SetupActions"],
		{
			"ok": self.go,
			"cancel": self.cancel
		}, -1)
Beispiel #48
0
	def __init__(self, list, selection=0, enableWrapAround=False):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		font = skin.fonts.get("ChoiceList", ("Regular", 20, 30))
		self.l.setFont(0, gFont(font[0], font[1]))
		self.l.setItemHeight(font[2])
		self.selection = selection
Beispiel #49
0
    def __init__(self, session, streamplayer, args=0):
        self.skin = LastFMScreenMain.skin
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)
        LastFM.__init__(self)
        self.session = session
        self.streamplayer = streamplayer  #StreamPlayer(session)
        self.streamplayer.onStateChanged.append(
            self.onStreamplayerStateChanged)
        self.imageconverter = ImageConverter(116, 116, self.setCoverArt)
        Screen.__init__(self, session)

        self.tabs = [(_("Personal Stations"), self.loadPersonalStations),
                     (_("Global Tags"), self.loadGlobalTags),
                     (_("Top Tracks"), self.loadTopTracks),
                     (_("Recent Tracks"), self.loadRecentTracks),
                     (_("Loved Tracks"), self.loadLovedTracks),
                     (_("Banned Tracks"), self.loadBannedTracks),
                     (_("Friends"), self.loadFriends),
                     (_("Neighbours"), self.loadNeighbours)]
        tablist = []
        for tab in self.tabs:
            tablist.append((tab[0], tab))
        self.tablist = MenuList(tablist)
        self.tablist.onSelectionChanged.append(self.action_TabChanged)

        self["artist"] = Label(_("Artist") + ":")
        self["duration"] = Label("-00:00")
        self["album"] = Label(_("Album") + ":")
        self["track"] = Label(_("Track") + ":")

        self["info_artist"] = Label("N/A")
        self["info_album"] = Label("N/A")
        self["info_track"] = Label("N/A")
        self["info_cover"] = Pixmap()

        self["tablist"] = self.tablist
        self["streamlist"] = MenuList([])

        self["button_red"] = Label(_("Play"))
        self["button_green"] = Label(_("Skip"))
        self["button_yellow"] = Label(_("Love"))
        self["button_blue"] = Label(_("Ban"))
        self["infolabel"] = Label("")

        self["actions"] = ActionMap(
            [
                "InfobarChannelSelection", "WizardActions", "DirectionActions",
                "MenuActions", "ShortcutActions", "GlobalActions",
                "HelpActions", "NumberActions"
            ], {
                "ok": self.action_ok,
                "back": self.action_exit,
                "red": self.action_startstop,
                "green": self.skipTrack,
                "yellow": self.love,
                "blue": self.banTrack,
                "historyNext": self.action_nextTab,
                "historyBack": self.action_prevTab,
                "menu": self.action_menu,
            }, -1)

        self.helpList.append((self["actions"], "WizardActions",
                              [("ok", _("Switch to selected Station"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("historyNext", _("Select next Tab"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("historyBack", _("Select prev Tab"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("switchChannelDown", _("Next Selection"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("switchChannelUp", _("Previous Selection"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("zapDown", _("Page forward Selections"))]))
        self.helpList.append((self["actions"], "InfobarChannelSelection",
                              [("zapUp", _("Page backward Selections"))]))
        self.helpList.append((self["actions"], "ShortcutActions",
                              [("red", _("Start/stop streaming"))]))
        self.helpList.append(
            (self["actions"], "ShortcutActions", [("green",
                                                   _("Skip current Track"))]))
        self.helpList.append(
            (self["actions"], "ShortcutActions", [("yellow",
                                                   _("Mark Track as loved"))]))
        self.helpList.append((self["actions"], "ShortcutActions",
                              [("blue", _("Ban Track, never play"))]))
        self.helpList.append((self["actions"], "MenuActions",
                              [("menu", _("Open") + " " + _("Setup"))]))
        self.helpList.append((self["actions"], "WizardActions", [
            ("back", _("Quit") + " " + config.plugins.LastFM.name.value)
        ]))

        self.onLayoutFinish.append(self.initLastFM)
        self.onLayoutFinish.append(self.tabchangedtimerFired)
        self.onLayoutFinish.append(self.setCoverArt)

        self.guiupdatetimer = eTimer()
        self.guiupdatetimer_conn = self.guiupdatetimer.timeout.connect(
            self.guiupdatetimerFired)
        self.guiupdatetimer.start(
            config.plugins.LastFM.metadatarefreshinterval.value * 1000)

        self.tabchangetimer = eTimer()
        self.tabchangetimer_conn = self.tabchangetimer.timeout.connect(
            self.tabchangedtimerFired)

        self.infolabelcleartimer = eTimer()
        self.infolabelcleartimer_conn = self.infolabelcleartimer.timeout.connect(
            self.clearInfoLabel)

        self.screensavertimer = eTimer()
        self.screensavertimer_conn = self.screensavertimer.timeout.connect(
            self.startScreensaver)
        self.onShown.append(self.startScreensaverTimer)
    def __init__(self, session, text, type = TYPE_YESNO, timeout = -1, close_on_any_key = False, default = True, enable_input = True, msgBoxID = None, picon = None, simple = False, list = [], timeout_default = None):
        self.type = type
        self.session = session
        if dwidth == 1280:
            skin = '/usr/lib/enigma2/python/Plugins/Extensions/SatVenusPanel/Skin/sboxHD.xml'
        else:
            skin = '/usr/lib/enigma2/python/Plugins/Extensions/SatVenusPanel/Skin/sboxFHD.xml'
        f = open(skin, 'r')
        self.skin = f.read()
        f.close()
        Screen.__init__(self, session)
        self.msgBoxID = msgBoxID
        self['text'] = Label(text)
        self['Text'] = StaticText(text)
        self['selectedChoice'] = StaticText()
        self.text = text
        self.close_on_any_key = close_on_any_key
        self.timeout_default = timeout_default
        self['ErrorPixmap'] = Pixmap()
        self['QuestionPixmap'] = Pixmap()
        self['InfoPixmap'] = Pixmap()
        self['WarningPixmap'] = Pixmap()
        self.timerRunning = False
        self.initTimeout(timeout)
        picon = picon or type
        if picon != self.TYPE_ERROR:
            self['ErrorPixmap'].hide()
        if picon != self.TYPE_YESNO:
            self['QuestionPixmap'].hide()
        if picon != self.TYPE_INFO:
            self['InfoPixmap'].hide()
#        if picon != self.TYPE_WARNING:
#            self['WarningPixmap'].hide()
        self.title = self.type < self.TYPE_MESSAGE and [_('Question'),
         _('Information'),
         _('Warning'),
         _('Error')][self.type] or _('Message')
        if type == self.TYPE_YESNO:
            if list:
                self.list = list
            elif default == True:
                self.list = [(_('Yes'), True), (_('No'), False)]
            else:
                self.list = [(_('No'), False), (_('Yes'), True)]
        else:
            self.list = []
        self['list'] = MenuList(self.list)
        if self.list:
            self['selectedChoice'].setText(self.list[0][0])
        else:
            self['list'].hide()
        if enable_input:
            self['actions'] = ActionMap(['MsgBoxActions', 'DirectionActions'], {'cancel': self.cancel,
             'ok': self.ok,
             'alwaysOK': self.alwaysOK,
             'up': self.up,
             'down': self.down,
             'left': self.left,
             'right': self.right,
             'upRepeated': self.up,
             'downRepeated': self.down,
             'leftRepeated': self.left,
             'rightRepeated': self.right}, -1)
        self.onLayoutFinish.append(self.layoutFinished)
Beispiel #51
0
	def __init__(self, session, text="", filename="", currDir=None, bookmarks=None, userMode=False, windowTitle=None, minFree=None, autoAdd=False, editDir=False, inhibitDirs=None, inhibitMounts=None, useAliases=False):
		# Init parents
		if not inhibitDirs: inhibitDirs = []
		if not inhibitMounts: inhibitMounts = []
		Screen.__init__(self, session)
		NumericalTextInput.__init__(self, handleTimeout=False)
		HelpableScreen.__init__(self)

		# Set useable chars
		self.setUseableChars(u'1234567890abcdefghijklmnopqrstuvwxyz')

		# Quickselect Timer
		self.qs_timer = eTimer()
		self.qs_timer.callback.append(self.timeout)
		self.qs_timer_type = 0

		# Initialize Quickselect
		self.curr_pos = -1
		self.quickselect = ""

		# Set Text
		self["text"] = Label(text)
		self["textbook"] = Label(_("Bookmarks"))

		# Save parameters locally
		self.text = text
		self.filename = filename
		self.minFree = minFree
		self.realBookmarks = bookmarks
		self.bookmarks = bookmarks and bookmarks.getValue()[:] or []
		self.userMode = userMode
		self.autoAdd = autoAdd
		self.editDir = editDir
		self.inhibitDirs = inhibitDirs
		self.useAliases = useAliases
		self.usingAliases = self.useAliases and config.misc.location_aliases.value

		# Initialize FileList
		self["filelist"] = FileList(currDir, showDirectories=True, showFiles=False, inhibitMounts=inhibitMounts, inhibitDirs=inhibitDirs)

		# Initialize BookList
		if self.usingAliases:
			self.bookmarks = [self.getAlias(bm) for bm in self.bookmarks]
		self["booklist"] = MenuList(self.bookmarks)

		# Buttons
		self["key_green"] = Button(_("OK"))
		self["key_yellow"] = Button(_("Rename"))
		self["key_blue"] = Button()
		self["key_red"] = Button(_("Cancel"))

		# Background for Buttons
		self["green"] = Pixmap()
		self["yellow"] = Pixmap()
		self["blue"] = Pixmap()
		self["red"] = Pixmap()

		# Initialize Target
		self["target"] = Label()

		if self.userMode:
			self.usermodeOn()

		# Custom Action Handler
		class LocationBoxActionMap(HelpableActionMap):
			def __init__(self, parent, context, actions=None, prio=0):
				if not actions: actions = {}
				HelpableActionMap.__init__(self, parent, context, actions, prio)
				self.box = parent

			def action(self, contexts, action):
				# Reset Quickselect
				self.box.timeout(force=True)

				return HelpableActionMap.action(self, contexts, action)

		# Actions that will reset quickselect
		self["WizardActions"] = LocationBoxActionMap(self, "WizardActions",
			{
				"ok": (self.ok, _("Select")),
				"back": (self.cancel, _("Cancel")),
			}, prio=-2)

		self["DirectionActions"] = LocationBoxActionMap(self, "DirectionActions",
			{
				"left": self.left,
				"right": self.right,
				"up": self.up,
				"down": self.down,
			}, prio=-2)

		self["ColorActions"] = LocationBoxActionMap(self, "ColorActions",
			{
				"red": self.cancel,
				"green": self.select,
				"yellow": self.changeName,
				"blue": self.addRemoveBookmark,
			}, prio=-2)

		self["EPGSelectActions"] = LocationBoxActionMap(self, "EPGSelectActions",
			{
				"prevService": (self.switchToBookList, _("Switch to bookmarks")),
				"nextService": (self.switchToFileList, _("Switch to directories")),
			}, prio=-2)

		self["MenuActions"] = LocationBoxActionMap(self, "MenuActions",
			{
				"menu": (self.showMenu, _("Menu")),
			}, prio=-2)

		# Actions used by quickselect
		self["NumberActions"] = NumberActionMap(["NumberActions"],
		{
			"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
		})

		# Run some functions when shown
		if windowTitle is None:
			windowTitle = _("Select Location")
		self.onShown.extend((
			boundFunction(self.setTitle, windowTitle),
			self.updateTarget,
			self.showHideRename,
		))

		self.onLayoutFinish.append(self.switchToFileListOnStart)

		# Make sure we remove our callback
		self.onClose.append(self.disableTimer)
Beispiel #52
0
	def __init__(self, list, selection = 0, enableWrapAround=True):
		MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
		self.l.setFont(0, gFont("Regular", 20))
		self.l.setItemHeight(60)
		self.selection = selection
Beispiel #53
0
	def __init__(self, list=None, enableWrapAround=False):
		MenuList.__init__(self, list or [], enableWrapAround, content=eListboxPythonMultiContent)
		font = skin.fonts.get("ImsSelectionList", ("Regular", 20, 30))
		self.l.setFont(0, gFont(font[0], font[1]))
		self.l.setItemHeight(font[2])
Beispiel #54
0
	def __init__(self, session, text, type=TYPE_YESNO, timeout=-1, close_on_any_key=False, default=True, enable_input=True, msgBoxID=None, picon=True, simple=False, wizard=False, list=None, skin_name=None):
		if not list: list = []
		if not skin_name: skin_name = []
		self.type = type
		Screen.__init__(self, session)
		self.skinName = ["MessageBox"]
		if wizard:
			from Components.config import config, ConfigInteger
			from Components.Pixmap import MultiPixmap
			self["rc"] = MultiPixmap()
			self["rc"].setPixmapNum(config.misc.rcused.value)		
			self.skinName = ["MessageBoxWizard"]

		if simple:
			self.skinName = ["MessageBoxSimple"]

		if isinstance(skin_name, str):
			self.skinName = [skin_name] + self.skinName

		self.msgBoxID = msgBoxID

		self["text"] = Label(_(text))
		self["Text"] = StaticText(_(text))
		self["selectedChoice"] = StaticText()

		self.text = _(text)
		self.close_on_any_key = close_on_any_key

		self["ErrorPixmap"] = Pixmap()
		self["ErrorPixmap"].hide()
		self["QuestionPixmap"] = Pixmap()
		self["QuestionPixmap"].hide()
		self["InfoPixmap"] = Pixmap()
		self["InfoPixmap"].hide()

		self.timerRunning = False
		self.initTimeout(timeout)

		if picon:
			picon = type
			if picon == self.TYPE_ERROR:
				self["ErrorPixmap"].show()
			elif picon == self.TYPE_YESNO:
				self["QuestionPixmap"].show()
			elif picon == self.TYPE_INFO:
				self["InfoPixmap"].show()

		self.messtype = type
		if type == self.TYPE_YESNO:
			if list:
				self.list = list
			elif default:
				self.list = [ (_("yes"), True), (_("no"), False) ]
			else:
				self.list = [ (_("no"), False), (_("yes"), True) ]
		else:
			self.list = []
		
		self["list"] = MenuList(self.list)
		if self.list:
			self["selectedChoice"].setText(self.list[0][0])
		else:
			self["list"].hide()

		if enable_input:
			self["actions"] = ActionMap(["MsgBoxActions", "DirectionActions"],
				{
					"cancel": self.cancel,
					"ok": self.ok,
					"alwaysOK": self.alwaysOK,
					"up": self.up,
					"down": self.down,
					"left": self.left,
					"right": self.right,
					"upRepeated": self.up,
					"downRepeated": self.down,
					"leftRepeated": self.left,
					"rightRepeated": self.right
				}, -1)
Beispiel #55
0
    def __init__(self, session, items, service=None):
        Screen.__init__(self, session)
        self.skinName = SkinTools.appendResolution(
            "AdvancedMovieSelectionDownload")
        self.onShow.append(self.selectionChanged)
        self.service = service
        self["logo"] = Pixmap()
        self["info"] = Label()
        self["title"] = Label()
        self["poster"] = Pixmap()
        self["poster"].hide()
        self["description"] = ScrollLabel()
        self["key_red"] = Button(_("Cancel"))
        self["key_green"] = Button("")
        self["key_yellow"] = Button("")
        self["key_yellow"] = Label(_("Manual search"))
        if self.service is not None:
            self["key_green"] = Label(_("Save infos/cover"))
        else:
            self["key_green"] = Label(_("Background"))
            self["key_yellow"].hide()

        self["ActionsMap"] = ActionMap(
            ["SetupActions", "ColorActions"], {
                "ok": self.titleSelected,
                "green": self.titleSelected,
                "red": self.__cancel,
                "yellow": self.editTitle,
                "cancel": self.__cancel,
                "left": self.scrollLabelPageUp,
                "right": self.scrollLabelPageDown
            }, -1)
        self.onShown.append(self.setWindowTitle)

        self.l = []
        self["list"] = MenuList(self.l)
        self["list"].onSelectionChanged.append(self.selectionChanged)

        self.picload = ePicLoad()
        self.picload.PictureData.get().append(self.paintPosterPixmap)
        self.refreshTimer = eTimer()
        self.refreshTimer.callback.append(self.refresh)

        self.tmdb3 = tmdb.init_tmdb3()

        if self.service is not None:
            global movie_title
            movie_title = ServiceCenter.getInstance().info(
                self.service).getName(
                    self.service).encode("utf-8").split(" - ")[0].strip()
            self.refreshTimer.start(1, True)
            return

        global fetchingMovies, this_session, is_hidden
        if fetchingMovies is None:
            fetchingMovies = FetchingMovies(items)
        else:
            fetchingMovies.cancel = False
        self.progressTimer = eTimer()
        self.progressTimer.callback.append(self.updateProgress)
        self.progressTimer.start(250, False)
        this_session = session
        is_hidden = False
Beispiel #56
0
 def __init__(self, list):
     MenuList.__init__(self, list, False, eListboxPythonMultiContent)
     self.l.setItemHeight(60)
     self.l.setFont(0, gFont('SetrixHD', 30))
     self.l.setFont(1, gFont('Regular', 22))
Beispiel #57
0
	def __init__(self, session, text, type=TYPE_YESNO, timeout=-1, close_on_any_key=False, default=True, enable_input=True, msgBoxID=None, picon=None, simple=False, list=[], timeout_default=None, title=None):
		self.type = type
		Screen.__init__(self, session)
		self.setScreenPathMode(None)
		if simple:
			self.skinName="MessageBoxSimple"

		self.msgBoxID = msgBoxID

		self["autoresize"] = Label("") #do not remove, used for autoResize()
		self["text"] = Label(text)
		self["Text"] = StaticText(text)
		self["selectedChoice"] = StaticText()

		self.text = text
		self.close_on_any_key = close_on_any_key
		self.timeout_default = timeout_default

		self["ErrorPixmap"] = Pixmap()
		self["QuestionPixmap"] = Pixmap()
		self["InfoPixmap"] = Pixmap()
		self["WarningPixmap"] = Pixmap()
		self.timerRunning = False
		self.initTimeout(timeout)

		picon = picon or type
		if picon != self.TYPE_ERROR:
			self["ErrorPixmap"].hide()
		if picon != self.TYPE_YESNO:
			self["QuestionPixmap"].hide()
		if picon != self.TYPE_INFO:
			self["InfoPixmap"].hide()
		if picon != self.TYPE_WARNING:
			self["WarningPixmap"].hide()
		self.title = title or self.type < self.TYPE_MESSAGE and [_("Question"), _("Information"), _("Warning"), _("Error")][self.type] or _("Message")
		if type == self.TYPE_YESNO:
			if list:
				self.list = list
			elif default:
				self.list = [ (_("yes"), True), (_("no"), False) ]
			else:
				self.list = [ (_("no"), False), (_("yes"), True) ]
		else:
			self.list = []

		self["list"] = MenuList(self.list)
		if self.list:
			self["selectedChoice"].setText(self.list[0][0])
		else:
			self["list"].hide()

		if enable_input:
			self["actions"] = ActionMap(["MsgBoxActions", "DirectionActions"],
				{
					"cancel": self.cancel,
					"ok": self.ok,
					"alwaysOK": self.alwaysOK,
					"up": self.up,
					"down": self.down,
					"left": self.left,
					"right": self.right,
					"upRepeated": self.up,
					"downRepeated": self.down,
					"leftRepeated": self.left,
					"rightRepeated": self.right
				}, -1)
		self.setTitle(self.title)
Beispiel #58
0
    def __init__(self, session, type=0, iface='eth0'):
        Screen.__init__(self, session)
        self.session = session
        self.type = type  # update type
        self.iface = iface

        self.drawProgressBarTimer = eTimer()
        self.drawProgressBarTimer.callback.append(self.drawProgressBar)

        self.checkEnvTimer = eTimer()
        self.checkEnvTimer.callback.append(self.checkEnv)

        self.progressSpin = ["%  /", "%  |", "%  -"]
        if self.iface == 'wlan0' or self.iface == 'ath0' or self.iface == 'ra0':
            lan = "Wireless"
        else:
            lan = "Integrated Ethernet"
        modelDir = open("/proc/stb/info/modelname").read().strip('\n')
        self.imageInfo = {
            self.INTERNET_UPDATE: {
                "title": "SW Update - " + lan,
                "imagedir": "K3_OE3/" + modelDir + "_REL"
            },
            self.INTERNET_SR_UPDATE: {
                "title": "SR SW Update - " + lan,
                "imagedir": "K3_OE3/" + modelDir + "SR_REL"
            },
            self.INTERNET_UPDATE_BETA: {
                "title": "SW Update (BETA) - " + lan,
                "imagedir": "K3_OE3/" + modelDir
            },
            self.INTERNET_SR_UPDATE_BETA: {
                "title": "SR SW Update (BETA) - " + lan,
                "imagedir": "K3_OE3/" + modelDir + "SR"
            }
        }
        self.setTitle(self.imageInfo[self.type]["title"])

        self.swList = []
        self["menulist"] = MenuList(self.swList)
        self["menulist"].hide()
        self["percent"] = Label(_(" "))
        self["run"] = Label(_(" "))
        self["prog"] = Label(_(" "))
        self["top"] = Label(_(" "))
        self["bottom"] = Label(_(" "))
        self["text"] = Label(_("Downloading list information. Please wait..."))

        self["actions"] = ActionMap(
            ["MinuteInputActions", "ColorActions"], {
                "cancel": self.cancel,
                "ok": self.ok,
                "up": self.up,
                "down": self.down,
            }, -1)

        self.requiredSize = -1
        self.serverAlive = False
        self.downloadingSW = False
        self.downloadedSW = {}

        def progressBar(configElement):
            num = int(configElement.value)
            if num > 0:
                self["run"].setText(_(self.progressSpin[num % 3]))
                self["prog"].setText("[" + "=" * (40 * num / 100) + "]")
                self["percent"].setText(_("%d" % num))
            else:
                self["run"].setText(_(" "))
                self["prog"].setText(_(" "))
                self["percent"].setText(_(" "))

        def progressAction(configElement):
            num = int(configElement.value)
            if num == -1:
                self.drawProgressBarTimer.stop()
                MiniFTP_Thread.getInstance().Stop_Thread()
                self.downloadingSW = False
                self.downloadedSW = {}
            elif num < 100:
                self.drawProgressBarTimer.start(1000, True)
            elif num == 100:
                self.drawProgressBarTimer.stop()
                MiniFTP_Thread.getInstance().Stop_Thread()
                self.downloadingSW = False

                if self.downloadedSWSizeOk():
                    #					self.downloadBurn()
                    self.session.openWithCallback(
                        self.downloadBurn, MessageBox,
                        _("Downloading Finished!!\nDo you really want to update \nthe file \"%s\"?"
                          ) % self["menulist"].getCurrent())
                else:
                    self.session.open(
                        MessageBox,
                        _("Failed while checking downloaded SW!\nTry again please."
                          ), MessageBox.TYPE_ERROR)
                    self.downloadCancel(True)

        config.progress = NoSave(ConfigSelectionNumber(-1, 100, 1, default=-1))
        config.progress.addNotifier(progressBar, False)
        config.progress.addNotifier(progressAction, False)

        self.checkEnvTimer.start(1000, True)
Beispiel #59
0
 def postWidgetCreate(self, instance):
     MenuList.postWidgetCreate(self, instance)
     instance.setItemHeight(50)
	def __init__(self, session, text, type = TYPE_YESNO, timeout = -1, close_on_any_key = False, default = True, enable_input = True, msgBoxID = None, picon = None, simple = False, list = []):
		self.type = type
		Screen.__init__(self, session)

		if simple:
			self.skinName="MessageBoxSimple"
		
		self.msgBoxID = msgBoxID

		self["text"] = Label(text)
		self["Text"] = StaticText(text)
		self["selectedChoice"] = StaticText()

		self.text = text
		self.close_on_any_key = close_on_any_key

		self["ErrorPixmap"] = Pixmap()
		self["QuestionPixmap"] = Pixmap()
		self["InfoPixmap"] = Pixmap()
		self.timerRunning = False
		self.initTimeout(timeout)

		picon = picon or type
		if picon != self.TYPE_ERROR:
			self["ErrorPixmap"].hide()
		if picon != self.TYPE_YESNO:
			self["QuestionPixmap"].hide()
		if picon != self.TYPE_INFO:
			self["InfoPixmap"].hide()

		if type == self.TYPE_YESNO:
			if list:
				self.list = list
			elif default == True:
				self.list = [ (_("yes"), True), (_("no"), False) ]
			else:
				self.list = [ (_("no"), False), (_("yes"), True) ]
		else:
			self.list = []
		
		self["list"] = MenuList(self.list)
		if self.list:
			self["selectedChoice"].setText(self.list[0][0])
		else:
			self["list"].hide()

		if enable_input:
			self["actions"] = ActionMap(["MsgBoxActions", "DirectionActions"], 
				{
					"cancel": self.cancel,
					"ok": self.ok,
					"alwaysOK": self.alwaysOK,
					"up": self.up,
					"down": self.down,
					"left": self.left,
					"right": self.right,
					"upRepeated": self.up,
					"downRepeated": self.down,
					"leftRepeated": self.left,
					"rightRepeated": self.right
				}, -1)

		self.onLayoutFinish.append(self.layoutFinished)