use tabs for indentation, whitespace cleanup
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Mon, 23 Feb 2009 17:52:50 +0000 (17:52 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Mon, 23 Feb 2009 17:52:50 +0000 (17:52 +0000)
36 files changed:
webinterface/src/WebChilds/FileStreamer.py
webinterface/src/WebChilds/IPKG.py
webinterface/src/WebChilds/PlayService.py
webinterface/src/WebChilds/RedirecToCurrentStream.py
webinterface/src/WebChilds/Screengrab.py
webinterface/src/WebChilds/Screenpage.py
webinterface/src/WebChilds/ServiceListSave.py
webinterface/src/WebChilds/Toplevel.py
webinterface/src/WebChilds/Uploader.py
webinterface/src/WebComponents/Converter/HddInfo.py
webinterface/src/WebComponents/Converter/NetworkInfo.py
webinterface/src/WebComponents/Converter/NetworkInterfaceInfo.py
webinterface/src/WebComponents/Sources/AT.py
webinterface/src/WebComponents/Sources/About.py
webinterface/src/WebComponents/Sources/AudioTracks.py
webinterface/src/WebComponents/Sources/CurrentService.py
webinterface/src/WebComponents/Sources/Hdd.py
webinterface/src/WebComponents/Sources/LocationsAndTags.py
webinterface/src/WebComponents/Sources/MP.py
webinterface/src/WebComponents/Sources/Message.py
webinterface/src/WebComponents/Sources/Network.py
webinterface/src/WebComponents/Sources/ParentControl.py
webinterface/src/WebComponents/Sources/PowerState.py
webinterface/src/WebComponents/Sources/RemoteControl.py
webinterface/src/WebComponents/Sources/RequestData.py
webinterface/src/WebComponents/Sources/ServiceListRecursive.py
webinterface/src/WebComponents/Sources/ServiceListReload.py
webinterface/src/WebComponents/Sources/Settings.py
webinterface/src/WebComponents/Sources/SubServices.py
webinterface/src/WebComponents/Sources/Timer.py
webinterface/src/WebComponents/Sources/Volume.py
webinterface/src/WebComponents/Sources/WAPfunctions.py
webinterface/src/WebIfConfig.py
webinterface/src/__init__.py
webinterface/src/plugin.py
webinterface/src/webif.py

index fa4751b..de0b3be 100644 (file)
@@ -3,42 +3,42 @@ from urllib import unquote_plus
 from os import path as os_path
 
 class FileStreamer(resource.Resource):
-    addSlash = True
-    
-    def render(self, req):
-        try:
-            w1 = req.uri.split("?")[1]
-            w2 = w1.split("&")
-            parts= {}
-            for i in w2:
-                w3 = i.split("=")
-                parts[w3[0]] = w3[1]
-        except:
-            return http.Response(responsecode.OK, stream="no file given with file=???")
-        root = "/hdd/movie/"
-        if parts.has_key("root"):
-            #root = parts["root"].replace("%20"," ")
-            root = unquote_plus(parts["root"])
-        if parts.has_key("file"):
-            #filename = parts["file"].replace("%20"," ")
-            filename = unquote_plus(parts["file"])
-            path = root+filename
-            if os_path.exists(path):
-                s = stream.FileStream(open(path,"r"))
-                type = path.split(".")[-1]
-                header = http_headers.MimeType('video', 'ts')
-                if type == "mp3" or type == "ogg" or type == "wav":
-                    header = http_headers.MimeType('audio', 'x-mpeg')
-                elif type == "avi" or type == "mpg":
-                    header = http_headers.MimeType('video', 'x-msvideo')
-                elif type == "jpg" or type == "jpeg" or type == "jpe":
-                    header = http_headers.MimeType('image', 'jpeg')
-                
-                resp =  http.Response(responsecode.OK, {'Content-type': header},stream=s)
-                resp.headers.addRawHeader('Content-Disposition','attachment; filename="%s"'%filename)
-                return resp
-            else:
-                return http.Response(responsecode.OK, stream="file '%s' was not found"%path)            
-        else:
-            return http.Response(responsecode.OK, stream="no file given with file=???")            
-    
+       addSlash = True
+
+       def render(self, req):
+               try:
+                       w1 = req.uri.split("?")[1]
+                       w2 = w1.split("&")
+                       parts= {}
+                       for i in w2:
+                               w3 = i.split("=")
+                               parts[w3[0]] = w3[1]
+               except:
+                       return http.Response(responsecode.OK, stream="no file given with file=???")
+               root = "/hdd/movie/"
+               if parts.has_key("root"):
+                       #root = parts["root"].replace("%20"," ")
+                       root = unquote_plus(parts["root"])
+               if parts.has_key("file"):
+                       #filename = parts["file"].replace("%20"," ")
+                       filename = unquote_plus(parts["file"])
+                       path = root+filename
+                       if os_path.exists(path):
+                               s = stream.FileStream(open(path,"r"))
+                               type = path.split(".")[-1]
+                               header = http_headers.MimeType('video', 'ts')
+                               if type == "mp3" or type == "ogg" or type == "wav":
+                                       header = http_headers.MimeType('audio', 'x-mpeg')
+                               elif type == "avi" or type == "mpg":
+                                       header = http_headers.MimeType('video', 'x-msvideo')
+                               elif type == "jpg" or type == "jpeg" or type == "jpe":
+                                       header = http_headers.MimeType('image', 'jpeg')
+
+                               resp = http.Response(responsecode.OK, {'Content-type': header},stream=s)
+                               resp.headers.addRawHeader('Content-Disposition','attachment; filename="%s"'%filename)
+                               return resp
+                       else:
+                               return http.Response(responsecode.OK, stream="file '%s' was not found"%path)
+               else:
+                       return http.Response(responsecode.OK, stream="no file given with file=???")
+
index 2a20fbf..df3eb00 100755 (executable)
@@ -3,107 +3,92 @@ from enigma import eConsoleAppContainer
 from twisted.web2 import resource, stream, responsecode, http
 
 class IPKGResource(resource.Resource):
-    IPKG_PATH = "/usr/bin/ipkg"
-    
-    SIMPLECMDS = [ "list", "list_installed", "update", "upgrade" ]
-    PACKAGECMDS = [ "info", "status", "install", "remove" ]
-    FILECMDS = [ "search" ]
-    
-  
-    def render(self, request):
-        self.args = request.args
-        self.command = self.getArg("command")
-        
-        if self.command is not None:
-            
-            if self.command in IPKGResource.SIMPLECMDS:
-                return self.execSimpleCmd()
-            
-            elif self.command in IPKGResource.PACKAGECMDS:
-                return self.execPackageCmd() 
-            
-            elif self.command in IPKGResource.FILECMDS:
-                return self.execFileCmd()
-                
-            else:
-                return self.doErrorPage("Unknown command: ", self.command)
-        else:
-            return self.doIndexPage()
-            
-
-    def buildCmd(self, parms = []):
-        cmd = [IPKGResource.IPKG_PATH, "ipkg", self.command] + parms
-        print "[IPKG.py] cmd: %s" %cmd
-        return cmd
-
-    
-    def execCmd(self, parms = []):
-        cmd = self.buildCmd(parms)
-        return http.Response(responsecode.OK,stream=IPKGConsoleStream(cmd) )
-    
-    
-    def execSimpleCmd(self):
-         return self.execCmd()
-
-
-    def execPackageCmd(self):
-        package = self.getArg("package")
-        if package is not None:
-            return self.execCmd([package])
-        
-        else:
-            return self.doErrorPage("Missing parameter: package")
-        
-        
-    def execFileCmd(self):
-        file = self.getArg("file")
-        if file is not None:
-            return self.execCmd([file])
-        
-        else:
-            return self.doErrorPage("Missing parameter: file")
-        
-
-    def doIndexPage(self):
-        html  = "<html><body>"
-        html += "<h1>Interface to IPKG</h1>"
-        html += "update, ?command=update<br>"
-        html += "upgrade, ?command=upgrade<br>"
-        html += "list_installed, ?command=list_installed<br>"
-        html += "list, ?command=list<br>"
-        html += "search, ?command=search&file=&lt;filename&gt;<br>"
-        html += "info, ?command=search&package=&lt;packagename&gt;<br>"
-        html += "status, ?command=search&package=&lt;packagename&gt;<br>"
-        html += "install, ?command=install&package=&lt;packagename&gt;<br>"
-        html += "remove, ?command=remove&package=&lt;packagename&gt;<br>"
-        html += "</body></html>"
-        return http.Response(responsecode.OK,stream=html)
-
-        
-    def doErrorPage(self, errormsg):
-        return http.Response(responsecode.OK,stream=errormsg)
-    
-    
-    def getArg(self, key):
-        if self.args.has_key(key):
-            return self.args[key][0]
-        else:
-            return None
+       IPKG_PATH = "/usr/bin/ipkg"
+
+       SIMPLECMDS = [ "list", "list_installed", "update", "upgrade" ]
+       PACKAGECMDS = [ "info", "status", "install", "remove" ]
+       FILECMDS = [ "search" ]
+
+       def render(self, request):
+               self.args = request.args
+               self.command = self.getArg("command")
+
+               if self.command is not None:
+                       if self.command in IPKGResource.SIMPLECMDS:
+                               return self.execSimpleCmd()
+                       elif self.command in IPKGResource.PACKAGECMDS:
+                               return self.execPackageCmd()
+                       elif self.command in IPKGResource.FILECMDS:
+                               return self.execFileCmd()
+                       else:
+                               return self.doErrorPage("Unknown command: ", self.command)
+               else:
+                       return self.doIndexPage()
+
+       def buildCmd(self, parms = []):
+               cmd = [IPKGResource.IPKG_PATH, "ipkg", self.command] + parms
+               print "[IPKG.py] cmd: %s" %cmd
+               return cmd
+
+       def execCmd(self, parms = []):
+               cmd = self.buildCmd(parms)
+               return http.Response(responsecode.OK,stream=IPKGConsoleStream(cmd) )
+
+       def execSimpleCmd(self):
+                return self.execCmd()
+
+       def execPackageCmd(self):
+               package = self.getArg("package")
+               if package is not None:
+                       return self.execCmd([package])
+               else:
+                       return self.doErrorPage("Missing parameter: package")
+
+       def execFileCmd(self):
+               file = self.getArg("file")
+               if file is not None:
+                       return self.execCmd([file])
+
+               else:
+                       return self.doErrorPage("Missing parameter: file")
+
+       def doIndexPage(self):
+               html  = "<html><body>"
+               html += "<h1>Interface to IPKG</h1>"
+               html += "update, ?command=update<br>"
+               html += "upgrade, ?command=upgrade<br>"
+               html += "list_installed, ?command=list_installed<br>"
+               html += "list, ?command=list<br>"
+               html += "search, ?command=search&file=&lt;filename&gt;<br>"
+               html += "info, ?command=search&package=&lt;packagename&gt;<br>"
+               html += "status, ?command=search&package=&lt;packagename&gt;<br>"
+               html += "install, ?command=install&package=&lt;packagename&gt;<br>"
+               html += "remove, ?command=remove&package=&lt;packagename&gt;<br>"
+               html += "</body></html>"
+               return http.Response(responsecode.OK,stream=html)
+
+       def doErrorPage(self, errormsg):
+               return http.Response(responsecode.OK,stream=errormsg)
+
+       def getArg(self, key):
+               if self.args.has_key(key):
+                       return self.args[key][0]
+               else:
+                       return None
 
 class IPKGConsoleStream(stream.ProducerStream):
-    def __init__(self, cmd):
-        stream.ProducerStream.__init__(self)
-        self.container = eConsoleAppContainer()
-        
-        self.container.dataAvail.append(self.dataAvail)
-        self.container.appClosed.append(self.cmdFinished)
-        
-        self.container.execute(*cmd)
-
-    
-    def cmdFinished(self, data):
-        self.finish()    
-            
-    
-    def dataAvail(self, data):
-        self.write(data)
+       def __init__(self, cmd):
+               stream.ProducerStream.__init__(self)
+               self.container = eConsoleAppContainer()
+
+               self.container.dataAvail.append(self.dataAvail)
+               self.container.appClosed.append(self.cmdFinished)
+
+               self.container.execute(*cmd)
+
+       def cmdFinished(self, data):
+               self.finish()
+
+       def dataAvail(self, data):
+               self.write(data)
+
index 6ebad1f..e45751f 100755 (executable)
@@ -3,53 +3,54 @@ from twisted.web2 import resource, stream, responsecode, http
 from os import path as os_path
 
 class ServiceplayerResource(resource.Resource):
-    def __init__(self,session):
-        resource.Resource.__init__(self)
-        self.session = session
-        self.oldservice = None
-        
-    def render(self, req):
-        if req.args.has_key("file"):
-            output = self.playFile(req.args['file'][0])
-        elif req.args.has_key("url"):
-            output = self.playURL(req.args['url'][0])
-        elif req.args.has_key("stop"):
-            output = self.stopServicePlay()
-        else:
-            output = True,"unknown command"
-        return http.Response(responsecode.OK,stream=output[1])
-    
-    def playFile(self,path):
-        print "[ServiceplayerResource] playing file",path
-        if os_path.exists(path) is not True:
-            return False,"given path is not existing, %s"%path
-        else:
-            sref = "4097:0:0:0:0:0:0:0:0:0:%s"%path
-            self.startServicePlay(eServiceReference(sref))
-            return True,"playing path started, %s"%path
-        
-    def playURL(self,url):
-        #url= url.replace("%3a",":").replace("%20"," ")
-        #print "[ServiceplayerResource] playing url",url
-        #sref = "4097:0:0:0:0:0:0:0:0:0:%s"%url
-        #self.startServicePlay(eServiceReference(sref))
-        return False,"Not implemented"
-    
-    def startServicePlay(self,esref):
-        print "[ServiceplayerResource] playing sref",esref.toString()
-        csref = self.session.nav.getCurrentlyPlayingServiceReference()
-        if csref is not None:
-            if csref.toString().startswith("4097") is not True:
-                self.oldservice = csref.toString(),csref
-        
-        self.session.nav.stopService()
-        self.session.nav.playService(esref)
-        
-    def stopServicePlay(self):
-        print "[ServiceplayerResource] stopping service",self.oldservice
-        self.session.nav.stopService()
-        if self.oldservice is not None:
-            self.session.nav.playService(self.oldservice[1])
-            return True, "[ServiceplayerResource] stopped, now playing old service, %s"%self.oldservice[0]
-        else:
-            return True, "[ServiceplayerResource] stopped"
\ No newline at end of file
+       def __init__(self,session):
+               resource.Resource.__init__(self)
+               self.session = session
+               self.oldservice = None
+
+       def render(self, req):
+               if req.args.has_key("file"):
+                       output = self.playFile(req.args['file'][0])
+               elif req.args.has_key("url"):
+                       output = self.playURL(req.args['url'][0])
+               elif req.args.has_key("stop"):
+                       output = self.stopServicePlay()
+               else:
+                       output = True,"unknown command"
+               return http.Response(responsecode.OK,stream=output[1])
+
+       def playFile(self,path):
+               print "[ServiceplayerResource] playing file",path
+               if os_path.exists(path) is not True:
+                       return False,"given path is not existing, %s"%path
+               else:
+                       sref = "4097:0:0:0:0:0:0:0:0:0:%s"%path
+                       self.startServicePlay(eServiceReference(sref))
+                       return True,"playing path started, %s"%path
+
+       def playURL(self,url):
+               #url= url.replace("%3a",":").replace("%20"," ")
+               #print "[ServiceplayerResource] playing url",url
+               #sref = "4097:0:0:0:0:0:0:0:0:0:%s"%url
+               #self.startServicePlay(eServiceReference(sref))
+               return False,"Not implemented"
+
+       def startServicePlay(self,esref):
+               print "[ServiceplayerResource] playing sref",esref.toString()
+               csref = self.session.nav.getCurrentlyPlayingServiceReference()
+               if csref is not None:
+                       if csref.toString().startswith("4097") is not True:
+                               self.oldservice = csref.toString(),csref
+
+               self.session.nav.stopService()
+               self.session.nav.playService(esref)
+
+       def stopServicePlay(self):
+               print "[ServiceplayerResource] stopping service",self.oldservice
+               self.session.nav.stopService()
+               if self.oldservice is not None:
+                       self.session.nav.playService(self.oldservice[1])
+                       return True, "[ServiceplayerResource] stopped, now playing old service, %s"%self.oldservice[0]
+               else:
+                       return True, "[ServiceplayerResource] stopped"
+
index a31c9bc..484f767 100644 (file)
@@ -2,18 +2,18 @@ from twisted.web2 import resource
 from ServiceReference import ServiceReference
 
 class RedirecToCurrentStreamResource(resource.Resource):
-    """
-        used to redirect the client to the streamproxy with the current service tuned on TV
-    """
-    def __init__(self,session):
-        self.session = session
-        resource.Resource.__init__(self)
+       """
+               used to redirect the client to the streamproxy with the current service tuned on TV
+       """
+       def __init__(self,session):
+               self.session = session
+               resource.Resource.__init__(self)
 
-    def render(self, req):
-        currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()
-        if currentServiceRef is not None:
-            sref = currentServiceRef.toString()
-        else:
-            sref = "N/A"
-        return http.RedirectResponse("http://%s:8001/%s"%(req.host,sref))
+       def render(self, req):
+               currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()
+               if currentServiceRef is not None:
+                       sref = currentServiceRef.toString()
+               else:
+                       sref = "N/A"
+               return http.RedirectResponse("http://%s:8001/%s"%(req.host,sref))
 
index 68c9c7a..ff80a7b 100755 (executable)
@@ -5,113 +5,110 @@ from twisted.web2 import resource, stream, responsecode, http, http_headers
 from os import path as os_path, remove as os_remove
 
 class GrabResource(resource.Resource):
-    '''
-        this is a interface to Seddis AiO Dreambox Screengrabber
-    '''
-    GRAB_BIN = '/usr/bin/grab'
-    SPECIAL_ARGS = ['format', 'filename', 'save'] 
-    
-    def render(self, req):
-        self.baseCmd = ['/usr/bin/grab', '/usr/bin/grab']
-        self.args = []
-        
-        # some presets
-        filename = 'screenshot'
-        imageformat = 'bmp'
-        osdOnly = False
-        videoOnly = False
-        save = False
-        
-        for key, value in req.args.items():
-            if key in GrabResource.SPECIAL_ARGS:                
-                
-                if key == 'format':                
-                    format = req.args['format'][0]
-                    
-                    if format == 'png':
-                        #-p produce png files instead of bmp
-                        imageformat = format
-                        self.args.append('-p')
-                    elif format == 'jpg':
-                        #-j (quality) produce jpg files instead of bmp
-                    
-                        imageformat = format
-                        self.args.append('-j')
-                        #Quality Setting                    
-                        if req.args.has_key("jpgquali"):
-                            self.args.append("%s" %(req.args["jpgquali"][0]) )
-                        else:                            
-                            self.args.append('80')
-                
-                elif key == 'filename':
-                    filename = req.args['filename'][0]
-                
-                elif key == 'save':
-                    save = True
-                                                
-            else:
-                if key == "o" and videoOnly is True:
-                    continue
-                if key == "v" and osdOnly is True:
-                    continue                                        
-                                
-                self.args.append("-%s" %key )
-                
-                if value is not None:
-                    if len(value[0]) > 0:
-                        self.args.append("%s" %value[0])
-                
-
-        if not os_path.exists(self.GRAB_BIN):
-            return http.Response(responsecode.OK,stream='Grab is not installed at %s. Please install package aio-grab.' %self.GRAB_BIN)
-        else:
-            headers = http_headers.Headers()
-            headers.addRawHeader('Content-Disposition', 'inline; filename=screenshot.%s;' %imageformat)
-            headers.addRawHeader('Content-Type','image/%s' %imageformat)
-            
-            filename = filename+imageformat
-            self.args.append(filename)
-            cmd = self.baseCmd + self.args
-            
-            return http.Response(responsecode.OK,headers,stream=GrabStream(cmd, filename, save))
-       
+       '''
+               this is a interface to Seddis AiO Dreambox Screengrabber
+       '''
+       GRAB_BIN = '/usr/bin/grab'
+       SPECIAL_ARGS = ['format', 'filename', 'save']
+
+       def render(self, req):
+               self.baseCmd = ['/usr/bin/grab', '/usr/bin/grab']
+               self.args = []
+
+               # some presets
+               filename = 'screenshot'
+               imageformat = 'bmp'
+               osdOnly = False
+               videoOnly = False
+               save = False
+
+               for key, value in req.args.items():
+                       if key in GrabResource.SPECIAL_ARGS:
+                               if key == 'format':
+                                       format = req.args['format'][0]
+
+                                       if format == 'png':
+                                               #-p produce png files instead of bmp
+                                               imageformat = format
+                                               self.args.append('-p')
+                                       elif format == 'jpg':
+                                               #-j (quality) produce jpg files instead of bmp
+
+                                               imageformat = format
+                                               self.args.append('-j')
+                                               #Quality Setting
+                                               if req.args.has_key("jpgquali"):
+                                                       self.args.append("%s" %(req.args["jpgquali"][0]) )
+                                               else:
+                                                       self.args.append('80')
+
+                               elif key == 'filename':
+                                       filename = req.args['filename'][0]
+                               elif key == 'save':
+                                       save = True
+                       else:
+                               if key == "o" and videoOnly is True:
+                                       continue
+                               if key == "v" and osdOnly is True:
+                                       continue
+
+                               self.args.append("-%s" %key )
+
+                               if value is not None:
+                                       if len(value[0]) > 0:
+                                               self.args.append("%s" %value[0])
+
+               if not os_path.exists(self.GRAB_BIN):
+                       return http.Response(responsecode.OK,stream='Grab is not installed at %s. Please install package aio-grab.' %self.GRAB_BIN)
+               else:
+                       headers = http_headers.Headers()
+                       headers.addRawHeader('Content-Disposition', 'inline; filename=screenshot.%s;' %imageformat)
+                       headers.addRawHeader('Content-Type','image/%s' %imageformat)
+
+                       filename = filename+imageformat
+                       self.args.append(filename)
+                       cmd = self.baseCmd + self.args
+
+                       return http.Response(responsecode.OK,headers,stream=GrabStream(cmd, filename, save))
+
 class GrabStream(stream.ProducerStream):
-    '''
-        used to start the grab-bin in the console in the background
-        while this takes some time, the browser must wait until the grabis finished
-    '''
-    def __init__(self, cmd, target=None, save=False):
-        self.target = target
-        self.save = save
-        self.output = ''
-        stream.ProducerStream.__init__(self)
-
-        self.container = eConsoleAppContainer()
-        self.container.appClosed.append(self.cmdFinished)
-        self.container.dataAvail.append(self.dataAvail)
-        
-        print '[Screengrab.py] starting AiO grab with cmdline:', cmd
-        self.container.execute(*cmd)
-
-    def cmdFinished(self, data):
-        print '[Screengrab.py] cmdFinished'
-        if int(data) is 0 and self.target is not None:
-            try:
-                fp = open(self.target)
-                self.write(fp.read())
-                fp.close()
-                if self.save is False:
-                    os_remove(self.target)
-                    print '[Screengrab.py] %s removed' %self.target
-            except Exception,e:
-                self.write('Internal error while reading target file')
-        elif int(data) is 0 and self.target is None:
-            self.write(self.output)
-        elif int(data) is 1:
-            self.write(self.output)
-        else:
-            self.write('Internal error')
-        self.finish()
-
-    def dataAvail(self, data):
-        print '[Screengrab.py] data Available ', data
+       '''
+               used to start the grab-bin in the console in the background
+               while this takes some time, the browser must wait until the grabis finished
+       '''
+       def __init__(self, cmd, target=None, save=False):
+               self.target = target
+               self.save = save
+               self.output = ''
+               stream.ProducerStream.__init__(self)
+
+               self.container = eConsoleAppContainer()
+               self.container.appClosed.append(self.cmdFinished)
+               self.container.dataAvail.append(self.dataAvail)
+
+               print '[Screengrab.py] starting AiO grab with cmdline:', cmd
+               self.container.execute(*cmd)
+
+       def cmdFinished(self, data):
+               print '[Screengrab.py] cmdFinished'
+               if int(data) is 0 and self.target is not None:
+                       try:
+                               fp = open(self.target)
+                               self.write(fp.read())
+                               fp.close()
+                               if self.save is False:
+                                       os_remove(self.target)
+                                       print '[Screengrab.py] %s removed' %self.target
+                       except Exception,e:
+                               self.write('Internal error while reading target file')
+               elif int(data) is 0 and self.target is None:
+                       self.write(self.output)
+               elif int(data) is 1:
+                       self.write(self.output)
+               else:
+                       self.write('Internal error')
+               self.finish()
+
+       def dataAvail(self, data):
+               print '[Screengrab.py] data Available ', data
+
index af197ad..df13ed4 100755 (executable)
@@ -4,10 +4,9 @@ from Plugins.Extensions.WebInterface import webif
 
 import os
 
-
 """
-    define all files in /web to send no  XML-HTTP-Headers here
-    all files listed here will get an Content-Type: application/xhtml+xml charset: UTF-8
+       define all files in /web to send no XML-HTTP-Headers here
+       all files listed here will get an Content-Type: application/xhtml+xml charset: UTF-8
 """
 AppTextHeaderFiles = ['stream.m3u.xml','ts.m3u.xml','streamcurrent.m3u.xml','movielist.m3u.xml','services.m3u.xml',]
 
@@ -18,48 +17,49 @@ AppTextHeaderFiles = ['stream.m3u.xml','ts.m3u.xml','streamcurrent.m3u.xml','mov
 TextHtmlHeaderFiles = ['wapremote.xml','stream.xml',]
 
 """
-    define all files in /web to send no  XML-HTTP-Headers here
-    all files listed here will get an Content-Type: text/html charset: UTF-8
+       define all files in /web to send no XML-HTTP-Headers here
+       all files listed here will get an Content-Type: text/html charset: UTF-8
 """
 NoExplicitHeaderFiles = ['getpid.xml','tvbrowser.xml',]
 
 class ScreenPage(resource.Resource):
-    def __init__(self, session,path):
-        self.session = session
-        self.path = path
+       def __init__(self, session,path):
+               self.session = session
+               self.path = path
+
+       def render(self, req):
+               #if self.session is not True:
+               #       return http.Response(responsecode.OK, stream="please wait until enigma has booted")
 
-    def render(self, req):
-        #if self.session is not True:
-        #    return http.Response(responsecode.OK, stream="please wait until enigma has booted")
+               class myProducerStream(stream.ProducerStream):
+                       def __init__(self):
+                               stream.ProducerStream.__init__(self)
+                               self.closed_callback = None
 
-        class myProducerStream(stream.ProducerStream):
-            def __init__(self):
-                stream.ProducerStream.__init__(self)
-                self.closed_callback = None
+                       def close(self):
+                               if self.closed_callback:
+                                       self.closed_callback()
+                                       self.closed_callback = None
+                               stream.ProducerStream.close(self)
 
-            def close(self):
-                if self.closed_callback:
-                    self.closed_callback()
-                    self.closed_callback = None
-                stream.ProducerStream.close(self)
+               if os.path.isfile(self.path):
+                       s=myProducerStream()
+                       webif.renderPage(s, self.path, req, self.session) # login?
+                       if self.path.split("/")[-1] in AppTextHeaderFiles:
+                               return http.Response(responsecode.OK,{'Content-type': http_headers.MimeType('application', 'text', (('charset', 'UTF-8'),))},stream=s)
+                       elif self.path.split("/")[-1] in TextHtmlHeaderFiles or (self.path.endswith(".html.xml") and self.path.split("/")[-1] != "updates.html.xml"):
+                               return http.Response(responsecode.OK,{'Content-type': http_headers.MimeType('text', 'html', (('charset', 'UTF-8'),))},stream=s)
+                       elif self.path.split("/")[-1] in NoExplicitHeaderFiles:
+                               return http.Response(responsecode.OK,stream=s)
+                       else:
+                               return http.Response(responsecode.OK,{'Content-type': http_headers.MimeType('application', 'xhtml+xml', (('charset', 'UTF-8'),))},stream=s)
+               else:
+                       return http.Response(responsecode.NOT_FOUND)
 
-        if os.path.isfile(self.path):
-            s=myProducerStream()
-            webif.renderPage(s, self.path, req, self.session)  # login?
-            if self.path.split("/")[-1] in AppTextHeaderFiles:
-                return http.Response(responsecode.OK,{'Content-type': http_headers.MimeType('application', 'text', (('charset', 'UTF-8'),))},stream=s)
-            elif self.path.split("/")[-1] in TextHtmlHeaderFiles or (self.path.endswith(".html.xml") and self.path.split("/")[-1] != "updates.html.xml"):
-                return http.Response(responsecode.OK,{'Content-type': http_headers.MimeType('text', 'html', (('charset', 'UTF-8'),))},stream=s)
-            elif self.path.split("/")[-1] in NoExplicitHeaderFiles:
-                return http.Response(responsecode.OK,stream=s)
-            else:
-                return http.Response(responsecode.OK,{'Content-type': http_headers.MimeType('application', 'xhtml+xml', (('charset', 'UTF-8'),))},stream=s)
-        else:
-            return http.Response(responsecode.NOT_FOUND)
+       def locateChild(self, request, segments):
+               path = self.path+'/'+'/'.join(segments)
+               if path[-1:] == "/":
+                       path += "index.html"
+               path +=".xml"
+               return ScreenPage(self.session,path), ()
 
-    def locateChild(self, request, segments):
-        path = self.path+'/'+'/'.join(segments)
-        if path[-1:] == "/":
-            path += "index.html"
-        path +=".xml"
-        return ScreenPage(self.session,path), ()
index ee98a5e..f4f71ce 100644 (file)
@@ -6,203 +6,200 @@ from xml.dom.minidom import parseString as xml_dom_minidom_parseString
 from urllib import unquote as urllib_unquote
 ##########################
 class ServiceList(resource.Resource):
-    def __init__(self,session):
-        self.session = session
-        resource.Resource.__init__(self)
-        self.putChild("reload",ServiceListReload())
-        self.putChild("save",ServiceListSave())
-        
+       def __init__(self,session):
+               self.session = session
+               resource.Resource.__init__(self)
+               self.putChild("reload",ServiceListReload())
+               self.putChild("save",ServiceListSave())
+
 class ServiceListReload(resource.Resource):
-    def render(self, req):
-        headers = http_headers.Headers()
-        try:
-            db = eDVBDB.getInstance()
-            #db.reloadServicelist() # reloading only lamedb
-            db.reloadBouquets() # reloading *.tv and *.radio
-            return http.Response(responsecode.OK,headers,stream="Servicelist reloaded")
-        except Exception,e:
-            return http.Response(responsecode.OK,headers,stream="Error while loading Servicelist!")
-        
-        
+       def render(self, req):
+               headers = http_headers.Headers()
+               try:
+                       db = eDVBDB.getInstance()
+                       #db.reloadServicelist() # reloading only lamedb
+                       db.reloadBouquets() # reloading *.tv and *.radio
+                       return http.Response(responsecode.OK,headers,stream="Servicelist reloaded")
+               except Exception,e:
+                       return http.Response(responsecode.OK,headers,stream="Error while loading Servicelist!")
+
 class ServiceListSave(resource.PostableResource):
-    TYPE_TV = 0
-    TYPE_RADIO = 1
-    EXTENSIONS = ['.tv','.radio']
-    DIR = "/etc/enigma2/"
-    undefinded_tag = "%n/a%"
-    undefinded_and = "%und%"
-    
-    def http_POST(self, request):
-        """
-        overwriten, because we need a custom parsePOSTData
-        """
-        return self.parsePOSTData(request).addCallback(
-            lambda res: self.render(request))
-        
-    def parsePOSTData(self,request):
-        """
-        overwriten, because we need to set higher values to fileupload.parse_urlencoded
-        """
-        if request.stream.length == 0:
-            return defer.succeed(None)
-    
-        parser = None
-        ctype = request.headers.getHeader('content-type')
-        print "#"*20,ctype
-        if ctype is None:
-            return defer.succeed(None)
-    
-        def updateArgs(data):
-            args = data
-            request.args.update(args)
-    
-        def updateArgsAndFiles(data):
-            args, files = data
-            request.args.update(args)
-            request.files.update(files)
-    
-        def error(f):
-            f.trap(fileupload.MimeFormatError)
-            raise http.HTTPError(responsecode.BAD_REQUEST)
-    
-        if ctype.mediaType == 'application' and ctype.mediaSubtype == 'x-www-form-urlencoded':
-            d = fileupload.parse_urlencoded(request.stream, maxMem=100*1024*1024, maxFields=1024)
-            d.addCallbacks(updateArgs, error)
-            return d
-        else:
-            raise http.HTTPError(responsecode.BAD_REQUEST)
-
-    def render(self, req):
-        XML_HEADER = {'Content-type': http_headers.MimeType('application', 'xhtml+xml', (('charset', 'UTF-8'),))}
-        
-        try:
-            content = req.args['content'][0].replace("<n/a>",self.undefinded_tag).replace('&',self.undefinded_and)            
-            if content.find('undefined')!=-1:
-                fp = open('/tmp/savedlist','w')
-                fp.write(content)
-                fp.close()
-                result = """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n
-                        <e2simplexmlresult>\n
-                            <e2state>false</e2state>
-                            <e2statetext>found string 'undefined in XML DATA... a copie was saved to '/tmp/savedlist'.</e2statetext>
-                        </e2simplexmlresult>\n
-                     """    
-                return http.Response(responsecode.OK,XML_HEADER,stream=result)
-
-            (bouqets_tv,bouqets_radio) = self.parseXML( content)
-            #print "having num %i TV Bouqets and num %i Radio Bouqets" %(len(bouqets_tv),len(bouqets_radio))
-                
-            #deleting old files
-            os.system("rm "+self.DIR+"userbouquet*.tv ")
-            os.system("rm "+self.DIR+"userbouquet*.radio ")
-            os.system("rm "+self.DIR+"bouquets.tv ")
-            os.system("rm "+self.DIR+"bouquets.radio ")
-                
-            #writing new files
-            self.createIndexFile(self.TYPE_TV, bouqets_tv)
-            counter = 0
-            for bouqet in bouqets_tv:
-                self.createBouqetFile(self.TYPE_TV, bouqet['bname'], bouqet['services'],counter)
-                counter = counter +1
-            
-            self.createIndexFile(self.TYPE_RADIO, bouqets_radio)
-            counter = 0
-            for bouqet in bouqets_radio:
-                self.createBouqetFile(self.TYPE_RADIO, bouqet['bname'], bouqet['services'],counter)
-                counter = counter +1
-                
-            # reloading *.tv and *.radio
-            db = eDVBDB.getInstance()
-            db.reloadBouquets() 
-            print "servicelists reloaded"
-            result = """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n
-                        <e2simplexmlresult>\n
-                            <e2state>true</e2state>
-                            <e2statetext>servicelist saved with %i TV und %i Radio Bouquets and was reloaded</e2statetext>
-                        </e2simplexmlresult>\n
-                     """ %(len(bouqets_tv),len(bouqets_radio))       
-            return http.Response(responsecode.OK,XML_HEADER,stream=result)
-        except Exception,e:
-            print e
-            result = """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n
-                        <e2simplexmlresult>\n
-                            <e2state>false</e2state>
-                            <e2statetext>%s</e2statetext>
-                        </e2simplexmlresult>\n
-                     """%e        
-            return http.Response(responsecode.OK,XML_HEADER,stream=result)
-
-        
-    def parseXML(self,xmldata):
-        print "parsing xmldata with length", len(xmldata)
-        xmldoc = xml_dom_minidom_parseString(xmldata);
-        blist = xmldoc.getElementsByTagName("e2bouqetlist")[0]
-        print "Num TV Bouqets",len(blist.getElementsByTagName('e2tvbouqetlist')[0].getElementsByTagName('e2bouqet'))
-        print "Num RADIO Bouqets",len(blist.getElementsByTagName('e2radiobouqetlist')[0].getElementsByTagName('e2bouqet'))
-        
-        bouqets_tv =self.parseBouqets(blist.getElementsByTagName('e2tvbouqetlist')[0])
-        bouqets_radio =self.parseBouqets(blist.getElementsByTagName('e2radiobouqetlist')[0])
-        return bouqets_tv,bouqets_radio
-    
-    def parseBouqets(self,xmlnode):
-        #print "parsing Bouqets", xmlnode
-        list = []
-        for bouqet in xmlnode.getElementsByTagName('e2bouqet'):
-            bref = urllib_unquote(bouqet.getElementsByTagName('e2bouqetreference')[0].childNodes[0].data)
-            bname = urllib_unquote(bouqet.getElementsByTagName('e2bouqetname')[0].childNodes[0].data)
-            #print "BOUQET",bref,bname
-            list.append({'bname':bname,'bref':bref,'services':self.parseServices(bouqet)})
-        return list
-    
-    def parseServices(self,xmlnode):
-        #print "parsing Services", xmlnode
-        list = []
-        for service in xmlnode.getElementsByTagName('e2servicelist')[0].getElementsByTagName('e2service'):
-            sref = urllib_unquote(service.getElementsByTagName('e2servicereference')[0].childNodes[0].data)
-            sname = urllib_unquote(service.getElementsByTagName('e2servicename')[0].childNodes[0].data)
-            sname = sname.replace(self.undefinded_tag,"<n/a>").replace(self.undefinded_and,"&")
-            #print sref,sname
-            list.append({'sref':sref,'sname':sname})
-        return list
-    
-    def createBouqetFile(self,type,bname,list_services,counter):
-        print "creating file for bouqet",bname,"with",len(list_services),"services for type",type
-        filename  = self.getFilenameForBouqet(type,bname,counter)
-        fcontent  = "#NAME %s\n" %bname  
-        for service in list_services:
-            fcontent += "#SERVICE %s\n" % service['sref']        
-            fcontent += "#DESCRIPTION %s\n" % service['sname']    
-        fcontent=fcontent.encode('utf-8')
-        fp = open(self.DIR+filename,"w")
-        fp.write(fcontent)
-        fp.close()
-        
-    def createIndexFile(self,type, bouqets):
-        print "creating Indexfile with",len(bouqets),"num bouqets for type",type
-        filename  = self.getFilenameForIndex(type)
-        if(type == self.TYPE_TV):
-            fcontent  = "#NAME User - bouquets (TV)\n"
-        else:  
-            fcontent  = "#NAME User - bouquets (Radio)\n"
-        counter = 0;    
-        for bouqet in bouqets:
-            fcontent += "#SERVICE: 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"%s\" ORDER BY bouquet\n" %self.getFilenameForBouqet(type, bouqet['bname'],counter)
-            counter = counter+1
-
-        fp = open(self.DIR+filename,"w")
-        fp.write(fcontent)
-        fp.close()
-        
-    def getFilenameForBouqet(self,type,bouqetname,counter):
-        if bouqetname == "Favourites (TV)" and type == self.TYPE_TV:
-            s =  "userbouquet.favourites%s" %self.EXTENSIONS[type]
-        elif bouqetname == "Favourites (Radio)" and type == self.TYPE_RADIO:
-            s =  "userbouquet.favourites%s" %self.EXTENSIONS[type]
-        else:
-            s =  "userbouquet.%i%s" %(counter,self.EXTENSIONS[type])
-        return s
-    
-    def getFilenameForIndex(self,type):
-        return "bouquets"+self.EXTENSIONS[type]
+       TYPE_TV = 0
+       TYPE_RADIO = 1
+       EXTENSIONS = ['.tv','.radio']
+       DIR = "/etc/enigma2/"
+       undefinded_tag = "%n/a%"
+       undefinded_and = "%und%"
+
+       def http_POST(self, request):
+               """
+               overwriten, because we need a custom parsePOSTData
+               """
+               return self.parsePOSTData(request).addCallback(
+                       lambda res: self.render(request))
+
+       def parsePOSTData(self,request):
+               """
+               overwriten, because we need to set higher values to fileupload.parse_urlencoded
+               """
+               if request.stream.length == 0:
+                       return defer.succeed(None)
+
+               parser = None
+               ctype = request.headers.getHeader('content-type')
+               print "#"*20,ctype
+               if ctype is None:
+                       return defer.succeed(None)
+
+               def updateArgs(data):
+                       args = data
+                       request.args.update(args)
+
+               def updateArgsAndFiles(data):
+                       args, files = data
+                       request.args.update(args)
+                       request.files.update(files)
+
+               def error(f):
+                       f.trap(fileupload.MimeFormatError)
+                       raise http.HTTPError(responsecode.BAD_REQUEST)
+
+               if ctype.mediaType == 'application' and ctype.mediaSubtype == 'x-www-form-urlencoded':
+                       d = fileupload.parse_urlencoded(request.stream, maxMem=100*1024*1024, maxFields=1024)
+                       d.addCallbacks(updateArgs, error)
+                       return d
+               else:
+                       raise http.HTTPError(responsecode.BAD_REQUEST)
+
+       def render(self, req):
+               XML_HEADER = {'Content-type': http_headers.MimeType('application', 'xhtml+xml', (('charset', 'UTF-8'),))}
+
+               try:
+                       content = req.args['content'][0].replace("<n/a>",self.undefinded_tag).replace('&',self.undefinded_and)
+                       if content.find('undefined')!=-1:
+                               fp = open('/tmp/savedlist','w')
+                               fp.write(content)
+                               fp.close()
+                               result = """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n
+                                               <e2simplexmlresult>\n
+                                                       <e2state>false</e2state>
+                                                       <e2statetext>found string 'undefined in XML DATA... a copie was saved to '/tmp/savedlist'.</e2statetext>
+                                               </e2simplexmlresult>\n
+                                        """
+                               return http.Response(responsecode.OK,XML_HEADER,stream=result)
+
+                       (bouqets_tv,bouqets_radio) = self.parseXML( content)
+                       #print "having num %i TV Bouqets and num %i Radio Bouqets" %(len(bouqets_tv),len(bouqets_radio))
+
+                       #deleting old files
+                       os.system("rm "+self.DIR+"userbouquet*.tv ")
+                       os.system("rm "+self.DIR+"userbouquet*.radio ")
+                       os.system("rm "+self.DIR+"bouquets.tv ")
+                       os.system("rm "+self.DIR+"bouquets.radio ")
+
+                       #writing new files
+                       self.createIndexFile(self.TYPE_TV, bouqets_tv)
+                       counter = 0
+                       for bouqet in bouqets_tv:
+                               self.createBouqetFile(self.TYPE_TV, bouqet['bname'], bouqet['services'],counter)
+                               counter = counter +1
+
+                       self.createIndexFile(self.TYPE_RADIO, bouqets_radio)
+                       counter = 0
+                       for bouqet in bouqets_radio:
+                               self.createBouqetFile(self.TYPE_RADIO, bouqet['bname'], bouqet['services'],counter)
+                               counter = counter +1
+
+                       # reloading *.tv and *.radio
+                       db = eDVBDB.getInstance()
+                       db.reloadBouquets()
+                       print "servicelists reloaded"
+                       result = """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n
+                                               <e2simplexmlresult>\n
+                                                       <e2state>true</e2state>
+                                                       <e2statetext>servicelist saved with %i TV und %i Radio Bouquets and was reloaded</e2statetext>
+                                               </e2simplexmlresult>\n
+                                        """ %(len(bouqets_tv),len(bouqets_radio))
+                       return http.Response(responsecode.OK,XML_HEADER,stream=result)
+               except Exception,e:
+                       print e
+                       result = """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n
+                                               <e2simplexmlresult>\n
+                                                       <e2state>false</e2state>
+                                                       <e2statetext>%s</e2statetext>
+                                               </e2simplexmlresult>\n
+                                        """%e
+                       return http.Response(responsecode.OK,XML_HEADER,stream=result)
+
+       def parseXML(self,xmldata):
+               print "parsing xmldata with length", len(xmldata)
+               xmldoc = xml_dom_minidom_parseString(xmldata);
+               blist = xmldoc.getElementsByTagName("e2bouqetlist")[0]
+               print "Num TV Bouqets",len(blist.getElementsByTagName('e2tvbouqetlist')[0].getElementsByTagName('e2bouqet'))
+               print "Num RADIO Bouqets",len(blist.getElementsByTagName('e2radiobouqetlist')[0].getElementsByTagName('e2bouqet'))
+
+               bouqets_tv =self.parseBouqets(blist.getElementsByTagName('e2tvbouqetlist')[0])
+               bouqets_radio =self.parseBouqets(blist.getElementsByTagName('e2radiobouqetlist')[0])
+               return bouqets_tv,bouqets_radio
+
+       def parseBouqets(self,xmlnode):
+               #print "parsing Bouqets", xmlnode
+               list = []
+               for bouqet in xmlnode.getElementsByTagName('e2bouqet'):
+                       bref = urllib_unquote(bouqet.getElementsByTagName('e2bouqetreference')[0].childNodes[0].data)
+                       bname = urllib_unquote(bouqet.getElementsByTagName('e2bouqetname')[0].childNodes[0].data)
+                       #print "BOUQET",bref,bname
+                       list.append({'bname':bname,'bref':bref,'services':self.parseServices(bouqet)})
+               return list
+
+       def parseServices(self,xmlnode):
+               #print "parsing Services", xmlnode
+               list = []
+               for service in xmlnode.getElementsByTagName('e2servicelist')[0].getElementsByTagName('e2service'):
+                       sref = urllib_unquote(service.getElementsByTagName('e2servicereference')[0].childNodes[0].data)
+                       sname = urllib_unquote(service.getElementsByTagName('e2servicename')[0].childNodes[0].data)
+                       sname = sname.replace(self.undefinded_tag,"<n/a>").replace(self.undefinded_and,"&")
+                       #print sref,sname
+                       list.append({'sref':sref,'sname':sname})
+               return list
+
+       def createBouqetFile(self,type,bname,list_services,counter):
+               print "creating file for bouqet",bname,"with",len(list_services),"services for type",type
+               filename  = self.getFilenameForBouqet(type,bname,counter)
+               fcontent  = "#NAME %s\n" %bname
+               for service in list_services:
+                       fcontent += "#SERVICE %s\n" % service['sref']
+                       fcontent += "#DESCRIPTION %s\n" % service['sname']
+               fcontent=fcontent.encode('utf-8')
+               fp = open(self.DIR+filename,"w")
+               fp.write(fcontent)
+               fp.close()
+
+       def createIndexFile(self,type, bouqets):
+               print "creating Indexfile with",len(bouqets),"num bouqets for type",type
+               filename  = self.getFilenameForIndex(type)
+               if(type == self.TYPE_TV):
+                       fcontent  = "#NAME User - bouquets (TV)\n"
+               else:
+                       fcontent  = "#NAME User - bouquets (Radio)\n"
+               counter = 0
+               for bouqet in bouqets:
+                       fcontent += "#SERVICE: 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"%s\" ORDER BY bouquet\n" %self.getFilenameForBouqet(type, bouqet['bname'],counter)
+                       counter = counter+1
+
+               fp = open(self.DIR+filename,"w")
+               fp.write(fcontent)
+               fp.close()
+
+       def getFilenameForBouqet(self,type,bouqetname,counter):
+               if bouqetname == "Favourites (TV)" and type == self.TYPE_TV:
+                       s =  "userbouquet.favourites%s" %self.EXTENSIONS[type]
+               elif bouqetname == "Favourites (Radio)" and type == self.TYPE_RADIO:
+                       s =  "userbouquet.favourites%s" %self.EXTENSIONS[type]
+               else:
+                       s =  "userbouquet.%i%s" %(counter,self.EXTENSIONS[type])
+               return s
+
+       def getFilenameForIndex(self,type):
+               return "bouquets"+self.EXTENSIONS[type]
 
index b64ea1c..ae92659 100755 (executable)
@@ -14,44 +14,44 @@ from ServiceListSave import ServiceList
 from RedirecToCurrentStream import RedirecToCurrentStreamResource
 
 class Toplevel(resource.Resource):
-    addSlash = True
-    def __init__(self,session):
-        self.session = session
-        resource.Resource.__init__(self)
-
-        self.putChild("web", ScreenPage(self.session,util.sibpath(WebInterface.__file__, "web"))) # "/web/*"
-        self.putChild("web-data", static.File(util.sibpath(WebInterface.__file__, "web-data"))) # FIXME: web-data appears as webdata
-        self.putChild("file", FileStreamer())
-        self.putChild("grab", GrabResource())
-        self.putChild("ipkg", IPKGResource())
-        self.putChild("play", ServiceplayerResource(self.session))
-        self.putChild("wap", RedirectorResource("/web/wap/"))# shorten and simplify url to wap-pages
-        self.putChild("upload", UploadResource())
-        self.putChild("servicelist", ServiceList(self.session))
-        self.putChild("streamcurrent", RedirecToCurrentStreamResource(session))
-            
-        if config.plugins.Webinterface.includemedia.value is True:
-            self.putChild("media", static.File("/media"))
-            self.putChild("hdd", static.File("/media/hdd"))
-
-    def render(self, req):
-        fp = open(util.sibpath(WebInterface.__file__, "web-data/tpl/default")+"/index.html")
-        s = fp.read()
-        fp.close()
-        return http.Response(responsecode.OK, {'Content-type': http_headers.MimeType('text', 'html')},stream=s)
-
-    def locateChild(self, request, segments):
-        print "[WebIf]", request.remoteAddr.host,request.method,request.path,request.args
-        return resource.Resource.locateChild(self, request, segments)
+       addSlash = True
+       def __init__(self,session):
+               self.session = session
+               resource.Resource.__init__(self)
+
+               self.putChild("web", ScreenPage(self.session,util.sibpath(WebInterface.__file__, "web"))) # "/web/*"
+               self.putChild("web-data", static.File(util.sibpath(WebInterface.__file__, "web-data"))) # FIXME: web-data appears as webdata
+               self.putChild("file", FileStreamer())
+               self.putChild("grab", GrabResource())
+               self.putChild("ipkg", IPKGResource())
+               self.putChild("play", ServiceplayerResource(self.session))
+               self.putChild("wap", RedirectorResource("/web/wap/"))# shorten and simplify url to wap-pages
+               self.putChild("upload", UploadResource())
+               self.putChild("servicelist", ServiceList(self.session))
+               self.putChild("streamcurrent", RedirecToCurrentStreamResource(session))
+
+               if config.plugins.Webinterface.includemedia.value is True:
+                       self.putChild("media", static.File("/media"))
+                       self.putChild("hdd", static.File("/media/hdd"))
+
+       def render(self, req):
+               fp = open(util.sibpath(WebInterface.__file__, "web-data/tpl/default")+"/index.html")
+               s = fp.read()
+               fp.close()
+               return http.Response(responsecode.OK, {'Content-type': http_headers.MimeType('text', 'html')},stream=s)
+
+       def locateChild(self, request, segments):
+               print "[WebIf]", request.remoteAddr.host,request.method,request.path,request.args
+               return resource.Resource.locateChild(self, request, segments)
 
 class RedirectorResource(resource.Resource):
-    """
-        this class can be used to redirect a request to a specified uri
-    """
-    def __init__(self,uri):
-        self.uri = uri
-        resource.Resource.__init__(self)
-    def render(self, req):
-        return http.RedirectResponse(self.uri)
+       """
+               this class can be used to redirect a request to a specified uri
+       """
+       def __init__(self,uri):
+               self.uri = uri
+               resource.Resource.__init__(self)
+       def render(self, req):
+               return http.RedirectResponse(self.uri)
 
 
index 5e06f90..70a2d4f 100755 (executable)
@@ -2,67 +2,67 @@ from os import statvfs, path as os_path, system as os_system, chmod as os_chmod
 from twisted.web2 import resource, responsecode, http, http_headers
 
 class UploadResource(resource.PostableResource):
-    default_uploaddir = "/tmp/"
-    
-    def render(self, req):
-        self.args = req.args
-        #############
-        uploaddir=self.default_uploaddir
-        if self.getArg("path"):
-            if os_path.isdir(self.getArg("path")):
-                uploaddir= self.getArg("path")
-                if uploaddir[-1] != "/":
-                    uploaddir += "/"
-            else:
-                return http.Response(responsecode.OK,{'content-type': http_headers.MimeType('text', 'html')},"path '%s' to upload not existing!"%self.getArg("path"))
-        #########
-        if len(req.files):
-            #static.destination = uploaddir
-            return self.do_upload(req,uploaddir)
-        else:
-            return self.do_indexpage(req)
-    
-    def do_upload(self,req,uploaddir):
-        for file in req.files:
-            import tempfile
-            (filename,mimetype,filehandler) = req.files[file][0]
-#            filehandler.name = tempfile.mktemp(suffix=os_path.splitext(filename)[1], dir=uploaddir)
-            print "filehandler.name: ",filehandler.name
-            filehandler.seek(0, 2)  # Seek to the end of the file.
-            filesize = filehandler.tell()  # Get the position of EOF.
-            filehandler.seek(0)  # Reset the file position to the beginning.
-            if filesize <=0:
-                os_system("rm '%s'" %filehandler.name)
-                return http.Response(responsecode.OK,{'content-type': http_headers.MimeType('text', 'html')},"filesize was 0, not uploaded")
-            else:
-                os_system("mv '%s' '%s' " %(filehandler.name,uploaddir+filename))
-                os_chmod(uploaddir+filename, 0755)
-                return http.Response(responsecode.OK,{'content-type': http_headers.MimeType('text', 'html')},"uploaded to %s"%uploaddir+filename)
-    
-    def do_indexpage(self,req):
-        try:
-            stat = statvfs("/tmp/")
-        except OSError:
-            return -1
-        
-        freespace = stat.f_bfree / 1000 * stat.f_bsize / 1000
-        
-        return http.Response(responsecode.OK,
-                             {'content-type': http_headers.MimeType('text', 'html')},
-        """
-                <form method="POST" enctype="multipart/form-data">
-                <table>
-                <tr><td>Path to save (default is '%s')</td><td><input name="path"></td></tr>
-                <tr><td>File to upload</td><td><input name="file" type="file"></td></tr>
-                <tr><td colspan="2">Filesize must not be greather than %dMB! /tmp/ has not more free space!</td></tr>
-                <tr><td colspan="2"><input type="submit"></td><tr>
-                </table>
-                </form>
-                
-        """%(self.default_uploaddir,freespace))
+       default_uploaddir = "/tmp/"
+
+       def render(self, req):
+               self.args = req.args
+               #############
+               uploaddir=self.default_uploaddir
+               if self.getArg("path"):
+                       if os_path.isdir(self.getArg("path")):
+                               uploaddir= self.getArg("path")
+                               if uploaddir[-1] != "/":
+                                       uploaddir += "/"
+                       else:
+                               return http.Response(responsecode.OK,{'content-type': http_headers.MimeType('text', 'html')},"path '%s' to upload not existing!"%self.getArg("path"))
+               #########
+               if len(req.files):
+                       #static.destination = uploaddir
+                       return self.do_upload(req,uploaddir)
+               else:
+                       return self.do_indexpage(req)
+
+       def do_upload(self,req,uploaddir):
+               for file in req.files:
+                       import tempfile
+                       (filename,mimetype,filehandler) = req.files[file][0]
+#                      filehandler.name = tempfile.mktemp(suffix=os_path.splitext(filename)[1], dir=uploaddir)
+                       print "filehandler.name: ",filehandler.name
+                       filehandler.seek(0, 2) # Seek to the end of the file.
+                       filesize = filehandler.tell() # Get the position of EOF.
+                       filehandler.seek(0) # Reset the file position to the beginning.
+                       if filesize <=0:
+                               os_system("rm '%s'" %filehandler.name)
+                               return http.Response(responsecode.OK,{'content-type': http_headers.MimeType('text', 'html')},"filesize was 0, not uploaded")
+                       else:
+                               os_system("mv '%s' '%s' " %(filehandler.name,uploaddir+filename))
+                               os_chmod(uploaddir+filename, 0755)
+                               return http.Response(responsecode.OK,{'content-type': http_headers.MimeType('text', 'html')},"uploaded to %s"%uploaddir+filename)
+
+       def do_indexpage(self,req):
+               try:
+                       stat = statvfs("/tmp/")
+               except OSError:
+                       return -1
+
+               freespace = stat.f_bfree / 1000 * stat.f_bsize / 1000
+
+               return http.Response(responsecode.OK,
+                                                        {'content-type': http_headers.MimeType('text', 'html')},
+               """
+                               <form method="POST" enctype="multipart/form-data">
+                               <table>
+                               <tr><td>Path to save (default is '%s')</td><td><input name="path"></td></tr>
+                               <tr><td>File to upload</td><td><input name="file" type="file"></td></tr>
+                               <tr><td colspan="2">Filesize must not be greather than %dMB! /tmp/ has not more free space!</td></tr>
+                               <tr><td colspan="2"><input type="submit"></td><tr>
+                               </table>
+                               </form>
+               """%(self.default_uploaddir,freespace))
+
+       def getArg(self,key):
+               if self.args.has_key(key):
+                       return self.args[key][0]
+               else:
+                       return False
 
-    def getArg(self,key):
-        if self.args.has_key(key):
-            return self.args[key][0]
-        else:
-            return False
index 8926c43..a99aa09 100644 (file)
@@ -1,37 +1,35 @@
 from Components.Converter.Converter import Converter
 
 class HddInfo(Converter, object):
-    MODEL = 0
-    CAPACITY = 1
-    FREE = 2
-    
-    def __init__(self, type):
-        Converter.__init__(self, type)
-        
-        self.type = {
-                     "Model" : self.MODEL,
-                     "Capacity" : self.CAPACITY,
-                     "Free" : self.FREE,
-                     }[type]                    
-                     
-    def getText(self):        
-        hdd = self.source.hdd
-        
-        if hdd is not None:
-            if self.type == self.MODEL:
-                return "%s" %hdd.model()
-            elif self.type == self.CAPACITY:            
-                return "%s" %hdd.capacity()
-            elif self.type == self.FREE:                
-                if hdd.free() > 1024:
-                    free = float(hdd.free()) / float(1024)
-                    return "%.3f GB" %free
-                else:
-                    return "%i MB" %hdd.free()
-                     
-                
-        return _("N/A")
-
-                
-    text = property(getText)
-    
\ No newline at end of file
+       MODEL = 0
+       CAPACITY = 1
+       FREE = 2
+
+       def __init__(self, type):
+               Converter.__init__(self, type)
+
+               self.type = {
+                                        "Model" : self.MODEL,
+                                        "Capacity" : self.CAPACITY,
+                                        "Free" : self.FREE,
+                                        }[type]
+
+       def getText(self):
+               hdd = self.source.hdd
+
+               if hdd is not None:
+                       if self.type == self.MODEL:
+                               return "%s" %hdd.model()
+                       elif self.type == self.CAPACITY:
+                               return "%s" %hdd.capacity()
+                       elif self.type == self.FREE:
+                               if hdd.free() > 1024:
+                                       free = float(hdd.free()) / float(1024)
+                                       return "%.3f GB" %free
+                               else:
+                                       return "%i MB" %hdd.free()
+
+               return _("N/A")
+
+       text = property(getText)
+
index 215df11..6396312 100644 (file)
@@ -1,40 +1,39 @@
 from Components.Converter.Converter import Converter
 from Components.Element import cached
 
-
 class NetworkInfo(Converter, object):
-    MAC = 0
-    DHCP = 1
-    IP = 2
-    GATEWAY = 3
-    NETMASK = 4
-    
-    def __init__(self, type):
-        Converter.__init__(self, type)
-        self.type = {
-                     "Mac" : self.MAC,
-                     "Dhcp" : self.DHCP,
-                     "Ip" : self.IP,
-                     "Gateway" : self.GATEWAY,
-                     "Netmask" : self.NETMASK,
-                     }[type]
-    
-    @cached
-    def getText(self):
-        iface = self.source.interface
-        
-        if self.type is self.MAC:
-            return iface.mac
-        elif self.type is self.DHCP:
-            return iface.dhcp
-        elif self.type is self.IP:
-            return iface.ip
-        elif self.type is self.GATEWAY:
-            return iface.gateway
-        elif self.type is self.NETMASK:
-            return iface.netmask
-        else:
-            return _("N/A")
-        
-    text = property(getText)
-    
\ No newline at end of file
+       MAC = 0
+       DHCP = 1
+       IP = 2
+       GATEWAY = 3
+       NETMASK = 4
+
+       def __init__(self, type):
+               Converter.__init__(self, type)
+               self.type = {
+                                        "Mac" : self.MAC,
+                                        "Dhcp" : self.DHCP,
+                                        "Ip" : self.IP,
+                                        "Gateway" : self.GATEWAY,
+                                        "Netmask" : self.NETMASK,
+                                        }[type]
+
+       @cached
+       def getText(self):
+               iface = self.source.interface
+
+               if self.type is self.MAC:
+                       return iface.mac
+               elif self.type is self.DHCP:
+                       return iface.dhcp
+               elif self.type is self.IP:
+                       return iface.ip
+               elif self.type is self.GATEWAY:
+                       return iface.gateway
+               elif self.type is self.NETMASK:
+                       return iface.netmask
+               else:
+                       return _("N/A")
+
+       text = property(getText)
+
index 9f5cd44..91d5816 100644 (file)
@@ -1,38 +1,37 @@
 from Components.Converter.Converter import Converter
 from Components.Element import cached
 
-
 class NetworkInfo(Converter, object):
-    MAC = 0
-    DHCP = 1
-    IP = 2
-    GATEWAY = 3
-    NAMESERVER = 4
-    
-    def __init__(self, type):
-        Converter.___init__(self)
-        self.type = {
-                     "Mac" : self.MAC,
-                     "Dhcp" : self.DHCP,
-                     "Ip" : self.IP,
-                     "Gateway" : self.GATEWAY,
-                     "Nameserver" : self.NAMESERVER,
-                     }[type]
-    
-    @cached
-    def getText(self):
-        iface = iface.interface
-        
-        if self.type is self.MAC:
-            return iface.mac
-        elif self.type is self.DHCP:
-            return iface.dhcp
-        elif self.type is self.IP:
-            return iface.IP
-        elif self.type is self.GATEWAY:
-            return iface.gateway
-        elif self.type is self.NAMESERVER:
-            return iface.nameserver
-        
-    text = property(getText)
-    
\ No newline at end of file
+       MAC = 0
+       DHCP = 1
+       IP = 2
+       GATEWAY = 3
+       NAMESERVER = 4
+
+       def __init__(self, type):
+               Converter.___init__(self)
+               self.type = {
+                                        "Mac" : self.MAC,
+                                        "Dhcp" : self.DHCP,
+                                        "Ip" : self.IP,
+                                        "Gateway" : self.GATEWAY,
+                                        "Nameserver" : self.NAMESERVER,
+                                        }[type]
+
+       @cached
+       def getText(self):
+               iface = iface.interface
+
+               if self.type is self.MAC:
+                       return iface.mac
+               elif self.type is self.DHCP:
+                       return iface.dhcp
+               elif self.type is self.IP:
+                       return iface.IP
+               elif self.type is self.GATEWAY:
+                       return iface.gateway
+               elif self.type is self.NAMESERVER:
+                       return iface.nameserver
+
+       text = property(getText)
+
index 9c394f9..e10fc5b 100644 (file)
@@ -1,4 +1,4 @@
-# Code for the AutoTimerPlugin
+ Code for the AutoTimerPlugin
 #from enigma import eServiceReference, iServiceInformation, eServiceCenter
 from Components.Sources.Source import Source
 #from ServiceReference import ServiceReference
@@ -6,179 +6,177 @@ from Components.Sources.Source import Source
 #from os import path as os_path
 
 class AT( Source ):
-    LIST = 0
-    WRITE = 1
-    
-    def __init__(self, session, func = LIST):
-        print "AutoTimer: init: ", func
-        Source.__init__(self)
-        self.func = func
-        self.session = session
-        self.result = []
-    
-    def handleCommand(self, cmd):
-        print "AutoTimer: handleCommand: ", cmd
-        if cmd is not None:
-            self.cmd = cmd
-            if self.func is self.LIST:
-                self.result = self.timerList(cmd)
-            elif self.func is self.WRITE:
-                self.result = self.writeTimer(cmd)
-        
-    def timerList(self,param):
-        print "timerList:",param
-        
-        returnList = []
-        
-        from Components.PluginComponent import plugins
-        from Plugins.Plugin import PluginDescriptor#, PluginEntryComponent
-        pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
-        autoTimerAvailable = False
-        for plugin in pluginlist:
-            if plugin.name == "AutoTimer":
-                #if PluginEntryComponent(plugin).name == "AutoTimer":
-                autoTimerAvailable = True
-        
-        if autoTimerAvailable:
-            print "AutoTimer vorhanden"
-            from Plugins.Extensions.AutoTimer.plugin import autotimer
-            
-            if autotimer is None:
-                from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
-                autotimer = AutoTimer()
-            #timers = autotimer.getTimerList
-            #AutoTimerComponent
-            from Plugins.Extensions.AutoTimer.AutoTimerComponent import AutoTimerComponent
-            for timer in autotimer.getTimerList():
-                print "TIMER: ", timer
-                innerList = []
-                innerList.append(timer.getName())
-                innerList.append(timer.getMatch())
-                
-                if timer.hasAfterEvent():
-                    innerList.append(timer.getAfterEvent()) # 2
-                else:
-                    innerList.append("") # 2
-                                
-                #excludes
-                innerList.append(timer.getExcludedTitle())
-                innerList.append(timer.getExcludedShort())
-                innerList.append(timer.getExcludedDescription())
-                innerList.append(timer.getExcludedDays())
-                
-                #inclides
-                innerList.append(timer.getIncludedTitle())
-                innerList.append(timer.getIncludedShort())
-                innerList.append(timer.getIncludedDescription())
-                innerList.append(timer.getIncludedDays())
-                
-                # filterSET
-                self.excludes = (
-                                 timer.getExcludedTitle(),
-                                 timer.getExcludedShort(),
-                                 timer.getExcludedDescription(),
-                                 timer.getExcludedDays()
-                )
-                self.includes = (
-                                 timer.getIncludedTitle(),
-                                 timer.getIncludedShort(),
-                                 timer.getIncludedDescription(),
-                                 timer.getIncludedDays()
-                )
-                innerList.append(timer.getServices()) # 11
-                innerList.append(timer.getBouquets()) # 12
-                if timer.hasTimespan():
-                    innerList.append(timer.getTimespanBegin()) # 13
-                    innerList.append(timer.getTimespanEnd()) # 14
-                else:
-                    innerList.append("") # 13
-                    innerList.append("") # 14
-                
-                if timer.hasDuration():
-                    innerList.append(timer.getDuration()) # 15
-                else:
-                    innerList.append("") # 15
-                
-                if timer.hasCounter():
-                    innerList.append(timer.getCounter()) # 16
-                    innerList.append(timer.getCounterLeft()) # 17
-                else:
-                    innerList.append(0) # 16
-                    innerList.append(0) # 17
-                
-                innerList.append(timer.getCounterLimit()) # 18
-                
-                if timer.hasDestination():
-                    innerList.append(timer.hasDestination()) # 19
-                else:
-                    innerList.append("/hdd/movie/") # 19
-                    
-                if timer.hasCounterFormatString():
-                    innerList.append(timer.getCounterFormatString()) # 20
-                else:
-                    innerList.append("") # 20
-                
-                innerList.append(timer.getLastBegin()) # 21
-                innerList.append(timer.getJustplay()) # 22
-                innerList.append(timer.getAvoidDuplicateDescription()) # 23
-                
-                if timer.hasTags():
-                    innerList.append(timer.getTags()) # 24
-                else:
-                    innerList.append("") # 24
-                
-                print "Enabled", timer.getEnabled()
-                innerList.append(timer.getEnabled())  # 25
-                innerList.append("off")  # 26
-
-                returnList.append(innerList)
-        
-        return returnList
-
-        
-    def writeTimer(self,param):
-        print "writeTimer: ",param
-        # TODO: fix error handling
-
-        return
-        
-    def command(self,param):
-        print "command: ",param
-        return
-
-        param = int(param)
-        
-        # TODO: fix error handling
-    
-    def getList(self):
-        return self.result
-    
-    list = property(getList)
-    lut = {"Name": 0
-           ,"Match": 1
-           ,"AfterEvent": 2
-           ,"ExcludedTitle": 3
-           ,"ExcludedShort": 4
-           ,"ExcludedDescription": 5
-           ,"ExcludedDays": 6
-           ,"IncludedTitle": 7
-           ,"IncludedShort": 8
-           ,"IncludedDescription": 9
-           ,"IncludedDays": 10
-           ,"Services": 11
-           ,"Bouquets": 12
-           ,"TimespanBegin": 13
-           ,"TimespanEnd": 14
-           ,"Duration": 15
-           ,"Counter": 16
-           ,"CounterLeft": 17
-           ,"CounterLimit": 18
-           ,"Destination": 19
-           ,"CounterFormatString": 20
-           ,"LastBegin": 21
-           ,"Justplay": 22
-           ,"AvoidDuplicateDescription": 23
-           ,"Tags": 24
-           ,"Enabled": 25
-           ,"toggleDisabledIMG": 26
-           }
+       LIST = 0
+       WRITE = 1
+
+       def __init__(self, session, func = LIST):
+               print "AutoTimer: init: ", func
+               Source.__init__(self)
+               self.func = func
+               self.session = session
+               self.result = []
+
+       def handleCommand(self, cmd):
+               print "AutoTimer: handleCommand: ", cmd
+               if cmd is not None:
+                       self.cmd = cmd
+                       if self.func is self.LIST:
+                               self.result = self.timerList(cmd)
+                       elif self.func is self.WRITE:
+                               self.result = self.writeTimer(cmd)
+
+       def timerList(self,param):
+               print "timerList:",param
+
+               returnList = []
+
+               from Components.PluginComponent import plugins
+               from Plugins.Plugin import PluginDescriptor#, PluginEntryComponent
+               pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
+               autoTimerAvailable = False
+               for plugin in pluginlist:
+                       if plugin.name == "AutoTimer":
+                               #if PluginEntryComponent(plugin).name == "AutoTimer":
+                               autoTimerAvailable = True
+
+               if autoTimerAvailable:
+                       print "AutoTimer vorhanden"
+                       from Plugins.Extensions.AutoTimer.plugin import autotimer
+
+                       if autotimer is None:
+                               from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
+                               autotimer = AutoTimer()
+                       #timers = autotimer.getTimerList
+                       #AutoTimerComponent
+                       from Plugins.Extensions.AutoTimer.AutoTimerComponent import AutoTimerComponent
+                       for timer in autotimer.getTimerList():
+                               print "TIMER: ", timer
+                               innerList = []
+                               innerList.append(timer.getName())
+                               innerList.append(timer.getMatch())
+
+                               if timer.hasAfterEvent():
+                                       innerList.append(timer.getAfterEvent()) # 2
+                               else:
+                                       innerList.append("") # 2
+
+                               #excludes
+                               innerList.append(timer.getExcludedTitle())
+                               innerList.append(timer.getExcludedShort())
+                               innerList.append(timer.getExcludedDescription())
+                               innerList.append(timer.getExcludedDays())
+
+                               #inclides
+                               innerList.append(timer.getIncludedTitle())
+                               innerList.append(timer.getIncludedShort())
+                               innerList.append(timer.getIncludedDescription())
+                               innerList.append(timer.getIncludedDays())
+
+                               # filterSET
+                               self.excludes = (
+                                                                timer.getExcludedTitle(),
+                                                                timer.getExcludedShort(),
+                                                                timer.getExcludedDescription(),
+                                                                timer.getExcludedDays()
+                               )
+                               self.includes = (
+                                                                timer.getIncludedTitle(),
+                                                                timer.getIncludedShort(),
+                                                                timer.getIncludedDescription(),
+                                                                timer.getIncludedDays()
+                               )
+                               innerList.append(timer.getServices()) # 11
+                               innerList.append(timer.getBouquets()) # 12
+                               if timer.hasTimespan():
+                                       innerList.append(timer.getTimespanBegin()) # 13
+                                       innerList.append(timer.getTimespanEnd()) # 14
+                               else:
+                                       innerList.append("") # 13
+                                       innerList.append("") # 14
+
+                               if timer.hasDuration():
+                                       innerList.append(timer.getDuration()) # 15
+                               else:
+                                       innerList.append("") # 15
+
+                               if timer.hasCounter():
+                                       innerList.append(timer.getCounter()) # 16
+                                       innerList.append(timer.getCounterLeft()) # 17
+                               else:
+                                       innerList.append(0) # 16
+                                       innerList.append(0) # 17
+
+                               innerList.append(timer.getCounterLimit()) # 18
+
+                               if timer.hasDestination():
+                                       innerList.append(timer.hasDestination()) # 19
+                               else:
+                                       innerList.append("/hdd/movie/") # 19
+
+                               if timer.hasCounterFormatString():
+                                       innerList.append(timer.getCounterFormatString()) # 20
+                               else:
+                                       innerList.append("") # 20
+
+                               innerList.append(timer.getLastBegin()) # 21
+                               innerList.append(timer.getJustplay()) # 22
+                               innerList.append(timer.getAvoidDuplicateDescription()) # 23
+
+                               if timer.hasTags():
+                                       innerList.append(timer.getTags()) # 24
+                               else:
+                                       innerList.append("") # 24
+
+                               print "Enabled", timer.getEnabled()
+                               innerList.append(timer.getEnabled()) # 25
+                               innerList.append("off") # 26
+
+                               returnList.append(innerList)
+
+               return returnList
+
+       def writeTimer(self,param):
+               print "writeTimer: ",param
+               # TODO: fix error handling
+               return
+
+       def command(self,param):
+               print "command: ",param
+               return
+
+               param = int(param)
+
+               # TODO: fix error handling
+
+       def getList(self):
+               return self.result
+
+       list = property(getList)
+       lut = {"Name": 0
+                       ,"Match": 1
+                       ,"AfterEvent": 2
+                       ,"ExcludedTitle": 3
+                       ,"ExcludedShort": 4
+                       ,"ExcludedDescription": 5
+                       ,"ExcludedDays": 6
+                       ,"IncludedTitle": 7
+                       ,"IncludedShort": 8
+                       ,"IncludedDescription": 9
+                       ,"IncludedDays": 10
+                       ,"Services": 11
+                       ,"Bouquets": 12
+                       ,"TimespanBegin": 13
+                       ,"TimespanEnd": 14
+                       ,"Duration": 15
+                       ,"Counter": 16
+                       ,"CounterLeft": 17
+                       ,"CounterLimit": 18
+                       ,"Destination": 19
+                       ,"CounterFormatString": 20
+                       ,"LastBegin": 21
+                       ,"Justplay": 22
+                       ,"AvoidDuplicateDescription": 23
+                       ,"Tags": 24
+                       ,"Enabled": 25
+                       ,"toggleDisabledIMG": 26
+                       }
index b94b5e3..61d8e01 100644 (file)
@@ -1,4 +1,4 @@
-# Parts of Code and idea  by Homey
+# Parts of Code and idea by Homey
 from Components.Sources.Source import Source
 from Components.Harddisk import harddiskmanager
 from Components.NimManager import nimmanager
@@ -13,176 +13,170 @@ from enigma import iServiceInformation
 from Components.config import config
 
 class About( Source):
-    
-    def __init__(self, session):
-        Source.__init__(self)
-        self.session = session
-    
-    def handleCommand(self,cmd):
-        self.result = False,"unknown command"
-        
-    def command(self):
-        list = []
-        list.append(about.getVersionString()) 
-
-
-        #Get Network Info
-        def ConvertIP(list):
-            if(len(list) == 4):
-                retstr = "%s.%s.%s.%s" %(list[0], list[1], list[2], list[3])
-            else:
-                retstr = "0.0.0.0"
-            return retstr
-
-        
-        if iNetwork.getNumberOfAdapters > 0:
-            iface = iNetwork.getAdapterList()[0]
-            print "[WebComponents.About] iface: %s" %iface
-            list.append(iNetwork.getAdapterAttribute(iface, "mac"))
-            list.append(iNetwork.getAdapterAttribute(iface, "dhcp"))
-            list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "ip")))
-            list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "netmask")))
-            list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "gateway")))
-        else:
-            print "[WebComponents.About] no network iface configured!"
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-
-        #Get FrontProcessor Version
-        fp_version = getFPVersion()
-        if fp_version is None:
-            fp_version = "?"
-        else:
-            fp_version = str(fp_version)
-        list.append(fp_version)
-
-        #Get Tuner Info
-        niminfo = ""
-        for nim in nimmanager.nimList():
-            info = nim.split(":")
-            
-            niminfo += "\n\t\t\t<e2nim>\n"
-            niminfo += "\t\t\t\t<name>%s</name>\n" %(info[0])
-            niminfo += "\t\t\t\t<type>%s</type>\n" %(info[1])
-            niminfo += "\t\t\t</e2nim>"
-            
-        list.append(niminfo)
-
-        #Get HDD Info
-        if len(harddiskmanager.hdd):
-            hdddata = harddiskmanager.hdd[0] # TODO, list more than the first harddisc if there are more than one. but this requires many changes in the way the webif generates the responses
-            hddinfo = "\n\t\t\t<model>"+hdddata.model()+"</model>\n"
-            hddinfo += "\t\t\t<capacity>"+hdddata.capacity()+"</capacity>\n"
-            hddinfo += "\t\t\t<free>"+str(hdddata.free())+" MB</free>"
-            list.append(hddinfo)
-        else:            
-            hddinfo = "\n\t\t\t<model>N/A</model>\n"
-            hddinfo += "\t\t\t<capacity>-</capacity>\n"
-            hddinfo += "\t\t\t<free>-</free>"
-            list.append(hddinfo)
-
-        #Get Service Info
-        service = self.session.nav.getCurrentService()
-
-        if self.session.nav.getCurrentlyPlayingServiceReference() is not None:
-            Name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()
-        else:
-            Name = "N/A"
-        list.append(Name)
-
-        if service is not None:
-            svinfo = service.info()
-            svfeinfo = service.frontendInfo()
-        else:
-            svinfo = None
-            svfeinfo = None
-
-        # Get Service Info
-        if self.session.nav.getCurrentlyPlayingServiceReference() is not None:
-            list.append(svinfo.getInfoString(iServiceInformation.sProvider))
-            
-            aspect = svinfo.getInfo(iServiceInformation.sAspect)
-            if aspect in ( 1, 2, 5, 6, 9, 0xA, 0xD, 0xE ):
-                aspect = "4:3"
-            else:
-                aspect = "16:9"
-            list.append(aspect)
-
-            width = svinfo and svinfo.getInfo(iServiceInformation.sVideoWidth) or -1
-            height = svinfo and svinfo.getInfo(iServiceInformation.sVideoHeight) or -1
-            videosize = "%dx%d" %(width, height)
-            list.append(videosize)
-            
-            list.append(hex(svinfo.getInfo(iServiceInformation.sNamespace)))
-
-            # Get PIDs
-            list.append(svinfo.getInfo(iServiceInformation.sVideoPID))
-            list.append(svinfo.getInfo(iServiceInformation.sAudioPID))
-            list.append(svinfo.getInfo(iServiceInformation.sPCRPID))
-            list.append(svinfo.getInfo(iServiceInformation.sPMTPID))
-            list.append(svinfo.getInfo(iServiceInformation.sTXTPID))
-            list.append(svinfo.getInfo(iServiceInformation.sTSID))
-            list.append(svinfo.getInfo(iServiceInformation.sONID))
-            list.append(svinfo.getInfo(iServiceInformation.sSID))
-        else:
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            list.append("N/A")
-            
-        ## webifversion
-        list.append(config.plugins.Webinterface.version.value)
-        
-        
-        #box model
-        fp = open("/proc/stb/info/model")
-        model = fp.read().lstrip().rstrip()
-        fp.close()
-        list.append(model)
-        #please remove unneeded debugoutpu while commiting #print list
-        
-        listR = []
-        listR.append(list)
-        
-        
-        return listR
-
-    text = property(command)        
-    
-    list = property(command)
-    lut = {"enigmaVersion": 0
-           ,"lanMac": 1
-           ,"lanDHCP": 2
-           ,"lanIP": 3
-           ,"lanMask": 4
-           ,"lanGW": 5
-           ,"fpVersion": 6
-           ,"tunerInfo": 7
-           ,"hddInfo": 8
-           ,"serviceName": 9
-           ,"serviceProvider": 10
-           ,"serviceAspect": 11
-           ,"serviceVideosize": 12
-           ,"serviceNamespace": 13
-           ,"vPID": 14
-           ,"aPID": 15
-           ,"pcrID": 16
-           ,"pmtPID": 17
-           ,"txtPID": 18
-           ,"tsID": 19
-           ,"onID": 20
-           ,"sid": 21
-           ,"WebIfVersion": 22
-           ,"model": 23
-           }
\ No newline at end of file
+       def __init__(self, session):
+               Source.__init__(self)
+               self.session = session
+
+       def handleCommand(self,cmd):
+               self.result = False,"unknown command"
+
+       def command(self):
+               list = []
+               list.append(about.getVersionString())
+
+               #Get Network Info
+               def ConvertIP(list):
+                       if(len(list) == 4):
+                               retstr = "%s.%s.%s.%s" %(list[0], list[1], list[2], list[3])
+                       else:
+                               retstr = "0.0.0.0"
+                       return retstr
+
+               if iNetwork.getNumberOfAdapters > 0:
+                       iface = iNetwork.getAdapterList()[0]
+                       print "[WebComponents.About] iface: %s" %iface
+                       list.append(iNetwork.getAdapterAttribute(iface, "mac"))
+                       list.append(iNetwork.getAdapterAttribute(iface, "dhcp"))
+                       list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "ip")))
+                       list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "netmask")))
+                       list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "gateway")))
+               else:
+                       print "[WebComponents.About] no network iface configured!"
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+
+               #Get FrontProcessor Version
+               fp_version = getFPVersion()
+               if fp_version is None:
+                       fp_version = "?"
+               else:
+                       fp_version = str(fp_version)
+               list.append(fp_version)
+
+               #Get Tuner Info
+               niminfo = ""
+               for nim in nimmanager.nimList():
+                       info = nim.split(":")
+
+                       niminfo += "\n\t\t\t<e2nim>\n"
+                       niminfo += "\t\t\t\t<name>%s</name>\n" %(info[0])
+                       niminfo += "\t\t\t\t<type>%s</type>\n" %(info[1])
+                       niminfo += "\t\t\t</e2nim>"
+
+               list.append(niminfo)
+
+               #Get HDD Info
+               if len(harddiskmanager.hdd):
+                       hdddata = harddiskmanager.hdd[0] # TODO, list more than the first harddisc if there are more than one. but this requires many changes in the way the webif generates the responses
+                       hddinfo = "\n\t\t\t<model>"+hdddata.model()+"</model>\n"
+                       hddinfo += "\t\t\t<capacity>"+hdddata.capacity()+"</capacity>\n"
+                       hddinfo += "\t\t\t<free>"+str(hdddata.free())+" MB</free>"
+                       list.append(hddinfo)
+               else:
+                       hddinfo = "\n\t\t\t<model>N/A</model>\n"
+                       hddinfo += "\t\t\t<capacity>-</capacity>\n"
+                       hddinfo += "\t\t\t<free>-</free>"
+                       list.append(hddinfo)
+
+               #Get Service Info
+               service = self.session.nav.getCurrentService()
+
+               if self.session.nav.getCurrentlyPlayingServiceReference() is not None:
+                       Name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()
+               else:
+                       Name = "N/A"
+               list.append(Name)
+
+               if service is not None:
+                       svinfo = service.info()
+                       svfeinfo = service.frontendInfo()
+               else:
+                       svinfo = None
+                       svfeinfo = None
+
+               # Get Service Info
+               if self.session.nav.getCurrentlyPlayingServiceReference() is not None:
+                       list.append(svinfo.getInfoString(iServiceInformation.sProvider))
+
+                       aspect = svinfo.getInfo(iServiceInformation.sAspect)
+                       if aspect in ( 1, 2, 5, 6, 9, 0xA, 0xD, 0xE ):
+                               aspect = "4:3"
+                       else:
+                               aspect = "16:9"
+                       list.append(aspect)
+
+                       width = svinfo and svinfo.getInfo(iServiceInformation.sVideoWidth) or -1
+                       height = svinfo and svinfo.getInfo(iServiceInformation.sVideoHeight) or -1
+                       videosize = "%dx%d" %(width, height)
+                       list.append(videosize)
+
+                       list.append(hex(svinfo.getInfo(iServiceInformation.sNamespace)))
+
+                       # Get PIDs
+                       list.append(svinfo.getInfo(iServiceInformation.sVideoPID))
+                       list.append(svinfo.getInfo(iServiceInformation.sAudioPID))
+                       list.append(svinfo.getInfo(iServiceInformation.sPCRPID))
+                       list.append(svinfo.getInfo(iServiceInformation.sPMTPID))
+                       list.append(svinfo.getInfo(iServiceInformation.sTXTPID))
+                       list.append(svinfo.getInfo(iServiceInformation.sTSID))
+                       list.append(svinfo.getInfo(iServiceInformation.sONID))
+                       list.append(svinfo.getInfo(iServiceInformation.sSID))
+               else:
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+                       list.append("N/A")
+
+               ## webifversion
+               list.append(config.plugins.Webinterface.version.value)
+
+               #box model
+               fp = open("/proc/stb/info/model")
+               model = fp.read().lstrip().rstrip()
+               fp.close()
+               list.append(model)
+               #please remove unneeded debugoutpu while commiting #print list
+
+               listR = []
+               listR.append(list)
+
+               return listR
+
+       text = property(command)
+       list = property(command)
+       lut = {"enigmaVersion": 0
+                       ,"lanMac": 1
+                       ,"lanDHCP": 2
+                       ,"lanIP": 3
+                       ,"lanMask": 4
+                       ,"lanGW": 5
+                       ,"fpVersion": 6
+                       ,"tunerInfo": 7
+                       ,"hddInfo": 8
+                       ,"serviceName": 9
+                       ,"serviceProvider": 10
+                       ,"serviceAspect": 11
+                       ,"serviceVideosize": 12
+                       ,"serviceNamespace": 13
+                       ,"vPID": 14
+                       ,"aPID": 15
+                       ,"pcrID": 16
+                       ,"pmtPID": 17
+                       ,"txtPID": 18
+                       ,"tsID": 19
+                       ,"onID": 20
+                       ,"sid": 21
+                       ,"WebIfVersion": 22
+                       ,"model": 23
+                       }
index 36abb66..8924feb 100644 (file)
@@ -2,77 +2,76 @@ from Components.Sources.Source import Source
 from Tools.ISO639 import LanguageCodes
 
 class AudioTracks( Source ):
