Exemplo n.º 1
0
	def layoutFinishedCB(self):
		if not os.access(ENABLE_QPIP_PROCPATH, os.F_OK):
			self.notSupportTimer.start(100, True)
			return

		self.onClose.append(self.__onClose)

		if self.session.pipshown: # try to disable pip
			self.session.pipshown = False
			del self.session.pip

		self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()
		self.session.nav.stopService()

		if SystemInfo.get("FastChannelChange", False):
			self.disableFCC()

		if SystemInfo.get("MiniTV", False):
			self.disableMiniTV()

		ret = setDecoderMode("mosaic")
		if ret is not True:
			self.forceToExitTimer.start(0, True)
			return

		self.moveLabel()

		if self.qpipChannelList.length() == 0:
			self.noChannelTimer.start(10, True)
		else:
			self.playLastChannel()
Exemplo n.º 2
0
	def addItems(self, parentNode):
		for x in parentNode:
			if not x.tag:
				continue
			if x.tag == 'item':
				item_level = int(x.get("level", 0))

				if item_level > config.usage.setup_level.index:
					continue

				requires = x.get("requires")
				if requires:
					if requires[0] == '!':
						if SystemInfo.get(requires[1:], False):
							continue
					elif not SystemInfo.get(requires, False):
						continue
				configCondition = x.get("configcondition")
				if configCondition and not eval(configCondition + ".value"):
					continue

				item_text = _(x.get("text", "??").encode("UTF-8"))
				item_description = _(x.get("description", " ").encode("UTF-8"))
				b = eval(x.text or "");
				if b == "":
					continue
				#add to configlist
				item = b
				# the first b is the item itself, ignored by the configList.
				# the second one is converted to string.
				if not isinstance(item, ConfigNothing):
					self.list.append((item_text, item, item_description))
Exemplo n.º 3
0
 def addMenu(self, destList, node):
     requires = node.get('requires')
     if requires:
         if requires[0] == '!':
             if SystemInfo.get(requires[1:], False):
                 return
         elif not SystemInfo.get(requires, False):
             return
     MenuTitle = _(node.get('text', '??').encode('UTF-8'))
     entryID = node.get('entryID', 'undefined')
     weight = node.get('weight', 50)
     description = node.get('description', '').encode('UTF-8') or None
     description = description and _(description)
     menupng = MenuEntryPixmap(entryID, self.png_cache, lastMenuID)
     x = node.get('flushConfigOnClose')
     if x:
         a = boundFunction(self.session.openWithCallback, self.menuClosedWithConfigFlush, Menu, node)
     else:
         a = boundFunction(self.session.openWithCallback, self.menuClosed, Menu, node)
     destList.append((MenuTitle,
      a,
      entryID,
      weight,
      description,
      menupng))
Exemplo n.º 4
0
    def searchMenu(self, parent, name):
        menuID = None
        ret = None
        for x in parent:
            if x.tag == "item":
                requires = x.get("requires")
                if requires:
                    if requires[0] == "!":
                        if SystemInfo.get(requires[1:], False):
                            continue
                    elif not SystemInfo.get(requires, False):
                        continue

                item_text = x.get("text", "").encode("UTF-8")
                entryID = x.get("entryID", "")

                if entryID == name:
                    for z in x:
                        if z.tag == "screen":
                            module = z.get("module")
                            screen = z.get("screen")

                            if screen is None:
                                screen = module

                            print module, screen
                            if module[:7] == "SIFTeam":
                                pass  # we don't need any change to module
                            elif module:
                                module = "Screens." + module
                            else:
                                module = ""

                                # check for arguments. they will be appended to the
                                # openDialog call
                            args = z.text or ""
                            screen += ", " + args

                            ret = boundFunction(self.runScreen, (module, screen))
                        elif z.tag == "code":
                            ret = boundFunction(self.execText, z.text)
                        elif z.tag == "setup":
                            id = z.get("id")
                            ret = boundFunction(self.openSetup, id)

            elif x.tag == "menu":
                if ret is None:
                    ret = self.searchMenu(x, name)

            elif x.tag == "id":
                menuID = x.get("val")

        if menuID is not None:
            for l in plugins.getPluginsForMenu(menuID):
                if l[2] == name:
                    ret = boundFunction(l[1], self.session)

        return ret
Exemplo n.º 5
0
    def addItem(self, destList, node):
        requires = node.get('requires')
        if requires:
            if requires[0] == '!':
                if SystemInfo.get(requires[1:], False):
                    return
            elif not SystemInfo.get(requires, False):
                return
        configCondition = node.get('configcondition')
        if configCondition and not eval(configCondition + '.value'):
            return
        item_text = node.get('text', '').encode('UTF-8')
        entryID = node.get('entryID', 'undefined')
        weight = node.get('weight', 50)
        for x in node:
            if x.tag == 'screen':
                module = x.get('module')
                screen = x.get('screen')
                if screen is None:
                    screen = module
                if module:
                    module = 'Screens.' + module
                else:
                    module = ''
                args = x.text or ''
                screen += ', ' + args
                destList.append((_(item_text or '??'),
                 boundFunction(self.runScreen, (module, screen)),
                 entryID,
                 weight))
                return
            if x.tag == 'code':
                destList.append((_(item_text or '??'),
                 boundFunction(self.execText, x.text),
                 entryID,
                 weight))
                return
            if x.tag == 'setup':
                id = x.get('id')
                if item_text == '':
                    item_text = _(getSetupTitle(id))
                else:
                    item_text = _(item_text)
                destList.append((item_text,
                 boundFunction(self.openSetup, id),
                 entryID,
                 weight))
                return

        destList.append((item_text,
         self.nothing,
         entryID,
         weight))
Exemplo n.º 6
0
	def __onClose(self):
		self.disableQuadPip()
		setDecoderMode("normal")

		if SystemInfo.get("FastChannelChange", False):
			self.enableFCC()

		if SystemInfo.get("MiniTV", False):
			self.enableMiniTV()

		self.qpipChannelList.saveAll()
		self.session.nav.playService(self.oldService)
Exemplo n.º 7
0
	def createSetupList(self):
		currentItem = self["config"].getCurrent()
		self.list = []
		for x in self.setup:
			if not x.tag:
				continue
			if x.tag == 'item':
				item_level = int(x.get("level", 0))

				if item_level > config.usage.setup_level.index:
					continue

				requires = x.get("requires")
				if requires and not requires.startswith('config.'):
					if requires.startswith('!'):
						if SystemInfo.get(requires[1:], False):
							continue
					elif not SystemInfo.get(requires, False):
						continue
				conditional = x.get("conditional")
				if conditional and not eval(conditional):
					continue

				# this block is just for backwards compatibility
				if requires and requires.startswith('config.'):
					item = eval(requires)
					if not (item.value and not item.value == "0"):
						continue

				if self.PluginLanguageDomain:
					item_text = dgettext(self.PluginLanguageDomain, x.get("text", "??").encode("UTF-8"))
					item_description = dgettext(self.PluginLanguageDomain, x.get("description", " ").encode("UTF-8"))
				else:
					item_text = _(x.get("text", "??").encode("UTF-8"))
					item_description = _(x.get("description", " ").encode("UTF-8"))

				item_text = item_text.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
				item_description = item_description.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
				b = eval(x.text or "")
				if b == "":
					continue
				#add to configlist
				item = b
				# the first b is the item itself, ignored by the configList.
				# the second one is converted to string.
				if not isinstance(item, ConfigNothing):
					self.list.append((item_text, item, item_description))
		self["config"].setList(self.list)
		if config.usage.sort_settings.value:
			self["config"].list.sort()
		self.moveToItem(currentItem)
Exemplo n.º 8
0
    def addItem(self, destList, node):
        requires = node.get('requires')
        if requires:
            if requires.startswith('config.'):
                if configfile.getResolvedKey(requires) == 'False':
                    return
            elif requires[0] == '!':
                if SystemInfo.get(requires[1:], False):
                    return
            elif not SystemInfo.get(requires, False):
                return
        item_text = node.get('text', '').encode('UTF-8')
        entryID = node.get('entryID', 'undefined')
        weight = node.get('weight', 50)
        end_text = node.get('endtext', '>').encode('UTF-8')
        for x in node:
            if x.tag == 'screen':
                module = x.get('module')
                screen = x.get('screen')
                if screen is None:
                    screen = module
                print module, screen
                if module:
                    if module.find('.') == -1:
                        module = 'Screens.' + module
                    else:
                        try:
                            exec 'from ' + module + ' import *'
                        except:
                            module = None

                else:
                    module = ''
                args = x.text or ''
                screen += ', ' + args
                if module is not None:
                    destList.append((_(item_text or '??'), boundFunction(self.runScreen, (module, screen)), entryID, weight, end_text))
                return
            if x.tag == 'code':
                destList.append((_(item_text or '??'), boundFunction(self.execText, x.text), entryID, weight, end_text))
                return
            if x.tag == 'setup':
                id = x.get('id')
                if item_text == '':
                    item_text = getSetupTitle(id)
                destList.append((_(item_text), boundFunction(self.openSetup, id), entryID, weight, end_text))
                return

        destList.append((_(item_text), self.nothing, entryID, weight, end_text))
Exemplo n.º 9
0
	def addItem(self, destList, node):
		requires = node.get("requires")
		if requires:
			if requires[0] == '!':
				if SystemInfo.get(requires[1:], False):
					return
			elif not SystemInfo.get(requires, False):
				return
		conditional = node.get("conditional")
		if conditional and not eval(conditional):
			return
		item_text = node.get("text", "").encode("UTF-8")
		entryID = node.get("entryID", "undefined")
		weight = node.get("weight", 50)
		for x in node:
			if x.tag == 'screen':
				module = x.get("module")
				screen = x.get("screen")

				if screen is None:
					screen = module

				# print module, screen
				if module:
					module = "Screens." + module
				else:
					module = ""

				# check for arguments. they will be appended to the
				# openDialog call
				args = x.text or ""
				screen += ", " + args

				destList.append((_(item_text or "??"), boundFunction(self.runScreen, (module, screen)), entryID, weight))
				return
			elif x.tag == 'code':
				destList.append((_(item_text or "??"), boundFunction(self.execText, x.text), entryID, weight))
				return
			elif x.tag == 'setup':
				id = x.get("id")
				if item_text == "":
					if getSetupTitleLevel(id) > config.usage.setup_level.index:
						return
					item_text = _(getSetupTitle(id))
				else:
					item_text = _(item_text)
				destList.append((item_text, boundFunction(self.openSetup, id), entryID, weight))
				return
		destList.append((item_text, self.nothing, entryID, weight))
Exemplo n.º 10
0
 def addItems(self, list, parentNode):
     for x in parentNode:
         if not x.tag:
             continue
         if x.tag == 'item':
             item_level = int(x.get('level', 0))
             if self.levelChanged not in config.usage.setup_level.notifiers:
                 config.usage.setup_level.notifiers.append(self.levelChanged)
                 self.onClose.append(self.removeNotifier)
             if item_level > config.usage.setup_level.index:
                 continue
             requires = x.get('requires')
             if requires and requires.startswith('config.'):
                 item = eval(requires or '')
                 if item.value and not item.value == '0':
                     SystemInfo[requires] = True
                 else:
                     SystemInfo[requires] = False
             if requires and not SystemInfo.get(requires, False):
                 continue
             item_text = _(x.get('text', '??').encode('UTF-8'))
             item_description = _(x.get('description', ' ').encode('UTF-8'))
             b = eval(x.text or '')
             if b == '':
                 continue
             item = b
             if not isinstance(item, ConfigNothing):
                 list.append((item_text, item, item_description))
Exemplo n.º 11
0
def getConfigs(key):
	configs = []
	title = ""
	
	setupfile = file(eEnv.resolve('${datadir}/enigma2/setup.xml'), 'r')
	setupdom = xml.etree.cElementTree.parse(setupfile)
	setupfile.close()
	xmldata = setupdom.getroot()
	for section in xmldata.findall("setup"):
		if section.get("key") != key:
			continue
			
		for entry in section:
			if entry.tag == "item":
				requires = entry.get("requires")
				if requires and not SystemInfo.get(requires, False):
					continue;
				
				if int(entry.get("level", 0)) > config.usage.setup_level.index:
					continue
				
				try:
					configs.append({
						"description": entry.get("text", ""),
						"path": entry.text or "",
						"data": getJsonFromConfig(eval(entry.text or ""))
					})		
				except Exception, e:
					pass
				
		title = section.get("title", "")
		break
	def _getConfig(self):
		# Name, configElement, HelpTxt, reloadConfig
		self.list = [] 
		self.list.append(getConfigListEntry(_("Refresh EPG automatically"), config.plugins.epgrefresh.enabled, _("Unless this is enabled, EPGRefresh won't automatically run but needs to be explicitly started by the yellow button in this menu."), True))
		if config.plugins.epgrefresh.enabled.value:
			self.list.append(getConfigListEntry(_("Duration to stay on service (seconds)"), config.plugins.epgrefresh.interval_seconds, _("This is the duration each service/channel will stay active during a refresh."), False))
			self.list.append(getConfigListEntry(_("EPG refresh auto-start earliest (hh:mm)"), config.plugins.epgrefresh.begin, _("An automated refresh will start after this time of day, but before the time specified in next setting."), False))
			self.list.append(getConfigListEntry(_("EPG refresh auto-start latest (hh:mm)"), config.plugins.epgrefresh.end, _("An automated refresh will start before this time of day, but after the time specified in previous setting."), False))
			self.list.append(getConfigListEntry(_("Delay if not in standby (minutes)"), config.plugins.epgrefresh.delay_standby, _("If the receiver currently isn't in standby, this is the duration which EPGRefresh will wait before retry."), False))
			if SystemInfo.get("NumVideoDecoders", 1) > 1:
				self.list.append(getConfigListEntry(_("Refresh EPG using"), config.plugins.epgrefresh.adapter, _("If you want to refresh the EPG in background, you can choose the method which best suits your needs here, e.g. hidden, fake reocrding or regular Picture in Picture."), False))
			self.list.append(getConfigListEntry(_("Show Advanced Options"), NoSave(config.plugins.epgrefresh.showadvancedoptions), _("Display more Options"), True))
			if config.plugins.epgrefresh.showadvancedoptions.value:
				if config.ParentalControl.servicepinactive.value:
					self.list.append(getConfigListEntry(_("Skip protected Services"), config.plugins.epgrefresh.skipProtectedServices, _("Should protected services be skipped if refresh was started in interactive-mode?"), False))
				self.list.append(getConfigListEntry(_("Show Setup in extension menu"), config.plugins.epgrefresh.show_in_extensionsmenu, _("Enable this to be able to access the EPGRefresh configuration from within the extension menu."), False))
				self.list.append(getConfigListEntry(_("Show 'EPGRefresh Start now' in extension menu"), config.plugins.epgrefresh.show_run_in_extensionsmenu, _("Enable this to be able to start the EPGRefresh from within the extension menu."), False))
				self.list.append(getConfigListEntry(_("Show popup when refresh starts and ends"), config.plugins.epgrefresh.enablemessage, _("This setting controls whether or not an informational message will be shown at start and completion of refresh."), False))
				self.list.append(getConfigListEntry(_("Wake up from standby for EPG refresh"), config.plugins.epgrefresh.wakeup, _("If this is enabled, the plugin will wake up the receiver from standby if possible. Otherwise it needs to be switched on already."), False))
				self.list.append(getConfigListEntry(_("Force scan even if receiver is in use"), config.plugins.epgrefresh.force, _("This setting controls whether or not the refresh will be initiated even though the receiver is active (either not in standby or currently recording)."), False))
				self.list.append(getConfigListEntry(_("Shutdown after EPG refresh"), config.plugins.epgrefresh.afterevent, _("This setting controls whether the receiver should be set to standby after refresh is completed."), False))
				try:
					# try to import autotimer module to check for its existence
					from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
		
					self.list.append(getConfigListEntry(_("Inherit Services from AutoTimer"), config.plugins.epgrefresh.inherit_autotimer, _("Extend the list of services to refresh by those your AutoTimers use?"), True))
					self.list.append(getConfigListEntry(_("Run AutoTimer after refresh"), config.plugins.epgrefresh.parse_autotimer, _("After a successful refresh the AutoTimer will automatically search for new matches if this is enabled. The options 'Ask*' has only affect on a manually refresh. If EPG-Refresh was called in background the default-Answer will be executed!"), False))
				except ImportError as ie:
					print("[EPGRefresh] AutoTimer Plugin not installed:", ie)
			
		self["config"].list = self.list
		self["config"].setList(self.list)
