Пример #1
0
class DreamboxUpnpDevice(log.Loggable, BasicDeviceMixin):
    logCategory = 'dreambox'
    device_type = ManagedControlPoint.DEVICE_TYPE_DREAMBOX
    presentationURL = None

    def __init__(self, coherence, backend=None, **kwargs):
        BasicDeviceMixin.__init__(self,
                                  coherence,
                                  backend,
                                  uuid=getUUID(
                                      config.plugins.upnp.dreambox_web_uuid),
                                  **kwargs)
        self.model_name = HardwareInfo().get_device_name()
        self.device_name = "%s WebInterface" % (self.model_name, )
        self.version = 1
        self._services = []

    def fire(self, backend, **kwargs):
        pass

    def init_complete(self, backend):
        self.web_resource = DeviceHttpRoot(self)
        self.coherence.add_web_resource(str(self.uuid)[5:], self.web_resource)

        transport = "http" if config.plugins.Webinterface.http.enabled.value else "https"
        port = config.plugins.Webinterface.http.port.value
        if not config.plugins.Webinterface.http.enabled.value:
            port = config.plugins.Webinterface.https.port.value
        presentation_url = "%s://%s" % (transport, self.coherence.hostname)
        if (transport == "http" and port != 80) or (transport == "https"
                                                    and port != 443):
            presentation_url = "%s:%s" % (presentation_url, port)

        self.web_resource.putChild(
            'description-%d.xml' % self.version,
            RootDeviceXML(
                self.coherence.hostname,
                str(self.uuid),
                self.coherence.urlbase,
                device_type=self.device_type,
                device_uri_base=ManagedControlPoint.URI_BASE_DREAMBOX,
                version=self.version,
                friendly_name=self.device_name,
                services=[],
                devices=[],
                icons=self.icons,
                manufacturer='dreambox',
                manufacturer_url='http://www.dreambox.de',
                model_description=self.model_name,
                model_name=self.model_name,
                model_number=self.device_name,
                model_url='http://www.dreambox.de',
                presentation_url=presentation_url))

        self.register()
        self.warning("%s %s (%s) activated with id %s" %
                     (self.device_type, self.model_name, self.backend,
                      str(self.uuid)[5:]))
Пример #2
0
    def __init__(self, coherence, tube_device,external_address):
        log.Loggable.__init__(self)
        self.device = tube_device
        self.coherence = coherence
        self.external_address = external_address
        self.uuid = self.device.get_id().split('-')
        self.uuid[1] = 'tube'
        self.uuid = '-'.join(self.uuid)
        self.friendly_name = self.device.get_friendly_name()
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())

        self._services = []
        self._devices = []
        self.icons = []

        self.info("uuid: %s, name: %r, device type: %r, version: %r",
                  self.uuid, self.friendly_name, self.device_type, self.version)

        """ create the http entrypoint """

        self.web_resource = DeviceHttpRoot(self)
        self.coherence.add_web_resource( str(self.uuid)[5:], self.web_resource)


        """ create the Service proxy(s) """

        for service in self.device.services:
            self.debug("Proxying service %r", service)
            new_service = TubeServiceProxy(service, self)
            self._services.append(new_service)

        """ create a device description xml file(s) """

        version = self.version
        while version > 0:
            self.web_resource.putChild( 'description-%d.xml' % version,
                                    RootDeviceXML( self.coherence.hostname,
                                    str(self.uuid),
                                    self.coherence.urlbase,
                                    device_type=self.device_type, version=version,
                                    friendly_name=self.friendly_name,
                                    model_description='Coherence UPnP %s' % self.device_type,
                                    model_name='Coherence UPnP %s' % self.device_type,
                                    services=self._services,
                                    devices=self._devices,
                                    icons=self.icons))
            version -= 1


        """ and register with SSDP server """
        self.register()