-    
-    GET = 0
-    SET = 1
-    
-    text="False"
-    
-    def __init__(self, session, func=GET):
-        self.cmd = None
-        self.session = session
-        self.func = func
-        Source.__init__(self)
-    
-    def handleCommand(self, cmd):
-        self.cmd = cmd
-    
-    def setAudioTrack(self):
-        if self.cmd is not None:
-            service = self.session.nav.getCurrentService()
-            audio = service and service.audioTracks()
-            try:
-                cmd = int(self.cmd)
-            except ValueError:
-                cmd = -1
-                
-            print "COMMAND is %s" %self.cmd
-            if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > cmd and cmd >= 0:
-                audio.selectTrack(cmd)
-                return "Success"
-            else:
-                return "Error"
-        else:
-            return "Error"
-     
-    def getAudioTracks(self):
-        service = self.session.nav.getCurrentService()
-        audio = service and service.audioTracks()
-        n = audio and audio.getNumberOfTracks() or 0
-        
-        tracklist = []
-        
-        #check for standby
-        if audio is not None and service is not None: 
-            currentTrack = audio.getCurrentTrack()
-    
-            if n > 0:
-                print "[AudioTracks.py] got %s Audiotracks!" %(n)
-                
-                for x in range(n):
-                    i = audio.getTrackInfo(x)
-
-                    language = i.getLanguage()
-                    description = i.getDescription()
-                    pid = i.getPID()
-                    
-                    if LanguageCodes.has_key(language):
-                        language = LanguageCodes[language][0]
-                    
-                    if len(description):
-                        description += " (" + language + ")"
-                    else:
-                        description = language
-                    
-                    if x == currentTrack:
-                        active = "True"
-                    else:
-                        active = "False"
-                    
-                    tracklist.append((description, x, pid, active))
-        
-        return tracklist
-    
-    text = property(setAudioTrack)
-    list = property(getAudioTracks)
-    lut = {"Description": 0, "Id": 1, "Pid": 2, "Active": 3}
\ No newline at end of file
+       GET = 0
+       SET = 1
+
+       text="False"
+
+       def __init__(self, session, func=GET):
+               self.cmd = None
+               self.session = session
+               self.func = func
+               Source.__init__(self)
+
+       def handleCommand(self, cmd):
+               self.cmd = cmd
+
+       def setAudioTrack(self):
+               if self.cmd is not None:
+                       service = self.session.nav.getCurrentService()
+                       audio = service and service.audioTracks()
+                       try:
+                               cmd = int(self.cmd)
+                       except ValueError:
+                               cmd = -1
+
+                       print "COMMAND is %s" %self.cmd
+                       if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > cmd and cmd >= 0:
+                               audio.selectTrack(cmd)
+                               return "Success"
+                       else:
+                               return "Error"
+               else:
+                       return "Error"
+
+       def getAudioTracks(self):
+               service = self.session.nav.getCurrentService()
+               audio = service and service.audioTracks()
+               n = audio and audio.getNumberOfTracks() or 0
+
+               tracklist = []
+
+               #check for standby
+               if audio is not None and service is not None:
+                       currentTrack = audio.getCurrentTrack()
+
+                       if n > 0:
+                               print "[AudioTracks.py] got %s Audiotracks!" %(n)
+
+                               for x in range(n):
+                                       i = audio.getTrackInfo(x)
+
+                                       language = i.getLanguage()
+                                       description = i.getDescription()
+                                       pid = i.getPID()
+
+                                       if LanguageCodes.has_key(language):
+                                               language = LanguageCodes[language][0]
+
+                                       if len(description):
+                                               description += " (" + language + ")"
+                                       else:
+                                               description = language
+
+                                       if x == currentTrack:
+                                               active = "True"
+                                       else:
+                                               active = "False"
+
+                                       tracklist.append((description, x, pid, active))
+
+               return tracklist
+
+       text = property(setAudioTrack)
+       list = property(getAudioTracks)
+       lut = {"Description": 0, "Id": 1, "Pid": 2, "Active": 3}
index 63061fd..70e6554 100644 (file)
@@ -2,20 +2,18 @@ from Components.Sources.Source import Source
 from ServiceReference import ServiceReference
 
 class CurrentService(Source):