Exemplo n.º 13
0
	def addItems(self, list, parentNode):
		for x in parentNode:
			if x.tag == 'item':
				item_level = int(x.get("level", 0))

				if not self.levelChanged in config.usage.setup_level.notifiers:
					config.usage.setup_level.addNotifier(self.levelChanged, initial_call = False)
					self.onClose.append(self.removeNotifier)

				if item_level > config.usage.setup_level.index:
					continue

				requires = x.get("requires")
				if requires and not SystemInfo.get(requires, False):
					continue;

				item_text = _(x.get("text", "??").encode("UTF-8"))
				b = eval(x.text or "");
				if b == "":
					continue
				#add to configlist
				item = b
				# the first b is the item itself, ignored by the configList.
				# the second one is converted to string.
				if not isinstance(item, ConfigNothing):
					list.append( (item_text, item) )
Exemplo n.º 14
0
	def __init__(self):
		Renderer.__init__(self)
		global fbtool
		fbtool=KravenFBHelper()
		self.Position=self.Size=None
		self.decoder=0
		if SystemInfo.get("NumVideoDecoders",1)>1:
			self.decoder=1
		self.fb_w=getDesktop(0).size().width()
		self.fb_h=getDesktop(0).size().height()
		self.fb_size=None
		self._del_pip=False
		self._can_extended_PiG=False
		self.first_PiG=False
		self.is_channelselection=False

		self.x2=103
		self.y2=523
		self.w2=544
		self.h2=306
		self.x2=format(int(float(self.x2)/self.fb_w*720.0),'x').zfill(8)
		self.y2=format(int(float(self.y2)/self.fb_h*576.0),'x').zfill(8)
		self.w2=format(int(float(self.w2)/self.fb_w*720.0),'x').zfill(8)
		self.h2=format(int(float(self.h2)/self.fb_h*576.0),'x').zfill(8)
		self.fb_size2=[self.w2,self.h2,self.x2,self.y2]
Exemplo n.º 15
0
	def __init__(self):
		Renderer.__init__(self)

		global KravenFBTool
		KravenFBTool = KravenFBHelper()
		
		self.Position = self.Size = None
		
		self.timer = eTimer()
		self.timer.callback.append(self.showpip)

		self.pipCreated = False
		self.pipRemoved = False
		self.Initialized = False

		self.PigStyle = config.plugins.KravenFHD.PigStyle.value
		if SystemInfo.get("NumVideoDecoders", 1) > 1 and not self.PigStyle == "Preview":
			self.decoder = 1
		else:
			self.decoder = 0

		self.fb_w = getDesktop(0).size().width()
		self.fb_h = getDesktop(0).size().height()
		self.fb_size = None

		self.x2 = 103
		self.y2 = 530
		self.w2 = 544
		self.h2 = 306
		self.x2 = format(int(float(self.x2) / self.fb_w * 720.0), 'x').zfill(8)
		self.y2 = format(int(float(self.y2) / self.fb_h * 576.0), 'x').zfill(8)
		self.w2 = format(int(float(self.w2) / self.fb_w * 720.0), 'x').zfill(8)
		self.h2 = format(int(float(self.h2) / self.fb_h * 576.0), 'x').zfill(8)
		self.fb_size2 = [self.w2, self.h2, self.x2, self.y2]
Exemplo n.º 16
0
Arquivo: Menu.py Projeto: popazerty/12
	def addItem(self, destList, node):
		requires = node.get("requires")
		if requires:
			if requires[0] == '!':
				if SystemInfo.get(requires[1:], False):
					return
			elif not SystemInfo.get(requires, False):
				return
		item_text = node.get("text", "").encode("UTF-8")
		entryID = node.get("entryID", "undefined")
		weight = node.get("weight", 50)
		description = node.get("description", "").encode("UTF-8") or None
		description = description and _(description)
		menupng = MenuEntryPixmap(entryID, self.png_cache, lastMenuID)
		for x in node:
			if x.tag == 'screen':
				module = x.get("module")
				screen = x.get("screen")

				if screen is None:
					screen = module

				print module, screen
				if module:
					module = "Screens." + module
				else:
					module = ""

				# check for arguments. they will be appended to the
				# openDialog call
				args = x.text or ""
				screen += ", " + args

				destList.append((_(item_text or "??"), boundFunction(self.runScreen, (module, screen)), entryID, weight, description, menupng))
				return
			elif x.tag == 'code':
				destList.append((_(item_text or "??"), boundFunction(self.execText, x.text), entryID, weight, description, menupng))
				return
			elif x.tag == 'setup':
				id = x.get("id")
				if item_text == "":
					item_text = _(getSetupTitle(id))
				else:
					item_text = _(item_text)
				destList.append((item_text, boundFunction(self.openSetup, id), entryID, weight, description, menupng))
				return
		destList.append((item_text, self.nothing, entryID, weight, description, menupng))
Exemplo n.º 17
0
	def createScreen(self):
		self.list = [ ]
		self.audio_cfg = [ ]

		for x in self.avSetupItems:
			item_level = int(x.get("level", 0))
			if item_level > config.usage.setup_level.index:
				continue

			requires = x.get("requires")
			if requires and not SystemInfo.get(requires, False):
				continue

			item_text = _(x.get("text", "??").encode("UTF-8"))

			item_str = x.get("item", None)
			if item_str is None:
				continue
			item = eval(item_str)

			idx = x.get("idx", 0)
			if idx > 0:
				if idx == 1: # Video Output
					current_port = item.value
				elif idx == 2: # Mode
					item = config.av.videomode[current_port]
					current_mode = item.value
					# some modes (720p, 1080i, 1080p) are always widescreen.
					force_wide = self.video_cfg.isWidescreenMode(current_mode)
				elif idx == 3: # Refresh Rate
					item = config.av.videorate[current_mode]
					current_rate = item.value
					if current_mode == "PC":
						item_text = _("Resolution")
				elif idx == 4: # Aspect Ratio
					current_aspect = item.value
					if force_wide:
						continue
				elif idx == 5: # Display 4:3 content as
					if current_aspect == "auto" and not force_wide:
						continue
					elif current_aspect == "4_3":
						continue
				elif idx == 6: # Display 16:9 > content as
					if current_aspect == "auto" and not force_wide:
						continue
				# Color Format, WSS on 4:3, Auto scart switching
				elif (idx == 7 or idx == 8 or idx == 9) and not current_port == "Scart":
					continue
				elif (idx == 10) and not current_port == "DVI": # HDMI Colorspace
					continue
			if idx == 0 and item_level == 1: # audio
				self.audio_cfg.append(item_text)

			# add to configlist
			if not isinstance(item, ConfigNothing):
				self.list.append(getConfigListEntry(item_text, item))

		self["config"].setList(self.list)
Exemplo n.º 18
0
def InfoBarPiP__init__(self):
    baseMethods.InfoBarPiP__init__(self)
    if SystemInfo.get("NumVideoDecoders", 1) > 1 and self.allowPiP:
        self.addExtension((self.getTogglePipzapName, self.togglePipzap, self.pipzapAvailable), "red")
        if config.plugins.pipzap.enable_hotkey.value:
            self["pipzapActions"] = HelpableActionMap(
                self, "pipzapActions", {"switchPiP": (self.togglePipzap, _("zap in pip window..."))}
            )
Exemplo n.º 19
0
	def __init__(self, session):
		if SystemInfo.get("NumVideoDecoders", 1) < 2:
			self.backgroundRefreshAvailable = False
			return

		self.backgroundRefreshAvailable = True
		self.__service = None
		self.navcore = session.nav
Exemplo n.º 20
0
	def __init__(self, session, hide=True):
		if SystemInfo.get("NumVideoDecoders", 1) < 2:
			self.pipAvail = False
			return

		self.hide = hide
		self.session = session
		self.pipAvail = True
Exemplo n.º 21
0
	def addMenu(self, destList, node):
		requires = node.get("requires")
		if requires:
			if requires[0] == '!':
				if SystemInfo.get(requires[1:], False):
					return
			elif not SystemInfo.get(requires, False):
				return
		MenuTitle = _(node.get("text", "??").encode("UTF-8"))
		entryID = node.get("entryID", "undefined")
		weight = node.get("weight", 50)
		x = node.get("flushConfigOnClose")
		if x:
			a = boundFunction(self.session.openWithCallback, self.menuClosedWithConfigFlush, Menu, node)
		else:
			a = boundFunction(self.session.openWithCallback, self.menuClosed, Menu, node)
		#TODO add check if !empty(node.childNodes)
		destList.append((MenuTitle, a, entryID, weight))
Exemplo n.º 22
0
	def addItems(self, list, parentNode):
		for x in parentNode:
			if not x.tag:
				continue
			if x.tag == 'item':
				item_level = int(x.get("level", 0))
				item_tunerlevel = int(x.get("tunerlevel", 0))
				item_rectunerlevel = int(x.get("rectunerlevel", 0))
				item_tuxtxtlevel = int(x.get("tt_level", 0))

				if not self.onNotifiers:
					self.onNotifiers.append(self.levelChanged)
					self.onClose.append(self.removeNotifier)

				if item_level > config.usage.setup_level.index:
					continue
				if (item_tuxtxtlevel == 1) and (config.usage.tuxtxt_font_and_res.value != "expert_mode"):
					continue
				if item_tunerlevel == 1 and not config.usage.frontend_priority.value in ("expert_mode", "experimental_mode"):
					continue
				if item_tunerlevel == 2 and not config.usage.frontend_priority.value == "experimental_mode":
					continue
				if item_rectunerlevel == 1 and not config.usage.recording_frontend_priority.value in ("expert_mode", "experimental_mode"):
					continue
				if item_rectunerlevel == 2 and not config.usage.recording_frontend_priority.value == "experimental_mode":
					continue

				requires = x.get("requires")
				if requires and requires.startswith('config.'):
					item = eval(requires or "")
					if item.value and not item.value == "0":
						SystemInfo[requires] = True
					else:
						SystemInfo[requires] = False

				if requires and not SystemInfo.get(requires, False):
					continue

				if self.PluginLanguageDomain:
					item_text = dgettext(self.PluginLanguageDomain, x.get("text", "??").encode("UTF-8"))
					item_description = dgettext(self.PluginLanguageDomain, x.get("description", " ").encode("UTF-8"))
				else:
					item_text = _(x.get("text", "??").encode("UTF-8"))
					item_description = _(x.get("description", " ").encode("UTF-8"))

				item_text = item_text.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
				item_description = item_description.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
				b = eval(x.text or "")
				if b == "":
					continue
				#add to configlist
				item = b
				# the first b is the item itself, ignored by the configList.
				# the second one is converted to string.
				if not isinstance(item, ConfigNothing):
					list.append((item_text, item, item_description))
Exemplo n.º 23
0
	def __init__(self, session):
		Screen.__init__(self, session)
		self["CurrentService"] = CurrentService(session.nav)
		self["CurrentTime"] = Clock()
		self["Event_Now"] = EventInfo(session.nav, EventInfo.NOW)
		self["Event_Next"] = EventInfo(session.nav, EventInfo.NEXT)
		self["FrontendStatus"] = FrontendStatus(service_source = session.nav.getCurrentService)
		self["FrontendInfo"] = FrontendInfo(navcore = session.nav)
		self["VideoPicture"] = Source()
		self["TunerInfo"] = TunerInfo()
		self["RecordState"] = RecordState(session)
		self["Standby"] = Boolean(fixed = False)
		
		from Components.SystemInfo import SystemInfo
		
		combine = Combine(func = lambda s: {(False, False): 0, (False, True): 1, (True, False): 2, (True, True): 3}[(s[0].boolean, s[1].boolean)])
		combine.connect(self["Standby"])
		combine.connect(self["RecordState"])

		#                      |  two leds  | single led |
		# recordstate  standby   red green   
		#    false      false    off   on     off
		#    true       false    blnk  on     blnk
		#    false      true      on   off    off
		#    true       true     blnk  off    blnk
		
		PATTERN_ON     = (20, 0xffffffff, 0xffffffff)
		PATTERN_OFF    = (20, 0, 0)
		PATTERN_BLINK  = (20, 0x55555555, 0xa7fccf7a)

		have_display = SystemInfo.get("FrontpanelDisplay", False)
		have_touch_sensor = SystemInfo.get("HaveTouchSensor", False)
		nr_leds = SystemInfo.get("NumFrontpanelLEDs", 0)

		if nr_leds == 1:
			FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_OFF if have_display else PATTERN_ON, PATTERN_BLINK, PATTERN_OFF, PATTERN_BLINK]).connect(combine)
		elif nr_leds == 2:
			if have_touch_sensor:
				FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_ON, PATTERN_BLINK, PATTERN_OFF, PATTERN_BLINK]).connect(combine)
				FrontpanelLed(which = 1, boolean = False, patterns = [PATTERN_OFF, PATTERN_OFF, PATTERN_OFF, PATTERN_OFF]).connect(combine)
			else:
				FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_OFF, PATTERN_BLINK, PATTERN_ON, PATTERN_BLINK]).connect(combine)
				FrontpanelLed(which = 1, boolean = False, patterns = [PATTERN_ON, PATTERN_ON, PATTERN_OFF, PATTERN_OFF]).connect(combine)
