Ejemplo n.º 1
0
    def __init__(self, service, dbus_device, bus):
        self.service = service
        self.dbus_device = dbus_device

        if self.service is not None:
            self.type = self.service.service_type.split(":")[3]  # get the service name
            self.type = self.type.replace("-", "")
        else:
            self.type = "from_the_tubes"

        try:
            bus_name = dbus.service.BusName(SERVICE_IFACE, bus)
        except:
            bus_name = None
            self.tube = bus
        else:
            self.tube = None

        if self.dbus_device is not None:
            self.device_id = self.dbus_device.id
        else:
            self.device_id = "dev_from_the_tubes"
        self.path = OBJECT_PATH + "/devices/" + self.device_id + "/services/" + self.type

        dbus.service.Object.__init__(self, bus, bus_name=bus_name, object_path=self.path)
        self.debug("DBusService %r %r", service, self.type)
        louie.connect(self.variable_changed, "Coherence.UPnP.StateVariable.changed", sender=self.service)

        self.subscribe()
    def __init__(self, device):
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons

        self.wan_connection_device = None
        self.wan_common_interface_connection = None

        self.embedded_device_detection_completed = False
        self.service_detection_completed = False

        louie.connect(self.embedded_device_notified, signal='Coherence.UPnP.EmbeddedDeviceClient.detection_completed', sender=self.device)

        try:
            wan_connection_device = self.device.get_embedded_device_by_type('WANConnectionDevice')[0]
            self.wan_connection_device = WANConnectionDeviceClient(wan_connection_device)
        except:
            self.warning("Embedded WANConnectionDevice device not available, device not implemented properly according to the UPnP specification")
            raise

        louie.connect(self.service_notified, signal='Coherence.UPnP.DeviceClient.Service.notified', sender=self.device)
        for service in self.device.get_services():
            if service.get_type() in ["urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"]:
                self.wan_common_interface_connection = WANCommonInterfaceConfigClient(service)

        self.info("WANDevice %s" % (self.device.get_friendly_name()))
    def __init__(self, device):
        log.Loggable.__init__(self)
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons

        self.wan_device = None

        self.detection_completed = False

        louie.connect(
            self.embedded_device_notified,
            signal='Coherence.UPnP.EmbeddedDeviceClient.detection_completed',
            sender=self.device)

        try:
            wan_device = self.device.get_embedded_device_by_type(
                'WANDevice')[0]
            self.wan_device = WANDeviceClient(wan_device)
        except:
            self.warning(
                "Embedded WANDevice device not available, device not implemented properly according to the UPnP specification"
            )
            raise

        self.info("InternetGatewayDevice %s", self.device.get_friendly_name())
Ejemplo n.º 4
0
    def __init__(self, device):
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons
        self.switch_power = None

        self.detection_completed = False

        louie.connect(self.service_notified,
                      signal='Coherence.UPnP.DeviceClient.Service.notified',
                      sender=self.device)

        for service in self.device.get_services():
            if service.get_type() in [
                    "urn:schemas-upnp-org:service:SwitchPower:1"
            ]:
                self.switch_power = SwitchPowerClient(service)

        self.info("BinaryLight %s" % (self.device.get_friendly_name()))
        if self.switch_power:
            self.info("SwitchPower service available")
        else:
            self.warning(
                "SwitchPower service not available, device not implemented properly according to the UPnP specification"
            )
Ejemplo n.º 5
0
    def __init__(self, coherence, backend, **kwargs):
        self.coherence = coherence
        if not hasattr(self, 'version'):
            self.version = int(
                kwargs.get('version', self.coherence.config.get('version', 2)))

        try:
            self.uuid = kwargs['uuid']
            if not self.uuid.startswith('uuid:'):
                self.uuid = 'uuid:' + self.uuid
        except KeyError:
            from coherence.upnp.core.uuid import UUID
            self.uuid = UUID()

        self.backend = None
        urlbase = self.coherence.urlbase
        if urlbase[-1] != '/':
            urlbase += '/'
        self.urlbase = urlbase + str(self.uuid)[5:]

        kwargs['urlbase'] = self.urlbase
        self.icons = kwargs.get('iconlist', kwargs.get('icons', []))
        if len(self.icons) == 0:
            if kwargs.has_key('icon'):
                if isinstance(kwargs['icon'], dict):
                    self.icons.append(kwargs['icon'])
                else:
                    self.icons = kwargs['icon']

        louie.connect(self.init_complete,
                      'Coherence.UPnP.Backend.init_completed', louie.Any)
        louie.connect(self.init_failed, 'Coherence.UPnP.Backend.init_failed',
                      louie.Any)
        reactor.callLater(0.2, self.fire, backend, **kwargs)
Ejemplo n.º 6
0
    def __init__(self, service, dbus_device, bus):
        self.service = service
        self.dbus_device = dbus_device

        if self.service is not None:
            self.type = self.service.service_type.split(':')[3] # get the service name
        else:
            self.type = "from_the_tubes"

        try:
            bus_name = dbus.service.BusName(CDS_SERVICE, bus)
        except:
            bus_name = None
            self.tube = bus
        else:
            self.tube = None

        if dbus_device:
            device_id = dbus_device.id
        else:
            device_id = "dev_from_the_tubes"
        self.path = OBJECT_PATH + '/devices/' + device_id + '/services/' + 'CDS'
        s = dbus.service.Object.__init__(self, bus, bus_name=bus_name,
                                         object_path=self.path)
        self.debug("DBusService %r %r %r", service, self.type, s)
        louie.connect(self.variable_changed, 'StateVariable.changed', sender=self.service)

        self.subscribeStateVariables()
    def __init__(self, device):
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons
        self.switch_power = None
        self.dimming = None

        self.detection_completed = False

        louie.connect(self.service_notified, signal='Coherence.UPnP.DeviceClient.Service.notified', sender=self.device)

        for service in self.device.get_services():
            if service.get_type() in ["urn:schemas-upnp-org:service:SwitchPower:1"]:
                self.switch_power = SwitchPowerClient(service)
            if service.get_type() in ["urn:schemas-upnp-org:service:Dimming:1"]:
                self.dimming = DimmingClient(service)

        self.info("DimmingLight %s" % (self.device.get_friendly_name()))
        if self.switch_power:
            self.info("SwitchPower service available")
        else:
            self.warning("SwitchPower service not available, device not implemented properly according to the UPnP specification")
            return
        if self.dimming:
            self.info("Dimming service available")
        else:
            self.warning("Dimming service not available, device not implemented properly according to the UPnP specification")
    def __init__(self, device):
        log.Loggable.__init__(self)
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons

        self.wan_ip_connection = None
        self.wan_ppp_connection = None

        self.detection_completed = False

        louie.connect(self.service_notified,
                      signal='Coherence.UPnP.DeviceClient.Service.notified',
                      sender=self.device)

        for service in self.device.get_services():
            if service.get_type() in [
                    "urn:schemas-upnp-org:service:WANIPConnection:1"
            ]:
                self.wan_ip_connection = WANIPConnectionClient(service)
            if service.get_type() in [
                    "urn:schemas-upnp-org:service:WANPPPConnection:1"
            ]:
                self.wan_ppp_connection = WANPPPConnectionClient(service)
        self.info("WANConnectionDevice %s", self.device.get_friendly_name())
        if self.wan_ip_connection:
            self.info("WANIPConnection service available")
        if self.wan_ppp_connection:
            self.info("WANPPPConnection service available")