Пример #3
0
    def __init__(self, coherence, tube_device, external_address):
        log.LogAble.__init__(self)
        self.device = tube_device
        self.coherence = coherence
        self.external_address = external_address
        self.uuid = self.device.get_id().split('-')
        self.uuid[1] = 'tube'
        self.uuid = '-'.join(self.uuid)
        self.friendly_name = self.device.get_friendly_name()
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())

        self._services = []
        self._devices = []
        self.icons = []

        self.info(f'uuid: {self.uuid}, name: {self.friendly_name}, ' +
                  f'device type: {self.device_type}, version: {self.version}')
        ''' create the http entrypoint '''

        self.web_resource = DeviceHttpRoot(self)
        self.coherence.add_web_resource(str(self.uuid)[5:], self.web_resource)
        ''' create the Service proxy(s) '''

        for device_service in self.device.services:
            self.debug(f'Proxying service {device_service}')
            new_service = TubeServiceProxy(device_service, self)
            self._services.append(new_service)
        ''' create a device description xml file(s) '''

        version = self.version
        while version > 0:
            self.web_resource.putChild(
                f'description-{version:d}.xml',
                RootDeviceXML(
                    self.coherence.hostname,
                    str(self.uuid),
                    self.coherence.urlbase,
                    device_type=self.device_type,
                    version=version,
                    friendly_name=self.friendly_name,
                    # model_description=f'Coherence UPnP {self.device_type}',
                    # model_name=f'Coherence UPnP {self.device_type}',
                    services=self._services,
                    devices=self._devices,
                    icons=self.icons,
                ),
            )
            version -= 1
        ''' and register with SSDP server '''
        self.register()
Пример #4
0
    def __init__(self, coherence, tube_device,external_address):
        log.Loggable.__init__(self)
        self.device = tube_device
        self.coherence = coherence
        self.external_address = external_address
        self.uuid = self.device.get_id().split('-')
        self.uuid[1] = 'tube'
        self.uuid = '-'.join(self.uuid)
        self.friendly_name = self.device.get_friendly_name()
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())

        self._services = []
        self._devices = []
        self.icons = []

        self.info("uuid: %s, name: %r, device type: %r, version: %r",
                  self.uuid, self.friendly_name, self.device_type, self.version)

        """ create the http entrypoint """

        self.web_resource = DeviceHttpRoot(self)
        self.coherence.add_web_resource( str(self.uuid)[5:], self.web_resource)


        """ create the Service proxy(s) """

        for service in self.device.services:
            self.debug("Proxying service %r", service)
            new_service = TubeServiceProxy(service, self)
            self._services.append(new_service)

        """ create a device description xml file(s) """

        version = self.version
        while version > 0:
            self.web_resource.putChild( 'description-%d.xml' % version,
                                    RootDeviceXML( self.coherence.hostname,
                                    str(self.uuid),
                                    self.coherence.urlbase,
                                    device_type=self.device_type, version=version,
                                    friendly_name=self.friendly_name,
                                    model_description='Coherence UPnP %s' % self.device_type,
                                    model_name='Coherence UPnP %s' % self.device_type,
                                    services=self._services,
                                    devices=self._devices,
                                    icons=self.icons))
            version -= 1


        """ and register with SSDP server """
        self.register()
Пример #5
0
    def init_complete(self, backend):
        self.web_resource = DeviceHttpRoot(self)
        self.coherence.add_web_resource(str(self.uuid)[5:], self.web_resource)

        transport = "http" if config.plugins.Webinterface.http.enabled.value else "https"
        port = config.plugins.Webinterface.http.port.value
        if not config.plugins.Webinterface.http.enabled.value:
            port = config.plugins.Webinterface.https.port.value
        presentation_url = "%s://%s" % (transport, self.coherence.hostname)
        if (transport == "http" and port != 80) or (transport == "https"
                                                    and port != 443):
            presentation_url = "%s:%s" % (presentation_url, port)

        self.web_resource.putChild(
            'description-%d.xml' % self.version,
            RootDeviceXML(
                self.coherence.hostname,
                str(self.uuid),
                self.coherence.urlbase,
                device_type=self.device_type,
                device_uri_base=ManagedControlPoint.URI_BASE_DREAMBOX,
                version=self.version,
                friendly_name=self.device_name,
                services=[],
                devices=[],
                icons=self.icons,
                manufacturer='dreambox',
                manufacturer_url='http://www.dreambox.de',
                model_description=self.model_name,
                model_name=self.model_name,
                model_number=self.device_name,
                model_url='http://www.dreambox.de',
                presentation_url=presentation_url))

        self.register()
        self.warning("%s %s (%s) activated with id %s" %
                     (self.device_type, self.model_name, self.backend,
                      str(self.uuid)[5:]))