Exemplo n.º 24
0
	def __init__(self):
		Renderer.__init__(self)
		self.Position = self.Size = None
		self.pipavailable = (SystemInfo.get("NumVideoDecoders", 1) > 1)
		self.timer = eTimer()	        
		try:
			self.timer_connection = self.timer.timeout.connect(self.activatePiP)
		except AttributeError:
			self.timer.callback.append(self.activatePiP)
		self.currentPiPService = None
		self.currentPiPServicePath = None
Exemplo n.º 25
0
 def addMenu(self, destList, node):
     requires = node.get('requires')
     if requires:
         if requires[0] == '!':
             if SystemInfo.get(requires[1:], False):
                 return
         elif not SystemInfo.get(requires, False):
             return
     MenuTitle = _(node.get('text', '??').encode('UTF-8'))
     entryID = node.get('entryID', 'undefined')
     weight = node.get('weight', 50)
     x = node.get('flushConfigOnClose')
     if x:
         a = boundFunction(self.session.openWithCallback, self.menuClosedWithConfigFlush, Menu, node)
     else:
         a = boundFunction(self.session.openWithCallback, self.menuClosed, Menu, node)
     destList.append((MenuTitle,
      a,
      entryID,
      weight))
Exemplo n.º 26
0
def newSessionGlobals__init__(self, session):
	baseSessionGlobals__init__(self, session)
	global SessionGlobals_instance
	SessionGlobals_instance = self
	from Components.Sources.CurrentService import CurrentService
	from Components.Sources.EventInfo import EventInfo
	from Components.Sources.FrontendStatus import FrontendStatus
	from Components.Sources.FrontendInfo import FrontendInfo
	from Components.Sources.Source import Source
	from Components.Sources.TunerInfo import TunerInfo
	from Components.Sources.Boolean import Boolean
	from Components.Sources.RecordState import RecordState
	from Components.Converter.Combine import Combine
	from Components.Renderer.FrontpanelLed import FrontpanelLed
	self["CurrentService"] = CurrentService(session.nav)
	self["Event_Now"] = EventInfo(session.nav, EventInfo.NOW)
	self["Event_Next"] = EventInfo(session.nav, EventInfo.NEXT)
	self["FrontendStatus"] = FrontendStatus(service_source = session.nav.getCurrentService)
	self["FrontendInfo"] = FrontendInfo(navcore = session.nav)
	self["VideoPicture"] = Source()
	self["TunerInfo"] = TunerInfo()
	self["RecordState"] = RecordState(session)
	self["Standby"] = Boolean(fixed = False)

	from Components.SystemInfo import SystemInfo

	combine = Combine(func = lambda s: {(False, False): 0, (False, True): 1, (True, False): 2, (True, True): 3}[(s[0].boolean, s[1].boolean)])
	combine.connect(self["Standby"])
	combine.connect(self["RecordState"])

	#                      |  two leds  | single led |
	# recordstate  standby   red green
	#    false      false    off   on     off
	#    true       false    blnk  on     blnk
	#    false      true      on   off    off
	#    true       true     blnk  off    blnk

	PATTERN_ON     = (20, 0xffffffff, 0xffffffff)
	PATTERN_OFF    = (20, 0, 0)
	PATTERN_BLINK  = (20, 0x55555555, 0xa7fccf7a)

	nr_leds = SystemInfo.get("NumFrontpanelLEDs", 0)

	if nr_leds == 1:
		FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_OFF, PATTERN_BLINK, PATTERN_OFF, PATTERN_BLINK]).connect(combine)
	elif nr_leds == 2:
		if config.plugins.VFD_spark.redLed.value == '1':
			FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_OFF, PATTERN_BLINK, PATTERN_ON, PATTERN_BLINK]).connect(combine)
		if config.plugins.VFD_spark.greenLed.value == '1':
			FrontpanelLed(which = 1, boolean = False, patterns = [PATTERN_OFF, PATTERN_OFF, PATTERN_ON, PATTERN_OFF]).connect(combine)
		else:
			FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_OFF, PATTERN_OFF, PATTERN_OFF, PATTERN_OFF]).connect(combine)
			FrontpanelLed(which = 1, boolean = False, patterns = [PATTERN_OFF, PATTERN_OFF, PATTERN_OFF, PATTERN_OFF]).connect(combine)
Exemplo n.º 27
0
Arquivo: Menu.py Projeto: popazerty/12
	def addMenu(self, destList, node):
		requires = node.get("requires")
		if requires:
			if requires[0] == '!':
				if SystemInfo.get(requires[1:], False):
					return
			elif not SystemInfo.get(requires, False):
				return
		MenuTitle = _(node.get("text", "??").encode("UTF-8"))
		entryID = node.get("entryID", "undefined")
		weight = node.get("weight", 50)
		description = node.get("description", "").encode("UTF-8") or None
		description = description and _(description)
		menupng = MenuEntryPixmap(entryID, self.png_cache, lastMenuID)
		x = node.get("flushConfigOnClose")
		if x:
			a = boundFunction(self.session.openWithCallback, self.menuClosedWithConfigFlush, Menu, node)
		else:
			a = boundFunction(self.session.openWithCallback, self.menuClosed, Menu, node)
		#TODO add check if !empty(node.childNodes)
		destList.append((MenuTitle, a, entryID, weight, description, menupng))
Exemplo n.º 28
0
	def __init__(self):
		Renderer.__init__(self)
		self.Position = self.Size = None
		self.decoder = 0
		if SystemInfo.get("NumVideoDecoders", 1) > 1:
			self.decoder = 1
		self.fb_w = getDesktop(0).size().width()
		self.fb_h = getDesktop(0).size().height()
		self.fb_size = None
		self._del_pip = False
		self._can_extended_PiG = False
		self.first_PiG = False
		self.is_channelselection = False
Exemplo n.º 29
0
	def parseConfigFiles(self):
		sections = []
		for setupfile in self.setupfiles:
			# print "[OpenWebif] loading configuration file :", setupfile
			setupfile = file(setupfile, 'r')
			setupdom = xml.etree.cElementTree.parse(setupfile)  # nosec
			setupfile.close()
			xmldata = setupdom.getroot()
			for section in xmldata.findall("setup"):
				configs = []
				requires = section.get("requires")
				if requires and not SystemInfo.get(requires, False):
					continue
				key = section.get("key")
				if key not in self.allowedsections:
					showOpenWebIF = section.get("showOpenWebIF")
					if showOpenWebIF == "1":
						self.allowedsections.append(key)
					else:
						continue
				# print "[OpenWebif] loading configuration section :", key
				for entry in section:
					if entry.tag == "item":
						requires = entry.get("requires")
						if requires and not SystemInfo.get(requires, False):
							continue

						if int(entry.get("level", 0)) > config.usage.setup_level.index:
							continue
						configs.append(entry)
				if len(configs):
					sections.append({
						"key": key,
						"description": _(section.get("title"))
					})
					title = _(section.get("title", ""))
					self.section_config[key] = (title, configs)
		sections = sorted(sections, key=lambda k: k['description'])
		self.sections = sections
Exemplo n.º 30
0
	def createSetupList(self):
		currentItem = self["config"].getCurrent()
		self.list = []
		for x in self.setup:
			if not x.tag:
				continue
			if x.tag == 'item':
				item_level = int(x.get("level", 0))

				if item_level > config.usage.setup_level.index:
					continue

				requires = x.get("requires")
				if requires:
					if requires.startswith('!'):
						if SystemInfo.get(requires[1:], False):
							continue
					elif not SystemInfo.get(requires, False):
						continue
				conditional = x.get("conditional")
				if conditional and not eval(conditional):
					continue

				item_text = _(x.get("text", "??").encode("UTF-8"))
				item_description = _(x.get("description", " ").encode("UTF-8"))
				b = eval(x.text or "");
				if b == "":
					continue
				#add to configlist
				item = b
				# the first b is the item itself, ignored by the configList.
				# the second one is converted to string.
				if not isinstance(item, ConfigNothing):
					self.list.append((item_text, item, item_description))
		self["config"].setList(self.list)
		if config.usage.sort_settings.value:
			self["config"].list.sort()
		self.moveToItem(currentItem)
Exemplo n.º 31
0
    def __init__(self, session):
        if SystemInfo.get("NumVideoDecoders", 1) < 2:
            self.pipAvail = False
            return

        self.session = session
        self.pipAvail = True
        if session.pipshown:
            # Hijack PiP
            self.wasShown = True
            self.previousService = self.session.pip.getCurrentService()
            self.previousPath = self.session.pip.servicePath
        else:
            self.wasShown = False
            self.initPiP()
Exemplo n.º 32
0
    def addItems(self, list, parentNode):
        for x in parentNode:
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get("level", 0))

                if not self.onNotifiers:
                    self.onNotifiers.append(self.levelChanged)
                    self.onClose.append(self.removeNotifier)

                if item_level > config.usage.setup_level.index:
                    continue

                requires = x.get("requires")
                if requires:
                    if requires[0] == '!':
                        if SystemInfo.get(requires[1:], False):
                            continue
                    elif not SystemInfo.get(requires, False):
                        continue
                conditional = x.get("conditional")
                if conditional and not eval(conditional):
                    continue

                item_text = _(x.get("text", "??").encode("UTF-8"))
                item_description = _(x.get("description", " ").encode("UTF-8"))
                b = eval(x.text or "")
                if b == "":
                    continue
                #add to configlist
                item = b
                # the first b is the item itself, ignored by the configList.
                # the second one is converted to string.
                if not isinstance(item, ConfigNothing):
                    list.append((item_text, item, item_description))
Exemplo n.º 33
0
    def addItems(self, list, parentNode):
        for x in parentNode:
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get("level", 0))
                item_rectunerlevel = int(x.get("rectunerlevel", 0))

                if not self.levelChanged in config.usage.setup_level.notifiers:
                    config.usage.setup_level.notifiers.append(
                        self.levelChanged)
                    self.onClose.append(self.removeNotifier)
                if not self.levelChanged in config.usage.recording_frontend_priority.notifiers:
                    config.usage.recording_frontend_priority.notifiers.append(
                        self.levelChanged)
                    self.onClose.append(
                        self.removeNotifierRecordFrontendPriority)

                if item_level > config.usage.setup_level.index:
                    continue
                if item_rectunerlevel == 1 and not config.usage.recording_frontend_priority.value in (
                        "expert_mode", "experimental_mode"):
                    continue
                if item_rectunerlevel == 2 and not config.usage.recording_frontend_priority.value == "experimental_mode":
                    continue

                requires = x.get("requires")
                if requires and requires.startswith('config.'):
                    item = eval(requires or "")
                    if item.value and not item.value == "0":
                        SystemInfo[requires] = True
                    else:
                        SystemInfo[requires] = False

                if requires and not SystemInfo.get(requires, False):
                    continue

                item_text = _(x.get("text", "??").encode("UTF-8"))
                item_description = _(x.get("description", " ").encode("UTF-8"))
                b = eval(x.text or "")
                if b == "":
                    continue
                #add to configlist
                item = b
                # the first b is the item itself, ignored by the configList.
                # the second one is converted to string.
                if not isinstance(item, ConfigNothing):
                    list.append((item_text, item, item_description))
Exemplo n.º 34
0
    def addItem(self, destList, node):
        requires = node.get("requires")
        if requires and not SystemInfo.get(requires, False):
            return
        item_text = node.get("text", "").encode("UTF-8")
        entryID = node.get("entryID", "undefined")
        weight = node.get("weight", 50)
        for x in node:
            if x.tag == 'screen':
                module = x.get("module")
                screen = x.get("screen")

                if screen is None:
                    screen = module

                print module, screen
                if module:
                    module = "Screens." + module
                else:
                    module = ""

                # check for arguments. they will be appended to the
                # openDialog call
                args = x.text or ""
                screen += ", " + args

                destList.append(
                    (_(item_text or "??"),
                     boundFunction(self.runScreen,
                                   (module, screen)), entryID, weight))
                return
            elif x.tag == 'code':
                destList.append(
                    (_(item_text
                       or "??"), boundFunction(self.execText,
                                               x.text), entryID, weight))
                return
            elif x.tag == 'setup':
                id = x.get("id")
                if item_text == "":
                    item_text = _(getSetupTitle(id)) + "..."
                else:
                    item_text = _(item_text)
                destList.append(
                    (item_text, boundFunction(self.openSetup,
                                              id), entryID, weight))
                return
        destList.append((item_text, self.nothing, entryID, weight))
Exemplo n.º 35
0
 def addMenu(self, destList, node):
     requires = node.get("requires")
     if requires and not SystemInfo.get(requires, False):
         return
     MenuTitle = _(node.get("text", "??").encode("UTF-8"))
     entryID = node.get("entryID", "undefined")
     weight = node.get("weight", 50)
     x = node.get("flushConfigOnClose")
     if x:
         a = boundFunction(self.session.openWithCallback,
                           self.menuClosedWithConfigFlush, Menu, node)
     else:
         a = boundFunction(self.session.openWithCallback, self.menuClosed,
                           Menu, node)
     #TODO add check if !empty(node.childNodes)
     destList.append((MenuTitle, a, entryID, weight))
Exemplo n.º 36
0
    def __init__(self):
        Renderer.__init__(self)

        global SevenFBTool
        SevenFBTool = SevenFBHelper()

        self.Position = self.Size = None

        self.timer = eTimer()
        self.timer.callback.append(self.showpip)

        self.pipCreated = False
        self.pipRemoved = False
        self.Initialized = False

        self.PigStyle = config.plugins.SevenHD.PigStyle.value
        if SystemInfo.get("NumVideoDecoders",
                          1) > 1 and not self.PigStyle == "Preview":
            self.decoder = 1
        else:
            self.decoder = 0

        self.fb_w = getDesktop(0).size().width()
        self.fb_h = getDesktop(0).size().height()
        self.fb_size = None

        # self.x2=92
        # self.y2=313
        # self.w2=400
        # self.h2=220
        # self.x2=format(int(float(self.x2)/self.fb_w*720.0),'x').zfill(8)
        # self.y2=format(int(float(self.y2)/self.fb_h*576.0),'x').zfill(8)
        # self.w2=format(int(float(self.w2)/self.fb_w*720.0),'x').zfill(8)
        # self.h2=format(int(float(self.h2)/self.fb_h*576.0),'x').zfill(8)

        self.x2 = 51
        self.y2 = 249
        self.w2 = 228
        self.h2 = 178

        self.x2 = format(int(self.x2), 'x').zfill(8)
        self.y2 = format(int(self.y2), 'x').zfill(8)
        self.w2 = format(int(self.w2), 'x').zfill(8)
        self.h2 = format(int(self.h2), 'x').zfill(8)

        self.fb_size2 = [self.w2, self.h2, self.x2, self.y2]