Ejemplo n.º 9
0
    def __init__(self, server, **kwargs):
        log.Loggable.__init__(self)
        self.next_id = 1000
        self.config = kwargs
        self.name = kwargs.get('name', 'Buzztard')

        self.urlbase = kwargs.get('urlbase', '')
        if (len(self.urlbase) > 0
                and self.urlbase[len(self.urlbase) - 1] != '/'):
            self.urlbase += '/'

        self.host = kwargs.get('host', '127.0.0.1')
        self.port = int(kwargs.get('port', 7654))

        self.server = server
        self.update_id = 0
        self.store = {}
        self.parent = None

        louie.connect(self.add_content, 'Buzztard.Response.browse', louie.Any)
        louie.connect(self.clear, 'Buzztard.Response.flush', louie.Any)

        self.buzztard = BzConnection(backend=self,
                                     host=self.host,
                                     port=self.port)
Ejemplo n.º 10
0
    def __init__(self, service, dbus_device, bus):
        self.service = service
        self.dbus_device = dbus_device

        if self.service is not None:
            self.type = self.service.service_type.split(':')[
                3]  # get the service name
            self.type = self.type.replace('-', '')
        else:
            self.type = "from_the_tubes"

        try:
            bus_name = dbus.service.BusName(SERVICE_IFACE, bus)
        except:
            bus_name = None
            self.tube = bus
        else:
            self.tube = None

        if self.dbus_device is not None:
            self.device_id = self.dbus_device.id
        else:
            self.device_id = "dev_from_the_tubes"
        self.path = OBJECT_PATH + '/devices/' + self.device_id + '/services/' + self.type

        dbus.service.Object.__init__(self,
                                     bus,
                                     bus_name=bus_name,
                                     object_path=self.path)
        self.debug("DBusService %r %r", service, self.type)
        louie.connect(self.variable_changed,
                      'Coherence.UPnP.StateVariable.changed',
                      sender=self.service)

        self.subscribe()
Ejemplo n.º 11
0
 def __init__(self, coherence, backend, **kwargs):
     self.coherence = coherence
     if not hasattr(self, 'version'):
         self.version = int(kwargs.get('version', self.coherence.config.get('version', 2)))
     try:
         self.uuid = kwargs['uuid']
         if not self.uuid.startswith('uuid:'):
             self.uuid = 'uuid:' + self.uuid
     except KeyError:
         from coherence.upnp.core.uuid import UUID
         self.uuid = UUID()
     self.backend = None
     urlbase = self.coherence.urlbase
     if urlbase[-1] != '/':
         urlbase += '/'
     self.urlbase = urlbase + str(self.uuid)[5:]
     kwargs['urlbase'] = self.urlbase
     self.icons = kwargs.get('iconlist', kwargs.get('icons', []))
     if len(self.icons) == 0:
         if kwargs.has_key('icon'):
             if isinstance(kwargs['icon'], dict):
                 self.icons.append(kwargs['icon'])
             else:
                 self.icons = kwargs['icon']
     louie.connect(self.init_complete, 'Coherence.UPnP.Backend.init_completed', louie.Any)
     louie.connect(self.init_failed, 'Coherence.UPnP.Backend.init_failed', louie.Any)
     reactor.callLater(0.2, self.fire, backend, **kwargs)
Ejemplo n.º 12
0
 def connect(self,
             receiver,
             signal=louie.signal.All,
             sender=louie.sender.Any,
             weak=True):
     """ wrapper method around louie.connect
     """
     louie.connect(receiver, signal=signal, sender=sender, weak=weak)
Ejemplo n.º 13
0
 def subscribe_for_variable(self, var_name, instance=0, callback=None, signal=False):
   variable = self.get_state_variable(var_name)
   if variable:
     if callback is not None:
       if signal:
         callback(variable)
         louie.connect(callback, signal='Coherence.UPnP.StateVariable.%s.changed' % var_name, sender=self)
       else:
         variable.subscribe(callback)
Ejemplo n.º 14
0
    def __init__(self, service, dbus_device, bus):
        self.service = service
        self.dbus_device = dbus_device
        self.type = self.service.service_type.split(':')[3] # get the service name
        bus_name = dbus.service.BusName(BUS_NAME+'.service', bus)
        s = dbus.service.Object.__init__(self, bus_name, OBJECT_PATH + '/devices/' + dbus_device.id + '/services/' + self.type)
        self.debug("DBusService %r %r %r", service, self.type, s)
        louie.connect(self.variable_changed, 'Coherence.UPnP.StateVariable.changed', sender=self.service)

        self.subscribe()
Ejemplo n.º 15
0
    def connect(self, receiver, signal = louie.signal.All, sender = louie.sender.Any, weak = True):
        """ wrapper method around louie.connect

        @param receiver: Method to connect to.
        @param signal:
        @param sender:
        @param weak:
        """
        #print " Connect #3 (ControlPoint) Receiver:{0:}, Signal:{1:}, Sender:{2:}, Weak:{3:}".format(receiver, signal, sender, weak)
        louie.connect(receiver, signal = signal, sender = sender, weak = weak)
Ejemplo n.º 16
0
    def testBrowse(self):
        self._log.info( "\ntestBrowse" )

        self.loader = EventRouterLoader()
        self.loader.loadHandlers( getDictFromXmlString(testConfigUPNP) )
        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()

        louie.connect( self.mediaserver_detected, 'Coherence.UPnP.ControlPoint.MediaServer.detected')

        time.sleep(30)
Ejemplo n.º 17
0
	def load_device_info(self, device_infos):
		# Return a deferred that signals that the device's info is loaded
		# Bridges the coherence louie event bus to a single deferred
		def receive_callback(device):
			if device == self.device:
				louie.disconnect(receive_callback, 'Coherence.UPnP.RootDevice.detection_completed')
				d.callback(device)
		d = Deferred()
		louie.connect(receive_callback, 'Coherence.UPnP.RootDevice.detection_completed', louie.Any)
		self.device = RootDevice(device_infos)
		return d