+       def __init__(self, session):
+               Source.__init__(self)
+               self.session = session
 
-    def __init__(self, session):
-        Source.__init__(self)
-        self.session = session
+       def command(self):
+               currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()
+               if currentServiceRef is not None:
+                       text = currentServiceRef.toString()
+               else:
+                       text = "N/A"
 
-    def command(self):
-        currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()
-        if currentServiceRef is not None:
-            text = currentServiceRef.toString()
-        else:
-            text = "N/A"
+               return text
 
-
-        return text
-
-    text = property(command)
+       text = property(command)
 
index d7ad804..d464887 100644 (file)
@@ -2,19 +2,17 @@ from Components.Sources.Source import Source
 from Components.Harddisk import harddiskmanager
 
 class Hdd(Source):
-    def __init__(self, devicecount = 0):
-        Source.__init__(self)
-        self.devicecount = devicecount
-    
-    def getHddData(self):
-        if len(harddiskmanager.hdd) > 0:
-            return harddiskmanager.hdd[0] # TODO, list more than the first harddisc if there are more than one. but this requires many changes in the way the webif generates the responses
-        else:
-            return None
-        
-    
-            
-    hdd = property(getHddData)
-    
-    def destroy(self):
-        Source.destroy(self)
\ No newline at end of file
+       def __init__(self, devicecount = 0):
+               Source.__init__(self)
+               self.devicecount = devicecount
+
+       def getHddData(self):
+               if len(harddiskmanager.hdd) > 0:
+                       return harddiskmanager.hdd[0] # TODO, list more than the first harddisc if there are more than one. but this requires many changes in the way the webif generates the responses
+               else:
+                       return None
+
+       hdd = property(getHddData)
+
+       def destroy(self):
+               Source.destroy(self)
index 23343d6..73f170a 100644 (file)
@@ -2,52 +2,52 @@ from Components.Sources.Source import Source
 from Components.config import config
 
 class LocationsAndTags(Source):