Exemplo n.º 37
0
	def __init__(self, session):
		Screen.__init__(self, session)
		self["key_red"] = StaticText(_("Cancel"))
		self["key_green"] = StaticText(_("OK"))
		self.list = []
		self.list.append(getConfigListEntry(_("Usage"), config.plugins.virtualzap.mode))
		if SystemInfo.get("NumVideoDecoders", 1) > 1:
			self.list.append(getConfigListEntry(_("Use PiP"), config.plugins.virtualzap.usepip))
			self.list.append(getConfigListEntry(_("Show PiP in Infobar"), config.plugins.virtualzap.showpipininfobar))
			self.list.append(getConfigListEntry(_("Start standard PiP after x secs (0 = disabled)"), config.plugins.virtualzap.exittimer))
		self.list.append(getConfigListEntry(_("Remember last service"), config.plugins.virtualzap.saveLastService))
		ConfigListScreen.__init__(self, self.list, session)
		self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
		{
			"green": self.keySave,
			"cancel": self.keyClose,
		}, -2)
Exemplo n.º 38
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.session = session

        self.skin = CustomButtonActionMenu.skin
        self.list = []
        self["actionlist"] = MenuList(self.list)

        activecustom = ""

        try:
            fp = open('/var/custombutton.dat', 'r')
            activecustom = fp.readline()
            print("ACTIVE CUSTOM:", str(activecustom))
            fp.close()
        except:
            pass

        xmldata = keycustomxml.childNodes[0]
        entries = xmldata.childNodes
        idx = -1
        self.idxactive = -1
        for x in entries:  #walk through the actual nodelist
            if (x.nodeType == Node.ELEMENT_NODE and x.tagName == 'item'):

                if ((len(str(x.getAttribute("requires"))) > 0)
                        and (not SystemInfo.get(
                            str(x.getAttribute("requires")), False))):
                    pass
                else:
                    idx = idx + 1
                    print("FOUND NODE ELEMENT:", x.getAttribute("name"))
                    self.list.append(str(x.getAttribute("name")))
                    if len(activecustom) > 0:
                        if activecustom == str(x.getAttribute("name")):
                            self.idxactive = idx

        self["actionlist"].l.setList(self.list)

        self["actions"] = ActionMap(["DirectionActions", "OkCancelActions"], {
            "ok": self.ok,
            "cancel": self.exit,
        }, -1)

        self.onShown.append(self.selectActive)
Exemplo n.º 39
0
	def includeElement(self, element):
		itemLevel = int(element.get("level", 0))
		if itemLevel > config.usage.setup_level.index:  # The item is higher than the current setup level.
			return False
		requires = element.get("requires")
		if requires:
			negate = requires.startswith("!")
			if negate:
				requires = requires[1:]
			if requires.startswith("config."):
				item = eval(requires)
				result = bool(item.value and item.value not in ("0", "False", "false"))
			else:
				result = bool(SystemInfo.get(requires, False))
			if requires and negate == result:  # The item requirements are not met.
				return False
		conditional = element.get("conditional")
		return not conditional or eval(conditional)
Exemplo n.º 40
0
    def doActivate(self, w):
        if w.state == RecordTimerEntry.StateWaiting:
            from Components.SystemInfo import SystemInfo
            if SystemInfo.get("DisableUsbRecord",
                              True) and w.isUsbRecordingPath():
                service_name = w.service_ref.getServiceName()
                self.timer_list.remove(w)
                if w.dontSave is False:
                    w.resetState()
                    w.disable()
                    self.addTimerEntry(w)
                Notifications.AddNotification(
                    MessageBox,
                    _("Can not recording on a USB storage.\nService name : %s"
                      % service_name), MessageBox.TYPE_ERROR)
                return

        # when activating a timer which has already passed,
        # simply abort the timer. don't run trough all the stages.
        if w.shouldSkip():
            w.state = RecordTimerEntry.StateEnded
        else:
            # when active returns true, this means "accepted".
            # otherwise, the current state is kept.
            # the timer entry itself will fix up the delay then.
            if w.activate():
                w.state += 1

        self.timer_list.remove(w)

        # did this timer reached the last state?
        if w.state < RecordTimerEntry.StateEnded:
            # no, sort it into active list
            insort(self.timer_list, w)
        else:
            # yes. Process repeated, and re-add.
            if w.repeated:
                w.processRepeated()
                w.state = RecordTimerEntry.StateWaiting
                self.addTimerEntry(w)
            else:
                insort(self.processed_timers, w)

        self.stateChanged(w)
Exemplo n.º 41
0
	def includeElement(self, element):
		itemLevel = int(element.get("level", 0))
		if itemLevel > config.usage.setup_level.index:  # The item is higher than the current setup level.
			return False
		requires = element.get("requires")
		if requires:
			for require in [x.strip() for x in requires.split(";")]:
				negate = require.startswith("!")
				if negate:
					require = require[1:]
				if require.startswith("config."):
					item = eval(require)
					result = bool(item.value and item.value not in ("0", "Disable", "disable", "False", "false", "No", "no", "Off", "off"))
				else:
					result = bool(SystemInfo.get(require, False))
				if require and negate == result:  # The item requirements are not met.
					return False
		conditional = element.get("conditional")
		return not conditional or eval(conditional)
Exemplo n.º 42
0
    def addItems(self, list, parentNode):
        for x in parentNode:
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get("level", 0))
                item_tuxtxtlevel = int(x.get("tt_level", 0))

                if not self.levelChanged in config.usage.setup_level.notifiers:
                    config.usage.setup_level.notifiers.append(
                        self.levelChanged)
                    self.onClose.append(self.removeNotifier)

                if item_level > config.usage.setup_level.index:
                    continue
                if (item_tuxtxtlevel
                        == 1) and (config.usage.tuxtxt_font_and_res.value !=
                                   "expert_mode"):
                    continue

                item_text = _(x.get("text", "??").encode("UTF-8"))
                item_description = _(x.get("description", " ").encode("UTF-8"))
                try:
                    b = eval(x.text or "")
                except:
                    b = ""
                if b == "":
                    continue
                #add to configlist
                item = b

                requires = x.get("requires")
                if item.value and not item.value == "0":
                    SystemInfo[x.text] = True
                else:
                    SystemInfo[x.text] = False

                if requires and not SystemInfo.get(requires, False):
                    continue
                # the first b is the item itself, ignored by the configList.
                # the second one is converted to string.
                if not isinstance(item, ConfigNothing):
                    list.append((item_text, item, item_description))
Exemplo n.º 43
0
	def UpdateConfigList(self):
		self.configlist = []
		if _flagSupportWol:
			macaddr = " "
			self.configlist.append(getConfigListEntry(_("WakeOnLan Enable"), config.plugins.wolconfig.activate))
			if config.plugins.wolconfig.activate.value:
				self.configlist.append(getConfigListEntry(_("Location"), config.plugins.wolconfig.location))
				if SystemInfo.get("WOWLSupport", False):
					if iNetwork.getAdapterAttribute(_ethDevice, 'up'):
						macaddr = "HWaddr of %s is %s" % (_ethDevice, NetTool.GetHardwareAddr(_ethDevice))
					else:
						macaddr = "Wireless lan is not activated."
				else:
					macaddr = "HWaddr of %s is %s" % (_ethDevice, NetTool.GetHardwareAddr(_ethDevice))
			else:	macaddr = "Wake on Lan disabled"
			self["introduction"].setText(macaddr)

		self["config"].list = self.configlist
		self["config"].l.setList(self.configlist)
Exemplo n.º 44
0
    def addItems(self, list, parentNode):
        for x in parentNode:
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get("level", 0))

                if not self.levelChanged in config.usage.setup_level.notifiers and not self.onNotifiers:
                    config.usage.setup_level.notifiers.append(
                        self.levelChanged)
                    self.onNotifiers.append(self.levelChanged)
                    self.onClose.append(self.removeNotifier)

                if item_level > config.usage.setup_level.index or item_level > config.usage.setup_level.index:
                    continue

                requires = x.get("requires")
                if requires and requires.startswith('config.'):
                    item = eval(requires or "")
                    if item.getValue() and not item.getValue() == "0":
                        SystemInfo[requires] = True
                    else:
                        SystemInfo[requires] = False

                if requires and not SystemInfo.get(requires, False):
                    continue

                item_text = _(x.get("text", "??").encode("UTF-8"))
                item_text = item_text.replace(
                    "%s %s", "%s %s" % (getMachineBrand(), getMachineName()))
                item_description = _(x.get("description", " ").encode("UTF-8"))
                item_description = item_description.replace(
                    "%s %s", "%s %s" % (getMachineBrand(), getMachineName()))
                b = eval(x.text or "")
                if b == "":
                    continue
                #add to configlist
                item = b
                # the first b is the item itself, ignored by the configList.
                # the second one is converted to string.
                if not isinstance(item, ConfigNothing):
                    list.append((item_text, item, item_description))
Exemplo n.º 45
0
def Plugins(**kwargs):
	# do not add any entry if only one (or less :P) video decoders present
	if SystemInfo.get("NumVideoDecoders", 1) < 2:
		return []

	l = [
		PluginDescriptor(
			where=PluginDescriptor.WHERE_AUTOSTART,
			fnc=autostart,
			needsRestart=True, # XXX: force restart for now as I don't think the plugin will work properly without one
		),
		PluginDescriptor(
			where=PluginDescriptor.WHERE_MENU,
			fnc=menu,
			needsRestart=False,
		),
	]
	if config.plugins.pipzap.show_in_plugins.value:
		l.append(activateDescriptor)
	return l
Exemplo n.º 46
0
def getConfigs(key):
    configs = []
    title = ""

    setupfile = file(eEnv.resolve('${datadir}/enigma2/setup.xml'), 'r')
    setupdom = xml.etree.cElementTree.parse(setupfile)
    setupfile.close()
    xmldata = setupdom.getroot()
    for section in xmldata.findall("setup"):
        if section.get("key") != key:
            continue

        for entry in section:
            if entry.tag == "item":
                requires = entry.get("requires")
                if requires and requires.startswith('config.'):
                    item = eval(requires or "")
                    if item.value and not item.value == "0":
                        SystemInfo[requires] = True
                    else:
                        SystemInfo[requires] = False
                if requires and not SystemInfo.get(requires, False):
                    continue

                if int(entry.get("level", 0)) > config.usage.setup_level.index:
                    continue

                try:
                    configs.append({
                        "description":
                        entry.get("text", ""),
                        "path":
                        entry.text or "",
                        "data":
                        getJsonFromConfig(eval(entry.text or ""))
                    })
                except Exception, e:
                    pass

        title = section.get("title", "")
        break
Exemplo n.º 47
0
    def __init__(self):
        Renderer.__init__(self)

        global KravenFBTool
        KravenFBTool = KravenFBHelper()

        self.Position = self.Size = None

        self.timer = eTimer()
        self.timer.callback.append(self.showpip)

        self.pipCreated = False
        self.pipRemoved = False
        self.Initialized = False

        self.PigStyle = config.plugins.KravenHD.PigStyle.value
        if SystemInfo.get("NumVideoDecoders",
                          1) > 1 and not self.PigStyle == "Preview":
            self.decoder = 1
        else:
            self.decoder = 0

        self.fb_w = getDesktop(0).size().width()
        self.fb_h = getDesktop(0).size().height()
        self.fb_size = None

        if config.plugins.KravenHD.SkinResolution.value == "hd":
            self.x2 = 69
            self.y2 = 354
            self.w2 = 363
            self.h2 = 204
        else:
            self.x2 = 103
            self.y2 = 530
            self.w2 = 544
            self.h2 = 306
        self.x2 = format(int(float(self.x2) / self.fb_w * 720.0), 'x').zfill(8)
        self.y2 = format(int(float(self.y2) / self.fb_h * 576.0), 'x').zfill(8)
        self.w2 = format(int(float(self.w2) / self.fb_w * 720.0), 'x').zfill(8)
        self.h2 = format(int(float(self.h2) / self.fb_h * 576.0), 'x').zfill(8)
        self.fb_size2 = [self.w2, self.h2, self.x2, self.y2]
Exemplo n.º 48
0
def getConfigsSections():
    allowedsections = [
        "usage", "recording", "subtitlesetup", "autolanguagesetup", "avsetup",
        "harddisk", "keyboard", "timezone", "time", "osdsetup", "epgsetup",
        "lcd", "remotesetup", "softcamsetup", "logs", "timeshift"
    ]
    sections = []

    setupfile = file(eEnv.resolve('${datadir}/enigma2/setup.xml'), 'r')
    setupdom = xml.etree.cElementTree.parse(setupfile)
    setupfile.close()
    xmldata = setupdom.getroot()
    for section in xmldata.findall("setup"):
        key = section.get("key")
        if key not in allowedsections:
            continue

        count = 0
        for entry in section:
            if entry.tag == "item":
                requires = entry.get("requires")
                if requires and requires.startswith('config.'):
                    item = eval(requires or "")
                    if item.value and not item.value == "0":
                        SystemInfo[requires] = True
                    else:
                        SystemInfo[requires] = False
                if requires and not SystemInfo.get(requires, False):
                    continue

                if int(entry.get("level", 0)) > config.usage.setup_level.index:
                    continue

                count += 1

        if count > 0:
            sections.append({"key": key, "description": section.get("title")})

    sections = sorted(sections, key=lambda k: k['description'])
    return {"result": True, "sections": sections}
Exemplo n.º 49
0
 def addItems(self, list, parentNode):
     for x in parentNode:
         if not x.tag:
             continue
         if x.tag == 'item':
             item_level = int(x.get('level', 0))
             item_rectunerlevel = int(x.get('rectunerlevel', 0))
             if self.levelChanged not in config.usage.setup_level.notifiers:
                 config.usage.setup_level.notifiers.append(
                     self.levelChanged)
                 self.onClose.append(self.removeNotifier)
             if self.levelChanged not in config.usage.recording_frontend_priority.notifiers:
                 config.usage.recording_frontend_priority.notifiers.append(
                     self.levelChanged)
                 self.onClose.append(
                     self.removeNotifierRecordFrontendPriority)
             if item_level > config.usage.setup_level.index:
                 continue
             if item_rectunerlevel == 1 and config.usage.recording_frontend_priority.value not in (
                     'expert_mode', 'experimental_mode'):
                 continue
             if item_rectunerlevel == 2 and not config.usage.recording_frontend_priority.value == 'experimental_mode':
                 continue
             requires = x.get('requires')
             if requires and requires.startswith('config.'):
                 item = eval(requires or '')
                 if item.value and not item.value == '0':
                     SystemInfo[requires] = True
                 else:
                     SystemInfo[requires] = False
             if requires and not SystemInfo.get(requires, False):
                 continue
             item_text = _(x.get('text', '??').encode('UTF-8'))
             item_description = _(x.get('description', ' ').encode('UTF-8'))
             b = eval(x.text or '')
             if b == '':
                 continue
             item = b
             if not isinstance(item, ConfigNothing):
                 list.append((item_text, item, item_description))
    def layoutFinishedCB(self):
        if not os.access(ENABLE_QPIP_PROCPATH, os.F_OK):
            self.notSupportTimer.start(100, True)
            return

        if os.path.exists("/proc/stb/vmpeg/0/dst_apply"):
            open("/proc/stb/vmpeg/0/dst_left", "w").write("00000000")
            open("/proc/stb/vmpeg/0/dst_top", "w").write("00000000")
            open("/proc/stb/vmpeg/0/dst_width", "w").write("00000000")
            open("/proc/stb/vmpeg/0/dst_height", "w").write("00000000")
            open("/proc/stb/vmpeg/0/dst_apply", "w").write("00000001")

        self.onClose.append(self.__onClose)

        if self.session.pipshown:
            if self.InfoBarInstance:
                hasattr(self.InfoBarInstance,
                        "showPiP") and self.InfoBarInstance.showPiP()
            if hasattr(self.session, 'pip'):
                del self.session.pip
            self.session.pipshown = False

        self.oldService = self.session.nav.getCurrentlyPlayingServiceOrGroup()
        self.newService = None
        self.session.nav.stopService()

        if SystemInfo.get("LcdLiveTV", False):
            self.disableLcdLiveTV()

        ret = setDecoderMode("mosaic")
        if ret is not True:
            self.forceToExitTimer.start(0, True)
            return

        self.moveLabel()

        if self.qpipChannelList.length() == 0:
            self.noChannelTimer.start(10, True)
        else:
            self.playLastChannel()