Ejemplo n.º 18
0
 def __init__(self, service, dbus_device, bus):
     self.service = service
     self.dbus_device = dbus_device
     self.type = self.service.service_type.split(":")[3]  # get the service name
     bus_name = dbus.service.BusName(CDS_SERVICE, bus)
     device_id = dbus_device.id
     self.path = OBJECT_PATH + "/devices/" + device_id + "/services/" + "CDS"
     dbus.service.Object.__init__(self, bus, bus_name=bus_name, object_path=self.path)
     self.debug("DBusService %r %r", service, self.type)
     louie.connect(self.variable_changed, "StateVariable.changed", sender=self.service)
     self.subscribeStateVariables()
Ejemplo n.º 19
0
    def __init__(self, device):
        log.Loggable.__init__(self)
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons
        self.scheduled_recording = None
        self.content_directory = None
        self.connection_manager = None
        self.av_transport = None

        self.detection_completed = False

        louie.connect(self.service_notified,
                      signal='Coherence.UPnP.DeviceClient.Service.notified',
                      sender=self.device)

        for service in self.device.get_services():
            if service.get_type() in [
                    "urn:schemas-upnp-org:service:ContentDirectory:1",
                    "urn:schemas-upnp-org:service:ContentDirectory:2"
            ]:
                self.content_directory = ContentDirectoryClient(service)
            if service.get_type() in [
                    "urn:schemas-upnp-org:service:ConnectionManager:1",
                    "urn:schemas-upnp-org:service:ConnectionManager:2"
            ]:
                self.connection_manager = ConnectionManagerClient(service)
            if service.get_type() in [
                    "urn:schemas-upnp-org:service:AVTransport:1",
                    "urn:schemas-upnp-org:service:AVTransport:2"
            ]:
                self.av_transport = AVTransportClient(service)

        self.info("MediaServer %s", self.device.get_friendly_name())
        if self.content_directory:
            self.info("ContentDirectory available")
        else:
            self.warning(
                "ContentDirectory not available, device not implemented properly according to the UPnP specification"
            )
            return
        if self.connection_manager:
            self.info("ConnectionManager available")
        else:
            self.warning(
                "ConnectionManager not available, device not implemented properly according to the UPnP specification"
            )
            return
        if self.av_transport:
            self.info("AVTransport (optional) available")
        if self.scheduled_recording:
            self.info("ScheduledRecording (optional) available")
    def __init__(self, device):
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons
        self.scheduled_recording = None
        self.content_directory = None
        self.connection_manager = None
        self.av_transport = None

        self.detection_completed = False

        louie.connect(self.service_notified, signal="Coherence.UPnP.DeviceClient.Service.notified", sender=self.device)

        for service in self.device.get_services():
            if service.get_type() in [
                "urn:schemas-upnp-org:service:ContentDirectory:1",
                "urn:schemas-upnp-org:service:ContentDirectory:2",
            ]:
                self.content_directory = ContentDirectoryClient(service)
            if service.get_type() in [
                "urn:schemas-upnp-org:service:ConnectionManager:1",
                "urn:schemas-upnp-org:service:ConnectionManager:2",
            ]:
                self.connection_manager = ConnectionManagerClient(service)
            if service.get_type() in [
                "urn:schemas-upnp-org:service:AVTransport:1",
                "urn:schemas-upnp-org:service:AVTransport:2",
            ]:
                self.av_transport = AVTransportClient(service)
            # if service.get_type()  in ["urn:schemas-upnp-org:service:ScheduledRecording:1",
            #                           "urn:schemas-upnp-org:service:ScheduledRecording:2"]:
            #    self.scheduled_recording = ScheduledRecordingClient( service)
        self.info("MediaServer %s" % (self.device.get_friendly_name()))
        if self.content_directory:
            self.info("ContentDirectory available")
        else:
            self.warning(
                "ContentDirectory not available, device not implemented properly according to the UPnP specification"
            )
            return
        if self.connection_manager:
            self.info("ConnectionManager available")
        else:
            self.warning(
                "ConnectionManager not available, device not implemented properly according to the UPnP specification"
            )
            return
        if self.av_transport:
            self.info("AVTransport (optional) available")
        if self.scheduled_recording:
            self.info("ScheduledRecording (optional) available")
Ejemplo n.º 21
0
 def __init__(self, infos):
     self.usn = infos['USN']
     self.server = infos['SERVER']
     self.st = infos['ST']
     self.location = infos['LOCATION']
     self.manifestation = infos['MANIFESTATION']
     self.host = infos['HOST']
     self.root_detection_completed = False
     Device.__init__(self, None)
     louie.connect(self.device_detect, 'Coherence.UPnP.Device.detection_completed', self)
     # we need to handle root device completion
     # these events could be ourself or our children.
     self.parse_description()
Ejemplo n.º 22
0
 def __init__(self, infos):
     self.usn = infos['USN']
     self.server = infos['SERVER']
     self.st = infos['ST']
     self.location = infos['LOCATION']
     self.manifestation = infos['MANIFESTATION']
     self.host = infos['HOST']
     self.root_detection_completed = False
     Device.__init__(self, None)
     louie.connect( self.device_detect, 'Coherence.UPnP.Device.detection_completed', self)
     # we need to handle root device completion
     # these events could be ourself or our children.
     self.parse_description()
Ejemplo n.º 23
0
 def __init__(self, parent=None):
     self.parent = parent
     self.services = []
     self.friendly_name = ""
     self.device_type = ""
     self.friendly_device_type = "[unknown]"
     self.device_type_version = 0
     self.udn = None
     self.detection_completed = False
     self.client = None
     self.icons = []
     self.devices = []
     louie.connect(self.receiver, "Coherence.UPnP.Service.detection_completed", self)
     louie.connect(self.service_detection_failed, "Coherence.UPnP.Service.detection_failed", self)
Ejemplo n.º 24
0
    def __init__(self, parent=None):
        self.parent = parent
        self.services = []
        #self.uid = self.usn[:-len(self.st)-2]
        self.friendly_name = ""
        self.device_type = ""
        self.udn = None
        self.detection_completed = False
        self.client = None
        self.icons = []
        self.devices = []

        louie.connect( self.receiver, 'Coherence.UPnP.Service.detection_completed', self)
        louie.connect( self.service_detection_failed, 'Coherence.UPnP.Service.detection_failed', self)