-    CURRLOCATION = 0
-    LOCATIONS = 1
-    TAGS = 2
-    
-    def __init__(self, session, func):
-        self.func = func
-        Source.__init__(self)        
-        self.session = session
-        self.result = False,"one two three four unknown command"
-
-    def handleCommand(self, cmd):
-        if self.func is self.CURRLOCATION:
-            self.result = [self.getCurrentLocation()]
-        elif self.func is self.LOCATIONS:
-            self.result = self.getLocations()
-        elif self.func is self.TAGS:
-            self.result = self.getTags()
-        else:
-            self.result = False
-
-    def getCurrentLocation(self):
-        return config.movielist.last_videodir.value
-
-    def getLocations(self):
-        return config.movielist.videodirs.value
-
-    def getTags(self):
-        try:
-            file = open("/etc/enigma2/movietags")
-            tags = [x.rstrip() for x in file.readlines()]
-            while "" in tags:
-                tags.remove("")
-            file.close()
-        except IOError, ioe:
-            tags = []
-        return tags
-
-    def getText(self):
-        self.handleCommand(None)
-        print self.result
-        lst = self.result
-        xml  = "<e2simplexmllist>\n"
-        if self.result:
-            for ele in self.result:
+       CURRLOCATION = 0
+       LOCATIONS = 1
+       TAGS = 2
+
+       def __init__(self, session, func):
+               self.func = func
+               Source.__init__(self)
+               self.session = session
+               self.result = False,"one two three four unknown command"
+
+       def handleCommand(self, cmd):
+               if self.func is self.CURRLOCATION:
+                       self.result = [self.getCurrentLocation()]
+               elif self.func is self.LOCATIONS:
+                       self.result = self.getLocations()
+               elif self.func is self.TAGS:
+                       self.result = self.getTags()
+               else:
+                       self.result = False
+
+       def getCurrentLocation(self):
+               return config.movielist.last_videodir.value
+
+       def getLocations(self):
+               return config.movielist.videodirs.value
+
+       def getTags(self):
+               try:
+                       file = open("/etc/enigma2/movietags")
+                       tags = [x.rstrip() for x in file.readlines()]
+                       while "" in tags:
+                               tags.remove("")
+                       file.close()
+               except IOError, ioe:
+                       tags = []
+               return tags
+
+       def getText(self):
+               self.handleCommand(None)
+               print self.result
+               lst = self.result
+               xml = "<e2simplexmllist>\n"
+               if self.result:
+                       for ele in self.result:
                xml += "<e2simplexmlitem>%s</e2simplexmlitem>\n"%ele
-        xml += "</e2simplexmllist>\n"
-        return xml
-    
-    text = property(getText)
+               xml += "</e2simplexmllist>\n"
+               return xml
+
+       text = property(getText)
index 7d0a27d..58c6e18 100644 (file)
@@ -5,176 +5,176 @@ from Components.FileList import FileList
 from os import path as os_path
 
 class MP( Source):
-    LIST = 0
-    PLAY = 1
-    COMMAND = 3
-    WRITEPLAYLIST = 4
-    
-    def __init__(self, session,func = LIST):
-        Source.__init__(self)
-        self.func = func
-        self.session = session
-        error = "unknown command (%s)" % func
-        self.result = [[error,error,error]]
-    
-    def handleCommand(self,cmd):       
-        self.cmd = cmd
-        if self.func is self.LIST:
-            self.result = self.getFileList(cmd)
-        elif self.func is self.PLAY:
-            self.result = self.playFile(cmd)
-        elif self.func is self.COMMAND:
-            self.result = self.command(cmd)
-        elif self.func is self.WRITEPLAYLIST:
-            self.result = self.writePlaylist(cmd)
-
-    def tryOpenMP(self):
-        # See is the Link is still active
-        if self.session.mediaplayer is not None:
-            try:
-                test = len(self.session.mediaplayer.playlist)
-                return True
-            except:
-                pass
-        
-        # Link inactive, instantiate new MP
-        try:
-            from Plugins.Extensions.MediaPlayer.plugin import MediaPlayer, MyPlayList
-            self.session.mediaplayer = self.session.open(MediaPlayer)
-            self.session.mediaplayer.playlist = MyPlayList()
-            return True
-        
-        # No MP installed
-        except ImportError, ie:
-            return False
-           
-    def getFileList(self,param):
-        print "getFileList:",param
-        
-        returnList = []
-        
-        if param["path"] == "playlist":
-            # TODO: Fix dummy return if unable to load mp
-            if not self.tryOpenMP():
-                returnList.append(["empty","True","playlist"])
-                return returnList
-            
-            mp = self.session.mediaplayer
-            if len(mp.playlist) != 0:
-                serviceRefList = mp.playlist.getServiceRefList()
-                for count in range(len(serviceRefList)):
-                    returnList.append([serviceRefList[count].toString(),"True","playlist"])
-            else:
-                returnList.append(["empty","True","playlist"])
-            
-            return returnList
-
-        matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob)" #MediaPlayer-Match
-        useServiceRef = False
-        if param["types"] == "audio":
-            matchingPattern = "(?i)^.*\.(mp3|ogg|wav|wave|m3u|pls|e2pls)"
-            useServiceRef = True
-        elif param["types"] == "video":
-            matchingPattern = "(?i)^.*\.(ts|avi|mpeg|m3u|pls|e2pls|mpg|vob)"
-            useServiceRef = True
-        elif param["types"] == "any":
-            matchingPattern = ".*"
-        else:
-            matchingPattern = param["types"]
-
-        filelist = FileList(param["path"], showDirectories = True, showFiles = True, matchingPattern = matchingPattern, useServiceRef = useServiceRef, isTop = False)
-        list = filelist.getFileList()
-        for x in list:
-            if useServiceRef == True:
-                if x[0][1] == False: #isDir
-                    returnList.append([x[0][0].toString(),x[0][1],param["path"]])
-                else:
-                    returnList.append([x[0][0],x[0][1],param["path"]])
-            else:
-                if x[0][1] == False: #isDir
-                    returnList.append([param["path"]+x[0][0],x[0][1],param["path"]])
-                else:
-                    returnList.append([x[0][0],x[0][1],param["path"]])
-
-        return returnList
-
-    def playFile(self,param):
-        print "playFile: ",param
-        # TODO: fix error handling
-        if not self.tryOpenMP():
-            return
-
-        root = param["root"]
-        file = param["file"]
-
-        mp = self.session.mediaplayer
-        ref = eServiceReference(file)
-        
-        mp.switchToPlayList()
-        
-        if len(mp.playlist) == 1:
-                mp.changeEntry(0)
-        
-        mp.playlist.addFile(ref)
-
-        #mp.playServiceRefEntry(ref)
-        print "len len(mp.playlist.getServiceRefList()): ",len(mp.playlist.getServiceRefList())
-        if len(mp.playlist.getServiceRefList()):
-            lastEntry = len(mp.playlist.getServiceRefList()) -1
-            currref = mp.playlist.getServiceRefList()[lastEntry]
-            if self.session.nav.getCurrentlyPlayingServiceReference() is None or currref != self.session.nav.getCurrentlyPlayingServiceReference():
-                self.session.nav.playService(mp.playlist.getServiceRefList()[lastEntry])
-                info = eServiceCenter.getInstance().info(currref)
-                description = info and info.getInfoString(currref, iServiceInformation.sDescription) or ""
-                mp["title"].setText(description)
-            mp.unPauseService()
-            #mp.playEntry(len(self.playlist.getServiceRefList()))
-        
-        mp.playlist.updateList()
-        mp.infoTimerFire()
-        return
-    #
-    def writePlaylist(self,param):
-        print "writePlaylist: ",param
-        filename = "playlist/%s.e2pls" % param
-        from Tools.Directories import resolveFilename, SCOPE_CONFIG
-        
-        # TODO: fix error handling
-        if not self.tryOpenMP():
-            return
-        
-        mp = self.session.mediaplayer
-        mp.playlistIOInternal.save(resolveFilename(SCOPE_CONFIG, filename))
-        
-    def command(self,param):
-        print "command: ",param
-        
-        # TODO: fix error handling
-        if not self.tryOpenMP():
-            return
-        
-        mp = self.session.mediaplayer
-        
-        if param == "previous":
-            mp.previousEntry()
-        elif param == "play":
-            mp.playEntry()
-        elif param == "pause":
-            mp.pauseEntry()
-        elif param == "next":
-            mp.nextEntry()
-        elif param == "stop":
-            mp.stopEntry()
-        elif param == "exit":
-            mp.exit()
-        
-        return
-    
-    def getList(self):
-        return self.result
-    
-    list = property(getList)
-    lut = {"ServiceReference": 0
-           ,"IsDirectory": 1
-           ,"Root": 2
-           }
+       LIST = 0
+       PLAY = 1
+       COMMAND = 3
+       WRITEPLAYLIST = 4
+
+       def __init__(self, session,func = LIST):
+               Source.__init__(self)
+               self.func = func
+               self.session = session
+               error = "unknown command (%s)" % func
+               self.result = [[error,error,error]]
+
+       def handleCommand(self,cmd):
+               self.cmd = cmd
+               if self.func is self.LIST:
+                       self.result = self.getFileList(cmd)
+               elif self.func is self.PLAY:
+                       self.result = self.playFile(cmd)
+               elif self.func is self.COMMAND:
+                       self.result = self.command(cmd)
+               elif self.func is self.WRITEPLAYLIST:
+                       self.result = self.writePlaylist(cmd)
+
+       def tryOpenMP(self):
+               # See is the Link is still active
+               if self.session.mediaplayer is not None:
+                       try:
+                               test = len(self.session.mediaplayer.playlist)
+                               return True
+                       except:
+                               pass
+
+               # Link inactive, instantiate new MP
+               try:
+                       from Plugins.Extensions.MediaPlayer.plugin import MediaPlayer, MyPlayList
+                       self.session.mediaplayer = self.session.open(MediaPlayer)
+                       self.session.mediaplayer.playlist = MyPlayList()
+                       return True
+
+               # No MP installed
+               except ImportError, ie:
+                       return False
+
+       def getFileList(self,param):
+               print "getFileList:",param
+
+               returnList = []
+
+               if param["path"] == "playlist":
+                       # TODO: Fix dummy return if unable to load mp
+                       if not self.tryOpenMP():
+                               returnList.append(["empty","True","playlist"])
+                               return returnList
+
+                       mp = self.session.mediaplayer
+                       if len(mp.playlist) != 0:
+                               serviceRefList = mp.playlist.getServiceRefList()
+                               for count in range(len(serviceRefList)):
+                                       returnList.append([serviceRefList[count].toString(),"True","playlist"])
+                       else:
+                               returnList.append(["empty","True","playlist"])
+
+                       return returnList
+
+               matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob)" #MediaPlayer-Match
+               useServiceRef = False
+               if param["types"] == "audio":
+                       matchingPattern = "(?i)^.*\.(mp3|ogg|wav|wave|m3u|pls|e2pls)"
+                       useServiceRef = True
+               elif param["types"] == "video":
+                       matchingPattern = "(?i)^.*\.(ts|avi|mpeg|m3u|pls|e2pls|mpg|vob)"
+                       useServiceRef = True
+               elif param["types"] == "any":
+                       matchingPattern = ".*"
+               else:
+                       matchingPattern = param["types"]
+
+               filelist = FileList(param["path"], showDirectories = True, showFiles = True, matchingPattern = matchingPattern, useServiceRef = useServiceRef, isTop = False)
+               list = filelist.getFileList()
+               for x in list:
+                       if useServiceRef == True:
+                               if x[0][1] == False: #isDir
+                                       returnList.append([x[0][0].toString(),x[0][1],param["path"]])
+                               else:
+                                       returnList.append([x[0][0],x[0][1],param["path"]])
+                       else:
+                               if x[0][1] == False: #isDir
+                                       returnList.append([param["path"]+x[0][0],x[0][1],param["path"]])
+                               else:
+                                       returnList.append([x[0][0],x[0][1],param["path"]])
+
+               return returnList
+
+       def playFile(self,param):
+               print "playFile: ",param
+               # TODO: fix error handling
+               if not self.tryOpenMP():
+                       return
+
+               root = param["root"]
+               file = param["file"]
+
+               mp = self.session.mediaplayer
+               ref = eServiceReference(file)
+
+               mp.switchToPlayList()
+
+               if len(mp.playlist) == 1:
+                               mp.changeEntry(0)
+
+               mp.playlist.addFile(ref)
+
+               #mp.playServiceRefEntry(ref)
+               print "len len(mp.playlist.getServiceRefList()): ",len(mp.playlist.getServiceRefList())
+               if len(mp.playlist.getServiceRefList()):
+                       lastEntry = len(mp.playlist.getServiceRefList()) -1
+                       currref = mp.playlist.getServiceRefList()[lastEntry]
+                       if self.session.nav.getCurrentlyPlayingServiceReference() is None or currref != self.session.nav.getCurrentlyPlayingServiceReference():
+                               self.session.nav.playService(mp.playlist.getServiceRefList()[lastEntry])
+                               info = eServiceCenter.getInstance().info(currref)
+                               description = info and info.getInfoString(currref, iServiceInformation.sDescription) or ""
+                               mp["title"].setText(description)
+                       mp.unPauseService()
+                       #mp.playEntry(len(self.playlist.getServiceRefList()))
+
+               mp.playlist.updateList()
+               mp.infoTimerFire()
+               return
+
+       def writePlaylist(self,param):
+               print "writePlaylist: ",param
+               filename = "playlist/%s.e2pls" % param
+               from Tools.Directories import resolveFilename, SCOPE_CONFIG
+
+               # TODO: fix error handling
+               if not self.tryOpenMP():
+                       return
+
+               mp = self.session.mediaplayer
+               mp.playlistIOInternal.save(resolveFilename(SCOPE_CONFIG, filename))
+
+       def command(self,param):
+               print "command: ",param
+
+               # TODO: fix error handling
+               if not self.tryOpenMP():
+                       return
+
+               mp = self.session.mediaplayer
+
+               if param == "previous":
+                       mp.previousEntry()
+               elif param == "play":
+                       mp.playEntry()
+               elif param == "pause":
+                       mp.pauseEntry()
+               elif param == "next":
+                       mp.nextEntry()
+               elif param == "stop":
+                       mp.stopEntry()
+               elif param == "exit":
+                       mp.exit()
+
+               return
+
+       def getList(self):
+               return self.result
+
+       list = property(getList)
+       lut = {"ServiceReference": 0
+                       ,"IsDirectory": 1
+                       ,"Root": 2
+                       }
index c3dcb95..3ed4d25 100644 (file)
@@ -3,97 +3,97 @@ from Screens.MessageBox import MessageBox
 from os import system, path
 
 class Message( Source):
-    PRINT = 0
-    ANSWER = 1
-    yesnoFile = "/tmp/yesno"
-
-    def __init__(self,session, func = PRINT):
-        self.cmd = []
-        self.session = session
-        
-        self.func = func
-        Source.__init__(self)
-        error = "unknown command (%s)" % func
-        self.result = [[False,error]]
-
-    def handleCommand(self,cmd):
-        self.cmd = cmd
-        if self.func is self.PRINT:
-            self.result = self.printMessage(cmd)
-        elif self.func is self.ANSWER:
-            self.result = self.getYesNoAnswer(cmd)
-        
-    def printMessage(self,param):
-        print "printMessage"
-        
-        if self.cmd['text'] == "" or self.cmd['text'] is None:
-            return [[False, "No Messagetext given"]]
-        else:
-            mtext = self.cmd['text']
-
-        try:
-            typeint = int(self.cmd['type'])
-        except ValueError,e:
-            return [[False,"type %s is not a number"%self.cmd['type']]]   
-            
-        if typeint == MessageBox.TYPE_YESNO:
-            #dont know how to give the result to the webif back 
-            mtype= MessageBox.TYPE_YESNO
-        elif typeint == MessageBox.TYPE_INFO:
-            mtype= MessageBox.TYPE_INFO
-        elif typeint == MessageBox.TYPE_WARNING:
-            mtype= MessageBox.TYPE_WARNING
-        elif typeint == MessageBox.TYPE_ERROR:
-            mtype= MessageBox.TYPE_ERROR
-        else:
-            return [[ False, "Unsupported Messagetype %s" %self.cmd['type'] ]]   
-        
-        try:
-            mtimeout = int(self.cmd['timeout'])
-        except ValueError,e:
-            mtimeout = -1
-        
-        if typeint == MessageBox.TYPE_YESNO:
-            self.session.openWithCallback(self.yesNoAnswer, MessageBox, mtext, type = mtype, timeout = mtimeout)
-        else:
-            self.session.open(MessageBox, mtext, type = mtype ,timeout = mtimeout)
-        
-        return [[True, "Message sent successfully!"]]
-    
-    def yesNoAnswer(self, confirmed):
-        print "yesNoAnswer",confirmed
-        #self.session.messageboxanswer = confirmed
-
-        yesnoFile = self.yesnoFile
-        
-        cmdstr = "/bin/echo -n yes > %s" % yesnoFile
-        if not confirmed:
-            cmdstr = "/bin/echo -n no > %s" % yesnoFile
-
-        system(cmdstr)
-    
-    def getYesNoAnswer(self,param):
-        print "getYesNoAnswer"#,self.session.messageboxanswer
-        yesnoFile = self.yesnoFile
-        if path.exists(yesnoFile) == True:
-            file = open(yesnoFile, "r")
-            lines = file.readlines()
-            file.close()
-            cmdstr = "rm %s" % yesnoFile
-            system(cmdstr)
-            print "Answer: (%s)"%lines[0]
-            if lines[0] == "yes":
-                return [[True,"Answer is YES!"]]
-            else:
-                return [[True,"Answer is NO!"]]
-        else:
-            return [[False,"No answer in time"]]
-        
-    def getResults(self):
-        return self.result
-    
-    list = property(getResults)
-    lut = {"Result": 0
-           ,"ResultText": 1
-           }
+       PRINT = 0
+       ANSWER = 1
+       yesnoFile = "/tmp/yesno"
+
+       def __init__(self,session, func = PRINT):
+               self.cmd = []
+               self.session = session
+
+               self.func = func
+               Source.__init__(self)
+               error = "unknown command (%s)" % func
+               self.result = [[False,error]]
+
+       def handleCommand(self,cmd):
+               self.cmd = cmd
+               if self.func is self.PRINT:
+                       self.result = self.printMessage(cmd)
+               elif self.func is self.ANSWER:
+                       self.result = self.getYesNoAnswer(cmd)
+
+       def printMessage(self,param):
+               print "printMessage"
+
+               if self.cmd['text'] == "" or self.cmd['text'] is None:
+                       return [[False, "No Messagetext given"]]
+               else:
+                       mtext = self.cmd['text']
+
+               try:
+                       typeint = int(self.cmd['type'])
+               except ValueError,e:
+                       return [[False,"type %s is not a number"%self.cmd['type']]]
+
+               if typeint == MessageBox.TYPE_YESNO:
+                       #dont know how to give the result to the webif back
+                       mtype= MessageBox.TYPE_YESNO
+               elif typeint == MessageBox.TYPE_INFO:
+                       mtype= MessageBox.TYPE_INFO
+               elif typeint == MessageBox.TYPE_WARNING:
+                       mtype= MessageBox.TYPE_WARNING
+               elif typeint == MessageBox.TYPE_ERROR:
+                       mtype= MessageBox.TYPE_ERROR
+               else:
+                       return [[ False, "Unsupported Messagetype %s" %self.cmd['type'] ]]
+
+               try:
+                       mtimeout = int(self.cmd['timeout'])
+               except ValueError,e:
+                       mtimeout = -1
+
+               if typeint == MessageBox.TYPE_YESNO:
+                       self.session.openWithCallback(self.yesNoAnswer, MessageBox, mtext, type = mtype, timeout = mtimeout)
+               else:
+                       self.session.open(MessageBox, mtext, type = mtype ,timeout = mtimeout)
+
+               return [[True, "Message sent successfully!"]]
+
+       def yesNoAnswer(self, confirmed):
+               print "yesNoAnswer",confirmed
+               #self.session.messageboxanswer = confirmed
+
+               yesnoFile = self.yesnoFile
+
+               cmdstr = "/bin/echo -n yes > %s" % yesnoFile
+               if not confirmed:
+                       cmdstr = "/bin/echo -n no > %s" % yesnoFile
+
+               system(cmdstr)
+
+       def getYesNoAnswer(self,param):
+               print "getYesNoAnswer"#,self.session.messageboxanswer
+               yesnoFile = self.yesnoFile
+               if path.exists(yesnoFile) == True:
+                       file = open(yesnoFile, "r")
+                       lines = file.readlines()
+                       file.close()
+                       cmdstr = "rm %s" % yesnoFile
+                       system(cmdstr)
+                       print "Answer: (%s)"%lines[0]
+                       if lines[0] == "yes":
+                               return [[True,"Answer is YES!"]]
+                       else:
+                               return [[True,"Answer is NO!"]]
+               else:
+                       return [[False,"No answer in time"]]
+
+       def getResults(self):
+               return self.result
+
+       list = property(getResults)
+       lut = {"Result": 0
+                       ,"ResultText": 1
+                       }
 
index 4ccfa76..08fbbea 100644 (file)
@@ -2,37 +2,35 @@ from Components.Sources.Source import Source
 from Components.Network import iNetwork
 #from Components.Element import cached
 
-
 class Network(Source):
-    LAN = 0
-    WLAN = 1
-    
-    def __init__(self, device = LAN):
-        Source.__init__(self)
-        if device is self.LAN:
-            self.iface = "eth0"
-        elif device is self.WLAN:
-            self.iface = "ath0"
-            
-            
-            #Get Network Info
-    def ConvertIP(self, list):
-        if(len(list) == 4):
-            retstr = "%s.%s.%s.%s" %(list[0], list[1], list[2], list[3])
-        else:
-            retstr = "0.0.0.0"
-        return retstr
-#    @cached        
-    def getInterface(self):
-        self.mac =  iNetwork.getAdapterAttribute(self.iface, "mac")
-        self.dhcp = iNetwork.getAdapterAttribute(self.iface, "dhcp")
-        self.ip = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "ip"))
-        self.netmask = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "netmask"))
-        self.gateway = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "gateway"))
-        
-        return self
-        
-    interface = property(getInterface)
-    
-    def destroy(self):
-        Source.destroy(self)
\ No newline at end of file
+       LAN = 0
+       WLAN = 1
+
+       def __init__(self, device = LAN):
+               Source.__init__(self)
+               if device is self.LAN:
+                       self.iface = "eth0"
+               elif device is self.WLAN:
+                       self.iface = "ath0"
+
+                       #Get Network Info
+       def ConvertIP(self, list):
+               if(len(list) == 4):
+                       retstr = "%s.%s.%s.%s" %(list[0], list[1], list[2], list[3])
+               else:
+                       retstr = "0.0.0.0"
+               return retstr
+#      @cached
+       def getInterface(self):
+               self.mac = iNetwork.getAdapterAttribute(self.iface, "mac")
+               self.dhcp = iNetwork.getAdapterAttribute(self.iface, "dhcp")
+               self.ip = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "ip"))
+               self.netmask = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "netmask"))
+               self.gateway = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "gateway"))
+
+               return self
+
+       interface = property(getInterface)
+
+       def destroy(self):
+               Source.destroy(self)
index 1fb8f5c..506bed0 100644 (file)
@@ -4,31 +4,30 @@ from Components.config import config
 from ServiceReference import ServiceReference
 
 class ParentControl( Source):
-    
-    def __init__(self, session):
-        Source.__init__(self)        
-        self.session = session
-        
-    def command(self):
-        print "ParentControl was called"
-        list = []
-        
-        if config.ParentalControl.configured.value:
-            parentalControl.open()
-            servicelist = None
-            if config.ParentalControl.type.value == "whitelist":
-                servicelist = parentalControl.whitelist
-            else:
-                servicelist = parentalControl.blacklist
-            
-            for service_ref in servicelist:
-                list.append( [str(service_ref),ServiceReference(service_ref).getServiceName()] )
-        
-        print "list",list
-        return list
-        
-    list = property(command)
-    lut = {"ServiceReference": 0
-           ,"ServiceName":1
-           }
+       def __init__(self, session):
+               Source.__init__(self)
+               self.session = session
+
+       def command(self):
+               print "ParentControl was called"
+               list = []
+
+               if config.ParentalControl.configured.value:
+                       parentalControl.open()
+                       servicelist = None
+                       if config.ParentalControl.type.value == "whitelist":
+                               servicelist = parentalControl.whitelist
+                       else:
+                               servicelist = parentalControl.blacklist
+
+                       for service_ref in servicelist:
+                               list.append( [str(service_ref),ServiceReference(service_ref).getServiceName()] )
+
+               print "list",list
+               return list
+
+       list = property(command)
+       lut = {"ServiceReference": 0
+                       ,"ServiceName":1
+                       }
 
index 36eb35c..b17fcd3 100644 (file)
@@ -1,54 +1,53 @@
 from Components.Sources.Source import Source
 
 class PowerState(Source):
-        
-    def __init__(self,session):
-        self.cmd = None
-        self.session = session
-        Source.__init__(self)
+       def __init__(self,session):
+               self.cmd = None
+               self.session = session
+               Source.__init__(self)
 
-    def handleCommand(self, cmd):
-        self.cmd = cmd
-    
-    def do_func(self):        
-        if self.cmd == "" or self.cmd is None:
-            print "[PowerState.py] cmd was empty or None"
-            return "error"
-        
-        #-1: get current state
-        # 0: toggle standby
-        # 1: poweroff/deepstandby
-        # 2: rebootdreambox
-        # 3: rebootenigma
-        try:
-            type = int(self.cmd)
-            if type == -1:
-                from Screens.Standby import inStandby
-                if inStandby == None:
-                    return "false"
-                else:
-                    return "true"
-                
-            elif type == 0:
-                print "[PowerState.py] Standby 0"
-                from Screens.Standby import inStandby
-                if inStandby == None:
-                    from Screens.Standby import Standby
-                    self.session.open(Standby)
-                    return "true"
-                else:
-                    inStandby.Power()
-                    return "false"
-                
-            elif 0 < type < 4:
-                print "[PowerState.py] TryQuitMainloop"
-                from Screens.Standby import TryQuitMainloop
-                self.session.open(TryQuitMainloop, type)
-                return "true"
-            else:
-                print "[PowerState.py] cmd unknown" % type
-                return "error"
-        except ValueError:
-            return "error"
-        
-    text = property(do_func)
\ No newline at end of file
+       def handleCommand(self, cmd):
+               self.cmd = cmd
+
+       def do_func(self):
+               if self.cmd == "" or self.cmd is None:
+                       print "[PowerState.py] cmd was empty or None"
+                       return "error"
+
+               #-1: get current state
+               # 0: toggle standby
+               # 1: poweroff/deepstandby
+               # 2: rebootdreambox
+               # 3: rebootenigma
+               try:
+                       type = int(self.cmd)
+                       if type == -1:
+                               from Screens.Standby import inStandby
+                               if inStandby == None:
+                                       return "false"
+                               else:
+                                       return "true"
+
+                       elif type == 0:
+                               print "[PowerState.py] Standby 0"
+                               from Screens.Standby import inStandby
+                               if inStandby == None:
+                                       from Screens.Standby import Standby
+                                       self.session.open(Standby)
+                                       return "true"
+                               else:
+                                       inStandby.Power()
+                                       return "false"
+
+                       elif 0 < type < 4:
+                               print "[PowerState.py] TryQuitMainloop"
+                               from Screens.Standby import TryQuitMainloop
+                               self.session.open(TryQuitMainloop, type)
+                               return "true"
+                       else:
+                               print "[PowerState.py] cmd unknown" % type
+                               return "error"
+               except ValueError:
+                       return "error"
+
+       text = property(do_func)
index 93e6380..0e758b4 100644 (file)
@@ -2,7 +2,6 @@ from struct import pack
 from Components.Sources.Source import Source
 
 class RemoteControl( Source):