Пример #6
0
class TubeDeviceProxy(log.Loggable):
    logCategory = 'dbus'

    def __init__(self, coherence, tube_device, external_address):
        log.Loggable.__init__(self)
        self.device = tube_device
        self.coherence = coherence
        self.external_address = external_address
        self.uuid = self.device.get_id().split('-')
        self.uuid[1] = 'tube'
        self.uuid = '-'.join(self.uuid)
        self.friendly_name = self.device.get_friendly_name()
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())

        self._services = []
        self._devices = []
        self.icons = []

        self.info("uuid: %s, name: %r, device type: %r, version: %r",
                  self.uuid, self.friendly_name, self.device_type, self.version)

        """ create the http entrypoint """

        self.web_resource = DeviceHttpRoot(self)
        self.coherence.add_web_resource(str(self.uuid)[5:], self.web_resource)

        """ create the Service proxy(s) """

        for service in self.device.services:
            self.debug("Proxying service %r", service)
            new_service = TubeServiceProxy(service, self)
            self._services.append(new_service)

        """ create a device description xml file(s) """

        version = self.version
        while version > 0:
            self.web_resource.putChild('description-%d.xml' % version,
                                    RootDeviceXML(self.coherence.hostname,
                                    str(self.uuid),
                                    self.coherence.urlbase,
                                    device_type=self.device_type, version=version,
                                    friendly_name=self.friendly_name,
                                    model_description='Coherence UPnP %s' % self.device_type,
                                    model_name='Coherence UPnP %s' % self.device_type,
                                    services=self._services,
                                    devices=self._devices,
                                    icons=self.icons))
            version -= 1

        """ and register with SSDP server """
        self.register()

    def register(self):
        s = self.coherence.ssdp_server
        uuid = str(self.uuid)
        host = self.coherence.hostname
        self.msg('%s register', self.device_type)
        # we need to do this after the children are there, since we send notifies
        s.register('local',
                    '%s::upnp:rootdevice' % uuid,
                    'upnp:rootdevice',
                    self.coherence.urlbase + uuid[5:] + '/' + 'description-%d.xml' % self.version,
                    host=host)

        s.register('local',
                    uuid,
                    uuid,
                    self.coherence.urlbase + uuid[5:] + '/' + 'description-%d.xml' % self.version,
                    host=host)

        version = self.version
        while version > 0:
            if version == self.version:
                silent = False
            else:
                silent = True
            s.register('local',
                        '%s::urn:schemas-upnp-org:device:%s:%d' % (uuid, self.device_type, version),
                        'urn:schemas-upnp-org:device:%s:%d' % (self.device_type, version),
                        self.coherence.urlbase + uuid[5:] + '/' + 'description-%d.xml' % version,
                        silent=silent,
                        host=host)
            version -= 1


        for service in self._services:
            device_version = self.version
            service_version = self.version
            if hasattr(service, 'version'):
                service_version = service.version
            silent = False

            while service_version > 0:
                try:
                    namespace = service.namespace
                except:
                    namespace = 'schemas-upnp-org'

                device_description_tmpl = 'description-%d.xml' % device_version
                if hasattr(service, 'device_description_tmpl'):
                    device_description_tmpl = service.device_description_tmpl

                s.register('local',
                            '%s::urn:%s:service:%s:%d' % (uuid, namespace, service.id, service_version),
                            'urn:%s:service:%s:%d' % (namespace, service.id, service_version),
                            self.coherence.urlbase + uuid[5:] + '/' + device_description_tmpl,
                            silent=silent,
                            host=host)

                silent = True
                service_version -= 1
                device_version -= 1