Ejemplo n.º 25
0
    def __init__(self, device):
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons
        self.rendering_control = None
        self.connection_manager = None
        self.av_transport = None

        self.detection_completed = False

        louie.connect(self.service_notified, signal='Coherence.UPnP.DeviceClient.Service.notified', sender=self.device)

        for service in self.device.get_services():
            if service.get_type() in ["urn:schemas-upnp-org:service:RenderingControl:1",
                                      "urn:schemas-upnp-org:service:RenderingControl:2"]:
                self.rendering_control = RenderingControlClient( service)
            if service.get_type() in ["urn:schemas-upnp-org:service:ConnectionManager:1",
                                      "urn:schemas-upnp-org:service:ConnectionManager:2"]:
                self.connection_manager = ConnectionManagerClient( service)
            if service.get_type() in ["urn:schemas-upnp-org:service:AVTransport:1",
                                      "urn:schemas-upnp-org:service:AVTransport:2"]:
                self.av_transport = AVTransportClient( service)
        self.info("MediaRenderer %s" % (self.device.get_friendly_name()))
        if self.rendering_control:
            self.info("RenderingControl available")
            """
            actions =  self.rendering_control.service.get_actions()
            print actions
            for action in actions:
                print "Action:", action
                for arg in actions[action].get_arguments_list():
                    print "       ", arg
            """
            #self.rendering_control.list_presets()
            #self.rendering_control.get_mute()
            #self.rendering_control.get_volume()
            #self.rendering_control.set_mute(desired_mute=1)
        else:
            self.warning("RenderingControl not available, device not implemented properly according to the UPnP specification")
            return
        if self.connection_manager:
            self.info("ConnectionManager available")
            #self.connection_manager.get_protocol_info()
        else:
            self.warning("ConnectionManager not available, device not implemented properly according to the UPnP specification")
            return
        if self.av_transport:
            self.info("AVTransport (optional) available")
Ejemplo n.º 26
0
    def testBrowse2(self):
        self._log.info( "\ntestBrowse2" )

        louie.connect( self.add_server, 'Coherence.UPnP.ControlPoint.MediaServer.detected')

        self.loader = EventRouterLoader()
        self.loader.loadHandlers( getDictFromXmlString(testConfigUPNP) )
        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()
        self.directory = UPNP_Directory()


        time.sleep(5)
        for clnt in self.directory.getContainers():
            self.dumpDirectory(clnt)
Ejemplo n.º 27
0
def main():

    louie.connect( test_init_complete, 'Coherence.UPnP.Backend.init_completed', louie.Any)

    f = BuzztardStore(None)

    f.parent = f.append('Buzztard', 'directory', None)
    print f.parent
    print f.store
    f.add_content('playlist|test label|start|stop')
    print f.store
    f.clear()
    print f.store
    f.add_content('playlist|after flush label|flush-start|flush-stop')
    print f.store
Ejemplo n.º 28
0
    def __init__(self, service, dbus_device, bus):
        self.service = service
        self.dbus_device = dbus_device

        self.type = self.service.service_type.split(':')[3] # get the service name

        bus_name = dbus.service.BusName(CDS_SERVICE, bus)

        device_id = dbus_device.id
        self.path = OBJECT_PATH + '/devices/' + device_id + '/services/' + 'CDS'
        dbus.service.Object.__init__(self, bus, bus_name=bus_name,
                                         object_path=self.path)
        self.debug("DBusService %r %r", service, self.type)
        louie.connect(self.variable_changed, 'StateVariable.changed', sender=self.service)

        self.subscribeStateVariables()
Ejemplo n.º 29
0
def main():

    louie.connect(test_init_complete, 'Coherence.UPnP.Backend.init_completed',
                  louie.Any)

    f = BuzztardStore(None)

    f.parent = f.append('Buzztard', 'directory', None)
    print(f.parent)
    print(f.store)
    f.add_content('playlist|test label|start|stop')
    print(f.store)
    f.clear()
    print(f.store)
    f.add_content('playlist|after flush label|flush-start|flush-stop')
    print(f.store)
Ejemplo n.º 30
0
 def going_live(self):
     self.info("add a view to the DevicesFragment",self._athenaID)
     self.page.menu.add_tab('Devices',self.active,self._athenaID)
     d = self.page.notifyOnDisconnect()
     d.addCallback( self.remove_me)
     d.addErrback( self.remove_me)
     devices = []
     for device in self.coherence.get_devices():
         if device != None:
             _,_,_,device_type,version = device.get_device_type().split(':')
             name = unicode("%s:%s %s" % (device_type,version,device.get_friendly_name()))
             usn = unicode(device.get_usn())
             devices.append({u'name':name,u'usn':usn})
     louie.connect( self.add_device, 'Coherence.UPnP.Device.detection_completed', louie.Any)
     louie.connect( self.remove_device, 'Coherence.UPnP.Device.removed', louie.Any)
     return devices
Ejemplo n.º 31
0
    def __init__(self, service, dbus_device, bus):
        log.Loggable.__init__(self)
        self.service = service
        self.dbus_device = dbus_device

        self.type = self.service.service_type.split(':')[3]  # get the service name

        bus_name = dbus.service.BusName(CDS_SERVICE, bus)

        device_id = dbus_device.id
        self.path = OBJECT_PATH + '/devices/' + device_id + '/services/' + 'CDS'
        dbus.service.Object.__init__(self, bus, bus_name=bus_name,
                                         object_path=self.path)
        self.debug("DBusService %r %r", service, self.type)
        louie.connect(self.variable_changed, 'StateVariable.changed', sender=self.service)

        self.subscribeStateVariables()
Ejemplo n.º 32
0
 def subscribe_for_variable(self,
                            var_name,
                            instance=0,
                            callback=None,
                            signal=False):
     variable = self.get_state_variable(var_name)
     if variable:
         if callback != None:
             if signal == True:
                 callback(variable)
                 louie.connect(
                     callback,
                     signal='Coherence.UPnP.StateVariable.%s.changed' %
                     var_name,
                     sender=self)
             else:
                 variable.subscribe(callback)
Ejemplo n.º 33
0
    def __init__(self, parent=None):
        log.Loggable.__init__(self)
        self.parent = parent
        self.services = []
        #self.uid = self.usn[:-len(self.st)-2]
        self.friendly_name = ""
        self.device_type = ""
        self.friendly_device_type = "[unknown]"
        self.device_type_version = 0
        self.udn = None
        self.detection_completed = False
        self.client = None
        self.icons = []
        self.devices = []

        louie.connect(self.receiver, 'Coherence.UPnP.Service.detection_completed', self)
        louie.connect(self.service_detection_failed, 'Coherence.UPnP.Service.detection_failed', self)
Ejemplo n.º 34
0
    def going_live(self):
        self.info("add a view to the DevicesFragment %s", self._athenaID)
        self.page.menu.add_tab('Devices', self.active, self._athenaID)
        d = self.page.notifyOnDisconnect()
        d.addCallback(self.remove_me)
        d.addErrback(self.remove_me)
        devices = []
        for device in self.coherence.get_devices():
            if device is not None:
                devices.append({u'name': device.get_markup_name(),
                        u'usn': unicode(device.get_usn())})

        louie.connect(self.add_device,
                'Coherence.UPnP.Device.detection_completed', louie.Any)
        louie.connect(self.remove_device,
                'Coherence.UPnP.Device.removed', louie.Any)

        return devices