Exemplo n.º 51
0
	def addItems(self, parentNode):
		for element in parentNode:
			if element.tag and element.tag == "item":
				itemLevel = int(element.get("level", 0))
				if itemLevel > config.usage.setup_level.index:  # The item is higher than the current setup level.
					continue
				requires = element.get("requires")
				if requires:
					negate = requires.startswith("!")
					if negate:
						requires = requires[1:]
					if requires.startswith("config."):
						item = eval(requires)
						SystemInfo[requires] = True if item.value and item.value not in ("0", "False", "false") else False
						clean = True
					else:
						clean = False
					result = bool(SystemInfo.get(requires, False))
					if clean:
						SystemInfo.pop(requires, None)
					if requires and negate == result:  # The item requirements are not met.
						continue
				conditional = element.get("conditional")
				if conditional and not eval(conditional):  # The item conditions are not met.
					continue
				if self.PluginLanguageDomain:
					itemText = dgettext(self.PluginLanguageDomain, element.get("text", "??").encode("UTF-8"))
					itemDescription = dgettext(self.PluginLanguageDomain, element.get("description", " ").encode("UTF-8"))
				else:
					itemText = _(element.get("text", "??").encode("UTF-8"))
					itemDescription = _(element.get("description", " ").encode("UTF-8"))
				itemText = itemText.replace("%s %s", "%s %s" % (SystemInfo["MachineBrand"], SystemInfo["MachineName"]))
				itemDescription = itemDescription.replace("%s %s", "%s %s" % (SystemInfo["MachineBrand"], SystemInfo["MachineName"]))
				item = eval(element.text or "")
				if item != "" and not isinstance(item, ConfigNothing):
					itemDefault = "(Default: %s)" % item.toDisplayString(item.default)
					itemDescription = "%s  %s" % (itemDescription, itemDefault) if itemDescription and itemDescription != " " else itemDefault
					self.list.append((itemText, item, itemDescription))  # Add the item to the config list.
				if item is config.usage.boolean_graphic:
					self.switch = True
Exemplo n.º 52
0
    def parseConfigFiles(self):
        sections = []
        for setupfile in self.setupfiles:
            # print("[OpenWebif] loading configuration file :", setupfile)
            setupfile = open(setupfile, 'r')
            setupdom = xml.etree.cElementTree.parse(setupfile)  # nosec
            setupfile.close()
            xmldata = setupdom.getroot()
            for section in xmldata.findall("setup"):
                configs = []
                requires = section.get("requires")
                if requires and not SystemInfo.get(requires, False):
                    continue
                key = section.get("key")
                if key not in self.allowedsections:
                    showOpenWebif = section.get("showOpenWebif") or section.get(
                        "showOpenWebIf") or section.get("showOpenWebIF") or "0"
                    if showOpenWebif.lower() in ("1", "showopenwebif",
                                                 "enabled", "on", "true",
                                                 "yes"):
                        self.allowedsections.append(key)
                    else:
                        continue
                # print("[OpenWebif] loading configuration section :", key)

                self.itemstoadd = []
                self.addItems(section)
                for entry in self.itemstoadd:
                    configs.append(entry)

                if len(configs):
                    sections.append({
                        "key": key,
                        "description": _(section.get("title"))
                    })
                    title = _(section.get("title", ""))
                    self.section_config[key] = (title, configs)
        sections = sorted(sections, key=lambda k: k['description'])
        self.sections = sections
Exemplo n.º 53
0
    def addItems(self, list, parentNode):
        for x in parentNode:
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get('level', 0))
                item_rectunerlevel = int(x.get('rectunerlevel', 0))
                if self.levelChanged not in config.usage.setup_level.notifiers:
                    config.usage.setup_level.notifiers.append(self.levelChanged)
                    self.onClose.append(self.removeNotifier)
                if item_level > config.usage.setup_level.index:
                    continue
                requires = x.get('requires')
                if requires and requires.startswith('config.'):
                    try:
                        item = eval(requires or '')
                    except:
                        continue

                    if item.value and not item.value == '0':
                        SystemInfo[requires] = True
                    else:
                        SystemInfo[requires] = False
                if requires and not SystemInfo.get(requires, False):
                    continue
                item_text = _(x.get('text', '??').encode('UTF-8'))
                item_description = _(x.get('description', ' ').encode('UTF-8'))
                item_text = item_text.replace('%s %s', '%s %s' % (getMachineBrand(), getMachineName()))
                item_description = item_description.replace('%s %s', '%s %s' % (getMachineBrand(), getMachineName()))
                try:
                    b = eval(x.text or '')
                except:
                    b = ''

                if b == '':
                    continue
                item = b
                if not isinstance(item, ConfigNothing):
                    list.append((item_text, item, item_description))
Exemplo n.º 54
0
    def addItems(self, list, parentNode):
        self.needEntryChange = []
        self.needGUIRestart = []
        for x in parentNode:
            if x.tag == 'item':
                item_level = int(x.get("level", 0))

                if not self.levelChanged in config.usage.setup_level.notifiers:
                    config.usage.setup_level.notifiers.append(
                        self.levelChanged)
                    self.onClose.append(self.removeNotifier)

                if item_level > config.usage.setup_level.index:
                    continue

                requires = x.get("requires")
                if requires and not SystemInfo.get(requires, False):
                    continue

                item_text = _(x.get("text", "??").encode("UTF-8"))
                b = eval(x.text or "")
                if b == "":
                    continue
                #add to configlist
                item = b
                # the first b is the item itself, ignored by the configList.
                # the second one is converted to string.
                if not isinstance(item, ConfigNothing):
                    list.append((item_text, item))
                    needentrychange = x.get("entrychange")
                    if needentrychange == "yes":
                        self.needEntryChange.append(item)
                        if not self.entryChanged in item.notifiers:
                            item.notifiers.append(self.entryChanged)
                        if not self.removeEntryNotifier in self.onClose:
                            self.onClose.append(self.removeEntryNotifier)
                    need_gui_restart = x.get("guirestart")
                    if need_gui_restart == "yes":
                        self.needGUIRestart.append((item, item.getText()))
Exemplo n.º 55
0
	def __init__(self, session):
		Screen.__init__(self, session)
		self["CurrentService"] = CurrentService(session.nav)
		self["Event_Now"] = EventInfo(session.nav, EventInfo.NOW)
		self["Event_Next"] = EventInfo(session.nav, EventInfo.NEXT)
		self["FrontendStatus"] = FrontendStatus(service_source=session.nav.getCurrentService)
		self["FrontendInfo"] = FrontendInfo(navcore=session.nav)
		self["VideoPicture"] = Source()
		self["TunerInfo"] = TunerInfo()
		self["RecordState"] = RecordState(session)
		self["Standby"] = Boolean(fixed=False)
		self["HddSleepingState"] = HddState(session)

		from Components.SystemInfo import SystemInfo

		combine = Combine(func=lambda s: {(False, False): 0, (False, True): 1, (True, False): 2, (True, True): 3}[(s[0].boolean, s[1].boolean)])
		combine.connect(self["Standby"])
		combine.connect(self["RecordState"])
		combine.connect(self["HddSleepingState"])

		#                      |  two leds  | single led |
		# recordstate  standby   red green
		#    false      false    off   on     off
		#    true       false    blnk  on     blnk
		#    false      true      on   off    off
		#    true       true     blnk  off    blnk

		PATTERN_ON = (20, 0xffffffff, 0xffffffff)
		PATTERN_OFF = (20, 0, 0)
		PATTERN_BLINK = (20, 0x55555555, 0xa7fccf7a)

		nr_leds = SystemInfo.get("NumFrontpanelLEDs", 0)

		if nr_leds == 1:
			FrontpanelLed(which=0, boolean=False, patterns=[PATTERN_OFF, PATTERN_BLINK, PATTERN_OFF, PATTERN_BLINK]).connect(combine)
		elif nr_leds == 2:
			FrontpanelLed(which=0, boolean=False, patterns=[PATTERN_OFF, PATTERN_BLINK, PATTERN_ON, PATTERN_BLINK]).connect(combine)
			FrontpanelLed(which=1, boolean=False, patterns=[PATTERN_ON, PATTERN_ON, PATTERN_OFF, PATTERN_OFF]).connect(combine)
	def _getConfig(self):
		# Name, configElement, HelpTxt, reloadConfig
		self.list = [] 
		self.list.append(getConfigListEntry(_("Refresh EPG automatically"), config.plugins.epgrefresh.enabled, _("Unless this is enabled, EPGRefresh won't automatically run but needs to be explicitly started by the yellow button in this menu."), True))
		if config.plugins.epgrefresh.enabled.value:
			# temporary until new mode is successfully tested
			self.list.append(getConfigListEntry(_("Use time-based duration to stay on service"), config.plugins.epgrefresh.usetimebased, _("Duration to stay can be automatically detected by enigma2 or manually set by the user"), True))
			if config.plugins.epgrefresh.usetimebased.value:
				self.list.append(getConfigListEntry(_("Duration to stay on service (seconds)"), config.plugins.epgrefresh.interval_seconds, _("This is the duration each service/channel will stay active during a refresh."), False))
			self.list.append(getConfigListEntry(_("EPG refresh auto-start earliest (hh:mm)"), config.plugins.epgrefresh.begin, _("An automated refresh will start after this time of day, but before the time specified in next setting."), False))
			self.list.append(getConfigListEntry(_("EPG refresh auto-start latest (hh:mm)"), config.plugins.epgrefresh.end, _("An automated refresh will start before this time of day, but after the time specified in previous setting."), False))
			self.list.append(getConfigListEntry(_("Delay if not in standby (minutes)"), config.plugins.epgrefresh.delay_standby, _("If the receiver currently isn't in standby, this is the duration which EPGRefresh will wait before retry."), False))
			if SystemInfo.get("NumVideoDecoders", 1) > 1:
				self.list.append(getConfigListEntry(_("Refresh EPG using"), config.plugins.epgrefresh.adapter, _("If you want to refresh the EPG in background, you can choose the method which best suits your needs here, e.g. hidden, fake reocrding or regular Picture in Picture."), False))
			self.list.append(getConfigListEntry(_("Show Advanced Options"), NoSave(config.plugins.epgrefresh.showadvancedoptions), _("Display more Options"), True))
			if config.plugins.epgrefresh.showadvancedoptions.value:
				if config.ParentalControl.configured.value and  config.ParentalControl.servicepinactive.value:
					self.list.append(getConfigListEntry(_("Skip protected Services"), config.plugins.epgrefresh.skipProtectedServices, _("Should protected services be skipped if refresh was started in interactive-mode?"), False))
				self.list.append(getConfigListEntry(_("Show Setup in extension menu"), config.plugins.epgrefresh.show_in_extensionsmenu, _("Enable this to be able to access the EPGRefresh configuration from within the extension menu."), False))
				self.list.append(getConfigListEntry(_("Show 'EPGRefresh Start now' in extension menu"), config.plugins.epgrefresh.show_run_in_extensionsmenu, _("Enable this to be able to start the EPGRefresh from within the extension menu."), False))
				self.list.append(getConfigListEntry(_("Show popup when refresh starts and ends"), config.plugins.epgrefresh.enablemessage, _("This setting controls whether or not an informational message will be shown at start and completion of refresh."), False))
				self.list.append(getConfigListEntry(_("Wake up from standby for EPG refresh"), config.plugins.epgrefresh.wakeup, _("If this is enabled, the plugin will wake up the receiver from standby if possible. Otherwise it needs to be switched on already."), False))
				self.list.append(getConfigListEntry(_("Force scan even if receiver is in use"), config.plugins.epgrefresh.force, _("This setting controls whether or not the refresh will be initiated even though the receiver is active (either not in standby or currently recording)."), False))
				self.list.append(getConfigListEntry(_("Shutdown after EPG refresh"), config.plugins.epgrefresh.afterevent, _("This setting controls whether the receiver should be set to standby after refresh is completed."), False))
                                self.list.append(getConfigListEntry(_("Force save EPG.db"), config.plugins.epgrefresh.epgsave, _("If this is enabled, the Plugin save the epg.db /etc/enigma2/epg.db."), False)) 
                                self.list.append(getConfigListEntry(_("Reset")+" "+_("EPG.db"), config.plugins.epgrefresh.epgreset, _("If this is enabled, the Plugin shows the Reset EPG.db function."), False)) 
				try:
					# try to import autotimer module to check for its existence
					from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
		
					self.list.append(getConfigListEntry(_("Inherit Services from AutoTimer"), config.plugins.epgrefresh.inherit_autotimer, _("Extend the list of services to refresh by those your AutoTimers use?"), True))
					self.list.append(getConfigListEntry(_("Run AutoTimer after refresh"), config.plugins.epgrefresh.parse_autotimer, _("After a successful refresh the AutoTimer will automatically search for new matches if this is enabled. The options 'Ask*' has only affect on a manually refresh. If EPG-Refresh was called in background the default-Answer will be executed!"), False))
				except ImportError as ie:
					print("[EPGRefresh] AutoTimer Plugin not installed:", ie)
			
		self["config"].list = self.list
		self["config"].setList(self.list)
Exemplo n.º 57
0
	def parseConfigFiles(self):
		sections = []
		for setupfile in self.setupfiles:
#			print "[OpenWebif] loading configuration file :", setupfile
			setupfile = file(setupfile, 'r')
			setupdom = xml.etree.cElementTree.parse(setupfile)
			setupfile.close()
			xmldata = setupdom.getroot()
			for section in xmldata.findall("setup"):
				configs = []
				key = section.get("key")
				if key not in self.allowedsections:
					showOpenWebIF = section.get("showOpenWebIF")
					if showOpenWebIF == "1":
						self.allowedsections.append(key)
					else:
						continue
