Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

# Licensed under the MIT license 

# http://opensource.org/licenses/mit-license.php 

 

# Copyright 2006, Frank Scholz <coherence@beebits.net> 

 

# Content Directory service 

 

from twisted.web import resource 

 

from coherence.upnp.core import service 

from coherence.upnp.core.soap_service import UPnPPublisher 

 

 

class FakeMediaReceiverRegistrarBackend: 

 

    def upnp_IsAuthorized(self, *args, **kwargs): 

        r = {'Result': 1} 

        return r 

 

    def upnp_IsValidated(self, *args, **kwargs): 

        r = {'Result': 1} 

        return r 

 

    def upnp_RegisterDevice(self, *args, **kwargs): 

        """ in parameter RegistrationReqMsg """ 

        RegistrationReqMsg = kwargs['RegistrationReqMsg'] 

        """ FIXME: check with WMC and WMP """ 

        r = {'RegistrationRespMsg': 'WTF should be in here?'} 

        return r 

 

 

class MediaReceiverRegistrarControl(service.ServiceControl, UPnPPublisher): 

 

    def __init__(self, server): 

        service.ServiceControl.__init__(self) 

        UPnPPublisher.__init__(self) 

        self.service = server 

        self.variables = server.get_variables() 

        self.actions = server.get_actions() 

 

 

class MediaReceiverRegistrarServer(service.ServiceServer, resource.Resource): 

    implementation = 'optional' 

 

    def __init__(self, device, backend=None): 

        self.device = device 

        if backend is None: 

            backend = self.device.backend 

        resource.Resource.__init__(self) 

        self.version = 1 

        self.namespace = 'microsoft.com' 

        self.id_namespace = 'microsoft.com' 

        service.ServiceServer.__init__(self, 'X_MS_MediaReceiverRegistrar', 

                                       self.version, backend) 

        self.device_description_tmpl = 'xbox-description-1.xml' 

 

        self.control = MediaReceiverRegistrarControl(self) 

        self.putChild(b'scpd.xml', service.scpdXML(self, self.control)) 

        self.putChild(b'control', self.control) 

 

    def listchilds(self, uri): 

        if isinstance(uri, bytes): 

            uri = uri.decode('utf-8') 

        cl = '' 

        for c in self.children: 

            cl += '<li><a href=%s/%s>%s</a></li>' % (uri, c, c) 

        return cl 

 

    def render(self, request): 

        return \ 

            '<html><p>root of the MediaReceiverRegistrar</p>' \ 

            '<p><ul>%s</ul></p></html>' % self.listchilds( 

                request.uri.decode('utf-8'))