Ejemplo n.º 35
0
    def __init__(self,controlpoint):
        self.controlpoint = controlpoint
        self.bus = dbus.SessionBus()
        self.bus_name = dbus.service.BusName(BUS_NAME, self.bus)
        dbus.service.Object.__init__(self, self.bus_name, OBJECT_PATH)

        self.debug("D-Bus pontoon %r %r %r" % (self, self.bus, self.bus_name))

        self.devices = []

        for device in self.controlpoint.get_devices():
            self.devices.append(DBusDevice(device,self.bus_name))

        louie.connect(self.cp_ms_detected, 'Coherence.UPnP.ControlPoint.MediaServer.detected', louie.Any)
        louie.connect(self.cp_ms_removed, 'Coherence.UPnP.ControlPoint.MediaServer.removed', louie.Any)
        louie.connect(self.cp_mr_detected, 'Coherence.UPnP.ControlPoint.MediaRenderer.detected', louie.Any)
        louie.connect(self.cp_mr_removed, 'Coherence.UPnP.ControlPoint.MediaRenderer.removed', louie.Any)
        louie.connect(self.remove_client, 'Coherence.UPnP.Device.remove_client', louie.Any)
Ejemplo n.º 36
0
    def going_live(self):
        self.info("add a view to the DevicesFragment", self._athenaID)
        self.page.menu.add_tab('Devices', self.active, self._athenaID)
        d = self.page.notifyOnDisconnect()
        d.addCallback(self.remove_me)
        d.addErrback(self.remove_me)
        devices = []
        for device in self.coherence.get_devices():
            if device is not None:
                devices.append({u'name': device.get_markup_name(),
                        u'usn':unicode(device.get_usn())})

        louie.connect(self.add_device,
                'Coherence.UPnP.Device.detection_completed', louie.Any)
        louie.connect(self.remove_device,
                'Coherence.UPnP.Device.removed', louie.Any)

        return devices
 def __init__(self, device):
     self.device = device
     self.device_type = self.device.get_friendly_device_type()
     self.version = int(self.device.get_device_type_version())
     self.icons = device.icons
     self.wan_ip_connection = None
     self.wan_ppp_connection = None
     self.detection_completed = False
     louie.connect(self.service_notified, signal = 'Coherence.UPnP.DeviceClient.Service.notified', sender = self.device)
     for service in self.device.get_services():
         if service.get_type() in ["urn:schemas-upnp-org:service:WANIPConnection:1"]:
             self.wan_ip_connection = WANIPConnectionClient(service)
         if service.get_type() in ["urn:schemas-upnp-org:service:WANPPPConnection:1"]:
             self.wan_ppp_connection = WANPPPConnectionClient(service)
     self.info("WANConnectionDevice %s" % (self.device.get_friendly_name()))
     if self.wan_ip_connection:
         self.info("WANIPConnection service available")
     if self.wan_ppp_connection:
         self.info("WANPPPConnection service available")
Ejemplo n.º 38
0
    def __init__(self, device):
        self.device = device
        self.device_type,self.version = device.get_device_type().split(':')[3:5]
        self.detection_completed = False
        self.standalone_group = True
        self.group_members = list()

#        self.icons = device.icons

        louie.connect(self.service_notified, signal='Coherence.UPnP.DeviceClient.Service.notified', sender=self.device)
	self.alarm_clock = None
	self.music_services = None
	self.audio_in = None
	self.device_properties = None
	self.system_properties = None
	self.zone_group_topology = None
	self.group_management = None

        for service in self.device.get_services():
            if service.get_type() in ["urn:schemas-upnp-org:service:AlarmClock:1",
                                      ]:
                self.alarm_clock = BaseClient( service)
            elif service.get_type() in ["urn:schemas-upnp-org:service:MusicServices:1",
					]:
                self.music_services = BaseClient( service)
            elif service.get_type() in ["urn:schemas-upnp-org:service:AudioIn:1",
					]:
                self.audio_in = BaseClient( service)
            elif service.get_type() in ["urn:schemas-upnp-org:service:DeviceProperties:1",
					]:
                self.device_properties = BaseClient( service)
            elif service.get_type() in ["urn:schemas-upnp-org:service:SystemProperties:1",
					]:
                self.system_properties = BaseClient( service)
            elif service.get_type() in ["urn:schemas-upnp-org:service:ZoneGroupTopology:1",
					]:
                self.zone_group_topology = ZoneGroupTopologyClient( service)
            elif service.get_type() in ["urn:schemas-upnp-org:service:GroupManagement:1",
					]:
                self.group_management = GroupManagementClient( service)

        self.info("%s", self.device.get_friendly_name())
    def __init__(self, device):
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons

        self.wan_device = None

        self.detection_completed = False

        louie.connect(self.embedded_device_notified, signal='Coherence.UPnP.EmbeddedDeviceClient.detection_completed', sender=self.device)

        try:
            wan_device = self.device.get_embedded_device_by_type('WANDevice')[0]
            self.wan_device = WANDeviceClient(wan_device)
        except:
            self.warning("Embedded WANDevice device not available, device not implemented properly according to the UPnP specification")
            raise

        self.info("InternetGatewayDevice %s" % (self.device.get_friendly_name()))
Ejemplo n.º 40
0
    def __init__(self, controlpoint, bus=None):
        self.bus = bus or dbus.SessionBus()
        try:
            bus_name = dbus.service.BusName(BUS_NAME, self.bus)
        except:
            bus_name = None
            self.tube = self.bus
        else:
            self.tube = None

        self.bus_name = bus_name
        dbus.service.Object.__init__(self,
                                     self.bus,
                                     bus_name=self.bus_name,
                                     object_path=OBJECT_PATH)

        self.debug("D-Bus pontoon %r %r %r" % (self, self.bus, self.bus_name))

        self.devices = {}
        self.controlpoint = controlpoint
        self.pinboard = {}

        # i am a stub service if i have no control point
        if self.controlpoint is None:
            return

        for device in self.controlpoint.get_devices():
            self.devices[device.get_id()] = DBusDevice(device, self.bus_name)

        #louie.connect(self.cp_ms_detected, 'Coherence.UPnP.ControlPoint.MediaServer.detected', louie.Any)
        #louie.connect(self.cp_ms_removed, 'Coherence.UPnP.ControlPoint.MediaServer.removed', louie.Any)
        #louie.connect(self.cp_mr_detected, 'Coherence.UPnP.ControlPoint.MediaRenderer.detected', louie.Any)
        #louie.connect(self.cp_mr_removed, 'Coherence.UPnP.ControlPoint.MediaRenderer.removed', louie.Any)
        #louie.connect(self.remove_client, 'Coherence.UPnP.Device.remove_client', louie.Any)

        louie.connect(self._device_detected,
                      'Coherence.UPnP.Device.detection_completed', louie.Any)
        louie.connect(self._device_removed, 'Coherence.UPnP.Device.removed',
                      louie.Any)

        self.debug("D-Bus pontoon started")