Пример #7
0
class TubeDeviceProxy(log.LogAble):
    logCategory = 'dbus'

    def __init__(self, coherence, tube_device, external_address):
        log.LogAble.__init__(self)
        self.device = tube_device
        self.coherence = coherence
        self.external_address = external_address
        self.uuid = self.device.get_id().split('-')
        self.uuid[1] = 'tube'
        self.uuid = '-'.join(self.uuid)
        self.friendly_name = self.device.get_friendly_name()
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())

        self._services = []
        self._devices = []
        self.icons = []

        self.info(f'uuid: {self.uuid}, name: {self.friendly_name}, ' +
                  f'device type: {self.device_type}, version: {self.version}')
        ''' create the http entrypoint '''

        self.web_resource = DeviceHttpRoot(self)
        self.coherence.add_web_resource(str(self.uuid)[5:], self.web_resource)
        ''' create the Service proxy(s) '''

        for device_service in self.device.services:
            self.debug(f'Proxying service {device_service}')
            new_service = TubeServiceProxy(device_service, self)
            self._services.append(new_service)
        ''' create a device description xml file(s) '''

        version = self.version
        while version > 0:
            self.web_resource.putChild(
                f'description-{version:d}.xml',
                RootDeviceXML(
                    self.coherence.hostname,
                    str(self.uuid),
                    self.coherence.urlbase,
                    device_type=self.device_type,
                    version=version,
                    friendly_name=self.friendly_name,
                    # model_description=f'Coherence UPnP {self.device_type}',
                    # model_name=f'Coherence UPnP {self.device_type}',
                    services=self._services,
                    devices=self._devices,
                    icons=self.icons,
                ),
            )
            version -= 1
        ''' and register with SSDP server '''
        self.register()

    def register(self):
        s = self.coherence.ssdp_server
        uuid = str(self.uuid)
        host = self.coherence.hostname
        self.msg(f'{self.device_type} register')
        # we need to do this after the children
        # are there, since we send notifies
        s.register(
            'local',
            f'{uuid}::upnp:rootdevice',
            'upnp:rootdevice',
            self.coherence.urlbase + uuid[5:] + '/' +
            f'description-{self.version:d}.xml',
            host=host,
        )

        s.register(
            'local',
            uuid,
            uuid,
            self.coherence.urlbase + uuid[5:] + '/' +
            f'description-{self.version:d}.xml',
            host=host,
        )

        version = self.version
        while version > 0:
            if version == self.version:
                silent = False
            else:
                silent = True
            s.register(
                'local',
                f'{uuid}::urn:schemas-upnp-org:device:{self.device_type}:{version:d}',  # noqa: E501
                f'urn:schemas-upnp-org:device:{self.device_type}:{version:d}',
                self.coherence.urlbase + uuid[5:] + '/' +
                f'description-{version:d}.xml',
                silent=silent,
                host=host,
            )
            version -= 1

        for my_service in self._services:
            device_version = self.version
            service_version = self.version
            if hasattr(my_service, 'version'):
                service_version = my_service.version
            silent = False

            while service_version > 0:
                try:
                    namespace = my_service.namespace
                except Exception:
                    namespace = 'schemas-upnp-org'

                device_description_tmpl = f'description-{device_version:d}.xml'
                if hasattr(my_service, 'device_description_tmpl'):
                    device_description_tmpl = my_service.device_description_tmpl  # noqa: E501

                s.register(
                    'local',
                    f'{uuid}::urn:{namespace}:service:{my_service.id}:{service_version:d}',  # noqa: E501
                    f'urn:{namespace}:service:{my_service.id}:{service_version:d}',  # noqa: E501
                    self.coherence.urlbase + uuid[5:] + '/' +
                    device_description_tmpl,
                    silent=silent,
                    host=host,
                )

                silent = True
                service_version -= 1
                device_version -= 1
