Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.pinsentry" name="PinSentry" version="100.5.0" provider-name="robwebset">
<addon id="script.pinsentry" name="PinSentry" version="100.6.0" provider-name="robwebset">
<requires>
<import addon="xbmc.python" version="2.24.0"/>
<import addon="script.module.simplejson" version="3.3.0"/>
Expand Down Expand Up @@ -36,8 +36,8 @@
<language></language>
<platform>all</platform>
<license>See LICENSE.txt</license>
<forum>http://www.urepo.org/forum/viewtopic.php?t=1763</forum>
<news>Available from the URepo repository</news>
<forum>currently none</forum>
<news>currently none</news>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
Expand Down
20 changes: 18 additions & 2 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,29 @@ def _setList(self, target):
except:
pass

prefix = ''
# Check if the classification is restricting this item
isBlockedByClassification = False
if 'mpaa' in item:
if item['mpaa'] not in [None, ""]:
prefix += 'bC '
isBlockedByClassification = True

# Add a tick if security is set
if item['securityLevel'] != 0:
li.setInfo('video', {'PlayCount': 1})
prefix += 's '
# Not the best display format - but the only way that I can get a number to display
# In the list, the problem is it will display 01:00 - but at least it's something
if Settings.showSecurityLevelInPlugin():
li.setInfo('video', {'Duration': item['securityLevel']})

elif Settings.isHighlightClassificationUnprotectedVideos():
# If the user wishes to see which files are not protected by one of the rules
# currently applied, we put the play signal next to them
prefix += 'u '
if not isBlockedByClassification:
prefix += 'nC '
li.setProperty("TotalTime", "")
li.setProperty("ResumeTime", "1")

Expand All @@ -229,10 +235,15 @@ def _setList(self, target):
# This is the case where the user has forced access to be allowed, this
# is useful if you have classification enabled and you want to allow a
# given video for a classification to be unprotected
prefix += 'or '
li.setProperty("TotalTime", "")
li.setProperty("ResumeTime", "1")

li.setProperty("Fanart_Image", item['fanart'])
if prefix:
prefix = '(' + prefix.strip() + ') '

li.setLabel(prefix + title)
url = self._build_url({'mode': 'setsecurity', 'level': item['securityLevel'], 'type': target, 'title': title, 'id': dbid, 'classificationBlocked': str(isBlockedByClassification)})
xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=False)