Ejemplo n.º 41
0
    def __init__(self, coherence, backend, **kwargs):
        self.coherence = coherence
        self.device_type = 'BinaryLight'
        self.version = 1
        #log.Loggable.__init__(self)

        try:
            self.uuid = kwargs['uuid']
        except KeyError:
            from coherence.upnp.core.uuid import UUID
            self.uuid = UUID()

        self.backend = None

        self.icons = kwargs.get('iconlist', kwargs.get('icons', []))
        if len(self.icons) == 0:
            if kwargs.has_key('icon'):
                self.icons.append(kwargs['icon'])

        louie.connect( self.init_complete, 'Coherence.UPnP.Backend.init_completed', louie.Any)
        reactor.callLater(0.2, self.fire, backend, **kwargs)
Ejemplo n.º 42
0
    def __init__(self, device):
        log.Loggable.__init__(self)
        self.device = device
        self.device_type = self.device.get_friendly_device_type()
        self.version = int(self.device.get_device_type_version())
        self.icons = device.icons

        self.wan_connection_device = None
        self.wan_common_interface_connection = None

        self.embedded_device_detection_completed = False
        self.service_detection_completed = False

        louie.connect(
            self.embedded_device_notified,
            signal='Coherence.UPnP.EmbeddedDeviceClient.detection_completed',
            sender=self.device)

        try:
            wan_connection_device = self.device.get_embedded_device_by_type(
                'WANConnectionDevice')[0]
            self.wan_connection_device = WANConnectionDeviceClient(
                wan_connection_device)
        except:
            self.warning(
                "Embedded WANConnectionDevice device not available, device not implemented properly according to the UPnP specification"
            )
            raise

        louie.connect(self.service_notified,
                      signal='Coherence.UPnP.DeviceClient.Service.notified',
                      sender=self.device)
        for service in self.device.get_services():
            if service.get_type() in [
                    "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"
            ]:
                self.wan_common_interface_connection = WANCommonInterfaceConfigClient(
                    service)

        self.info("WANDevice %s", self.device.get_friendly_name())
Ejemplo n.º 43
0
    def __init__(self,
                 coherence,
                 auto_client=[
                     'MediaServer', 'MediaRenderer', 'BinaryLight',
                     'DimmableLight'
                 ]):
        self.coherence = coherence

        self.info("Coherence UPnP ControlPoint starting...")
        self.event_server = EventServer(self)

        self.coherence.add_web_resource('RPC2', XMLRPC(self))

        self.auto_client = auto_client
        self.queries = []

        for device in self.get_devices():
            self.check_device(device)

        louie.connect(self.check_device,
                      'Coherence.UPnP.Device.detection_completed', louie.Any)
        louie.connect(self.remove_client,
                      'Coherence.UPnP.Device.remove_client', louie.Any)

        louie.connect(self.completed,
                      'Coherence.UPnP.DeviceClient.detection_completed',
                      louie.Any)
Ejemplo n.º 44
0
    def __init__(self, server, **kwargs):
        self.next_id = 1000
        self.config = kwargs
        self.name = kwargs.get('name','Buzztard')

        self.urlbase = kwargs.get('urlbase','')
        if( len(self.urlbase)>0 and
            self.urlbase[len(self.urlbase)-1] != '/'):
            self.urlbase += '/'

        self.host = kwargs.get('host','127.0.0.1')
        self.port = int(kwargs.get('port',7654))

        self.server = server
        self.update_id = 0
        self.store = {}
        self.parent = None

        louie.connect( self.add_content, 'Buzztard.Response.browse', louie.Any)
        louie.connect( self.clear, 'Buzztard.Response.flush', louie.Any)

        self.buzztard = BzConnection(backend=self,host=self.host,port=self.port)
Ejemplo n.º 45
0
	def __init__(self):
		self.ssdp = SSDPServer()
		self.msearch = MSearch(self.ssdp, test=False)
		self.devices = []
		louie.connect(self.ssdp_detected, 'Coherence.UPnP.SSDP.new_device', louie.Any)
		louie.connect(self.ssdp_deleted, 'Coherence.UPnP.SSDP.removed_device', louie.Any)
		louie.connect(self.device_found, 'Coherence.UPnP.RootDevice.detection_completed', louie.Any)
		self.msearch.double_discover()
Ejemplo n.º 46
0
    def __init__(self,controlpoint, bus=None):
        self.bus = bus or dbus.SessionBus()
        try:
            bus_name = dbus.service.BusName(BUS_NAME, self.bus)
        except:
            bus_name = None
            self.tube = self.bus
        else:
            self.tube = None

        self.bus_name = bus_name
        dbus.service.Object.__init__(self, self.bus, bus_name=self.bus_name,
                                     object_path=OBJECT_PATH)


        self.debug("D-Bus pontoon %r %r %r" % (self, self.bus, self.bus_name))

        self.devices = {}
        self.controlpoint = controlpoint
        self.pinboard = {}

        # i am a stub service if i have no control point
        if self.controlpoint is None:
            return

        for device in self.controlpoint.get_devices():
            self.devices[device.get_id()] = DBusDevice(device,self.bus_name)

        #louie.connect(self.cp_ms_detected, 'Coherence.UPnP.ControlPoint.MediaServer.detected', louie.Any)
        #louie.connect(self.cp_ms_removed, 'Coherence.UPnP.ControlPoint.MediaServer.removed', louie.Any)
        #louie.connect(self.cp_mr_detected, 'Coherence.UPnP.ControlPoint.MediaRenderer.detected', louie.Any)
        #louie.connect(self.cp_mr_removed, 'Coherence.UPnP.ControlPoint.MediaRenderer.removed', louie.Any)
        #louie.connect(self.remove_client, 'Coherence.UPnP.Device.remove_client', louie.Any)

        louie.connect(self._device_detected, 'Coherence.UPnP.Device.detection_completed', louie.Any)
        louie.connect(self._device_removed, 'Coherence.UPnP.Device.removed', louie.Any)

        self.debug("D-Bus pontoon started")
