from Components.Sources.Source import Source
from Components.config import config
+import os
class LocationsAndTags(Source):
CURRLOCATION = 0
LOCATIONS = 1
TAGS = 2
+ ADDLOCATION = 3
+ REMOVELOCATION = 4
def __init__(self, session, func):
self.func = func
self.result = self.getLocations()
elif self.func is self.TAGS:
self.result = self.getTags()
+ elif self.func is self.ADDLOCATION:
+ self.result = self.addLocation(cmd)
+ elif self.func is self.REMOVELOCATION:
+ self.result = self.removeLocation(cmd)
else:
self.result = False
tags = ()
return tags
+ def addLocation(self, param):
+ print "[WebComponents.LocationsAndTags] addLocation: ", param
+ if param['dirname'] is None:
+ return ( False, "Missing Parameter: dirname" )
+ dirname = param['dirname']
+ if len(dirname) == 0:
+ return ( False, "Missing value for parameter dirname" )
+ if not dirname.endswith("/"):
+ dirname += "/"
+ if not os.path.exists(dirname):
+ createFolder = False
+ if param['createFolder'] is not None:
+ if param['createFolder'] == "1":
+ try:
+ createFolder = True
+ os.makedirs(dirname)
+ except OSError:
+ return ( False, "Path %s can not be created" %(dirname) )
+ if not createFolder:
+ return ( False, "Path %s does not exist" %(dirname) )
+ bookmarks = config.movielist.videodirs.value[:] or []
+ if dirname in bookmarks:
+ return ( False, "Location '%s' is already existing" %(dirname) )
+ bookmarks.append(dirname)
+ config.movielist.videodirs.value = bookmarks
+ config.movielist.videodirs.save()
+ return ( True, "Location '%s' added successfully" % (dirname) )
+
+ def removeLocation(self, param):
+ print "[WebComponents.LocationsAndTags] removeLocation: ", param
+ if len(param) == 0:
+ return ( False, "Missing value for parameter dirname" )
+ dirname = param
+ if not dirname.endswith("/"):
+ dirname += "/"
+ bookmarks = config.movielist.videodirs.value[:] or []
+ if dirname in bookmarks:
+ bookmarks.remove(dirname)
+ config.movielist.videodirs.value = bookmarks
+ config.movielist.videodirs.save()
+ return ( True, "Location '%s' removed successfully" % (dirname) )
+ else:
+ return ( False, "Location '%s' does not exist" %(dirname) )
+
def getText(self):
self.handleCommand(None)
-
if self.result:
return str(self.result)
else:
--- /dev/null
+from Components.Sources.Source import Source
+from Components.PluginComponent import plugins
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS
+
+class ReadPluginList(Source):
+ def __init__(self, session):
+ Source.__init__(self)
+ self.session = session
+
+ def command(self):
+ print "[WebComponents.ReadPluginList] readPluginList"
+
+ plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
+ return ( True, "List of Plugins has been read" )
+
+ result = property(command)
ugly, but necessary :(
"""
+class ReadPluginListWebScreen(WebScreen):
+ def __init__(self, session, request):
+ WebScreen.__init__(self, session, request)
+ from WebComponents.Sources.ReadPluginList import ReadPluginList
+ self["ReadPluginList"] = ReadPluginList(session)
+
class LocationsAndTagsWebScreen(WebScreen):
def __init__(self, session, request):
WebScreen.__init__(self, session, request)
self["CurrentLocation"] = LocationsAndTags(session, LocationsAndTags.CURRLOCATION)
self["Locations"] = LocationsAndTags(session, LocationsAndTags.LOCATIONS)
+ self["AddLocation"] = LocationsAndTags(session, LocationsAndTags.ADDLOCATION)
+ self["RemoveLocation"] = LocationsAndTags(session, LocationsAndTags.REMOVELOCATION)
self["Tags"] = LocationsAndTags(session, LocationsAndTags.TAGS)
class EpgWebScreen(WebScreen):
self["ImageVersion"] = StaticText(about.getVersionString())
self["WebIfVersion"] = StaticText(config.plugins.Webinterface.version.value)
self["FpVersion"] = StaticText(str(getFPVersion()))
- self["DeviceName"] = StaticText(hw.get_device_name())
\ No newline at end of file
+ self["DeviceName"] = StaticText(hw.get_device_name())
--- /dev/null
+<e2:screen name="LocationsAndTagsWebScreen"><?xml version="1.0" encoding="UTF-8"?>
+<e2:element source="AddLocation" id="dirname,createFolder">
+ <e2:convert type="web:Null" />
+</e2:element>
+<e2simplexmlresult>
+ <e2state><e2:element source="AddLocation"><e2:convert type="SimpleResult">Result</e2:convert><e2:convert type="web:TextToHTML" /></e2:element></e2state>
+ <e2statetext><e2:element source="AddLocation"><e2:convert type="SimpleResult">ResultText</e2:convert><e2:convert type="web:TextToHTML" /></e2:element></e2statetext>
+</e2simplexmlresult>
+</e2:screen>
--- /dev/null
+<e2:screen name="ReadPluginListWebScreen"><?xml version="1.0" encoding="UTF-8"?>
+<e2:element source="ReadPluginList">
+ <e2:convert type="web:Null" />
+</e2:element>
+<e2simplexmlresult>
+ <e2state><e2:element source="ReadPluginList"><e2:convert type="SimpleResult">Result</e2:convert><e2:convert type="web:TextToHTML" /></e2:element></e2state>
+ <e2statetext><e2:element source="ReadPluginList"><e2:convert type="SimpleResult">ResultText</e2:convert><e2:convert type="web:TextToHTML" /></e2:element></e2statetext>
+</e2simplexmlresult>
+</e2:screen>
--- /dev/null
+<e2:screen name="LocationsAndTagsWebScreen"><?xml version="1.0" encoding="UTF-8"?>
+<e2:element source="RemoveLocation" id="dirname">
+ <e2:convert type="web:Null" />
+</e2:element>
+<e2simplexmlresult>
+ <e2state><e2:element source="RemoveLocation"><e2:convert type="SimpleResult">Result</e2:convert><e2:convert type="web:TextToHTML" /></e2:element></e2state>
+ <e2statetext><e2:element source="RemoveLocation"><e2:convert type="SimpleResult">ResultText</e2:convert><e2:convert type="web:TextToHTML" /></e2:element></e2statetext>
+</e2simplexmlresult>
+</e2:screen>