resize screen to 90% of Desktopsize and center it on tv screen
[enigma2-plugins.git] / webinterface / src / WebChilds / Toplevel.py
1 from twisted.web2 import resource, static, responsecode, http, http_headers
2 from twisted.python import util
3
4 from Components.config import config
5
6 from Plugins.Extensions import WebInterface
7 from Screenpage import ScreenPage
8 from FileStreamer import FileStreamer
9 from Screengrab import GrabResource
10 from IPKG import IPKGResource
11 from PlayService import ServiceplayerResource
12 from Uploader import UploadResource
13 from Notepad import NotepadResource
14 from ServiceListSave import ServiceList
15
16 class Toplevel(resource.Resource):
17     addSlash = True
18     def __init__(self,session):
19         self.session = session
20         resource.Resource.__init__(self)
21         
22         self.putChild("web",ScreenPage(self.session,util.sibpath(WebInterface.__file__, "web"))) # "/web/*"
23         self.putChild("webdata",static.File(util.sibpath(WebInterface.__file__, "web-data"))) # FIXME: web-data appears as webdata
24         self.putChild("file",FileStreamer())
25         self.putChild("grab",GrabResource())
26         self.putChild("ipkg",IPKGResource())
27         self.putChild("play",ServiceplayerResource(self.session))
28         self.putChild("wap",RedirectorResource("/web/wap/"))# shorten and simplify url to wap-pages
29         self.putChild("upload",UploadResource())
30         self.putChild("notes",NotepadResource())
31         self.putChild("servicelist",ServiceList(self.session))
32
33         if config.plugins.Webinterface.includehdd.value is True:
34             self.putChild("hdd",static.File("/hdd"))
35         
36     def render(self, req):
37         fp = open(util.sibpath(WebInterface.__file__, "web-data")+"/index.html")
38         s = fp.read()
39         fp.close()
40         return http.Response(responsecode.OK, {'Content-type': http_headers.MimeType('text', 'html')},stream=s)
41
42     def locateChild(self, request, segments):
43         print "[WebIf]",request.remoteAddr.host,request.method,request.path,request.args
44         return resource.Resource.locateChild(self, request, segments)
45
46 class RedirectorResource(resource.Resource):
47     """ 
48         this class can be used to redirect a request to a specified uri
49     """
50     def __init__(self,uri):
51         self.uri = uri
52         resource.Resource.__init__(self)
53     def render(self, req):
54         return http.RedirectResponse(self.uri)
55
56