Ejemplo n.º 47
0
	def __init__(self):
		self.ssdp = SSDPServer()		# listen for things destined to port 1900
		self.ssdpalt = SSDPServerAlt()
		self.msearch = MSearch(self.ssdpalt, test=False)	# use correct source port
		self.devices = []
		self.orphans = {}
		self.listeners = {'added':[], 'deleted':[]}
		louie.connect(self.ssdp_detected, 'Coherence.UPnP.SSDP.new_device', louie.Any)
		louie.connect(self.ssdp_deleted, 'Coherence.UPnP.SSDP.removed_device', louie.Any)
		louie.connect(self.device_found, 'Coherence.UPnP.RootDevice.detection_completed', louie.Any)
		self.msearch.double_discover()
Ejemplo n.º 48
0
    def __init__(self, device, **kwargs):
        self.name = kwargs.get('name', 'Buzztard MediaRenderer')
        self.host = kwargs.get('host', '127.0.0.1')
        self.port = int(kwargs.get('port', 7654))
        self.player = None

        self.playing = False
        self.state = None
        self.duration = None
        self.view = []
        self.tags = {}
        self.server = device

        self.poll_LC = LoopingCall(self.poll_player)

        louie.connect(self.event, 'Buzztard.Response.event', louie.Any)
        louie.connect(self.get_volume, 'Buzztard.Response.volume', louie.Any)
        louie.connect(self.get_mute, 'Buzztard.Response.mute', louie.Any)
        louie.connect(self.get_repeat, 'Buzztard.Response.repeat', louie.Any)
        self.buzztard = BzConnection(backend=self,
                                     host=self.host,
                                     port=self.port)
Ejemplo n.º 49
0
 def __init__(self):
     self.ssdp = SSDPServer()  # listen for things destined to port 1900
     self.ssdpalt = SSDPServerAlt()
     self.msearch = MSearch(self.ssdpalt,
                            test=False)  # use correct source port
     self.devices = []
     self.orphans = {}
     self.listeners = {'added': [], 'deleted': []}
     louie.connect(self.ssdp_detected, 'Coherence.UPnP.SSDP.new_device',
                   louie.Any)
     louie.connect(self.ssdp_deleted, 'Coherence.UPnP.SSDP.removed_device',
                   louie.Any)
     louie.connect(self.device_found,
                   'Coherence.UPnP.RootDevice.detection_completed',
                   louie.Any)
     self.msearch.double_discover()
Ejemplo n.º 50
0
  def setup_part2(self):
    self.info('running on host: %s', self.hostname)
    if self.hostname.startswith('127.'):
      self.warning('detection of own ip failed, using %s as own address, functionality will be limited', self.hostname)

    unittest = self.config.get('unittest', 'no')
    unittest = False if unittest == 'no' else True

    """ SSDP Server Initialization
    """
    try:
      # TODO: add ip/interface bind
      self.ssdp_server = SSDPServer(test=unittest)
    except CannotListenError as err:
      self.error("Error starting the SSDP-server: %s", err)
      self.debug("Error starting the SSDP-server", exc_info=True)
      reactor.stop()
      return

    louie.connect(self.create_device, 'Coherence.UPnP.SSDP.new_device', louie.Any)
    louie.connect(self.remove_device, 'Coherence.UPnP.SSDP.removed_device', louie.Any)
    louie.connect(self.add_device, 'Coherence.UPnP.RootDevice.detection_completed', louie.Any)
    # louie.connect( self.receiver, 'Coherence.UPnP.Service.detection_completed', louie.Any)

    self.ssdp_server.subscribe("new_device", self.add_device)
    self.ssdp_server.subscribe("removed_device", self.remove_device)

    self.msearch = MSearch(self.ssdp_server, test=unittest)

    reactor.addSystemEventTrigger('before', 'shutdown', self.shutdown, force=True)

    """ Web Server Initialization
    """
    try:
      # TODO: add ip/interface bind
      self.web_server = WebServer(self.config.get('web-ui', None), self.web_server_port, self)
    except CannotListenError:
      self.warning('port %r already in use, aborting!', self.web_server_port)
      reactor.stop()
      return

    self.urlbase = 'http://%s:%d/' % (self.hostname, self.web_server_port)
    # self.renew_service_subscription_loop = task.LoopingCall(self.check_devices)
    # self.renew_service_subscription_loop.start(20.0, now=False)

    try:
      plugins = self.config['plugin']
      if isinstance(plugins, dict):
        plugins = [plugins]
    except:
      plugins = None

    if plugins is None:
      plugins = self.config.get('plugins', None)

    if plugins is None:
      self.info("No plugin defined!")
    else:
      if isinstance(plugins, dict):
        for plugin, arguments in list(plugins.items()):
          try:
            if not isinstance(arguments, dict):
              arguments = {}
            self.add_plugin(plugin, **arguments)
          except Exception as msg:
            self.warning("Can't enable plugin, %s: %s!", plugin, msg)
            self.info(traceback.format_exc())
      else:
        for plugin in plugins:
          try:
            if plugin['active'] == 'no':
              continue
          except (KeyError, TypeError):
            pass
          try:
            backend = plugin['backend']
            arguments = copy.copy(plugin)
            del arguments['backend']
            backend = self.add_plugin(backend, **arguments)
            if self.writeable_config():
              if 'uuid' not in plugin:
                plugin['uuid'] = str(backend.uuid)[5:]
                self.config.save()
          except Exception as msg:
            self.warning("Can't enable plugin, %s: %s!", plugin, msg)
            self.info(traceback.format_exc())

    self.external_address = ':'.join((self.hostname, str(self.web_server_port)))

    """ Control Point Initialization
    """
    if self.config.get('controlpoint', 'no') == 'yes' or self.config.get('json', 'no') == 'yes':
      self.ctrl = ControlPoint(self)

    """ Json Interface Initialization
    """
    if self.config.get('json', 'no') == 'yes':
      from coherence.json_service import JsonInterface
      self.json = JsonInterface(self.ctrl)

    """ Transcoder Initialization
    """
    if self.config.get('transcoding', 'no') == 'yes':
      from coherence.transcoder import TranscoderManager
      self.transcoder_manager = TranscoderManager(self)

    """ DBus Initialization
    """
    if self.config.get('use_dbus', 'no') == 'yes':
      try:
        from coherence import dbus_service
        if self.ctrl is None:
          self.ctrl = ControlPoint(self)
        self.ctrl.auto_client_append('InternetGatewayDevice')
        self.dbus = dbus_service.DBusPontoon(self.ctrl)
      except Exception as msg:
        self.warning("Unable to activate dbus sub-system: %r", msg)
        self.debug(traceback.format_exc())