Expand Down Expand Up @@ -639,6 +650,10 @@ def setSecurity(self, type, title, id, oldLevel, classBlocked=False, forceLevel=
if numLevels > 1 or classBlocked:
# Need to prompt the user to see which pin they are trying to set
displayNameList = []

# Add the option to allow item always
displayNameList.append("%s %s" % (ADDON.getLocalizedString(32211), "-1"))

# Add the option to turn it off
displayNameList.append("%s %s" % (ADDON.getLocalizedString(32211), ADDON.getLocalizedString(32013)))
for i in range(1, numLevels + 1):
Expand All @@ -656,7 +671,7 @@ def setSecurity(self, type, title, id, oldLevel, classBlocked=False, forceLevel=
select = xbmcgui.Dialog().select(ADDON.getLocalizedString(32001), displayNameList)

if select != -1:
level = select
level = select - 1 # because first element is now -1 (because of to allow item always)
if classBlocked and (select >= (len(displayNameList) - 1)):
level = -1
log("Setting security level to %d" % level)
Expand Down Expand Up @@ -703,7 +718,8 @@ def setSecurity(self, type, title, id, oldLevel, classBlocked=False, forceLevel=
self._setBulkSecurity(type, level)

xbmc.executebuiltin("Dialog.Close(busydialog)")
xbmc.executebuiltin("Container.Refresh")
# longer lists always start from the beginning. crude workaround:
#xbmc.executebuiltin("Container.Refresh")

# Sets the security details on all the Movies in a given Movie Set
def _setSecurityOnMoviesInMovieSets(self, setid, level):
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Class to set the background while a pin is prompted for
class Background(xbmcgui.WindowXML):
BACKGOUND_IMAGE_ID = 3004
BACKGROUND_IMAGE_ID = 3004

@staticmethod
def createBackground():
Expand All @@ -29,5 +29,5 @@ def onInit(self):

if bgImage is not None:
log("Background: Setting background image to %s" % bgImage)
bgImageCtrl = self.getControl(Background.BACKGOUND_IMAGE_ID)
bgImageCtrl = self.getControl(Background.BACKGROUND_IMAGE_ID)
bgImageCtrl.setImage(bgImage)
2 changes: 1 addition & 1 deletion resources/lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,14 @@ class Settings():

@staticmethod
def reloadSettings():
global ADDON
# Before loading the new settings save off the length of the pin
# this means that if the length of the pin has changed and the actual
# pin value has not, we can clear the pin value
pinLength = Settings.getPinLength()
pinValue = ADDON.getSetting("pinValue")

# Force the reload of the settings to pick up any new values
global ADDON
ADDON = xbmcaddon.Addon(id='script.pinsentry')

if Settings.isPinSet():
Expand Down
2 changes: 1 addition & 1 deletion resources/skins/Default/720p/pinsentry-background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<posy>0</posy>
<width>1280</width>
<height>720</height>
<texture>screensaver-black.png</texture>
<texture>pinsentry-black.png</texture>
</control>
<control type="image" id="3004">
<description>Background Image</description>
Expand Down
50 changes: 29 additions & 21 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class PinSentry():
@staticmethod
def isPinSentryEnabled():
# Check if the Pin is set, as no point prompting if it is not
if (not Settings.isPinSet()) or (not Settings.isPinActive()):
# also check correct level
if (not Settings.isPinSet(Settings.getNumberOfLevels())) or (not Settings.isPinActive()):
return False
return True

Expand Down Expand Up @@ -69,7 +70,7 @@ def getCachedPinLevel():
return PinSentry.pinLevelCached

@staticmethod
def promptUserForPin(requiredLevel=1):
def promptUserForPin(requiredLevel=1, showBackgroundLonger = False):
userHasAccess = True

# Set the background
Expand All @@ -81,15 +82,20 @@ def promptUserForPin(requiredLevel=1):
numberpad = NumberPad.createNumberPad()
numberpad.doModal()

# Remove the background if we had one
if background is not None:
background.close()
del background

# Get the code that the user entered
enteredPin = numberpad.getPin()
del numberpad

# quick workaround for not showing the pin in the time line when entering it
# TODO: make it configureable?
if showBackgroundLonger:
xbmc.sleep(3000)

# Remove the background if we had one
if background is not None:
background.close()
del background

# Find out what level this pin gives access to
# This will be the highest level
pinMatchLevel = Settings.getSecurityLevelForPin(enteredPin)
Expand Down Expand Up @@ -367,7 +373,7 @@ def onPlayBackStarted(self):
log("PinSentryPlayer: Paused video to check if OK to play")

# Prompt the user for the pin, returns True if they knew it
if PinSentry.promptUserForPin(securityLevel):
if PinSentry.promptUserForPin(securityLevel, True):
log("PinSentryPlayer: Resuming video")
# Pausing again will start the video playing again
if muted:
Expand Down Expand Up @@ -497,7 +503,7 @@ def checkMovieSets(self):
return

# Prompt the user for the pin, returns True if they knew it
if PinSentry.promptUserForPin(securityLevel):
if PinSentry.promptUserForPin(securityLevel, True):
log("NavigationRestrictions: Allowed access to movie set %s" % moveSetName)
else:
log("NavigationRestrictions: Not allowed access to movie set %s which has security level %d" % (moveSetName, securityLevel))
Expand Down Expand Up @@ -1102,18 +1108,20 @@ def shutdown(self, reason=0):
navRestrictions = NavigationRestrictions()
pvrMonitor = PvrMonitor()

displayNotice = True
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Addons.GetAddonDetails", "params": { "addonid": "repository.urepo", "properties": ["enabled", "broken", "name", "author"] }, "id": 1}')
json_response = json.loads(json_query)

if ("result" in json_response) and ('addon' in json_response['result']):
addonItem = json_response['result']['addon']
if (addonItem['enabled'] is True) and (addonItem['broken'] is False) and (addonItem['type'] == 'xbmc.addon.repository') and (addonItem['addonid'] == 'repository.urepo'):
displayNotice = False

if displayNotice:
xbmc.executebuiltin('Notification("URepo Repository Required","www.urepo.org",10000,%s)' % ADDON.getAddonInfo('icon'))
else:
# displayNotice = True
# json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Addons.GetAddonDetails", "params": { "addonid": "repository.urepo", "properties": ["enabled", "broken", "name", "author"] }, "id": 1}')
# json_response = json.loads(json_query)

# as long as there is no repository:
# if ("result" in json_response) and ('addon' in json_response['result']):
# addonItem = json_response['result']['addon']
# if (addonItem['enabled'] is True) and (addonItem['broken'] is False) and (addonItem['type'] == 'xbmc.addon.repository') and (addonItem['addonid'] == 'repository.urepo'):
# displayNotice = False
#
# if displayNotice:
# xbmc.executebuiltin('Notification("URepo Repository Required","www.urepo.org",10000,%s)' % ADDON.getAddonInfo('icon'))
# else:
if True:
loopsUntilUserControlCheck = 0
while (not xbmc.abortRequested):
# There are two types of startup, the first is a genuine startup when
Expand Down
2 changes: 1 addition & 1 deletion wiki.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ After install you need to:
* Enable which videos you want the pin to be displayed for (Either via Settings, Programs->PinSenty or Videos->Addons->PinSentry)
<br />
<br />
== Pin Contol ==
== Pin Control ==
Whenever a user selects an item that has been protected by PinSentry they will be prompted with a dialog like the following:
<br />
[[https://github.com/robwebset/repository.robwebset/raw/master/script.pinsentry/images/PinSentry-PinDialog1.JPG|200px]]
Expand Down