#				print "[OpenWebif] loading configuration section :", key
				for entry in section:
					if entry.tag == "item":
						requires = entry.get("requires")
						if requires and not SystemInfo.get(requires, False):
							continue;

						if int(entry.get("level", 0)) > config.usage.setup_level.index:
							continue
						configs.append(entry)
				if len(configs):
					sections.append({
						"key": key,
						"description": _(section.get("title"))
					})
					title = _(section.get("title", ""))
					self.section_config[key] = (title, configs)
		sections = sorted(sections, key=lambda k: k['description'])
		self.sections = sections
Exemplo n.º 58
0
 def __init__(self, session, servicelist=None):
     Screen.__init__(self, session)
     self.session = session
     if SystemInfo.get(
             "NumVideoDecoders", 1
     ) > 1 and config.plugins.virtualzap.usepip.value and config.plugins.virtualzap.showpipininfobar.value:
         self.skinName = "VirtualZap"
         self.pipAvailable = True
     else:
         self.skinName = "VirtualZapNoPiP"
         self.pipAvailable = (
             SystemInfo.get("NumVideoDecoders", 1) > 1
         ) and config.plugins.virtualzap.usepip.value and not config.plugins.virtualzap.showpipininfobar.value
     self.epgcache = eEPGCache.getInstance()
     self.CheckForEPG = eTimer()
     self.CheckForEPG.callback.append(self.CheckItNow)
     self["NowChannel"] = Label()
     self["NowEPG"] = Label()
     self["NextEPG"] = Label()
     self["NowTime"] = Label()
     self["NextTime"] = Label()
     self["actions"] = ActionMap(
         [
             "OkCancelActions", "DirectionActions",
             "ChannelSelectBaseActions", "ChannelSelectEPGActions",
             "ColorActions"
         ], {
             "ok": self.ok,
             "cancel": self.closing,
             "right": self.nextService,
             "left": self.prevService,
             "nextBouquet": self.showFavourites,
             "prevBouquet": self.openServiceList,
             "showEPGList": self.openEventView,
             "blue": self.standardPiP,
             "yellow": self.switchAndStandardPiP,
             "down": self.switchChannelDown,
             "up": self.switchChannelUp,
         }, -2)
     self["actions2"] = NumberActionMap(
         ["NumberActions"], {
             "0": self.swap,
             "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,
         }, -1)
     self.onLayoutFinish.append(self.onLayoutReady)
     # PiP
     if self.pipAvailable:
         # activate PiP support
         if config.plugins.virtualzap.usepip.value and not config.plugins.virtualzap.showpipininfobar.value:
             # activate standard PiP
             self["video"] = VideoWindow()
         else:
             # show PiP in Infobar
             self["video"] = VideoWindow(
                 fb_width=getDesktop(0).size().width(),
                 fb_height=getDesktop(0).size().height())
         self.currentPiP = ""
     else:
         # no PiP
         self["video"] = Label()
     # this is the servicelist from ChannelSelectionBase
     self.servicelist = servicelist
     # save orig. method of zap in servicelist
     self.servicelist_orig_zap = self.servicelist.zap
     # when displaying ChannelSelection, do not zap when pressing "ok", so new method is needed
     self.servicelist.zap = self.servicelist_overwrite_zap
     # overwrite the actionmap of ChannelSelection
     self.servicelist["actions"] = ActionMap(
         ["OkCancelActions"], {
             "cancel": self.cancelChannelSelection,
             "ok": self.servicelist.channelSelected,
         })
     # temp. vars, needed when pressing cancel in ChannelSelection
     self.curSelectedRef = None
     self.curSelectedBouquet = None
     # needed, because if we won't zap, we have to go back to the current bouquet and service
     self.curRef = ServiceReference(self.servicelist.getCurrentSelection())
     self.curBouquet = self.servicelist.getRoot()
     # start with last used service
     if config.plugins.virtualzap.saveLastService.value:
         # get service and bouquet ref
         ref = eServiceReference(config.plugins.virtualzap.curref.value)
         bouquet = eServiceReference(
             config.plugins.virtualzap.curbouquet.value)
         if ref.valid() and bouquet.valid():
             # select bouquet and ref in servicelist
             self.setServicelistSelection(bouquet, ref)
     # prepare exitTimer
     self.exitTimer = eTimer()
     self.exitTimer.timeout.get().append(self.standardPiP)
     # reverse changes of ChannelSelection when closing plugin
     self.onClose.append(self.__onClose)
     # if PiPServiceRelation is installed, get relation dict
     if plugin_PiPServiceRelation_installed:
         self.pipServiceRelation = getRelationDict()
     else:
         self.pipServiceRelation = {}