Пример #8
0
class TubeDeviceProxy(log.Loggable):
    logCategory = 'dbus'

    def __init__(self, coherence, tube_device, external_address):
        log.Loggable.__init__(self)
        self.device = tube_device
        self.coherence = coherence
        self.external_address = external_address
        self.uuid = self.device.get_id().split('-')
        self.uuid[1] = 'tube'
        self.uuid = '-'.join(self.uuid)
        self.friendly_name = self.device.get_friendly_name()
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())

        self._services = []
        self._devices = []
        self.icons = []

        self.info("uuid: %s, name: %r, device type: %r, version: %r",
                  self.uuid, self.friendly_name, self.device_type,
                  self.version)
        """ create the http entrypoint """

        self.web_resource = DeviceHttpRoot(self)
        self.coherence.add_web_resource(str(self.uuid)[5:], self.web_resource)
        """ create the Service proxy(s) """

        for service in self.device.services:
            self.debug("Proxying service %r", service)
            new_service = TubeServiceProxy(service, self)
            self._services.append(new_service)
        """ create a device description xml file(s) """

        version = self.version
        while version > 0:
            self.web_resource.putChild(
                'description-%d.xml' % version,
                RootDeviceXML(
                    self.coherence.hostname,
                    str(self.uuid),
                    self.coherence.urlbase,
                    device_type=self.device_type,
                    version=version,
                    friendly_name=self.friendly_name,
                    model_description='Coherence UPnP %s' % self.device_type,
                    model_name='Coherence UPnP %s' % self.device_type,
                    services=self._services,
                    devices=self._devices,
                    icons=self.icons))
            version -= 1
        """ and register with SSDP server """
        self.register()

    def register(self):
        s = self.coherence.ssdp_server
        uuid = str(self.uuid)
        host = self.coherence.hostname
        self.msg('%s register', self.device_type)
        # we need to do this after the children are there, since we send notifies
        s.register('local',
                   '%s::upnp:rootdevice' % uuid,
                   'upnp:rootdevice',
                   self.coherence.urlbase + uuid[5:] + '/' +
                   'description-%d.xml' % self.version,
                   host=host)

        s.register('local',
                   uuid,
                   uuid,
                   self.coherence.urlbase + uuid[5:] + '/' +
                   'description-%d.xml' % self.version,
                   host=host)

        version = self.version
        while version > 0:
            if version == self.version:
                silent = False
            else:
                silent = True
            s.register('local',
                       '%s::urn:schemas-upnp-org:device:%s:%d' %
                       (uuid, self.device_type, version),
                       'urn:schemas-upnp-org:device:%s:%d' %
                       (self.device_type, version),
                       self.coherence.urlbase + uuid[5:] + '/' +
                       'description-%d.xml' % version,
                       silent=silent,
                       host=host)
            version -= 1

        for service in self._services:
            device_version = self.version
            service_version = self.version
            if hasattr(service, 'version'):
                service_version = service.version
            silent = False

            while service_version > 0:
                try:
                    namespace = service.namespace
                except:
                    namespace = 'schemas-upnp-org'

                device_description_tmpl = 'description-%d.xml' % device_version
                if hasattr(service, 'device_description_tmpl'):
                    device_description_tmpl = service.device_description_tmpl

                s.register('local',
                           '%s::urn:%s:service:%s:%d' %
                           (uuid, namespace, service.id, service_version),
                           'urn:%s:service:%s:%d' %
                           (namespace, service.id, service_version),
                           self.coherence.urlbase + uuid[5:] + '/' +
                           device_description_tmpl,
                           silent=silent,
                           host=host)

                silent = True
                service_version -= 1
                device_version -= 1