本文整理汇总了Python中settings.Settings.getSettingsSecurityLevel方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getSettingsSecurityLevel方法的具体用法?Python Settings.getSettingsSecurityLevel怎么用?Python Settings.getSettingsSecurityLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.getSettingsSecurityLevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkPlugins
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getSettingsSecurityLevel [as 别名]
def checkPlugins(self):
navPath = xbmc.getInfoLabel("Container.FolderPath")
if 'plugin://' not in navPath:
# No Plugin currently set
self.lastPluginChecked = ""
return
# Check if we are in a plugin location
pluginName = xbmc.getInfoLabel("Container.FolderName")
if pluginName in [None, "", self.lastPluginChecked]:
# No Plugin currently set or this is a Plugin that has already been checked
return
# If we reach here we have aPlugin that we need to check
log("NavigationRestrictions: Checking access to view Plugin: %s" % pluginName)
self.lastPluginChecked = pluginName
# Check for the case where the user does not want to check plugins
# but the Pin Sentry plugin is selected, we always need to check this
# as it is how permissions are set
if (not Settings.isActivePlugins()) and ('PinSentry' not in pluginName):
return
securityLevel = 0
# Check to see if the user should have access to this plugin
pinDB = PinSentryDB()
securityLevel = pinDB.getPluginSecurityLevel(pluginName)
if securityLevel < 1:
# Check for the special case that we are accessing ourself
# in which case we have a minimum security level
if 'PinSentry' in pluginName:
securityLevel = Settings.getSettingsSecurityLevel()
else:
log("NavigationRestrictions: No security enabled for plugin %s" % pluginName)
return
del pinDB
# Check if we have already cached the pin number and at which level
if PinSentry.getCachedPinLevel() >= securityLevel:
log("NavigationRestrictions: Already cached pin at level %d, allowing access" % PinSentry.getCachedPinLevel())
return
# Prompt the user for the pin, returns True if they knew it
if PinSentry.promptUserForPin(securityLevel):
log("NavigationRestrictions: Allowed access to plugin %s" % pluginName)
else:
log("NavigationRestrictions: Not allowed access to plugin %s which has security level %d" % (pluginName, securityLevel))
# Move back to the Video plugin Screen as they are not allowed where they are at the moment
xbmc.executebuiltin("ActivateWindow(Video,addons://sources/video/)", True)
# Clear the previous plugin as we will want to prompt for the pin again if the
# user navigates there again
self.lastPluginChecked = ""
PinSentry.displayInvalidPinMessage(securityLevel)
示例2: checkSystemSettings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getSettingsSecurityLevel [as 别名]
def checkSystemSettings(self):
# Check if the system restriction is enabled
if not Settings.isActiveSystemSettings():
return
# Check to see if the main system settings has been selected
systemSettings = xbmc.getCondVisibility("Window.IsActive(10004)")
addonBrowser = xbmc.getCondVisibility("Window.IsActive(10040)")
profiles = xbmc.getCondVisibility("Window.IsActive(10034)")
# Check if we are in any of the restricted sections
if not systemSettings and not addonBrowser and not profiles:
log("NavigationRestrictions: Not is restricted system settings")
return
# If we have already allowed the user to change settings, no need to check again
# Check if we are still in the allowed time limit to edit
if int(time.time()) < self.canChangeSettings:
return
# Need to make sure this user has access to change the settings
pinDB = PinSentryDB()
securityLevel = pinDB.getPluginSecurityLevel('PinSentry')
del pinDB
if securityLevel < 1:
# If the user hasn't reset the permissions, then set it to the highest
# security level available
securityLevel = Settings.getSettingsSecurityLevel()
log("NavigationRestrictions: Settings screen requires security level %d" % securityLevel)
# Check if we have already cached the pin number and at which level
if PinSentry.getCachedPinLevel() >= securityLevel:
log("NavigationRestrictions: Already cached pin at level %d, allowing access" % PinSentry.getCachedPinLevel())
return
# Before we prompt the user we need to close the dialog, otherwise the pin
# dialog will appear behind it
xbmc.executebuiltin("Dialog.Close(all, true)", True)
# Prompt the user for the pin, returns True if they knew it
if PinSentry.promptUserForPin(securityLevel):
log("NavigationRestrictions: Allowed access to settings")
# Allow the user 5 minutes to change the settings
self.canChangeSettings = int(time.time()) + 300
xbmcgui.Dialog().notification(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32110).encode('utf-8'), __icon__, 3000, False)
else:
log("NavigationRestrictions: Not allowed access to settings which has security level %d" % securityLevel)
self.canChangeSettings = False
PinSentry.displayInvalidPinMessage(securityLevel)
# Return the user to the home page as they should not be here
xbmc.executebuiltin("ActivateWindow(home)", True)
示例3: checkSettings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getSettingsSecurityLevel [as 别名]
def checkSettings(self):
# Check if we are in the Addon Information page (which can be used to disable the addon)
# or the actual setting page
addonSettings = xbmc.getCondVisibility("Window.IsActive(10140)")
addonInformation = xbmc.getCondVisibility("Window.IsActive(10146)")
if not addonSettings and not addonInformation:
# If not looking at an info or settings page, and the time for
# allowed edits has ended, then reset it
if self.canChangeSettings > 0:
# If we have reached the home page, reset the timer
if xbmc.getCondVisibility("Window.IsVisible(home)"):
self.canChangeSettings = 0
elif time.time() > self.canChangeSettings:
self.canChangeSettings = 0
return
# Check if the addon is the PinSentry addon
addonId = xbmc.getInfoLabel("ListItem.Property(Addon.ID)")
if 'script.pinsentry' not in addonId:
self.canChangeSettings = 0
return
# If we have already allowed the user to change settings, no need to check again
# Check if we are still in the allowed time limit to edit
if int(time.time()) < self.canChangeSettings:
return
# Need to make sure this user has access to change the settings
pinDB = PinSentryDB()
securityLevel = pinDB.getPluginSecurityLevel('PinSentry')
del pinDB
if securityLevel < 1:
# If the user hasn't reset the permissions, then set it to the highest
# security level available
securityLevel = Settings.getSettingsSecurityLevel()
log("NavigationRestrictions: Settings screen requires security level %d" % securityLevel)
# Check if we have already cached the pin number and at which level
if PinSentry.getCachedPinLevel() >= securityLevel:
log("NavigationRestrictions: Already cached pin at level %d, allowing access" % PinSentry.getCachedPinLevel())
return
# Before we prompt the user we need to close the dialog, otherwise the pin
# dialog will appear behind it
xbmc.executebuiltin("Dialog.Close(all, true)", True)
# Prompt the user for the pin, returns True if they knew it
if PinSentry.promptUserForPin(securityLevel):
log("NavigationRestrictions: Allowed access to settings")
# Allow the user 5 minutes to change the settings
self.canChangeSettings = int(time.time()) + 300
xbmcgui.Dialog().notification(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32110).encode('utf-8'), __icon__, 3000, False)
# Open the dialogs that should be shown, we don't reopen the Information dialog
# as if we do the Close Dialog will not close it and the pin screen will not show correctly
if addonSettings:
# Open the addon settings dialog
xbmc.executebuiltin("Addon.OpenSettings(script.pinsentry)", False)
else:
log("NavigationRestrictions: Not allowed access to settings which has security level %d" % securityLevel)
self.canChangeSettings = False
PinSentry.displayInvalidPinMessage(securityLevel)