Exemplo n.º 59
0
class VirtualZap(Screen):
    sz_w = getDesktop(0).size().width()

    #
    # VirtualZap or VirtualZapNoPiP
    #

    if SystemInfo.get(
            "NumVideoDecoders", 1
    ) > 1 and config.plugins.virtualzap.usepip.value and config.plugins.virtualzap.showpipininfobar.value:
        # use PiP in Infobar
        if sz_w == 1280:
            skin = """
				<screen backgroundColor="#101214" flags="wfNoBorder" name="VirtualZap" position="0,505" size="1280,220" title="Virtual Zap">
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/hd.png" position="0,0" size="1280,220" zPosition="0"/>
					<widget backgroundColor="transparent" name="video" position="60,50" size="214,120" zPosition="1"/>
					<widget backgroundColor="#101214" font="Regular;26" halign="left" name="NowChannel" position="305,60" size="887,32" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" foregroundColor="#fcc000" halign="left" name="NowEPG" position="305,105" size="600,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" halign="left" name="NextEPG" position="305,140" size="600,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" foregroundColor="#fcc000" halign="right" name="NowTime" position="1070,105" size="124,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" halign="right" name="NextTime" position="1070,140" size="124,28" transparent="1" zPosition="2"/>
				</screen>"""
        elif sz_w == 1024:
            skin = """
				<screen backgroundColor="#101214" flags="wfNoBorder" name="VirtualZap" position="0,420" size="1024,176" title="Virtual Zap">
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/sd.png" position="0,0" size="1024,176" zPosition="0"/>
					<widget backgroundColor="transparent" name="video" position="50,20" size="164,92" zPosition="1"/>
					<widget backgroundColor="#101214" font="Regular;22" halign="left" name="NowChannel" position="230,25" size="741,30" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="left" name="NowEPG" position="230,55" size="600,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="left" name="NextEPG" position="230,80" size="600,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="right" name="NowTime" position="850,55" size="124,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="right" name="NextTime" position="850,80" size="124,25" transparent="1" zPosition="2"/>
				</screen>"""
        else:
            skin = """
				<screen backgroundColor="#101214" flags="wfNoBorder" name="VirtualZap" position="0,420" size="720,176" title="Virtual Zap">
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/sd.png" position="0,0" size="720,176" zPosition="0"/>
					<widget backgroundColor="transparent" name="video" position="50,25" size="130,73" zPosition="1"/>
					<widget backgroundColor="#101214" font="Regular;22" halign="left" name="NowChannel" position="190,25" size="480,30" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="left" name="NowEPG" position="190,55" size="360,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="left" name="NextEPG" position="190,80" size="360,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="right" name="NowTime" position="550,55" size="120,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="right" name="NextTime" position="550,80" size="120,25" transparent="1" zPosition="2"/>
				</screen>"""
    else:
        if SystemInfo.get(
                "NumVideoDecoders", 1
        ) > 1 and config.plugins.virtualzap.usepip.value and not config.plugins.virtualzap.showpipininfobar.value:
            # use standard PiP
            config.av.pip = ConfigPosition(default=[0, 0, 0, 0],
                                           args=(719, 567, 720, 568))
            x = config.av.pip.value[0]
            y = config.av.pip.value[1]
            w = config.av.pip.value[2]
            h = config.av.pip.value[3]

        else:
            # no PiP
            x = 0
            y = 0
            w = 0
            h = 0

        if sz_w == 1280:
            skin = """
				<screen backgroundColor="transparent" flags="wfNoBorder" name="VirtualZapNoPiP" position="0,0" size="1280,720" title="Virtual Zap">
					<widget backgroundColor="transparent" name="video" position="%d,%d" size="%d,%d" zPosition="1"/>
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/hd.png" position="0,505" size="1280,220" zPosition="0"/>
					<widget backgroundColor="#101214" font="Regular;26" halign="center" name="NowChannel" position="140,565" size="1000,32" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" foregroundColor="#fcc000" halign="left" name="NowEPG" position="140,610" size="860,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" halign="left" name="NextEPG" position="140,645" size="860,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" foregroundColor="#fcc000" halign="right" name="NowTime" position="1015,610" size="124,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" halign="right" name="NextTime" position="1015,645" size="124,28" transparent="1" zPosition="2"/>
				</screen>""" % (x, y, w, h)
        elif sz_w == 1024:
            skin = """
				<screen backgroundColor="transparent" flags="wfNoBorder" name="VirtualZapNoPiP" position="0,0" size="1024,576" title="Virtual Zap">
					<widget backgroundColor="transparent" name="video" position="%d,%d" size="%d,%d" zPosition="1"/>
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/sd.png" position="0,420" size="1024,176" zPosition="0"/>
					<widget backgroundColor="#101214" font="Regular;22" halign="center" name="NowChannel" position="100,445" size="824,30" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="left" name="NowEPG" position="100,475" size="700,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="left" name="NextEPG" position="100,500" size="700,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="right" name="NowTime" position="800,475" size="124,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="right" name="NextTime" position="800,500" size="124,25" transparent="1" zPosition="2"/>
				</screen>""" % (x, y, w, h)
        else:

            skin = """
				<screen backgroundColor="transparent" flags="wfNoBorder" name="VirtualZapNoPiP" position="0,0" size="720,576" title="Virtual Zap">
					<widget backgroundColor="transparent" name="video" position="%d,%d" size="%d,%d" zPosition="1"/>
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/sd.png" position="0,420" size="720,176" zPosition="0"/>
					<widget backgroundColor="#101214" font="Regular;22" halign="center" name="NowChannel" position="50,445" size="620,30" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="left" name="NowEPG" position="50,475" size="500,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="left" name="NextEPG" position="50,500" size="500,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="right" name="NowTime" position="550,475" size="120,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="right" name="NextTime" position="550,500" size="120,25" transparent="1" zPosition="2"/>
				</screen>""" % (x, y, w, h)

    def __init__(self, session, servicelist=None):
        Screen.__init__(self, session)
        self.session = session
        if SystemInfo.get(
                "NumVideoDecoders", 1
        ) > 1 and config.plugins.virtualzap.usepip.value and config.plugins.virtualzap.showpipininfobar.value:
            self.skinName = "VirtualZap"
            self.pipAvailable = True
        else:
            self.skinName = "VirtualZapNoPiP"
            self.pipAvailable = (
                SystemInfo.get("NumVideoDecoders", 1) > 1
            ) and config.plugins.virtualzap.usepip.value and not config.plugins.virtualzap.showpipininfobar.value
        self.epgcache = eEPGCache.getInstance()
        self.CheckForEPG = eTimer()
        self.CheckForEPG.callback.append(self.CheckItNow)
        self["NowChannel"] = Label()
        self["NowEPG"] = Label()
        self["NextEPG"] = Label()
        self["NowTime"] = Label()
        self["NextTime"] = Label()
        self["actions"] = ActionMap(
            [
                "OkCancelActions", "DirectionActions",
                "ChannelSelectBaseActions", "ChannelSelectEPGActions",
                "ColorActions"
            ], {
                "ok": self.ok,
                "cancel": self.closing,
                "right": self.nextService,
                "left": self.prevService,
                "nextBouquet": self.showFavourites,
                "prevBouquet": self.openServiceList,
                "showEPGList": self.openEventView,
                "blue": self.standardPiP,
                "yellow": self.switchAndStandardPiP,
                "down": self.switchChannelDown,
                "up": self.switchChannelUp,
            }, -2)
        self["actions2"] = NumberActionMap(
            ["NumberActions"], {
                "0": self.swap,
                "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,
            }, -1)
        self.onLayoutFinish.append(self.onLayoutReady)
        # PiP
        if self.pipAvailable:
            # activate PiP support
            if config.plugins.virtualzap.usepip.value and not config.plugins.virtualzap.showpipininfobar.value:
                # activate standard PiP
                self["video"] = VideoWindow()
            else:
                # show PiP in Infobar
                self["video"] = VideoWindow(
                    fb_width=getDesktop(0).size().width(),
                    fb_height=getDesktop(0).size().height())
            self.currentPiP = ""
        else:
            # no PiP
            self["video"] = Label()
        # this is the servicelist from ChannelSelectionBase
        self.servicelist = servicelist
        # save orig. method of zap in servicelist
        self.servicelist_orig_zap = self.servicelist.zap
        # when displaying ChannelSelection, do not zap when pressing "ok", so new method is needed
        self.servicelist.zap = self.servicelist_overwrite_zap
        # overwrite the actionmap of ChannelSelection
        self.servicelist["actions"] = ActionMap(
            ["OkCancelActions"], {
                "cancel": self.cancelChannelSelection,
                "ok": self.servicelist.channelSelected,
            })
        # temp. vars, needed when pressing cancel in ChannelSelection
        self.curSelectedRef = None
        self.curSelectedBouquet = None
        # needed, because if we won't zap, we have to go back to the current bouquet and service
        self.curRef = ServiceReference(self.servicelist.getCurrentSelection())
        self.curBouquet = self.servicelist.getRoot()
        # start with last used service
        if config.plugins.virtualzap.saveLastService.value:
            # get service and bouquet ref
            ref = eServiceReference(config.plugins.virtualzap.curref.value)
            bouquet = eServiceReference(
                config.plugins.virtualzap.curbouquet.value)
            if ref.valid() and bouquet.valid():
                # select bouquet and ref in servicelist
                self.setServicelistSelection(bouquet, ref)
        # prepare exitTimer
        self.exitTimer = eTimer()
        self.exitTimer.timeout.get().append(self.standardPiP)
        # reverse changes of ChannelSelection when closing plugin
        self.onClose.append(self.__onClose)
        # if PiPServiceRelation is installed, get relation dict
        if plugin_PiPServiceRelation_installed:
            self.pipServiceRelation = getRelationDict()
        else:
            self.pipServiceRelation = {}

    def onLayoutReady(self):
        self.updateInfos()

    def resetExitTimer(self):
        # if enabled, run exit timer
        if config.plugins.virtualzap.exittimer.value != 0:
            if self.exitTimer.isActive():
                self.exitTimer.stop()
            self.exitTimer.start(config.plugins.virtualzap.exittimer.value *
                                 1000)

    def nextService(self):
        # get next service
        if self.servicelist.inBouquet():
            prev = self.servicelist.getCurrentSelection()
            if prev:
                prev = prev.toString()
                while True:
                    if config.usage.quickzap_bouquet_change.value and self.servicelist.atEnd(
                    ):
                        self.servicelist.nextBouquet()
                    else:
                        self.servicelist.moveDown()
                    cur = self.servicelist.getCurrentSelection()
                    if not cur or (
                            not (cur.flags & 64)) or cur.toString() == prev:
                        break
        else:
            self.servicelist.moveDown()
        if self.isPlayable():
            self.updateInfos()
        else:
            self.nextService()

    def prevService(self):
        # get previous service
        if self.servicelist.inBouquet():
            prev = self.servicelist.getCurrentSelection()
            if prev:
                prev = prev.toString()
                while True:
                    if config.usage.quickzap_bouquet_change.value:
                        if self.servicelist.atBegin():
                            self.servicelist.prevBouquet()
                    self.servicelist.moveUp()
                    cur = self.servicelist.getCurrentSelection()
                    if not cur or (
                            not (cur.flags & 64)) or cur.toString() == prev:
                        break
        else:
            self.servicelist.moveUp()
        if self.isPlayable():
            self.updateInfos()
        else:
            self.prevService()

    def isPlayable(self):
        # check if service is playable
        current = ServiceReference(self.servicelist.getCurrentSelection())
        return not (
            current.ref.flags &
            (eServiceReference.isMarker | eServiceReference.isDirectory))

    def nextBouquet(self):
        # next bouquet with first service
        if config.usage.multibouquet.value:
            self.servicelist.nextBouquet()
        self.updateInfos()

    def prevBouquet(self):
        # previous bouquet with first service
        if config.usage.multibouquet.value:
            self.servicelist.prevBouquet()
        self.updateInfos()

    def updateInfos(self):
        self.resetExitTimer()
        # update data
        current = ServiceReference(self.servicelist.getCurrentSelection())
        self["NowChannel"].setText(current.getServiceName())
        nowepg, nowtimedisplay = self.getEPGNowNext(current.ref, 0)
        nextepg, nexttimedisplay = self.getEPGNowNext(current.ref, 1)
        self["NowEPG"].setText(nowepg)
        self["NextEPG"].setText(nextepg)
        self["NowTime"].setText(nowtimedisplay)
        self["NextTime"].setText(nexttimedisplay)
        if not nowepg:
            # no epg found --> let's try it again, but only if PiP is activated
            if self.pipAvailable:
                self.CheckForEPG.start(3000, True)
        if self.pipAvailable:
            # play in videowindow
            self.playService(current.ref)

    def getEPGNowNext(self, ref, modus):
        # get now || next event
        if self.epgcache is not None:
            event = self.epgcache.lookupEvent(
                ['IBDCTSERNX', (ref.toString(), modus, -1)])
            if event:
                if event[0][4]:
                    t = localtime(event[0][1])
                    duration = event[0][2]
                    if modus == 0:
                        timedisplay = "+%d min" % ((
                            (event[0][1] + duration) - time()) / 60)
                    elif modus == 1:
                        timedisplay = "%d min" % (duration / 60)
                    return "%02d:%02d %s" % (t[3], t[4],
                                             event[0][4]), timedisplay
                else:
                    return "", ""
        return "", ""

    def openSingleServiceEPG(self):
        # show EPGList
        current = ServiceReference(self.servicelist.getCurrentSelection())
        self.session.open(EPGSelection, current.ref)

    def openEventView(self):
        # stop exitTimer
        if self.exitTimer.isActive():
            self.exitTimer.stop()
        # show EPG Event
        epglist = []
        self.epglist = epglist
        service = ServiceReference(self.servicelist.getCurrentSelection())
        ref = service.ref
        evt = self.epgcache.lookupEventTime(ref, -1)
        if evt:
            epglist.append(evt)
        evt = self.epgcache.lookupEventTime(ref, -1, 1)
        if evt:
            epglist.append(evt)
        if epglist:
            self.session.openWithCallback(self.EventViewEPGSelectCallBack,
                                          EventViewEPGSelect, epglist[0],
                                          service, self.eventViewCallback,
                                          self.openSingleServiceEPG,
                                          self.openMultiServiceEPG,
                                          self.openSimilarList)

    def EventViewEPGSelectCallBack(self):
        # if enabled, start ExitTimer
        self.resetExitTimer()

    def eventViewCallback(self, setEvent, setService, val):
        epglist = self.epglist
        if len(epglist) > 1:
            tmp = epglist[0]
            epglist[0] = epglist[1]
            epglist[1] = tmp
            setEvent(epglist[0])

    def openMultiServiceEPG(self):
        # not supported
        pass

    def openSimilarList(self, eventid, refstr):
        self.session.open(EPGSelection, refstr, None, eventid)

    def setServicelistSelection(self, bouquet, service):
        # we need to select the old service with bouquet
        if self.servicelist.getRoot() != bouquet:  #already in correct bouquet?
            self.servicelist.clearPath()
            self.servicelist.enterPath(self.servicelist.bouquet_root)
            self.servicelist.enterPath(bouquet)
        self.servicelist.setCurrentSelection(
            service)  #select the service in servicelist

    def closing(self):
        if self.pipAvailable:
            self.pipservice = None
        # save last used service and bouqet ref
        self.saveLastService(self.servicelist.getCurrentSelection().toString(),
                             self.servicelist.getRoot().toString())
        # select running service in servicelist again
        self.setServicelistSelection(self.curBouquet, self.curRef.ref)
        self.close()

    def ok(self):
        # we have to close PiP first, otherwise the service-display is freezed
        if self.pipAvailable:
            self.pipservice = None
        # play selected service and close virtualzap
        self.servicelist_orig_zap()
        # save last used service and bouqet ref
        self.saveLastService(self.curRef.ref.toString(),
                             self.curBouquet.toString())
        self.close()

    def standardPiP(self):
        if not self.pipAvailable:
            return
        # close PiP
        self.pipservice = None
        # save current selected service for standard PiP
        service = ServiceReference(self.servicelist.getCurrentSelection()).ref
        servicePath = self.servicelist.getCurrentServicePath(
        )  # same bug as in channelselection
        # save last used service and bouqet ref
        self.saveLastService(self.servicelist.getCurrentSelection().toString(),
                             self.servicelist.getRoot().toString())
        # select running service in servicelist
        self.setServicelistSelection(self.curBouquet, self.curRef.ref)
        # close VZ and start standard PiP
        self.close(service, servicePath)

    def switchAndStandardPiP(self):
        if not self.pipAvailable:
            return
        self.pipservice = None
        # save current selected servicePath for standard PiP
        servicePath = self.servicelist.getCurrentServicePath()
        # save last used service and bouqet ref
        self.saveLastService(self.curRef.ref.toString(),
                             self.curBouquet.toString())
        # play selected service
        self.servicelist_orig_zap()
        # close VZ and start standard PiP
        self.close(self.curRef.ref, servicePath)

    def saveLastService(self, ref, bouquet):
        if config.plugins.virtualzap.saveLastService.value:
            # save last VZ service
            config.plugins.virtualzap.curref.value = ref
            config.plugins.virtualzap.curbouquet.value = bouquet
            config.plugins.virtualzap.save()
        # stop exitTimer
        if self.exitTimer.isActive():
            self.exitTimer.stop()

    def CheckItNow(self):
        self.CheckForEPG.stop()
        self.updateInfos()

    # if available play service in PiP
    def playService(self, service):
        if parentalControl.getProtectionLevel(service.toCompareString(
        )) == -1 or (
                parentalControl.configInitialized
                and parentalControl.sessionPinCached
                and parentalControl.sessionPinCachedValue
        ):  # check parentalControl, only play a protected service when Pin-Cache is activated and still valid
            current_service = service
            n_service = self.pipServiceRelation.get(service.toString(),
                                                    None)  # PiPServiceRelation
            if n_service is not None:
                service = eServiceReference(n_service)
            if service and (service.flags & eServiceReference.isGroup):
                ref = getBestPlayableServiceReference(service,
                                                      eServiceReference())
            else:
                ref = service
            if ref and ref.toString() != self.currentPiP:
                self.pipservice = eServiceCenter.getInstance().play(ref)
                if self.pipservice and not self.pipservice.setTarget(1):
                    self.pipservice.start()
                    self.currentPiP = current_service.toString()
                else:
                    self.pipservice = None
                    self.currentPiP = ""
        else:
            self.pipservice = None
            self.currentPiP = ""

    # switch with numbers

    def keyNumberGlobal(self, number):
        self.session.openWithCallback(self.numberEntered, NumberZap, number)

    def numberEntered(self, retval):
        if retval > 0:
            self.zapToNumber(retval)

    def searchNumberHelper(self, serviceHandler, num, bouquet):
        servicelist = serviceHandler.list(bouquet)
        if not servicelist is None:
            while num:
                serviceIterator = servicelist.getNext()
                if not serviceIterator.valid():  #check end of list
                    break
                playable = not (serviceIterator.flags &
                                (eServiceReference.isMarker
                                 | eServiceReference.isDirectory))
                if playable:
                    num -= 1
            if not num:  #found service with searched number ?
                return serviceIterator, 0
        return None, num

    def zapToNumber(self, number):
        bouquet = self.servicelist.bouquet_root
        service = None
        serviceHandler = eServiceCenter.getInstance()
        bouquetlist = serviceHandler.list(bouquet)
        if not bouquetlist is None:
            while number:
                bouquet = bouquetlist.getNext()
                if not bouquet.valid():  #check end of list
                    break
                if bouquet.flags & eServiceReference.isDirectory:
                    service, number = self.searchNumberHelper(
                        serviceHandler, number, bouquet)
        if not service is None:
            self.setServicelistSelection(bouquet, service)
        # update infos, no matter if service is none or not
        self.updateInfos()

    def swap(self, number):
        # save old values for selecting it in servicelist after zapping
        currentRef = self.curRef
        currentBouquet = self.curBouquet
        # we have to close PiP first, otherwise the service-display is freezed
        if self.pipAvailable:
            self.pipservice = None
        # zap and set new values for the new reference and bouquet
        self.servicelist_orig_zap()
        self.curRef = ServiceReference(self.servicelist.getCurrentSelection())
        self.curBouquet = self.servicelist.getRoot()
        # select old values in servicelist
        self.setServicelistSelection(currentBouquet, currentRef.ref)
        # play old service in PiP
        self.updateInfos()

    # ChannelSelection Support
    def prepareChannelSelectionDisplay(self):
        # stop exitTimer
        if self.exitTimer.isActive():
            self.exitTimer.stop()
        # turn off PiP
        if self.pipAvailable:
            self.pipservice = None
        # save current ref and bouquet ( for cancel )
        self.curSelectedRef = eServiceReference(
            self.servicelist.getCurrentSelection().toString())
        self.curSelectedBouquet = self.servicelist.getRoot()

    def cancelChannelSelection(self):
        # select service and bouquet selected before started ChannelSelection
        if self.servicelist.revertMode is None:
            ref = self.curSelectedRef
            bouquet = self.curSelectedBouquet
            if ref.valid() and bouquet.valid():
                # select bouquet and ref in servicelist
                self.setServicelistSelection(bouquet, ref)
        # close ChannelSelection
        self.servicelist.revertMode = None
        self.servicelist.close(None)

        # clean up
        self.curSelectedRef = None
        self.curSelectedBouquet = None
        # display VZ data
        self.servicelist_overwrite_zap()

    def switchChannelDown(self):
        self.prepareChannelSelectionDisplay()
        self.servicelist.moveDown()
        # show ChannelSelection
        self.session.execDialog(self.servicelist)

    def switchChannelUp(self):
        self.prepareChannelSelectionDisplay()
        self.servicelist.moveUp()
        # show ChannelSelection
        self.session.execDialog(self.servicelist)

    def showFavourites(self):
        self.prepareChannelSelectionDisplay()
        self.servicelist.showFavourites()
        # show ChannelSelection
        self.session.execDialog(self.servicelist)

    def openServiceList(self):
        self.prepareChannelSelectionDisplay()
        # show ChannelSelection
        self.session.execDialog(self.servicelist)

    def servicelist_overwrite_zap(self, *args, **kwargs):
        # we do not really want to zap to the service, just display data for VZ
        self.currentPiP = ""
        if self.isPlayable():
            self.updateInfos()

    def __onClose(self):
        # reverse changes of ChannelSelection
        self.servicelist.zap = self.servicelist_orig_zap
        self.servicelist["actions"] = ActionMap(
            ["OkCancelActions", "TvRadioActions"], {
                "cancel": self.servicelist.cancel,
                "ok": self.servicelist.channelSelected,
                "keyRadio": self.servicelist.setModeRadio,
                "keyTV": self.servicelist.setModeTv,
            })