-               
        def __init__(self,session):
                self.cmd = None
                self.session = session
@@ -10,35 +9,31 @@ class RemoteControl( Source):
 
        def handleCommand(self, cmd):
                self.cmd = cmd
-               
+
        def do_func(self):
                list = []
-               
+
                if self.cmd == "" or self.cmd is None:
                        print "[RemoteControl.py] cmd is empty or None"
                        return [[False,"Missing or wrong argument"]]
-               
+
                type = int(self.cmd)
                if type <= 0:
                        print "[RemoteControl.py] command <= 0 (%s)" % type
                        return [[False,"the command was not greater 0"]]
-               
-               dataon  = pack('iiHHi',0,0,1,type,1)
-               dataoff  = pack('iiHHi',0,0,1,type,0)
-               
+
+               dataon = pack('iiHHi',0,0,1,type,1)
+               dataoff = pack('iiHHi',0,0,1,type,0)
+
                fp=open("/dev/input/event1", 'wb')
-               
-               fp.write(dataon)        
-               
-               fp.write(dataoff)       
-               
+               fp.write(dataon)
+               fp.write(dataoff)
                fp.close()
-               
+
                print "[RemoteControl.py] command was was sent (%s)" % type
                return [[True, "command was was sent"]]
 
-
        list = property(do_func)
        lut = {"Result": 0
-                  ,"ResultText": 1
-                  }
\ No newline at end of file
+                       ,"ResultText": 1
+                       }
index 81ae67f..a07b5e3 100644 (file)
@@ -12,7 +12,7 @@ class RequestData(Source):
        REMOTEPORT = 5
        REMOTETYPE = 6
        URI = 7
-       
+
        def __init__(self, request, what = None):
                Source.__init__(self)
                self.request = request
@@ -20,7 +20,7 @@ class RequestData(Source):
 
        def handleCommand(self, cmd):
                pass
-               
+
        def getHTML(self, id):
                if self.what is self.HOST:
                        return self.request.host
@@ -39,4 +39,4 @@ class RequestData(Source):
                elif self.what is self.URI:
                        return self.request.uri
                else:
-                       return "N/A"
\ No newline at end of file
+                       return "N/A"
index 38c30b6..4eb1da7 100644 (file)
@@ -4,72 +4,72 @@ from Screens.ChannelSelection import service_types_tv
 from enigma import eServiceReference
 
 class ServiceListRecursive( Source ):