Ejemplo n.º 51
0
class CoherencePlugin(rb.Plugin, log.Loggable):

    logCategory = 'rb_coherence_plugin'

    def __init__(self):
        rb.Plugin.__init__(self)
        self.coherence = None
        self.config = gconf.client_get_default()

        if self.config.get(gconf_keys['dmc_active']) is None:
            # key not yet found represented by "None"
            self._set_defaults()

    def _set_defaults(self):
        for a in ('r', 's'):
            self.config.set_bool(gconf_keys['dm%s_active' % a], True)
            self.config.set_int(gconf_keys['dm%s_version' % a], 2)

        self.config.set_string(gconf_keys['dmr_name'],
                               "Rhythmbox UPnP MediaRenderer on {host}")
        self.config.set_string(gconf_keys['dms_name'],
                               "Rhythmbox UPnP MediaServer on {host}")

        self.config.set_bool(gconf_keys['dmc_active'], True)

    def activate(self, shell):
        from twisted.internet import gtk2reactor
        try:
            gtk2reactor.install()
        except AssertionError, e:
            # sometimes it's already installed
            self.warning("gtk2reactor already installed %r" % e)

        self.coherence = self.get_coherence()
        if self.coherence is None:
            self.warning("Coherence is not installed or too old, aborting")
            return

        self.warning("Coherence UPnP plugin activated")

        self.shell = shell
        self.sources = {}

        # Set up our icon
        the_icon = None
        face_path = os.path.join(os.path.expanduser('~'), ".face")
        if os.path.exists(face_path):
            file = gio.File(path=face_path)
            url = file.get_uri()
            info = file.query_info("standard::fast-content-type")
            mimetype = info.get_attribute_as_string(
                "standard::fast-content-type")
            pixbuf = gtk.gdk.pixbuf_new_from_file(face_path)
            width = "%s" % pixbuf.get_width()
            height = "%s" % pixbuf.get_height()
            depth = '24'
            the_icon = {
                'url': url,
                'mimetype': mimetype,
                'width': width,
                'height': height,
                'depth': depth
            }

        if self.config.get_bool(gconf_keys['dms_active']):
            # create our own media server
            from coherence.upnp.devices.media_server import MediaServer
            from MediaStore import MediaStore

            kwargs = {
                'version': self.config.get_int(gconf_keys['dms_version']),
                'no_thread_needed': True,
                'db': self.shell.props.db,
                'plugin': self
            }

            if the_icon:
                kwargs['icon'] = the_icon

            dms_uuid = self.config.get_string(gconf_keys['dms_uuid'])
            if dms_uuid:
                kwargs['uuid'] = dms_uuid

            name = self.config.get_string(gconf_keys['dms_name'])
            if name:
                name = name.replace('{host}', self.coherence.hostname)
                kwargs['name'] = name

            self.server = MediaServer(self.coherence, MediaStore, **kwargs)

            if dms_uuid is None:
                self.config.set_string(gconf_keys['dms_uuid'],
                                       str(self.server.uuid))

            self.warning("Media Store available with UUID %s" %
                         str(self.server.uuid))

        if self.config.get_bool(gconf_keys['dmr_active']):
            # create our own media renderer
            # but only if we have a matching Coherence package installed
            if self.coherence_version < (0, 5, 2):
                print "activation failed. Coherence is older than version 0.5.2"
            else:
                from coherence.upnp.devices.media_renderer import MediaRenderer
                from MediaPlayer import RhythmboxPlayer
                kwargs = {
                    "version": self.config.get_int(gconf_keys['dmr_version']),
                    "no_thread_needed": True,
                    "shell": self.shell,
                    'dmr_uuid': gconf_keys['dmr_uuid']
                }

                if the_icon:
                    kwargs['icon'] = the_icon

                dmr_uuid = self.config.get_string(gconf_keys['dmr_uuid'])
                if dmr_uuid:
                    kwargs['uuid'] = dmr_uuid

                name = self.config.get_string(gconf_keys['dmr_name'])
                if name:
                    name = name.replace('{host}', self.coherence.hostname)
                    kwargs['name'] = name

                self.renderer = MediaRenderer(self.coherence, RhythmboxPlayer,
                                              **kwargs)

                if dmr_uuid is None:
                    self.config.set_string(gconf_keys['dmr_uuid'],
                                           str(self.renderer.uuid))

                self.warning("Media Renderer available with UUID %s" %
                             str(self.renderer.uuid))

        if self.config.get_bool(gconf_keys['dmc_active']):
            self.warning("start looking for media servers")
            # watch for media servers
            louie.connect(self.detected_media_server,
                          'Coherence.UPnP.ControlPoint.MediaServer.detected',
                          louie.Any)
            louie.connect(self.removed_media_server,
                          'Coherence.UPnP.ControlPoint.MediaServer.removed',
                          louie.Any)
Ejemplo n.º 52
0
    def __init__(self,config):
        self.config = config
        fullscreen = False
        try:
            if means_true(self.config['fullscreen']):
                fullscreen = True
        except:
            pass
        grafics = self.config.get('grafics')
        if grafics == 'pyglet':
            from cadre.scribbling.pyglet_backend import Canvas
        else:
            from cadre.scribbling.clutter_backend import Canvas
        self.canvas = Canvas(fullscreen)

        try:
            overlays = self.config['overlay']
            if not isinstance(overlays,list):
                overlays = [overlays]
        except:
            overlays = []

        map(self.canvas.add_overlay,overlays)

        coherence_config = {}
        #coherence_config['version'] = '1'
        coherence_config['logmode'] = 'warning'
        #coherence_config['controlpoint'] = 'yes'

        louie.connect(self.media_server_found, 'Coherence.UPnP.ControlPoint.MediaServer.detected', louie.Any)
        louie.connect(self.media_server_removed, 'Coherence.UPnP.ControlPoint.MediaServer.removed', louie.Any)
        self.coherence = Coherence(coherence_config)


        name = self.config.get('name','Cadre - Coherence Picture-Frame')
        kwargs = {'version':1,
                'no_thread_needed':True,
                'name':name}

        kwargs['transition'] = 'NONE'
        try:
            if self.config['transition'].upper() in self.get_available_transitions():
                kwargs['transition'] = self.config['transition'].upper()
                self.set_transition(self.config['transition'].upper())
        except:
            pass

        try:
            kwargs['display_time'] = int(self.config['display_time'])
        except:
            pass

        self.canvas.set_title(name)

        kwargs['controller'] = self
        uuid = self.config.get('uuid')
        if uuid:
            kwargs['uuid'] = uuid
        print kwargs
        self.renderer = MediaRenderer(self.coherence,CadreRenderer,**kwargs)

        if 'uuid' not in self.config:
            self.config['uuid'] = str(self.renderer.uuid)[5:]
            try:
                self.config.save()
            except AttributeError:
                pass
        reactor.callLater(0.5,self.start,name)