Exemplo n.º 60
0
def InitEPGConfig():
    config.epgselection = ConfigSubsection()
    config.epgselection.sort = ConfigSelection(default="0",
                                               choices=[("0", _("Time")),
                                                        ("1",
                                                         _("Alphanumeric"))])
    config.epgselection.overjump = ConfigYesNo(default=False)

    serviceTitleChoices = [
        ("servicename", _("Service Name")), ("picon", _("Picon")),
        ("picon+servicename", _("Picon and Service Name")),
        ("servicenumber+picon", _("Service Number and Picon")),
        ("picon+servicenumber", _("Picon and Service Number")),
        ("servicenumber+servicename", _("Service Number and Service Name")),
        ("picon+servicenumber+servicename",
         _("Picon, Service Number and Service Name")),
        ("servicenumber+picon+servicename",
         _("Service Number, Picon and Service Name"))
    ]

    singleBrowseModeChoices = [("currentservice", _("Select current service")),
                               ("lastepgservice",
                                _("Select last browsed service"))]

    multiBrowseModeChoices = [
        ("currentservice", _("Select current service")),
        ("firstservice", _("Select first service in bouquet")),
        ("lastepgservice", _("Select last browsed service"))
    ]

    config.epgselection.infobar = ConfigSubsection()
    config.epgselection.infobar.browse_mode = ConfigSelection(
        default="currentservice", choices=singleBrowseModeChoices)
    config.epgselection.infobar.type_mode = ConfigSelection(
        default="graphics",
        choices=[("text", _("Text Grid EPG")),
                 ("graphics", _("Graphics Grid EPG")),
                 ("single", _("Single EPG"))])
    if SystemInfo.get("NumVideoDecoders", 1) > 1:
        config.epgselection.infobar.preview_mode = ConfigSelection(choices=[
            ("0", _("Disabled")), ("1", _("Full screen")), ("2", _("PiP"))
        ],
                                                                   default="1")
    else:
        config.epgselection.infobar.preview_mode = ConfigSelection(choices=[
            ("0", _("Disabled")), ("1", _("Full screen"))
        ],
                                                                   default="1")
    config.epgselection.infobar.itemsperpage = ConfigSelectionNumber(
        default=2, stepwidth=1, min=1, max=4, wraparound=True)
    config.epgselection.infobar.roundto = ConfigSelection(
        default="15",
        choices=[("15", _("%d minutes") % 15), ("30", _("%d minutes") % 30),
                 ("60", _("%d minutes") % 60)])
    config.epgselection.infobar.prevtimeperiod = ConfigSelection(
        default="180",
        choices=[
            ("60", _("%d minutes") % 60), ("90", _("%d minutes") % 90),
            ("120", _("%d minutes") % 120), ("150", _("%d minutes") % 150),
            ("180", _("%d minutes") % 180), ("210", _("%d minutes") % 210),
            ("240", _("%d minutes") % 240), ("270", _("%d minutes") % 270),
            ("300", _("%d minutes") % 300)
        ])
    config.epgselection.infobar.primetime = ConfigClock(default=20 * 60)
    config.epgselection.infobar.servicetitle_mode = ConfigSelection(
        default="servicename", choices=serviceTitleChoices)
    config.epgselection.infobar.servfs = ConfigSelectionNumber(default=0,
                                                               stepwidth=1,
                                                               min=-8,
                                                               max=10,
                                                               wraparound=True)
    config.epgselection.infobar.eventfs = ConfigSelectionNumber(
        default=0, stepwidth=1, min=-8, max=10, wraparound=True)
    config.epgselection.infobar.timelinefs = ConfigSelectionNumber(
        default=0, stepwidth=1, min=-8, max=10, wraparound=True)
    config.epgselection.infobar.timeline24h = ConfigYesNo(default=True)
    config.epgselection.infobar.servicewidth = ConfigSelectionNumber(
        default=250, stepwidth=1, min=70, max=500, wraparound=True)
    config.epgselection.infobar.piconwidth = ConfigSelectionNumber(
        default=100, stepwidth=1, min=50, max=500, wraparound=True)
    config.epgselection.infobar.infowidth = ConfigSelectionNumber(
        default=50, stepwidth=25, min=0, max=150, wraparound=True)
    config.epgselection.infobar.btn_ok = ConfigSelection(choices=okActions,
                                                         default="zap")
    config.epgselection.infobar.btn_oklong = ConfigSelection(choices=okActions,
                                                             default="zapExit")
    config.epgselection.infobar.btn_epg = ConfigSelection(
        choices=infoActions, default="openSingleEPG")
    config.epgselection.infobar.btn_epglong = ConfigSelection(
        choices=infoActions, default="")
    config.epgselection.infobar.btn_info = ConfigSelection(
        choices=infoActions, default="openEventView")
    config.epgselection.infobar.btn_infolong = ConfigSelection(
        choices=infoActions, default="openSingleEPG")
    config.epgselection.infobar.btn_red = ConfigSelection(choices=epgActions,
                                                          default="openIMDb")
    config.epgselection.infobar.btn_redlong = ConfigSelection(
        choices=epgActions, default="sortEPG")
    config.epgselection.infobar.btn_green = ConfigSelection(
        choices=epgActions, default="addEditTimer")
    config.epgselection.infobar.btn_greenlong = ConfigSelection(
        choices=epgActions, default="openTimerList")
    config.epgselection.infobar.btn_yellow = ConfigSelection(
        choices=epgActions, default="openEPGSearch")
    config.epgselection.infobar.btn_yellowlong = ConfigSelection(
        choices=epgActions, default="")
    config.epgselection.infobar.btn_blue = ConfigSelection(
        choices=epgActions, default="addEditAutoTimer")
    config.epgselection.infobar.btn_bluelong = ConfigSelection(
        choices=epgActions, default="openAutoTimerList")
    config.epgselection.infobar.btn_rec = ConfigSelection(
        choices=recActions, default="addEditTimerMenu")
    config.epgselection.infobar.btn_reclong = ConfigSelection(
        choices=recActions, default="addEditZapTimerSilent")

    config.epgselection.single = ConfigSubsection()
    config.epgselection.single.browse_mode = ConfigSelection(
        default="currentservice", choices=singleBrowseModeChoices)
    config.epgselection.single.preview_mode = ConfigYesNo(default=True)
    config.epgselection.single.eventfs = ConfigSelectionNumber(default=0,
                                                               stepwidth=1,
                                                               min=-8,
                                                               max=10,
                                                               wraparound=True)
    config.epgselection.single.itemsperpage = ConfigSelectionNumber(
        default=18, stepwidth=1, min=1, max=40, wraparound=True)
    config.epgselection.single.btn_red = ConfigSelection(choices=epgActions,
                                                         default="openIMDb")
    config.epgselection.single.btn_redlong = ConfigSelection(
        choices=epgActions, default="sortEPG")
    config.epgselection.single.btn_green = ConfigSelection(
        choices=epgActions, default="addEditTimer")
    config.epgselection.single.btn_greenlong = ConfigSelection(
        choices=epgActions, default="openTimerList")
    config.epgselection.single.btn_yellow = ConfigSelection(
        choices=epgActions, default="openEPGSearch")
    config.epgselection.single.btn_yellowlong = ConfigSelection(
        choices=epgActions, default="")
    config.epgselection.single.btn_blue = ConfigSelection(
        choices=epgActions, default="addEditAutoTimer")
    config.epgselection.single.btn_bluelong = ConfigSelection(
        choices=epgActions, default="openAutoTimerList")
    config.epgselection.single.btn_ok = ConfigSelection(choices=okActions,
                                                        default="zap")
    config.epgselection.single.btn_oklong = ConfigSelection(choices=okActions,
                                                            default="zapExit")
    config.epgselection.single.btn_epg = ConfigSelection(
        choices=infoActions, default="openSingleEPG")
    config.epgselection.single.btn_epglong = ConfigSelection(
        choices=infoActions, default="")
    config.epgselection.single.btn_info = ConfigSelection(
        choices=infoActions, default="openEventView")
    config.epgselection.single.btn_infolong = ConfigSelection(
        choices=infoActions, default="openSingleEPG")
    config.epgselection.single.btn_rec = ConfigSelection(
        choices=recActions, default="addEditTimerMenu")
    config.epgselection.single.btn_reclong = ConfigSelection(
        choices=recActions, default="addEditZapTimerSilent")

    config.epgselection.multi = ConfigSubsection()
    config.epgselection.multi.showbouquet = ConfigYesNo(default=False)
    config.epgselection.multi.browse_mode = ConfigSelection(
        default="currentservice", choices=multiBrowseModeChoices)
    config.epgselection.multi.preview_mode = ConfigYesNo(default=True)
    config.epgselection.multi.eventfs = ConfigSelectionNumber(default=0,
                                                              stepwidth=1,
                                                              min=-8,
                                                              max=10,
                                                              wraparound=True)
    config.epgselection.multi.itemsperpage = ConfigSelectionNumber(
        default=18, stepwidth=1, min=12, max=40, wraparound=True)
    config.epgselection.multi.servicewidth = ConfigSelectionNumber(
        default=7, stepwidth=1, min=5, max=20, wraparound=True)
    config.epgselection.multi.btn_ok = ConfigSelection(choices=okActions,
                                                       default="zap")
    config.epgselection.multi.btn_oklong = ConfigSelection(choices=okActions,
                                                           default="zapExit")
    config.epgselection.multi.btn_epg = ConfigSelection(
        choices=infoActions, default="openSingleEPG")
    config.epgselection.multi.btn_epglong = ConfigSelection(
        choices=infoActions, default="")
    config.epgselection.multi.btn_info = ConfigSelection(
        choices=infoActions, default="openEventView")
    config.epgselection.multi.btn_infolong = ConfigSelection(
        choices=infoActions, default="openSingleEPG")
    config.epgselection.multi.btn_rec = ConfigSelection(
        choices=recActions, default="addEditTimerMenu")
    config.epgselection.multi.btn_reclong = ConfigSelection(
        choices=recActions, default="addEditZapTimerSilent")
    config.epgselection.multi.btn_red = ConfigSelection(choices=epgActions,
                                                        default="openIMDb")
    config.epgselection.multi.btn_redlong = ConfigSelection(choices=epgActions,
                                                            default="sortEPG")
    config.epgselection.multi.btn_green = ConfigSelection(
        choices=epgActions, default="addEditTimer")
    config.epgselection.multi.btn_greenlong = ConfigSelection(
        choices=epgActions, default="openTimerList")
    config.epgselection.multi.btn_yellow = ConfigSelection(
        choices=epgActions, default="openEPGSearch")
    config.epgselection.multi.btn_yellowlong = ConfigSelection(
        choices=epgActions, default="")
    config.epgselection.multi.btn_blue = ConfigSelection(
        choices=epgActions, default="addEditAutoTimer")
    config.epgselection.multi.btn_bluelong = ConfigSelection(
        choices=epgActions, default="openAutoTimerList")

    config.epgselection.grid = ConfigSubsection()
    config.epgselection.grid.showbouquet = ConfigYesNo(default=False)
    config.epgselection.grid.browse_mode = ConfigSelection(
        default="currentservice", choices=multiBrowseModeChoices)
    config.epgselection.grid.preview_mode = ConfigYesNo(default=True)
    config.epgselection.grid.type_mode = ConfigSelection(choices=[
        ("graphics", _("Graphics")), ("text", _("Text"))
    ],
                                                         default="graphics")
    config.epgselection.grid.highlight_current_events = ConfigYesNo(
        default=True)
    config.epgselection.grid.roundto = ConfigSelection(
        default="15",
        choices=[("15", _("%d minutes") % 15), ("30", _("%d minutes") % 30),
                 ("60", _("%d minutes") % 60)])
    config.epgselection.grid.prevtimeperiod = ConfigSelection(
        default="180",
        choices=[
            ("60", _("%d minutes") % 60), ("90", _("%d minutes") % 90),
            ("120", _("%d minutes") % 120), ("150", _("%d minutes") % 150),
            ("180", _("%d minutes") % 180), ("210", _("%d minutes") % 210),
            ("240", _("%d minutes") % 240), ("270", _("%d minutes") % 270),
            ("300", _("%d minutes") % 300)
        ])
    config.epgselection.grid.primetime = ConfigClock(default=20 * 60)
    config.epgselection.grid.servicetitle_mode = ConfigSelection(
        default="servicename", choices=serviceTitleChoices)
    possibleAlignmentChoices = [
        (str(RT_HALIGN_LEFT | RT_VALIGN_CENTER), _("left")),
        (str(RT_HALIGN_CENTER | RT_VALIGN_CENTER), _("centered")),
        (str(RT_HALIGN_RIGHT | RT_VALIGN_CENTER), _("right")),
        (str(RT_HALIGN_LEFT | RT_VALIGN_CENTER | RT_WRAP), _("left, wrapped")),
        (str(RT_HALIGN_CENTER | RT_VALIGN_CENTER | RT_WRAP),
         _("centered, wrapped")),
        (str(RT_HALIGN_RIGHT | RT_VALIGN_CENTER | RT_WRAP),
         _("right, wrapped"))
    ]
    config.epgselection.grid.servicename_alignment = ConfigSelection(
        default=possibleAlignmentChoices[0][0],
        choices=possibleAlignmentChoices)
    config.epgselection.grid.servicenumber_alignment = ConfigSelection(
        default=possibleAlignmentChoices[0][0],
        choices=possibleAlignmentChoices)
    config.epgselection.grid.event_alignment = ConfigSelection(
        default=possibleAlignmentChoices[0][0],
        choices=possibleAlignmentChoices)
    config.epgselection.grid.timelinedate_alignment = ConfigSelection(
        default=possibleAlignmentChoices[0][0],
        choices=possibleAlignmentChoices)
    config.epgselection.grid.servfs = ConfigSelectionNumber(default=0,
                                                            stepwidth=1,
                                                            min=-8,
                                                            max=10,
                                                            wraparound=True)
    config.epgselection.grid.eventfs = ConfigSelectionNumber(default=0,
                                                             stepwidth=1,
                                                             min=-8,
                                                             max=10,
                                                             wraparound=True)
    config.epgselection.grid.timelinefs = ConfigSelectionNumber(
        default=0, stepwidth=1, min=-8, max=10, wraparound=True)
    config.epgselection.grid.timeline24h = ConfigYesNo(default=True)
    config.epgselection.grid.itemsperpage = ConfigSelectionNumber(
        default=8, stepwidth=1, min=3, max=20, wraparound=True)
    config.epgselection.grid.pig = ConfigYesNo(default=True)
    config.epgselection.grid.heightswitch = NoSave(ConfigYesNo(default=False))
    config.epgselection.grid.servicewidth = ConfigSelectionNumber(
        default=250, stepwidth=1, min=70, max=500, wraparound=True)
    config.epgselection.grid.piconwidth = ConfigSelectionNumber(
        default=100, stepwidth=1, min=50, max=500, wraparound=True)
    config.epgselection.grid.infowidth = ConfigSelectionNumber(default=50,
                                                               stepwidth=25,
                                                               min=0,
                                                               max=150,
                                                               wraparound=True)
    config.epgselection.grid.rec_icon_height = ConfigSelection(
        choices=[("bottom", _("bottom")), ("top", _("top")),
                 ("middle", _("middle")), ("hide", _("hide"))],
        default="bottom")
    config.epgselection.grid.number_buttons_mode = ConfigSelection(
        choices=[("paging", _("Standard")),
                 ("service", _("Enter service number"))],
        default="paging")
    config.epgselection.grid.btn_ok = ConfigSelection(choices=okActions,
                                                      default="zap")
    config.epgselection.grid.btn_oklong = ConfigSelection(choices=okActions,
                                                          default="zapExit")
    config.epgselection.grid.btn_epg = ConfigSelection(choices=infoActions,
                                                       default="openSingleEPG")
    config.epgselection.grid.btn_epglong = ConfigSelection(choices=infoActions,
                                                           default="")
    config.epgselection.grid.btn_info = ConfigSelection(
        choices=infoActions, default="openEventView")
    config.epgselection.grid.btn_infolong = ConfigSelection(
        choices=infoActions, default="openSingleEPG")
    config.epgselection.grid.btn_rec = ConfigSelection(
        choices=recActions, default="addEditTimerMenu")
    config.epgselection.grid.btn_reclong = ConfigSelection(
        choices=recActions, default="addEditZapTimerSilent")
    config.epgselection.grid.btn_channelup = ConfigSelection(
        choices=channelUpActions, default="forward24Hours")
    config.epgselection.grid.btn_channeldown = ConfigSelection(
        choices=channelDownActions, default="back24Hours")
    config.epgselection.grid.btn_red = ConfigSelection(choices=epgActions,
                                                       default="openIMDb")
    config.epgselection.grid.btn_redlong = ConfigSelection(choices=epgActions,
                                                           default="sortEPG")
    config.epgselection.grid.btn_green = ConfigSelection(
        choices=epgActions, default="addEditTimer")
    config.epgselection.grid.btn_greenlong = ConfigSelection(
        choices=epgActions, default="openTimerList")
    config.epgselection.grid.btn_yellow = ConfigSelection(
        choices=epgActions, default="openEPGSearch")
    config.epgselection.grid.btn_yellowlong = ConfigSelection(
        choices=epgActions, default="")
    config.epgselection.grid.btn_blue = ConfigSelection(
        choices=epgActions, default="addEditAutoTimer")
    config.epgselection.grid.btn_bluelong = ConfigSelection(
        choices=epgActions, default="openAutoTimerList")