-    FETCH = 0
-    
-    def __init__(self, session, func = FETCH):
-        Source.__init__(self)  
-        
-        self.session = session
-        self.func = func
-        self.servicelist = {}
-        self.xml = ""
-        self.command = eServiceReference(service_types_tv + ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
-    
-    def handleCommand(self,cmd):
-        self.command = eServiceReference(cmd)
-    
-    def do_func(self):
-        if self.func == self.FETCH:
-            func = self.buildList
-        else:
-            func = self.buildList
-        
-        return func(self.command)
-    
-    def buildList(self, ref):
-        self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
-        list = self.servicelist.getServicesAsList()       
-        for index in range(len(list)): 
-            item = list[index]
-            
-            self.servicelist.setRoot(eServiceReference(item[0]))
-            sub = self.servicelist.getServicesAsList()
-            
-            if len(sub) > 0:
-                # list[index] = ( item[0] , item[1], sub )
-                self.xml += "\t<e2bouquet>\n"
-                bouquet = True
-                
-                subxml = ""
-                for (ref, name) in sub:
-                    subxml += "\t\t\t<e2service>\n"
-                    subxml += "\t\t\t\t<e2servicereference>%s</e2servicereference>\n\t\t\t\t<e2servicename>%s</e2servicename>\n" %(self.filterXML(ref), self.filterXML(name))
-                    subxml += "\t\t\t</e2service>\n"
-            
-            else:
-                self.xml += "\t\t<e2service>\n"
-                bouquet = False
-            
-            self.xml += "\t\t<e2servicereference>%s</e2servicereference>\n\t\t<e2servicename>%s</e2servicename>\n" %(self.filterXML(item[0]), self.filterXML(item[1]))
-            
-            if bouquet:
-                self.xml += "\t\t<e2servicelist>\n"
-                self.xml += subxml
-                self.xml += "\t\t</e2servicelist>\n"
-                self.xml += "\t</e2bouquet>\n"
-            else:
-                self.xml += "\t</e2service>\n"
-        
-        return self.xml
-    
-    def filterXML(self, item):
-        item = item.replace("&", "&amp;").replace("<", "&lt;").replace('"', '&quot;').replace(">", "&gt;")
-        return item
-    
-    def getServiceList(self, ref):
-        self.servicelist.root = ref
-            
-    text = property(do_func)
-        
-#    list = property(do_func)
- #   lut = {"ServiceReference": 0, "ServiceName": 1 }
\ No newline at end of file
+       FETCH = 0
+       
+       def __init__(self, session, func = FETCH):
+               Source.__init__(self)
+               
+               self.session = session
+               self.func = func
+               self.servicelist = {}
+               self.xml = ""
+               self.command = eServiceReference(service_types_tv + ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
+       
+       def handleCommand(self,cmd):
+               self.command = eServiceReference(cmd)
+       
+       def do_func(self):
+               if self.func == self.FETCH:
+                       func = self.buildList
+               else:
+                       func = self.buildList
+               
+               return func(self.command)
+       
+       def buildList(self, ref):
+               self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
+               list = self.servicelist.getServicesAsList()
+               for index in range(len(list)): 
+                       item = list[index]
+                       
+                       self.servicelist.setRoot(eServiceReference(item[0]))
+                       sub = self.servicelist.getServicesAsList()
+                       
+                       if len(sub) > 0:
+                               # list[index] = ( item[0] , item[1], sub )
+                               self.xml += "\t<e2bouquet>\n"
+                               bouquet = True
+                               
+                               subxml = ""
+                               for (ref, name) in sub:
+                                       subxml += "\t\t\t<e2service>\n"
+                                       subxml += "\t\t\t\t<e2servicereference>%s</e2servicereference>\n\t\t\t\t<e2servicename>%s</e2servicename>\n" %(self.filterXML(ref), self.filterXML(name))
+                                       subxml += "\t\t\t</e2service>\n"
+                       
+                       else:
+                               self.xml += "\t\t<e2service>\n"
+                               bouquet = False
+                       
+                       self.xml += "\t\t<e2servicereference>%s</e2servicereference>\n\t\t<e2servicename>%s</e2servicename>\n" %(self.filterXML(item[0]), self.filterXML(item[1]))
+                       
+                       if bouquet:
+                               self.xml += "\t\t<e2servicelist>\n"
+                               self.xml += subxml
+                               self.xml += "\t\t</e2servicelist>\n"
+                               self.xml += "\t</e2bouquet>\n"
+                       else:
+                               self.xml += "\t</e2service>\n"
+               
+               return self.xml
+       
+       def filterXML(self, item):
+               item = item.replace("&", "&amp;").replace("<", "&lt;").replace('"', '&quot;').replace(">", "&gt;")
+               return item
+       
+       def getServiceList(self, ref):
+               self.servicelist.root = ref
+                       
+       text = property(do_func)
+               
+#      list = property(do_func)
+#      lut = {"ServiceReference": 0, "ServiceName": 1 }
index 77eb08d..46077a2 100644 (file)
@@ -2,51 +2,51 @@ from enigma import eDVBDB
 from Components.Sources.Source import Source
 
 class ServiceListReload( Source):
-    BOTH = 0
-    LAMEDB = 1
-    USERBOUQUETS = 2
-    
-    def __init__(self, session):
-        Source.__init__(self)
-        self.session = session
-        self.eDVBDB = eDVBDB.getInstance()
-    
-    def handleCommand(self,cmd):       
-        try:
-            self.cmd = int(cmd)
-            if self.cmd is self.BOTH:
-                self.reloadLameDB()
-                self.reloadUserBouquets()
-                self.result = [['true','reloaded both']]
-            elif self.cmd is self.LAMEDB:
-                self.result = self.reloadLameDB()
-                self.result = [['true','reloaded lamedb']]
-            elif self.cmd is self.USERBOUQUETS:
-                self.result = self.reloadUserBouquets()
-                self.result = [['true','reloaded bouquets']]
-            else:
-                self.result = False # results in message generated in getList
-        except Exception,e:
-            self.result = False # results in message generated in getList
+       BOTH = 0
+       LAMEDB = 1
+       USERBOUQUETS = 2
 
-    def reloadLameDB(self):
-        print "[WebInterface] reloading lamedb"
-        self.eDVBDB.reloadServicelist()
-        
-    def reloadUserBouquets(self):
-        print "[WebInterface] reloading userbouquets"
-        self.eDVBDB.reloadBouquets()
-    
-    def getList(self):
-        try:
-            if self.result:
-                return self.result
-            else:
-                raise AttributeError
-        except AttributeError:
-            return [['false',"missing or wrong parameter mode [%i=both, %i=lamedb only, %i=userbouqets only]"%(self.BOTH,self.LAMEDB,self.USERBOUQUETS) ]]
-    
-    list = property(getList)
-    lut = {"result": 0
-           ,"mode": 1
-           }
+       def __init__(self, session):
+               Source.__init__(self)
+               self.session = session
+               self.eDVBDB = eDVBDB.getInstance()
+
+       def handleCommand(self,cmd):
+               try:
+                       self.cmd = int(cmd)
+                       if self.cmd is self.BOTH:
+                               self.reloadLameDB()
+                               self.reloadUserBouquets()
+                               self.result = [['true','reloaded both']]
+                       elif self.cmd is self.LAMEDB:
+                               self.result = self.reloadLameDB()
+                               self.result = [['true','reloaded lamedb']]
+                       elif self.cmd is self.USERBOUQUETS:
+                               self.result = self.reloadUserBouquets()
+                               self.result = [['true','reloaded bouquets']]
+                       else:
+                               self.result = False # results in message generated in getList
+               except Exception,e:
+                       self.result = False # results in message generated in getList
+
+       def reloadLameDB(self):
+               print "[WebInterface] reloading lamedb"
+               self.eDVBDB.reloadServicelist()
+
+       def reloadUserBouquets(self):
+               print "[WebInterface] reloading userbouquets"
+               self.eDVBDB.reloadBouquets()
+
+       def getList(self):
+               try:
+                       if self.result:
+                               return self.result
+                       else:
+                               raise AttributeError
+               except AttributeError:
+                       return [['false',"missing or wrong parameter mode [%i=both, %i=lamedb only, %i=userbouqets only]"%(self.BOTH,self.LAMEDB,self.USERBOUQUETS) ]]
+
+       list = property(getList)
+       lut = {"result": 0
+                       ,"mode": 1
+                       }
index 478c5c6..d263636 100644 (file)
@@ -2,31 +2,30 @@ from Components.config import config
 from Components.Sources.Source import Source
 
 class Settings(Source):
-        
-    def __init__(self,session):
-        self.cmd = []
-        self.session = session
-        Source.__init__(self)
+       def __init__(self,session):
+               self.cmd = []
+               self.session = session
+               Source.__init__(self)
 
-    def handleCommand(self, cmd):
-        self.cmd = cmd
-        
-    def do_func(self):
-        result=[]
-        self.pickle_this("config", config.saved_value, result)
-        return result
-    def pickle_this(self, prefix, topickle, result):
-        for (key, val) in topickle.items():
-            name = prefix + "." + key
-            if isinstance(val, dict):
-                self.pickle_this(name, val, result)
-            elif isinstance(val, tuple):
-                result.append([name,val[0]])
-            else:
-                result.append([name,val])
+       def handleCommand(self, cmd):
+               self.cmd = cmd
 
-    list = property(do_func)
-    lut = {"Name": 0           
-           ,"Value": 1
-           }
\ No newline at end of file
+       def do_func(self):
+               result=[]
+               self.pickle_this("config", config.saved_value, result)
+               return result
+
+       def pickle_this(self, prefix, topickle, result):
+               for (key, val) in topickle.items():
+                       name = prefix + "." + key
+                       if isinstance(val, dict):
+                               self.pickle_this(name, val, result)
+                       elif isinstance(val, tuple):
+                               result.append([name,val[0]])
+                       else:
+                               result.append([name,val])
+
+       list = property(do_func)
+       lut = {"Name": 0
+                       ,"Value": 1
+                       }
index af87641..ed0ed38 100644 (file)
@@ -1,42 +1,41 @@
 from Components.Sources.Source import Source
 from ServiceReference import ServiceReference
-from time import sleep
+#from time import sleep
 
 class SubServices(Source):
-    
-    def __init__(self, session):
-        Source.__init__(self)        
-        self.session = session
-        
-    def command(self):
-        print "SubServices was called"
-        list = []
-        
-        #sleep(5) # FIXMEEEEE very ugly code !! 
-        
-        list0 = []
-        currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()
-        if currentServiceRef is not None:
-            list.append( [currentServiceRef.toString(),
-                         ServiceReference(currentServiceRef).getServiceName()] 
-            )
-            
-            currentService = self.session.nav.getCurrentService()
-            subservices = currentService and currentService.subServices()
-            if subservices or subservices.getNumberOfSubservices() != 0:
-                n = subservices and subservices.getNumberOfSubservices()
-                for x in range(n):
-                    sub = subservices.getSubservice(x)                    
-                    list.append([sub.toString(), sub.getName()])
-                
-        else:
-            list.append(["N/A", "N/A"])
-        
-        print "SubServices is returning list ",list
-        return list
-        
-    list = property(command)
-    lut = {"ServiceReference": 0
-           ,"Name": 1
-           }
+       def __init__(self, session):
+               Source.__init__(self)
+               self.session = session
+
+       def command(self):
+               print "SubServices was called"
+               list = []
+
+               #sleep(5) # FIXMEEEEE very ugly code !!
+
+               list0 = []
+               currentServiceRef = self.session.nav.getCurrentlyPlayingServiceReference()
+               if currentServiceRef is not None:
+                       list.append( [currentServiceRef.toString(),
+                                                ServiceReference(currentServiceRef).getServiceName()]
+                       )
+
+                       currentService = self.session.nav.getCurrentService()
+                       subservices = currentService and currentService.subServices()
+                       if subservices or subservices.getNumberOfSubservices() != 0:
+                               n = subservices and subservices.getNumberOfSubservices()
+                               for x in range(n):
+                                       sub = subservices.getSubservice(x)
+                                       list.append([sub.toString(), sub.getName()])
+
+               else:
+                       list.append(["N/A", "N/A"])
+
+               print "SubServices is returning list ",list
+               return list
+
+       list = property(command)
+       lut = {"ServiceReference": 0
+                       ,"Name": 1
+                       }
 
index 95391ba..4711cf9 100644 (file)
@@ -10,188 +10,185 @@ from xml.sax.saxutils import unescape
 from time import time, strftime, localtime, mktime
 
 class Timer( Source):
-    LIST = 0
-    ADDBYID = 1
-    ADD = 2
-    DEL = 3
-    TVBROWSER = 4
-    CHANGE = 5
-    WRITE = 6
-    RECNOW = 7
-    
-    def __init__(self, session, func = LIST):
-        self.func = func
-        Source.__init__(self)
-        self.session = session
-        self.recordtimer = session.nav.RecordTimer
-        self.epgcache = eEPGCache.getInstance()
-        self.result = False,"unknown command"
-        
-
-    def handleCommand(self, cmd):
-        if self.func is self.ADDBYID:
-            self.result = self.addTimerByEventID(cmd)
-            self.writeTimerList()
-        elif self.func is self.ADD:
-            self.result = self.editTimer(cmd)
-            self.writeTimerList()
-        elif self.func is self.TVBROWSER:
-            self.result = self.tvBrowser(cmd)
-            self.writeTimerList()
-        elif self.func is self.DEL:
-            self.result = self.delTimer(cmd)
-            self.writeTimerList()
-        elif self.func is self.CHANGE:
-            self.result = self.editTimer(cmd)
-            self.writeTimerList()
-        elif self.func is self.WRITE:
-            self.result = self.writeTimerList(force=True)
-        elif self.func is self.RECNOW:
-            print "RECNOW"
-            self.result = self.recordNow(cmd)
-        else:
-            self.result = False, "Unknown function: '%s'" %(self.func)
-
-
-
-    def delTimer(self, param):
-        print "[WebComponents.Timer] delTimer"
-        
-        if param.has_key('sRef'):
-            service_ref = ServiceReference(param['sRef'])            
-        else: 
-            return False, "Missing Parameter: sRef"
-        
-        if param.has_key('begin'):
-            begin = int(float(param['begin']))
-        else:
-            return False, "Missing Parameter: begin"
-        
-        if param.has_key('end'):
-            end = int(float(param['end']))
-        else:
-               return False, "Missing Parameter: end"
-             
-        try:
-            for timer in self.recordtimer.timer_list + self.recordtimer.processed_timers:
-                if str(timer.service_ref) == str(service_ref) and int(timer.begin) == begin and int(timer.end) == end:
-                    self.recordtimer.removeEntry(timer)
-                    return True, "The timer '%s' has been deleted successfully" %(timer.name)
-        except:
-            return False, "The timer has NOT been deleted"
-            
-               return False, "No matching Timer found"
-
-    
-    def tvBrowser(self, param):
-        print "[WebComponents.Timer] tvbrowser"
-        
-        """ The URL's for the tvBrowser-Capture-Driver are:
-        
-            http://dreambox/web/tvbrowser? +
-            
-        To add something:
-            &command=add&&year={year}&month={month}&day={day}&shour={start_hour}&smin={start_minute}&ehour={end_hour}&emin={end_minute}&sRef={urlencode(channel_name_external, "utf8")}&name={urlencode(title, "utf8")}&description={urlencode(descr, "utf8")}&dirname={dirname}&tags={urlencode("tag1 tag2...", "utf8")}&afterevent=0&eit=&disabled=0&justplay=0&repeated=0
-        
-        to zap for some time:
-            &command=add&&year={year}&month={month}&day={day}&shour={start_hour}&smin={start_minute}&ehour={end_hour}&emin={end_minute}&sRef={urlencode(channel_name_external, "utf8")}&name={urlencode(title, "utf8")}&description={urlencode(descr, "utf8")}&dirname={dirname}&tags={urlencode("tag1 tag2...", "utf8")}&afterevent=0&eit=&disabled=0&justplay=1&repeated=0
-        
-        to delete something:
-            &command=del&&year={year}&month={month}&day={day}&shour={start_hour}&smin={start_minute}&ehour={end_hour}&emin={end_minute}&sRef={urlencode(channel_name_external, "utf8")}
-        """
-        
-        listDate = ['year','month','day','shour','smin','ehour','emin']
-        for element in listDate:
-            if param[element] is None:
-                if param['s'+element] is None:
-                    return False,"%s missing"%element
-                else:
-                    param[element] = int(param['s'+element])
-            else:
-                param[element] = int(param[element])
-        param['begin'] = int(mktime( (param['year'], param['month'], param['day'], param['shour'], param['smin'], 0, 0, 0, -1) ) )
-        param['end']   = int(mktime( (param['year'], param['month'], param['day'], param['ehour'], param['emin'], 0, 0, 0, -1) ) )
-        if param['end'] < param['begin']:
-            param['end'] += 86400
-        for element in listDate:
-            del param[element]
-        
-        if param['sRef'] is None:
-            return False, "Missing Parameter: sRef"
-        else:
-            takeApart = param['sRef'].split('|')
-            if len(takeApart) > 1:
-                param['sRef'] = takeApart[1]
-        
-        repeated = int(param.get('repeated') or 0)
-        if repeated == 0:
-            list = ["mo","tu","we","th","fr","sa","su","ms","mf"]
-            for element in list:
-                if param.has_key(element):
-                    number = param[element] or 0
-                    del param[element]
-                    repeated = repeated + int(number)
-            if repeated > 127:
-                repeated = 127
-        param['repeated'] = repeated
-
-        if param['command'] == "add":
-            del param['command']
-            return self.editTimer(param)
-        elif param['command'] == "del":
-            del param['command']
-            return self.delTimer(param)
-        elif param['command'] == "change":
-            del param['command']
-            return self.editTimer(param)
-        else:
-            return False, "Unknown command: '%s'" %param['command']
-    
-    def recordNow(self,param):
-        print "recordNow ",param
-        
-        limitEvent = True
-        if param == "undefinitely":
-            limitEvent = False
-        
-        serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
-        print serviceref
-        #assert isinstance(serviceref, ServiceReference)
-        serviceref = ServiceReference(serviceref.toString())
-        event = None
-        try:
-            service = self.session.nav.getCurrentService()
-            event = self.epgcache.lookupEventTime(serviceref, -1, 0)
-            if event is None:
-                info = service.info()
-                ev = info.getEvent(0)
-                event = ev
-        except:
-            pass
-
-        begin = time()
-        end = begin + 3600 * 10
-        name = "instant record"
-        description = ""
-        eventid = 0
-
-        if event is not None:
-            curEvent = parseEvent(event)
-            name = curEvent[2]
-            description = curEvent[3]
-            eventid = curEvent[4]
-            if limitEvent:
-                end = curEvent[1]
-        else:
-            if limitEvent:
-                return False, "No event found, started infinite recording"
-
-        location = config.movielist.last_videodir.value
-        timer = RecordTimerEntry(serviceref, begin, end, name, description, eventid, False, False, 0, dirname = location)
-        timer.dontSave = True
-        self.recordtimer.record(timer)
-
-        return True, "Instant recording started"
+       LIST = 0
+       ADDBYID = 1
+       ADD = 2
+       DEL = 3
+       TVBROWSER = 4
+       CHANGE = 5
+       WRITE = 6
+       RECNOW = 7
+
+       def __init__(self, session, func = LIST):
+               self.func = func
+               Source.__init__(self)
+               self.session = session
+               self.recordtimer = session.nav.RecordTimer
+               self.epgcache = eEPGCache.getInstance()
+               self.result = False,"unknown command"
+
+       def handleCommand(self, cmd):
+               if self.func is self.ADDBYID:
+                       self.result = self.addTimerByEventID(cmd)
+                       self.writeTimerList()
+               elif self.func is self.ADD:
+                       self.result = self.editTimer(cmd)
+                       self.writeTimerList()
+               elif self.func is self.TVBROWSER:
+                       self.result = self.tvBrowser(cmd)
+                       self.writeTimerList()
+               elif self.func is self.DEL:
+                       self.result = self.delTimer(cmd)
+                       self.writeTimerList()
+               elif self.func is self.CHANGE:
+                       self.result = self.editTimer(cmd)
+                       self.writeTimerList()
+               elif self.func is self.WRITE:
+                       self.result = self.writeTimerList(force=True)
+               elif self.func is self.RECNOW:
+                       print "RECNOW"
+                       self.result = self.recordNow(cmd)
+               else:
+                       self.result = False, "Unknown function: '%s'" %(self.func)
+
+
+
+       def delTimer(self, param):
+               print "[WebComponents.Timer] delTimer"
+
+               if param.has_key('sRef'):
+                       service_ref = ServiceReference(param['sRef'])
+               else:
+                       return False, "Missing Parameter: sRef"
+
+               if param.has_key('begin'):
+                       begin = int(float(param['begin']))
+               else:
+                       return False, "Missing Parameter: begin"
+
+               if param.has_key('end'):
+                       end = int(float(param['end']))
+               else:
+                       return False, "Missing Parameter: end"
+
+               try:
+                       for timer in self.recordtimer.timer_list + self.recordtimer.processed_timers:
+                               if str(timer.service_ref) == str(service_ref) and int(timer.begin) == begin and int(timer.end) == end:
+                                       self.recordtimer.removeEntry(timer)
+                                       return True, "The timer '%s' has been deleted successfully" %(timer.name)
+               except:
+                       return False, "The timer has NOT been deleted"
+
+                       return False, "No matching Timer found"
+
+       def tvBrowser(self, param):
+               """ The URL's for the tvBrowser-Capture-Driver are:
+
+                       http://dreambox/web/tvbrowser? +
+
+               To add something:
+                       &command=add&&year={year}&month={month}&day={day}&shour={start_hour}&smin={start_minute}&ehour={end_hour}&emin={end_minute}&sRef={urlencode(channel_name_external, "utf8")}&name={urlencode(title, "utf8")}&description={urlencode(descr, "utf8")}&dirname={dirname}&tags={urlencode("tag1 tag2...", "utf8")}&afterevent=0&eit=&disabled=0&justplay=0&repeated=0
+
+               to zap for some time:
+                       &command=add&&year={year}&month={month}&day={day}&shour={start_hour}&smin={start_minute}&ehour={end_hour}&emin={end_minute}&sRef={urlencode(channel_name_external, "utf8")}&name={urlencode(title, "utf8")}&description={urlencode(descr, "utf8")}&dirname={dirname}&tags={urlencode("tag1 tag2...", "utf8")}&afterevent=0&eit=&disabled=0&justplay=1&repeated=0
+
+               to delete something:
+                       &command=del&&year={year}&month={month}&day={day}&shour={start_hour}&smin={start_minute}&ehour={end_hour}&emin={end_minute}&sRef={urlencode(channel_name_external, "utf8")}
+               """
+               print "[WebComponents.Timer] tvbrowser"
+
+               listDate = ['year','month','day','shour','smin','ehour','emin']
+               for element in listDate:
+                       if param[element] is None:
+                               if param['s'+element] is None:
+                                       return False,"%s missing"%element
+                               else:
+                                       param[element] = int(param['s'+element])
+                       else:
+                               param[element] = int(param[element])
+               param['begin'] = int(mktime( (param['year'], param['month'], param['day'], param['shour'], param['smin'], 0, 0, 0, -1) ) )
+               param['end']    = int(mktime( (param['year'], param['month'], param['day'], param['ehour'], param['emin'], 0, 0, 0, -1) ) )
+               if param['end'] < param['begin']:
+                       param['end'] += 86400
+               for element in listDate:
+                       del param[element]
+
+               if param['sRef'] is None:
+                       return False, "Missing Parameter: sRef"
+               else:
+                       takeApart = param['sRef'].split('|')
+                       if len(takeApart) > 1:
+                               param['sRef'] = takeApart[1]
+
+               repeated = int(param.get('repeated') or 0)
+               if repeated == 0:
+                       list = ["mo","tu","we","th","fr","sa","su","ms","mf"]
+                       for element in list:
+                               if param.has_key(element):
+                                       number = param[element] or 0
+                                       del param[element]
+                                       repeated = repeated + int(number)
+                       if repeated > 127:
+                               repeated = 127
+               param['repeated'] = repeated
+
+               if param['command'] == "add":
+                       del param['command']
+                       return self.editTimer(param)
+               elif param['command'] == "del":
+                       del param['command']
+                       return self.delTimer(param)
+               elif param['command'] == "change":
+                       del param['command']
+                       return self.editTimer(param)
+               else:
+                       return False, "Unknown command: '%s'" %param['command']
+
+       def recordNow(self,param):
+               print "recordNow ",param
+
+               limitEvent = True
+               if param == "undefinitely":
+                       limitEvent = False
+
+               serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
+               print serviceref
+               #assert isinstance(serviceref, ServiceReference)
+               serviceref = ServiceReference(serviceref.toString())
+               event = None
+               try:
+                       service = self.session.nav.getCurrentService()
+                       event = self.epgcache.lookupEventTime(serviceref, -1, 0)
+                       if event is None:
+                               info = service.info()
+                               ev = info.getEvent(0)
+                               event = ev
+               except:
+                       pass
+
+               begin = time()
+               end = begin + 3600 * 10
+               name = "instant record"
+               description = ""
+               eventid = 0
+
+               if event is not None:
+                       curEvent = parseEvent(event)
+                       name = curEvent[2]
+                       description = curEvent[3]
+                       eventid = curEvent[4]
+                       if limitEvent:
+                               end = curEvent[1]
+               else:
+                       if limitEvent:
+                               return False, "No event found, started infinite recording"
+
+               location = config.movielist.last_videodir.value
+               timer = RecordTimerEntry(serviceref, begin, end, name, description, eventid, False, False, 0, dirname = location)
+               timer.dontSave = True
+               self.recordtimer.record(timer)
+
+               return True, "Instant recording started"
 
 
 #===============================================================================
@@ -200,301 +197,299 @@ class Timer( Source):
 # Otherwise, and if the parameters channelOld, beginOld and endOld are set,
 # an existing timer with corresponding values will be changed.
 #===============================================================================
-    def editTimer(self, param):
-        print "[WebComponents.Timer] editTimer"
-        
-        #OK first we need to parse all of your Parameters
-        #For some of them (like afterEvent or justplay) we can use default values
-        #for others (the serviceReference or the Begin/End time of the timer 
-        #we have to quit if they are not set/have illegal values
-              
-        if param.has_key('sRef'):
-            service_ref = ServiceReference(param['sRef'])
-        else:
-            return False, "Missing Parameter: sRef"
-
-        repeated = int(param.get('repeated') or 0)
-
-        if not param.has_key('begin'):
-            return False, "Missing Parameter: begin"
-        begin = int(float(param['begin']))
-
-        if not param.has_key('end'): 
-            return False, "Missing Parameter: end"
-        end = int(float(param['end']))
-          
-        tm = time()
-        if tm <= begin:                
-            pass
-        elif tm > begin and tm < end and repeated == 0:
-            begin = time()
-        elif repeated == 0:
-            return False, "Illegal Parameter value for Parameter begin : '%s'" %begin              
-        
-        if param.has_key('name'):
-            name = param['name']
-        else:
-            return False, "Missing Parameter: name"
-        
-        if param.has_key('description'):
-            description = param['description'].replace("\n", " ")
-        else:
-            return False, "Missing Parameter: description"
-                
-        disabled = False #Default to: Enabled
-        if param.has_key('disabled'):            
-            if param['disabled'] == "1":
-                disabled = True
-            else:
-                #TODO - maybe we can give the user some useful hint here
-                pass
-            
-        justplay = False #Default to: Record
-        if param.has_key('justplay'):
-            if param['justplay'] == "1":
-                justplay =  True
-            
-        afterEvent = 3 #Default to Afterevent: Auto
-        if param.has_key('afterevent'):
-            if ( param['afterevent'] == "0") or (param['afterevent'] == "1") or (param['afterevent'] == "2"):
-                afterEvent = int(param['afterevent'])
-
-        dirname = config.movielist.last_timer_videodir.value
-        if param.has_key('dirname') and param['dirname']:
-            dirname = param['dirname']
-
-        tags = []
-        if param.has_key('tags') and param['tags']:
-            tags = unescape(param['tags']).split(' ')
-
-        delold = 0
-        if param.has_key('deleteOldOnSave'):
-            delold = int(param['deleteOldOnSave'])
-
-        #Try to edit an existing Timer
-        if delold:
-            if param.has_key('channelOld') and param['channelOld'] != '':
-                channelOld = ServiceReference(param['channelOld'])
-            else:
-                return False, "Missing Parameter: channelOld"
-            # We do need all of the following Parameters, too, for being able of finding the Timer.
-            # Therefore so we can neither use default values in this part nor can we 
-            # continue if a parameter is missing            
-            if param.has_key('beginOld'):
-                beginOld = int(param['beginOld'])
-            else:
-                return False, "Missing Parameter: beginOld"
-            
-            if param.has_key('endOld'):
-                endOld = int(param['endOld'])
-            else:
-                return False, "Missing Parameter: endOld"
-            
-            #let's try to find the timer
-            try:
-                for timer in self.recordtimer.timer_list + self.recordtimer.processed_timers:
-                    if str(timer.service_ref) == str(channelOld):
-                        if int(timer.begin) == beginOld:
-                            if int(timer.end) == endOld:
-                                #we've found the timer we've been searching for
-                                #Let's apply the new values
-                                timer.service_ref = service_ref
-                                timer.begin = int(begin)
-                                timer.end = int(end)
-                                timer.name = name
-                                timer.description = description
-                                timer.disabled = disabled
-                                timer.justplay = justplay
-                                timer.afterEvent = afterEvent
-                                timer.repeated = repeated
-                                timer.dirname = dirname
-                                timer.tags = tags
-                                
-                                #send the changed timer back to enigma2 and hope it's good
-                                self.session.nav.RecordTimer.timeChanged(timer)
-                                print "[WebComponents.Timer] editTimer: Timer changed!"
-                                return True, "Timer %s has been changed!" %(timer.name)
-            except:
-                #obviously some value was not good, return an error
-                return False, "Changing the timer for '%s' failed!" %name
-            
-            return False, "Could not find timer '%s' with given start and end time!" %name
-
-        #Try adding a new Timer
-
-        try:
-            #Create a new instance of recordtimerentry
-            timer = RecordTimerEntry(service_ref, begin, end, name, description, 0, disabled, justplay, afterEvent, dirname = dirname, tags = tags)
-            timer.repeated = repeated
-            #add the new timer
-            self.recordtimer.record(timer)
-            return True, "Timer added successfully!"
-        except:
-            #something went wrong, most possibly one of the given paramater-values was wrong
-            return False, "Could not add timer '%s'!" %name
-            
-        return False, "Unexpected Error"
-                
-
-    def addTimerByEventID(self, param):
-        print "[WebComponents.Timer] addTimerByEventID", param
-        if param['sRef'] is None:
-            return False, "Missing Parameter: sRef"
-        if param['eventid'] is None:
-            return False, "Missing Parameter: eventid"
-        
-        justplay = False
-        if param['justplay'] is not None:
-            if param['justplay'] == "1":
-                justplay = True
-
-        location = config.movielist.last_timer_videodir.value
-        if param.has_key('dirname') and param['dirname']:
-            location = param['dirname']
-        tags = []
-        if param.has_key('tags') and param['tags']:
-            tags = unescape(param['tags']).split(' ')
-
-        epgcache = eEPGCache.getInstance()
-        event = epgcache.lookupEventId(eServiceReference(param['sRef']),int(param['eventid']))
-        if event is None:
-            return False, "EventId not found"
-        
-        (begin, end, name, description, eit) = parseEvent(event)
-
-        timer = RecordTimerEntry(ServiceReference(param['sRef']), begin , end, name, description, eit, False, justplay, AFTEREVENT.NONE, dirname=location, tags=tags)
-        self.recordtimer.record(timer)
-        return True, "Timer '%s' added" %(timer.name)  
-            
-        
-    def writeTimerList(self, force=False):
-        # is there an easier and better way? :\
-        if config.plugins.Webinterface.autowritetimer.value or force: 
-            print "Timer.py writing timer to flash"
-            self.session.nav.RecordTimer.saveTimer()
-            return True, "TimerList was saved "
-        else:
-            return False, "TimerList was not saved "    
-
-
-    def getText(self):
-        print "[WebComponents.Timer] result: ", self.result
-        (result, text) = self.result
-        xml  = "<e2simplexmlresult>\n"
-        if result:
-            xml += "<e2state>True</e2state>\n"
-        else:
-            xml += "<e2state>False</e2state>\n"
-        xml += "<e2statetext>%s</e2statetext>\n" % text
-        xml += "</e2simplexmlresult>\n"
-        return xml
-    
-    text = property(getText)
-    
-    ## part for listfiller requests
-    def command(self):
-        timerlist = []
-
-        for item in self.recordtimer.timer_list + self.recordtimer.processed_timers:
-            timer = []
-            timer.append(item.service_ref)
-            timer.append(item.service_ref.getServiceName())
-            timer.append(item.eit)
-            timer.append(item.name)
-            timer.append(item.description)
-
-            if item.disabled:
-                timer.append("1")
-            else:
-                timer.append("0")
-
-            timer.append(item.begin)
-            timer.append(item.end)
-            timer.append(item.end - item.begin)
-            timer.append(item.start_prepare)
-            
-            if item.justplay:
-                timer.append(1)
-            else:
-                timer.append(0)
-
-            timer.append(item.afterEvent)
-            
-            timer.append(item.dirname)
-            timer.append(" ".join(item.tags))
-
-            timer.append(item.log_entries)
-            
-            try:
-                timer.append(item.Filename)
-            except:
-                timer.append("")
-            
-            timer.append(item.backoff)
-            
-            try:
-                timer.append(item.next_activation)
-            except:
-                timer.append("")
-                
-            timer.append(item.first_try_prepare)  
-            timer.append(item.state)
-            timer.append(item.repeated)
-            
-            if item.dontSave:
-                timer.append(1)
-            else:
-                timer.append(0)
-
-            timer.append(item.cancelled)
-            
-            if item.eit is not None:
-                event = self.epgcache.lookupEvent(['EX',("%s" % item.service_ref ,2,item.eit)])
-                if event and event[0][0] is not None:
-                    timer.append(event[0][0])
-                else:
-                    timer.append("N/A")
-            else:
-                timer.append("N/A")
-            
-            #toggleDisabled
-            if item.disabled:
-                timer.append("0")
-                timer.append("on")
-            else:
-                timer.append("1")
-                timer.append("off")
-
-            timerlist.append(timer)
-            
-        return timerlist
-    
-    list = property(command)
-    lut = {
-               "ServiceReference":0,
-               "ServiceName": 1,
-               "EIT":2,
-               "Name":3,
-               "Description":4,
-               "Disabled":5,
-               "TimeBegin":6,
-               "TimeEnd":7,
-               "Duration":8,
-               "startPrepare":9,
-               "justPlay":10,
-               "afterEvent":11,
-               "Location":12,
-               "Tags":13,
-               "LogEntries":14,
-               "Filename":15,
-               "Backoff":16,
-               "nextActivation":17,
-               "firstTryPrepare":18,
-               "State":19,
-               "Repeated":20,
-               "dontSave":21,
-               "Cancled":22,
-               "DescriptionExtended":23,
-               "toggleDisabled":24,
-               "toggleDisabledIMG":25,
-           }
+       def editTimer(self, param):
+               print "[WebComponents.Timer] editTimer"
+
+               #OK first we need to parse all of your Parameters
+               #For some of them (like afterEvent or justplay) we can use default values
+               #for others (the serviceReference or the Begin/End time of the timer
+               #we have to quit if they are not set/have illegal values
+
+               if param.has_key('sRef'):
+                       service_ref = ServiceReference(param['sRef'])
+               else:
+                       return False, "Missing Parameter: sRef"
+
+               repeated = int(param.get('repeated') or 0)
+
+               if not param.has_key('begin'):
+                       return False, "Missing Parameter: begin"
+               begin = int(float(param['begin']))
+
+               if not param.has_key('end'):
+                       return False, "Missing Parameter: end"
+               end = int(float(param['end']))
+
+               tm = time()
+               if tm <= begin:
+                       pass
+               elif tm > begin and tm < end and repeated == 0:
+                       begin = time()
+               elif repeated == 0:
+                       return False, "Illegal Parameter value for Parameter begin : '%s'" %begin
+
+               if param.has_key('name'):
+                       name = param['name']
+               else:
+                       return False, "Missing Parameter: name"
+
+               if param.has_key('description'):
+                       description = param['description'].replace("\n", " ")
+               else:
+                       return False, "Missing Parameter: description"
+
+               disabled = False #Default to: Enabled
+               if param.has_key('disabled'):
+                       if param['disabled'] == "1":
+                               disabled = True
+                       else:
+                               #TODO - maybe we can give the user some useful hint here
+                               pass
+
+               justplay = False #Default to: Record
+               if param.has_key('justplay'):
+                       if param['justplay'] == "1":
+                               justplay =  True
+
+               afterEvent = 3 #Default to Afterevent: Auto
+               if param.has_key('afterevent'):
+                       if ( param['afterevent'] == "0") or (param['afterevent'] == "1") or (param['afterevent'] == "2"):
+                               afterEvent = int(param['afterevent'])
+
+               dirname = config.movielist.last_timer_videodir.value
+               if param.has_key('dirname') and param['dirname']:
+                       dirname = param['dirname']
+
+               tags = []
+               if param.has_key('tags') and param['tags']:
+                       tags = unescape(param['tags']).split(' ')
+
+               delold = 0
+               if param.has_key('deleteOldOnSave'):
+                       delold = int(param['deleteOldOnSave'])
+
+               #Try to edit an existing Timer
+               if delold:
+                       if param.has_key('channelOld') and param['channelOld'] != '':
+                               channelOld = ServiceReference(param['channelOld'])
+                       else:
+                               return False, "Missing Parameter: channelOld"
+                       # We do need all of the following Parameters, too, for being able of finding the Timer.
+                       # Therefore so we can neither use default values in this part nor can we
+                       # continue if a parameter is missing
+                       if param.has_key('beginOld'):
+                               beginOld = int(param['beginOld'])
+                       else:
+                               return False, "Missing Parameter: beginOld"
+
+                       if param.has_key('endOld'):
+                               endOld = int(param['endOld'])
+                       else:
+                               return False, "Missing Parameter: endOld"
+
+                       #let's try to find the timer
+                       try:
+                               for timer in self.recordtimer.timer_list + self.recordtimer.processed_timers:
+                                       if str(timer.service_ref) == str(channelOld):
+                                               if int(timer.begin) == beginOld:
+                                                       if int(timer.end) == endOld:
+                                                               #we've found the timer we've been searching for
+                                                               #Let's apply the new values
+                                                               timer.service_ref = service_ref
+                                                               timer.begin = int(begin)
+                                                               timer.end = int(end)
+                                                               timer.name = name
+                                                               timer.description = description
+                                                               timer.disabled = disabled
+                                                               timer.justplay = justplay
+                                                               timer.afterEvent = afterEvent
+                                                               timer.repeated = repeated
+                                                               timer.dirname = dirname
+                                                               timer.tags = tags
+
+                                                               #send the changed timer back to enigma2 and hope it's good
+                                                               self.session.nav.RecordTimer.timeChanged(timer)
+                                                               print "[WebComponents.Timer] editTimer: Timer changed!"
+                                                               return True, "Timer %s has been changed!" %(timer.name)
+                       except:
+                               #obviously some value was not good, return an error
+                               return False, "Changing the timer for '%s' failed!" %name
+
+                       return False, "Could not find timer '%s' with given start and end time!" %name
+
+               #Try adding a new Timer
+
+               try:
+                       #Create a new instance of recordtimerentry
+                       timer = RecordTimerEntry(service_ref, begin, end, name, description, 0, disabled, justplay, afterEvent, dirname = dirname, tags = tags)
+                       timer.repeated = repeated
+                       #add the new timer
+                       self.recordtimer.record(timer)
+                       return True, "Timer added successfully!"
+               except:
+                       #something went wrong, most possibly one of the given paramater-values was wrong
+                       return False, "Could not add timer '%s'!" %name
+
+               return False, "Unexpected Error"
+
+       def addTimerByEventID(self, param):
+               print "[WebComponents.Timer] addTimerByEventID", param
+               if param['sRef'] is None:
+                       return False, "Missing Parameter: sRef"
+               if param['eventid'] is None:
+                       return False, "Missing Parameter: eventid"
+
+               justplay = False
+               if param['justplay'] is not None:
+                       if param['justplay'] == "1":
+                               justplay = True
+
+               location = config.movielist.last_timer_videodir.value
+               if param.has_key('dirname') and param['dirname']:
+                       location = param['dirname']
+               tags = []
+               if param.has_key('tags') and param['tags']:
+                       tags = unescape(param['tags']).split(' ')
+
+               epgcache = eEPGCache.getInstance()
+               event = epgcache.lookupEventId(eServiceReference(param['sRef']),int(param['eventid']))
+               if event is None:
+                       return False, "EventId not found"
+
+               (begin, end, name, description, eit) = parseEvent(event)
+
+               timer = RecordTimerEntry(ServiceReference(param['sRef']), begin , end, name, description, eit, False, justplay, AFTEREVENT.NONE, dirname=location, tags=tags)
+               self.recordtimer.record(timer)
+               return True, "Timer '%s' added" %(timer.name)
+
+       def writeTimerList(self, force=False):
+               # is there an easier and better way? :\
+               if config.plugins.Webinterface.autowritetimer.value or force:
+                       print "Timer.py writing timer to flash"
+                       self.session.nav.RecordTimer.saveTimer()
+                       return True, "TimerList was saved "
+               else:
+                       return False, "TimerList was not saved "
+
+
+       def getText(self):
+               print "[WebComponents.Timer] result: ", self.result
+               (result, text) = self.result
+               xml  = "<e2simplexmlresult>\n"
+               if result:
+                       xml += "<e2state>True</e2state>\n"
+               else:
+                       xml += "<e2state>False</e2state>\n"
+               xml += "<e2statetext>%s</e2statetext>\n" % text
+               xml += "</e2simplexmlresult>\n"
+               return xml
+
+       text = property(getText)
+
+       ## part for listfiller requests
+       def command(self):
+               timerlist = []
+
+               for item in self.recordtimer.timer_list + self.recordtimer.processed_timers:
+                       timer = []
+                       timer.append(item.service_ref)
+                       timer.append(item.service_ref.getServiceName())
+                       timer.append(item.eit)
+                       timer.append(item.name)
+                       timer.append(item.description)
+
+                       if item.disabled:
+                               timer.append("1")
+                       else:
+                               timer.append("0")
+
+                       timer.append(item.begin)
+                       timer.append(item.end)
+                       timer.append(item.end - item.begin)
+                       timer.append(item.start_prepare)
+
+                       if item.justplay:
+                               timer.append(1)
+                       else:
+                               timer.append(0)
+
+                       timer.append(item.afterEvent)
+
+                       timer.append(item.dirname)
+                       timer.append(" ".join(item.tags))
+
+                       timer.append(item.log_entries)
+
+                       try:
+                               timer.append(item.Filename)
+                       except:
+                               timer.append("")
+
+                       timer.append(item.backoff)
+
+                       try:
+                               timer.append(item.next_activation)
+                       except:
+                               timer.append("")
+
+                       timer.append(item.first_try_prepare)
+                       timer.append(item.state)
+                       timer.append(item.repeated)
+
+                       if item.dontSave:
+                               timer.append(1)
+                       else:
+                               timer.append(0)
+
+                       timer.append(item.cancelled)
+
+                       if item.eit is not None:
+                               event = self.epgcache.lookupEvent(['EX',("%s" % item.service_ref ,2,item.eit)])
+                               if event and event[0][0] is not None:
+                                       timer.append(event[0][0])
+                               else:
+                                       timer.append("N/A")
+                       else:
+                               timer.append("N/A")
+
+                       #toggleDisabled
+                       if item.disabled:
+                               timer.append("0")
+                               timer.append("on")
+                       else:
+                               timer.append("1")
+                               timer.append("off")
+
+                       timerlist.append(timer)
+
+               return timerlist
+
+       list = property(command)
+       lut = {
+                               "ServiceReference":0,
+                               "ServiceName": 1,
+                               "EIT":2,
+                               "Name":3,
+                               "Description":4,
+                               "Disabled":5,
+                               "TimeBegin":6,
+                               "TimeEnd":7,
+                               "Duration":8,
+                               "startPrepare":9,
+                               "justPlay":10,
+                               "afterEvent":11,
+                               "Location":12,
+                               "Tags":13,
+                               "LogEntries":14,
+                               "Filename":15,
+                               "Backoff":16,
+                               "nextActivation":17,
+                               "firstTryPrepare":18,
+                               "State":19,
+                               "Repeated":20,
+                               "dontSave":21,
+                               "Cancled":22,
+                               "DescriptionExtended":23,
+                               "toggleDisabled":24,
+                               "toggleDisabledIMG":25,
+                       }
index 12790d3..a2fa859 100644 (file)
@@ -4,62 +4,61 @@ from GlobalActions import globalActionMap
 from Components.VolumeControl import VolumeControl
 
 class Volume(Source):
-        
-    def __init__(self,session, command_default="state"):
-        self.cmd = command_default
-        Source.__init__(self)
-        global globalActionMap # hackalert :)       
-        self.actionmap = globalActionMap
-        self.volctrl = eDVBVolumecontrol.getInstance() # this is not nice
-        #self.volcontrol = VolumeControl(session)
-    def handleCommand(self, cmd):
-        self.cmd = cmd
-        
-    def do_func(self):
-        list = []
-        if self.cmd == "state":
-            list.append(True)
-            list.append("State")
-        elif self.cmd == "up":
-            self.actionmap.actions["volumeUp"]()
-            list.append(True)
-            list.append("Volume changed")
-        elif self.cmd == "down":
-            self.actionmap.actions["volumeDown"]()
-            list.append(True)
-            list.append("Volume changed")
-        elif self.cmd == "mute":
-            self.actionmap.actions["volumeMute"]()
-            list.append(True)
-            list.append("Mute toggled")
-        elif self.cmd.startswith("set"):
-            try:
-                targetvol = int(self.cmd[3:])
-                if targetvol>100:
-                    targetvol = 100
-                if targetvol<0:
-                    targetvol = 0
-                
-                self.volctrl.setVolume(targetvol, targetvol) 
+       def __init__(self,session, command_default="state"):
+               self.cmd = command_default
+               Source.__init__(self)
+               global globalActionMap # hackalert :)
+               self.actionmap = globalActionMap
+               self.volctrl = eDVBVolumecontrol.getInstance() # this is not nice
+               #self.volcontrol = VolumeControl(session)
 
-                list.append(True)
-                list.append("Volume set to %i" % targetvol)
-            except ValueError: # if cmd was set12NotInt
-                list.append(False)
-                list.append("Wrong parameter format 'set=%s'. Use set=set15 "%self.cmd)
-        else:
-            list.append(False)
-            list.append("Unknown Volume command %s" %self.cmd)
-        list.append(self.volctrl.getVolume())
-        list.append(self.volctrl.isMuted())
-        
-        return [list]
-    
-    list = property(do_func)
-    lut = {"Result": 0
-           ,"ResultText": 1
-           ,"Volume": 2
-           ,"isMuted": 3
-           }
+       def handleCommand(self, cmd):
+               self.cmd = cmd
+
+       def do_func(self):
+               list = []
+               if self.cmd == "state":
+                       list.append(True)
+                       list.append("State")
+               elif self.cmd == "up":
+                       self.actionmap.actions["volumeUp"]()
+                       list.append(True)
+                       list.append("Volume changed")
+               elif self.cmd == "down":
+                       self.actionmap.actions["volumeDown"]()
+                       list.append(True)
+                       list.append("Volume changed")
+               elif self.cmd == "mute":
+                       self.actionmap.actions["volumeMute"]()
+                       list.append(True)
+                       list.append("Mute toggled")
+               elif self.cmd.startswith("set"):
+                       try:
+                               targetvol = int(self.cmd[3:])
+                               if targetvol>100:
+                                       targetvol = 100
+                               if targetvol<0:
+                                       targetvol = 0
+
+                               self.volctrl.setVolume(targetvol, targetvol)
+
+                               list.append(True)
+                               list.append("Volume set to %i" % targetvol)
+                       except ValueError: # if cmd was set12NotInt
+                               list.append(False)
+                               list.append("Wrong parameter format 'set=%s'. Use set=set15 "%self.cmd)
+               else:
+                       list.append(False)
+                       list.append("Unknown Volume command %s" %self.cmd)
+               list.append(self.volctrl.getVolume())
+               list.append(self.volctrl.isMuted())
+
+               return [list]
+
+       list = property(do_func)
+       lut = {"Result": 0
+                       ,"ResultText": 1
+                       ,"Volume": 2
+                       ,"isMuted": 3
+                       }
 
-        
\ No newline at end of file
index 8071582..b6f0f27 100644 (file)
@@ -9,340 +9,340 @@ from re import sub
 from time import strftime, localtime, time
 
 class WAPfunctions( Source):
-    LISTTIME = 0
-    REPEATED = 1
-    SERVICELIST = 2
-    OPTIONLIST = 3
-    FILLVALUE = 4
-    LOCATIONLIST = 5
-    TAGLIST = 6
-    DELETEOLD = 7
-    
-    lut = {"Name":0
-          ,"Value":1
-          ,"Selected":2
-          }
-    
-    def __init__(self, session,func = LISTTIME):
-        self.func = func
-        Source.__init__(self)        
-        self.session = session
-        self.result = ["unknown command (%s)"  % self.func]
+       LISTTIME = 0
+       REPEATED = 1
+       SERVICELIST = 2
+       OPTIONLIST = 3
+       FILLVALUE = 4
+       LOCATIONLIST = 5
+       TAGLIST = 6
+       DELETEOLD = 7
+       
+       lut = {"Name":0
+                       ,"Value":1
+                       ,"Selected":2
+       }
+       
+       def __init__(self, session,func = LISTTIME):
+               self.func = func
+               Source.__init__(self)           
+               self.session = session
+               self.result = ["unknown command (%s)" % self.func]
 
-    def handleCommand(self,cmd):
-        print "WAPfunctions: handleCommand", cmd
-        if self.func is self.LISTTIME:
-            self.result = self.fillListTime(cmd)
-        elif self.func is self.REPEATED:
-            self.result = self.fillRepeated(cmd)
-        elif self.func is self.SERVICELIST:
-            self.result = self.serviceList(cmd)
-        elif self.func is self.OPTIONLIST:
-            self.result = self.fillOptionList(cmd)
-        elif self.func is self.FILLVALUE:
-            self.result = self.fillValue(cmd)
-        elif self.func is self.LOCATIONLIST:
-            self.result = self.locationList(cmd)
-        elif self.func is self.TAGLIST:
-            self.result = self.tagList(cmd)
-        elif self.func is self.DELETEOLD:
-            self.result = self.deleteOldSaved(cmd)
-        else:
-            self.result = ["unknown command cmd(%s) self.func(%s)" % (cmd, self.func)]
+       def handleCommand(self,cmd):
+               print "WAPfunctions: handleCommand", cmd
+               if self.func is self.LISTTIME:
+                       self.result = self.fillListTime(cmd)
+               elif self.func is self.REPEATED:
+                       self.result = self.fillRepeated(cmd)
+               elif self.func is self.SERVICELIST:
+                       self.result = self.serviceList(cmd)
+               elif self.func is self.OPTIONLIST:
+                       self.result = self.fillOptionList(cmd)
+               elif self.func is self.FILLVALUE:
+                       self.result = self.fillValue(cmd)
+               elif self.func is self.LOCATIONLIST:
+                       self.result = self.locationList(cmd)
+               elif self.func is self.TAGLIST:
+                       self.result = self.tagList(cmd)
+               elif self.func is self.DELETEOLD:
+                       self.result = self.deleteOldSaved(cmd)
+               else:
+                       self.result = ["unknown command cmd(%s) self.func(%s)" % (cmd, self.func)]
 
-    def fillListTime(self,param):
-        print "fillListTime",param
-        
-        input = 0
-        start = 1
-        end = 1
-        
-        timeNow = time()
-        timePlusTwo = timeNow + 7200
+       def fillListTime(self,param):
+               print "fillListTime",param
+               
+               input = 0
+               start = 1
+               end = 1
+               
+               timeNow = time()
+               timePlusTwo = timeNow + 7200
 
-        if param.has_key('begin'):
-            begin = param['begin'] or 0
-            begin = int(begin)
-            del param['begin']
-            if begin > 0:
-                timeNow = begin
-        if param.has_key('end'):
-            end = param['end'] or 0
-            end = int(end)
-            del param['end']
-            if end > 0:
-                timePlusTwo = end
-        
-        t = {}
-        t["sday"]=t["day"]=strftime("%d", localtime(timeNow))
-        t["smonth"]=t["month"]=strftime("%m", localtime(timeNow))
-        t["syear"]=t["year"]=strftime("%Y", localtime(timeNow))
-        t["smin"]=strftime("%M", localtime(timeNow))
-        t["shour"]=strftime("%H", localtime(timeNow))
-        t["emin"]=strftime("%M", localtime(timePlusTwo))
-        t["ehour"]=strftime("%H", localtime(timePlusTwo))
-        
-        key = ""
-        for i in param:
-            p = str(i)
-            if p != "sRef" and param[p] != None:
-                key = p
+               if param.has_key('begin'):
+                       begin = param['begin'] or 0
+                       begin = int(begin)
+                       del param['begin']
+                       if begin > 0:
+                               timeNow = begin
+               if param.has_key('end'):
+                       end = param['end'] or 0
+                       end = int(end)
+                       del param['end']
+                       if end > 0:
+                               timePlusTwo = end
+               
+               t = {}
+               t["sday"]=t["day"]=strftime("%d", localtime(timeNow))
+               t["smonth"]=t["month"]=strftime("%m", localtime(timeNow))
+               t["syear"]=t["year"]=strftime("%Y", localtime(timeNow))
+               t["smin"]=strftime("%M", localtime(timeNow))
+               t["shour"]=strftime("%H", localtime(timeNow))
+               t["emin"]=strftime("%M", localtime(timePlusTwo))
+               t["ehour"]=strftime("%H", localtime(timePlusTwo))
+               
+               key = ""
+               for i in param:
+                       p = str(i)
+                       if p != "sRef" and param[p] != None:
+                               key = p
 
-        if key == "smin" or key == "emin" :
-            start = 0
-            end = 59
-        elif key == "shour" or key == "ehour":
-            start = 1
-            end = 24
-        elif key == "day" or key == "sday":
-            start = 1
-            end = 31
-        elif key == "month" or key == "smonth":
-            start = 1
-            end = 12
-        else:
-            start = int(t[key])
-            end = int(t[key])+2
-        
-        if param[key] == "now" or param[key] == "end" or param[key] == "begin":
-            input = int(t[key])
-        else:
-            input = param[key] or 0
-            input = int(input)
-        
-        self.result = self.fillOptionListAny(input,start,end)
-        return self.result
-    
-    def fillOptionListAny(self,input,start,end):
-        returnList = []
-        for i in range(start,end+1,1):
-            returnList1 = []
-            j = str(i)
-            if len(j) == 1:
-                j = "0%s" % j
-            returnList1.append(j)
-            returnList1.append(i)
-            if i==input:
-                returnList1.append("selected")
-            else:
-                returnList1.append("")
-            returnList.append(returnList1)
-        return returnList
-        
-    def fillRepeated(self,param):
-        print "fillRepeated",param
-        repeated = param or 0
-        repeated = int(repeated)
-        
-        self.lut = {"Name":0
-          ,"Value":1
-          ,"Description":2
-          ,"Selected":3
-          }
-        
-        mo = ["mo",   1, "Mo "]#"Monday"]
-        tu = ["tu",   2, "Tu "]#"Tuesday"]
-        we = ["we",   4, "We "]#"Wednesday"]
-        th = ["th",   8, "Th "]#"Thursday"]
-        fr = ["fr",  16, "Fr "]#"Friday"]
-        sa = ["sa",  32, "Sa "]#"Saturday"]
-        su = ["su",  64, "Su "]#"Sunday"]
-        mf = ["mf",  31, "Mo-Fr"]
-        ms = ["ms", 127, "Mo-Su"]
-        
-        if repeated == 127:
-            repeated = repeated - 127
-            ms.append("checked")
-        else:
-            ms.append("")
-        
-        if repeated >= 64:
-            repeated = repeated - 64
-            su.append("checked")
-        else:
-            su.append("")
-        
-        if repeated >= 32:
-            repeated = repeated - 32
-            sa.append("checked")
-        else:
-            sa.append("")
-        
-        if repeated == 31:
-            repeated = repeated - 31
-            mf.append("checked")
-        else:
-            mf.append("")
+               if key == "smin" or key == "emin" :
+                       start = 0
+                       end = 59
+               elif key == "shour" or key == "ehour":
+                       start = 1
+                       end = 24
+               elif key == "day" or key == "sday":
+                       start = 1
+                       end = 31
+               elif key == "month" or key == "smonth":
+                       start = 1
+                       end = 12
+               else:
+                       start = int(t[key])
+                       end = int(t[key])+2
+               
+               if param[key] == "now" or param[key] == "end" or param[key] == "begin":
+                       input = int(t[key])
+               else:
+                       input = param[key] or 0
+                       input = int(input)
+               
+               self.result = self.fillOptionListAny(input,start,end)
+               return self.result
+       
+       def fillOptionListAny(self,input,start,end):
+               returnList = []
+               for i in range(start,end+1,1):
+                       returnList1 = []
+                       j = str(i)
+                       if len(j) == 1:
+                               j = "0%s" % j
+                       returnList1.append(j)
+                       returnList1.append(i)
+                       if i==input:
+                               returnList1.append("selected")
+                       else:
+                               returnList1.append("")
+                       returnList.append(returnList1)
+               return returnList
+               
+       def fillRepeated(self,param):
+               print "fillRepeated",param
+               repeated = param or 0
+               repeated = int(repeated)
+               
+               self.lut = {"Name":0
+                       ,"Value":1
+                       ,"Description":2
+                       ,"Selected":3
+               }
+               
+               mo = ["mo",     1, "Mo "]#"Monday"]
+               tu = ["tu",     2, "Tu "]#"Tuesday"]
+               we = ["we",     4, "We "]#"Wednesday"]
+               th = ["th",     8, "Th "]#"Thursday"]
+               fr = ["fr", 16, "Fr "]#"Friday"]
+               sa = ["sa", 32, "Sa "]#"Saturday"]
+               su = ["su", 64, "Su "]#"Sunday"]
+               mf = ["mf", 31, "Mo-Fr"]
+               ms = ["ms", 127, "Mo-Su"]
+               
+               if repeated == 127:
+                       repeated = repeated - 127
+                       ms.append("checked")
+               else:
+                       ms.append("")
+               
+               if repeated >= 64:
+                       repeated = repeated - 64
+                       su.append("checked")
+               else:
+                       su.append("")
+               
+               if repeated >= 32:
+                       repeated = repeated - 32
+                       sa.append("checked")
+               else:
+                       sa.append("")
+               
+               if repeated == 31:
+                       repeated = repeated - 31
+                       mf.append("checked")
+               else:
+                       mf.append("")
 
-        if repeated >= 16:
-            repeated = repeated - 16
-            fr.append("checked")
-        else:
-            fr.append("")
+               if repeated >= 16:
+                       repeated = repeated - 16
+                       fr.append("checked")
+               else:
+                       fr.append("")
 
-        if repeated >= 8:
-            repeated = repeated - 8
-            th.append("checked")
-        else:
-            th.append("")
-        
-        if repeated >= 4:
-            repeated = repeated - 4
-            we.append("checked")
-        else:
-            we.append("")
-        
-        if repeated >= 2:
-            repeated = repeated - 2
-            tu.append("checked")
-        else:
-            tu.append("")
-        
-        if repeated == 1:
-            repeated = repeated - 1
-            mo.append("checked")
-        else:
-            mo.append("")
-            
-        returnList = []
-        returnList.append(mo)
-        returnList.append(tu)
-        returnList.append(we)
-        returnList.append(th)
-        returnList.append(fr)
-        returnList.append(sa)
-        returnList.append(su)
-        returnList.append(mf)
-        returnList.append(ms)
+               if repeated >= 8:
+                       repeated = repeated - 8
+                       th.append("checked")
+               else:
+                       th.append("")
+               
+               if repeated >= 4:
+                       repeated = repeated - 4
+                       we.append("checked")
+               else:
+                       we.append("")
+               
+               if repeated >= 2:
+                       repeated = repeated - 2
+                       tu.append("checked")
+               else:
+                       tu.append("")
+               
+               if repeated == 1:
+                       repeated = repeated - 1
+                       mo.append("checked")
+               else:
+                       mo.append("")
+                       
+               returnList = []
+               returnList.append(mo)
+               returnList.append(tu)
+               returnList.append(we)
+               returnList.append(th)
+               returnList.append(fr)
+               returnList.append(sa)
+               returnList.append(su)
+               returnList.append(mf)
+               returnList.append(ms)
 
-        return returnList
-    
-    def serviceListOne(self, bouquet, selref):
-        ref = eServiceReference(bouquet)
-        self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
-        self.servicelist.setRoot(ref)
-        returnList = []
-        for (ref2, name) in self.servicelist.getServicesAsList():
-            print "ref2: (",ref2, ") name: (",name,")"
-            returnListPart = []
-            returnListPart.append(name)
-            returnListPart.append(ref2)
-            if ref2 == str(selref):
-                returnListPart.append("selected")
-                self.sRefFound = 1
-            else:
-                returnListPart.append("")
-            returnList.append(returnListPart)
-        return returnList
+               return returnList
+       
+       def serviceListOne(self, bouquet, selref):
+               ref = eServiceReference(bouquet)
+               self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
+               self.servicelist.setRoot(ref)
+               returnList = []
+               for (ref2, name) in self.servicelist.getServicesAsList():
+                       print "ref2: (",ref2, ") name: (",name,")"
+                       returnListPart = []
+                       returnListPart.append(name)
+                       returnListPart.append(ref2)
+                       if ref2 == str(selref):
+                               returnListPart.append("selected")
+                               self.sRefFound = 1
+                       else:
+                               returnListPart.append("")
+                       returnList.append(returnListPart)
+               return returnList
 
-    def serviceList(self,param):
-        print "serviceList: ",param
-        sRef = str(param["sRef"])
-        bouquet = str(param["bouquet"])
-        self.sRefFound = 0
-        
-        if bouquet == '':
-            returnList = []
-            bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
-            ref = eServiceReference(bouquet)
-            self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
-            self.servicelist.setRoot(ref)
-            for (ref2, name) in self.servicelist.getServicesAsList():
-                part = self.serviceListOne(ref2, sRef)
-                if part:
-                    returnList = returnList + [["-- "+name+" --", "<"+name+">", ""]] + part
-            bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
-            ref = eServiceReference(bouquet)
-            self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
-            self.servicelist.setRoot(ref)
-            for (ref2, name) in self.servicelist.getServicesAsList():
-                part = self.serviceListOne(ref2, sRef)
-                if part:
-                    returnList = returnList + [["-- "+name+" --", "<"+name+">", ""]] + part
-        else:
-            returnList = self.serviceListOne(bouquet, sRef)
+       def serviceList(self,param):
+               print "serviceList: ",param
+               sRef = str(param["sRef"])
+               bouquet = str(param["bouquet"])
+               self.sRefFound = 0
+               
+               if bouquet == '':
+                       returnList = []
+                       bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
+                       ref = eServiceReference(bouquet)
+                       self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
+                       self.servicelist.setRoot(ref)
+                       for (ref2, name) in self.servicelist.getServicesAsList():
+                               part = self.serviceListOne(ref2, sRef)
+                               if part:
+                                       returnList = returnList + [["-- "+name+" --", "<"+name+">", ""]] + part
+                       bouquet = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
+                       ref = eServiceReference(bouquet)
+                       self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
+                       self.servicelist.setRoot(ref)
+                       for (ref2, name) in self.servicelist.getServicesAsList():
+                               part = self.serviceListOne(ref2, sRef)
+                               if part:
+                                       returnList = returnList + [["-- "+name+" --", "<"+name+">", ""]] + part
+               else:
+                       returnList = self.serviceListOne(bouquet, sRef)
 
-        if self.sRefFound == 0 and sRef != '':
-            returnListPart = ["Inserted", sRef, "selected"]
-            returnList = [returnListPart] + returnList
-        #print returnList
-        return returnList
+               if self.sRefFound == 0 and sRef != '':
+                       returnListPart = ["Inserted", sRef, "selected"]
+                       returnList = [returnListPart] + returnList
+               #print returnList
+               return returnList
 
-    def getServiceList(self, ref):
-        self.servicelist.root = ref
+       def getServiceList(self, ref):
+               self.servicelist.root = ref
 
-    def locationList(self,param):
-        print "locationList",param
-        dirname = param
-        lst = config.movielist.videodirs.value
-        if not dirname:
-            dirname = "/hdd/movie/"
-        if not dirname in lst:
-            lst = [dirname] + lst
-        returnList = [[lst[i], i, dirname == lst[i] and "selected" or ""] for i in range(len(lst))]
-        return returnList
+       def locationList(self,param):
+               print "locationList",param
+               dirname = param
+               lst = config.movielist.videodirs.value
+               if not dirname:
+                       dirname = "/hdd/movie/"
+               if not dirname in lst:
+                       lst = [dirname] + lst
+               returnList = [[lst[i], i, dirname == lst[i] and "selected" or ""] for i in range(len(lst))]
+               return returnList
 
-    def tagList(self,param):
-        print "tagList",param
-        tag = param
-        try:
-            file = open("/etc/enigma2/movietags")
-            taglist = [x.rstrip() for x in file.readlines()]
-            while "" in taglist:
-                taglist.remove("")
-            file.close()
-        except IOError, ioe:
-            taglist = []
-        if not tag in taglist:
-            taglist = [tag]+taglist
-        if not "" in taglist:
-            taglist.append("")
-        returnList = [[taglist[i], i, tag == taglist[i] and "selected" or ""] for i in range(len(taglist))]
-        return returnList
+       def tagList(self,param):
+               print "tagList",param
+               tag = param
+               try:
+                       file = open("/etc/enigma2/movietags")
+                       taglist = [x.rstrip() for x in file.readlines()]
+                       while "" in taglist:
+                               taglist.remove("")
+                       file.close()
+               except IOError, ioe:
+                       taglist = []
+               if not tag in taglist:
+                       taglist = [tag]+taglist
+               if not "" in taglist:
+                       taglist.append("")
+               returnList = [[taglist[i], i, tag == taglist[i] and "selected" or ""] for i in range(len(taglist))]
+               return returnList
 
-    def fillOptionList(self,param):
-        print "fillOptionList",param
-        returnList = []
-        if param.has_key("justplay"):
-            number = param["justplay"] or 0
-            number = int(number)
-            returnList.append(["Record",0,number==0 and "selected" or ""])
-            returnList.append(["Zap",1,number==1 and "selected" or ""])
-        elif param.has_key("afterevent"):
-            number = param["afterevent"] or 0
-            number = int(number)
-            returnList.append(["Nothing",0,number==0 and "selected" or ""])
-            returnList.append(["Standby",1,number==1 and "selected" or ""])
-            returnList.append(["Deepstandby/Shutdown",2,number==2 and "selected" or ""])
-            returnList.append(["Auto",3,number==3 and "selected" or ""])
-        return returnList
-    
-    def deleteOldSaved(self,param):
-        print "deleteOldSaved",param
-        returnList = []
-        returnList.append(["deleteOldOnSave",param["deleteOldOnSave"],""])
-        returnList.append(["command",param["command"],""])
-        if int(param["deleteOldOnSave"]) == 1:
-            returnList.append(["channelOld",param["sRef"],""])
-            returnList.append(["beginOld",param["begin"],""])
-            returnList.append(["endOld",param["end"],""])
-        return returnList
-            
-    
-    def fillValue(self,param):
-        print "fillValue: ",param
-        return [["",param,""]]
+       def fillOptionList(self,param):
+               print "fillOptionList",param
+               returnList = []
+               if param.has_key("justplay"):
+                       number = param["justplay"] or 0
+                       number = int(number)
+                       returnList.append(["Record",0,number==0 and "selected" or ""])
+                       returnList.append(["Zap",1,number==1 and "selected" or ""])
+               elif param.has_key("afterevent"):
+                       number = param["afterevent"] or 0
+                       number = int(number)
+                       returnList.append(["Nothing",0,number==0 and "selected" or ""])
+                       returnList.append(["Standby",1,number==1 and "selected" or ""])
+                       returnList.append(["Deepstandby/Shutdown",2,number==2 and "selected" or ""])
+                       returnList.append(["Auto",3,number==3 and "selected" or ""])
+               return returnList
+       
+       def deleteOldSaved(self,param):
+               print "deleteOldSaved",param
+               returnList = []
+               returnList.append(["deleteOldOnSave",param["deleteOldOnSave"],""])
+               returnList.append(["command",param["command"],""])
+               if int(param["deleteOldOnSave"]) == 1:
+                       returnList.append(["channelOld",param["sRef"],""])
+                       returnList.append(["beginOld",param["begin"],""])
+                       returnList.append(["endOld",param["end"],""])
+               return returnList
+                       
+       
+       def fillValue(self,param):
+               print "fillValue: ",param
+               return [["",param,""]]
 
-    def getText(self):
-        (result,text) = self.result
-        return text
-    
-    def filterXML(self, item):
-        item = item.replace("&", "&amp;").replace("<", "&lt;").replace('"', '&quot;').replace(">", "&gt;")
-        return item
+       def getText(self):
+               (result,text) = self.result
+               return text
+       
+       def filterXML(self, item):
+               item = item.replace("&", "&amp;").replace("<", "&lt;").replace('"', '&quot;').replace(">", "&gt;")
+               return item
 
-    def getList(self):
-        return self.result
+       def getList(self):
+               return self.result
 
-    text = property(getText)
-    list = property(getList)
+       text = property(getText)
+       list = property(getList)
index f1533df..d54e40a 100644 (file)
@@ -2,7 +2,7 @@ Version = '$Header$';
 
 from __init__ import _
 
-from enigma import  eListboxPythonMultiContent, gFont
+from enigma import eListboxPythonMultiContent, gFont
 from Screens.Screen import Screen
 from Screens.MessageBox import MessageBox
 
@@ -17,295 +17,291 @@ from Components.ActionMap import ActionMap
 
 from Components.Network import iNetwork
 def initInterfaceConfig(i = None, new = False):
-    choices = getConfiguredIPs()
-
-    if i is None and new is True:
-        i = config.plugins.Webinterface.interfacecount.value
-    elif i is None:
-        i = config.plugins.Webinterface.interfacecount.value - 1
-        
-    print "[WebIfConfig.initInterfaceConfig] i is %s" %i
-    config.plugins.Webinterface.interfaces.append(ConfigSubsection())
-    config.plugins.Webinterface.interfaces[i].disabled = ConfigYesNo(default = False)
-    config.plugins.Webinterface.interfaces[i].address = ConfigSelection(choices, default=choices[0])
-    config.plugins.Webinterface.interfaces[i].port = ConfigInteger(80, (0, 65535))
-    config.plugins.Webinterface.interfaces[i].useauth = ConfigYesNo(default = False)
-    config.plugins.Webinterface.interfaces[i].usessl = ConfigYesNo(default = False)
-    
-    config.plugins.Webinterface.interfacecount.value = i+1
-    
-    return i
-
-def getConfiguredIPs():    
-    choices = []
-    choices.append('0.0.0.0')
-    choices.append('127.0.0.1')
-    for adaptername in iNetwork.ifaces:
-        extip = iNetwork.ifaces[adaptername]['ip']
-        if iNetwork.ifaces[adaptername]['up'] is True:
-            extip = "%i.%i.%i.%i"%(extip[0],extip[1],extip[2],extip[3])
-            choices.append(extip)
-    return choices
+       choices = getConfiguredIPs()
+
+       if i is None and new is True:
+               i = config.plugins.Webinterface.interfacecount.value
+       elif i is None:
+               i = config.plugins.Webinterface.interfacecount.value - 1
+
+       print "[WebIfConfig.initInterfaceConfig] i is %s" %i
+       config.plugins.Webinterface.interfaces.append(ConfigSubsection())
+       config.plugins.Webinterface.interfaces[i].disabled = ConfigYesNo(default = False)
+       config.plugins.Webinterface.interfaces[i].address = ConfigSelection(choices, default=choices[0])
+       config.plugins.Webinterface.interfaces[i].port = ConfigInteger(80, (0, 65535))
+       config.plugins.Webinterface.interfaces[i].useauth = ConfigYesNo(default = False)
+       config.plugins.Webinterface.interfaces[i].usessl = ConfigYesNo(default = False)
+
+       config.plugins.Webinterface.interfacecount.value = i+1
+
+       return i
+
+def getConfiguredIPs():
+       choices = []
+       choices.append('0.0.0.0')
+       choices.append('127.0.0.1')
+       for adaptername in iNetwork.ifaces:
+               extip = iNetwork.ifaces[adaptername]['ip']
+               if iNetwork.ifaces[adaptername]['up'] is True:
+                       extip = "%i.%i.%i.%i"%(extip[0],extip[1],extip[2],extip[3])
+                       choices.append(extip)
+       return choices
 
 def initConfig():
-    if config.plugins.Webinterface.interfacecount.value == 0:
-        # setting default interface
-        # 0.0.0.0:80 auth=False
-        config.plugins.Webinterface.interfaces.append(ConfigSubsection())
-        config.plugins.Webinterface.interfaces[0].disabled = ConfigYesNo(default = False)
-        
-        #needs to be refreshed before each call, because ifaces can be changed since e2 boot 
-        config.plugins.Webinterface.interfaces[0].address = ConfigSelection(getConfiguredIPs(),default='0.0.0.0')
-        
-        config.plugins.Webinterface.interfaces[0].port = ConfigInteger(80, (0,65535))
-        config.plugins.Webinterface.interfaces[0].useauth = ConfigYesNo(default = False)
-        config.plugins.Webinterface.interfaces[0].usessl = ConfigYesNo(default = False)
-        config.plugins.Webinterface.interfaces[0].save()
-        
-        config.plugins.Webinterface.interfacecount.value = 1
-        config.plugins.Webinterface.interfacecount.save()        
-    else:           
-        for i in range(0, ( config.plugins.Webinterface.interfacecount.value ) ):
-            print "[WebIfConfig.initConfig] i is %s" %i
-            initInterfaceConfig(i)
+       if config.plugins.Webinterface.interfacecount.value == 0:
+               # setting default interface
+               # 0.0.0.0:80 auth=False
+               config.plugins.Webinterface.interfaces.append(ConfigSubsection())
+               config.plugins.Webinterface.interfaces[0].disabled = ConfigYesNo(default = False)
 
+               #needs to be refreshed before each call, because ifaces can be changed since e2 boot
+               config.plugins.Webinterface.interfaces[0].address = ConfigSelection(getConfiguredIPs(),default='0.0.0.0')
+
+               config.plugins.Webinterface.interfaces[0].port = ConfigInteger(80, (0,65535))
+               config.plugins.Webinterface.interfaces[0].useauth = ConfigYesNo(default = False)
+               config.plugins.Webinterface.interfaces[0].usessl = ConfigYesNo(default = False)
+               config.plugins.Webinterface.interfaces[0].save()
+
+               config.plugins.Webinterface.interfacecount.value = 1
+               config.plugins.Webinterface.interfacecount.save()
+       else:
+               for i in range(0, ( config.plugins.Webinterface.interfacecount.value ) ):
+                       print "[WebIfConfig.initConfig] i is %s" %i
+                       initInterfaceConfig(i)
 
 class WebIfConfigScreen(ConfigListScreen,Screen):
-    skin = """
-        <screen position="100,100" size="550,400" title="%s">
-            <widget name="config" position="5,5" size="540,360" scrollbarMode="showOnDemand" zPosition="1"/>
-            
-            <widget name="key_red" position="0,360" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/> 
-            <widget name="key_green" position="140,360" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/> 
-            <widget name="key_yellow" position="280,360" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
-            
-            <ePixmap name="red" pixmap="skin_default/buttons/red.png" position="0,360" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
-            <ePixmap name="green" pixmap="skin_default/buttons/green.png" position="140,360" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
-            <ePixmap name="yellow"  pixmap="skin_default/buttons/yellow.png" position="280,360" size="140,40" zPosition="4" transparent="1" alphatest="on"/> 
-        </screen>""" % _("Webinterface: Main Setup")
-    def __init__(self, session, args = 0):
-        self.session = session
-        Screen.__init__(self, session)
-        self.list = []
-        self.list.append(getConfigListEntry(_("Start Webinterface"), config.plugins.Webinterface.enable))
-        self.list.append(getConfigListEntry(_("Enable /media"), config.plugins.Webinterface.includemedia))
-        self.list.append(getConfigListEntry(_("Allow zapping via Webinterface"), config.plugins.Webinterface.allowzapping))
-        self.list.append(getConfigListEntry(_("Autowrite timer"), config.plugins.Webinterface.autowritetimer))
-        self.list.append(getConfigListEntry(_("Load movie-length"), config.plugins.Webinterface.loadmovielength))
-        
-        for i in range(0, config.plugins.Webinterface.interfacecount.value):
-            c = config.plugins.Webinterface.interfaces[i]
-            
-        ConfigListScreen.__init__(self, self.list)
-        self["key_red"] = Button(_("Cancel"))
-        self["key_green"] = Button(_("OK"))
-        self["key_yellow"] = Button(_("Interfaces"))
-        self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
-        {
-            "red": self.cancel,
-            "green": self.save,
-            "yellow": self.openIfacesConfig,
-            "save": self.save,
-            "cancel": self.cancel,
-            "ok": self.save,
-        }, -2)
-        
-    def openIfacesConfig(self):
-        print "yellow"
-        self.session.open(WebIfInterfaceListConfigScreen)
-        
-    def save(self):
-        print "saving"
-        for x in self["config"].list:
-            x[1].save()
-        self.close(True,self.session)
-
-    def cancel(self):
-        print "cancel"
-        for x in self["config"].list:
-            x[1].cancel()
-        self.close(False,self.session)
+       skin = """
+               <screen position="100,100" size="550,400" title="%s">
+                       <widget name="config" position="5,5" size="540,360" scrollbarMode="showOnDemand" zPosition="1"/>
+
+                       <widget name="key_red" position="0,360" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
+                       <widget name="key_green" position="140,360" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
+                       <widget name="key_yellow" position="280,360" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
+
+                       <ePixmap name="red" pixmap="skin_default/buttons/red.png" position="0,360" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
+                       <ePixmap name="green" pixmap="skin_default/buttons/green.png" position="140,360" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
+                       <ePixmap name="yellow" pixmap="skin_default/buttons/yellow.png" position="280,360" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
+               </screen>""" % _("Webinterface: Main Setup")
+
+       def __init__(self, session, args = 0):
+               self.session = session
+               Screen.__init__(self, session)
+               self.list = []
+               self.list.append(getConfigListEntry(_("Start Webinterface"), config.plugins.Webinterface.enable))
+               self.list.append(getConfigListEntry(_("Enable /media"), config.plugins.Webinterface.includemedia))
+               self.list.append(getConfigListEntry(_("Allow zapping via Webinterface"), config.plugins.Webinterface.allowzapping))
+               self.list.append(getConfigListEntry(_("Autowrite timer"), config.plugins.Webinterface.autowritetimer))
+               self.list.append(getConfigListEntry(_("Load movie-length"), config.plugins.Webinterface.loadmovielength))
+
+               for i in range(0, config.plugins.Webinterface.interfacecount.value):
+                       c = config.plugins.Webinterface.interfaces[i]
+
+               ConfigListScreen.__init__(self, self.list)
+               self["key_red"] = Button(_("Cancel"))
+               self["key_green"] = Button(_("OK"))
+               self["key_yellow"] = Button(_("Interfaces"))
+               self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
+               {
+                       "red": self.cancel,
+                       "green": self.save,
+                       "yellow": self.openIfacesConfig,
+                       "save": self.save,
+                       "cancel": self.cancel,
+                       "ok": self.save,
+               }, -2)
+
+       def openIfacesConfig(self):
+               print "yellow"
+               self.session.open(WebIfInterfaceListConfigScreen)
+
+       def save(self):
+               print "saving"
+               for x in self["config"].list:
+                       x[1].save()
+               self.close(True,self.session)
+
+       def cancel(self):
+               print "cancel"
+               for x in self["config"].list:
+                       x[1].cancel()
+               self.close(False,self.session)
 
 class WebIfInterfaceListConfigScreen(Screen):
