|
@@ -6,6 +6,7 @@ |
|
|
# (c) 2005, Tim Potter <tpot@samba.org> |
|
|
# (c) 2005, Tim Potter <tpot@samba.org> |
|
|
|
|
|
|
|
|
import random |
|
|
import random |
|
|
|
|
|
import socket |
|
|
import string |
|
|
import string |
|
|
import sys |
|
|
import sys |
|
|
from twisted.python import log |
|
|
from twisted.python import log |
|
@@ -37,6 +38,7 @@ port.joinGroup(SSDP_ADDR) |
|
|
port.setLoopbackMode(0) # don't get our own sends |
|
|
port.setLoopbackMode(0) # don't get our own sends |
|
|
|
|
|
|
|
|
uuid = 'uuid:' + generateuuid() |
|
|
uuid = 'uuid:' + generateuuid() |
|
|
|
|
|
urlbase = 'http://%s:%d/' % (listenAddr, listenPort) |
|
|
|
|
|
|
|
|
# Create SOAP server |
|
|
# Create SOAP server |
|
|
|
|
|
|
|
@@ -48,9 +50,15 @@ class WebServer(resource.Resource): |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
|
resource.Resource.__init__(self) |
|
|
resource.Resource.__init__(self) |
|
|
|
|
|
|
|
|
class RootDevice(static.File): |
|
|
|
|
|
|
|
|
class RootDevice(static.Data): |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
|
static.File.__init__(self, 'root-device.xml', defaultType = 'text/xml') |
|
|
|
|
|
|
|
|
r = { |
|
|
|
|
|
'hostname': socket.gethostname(), |
|
|
|
|
|
'uuid': uuid, |
|
|
|
|
|
'urlbase': urlbase, |
|
|
|
|
|
} |
|
|
|
|
|
d = file('root-device.xml').read() % r |
|
|
|
|
|
static.Data.__init__(self, d, 'text/xml') |
|
|
|
|
|
|
|
|
root = WebServer() |
|
|
root = WebServer() |
|
|
root.putChild('ContentDirectory', ContentDirectoryServer()) |
|
|
root.putChild('ContentDirectory', ContentDirectoryServer()) |
|
@@ -69,23 +77,23 @@ reactor.listenTCP(listenPort, site) |
|
|
# we need to do this after the children are there, since we send notifies |
|
|
# we need to do this after the children are there, since we send notifies |
|
|
s.register('%s::upnp:rootdevice' % uuid, |
|
|
s.register('%s::upnp:rootdevice' % uuid, |
|
|
'upnp:rootdevice', |
|
|
'upnp:rootdevice', |
|
|
'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) |
|
|
|
|
|
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
|
s.register(uuid, |
|
|
s.register(uuid, |
|
|
uuid, |
|
|
uuid, |
|
|
'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) |
|
|
|
|
|
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
|
s.register('%s::urn:schemas-upnp-org:device:MediaServer:1' % uuid, |
|
|
s.register('%s::urn:schemas-upnp-org:device:MediaServer:1' % uuid, |
|
|
'urn:schemas-upnp-org:device:MediaServer:1', |
|
|
'urn:schemas-upnp-org:device:MediaServer:1', |
|
|
'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) |
|
|
|
|
|
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
|
s.register('%s::urn:schemas-upnp-org:service:ConnectionManager:1' % uuid, |
|
|
s.register('%s::urn:schemas-upnp-org:service:ConnectionManager:1' % uuid, |
|
|
'urn:schemas-upnp-org:device:ConnectionManager:1', |
|
|
'urn:schemas-upnp-org:device:ConnectionManager:1', |
|
|
'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) |
|
|
|
|
|
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
|
s.register('%s::urn:schemas-upnp-org:service:ContentDirectory:1' % uuid, |
|
|
s.register('%s::urn:schemas-upnp-org:service:ContentDirectory:1' % uuid, |
|
|
'urn:schemas-upnp-org:device:ContentDirectory:1', |
|
|
'urn:schemas-upnp-org:device:ContentDirectory:1', |
|
|
'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) |
|
|
|
|
|
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
|
# Main loop |
|
|
# Main loop |
|
|
|
|
|
|
|
|