-    skin = """
-        <screen position="100,100" size="550,400" title="%s" >
-            <widget name="address" position="5,0" size="150,50" font="Regular;20" halign="left"/>
-            <widget name="port" position="120,0" size="50,50" font="Regular;20" halign="left"/>
-            <widget name="ssl" position="170,0" size="50,50" font="Regular;20" halign="left"/>
-            <widget name="auth" position="230,0" size="170,50" font="Regular;20" halign="left"/>
-            <widget name="disabled" position="400,0" size="160,50" font="Regular;20" halign="left"/>
-            <widget name="ifacelist" position="0,50" size="550,300" scrollbarMode="showOnDemand"/>
-            
-            <widget name="key_red" position="0,350" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
-               <widget name="key_yellow" position="280,350" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="yellow" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />             
-            <ePixmap name="red" position="0,350" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
-           <ePixmap name="yellow" position="280,350" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />    
-        </screen>""" % _("Webinterface: List of configured Interfaces")
-        
-    def __init__(self, session):
-        Screen.__init__(self, session)
-        self["address"] = Button(_("Address"))
-        self["port"] = Button(_("Port"))
-        self["auth"] = Button(_("Authorization"))
-        self["ssl"] = Button(_("SSL"))
-        self["disabled"] = Button(_("Disabled"))
-        self["key_red"] = Button(_("Add"))
-        self["key_yellow"] = Button(_("Change"))
-        self["ifacelist"] = WebIfInterfaceList([])
-        self["actions"] = ActionMap(["WizardActions","MenuActions","ShortcutActions"],
-            {
-             "ok"      :       self.keyGreen,
-             "back"    :       self.close,
-             "red"     :       self.keyRed,
-             "green":  self.keyGreen,
-             "yellow": self.keyYellow,
-             "up"      :       self.up,
-             "down"    :       self.down,
-             "left"    :       self.left,
-             "right":  self.right,
-             }, -1)
-        self.updateList()
-        
-    def updateList(self):
-        ifaceguilist = []
-        for i in range(0, config.plugins.Webinterface.interfacecount.value):
-            c= config.plugins.Webinterface.interfaces[i]
-            res = [ i ] #550,400
-            res.append(MultiContentEntryText(pos=(5, 0), size=(150, 25), font=0, text=c.address.value))
-            res.append(MultiContentEntryText(pos=(120, 0),size=(50, 25), font=0,text=str(c.port.value)))
-            
-            if c.usessl.value:
-                res.append(MultiContentEntryText(pos=(170, 0),size=(200, 25), font=0,text=_("yes"),color=0x0000FF00))
-            else:
-                res.append(MultiContentEntryText(pos=(170, 0),size=(200, 25), font=0,text=_("no"),color=0x00FF0000))
-            
-            if c.useauth.value:
-                res.append(MultiContentEntryText(pos=(230, 0),size=(170, 25), font=0,text=_("yes"),color=0x0000FF00))
-            else:
-                res.append(MultiContentEntryText(pos=(230, 0),size=(170, 25), font=0,text=_("no"),color=0x00FF0000))
-                
-            if c.disabled.value:
-                res.append(MultiContentEntryText(pos=(400, 0),size=(160, 25), font=0,text=_("yes"),color=0x0000FF00))
-            else:
-                res.append(MultiContentEntryText(pos=(400, 0),size=(160, 25), font=0,text=_("no"),color=0x00FF0000))
-            ifaceguilist.append(res)
-        ifaceguilist.sort()
-        self["ifacelist"].l.setList(ifaceguilist)
-
-    
-    def keyRed(self):
-        print "KEYRED"
-        self.session.openWithCallback(self.updateList,WebIfInterfaceConfigScreen,None)
-        
-    def keyGreen(self):
-        print "KEYGREEN"
-        
-    def keyYellow(self):
-        x = self["ifacelist"].getCurrent()[0]
-        print "current list index",x
-        self.session.openWithCallback(self.updateList,WebIfInterfaceConfigScreen,int(x))
-
-    def up(self):
-        self["ifacelist"].up()
-
-    def down(self):
-        self["ifacelist"].down()
-
-    def left(self):
-        self["ifacelist"].pageUp()
-
-    def right(self):
-        self["ifacelist"].pageDown()
+       skin = """
+               <screen position="100,100" size="550,400" title="%s" >
+                       <widget name="address" position="5,0" size="150,50" font="Regular;20" halign="left"/>
+                       <widget name="port" position="120,0" size="50,50" font="Regular;20" halign="left"/>
+                       <widget name="ssl" position="170,0" size="50,50" font="Regular;20" halign="left"/>
+                       <widget name="auth" position="230,0" size="170,50" font="Regular;20" halign="left"/>
+                       <widget name="disabled" position="400,0" size="160,50" font="Regular;20" halign="left"/>
+                       <widget name="ifacelist" position="0,50" size="550,300" scrollbarMode="showOnDemand"/>
+
+                       <widget name="key_red" position="0,350" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+                       <widget name="key_yellow" position="280,350" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="yellow" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+                       <ePixmap name="red" position="0,350" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
+                       <ePixmap name="yellow" position="280,350" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
+               </screen>""" % _("Webinterface: List of configured Interfaces")
+
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               self["address"] = Button(_("Address"))
+               self["port"] = Button(_("Port"))
+               self["auth"] = Button(_("Authorization"))
+               self["ssl"] = Button(_("SSL"))
+               self["disabled"] = Button(_("Disabled"))
+               self["key_red"] = Button(_("Add"))
+               self["key_yellow"] = Button(_("Change"))
+               self["ifacelist"] = WebIfInterfaceList([])
+               self["actions"] = ActionMap(["WizardActions","MenuActions","ShortcutActions"],
+                       {
+                        "ok"   :       self.keyGreen,
+                        "back" :       self.close,
+                        "red"  :       self.keyRed,
+                        "green":       self.keyGreen,
+                        "yellow":      self.keyYellow,
+                        "up"   :       self.up,
+                        "down" :       self.down,
+                        "left" :       self.left,
+                        "right":       self.right,
+                        }, -1)
+               self.updateList()
+
+       def updateList(self):
+               ifaceguilist = []
+               for i in range(0, config.plugins.Webinterface.interfacecount.value):
+                       c= config.plugins.Webinterface.interfaces[i]
+                       res = [ i ] #550,400
+                       res.append(MultiContentEntryText(pos=(5, 0), size=(150, 25), font=0, text=c.address.value))
+                       res.append(MultiContentEntryText(pos=(120, 0),size=(50, 25), font=0,text=str(c.port.value)))
+
+                       if c.usessl.value:
+                               res.append(MultiContentEntryText(pos=(170, 0),size=(200, 25), font=0,text=_("yes"),color=0x0000FF00))
+                       else:
+                               res.append(MultiContentEntryText(pos=(170, 0),size=(200, 25), font=0,text=_("no"),color=0x00FF0000))
+
+                       if c.useauth.value:
+                               res.append(MultiContentEntryText(pos=(230, 0),size=(170, 25), font=0,text=_("yes"),color=0x0000FF00))
+                       else:
+                               res.append(MultiContentEntryText(pos=(230, 0),size=(170, 25), font=0,text=_("no"),color=0x00FF0000))
 
+                       if c.disabled.value:
+                               res.append(MultiContentEntryText(pos=(400, 0),size=(160, 25), font=0,text=_("yes"),color=0x0000FF00))
+                       else:
+                               res.append(MultiContentEntryText(pos=(400, 0),size=(160, 25), font=0,text=_("no"),color=0x00FF0000))
+                       ifaceguilist.append(res)
+               ifaceguilist.sort()
+               self["ifacelist"].l.setList(ifaceguilist)
+
+       def keyRed(self):
+               print "KEYRED"
+               self.session.openWithCallback(self.updateList,WebIfInterfaceConfigScreen,None)
+
+       def keyGreen(self):
+               print "KEYGREEN"
+
+       def keyYellow(self):
+               x = self["ifacelist"].getCurrent()[0]
+               print "current list index",x
+               self.session.openWithCallback(self.updateList,WebIfInterfaceConfigScreen,int(x))
+
+       def up(self):
+               self["ifacelist"].up()
+
+       def down(self):
+               self["ifacelist"].down()
+
+       def left(self):
+               self["ifacelist"].pageUp()
+
+       def right(self):
+               self["ifacelist"].pageDown()
 
 class WebIfInterfaceList(MenuList):
-    def __init__(self, list, enableWrapAround = False):
-        MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
-        self.l.setFont(0, gFont("Regular", 20))
-        #self.l.setFont(1, gFont("Regular", 25))
-
-    def postWidgetCreate(self, instance):
-        MenuList.postWidgetCreate(self, instance)
-        instance.setItemHeight(25)
-    
-        
+       def __init__(self, list, enableWrapAround = False):
+               MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
+               self.l.setFont(0, gFont("Regular", 20))
+               #self.l.setFont(1, gFont("Regular", 25))
+
+       def postWidgetCreate(self, instance):
+               MenuList.postWidgetCreate(self, instance)
+               instance.setItemHeight(25)
+
 class WebIfInterfaceConfigScreen(Screen, ConfigListScreen):
-    skin = """
-        <screen name="Interface Config" position="80,148" size="560,280" title="%s">
-            <widget name="config" position="10,10" size="520,210" scrollbarMode="showOnDemand" />
-            <ePixmap name="red"    position="0,240"   zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
-            <ePixmap name="green"  position="140,240" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />            
-            <ePixmap name="blue"   position="420,240" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
-            
-            <widget name="key_red" position="0,240" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
-            <widget name="key_green" position="140,240" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
-            <widget name="key_blue" position="420,240" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
-        </screen>""" % _("Webinterface: Edit Interface")
-    
-    def __init__(self, session, ifacenum):
-        Screen.__init__(self, session)
-        self["actions"] = ActionMap(["SetupActions", "ColorActions"],
-        {
-            "green": self.keySave,
-            "red": self.keyCancel,
-            "blue": self.keyDelete,
-            "cancel": self.keyCancel
-        }, -2)
-
-        self["key_red"] = Button(_("Cancel"))
-        self["key_green"] = Button(_("OK"))
-        #self["key_yellow"] = Button("")
-        self["key_blue"] = Button(_("Delete"))
-
-        if ifacenum is None:
-            i = initInterfaceConfig(None, True)
-        else:
-            i = ifacenum
-        cfglist = []
-        try:
-            current = config.plugins.Webinterface.interfaces[i]
-        except IndexError,e:
-            print "[WebIf] iface config %i not found, adding it and setting default values"%i
-            initInterfaceConfig()
-            current = config.plugins.Webinterface.interfaces[ifacenum]
-        
-        #reloading current network devices
-        current.address = ConfigSelection(getConfiguredIPs(), default=current.address.value)
-        
-        cfglist.append(getConfigListEntry(_("Disabled"), current.disabled))
-        cfglist.append(getConfigListEntry(_("Address"), current.address))
-        cfglist.append(getConfigListEntry(_("Port"), current.port))
-        cfglist.append(getConfigListEntry(_("Require Authorization"), current.useauth))
-        cfglist.append(getConfigListEntry(_("SSL Encryption"), current.usessl))
-        ConfigListScreen.__init__(self, cfglist, session)
-        self.ifacenum = i
-
-
-    def keySave(self):
-        config.plugins.Webinterface.interfacecount.save()
-        for x in self["config"].list:
-            if isinstance(x[1].value, str):
-                x[1].value = x[1].value.strip()
-            x[1].save()
-        config.plugins.Webinterface.save()
-        self.close()
-        
-
-    def cancelConfirm(self, result):
-        if result:
-            config.plugins.Webinterface.interfacecount.cancel()
-        self.callback = None
-        ConfigListScreen.cancelConfirm(self, result)
-
-    def keyDelete(self):
-        self.session.openWithCallback(self.deleteConfirm, MessageBox, _("Really delete this Interface?"))
-
-    def deleteConfirm(self, result):
-        if not result:
-            return
-        del(config.plugins.Webinterface.interfaces[self.ifacenum])
-        config.plugins.Webinterface.interfaces.save()
-        config.plugins.Webinterface.interfacecount.value = config.plugins.Webinterface.interfacecount.value - 1;
-        config.plugins.Webinterface.interfacecount.save()
-        config.plugins.Webinterface.save()
-        self.close()
\ No newline at end of file
+       skin = """
+               <screen name="Interface Config" position="80,148" size="560,280" title="%s">
+                       <widget name="config" position="10,10" size="520,210" scrollbarMode="showOnDemand" />
+                       <ePixmap name="red"     position="0,240" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
+                       <ePixmap name="green" position="140,240" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
+                       <ePixmap name="blue" position="420,240" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
+
+                       <widget name="key_red" position="0,240" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+                       <widget name="key_green" position="140,240" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+                       <widget name="key_blue" position="420,240" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+               </screen>""" % _("Webinterface: Edit Interface")
+
+       def __init__(self, session, ifacenum):
+               Screen.__init__(self, session)
+               self["actions"] = ActionMap(["SetupActions", "ColorActions"],
+               {
+                       "green": self.keySave,
+                       "red": self.keyCancel,
+                       "blue": self.keyDelete,
+                       "cancel": self.keyCancel
+               }, -2)
+
+               self["key_red"] = Button(_("Cancel"))
+               self["key_green"] = Button(_("OK"))
+               #self["key_yellow"] = Button("")
+               self["key_blue"] = Button(_("Delete"))
+
+               if ifacenum is None:
+                       i = initInterfaceConfig(None, True)
+               else:
+                       i = ifacenum
+               cfglist = []
+               try:
+                       current = config.plugins.Webinterface.interfaces[i]
+               except IndexError,e:
+                       print "[WebIf] iface config %i not found, adding it and setting default values"%i
+                       initInterfaceConfig()
+                       current = config.plugins.Webinterface.interfaces[ifacenum]
+
+               #reloading current network devices
+               current.address = ConfigSelection(getConfiguredIPs(), default=current.address.value)
+
+               cfglist.append(getConfigListEntry(_("Disabled"), current.disabled))
+               cfglist.append(getConfigListEntry(_("Address"), current.address))
+               cfglist.append(getConfigListEntry(_("Port"), current.port))
+               cfglist.append(getConfigListEntry(_("Require Authorization"), current.useauth))
+               cfglist.append(getConfigListEntry(_("SSL Encryption"), current.usessl))
+               ConfigListScreen.__init__(self, cfglist, session)
+               self.ifacenum = i
+
+       def keySave(self):
+               config.plugins.Webinterface.interfacecount.save()
+               for x in self["config"].list:
+                       if isinstance(x[1].value, str):
+                               x[1].value = x[1].value.strip()
+                       x[1].save()
+               config.plugins.Webinterface.save()
+               self.close()
+
+       def cancelConfirm(self, result):
+               if result:
+                       config.plugins.Webinterface.interfacecount.cancel()
+               self.callback = None
+               ConfigListScreen.cancelConfirm(self, result)
+
+       def keyDelete(self):
+               self.session.openWithCallback(self.deleteConfirm, MessageBox, _("Really delete this Interface?"))
+
+       def deleteConfirm(self, result):
+               if not result:
+                       return
+               del(config.plugins.Webinterface.interfaces[self.ifacenum])
+               config.plugins.Webinterface.interfaces.save()
+               config.plugins.Webinterface.interfacecount.value = config.plugins.Webinterface.interfacecount.value - 1;
+               config.plugins.Webinterface.interfacecount.save()
+               config.plugins.Webinterface.save()
+               self.close()
+
index 34bf3d1..138ecae 100644 (file)
@@ -18,17 +18,17 @@ PluginLanguageDomain = "WebInterface"
 PluginLanguagePath = "Extensions/WebInterface/locale"
 
 def localeInit():
-    lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
-    os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
-    print "[WebInterface] set language to ", lang
-    gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
+       lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
+       os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
+       print "[WebInterface] set language to ", lang
+       gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
 
 def _(txt):
-    t = gettext.dgettext(PluginLanguageDomain, txt)
-    if t == txt:
-        print "[WebInterface] fallback to default translation for", txt
-        t = gettext.gettext(txt)
-    return t
-    
+       t = gettext.dgettext(PluginLanguageDomain, txt)
+       if t == txt:
+               print "[WebInterface] fallback to default translation for", txt
+               t = gettext.gettext(txt)
+       return t
+
 localeInit()
-language.addCallback(localeInit)
\ No newline at end of file
+language.addCallback(localeInit)
index f3c85b1..4906064 100644 (file)
@@ -35,7 +35,6 @@ config.plugins.Webinterface.interfacecount = ConfigInteger(0)
 config.plugins.Webinterface.interfaces = ConfigSubList()
 config.plugins.Webinterface.warningsslsend = ConfigYesNo(default = False)
 
-
 global running_defered,waiting_shutdown
 running_defered = []
 waiting_shutdown = 0
@@ -46,7 +45,7 @@ class Closer:
        def __init__(self,session, callback = None):
                self.callback = callback
                self.session = session
-               
+
        def stop(self):
                global running_defered
                for d in running_defered:
@@ -61,14 +60,13 @@ class Closer:
                if self.counter <1:
                        if self.callback is not None:
                                self.callback(self.session)
-               
+
        def isDown(self,s):
                self.counter-=1
                if self.counter <1:
                        if self.callback is not None:
                                self.callback(self.session)
-                       
-               
+
 def restartWebserver(session):
        try:
                del session.mediaplayer
@@ -88,14 +86,14 @@ def startWebserver(session):
        global running_defered
        session.mediaplayer = None
        session.messageboxanswer = None
-       
+
        if config.plugins.Webinterface.enable.value is not True:
                print "not starting Werbinterface"
                return False
        if DEBUG_TO_FILE:
-               print "start twisted logfile, writing to %s" % DEBUGFILE 
+               print "start twisted logfile, writing to %s" % DEBUGFILE
                startLogging(open(DEBUGFILE,'w'))
-       
+
        for i in range(0, config.plugins.Webinterface.interfacecount.value):
                c = config.plugins.Webinterface.interfaces[i]
                if c.disabled.value is False:
@@ -103,7 +101,6 @@ def startWebserver(session):
                else:
                        print "[Webinterface] not starting disabled interface on %s:%i"%(c.address.value,c.port.value)
 
-
 def stopWebserver(session):
        try:
                del session.mediaplayer
@@ -116,7 +113,7 @@ def stopWebserver(session):
        global running_defered
        if len(running_defered) > 0:
                Closer(session).stop()
-                       
+
 def startServerInstance(session,ipaddress,port,useauth=False,usessl=False):
        try:
                toplevel = Toplevel(session)
@@ -124,11 +121,11 @@ def startServerInstance(session,ipaddress,port,useauth=False,usessl=False):
                        portal = Portal(HTTPAuthRealm())
                        portal.registerChecker(PasswordDatabase())
                        root = wrapper.HTTPAuthResource(toplevel,(basic.BasicCredentialFactory(socket_gethostname()),),portal, (IHTTPUser,))
-                       site = server.Site(root)        
+                       site = server.Site(root)
                else:
                        site = server.Site(toplevel)
                try:
-                       if usessl:                              
+                       if usessl:
                                ctx = ssl.DefaultOpenSSLContextFactory('/etc/enigma2/server.pem','/etc/enigma2/cacert.pem',sslmethod=SSL.SSLv23_METHOD)
                                d = reactor.listenSSL(port, channel.HTTPFactory(site),ctx,interface=ipaddress)
                        else:
@@ -140,28 +137,27 @@ def startServerInstance(session,ipaddress,port,useauth=False,usessl=False):
                        session.open(MessageBox,'Could not Listen on %s:%i!\n\n%s'%(ipaddress,port,str(e)), MessageBox.TYPE_ERROR)
        except Exception,e:
                print "[Webinterface] starting FAILED on %s:%i!"%(ipaddress,port),e
-               session.open(MessageBox,'starting FAILED on %s:%i!\n\n%s'%(ipaddress,port,str(e)), MessageBox.TYPE_ERROR)       
-       
-       
+               session.open(MessageBox,'starting FAILED on %s:%i!\n\n%s'%(ipaddress,port,str(e)), MessageBox.TYPE_ERROR)
+
 class PasswordDatabase:
-    """
-       this checks webiflogins agains /etc/passwd
-    """
-    passwordfile = "/etc/passwd"
-    implements(checkers.ICredentialsChecker)
-    credentialInterfaces = (credentials.IUsernamePassword,credentials.IUsernameHashedPassword)
-
-    def _cbPasswordMatch(self, matched, username):
-        if matched:
-            return username
-        else:
-            return failure.Failure(error.UnauthorizedLogin())
-
-    def requestAvatarId(self, credentials):    
-       if check_passwd(credentials.username,credentials.password,self.passwordfile) is True:
-               return defer.maybeDeferred(credentials.checkPassword,credentials.password).addCallback(self._cbPasswordMatch, str(credentials.username))
-       else:
-               return defer.fail(error.UnauthorizedLogin())
+       """
+               this checks webiflogins agains /etc/passwd
+       """
+       passwordfile = "/etc/passwd"
+       implements(checkers.ICredentialsChecker)
+       credentialInterfaces = (credentials.IUsernamePassword,credentials.IUsernameHashedPassword)
+
+       def _cbPasswordMatch(self, matched, username):
+               if matched:
+                       return username
+               else:
+                       return failure.Failure(error.UnauthorizedLogin())
+
+       def requestAvatarId(self, credentials):
+               if check_passwd(credentials.username,credentials.password,self.passwordfile) is True:
+                       return defer.maybeDeferred(credentials.checkPassword,credentials.password).addCallback(self._cbPasswordMatch, str(credentials.username))
+               else:
+                       return defer.fail(error.UnauthorizedLogin())
 
 class IHTTPUser(Interface):
        pass
@@ -182,194 +178,192 @@ class HTTPAuthRealm(object):
 from hashlib import md5 as md5_new
 from crypt import crypt
 
-DES_SALT = list('./0123456789' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz') 
+DES_SALT = list('./0123456789' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz')
 def getpwnam(name, pwfile=None):
-    """Return pasword database entry for the given user name.
-    
-    Example from the Python Library Reference.
-    """
-    
-    if not pwfile:
-        pwfile = '/etc/passwd'
-
-    f = open(pwfile)
-    while 1:
-        line = f.readline()
-        if not line:
-            f.close()
-            raise KeyError, name
-        entry = tuple(line.strip().split(':', 6))
-        if entry[0] == name:
-            f.close()
-            return entry
+       """Return pasword database entry for the given user name.
+
+       Example from the Python Library Reference.
+       """
+
+       if not pwfile:
+               pwfile = '/etc/passwd'
+
+       f = open(pwfile)
+       while 1:
+               line = f.readline()
+               if not line:
+                       f.close()
+                       raise KeyError, name
+               entry = tuple(line.strip().split(':', 6))
+               if entry[0] == name:
+                       f.close()
+                       return entry
 
 def passcrypt(passwd, salt=None, method='des', magic='$1$'):
-    """Encrypt a string according to rules in crypt(3)."""
-    if method.lower() == 'des':
-           return crypt(passwd, salt)
-    elif method.lower() == 'md5':
-       return passcrypt_md5(passwd, salt, magic)
-    elif method.lower() == 'clear':
-        return passwd
+       """Encrypt a string according to rules in crypt(3)."""
+       if method.lower() == 'des':
+               return crypt(passwd, salt)
+       elif method.lower() == 'md5':
+               return passcrypt_md5(passwd, salt, magic)
+       elif method.lower() == 'clear':
+               return passwd
 
 def check_passwd(name, passwd, pwfile=None):
-    """Validate given user, passwd pair against password database."""
-    
-    if not pwfile or type(pwfile) == type(''):
-        getuser = lambda x,pwfile=pwfile: getpwnam(x,pwfile)[1]
-    else:
-        getuser = pwfile.get_passwd
-
-    try:
-        enc_passwd = getuser(name)
-    except (KeyError, IOError):
-        return 0
-    if not enc_passwd:
-        return 0
-    elif len(enc_passwd) >= 3 and enc_passwd[:3] == '$1$':
-        salt = enc_passwd[3:enc_passwd.find('$', 3)]
-        return enc_passwd == passcrypt(passwd, salt, 'md5')
-       
-    else:
-        return enc_passwd == passcrypt(passwd, enc_passwd[:2])
+       """Validate given user, passwd pair against password database."""
+
+       if not pwfile or type(pwfile) == type(''):
+               getuser = lambda x,pwfile=pwfile: getpwnam(x,pwfile)[1]
+       else:
+               getuser = pwfile.get_passwd
+
+       try:
+               enc_passwd = getuser(name)
+       except (KeyError, IOError):
+               return 0
+       if not enc_passwd:
+               return 0
+       elif len(enc_passwd) >= 3 and enc_passwd[:3] == '$1$':
+               salt = enc_passwd[3:enc_passwd.find('$', 3)]
+               return enc_passwd == passcrypt(passwd, salt, 'md5')
+       else:
+               return enc_passwd == passcrypt(passwd, enc_passwd[:2])
 
 def _to64(v, n):
-    r = ''
-    while (n-1 >= 0):
+       r = ''
+       while (n-1 >= 0):
        r = r + DES_SALT[v & 0x3F]
        v = v >> 6
        n = n - 1
-    return r
-                       
+       return r
+
 def passcrypt_md5(passwd, salt=None, magic='$1$'):
-    """Encrypt passwd with MD5 algorithm."""
-    
-    if not salt:
-       pass
-    elif salt[:len(magic)] == magic:
-        # remove magic from salt if present
-        salt = salt[len(magic):]
-
-    # salt only goes up to first '$'
-    salt = salt.split('$')[0]
-    # limit length of salt to 8
-    salt = salt[:8]
-
-    ctx = md5_new(passwd)
-    ctx.update(magic)
-    ctx.update(salt)
-    
-    ctx1 = md5_new(passwd)
-    ctx1.update(salt)
-    ctx1.update(passwd)
-    
-    final = ctx1.digest()
-    
-    for i in range(len(passwd), 0 , -16):
+       """Encrypt passwd with MD5 algorithm."""
+
+       if not salt:
+               pass
+       elif salt[:len(magic)] == magic:
+               # remove magic from salt if present
+               salt = salt[len(magic):]
+
+       # salt only goes up to first '$'
+       salt = salt.split('$')[0]
+       # limit length of salt to 8
+       salt = salt[:8]
+
+       ctx = md5_new(passwd)
+       ctx.update(magic)
+       ctx.update(salt)
+
+       ctx1 = md5_new(passwd)
+       ctx1.update(salt)
+       ctx1.update(passwd)
+
+       final = ctx1.digest()
+
+       for i in range(len(passwd), 0 , -16):
        if i > 16:
-           ctx.update(final)
+               ctx.update(final)
        else:
-           ctx.update(final[:i])
-    
-    i = len(passwd)
-    while i:
+               ctx.update(final[:i])
+
+       i = len(passwd)
+       while i:
        if i & 1:
-           ctx.update('\0')
+               ctx.update('\0')
        else:
-           ctx.update(passwd[:1])
+               ctx.update(passwd[:1])
        i = i >> 1
-    final = ctx.digest()
-    
-    for i in range(1000):
+       final = ctx.digest()
+
+       for i in range(1000):
        ctx1 = md5_new()
        if i & 1:
-           ctx1.update(passwd)
+               ctx1.update(passwd)
        else:
-           ctx1.update(final)
+               ctx1.update(final)
        if i % 3: ctx1.update(salt)
        if i % 7: ctx1.update(passwd)
        if i & 1:
-           ctx1.update(final)
+               ctx1.update(final)
        else:
-           ctx1.update(passwd)
-        final = ctx1.digest()
-    
-    rv = magic + salt + '$'
-    final = map(ord, final)
-    l = (final[0] << 16) + (final[6] << 8) + final[12]
-    rv = rv + _to64(l, 4)
-    l = (final[1] << 16) + (final[7] << 8) + final[13]
-    rv = rv + _to64(l, 4)
-    l = (final[2] << 16) + (final[8] << 8) + final[14]
-    rv = rv + _to64(l, 4)
-    l = (final[3] << 16) + (final[9] << 8) + final[15]
-    rv = rv + _to64(l, 4)
-    l = (final[4] << 16) + (final[10] << 8) + final[5]
-    rv = rv + _to64(l, 4)
-    l = final[11]
-    rv = rv + _to64(l, 2)
-    
-    return rv
+               ctx1.update(passwd)
+               final = ctx1.digest()
+
+       rv = magic + salt + '$'
+       final = map(ord, final)
+       l = (final[0] << 16) + (final[6] << 8) + final[12]
+       rv = rv + _to64(l, 4)
+       l = (final[1] << 16) + (final[7] << 8) + final[13]
+       rv = rv + _to64(l, 4)
+       l = (final[2] << 16) + (final[8] << 8) + final[14]
+       rv = rv + _to64(l, 4)
+       l = (final[3] << 16) + (final[9] << 8) + final[15]
+       rv = rv + _to64(l, 4)
+       l = (final[4] << 16) + (final[10] << 8) + final[5]
+       rv = rv + _to64(l, 4)
+       l = final[11]
+       rv = rv + _to64(l, 2)
+
+       return rv
 
 #### stuff for SSL Support
 def makeSSLContext(myKey,trustedCA):
-     '''Returns an ssl Context Object
-    @param myKey a pem formated key and certifcate with for my current host
-           the other end of this connection must have the cert from the CA
-           that signed this key
-    @param trustedCA a pem formated certificat from a CA you trust
-           you will only allow connections from clients signed by this CA
-           and you will only allow connections to a server signed by this CA
-     '''
-
-     # our goal in here is to make a SSLContext object to pass to connectSSL
-     # or listenSSL
-
-     # Why these functioins... Not sure...
-     fd = open(myKey,'r')
-     ss = fd.read()
-     theCert = ssl.PrivateCertificate.loadPEM(ss)
-     fd.close()
-     fd = open(trustedCA,'r')
-     theCA = ssl.Certificate.loadPEM(fd.read())
-     fd.close()
-     #ctx = theCert.options(theCA)
-     ctx = theCert.options()
-
-     # Now the options you can set look like Standard OpenSSL Library options
-
-     # The SSL protocol to use, one of SSLv23_METHOD, SSLv2_METHOD,
-     # SSLv3_METHOD, TLSv1_METHOD. Defaults to TLSv1_METHOD.
-     ctx.method = ssl.SSL.TLSv1_METHOD
-
-     # If True, verify certificates received from the peer and fail
-     # the handshake if verification fails. Otherwise, allow anonymous
-     # sessions and sessions with certificates which fail validation.
-     ctx.verify = True
-
-     # Depth in certificate chain down to which to verify.
-     ctx.verifyDepth = 1
-
-     # If True, do not allow anonymous sessions.
-     ctx.requireCertification = True
-
-     # If True, do not re-verify the certificate on session resumption.
-     ctx.verifyOnce = True
-
-     # If True, generate a new key whenever ephemeral DH parameters are used
-     # to prevent small subgroup attacks.
-     ctx.enableSingleUseKeys = True
-
-     # If True, set a session ID on each context. This allows a shortened
-     # handshake to be used when a known client reconnects.
-     ctx.enableSessions = True
-
-     # If True, enable various non-spec protocol fixes for broken
-     # SSL implementations.
-     ctx.fixBrokenPeers = False
-
-     return ctx
-
+        '''Returns an ssl Context Object
+       @param myKey a pem formated key and certifcate with for my current host
+                       the other end of this connection must have the cert from the CA
+                       that signed this key
+       @param trustedCA a pem formated certificat from a CA you trust
+                       you will only allow connections from clients signed by this CA
+                       and you will only allow connections to a server signed by this CA
+        '''
+
+        # our goal in here is to make a SSLContext object to pass to connectSSL
+        # or listenSSL
+
+        # Why these functioins... Not sure...
+        fd = open(myKey,'r')
+        ss = fd.read()
+        theCert = ssl.PrivateCertificate.loadPEM(ss)
+        fd.close()
+        fd = open(trustedCA,'r')
+        theCA = ssl.Certificate.loadPEM(fd.read())
+        fd.close()
+        #ctx = theCert.options(theCA)
+        ctx = theCert.options()
+
+        # Now the options you can set look like Standard OpenSSL Library options
+
+        # The SSL protocol to use, one of SSLv23_METHOD, SSLv2_METHOD,
+        # SSLv3_METHOD, TLSv1_METHOD. Defaults to TLSv1_METHOD.
+        ctx.method = ssl.SSL.TLSv1_METHOD
+
+        # If True, verify certificates received from the peer and fail
+        # the handshake if verification fails. Otherwise, allow anonymous
+        # sessions and sessions with certificates which fail validation.
+        ctx.verify = True
+
+        # Depth in certificate chain down to which to verify.
+        ctx.verifyDepth = 1
+
+        # If True, do not allow anonymous sessions.
+        ctx.requireCertification = True
+
+        # If True, do not re-verify the certificate on session resumption.
+        ctx.verifyOnce = True
+
+        # If True, generate a new key whenever ephemeral DH parameters are used
+        # to prevent small subgroup attacks.
+        ctx.enableSingleUseKeys = True
+
+        # If True, set a session ID on each context. This allows a shortened
+        # handshake to be used when a known client reconnects.
+        ctx.enableSessions = True
+
+        # If True, enable various non-spec protocol fixes for broken
+        # SSL implementations.
+        ctx.fixBrokenPeers = False
+
+        return ctx
 
 global_session = None
 
@@ -386,9 +380,7 @@ def autostart(reason, **kwargs):
                        print "[Webinterface] twisted not available, not starting web services", e
        elif reason is False:
                stopWebserver(global_session)
-               
-               
-                       
+
 def openconfig(session, **kwargs):
        session.openWithCallback(configCB, WebIfConfigScreen)
 
@@ -398,10 +390,9 @@ def configCB(result, session):
                restartWebserver(session)
        else:
                print "[WebIf] config not changed"
-               
 
 def Plugins(**kwargs):
        return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], fnc = sessionstart),
-                   PluginDescriptor(where = [PluginDescriptor.WHERE_NETWORKCONFIG_READ], fnc = autostart),
-                   PluginDescriptor(name=_("Webinterface"), description=_("Configuration for the Webinterface"),
-                                                        where = [PluginDescriptor.WHERE_PLUGINMENU], icon="plugin.png",fnc = openconfig)]
+                       PluginDescriptor(where = [PluginDescriptor.WHERE_NETWORKCONFIG_READ], fnc = autostart),
+                       PluginDescriptor(name=_("Webinterface"), description=_("Configuration for the Webinterface"),
+                                                       where = [PluginDescriptor.WHERE_PLUGINMENU], icon="plugin.png",fnc = openconfig)]
index 3d4b06b..cc2df33 100644 (file)
@@ -3,12 +3,12 @@ Version = '$Header$';
 
 # OK, this is more than a proof of concept
 # things to improve:
-#  - nicer code
-#  - screens need to be defined somehow else.
+#      - nicer code
+#      - screens need to be defined somehow else.
 #      I don't know how, yet. Probably each in an own file.
-#  - more components, like the channellist
-#  - better error handling
-#  - use namespace parser
+#      - more components, like the channellist
+#      - better error handling
+#      - use namespace parser
 from enigma import eServiceReference
 
 from Screens.Screen import Screen
@@ -146,7 +146,7 @@ class LocationsAndTagsWebScreen(WebScreen):
 class EPGWebScreen(WebScreen):
        def __init__(self, session, request):
                WebScreen.__init__(self, session, request)
-               
+
                self["EPGTITLE"] = EPG(session,func=EPG.TITLE)
                self["EPGSERVICE"] = EPG(session,func=EPG.SERVICE)
                self["EPGBOUQUETNOW"] = EPG(session,func=EPG.BOUQUETNOW)
@@ -154,7 +154,7 @@ class EPGWebScreen(WebScreen):
                self["EPGSERVICENOW"] = EPG(session,func=EPG.SERVICENOW)
                self["EPGSERVICENEXT"] = EPG(session,func=EPG.SERVICENEXT)
                self["EPGBOUQUET"] = EPG(session,func=EPG.BOUQUET)
-               
+
        def getServiceList(self, sRef):
                self["ServiceList"].root = sRef
 
@@ -271,7 +271,7 @@ class RestartWebScreen(WebScreen):
                plugin.restartWebserver(session)
 
 class GetPid(WebScreen):
-         def __init__(self, session, request):
+       def __init__(self, session, request):
                 WebScreen.__init__(self, session, request)
                 from Components.Sources.StaticText import StaticText
                 from enigma import iServiceInformation
@@ -524,7 +524,7 @@ class webifHandler(ContentHandler):
        def start_convert(self, attrs):
                ctype = attrs["type"]
 
-                       # TODO: we need something better here
+               # TODO: we need something better here
                if ctype[:4] == "web:": # for now
                        self.converter = eval(ctype[4:])
                else:
@@ -623,7 +623,6 @@ class webifHandler(ContentHandler):
                self.screens = [ ]
 
 def renderPage(stream, path, req, session):
-
        # read in the template, create required screens
        # we don't have persistense yet.
        # if we had, this first part would only be done once.