예제 #1
0
    def __init__(self, device, **kwargs):
        self.warning("__init__ RhythmboxPlayer %r", kwargs)
        self.shell = kwargs['shell']
        self.server = device
        self.dmr_uuid = kwargs['dmr_uuid']

        self.player = None
        self.entry = None
        self.metadata = None
        try:
            self.name = kwargs['name']
        except KeyError:
            self.name = "Rhythmbox on %s" % self.server.coherence.hostname

        self.player = self.shell.get_player()
        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
        
        coherence_player_entry_type = CoherenceDBEntryType("CoherencePlayer")
        self.shell.props.db.register_entry_type(coherence_player_entry_type)

        self.playing = False
        self.state = None
        self.duration = None
        self.volume = 1.0
        self.muted_volume = None
        self.view = []
        self.tags = {}
예제 #2
0
    def __init__(self,
                 server,
                 name="ShortlistStore",
                 trackcount=50,
                 updateFrequency=300,
                 **kwargs):
        BackendStore.__init__(self, server, **kwargs)
        self.name = name
        self.next_id = 1000
        self.store = {}
        self.trackcount = trackcount
        self.updateFrequency = updateFrequency
        UPnPClass = classChooser('root')
        id = str(self.getnextID())
        self.root = ShortListItem(id,
                                  None,
                                  'media',
                                  'root',
                                  self.urlbase,
                                  UPnPClass,
                                  update=True,
                                  store=self)
        self.add_store_item(id, self.root)

        self.source_backend = MediaStore(server, **kwargs)

        self.wmc_mapping.update({'14': '0', '15': '0', '16': '0', '17': '0'})
        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
    def __init__(self, device, **kwargs):
        if (device.coherence.config.get('use_dbus', 'no') != 'yes'
                and device.coherence.config.get('glib', 'no') != 'yes'):
            raise Exception, 'this media renderer needs use_dbus enabled in the configuration'
        self.name = kwargs.get('name', 'GStreamer Audio Player')

        audio_sink_name = kwargs.get("audio_sink_name")
        audio_sink_options = kwargs.get("audio_sink_options")
        video_sink_name = kwargs.get("video_sink_name")
        video_sink_options = kwargs.get("video_sink_options")

        self.player = Player(audio_sink_name=audio_sink_name,
                             video_sink_name=video_sink_name,
                             audio_sink_options=audio_sink_options,
                             video_sink_options=video_sink_options)
        self.player.add_view(self.update)

        self.metadata = None
        self.duration = None

        self.view = []
        self.tags = {}
        self.server = device

        self.playcontainer = None

        self.dlna_caps = ['playcontainer-0-1']

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #4
0
 def service_notified(self, service):
     self.info('notified about %r' % service)
     if self.detection_completed == True:
         self.info('notified about %r  Completed' % service)
         return
     if self.content_directory != None:
         if not hasattr(self.content_directory.service, 'last_time_updated'):
             return
         if self.content_directory.service.last_time_updated == None:
             return
     if self.connection_manager != None:
         if not hasattr(self.connection_manager.service, 'last_time_updated'):
             return
         if self.connection_manager.service.last_time_updated == None:
             return
     if self.av_transport != None:
         if not hasattr(self.av_transport.service, 'last_time_updated'):
             return
         if self.av_transport.service.last_time_updated == None:
             return
     if self.scheduled_recording != None:
         if not hasattr(self.scheduled_recording.service, 'last_time_updated'):
             return
         if self.scheduled_recording.service.last_time_updated == None:
             return
     self.detection_completed = True
     louie.send('Coherence.UPnP.DeviceClient.detection_completed', None,
                            client = self, udn = self.device.udn)
     self.info('detection_completed for %r' % self)
예제 #5
0
파일: ssdp.py 프로젝트: Python3pkg/Cohen
    def discoveryRequest(self, headers, xxx_todo_changeme2):
        """Process a discovery request.  The response must be sent to
        the address specified by (host, port)."""
        (host, port) = xxx_todo_changeme2
        self.info('Discovery request from (%s,%d) for %s', host, port,
                  headers['st'])
        self.info('Discovery request for %s', headers['st'])

        louie.send('Coherence.UPnP.Log', None, 'SSDP', host,
                   'M-Search for %s' % headers['st'])

        # Do we know about this service?
        for i in list(self.known.values()):
            if i['MANIFESTATION'] == 'remote':
                continue
            if (headers['st'] == 'ssdp:all' and i['SILENT'] == True):
                continue
            if (i['ST'] == headers['st'] or headers['st'] == 'ssdp:all'):
                response = []
                response.append('HTTP/1.1 200 OK')

                for k, v in list(i.items()):
                    if k == 'USN':
                        usn = v
                    if k not in ('MANIFESTATION', 'SILENT', 'HOST'):
                        response.append('%s: %s' % (k, v))
                response.append('DATE: %s' % datetimeToString())

                response.extend(('', ''))
                delay = random.randint(0, int(headers['mx']))

                reactor.callLater(delay, self.send_it, '\r\n'.join(response),
                                  (host, port), delay, usn)
예제 #6
0
 def got_auth_error(self, e, renegotiate=False):
     self.warning('error calling ampache %r', e)
     if not renegotiate:
         louie.send('Coherence.UPnP.Backend.init_failed',
                    None,
                    backend=self,
                    msg=e)
예제 #7
0
 def init_completed(self, *args, **kwargs):
     """ inform Coherence that this backend is ready for
         announcement
         this method just accepts any form of arguments
         as we don't under which circumstances it is called
     """
     louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #8
0
    def register(self, manifestation, usn, st, location,
                        server=SERVER_ID,
                        cache_control='max-age=1800',
                        silent=False,
                        host=None):
        """Register a service or device that this SSDP server will
        respond to."""

        self.info('Registering %s (%s)' % (st, location))

        self.known[usn] = {}
        self.known[usn]['USN'] = usn
        self.known[usn]['LOCATION'] = location
        self.known[usn]['ST'] = st
        self.known[usn]['EXT'] = ''
        self.known[usn]['SERVER'] = server
        self.known[usn]['CACHE-CONTROL'] = cache_control

        self.known[usn]['MANIFESTATION'] = manifestation
        self.known[usn]['SILENT'] = silent
        self.known[usn]['HOST'] = host
        self.known[usn]['last-seen'] = time.time()

        self.msg(self.known[usn])

        if manifestation == 'local':
            self.doNotify(usn)

        if st == 'upnp:rootdevice':
            louie.send('Coherence.UPnP.SSDP.new_device', None, device_type=st, infos=self.known[usn])
예제 #9
0
파일: ssdp.py 프로젝트: Python3pkg/Cohen
    def notifyReceived(self, headers, xxx_todo_changeme1):
        """Process a presence announcement.  We just remember the
        details of the SSDP service announced."""
        (host, port) = xxx_todo_changeme1
        self.info('Notification from (%s,%d) for %s', host, port,
                  headers['nt'])
        self.debug('Notification headers: %s', headers)

        if headers['nts'] == 'ssdp:alive':
            try:
                self.known[headers['usn']]['last-seen'] = time.time()
                self.debug('updating last-seen for %r', headers['usn'])
            except KeyError:
                self.register('remote',
                              headers['usn'],
                              headers['nt'],
                              headers['location'],
                              headers['server'],
                              headers['cache-control'],
                              host=host)
        elif headers['nts'] == 'ssdp:byebye':
            if self.isKnown(headers['usn']):
                self.unRegister(headers['usn'])
        else:
            self.warning('Unknown subtype %s for notification type %s',
                         headers['nts'], headers['nt'])
        louie.send('Coherence.UPnP.Log', None, 'SSDP', host,
                   'Notify %s for %s' % (headers['nts'], headers['usn']))
예제 #10
0
    def __init__(self, device, **kwargs):
        self.warning("__init__ RhythmboxPlayer %r", kwargs)
        self.shell = kwargs['shell']
        self.server = device
        self.dmr_uuid = kwargs['dmr_uuid']

        self.player = None
        self.entry = None
        self.metadata = None
        try:
            self.name = kwargs['name']
        except KeyError:
            self.name = "Rhythmbox on %s" % self.server.coherence.hostname

        self.player = self.shell.get_player()
        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)

        coherence_player_entry_type = CoherenceDBEntryType("CoherencePlayer")
        self.shell.props.db.register_entry_type(coherence_player_entry_type)

        self.playing = False
        self.state = None
        self.duration = None
        self.volume = 1.0
        self.muted_volume = None
        self.view = []
        self.tags = {}
예제 #11
0
 def embedded_device_notified(self, device):
     self.info("EmbeddedDevice %r sent notification" % device);
     if self.detection_completed == True:
         return
     self.detection_completed = True
     louie.send('Coherence.UPnP.DeviceClient.detection_completed', None,
                            client=self,udn=self.device.udn)
예제 #12
0
파일: event.py 프로젝트: Python3pkg/Cohen
    def render_NOTIFY(self, request):
        self.info("EventServer received notify from %s, code: %d",
                  request.client, request.code)
        data = request.content.getvalue()
        request.setResponseCode(200)

        command = {'method': request.method, 'path': request.path}
        headers = request.received_headers
        louie.send('UPnP.Event.Server.message_received', None, command,
                   headers, data)

        if request.code != 200:
            self.info("data: %s", data)
        else:
            self.debug("data: %s", data)
            headers = request.getAllHeaders()
            sid = headers['sid']
            try:
                tree = etree.fromstring(data)
            except (SyntaxError, AttributeError):
                self.warning("malformed event notification from %r",
                             request.client)
                self.debug("data: %r", data)
                request.setResponseCode(400)
                return ""

            event = Event(sid, tree, raw=data)
            if len(event) != 0:
                self.control_point.propagate(event)
        return ""
예제 #13
0
    def __init__(self, server, **kwargs):
        self.info("MediaStore __init__")
        self.server = server
        self.update_id = 0

        self.medialocation = kwargs.get('medialocation','tests/content/audio')
        self.coverlocation = kwargs.get('coverlocation',None)
        if self.coverlocation is not None and self.coverlocation[-1] != '/':
            self.coverlocation = self.coverlocation + '/'
        self.mediadb = kwargs.get('mediadb',MEDIA_DB)

        self.name = kwargs.get('name','MediaStore')

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

        self.containers = {}
        self.containers[ROOT_CONTAINER_ID] = \
                Container( ROOT_CONTAINER_ID,-1, self.name)

        self.wmc_mapping.update({'4': lambda : self.get_by_id(AUDIO_ALL_CONTAINER_ID),    # all tracks
                                 '7': lambda : self.get_by_id(AUDIO_ALBUM_CONTAINER_ID),    # all albums
                                 '6': lambda : self.get_by_id(AUDIO_ARTIST_CONTAINER_ID),    # all artists
                                })


        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #14
0
    def __init__(self, server, **kwargs):
        self.next_id = 1000
        self.name = kwargs.get('name','Flickr')
        self.proxy = kwargs.get('proxy','false')
        self.refresh = int(kwargs.get('refresh',60))*60
        if self.proxy in [1,'Yes','yes','True','true']:
            self.proxy = True
        else:
            self.proxy = False

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

        ignore_patterns = kwargs.get('ignore_patterns',[])
        ignore_file_pattern = re.compile('|'.join(['^\..*'] + list(ignore_patterns)))

        self.server = server
        self.update_id = 0
        self.flickr = Proxy('http://api.flickr.com/services/xmlrpc/')
        self.flickr_api_key = '837718c8a622c699edab0ea55fcec224'
        self.store = {}

        self.refresh_store_loop = task.LoopingCall(self.refresh_store)
        self.refresh_store_loop.start(self.refresh, now=False)

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #15
0
파일: light.py 프로젝트: 0-wiz-0/Coherence
    def __init__(self, server, **kwargs):
        self.name = kwargs.get('name','BetterLight')
        self.server = server
        self.state = 0 # we start switched off
        self.loadlevel = 50 # we start with 50% brightness

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #16
0
    def __init__(self, device, **kwargs):
        if(device.coherence.config.get('use_dbus','no') != 'yes' and
           device.coherence.config.get('glib','no') != 'yes'):
            raise Exception('this media renderer needs use_dbus enabled in the configuration')
        self.name = kwargs.get('name','GStreamer Audio Player')

        audio_sink_name = kwargs.get("audio_sink_name")
        audio_sink_options = kwargs.get("audio_sink_options")
        video_sink_name = kwargs.get("video_sink_name")
        video_sink_options = kwargs.get("video_sink_options")

        self.player = Player(audio_sink_name=audio_sink_name,
                             video_sink_name=video_sink_name,
                             audio_sink_options=audio_sink_options,
                             video_sink_options=video_sink_options)
        self.player.add_view(self.update)

        self.metadata = None
        self.duration = None

        self.view = []
        self.tags = {}
        self.server = device

        self.playcontainer = None

        self.dlna_caps = ['playcontainer-0-1']

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
 def embedded_device_notified(self, device):
     self.info("EmbeddedDevice %r sent notification" % device);
     if self.detection_completed == True:
         return
     self.detection_completed = True
     louie.send('Coherence.UPnP.DeviceClient.detection_completed', None,
                            client=self,udn=self.device.udn)
예제 #18
0
    def __init__(self, server, **kwargs):
        BackendStore.__init__(self, server, **kwargs)
        self.info("MediaStore __init__")
        self.update_id = 0

        self.medialocation = kwargs.get('medialocation', 'tests/content/audio')
        self.coverlocation = kwargs.get('coverlocation', None)
        if self.coverlocation is not None and self.coverlocation[-1] != '/':
            self.coverlocation = self.coverlocation + '/'
        self.mediadb = kwargs.get('mediadb', MEDIA_DB)

        self.name = kwargs.get('name', 'MediaStore')

        self.containers = {}
        self.containers[ROOT_CONTAINER_ID] = \
                Container(ROOT_CONTAINER_ID, -1, self.name)

        self.wmc_mapping.update({
            '4':
            lambda: self.get_by_id(AUDIO_ALL_CONTAINER_ID),  # all tracks
            '7':
            lambda: self.get_by_id(AUDIO_ALBUM_CONTAINER_ID),  # all albums
            '6':
            lambda: self.get_by_id(AUDIO_ARTIST_CONTAINER_ID),  # all artists
        })

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #19
0
    def __init__(self, device, **kwargs):
        logging.debug('MediaRendererProxyPlayer: starting initialization')
        if (device.coherence.config.get('use_dbus', 'no') != 'yes'
                and device.coherence.config.get('glib', 'no') != 'yes'):
            raise Exception, 'this media renderer needs use_dbus enabled in the configuration'
        logging.debug('\tInitialization passed the coherence checks')
        self.name = kwargs.get('name', 'CARPC Player')
        logging.debug('\tgot name {}'.format(self.name))
        self.controller = kwargs['controller']  #ahat
        logging.debug('\tgot controller {}'.format(self.controller))

        self.metadata = None
        self.duration = None

        self.view = []
        self.tags = {}
        logging.debug('\tabout to get the server device')
        self.server = device
        logging.debug('\tgot the server device')

        self.playcontainer = None

        self.dlna_caps = ['playcontainer-0-1']

        logging.debug('MediaRendererProxyPlayer: Finished initialization')
        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #20
0
    def device_detect(self, *args, **kwargs):
        """Called when device message rxed

        Note:  repeat messages are sent since UDP is used.
        """
        self.debug("Device_detect %r", kwargs)
        self.debug("Device_detect - root_detection_completed %r", self.root_detection_completed)
        if self.root_detection_completed == True:
            return
        # our self is not complete yet
        self.debug("Device_detect - sevice_detection_completed %r", self.detection_completed)
        if self.detection_completed == False:
            return
        # now check child devices.
        self.debug("Device_detect - self.devices = %r", self.devices)
        for d in self.devices:
            self.debug("Device_detect - check device %r %r", d.detection_completed, d)
            if d.detection_completed == False:
                return
        # now must be done, so notify root done
        self.root_detection_completed = True
        self.info(
            "Device_detect - rootdevice %r %r %r initialized, manifestation %r"
            % (self.friendly_name, self.st, self.host, self.manifestation)
        )
        louie.send("Coherence.UPnP.RootDevice.detection_completed", None, device=self)
예제 #21
0
    def __init__(self, server, **kwargs):
        self.name = kwargs.get('name', 'BetterLight')
        self.server = server
        self.state = 0  # we start switched off
        self.loadlevel = 50  # we start with 50% brightness

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #22
0
 def service_notified(self, service):
     self.info("Service %r sent notification", service)
     if self.detection_completed == True:
         return
     if self.rendering_control != None:
         if not hasattr(self.rendering_control.service,
                        'last_time_updated'):
             return
         if self.rendering_control.service.last_time_updated == None:
             return
     if self.connection_manager != None:
         if not hasattr(self.connection_manager.service,
                        'last_time_updated'):
             return
         if self.connection_manager.service.last_time_updated == None:
             return
     if self.av_transport != None:
         if not hasattr(self.av_transport.service, 'last_time_updated'):
             return
         if self.av_transport.service.last_time_updated == None:
             return
     self.detection_completed = True
     louie.send('Coherence.UPnP.DeviceClient.detection_completed',
                None,
                client=self,
                udn=self.device.udn)
예제 #23
0
파일: ssdp.py 프로젝트: ceton/coherence
    def unRegister(self, usn_loc):
        self.msg("Un-registering %s" % str(usn_loc))
        st = self.known[usn_loc]['ST']
        if st == 'upnp:rootdevice':
            louie.send('Coherence.UPnP.SSDP.removed_device', None, device_type=st, infos=self.known[usn_loc], interface=self.interface)

        del self.known[usn_loc]
예제 #24
0
    def device_detect(self, *args, **kwargs):
        self.debug("device_detect %r", kwargs)
        self.debug("root_detection_completed %r",
                   self.root_detection_completed)
        if self.root_detection_completed == True:
            return
        # our self is not complete yet

        self.debug("detection_completed %r", self.detection_completed)
        if self.detection_completed == False:
            return

        # now check child devices.
        self.debug("self.devices %r", self.devices)
        for d in self.devices:
            self.debug("check device %r %r", d.detection_completed, d)
            if d.detection_completed == False:
                return
        # now must be done, so notify root done
        self.root_detection_completed = True
        self.info("rootdevice %r %r %r initialized, manifestation %r" %
                  (self.friendly_name, self.st, self.host, self.manifestation))
        louie.send('Coherence.UPnP.RootDevice.detection_completed',
                   None,
                   device=self)
예제 #25
0
    def __init__(self, device, **kwargs):
        #print "PictureRenderer", kwargs
        self.server = device
        try:
            self.name = kwargs['name']
        except KeyError:
            self.name = "PictureFrame on %s" % self.server.coherence.hostname

        self.controller = kwargs['controller']

        try:
            self.display_time = kwargs['display_time']
        except KeyError:
            self.display_time = 20

        try:
            self.display_transition = kwargs['transition']
        except KeyError:
            self.display_transition = 'NONE'

        self.playcontainer = None

        self.auto_next_image = None
        self.display_loop = None

        self.dlna_caps = ['playcontainer-0-1']

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #26
0
파일: event.py 프로젝트: pezam/Cohen
    def render_NOTIFY(self, request):
        self.info("EventServer received notify from %s, code: %d", request.client, request.code)
        data = request.content.getvalue()
        request.setResponseCode(200)

        command = {'method': request.method, 'path': request.path}
        headers = request.received_headers
        louie.send('UPnP.Event.Server.message_received', None, command, headers, data)

        if request.code != 200:
            self.info("data: %s", data)
        else:
            self.debug("data: %s", data)
            headers = request.getAllHeaders()
            sid = headers['sid']
            try:
                tree = etree.fromstring(data)
            except (SyntaxError, AttributeError):
                self.warning("malformed event notification from %r", request.client)
                self.debug("data: %r", data)
                request.setResponseCode(400)
                return ""

            event = Event(sid, tree, raw=data)
            if len(event) != 0:
                self.control_point.propagate(event)
        return ""
예제 #27
0
 def service_notified(self, service):
     self.info('notified about %r', service)
     if self.detection_completed:
         return
     if self.content_directory is not None:
         if not hasattr(self.content_directory.service,
                        'last_time_updated'):
             return
         if self.content_directory.service.last_time_updated is None:
             return
     if self.connection_manager is not None:
         if not hasattr(self.connection_manager.service,
                        'last_time_updated'):
             return
         if self.connection_manager.service.last_time_updated is None:
             return
     if self.av_transport is not None:
         if not hasattr(self.av_transport.service, 'last_time_updated'):
             return
         if self.av_transport.service.last_time_updated is None:
             return
     if self.scheduled_recording is not None:
         if not hasattr(self.scheduled_recording.service,
                        'last_time_updated'):
             return
         if self.scheduled_recording.service.last_time_updated is None:
             return
     self.detection_completed = True
     louie.send('Coherence.UPnP.DeviceClient.detection_completed',
                None,
                client=self,
                udn=self.device.udn)
     self.info('detection_completed for %r', self)
예제 #28
0
    def render_NOTIFY(self, request):
        self.info("EventServer received notify from %s, code: %d" % (request.client, request.code))
        data = request.content.getvalue()
        self.debug("EventServer notify data (%i) %s", len(data), data)
        request.setResponseCode(200)

        command = {'method': request.method, 'path': request.path}
        headers = request.received_headers
        louie.send('UPnP.Event.Server.message_received', None, command, headers, data)

        if request.code != 200:
            self.info("data: %s", data)
        else:
            headers = request.getAllHeaders()
            sid = headers['sid']
            try:
                tree = utils.parse_xml(data).getroot()

                ns = "urn:schemas-upnp-org:event-1-0"
                event = Event(sid)
                for prop in tree.findall('{%s}property' % ns):
                    for var in prop.getchildren():
                        tag = var.tag
                        idx = tag.find('}') + 1
                        event.update({tag[idx:]: var.text})
                self.control_point.propagate(event)

            except (SyntaxError,AttributeError):
                self.warning("malformed event notification from %s", request.client)
                self.exception("data: %s", data)
                return ""
            except Exception:
                self.exception("data: %s", data)

        return ""
예제 #29
0
 def check_valid(self):
     """ check if the discovered devices are still ok, or
         if we haven't received a new discovery response
     """
     self.debug("Checking devices/services are still valid")
     removable = []
     for usn in self.known:
         if self.known[usn]['MANIFESTATION'] != 'local':
             _, expiry = self.known[usn]['CACHE-CONTROL'].split('=')
             expiry = int(expiry)
             now = time.time()
             last_seen = self.known[usn]['last-seen']
             self.debug(
                 "Checking if %r is still valid - last seen %d (+%d), now %d"
                 % (self.known[usn]['USN'], last_seen, expiry, now))
             if last_seen + expiry + 30 < now:
                 self.debug("Expiring: %r" % self.known[usn])
                 if self.known[usn]['ST'] == 'upnp:rootdevice':
                     louie.send('Coherence.UPnP.SSDP.removed_device',
                                None,
                                device_type=self.known[usn]['ST'],
                                infos=self.known[usn])
                 removable.append(usn)
     while len(removable) > 0:
         usn = removable.pop(0)
         del self.known[usn]
예제 #30
0
파일: ssdp.py 프로젝트: Python3pkg/Cohen
    def datagramReceived(self, data, xxx_todo_changeme):
        """Handle a received multicast datagram."""
        (host, port) = xxx_todo_changeme
        try:
            header, payload = data.split('\r\n\r\n')[:2]
        except ValueError as err:
            print(err)
            print('Arggg,', data)
            import pdb
            pdb.set_trace()

        lines = header.split('\r\n')
        cmd = string.split(lines[0], ' ')
        lines = [x.replace(': ', ':', 1) for x in lines[1:]]
        lines = [x for x in lines if len(x) > 0]

        headers = [string.split(x, ':', 1) for x in lines]
        headers = dict([(x[0].lower(), x[1]) for x in headers])

        self.msg('SSDP command %s %s - from %s:%d', cmd[0], cmd[1], host, port)
        self.debug('with headers: %s', headers)
        if cmd[0] == 'M-SEARCH' and cmd[1] == '*':
            # SSDP discovery
            self.discoveryRequest(headers, (host, port))
        elif cmd[0] == 'NOTIFY' and cmd[1] == '*':
            # SSDP presence
            self.notifyReceived(headers, (host, port))
        else:
            self.warning('Unknown SSDP command %s %s', cmd[0], cmd[1])

        # make raw data available
        # send out the signal after we had a chance to register the device
        louie.send('UPnP.SSDP.datagram_received', None, data, host, port)
예제 #31
0
    def __init__(self, device, **kwargs):
        if (
            device.coherence.config.get("use_dbus", "no") != "yes"
            and device.coherence.config.get("glib", "no") != "yes"
        ):
            raise Exception, "this media renderer needs use_dbus enabled in the configuration"
        self.name = kwargs.get("name", "GStreamer Audio Player")

        audio_sink_name = kwargs.get("audio_sink_name")
        audio_sink_options = kwargs.get("audio_sink_options")
        video_sink_name = kwargs.get("video_sink_name")
        video_sink_options = kwargs.get("video_sink_options")

        self.player = Player(
            audio_sink_name=audio_sink_name,
            video_sink_name=video_sink_name,
            audio_sink_options=audio_sink_options,
            video_sink_options=video_sink_options,
        )
        self.player.add_view(self.update)

        self.metadata = None
        self.duration = None

        self.view = []
        self.tags = {}
        self.server = device

        self.playcontainer = None

        self.dlna_caps = ["playcontainer-0-1"]

        louie.send("Coherence.UPnP.Backend.init_completed", None, backend=self)
예제 #32
0
    def __init__(self, server, **kwargs):

        if server.coherence.config.get('use_dbus', 'no') != 'yes':
            raise Exception('this backend needs use_dbus enabled in the configuration')
        BackendStore.__init__(self, server, **kwargs)

        self.config = kwargs
        self.name = kwargs.get('name', 'Tracker')

        self.update_id = 0
        self.token = None

        self.songs = 0
        self.albums = 0
        self.artists = 0
        self.playlists = 0
        self.genres = 0

        self.videos = 0
        self.images = 0

        self.bus = dbus.SessionBus()
        tracker_object = self.bus.get_object(BUS_NAME, OBJECT_PATH)
        self.tracker_interface = dbus.Interface(tracker_object, 'org.freedesktop.Tracker')
        self.search_interface = dbus.Interface(tracker_object, 'org.freedesktop.Tracker.Search')
        self.keywords_interface = dbus.Interface(tracker_object, 'org.freedesktop.Tracker.Keywords')
        self.metadata_interface = dbus.Interface(tracker_object, 'org.freedesktop.Tracker.Metadata')
        self.query_id = -1

        self.containers = {}
        self.tracks = {}
        self.containers[ROOT_CONTAINER_ID] = \
                    Container(ROOT_CONTAINER_ID, -1, self.name, store=self)

        def queries_finished(r):
            louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)

        def queries_failed(r):
            error = ''
            louie.send('Coherence.UPnP.Backend.init_failed', None, backend=self, msg=error)

        services = kwargs.get('service', 'Music,Videos,Images')
        services = map(lambda x: x.strip().lower(), services.split(','))

        l = []
        mapping = {'music': self.get_tracks,
                    'videos': self.get_videos,
                    'images': self.get_images}
        for service in services:
            try:
                l.append(mapping[service]())
            except KeyError:
                self.warning('Wrong Tracker service definition - %r', service)
        if len(l) > 0:
            dl = defer.DeferredList(l)
            dl.addCallback(queries_finished)
            dl.addErrback(lambda x: louie.send('Coherence.UPnP.Backend.init_failed', None, backend=self, msg='Connection to Tracker service(s) failed!'))
        else:
            louie.send('Coherence.UPnP.Backend.init_failed', None, backend=self, msg='No Tracker service defined!')
예제 #33
0
    def __init__(self, server, **kwargs):

        if server.coherence.config.get('use_dbus','no') != 'yes':
            raise Exception('this backend needs use_dbus enabled in the configuration')
        BackendStore.__init__(self,server,**kwargs)

        self.config = kwargs
        self.name = kwargs.get('name','Tracker')

        self.update_id = 0
        self.token = None

        self.songs = 0
        self.albums = 0
        self.artists = 0
        self.playlists = 0
        self.genres = 0

        self.videos = 0
        self.images = 0

        self.bus = dbus.SessionBus()
        tracker_object = self.bus.get_object(BUS_NAME,OBJECT_PATH)
        self.tracker_interface = dbus.Interface(tracker_object, 'org.freedesktop.Tracker')
        self.search_interface = dbus.Interface(tracker_object, 'org.freedesktop.Tracker.Search')
        self.keywords_interface = dbus.Interface(tracker_object, 'org.freedesktop.Tracker.Keywords')
        self.metadata_interface = dbus.Interface(tracker_object, 'org.freedesktop.Tracker.Metadata')
        self.query_id = -1

        self.containers = {}
        self.tracks = {}
        self.containers[ROOT_CONTAINER_ID] = \
                    Container(ROOT_CONTAINER_ID,-1,self.name,store=self)

        def queries_finished(r):
            louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)

        def queries_failed(r):
            error = ''
            louie.send('Coherence.UPnP.Backend.init_failed', None, backend=self, msg=error)

        services = kwargs.get('service','Music,Videos,Images')
        services = map(lambda x: x.strip().lower(),services.split(','))

        l = []
        mapping =  {'music':self.get_tracks,
                    'videos':self.get_videos,
                    'images':self.get_images}
        for service in services:
            try:
                l.append(mapping[service]())
            except KeyError:
                self.warning('Wrong Tracker service definition - %r' % service)
        if len(l)>0:
            dl = defer.DeferredList(l)
            dl.addCallback(queries_finished)
            dl.addErrback(lambda x: louie.send('Coherence.UPnP.Backend.init_failed', None, backend=self, msg='Connection to Tracker service(s) failed!'))
        else:
            louie.send('Coherence.UPnP.Backend.init_failed', None, backend=self, msg='No Tracker service defined!')
예제 #34
0
    def unRegister(self, usn):
        self.msg("Un-registering %s" % usn)
        st = self.known[usn]['ST']
        if st == 'upnp:rootdevice':
            louie.send('Coherence.UPnP.SSDP.removed_device', None, device_type=st, infos=self.known[usn])
            #self.callback("removed_device", st, self.known[usn])

        del self.known[usn]
예제 #35
0
	def ssdp_deleted(self, device_type, infos, *args, **kwargs):
		device = self._get_device_with_usn(infos['USN'])
		if device:
			louie.send('Coherence.UPnP.Device.removed', None, usn=infos['USN'])
			self.devices.remove(device)
			device.remove()
			if infos['ST'] == 'upnp:rootdevice':
				louie.send('Coherence.UPnP.RootDevice.removed', None, usn=infos['USN'])
예제 #36
0
 def __init__(self, server, **kwargs):
     self.name = kwargs.get('name', 'SimpleLight')
     self.server = server
     self.state = 0 # we start switched off
     self.family = kwargs.get('family', 'missing family')
     louie.send('Coherence.UPnP.Backend.init_completed', None, backend = self)
     #Dispatcher().save_emit('Coherence.UPnP.Backend.init_completed', None, backend = self)
     pass
예제 #37
0
 def init_completed(self, *args, **kwargs):
     """ inform Coherence that this backend is ready for
         announcement
         this method just accepts any form of arguments
         as we don't under which circumstances it is called
     """
     louie.send('Coherence.UPnP.Backend.init_completed',
             None, backend=self)
예제 #38
0
 def remove_client(self, udn, client):
     louie.send('Coherence.UPnP.ControlPoint.%s.removed' %
                client.device_type,
                None,
                udn=udn)
     self.info("removed %s %s" %
               (client.device_type, client.device.get_friendly_name()))
     client.remove()
예제 #39
0
 def clientReady(self, instance):
     self.info("clientReady")
     louie.send('Coherence.UPnP.Backend.init_completed',
                None,
                backend=self.backend)
     self.clientInstance = instance
     for msg in self.messageQueue:
         self.sendMessage(msg)
예제 #40
0
 def completed(self, client, udn):
     self.info('sending signal Coherence.UPnP.ControlPoint.%s.detected %r' %
               (client.device_type, udn))
     louie.send('Coherence.UPnP.ControlPoint.%s.detected' %
                client.device_type,
                None,
                client=client,
                udn=udn)
예제 #41
0
 def remove_device(self, device_type, infos):
     _log.info("removed device %s %s", infos['ST'], infos['USN'] )
     device = self.get_device_with_usn(infos['USN'])
     if device:
         del self._devices[device.get_id()]
         if infos['ST'] == 'upnp:rootdevice':
             louie.send('Coherence.UPnP.Device.removed', None, udn=device.get_id() )
         device.remove()
예제 #42
0
    def __init__(self, server, **kwargs):
        BackendStore.__init__(self,server,**kwargs)
        self.warning("__init__ MediaStore %r", kwargs)
        self.db = kwargs['db']
        self.plugin = kwargs['plugin']

        self.wmc_mapping.update({'4': lambda : self.get_by_id(AUDIO_ALL_CONTAINER_ID),    # all tracks
                                 '7': lambda : self.get_by_id(AUDIO_ALBUM_CONTAINER_ID),    # all albums
                                 '6': lambda : self.get_by_id(AUDIO_ARTIST_CONTAINER_ID),    # all artists
                                })

        self.next_id = CONTAINER_COUNT
        self.albums = None
        self.artists = None
        self.tracks = None

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

        try:
            self.name = kwargs['name']
        except KeyError:
            self.name = "Rhythmbox on %s" % self.server.coherence.hostname

        query = self.db.query_new()
        self.info(query)
        self.db.query_append(query, [rhythmdb.QUERY_PROP_EQUALS, rhythmdb.PROP_TYPE, self.db.entry_type_get_by_name('song')])
        qm = self.db.query_model_new(query)
        self.db.do_full_query_async_parsed(qm, query)

        self.album_query = self.db.property_model_new(rhythmdb.PROP_ALBUM)
        self.album_query.props.query_model = qm

        self.artist_query = self.db.property_model_new(rhythmdb.PROP_ARTIST)
        self.artist_query.props.query_model = qm

        self.containers = {}
        self.containers[ROOT_CONTAINER_ID] = \
                Container( ROOT_CONTAINER_ID,-1, "Rhythmbox on %s" % self.server.coherence.hostname)

        self.containers[AUDIO_ALL_CONTAINER_ID] = \
                Container( AUDIO_ALL_CONTAINER_ID,ROOT_CONTAINER_ID, 'All tracks',
                          children_callback=self.children_tracks,
                          store=self,play_container=True)
        self.containers[ROOT_CONTAINER_ID].add_child(self.containers[AUDIO_ALL_CONTAINER_ID])

        self.containers[AUDIO_ALBUM_CONTAINER_ID] = \
                Container( AUDIO_ALBUM_CONTAINER_ID,ROOT_CONTAINER_ID, 'Albums',
                          children_callback=self.children_albums)
        self.containers[ROOT_CONTAINER_ID].add_child(self.containers[AUDIO_ALBUM_CONTAINER_ID])

        self.containers[AUDIO_ARTIST_CONTAINER_ID] = \
                Container( AUDIO_ARTIST_CONTAINER_ID,ROOT_CONTAINER_ID, 'Artists',
                          children_callback=self.children_artists)
        self.containers[ROOT_CONTAINER_ID].add_child(self.containers[AUDIO_ARTIST_CONTAINER_ID])

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
    def embedded_device_notified(self, device):
        self.info("EmbeddedDevice %r sent notification" % device);
        if self.embedded_device_detection_completed == True:
            return

        self.embedded_device_detection_completed = True
        if self.embedded_device_detection_completed == True and self.service_detection_completed == True:
            louie.send('Coherence.UPnP.EmbeddedDeviceClient.detection_completed', None,
                               self)
예제 #44
0
    def __init__(self, server, **kwargs):
        BackendStore.__init__(self,server)
        self.next_id = 1000
        self.name = kwargs.get('name','my media')
        self.content = kwargs.get('content',None)
        if self.content != None:
                if isinstance(self.content,basestring):
                    self.content = [self.content]
                l = []
                for a in self.content:
                    l += a.split(',')
                self.content = l
        else:
            self.content = xdg_content()
        if self.content == None:
            self.content = 'tests/content'
        if not isinstance( self.content, list):
            self.content = [self.content]
        self.urlbase = kwargs.get('urlbase','')
        ignore_patterns = kwargs.get('ignore_patterns',[])

        if self.urlbase[len(self.urlbase)-1] != '/':
            self.urlbase += '/'
        self.server = server
        self.store = {}

        try:
            self.inotify = INotify()
        except:
            self.inotify = None

        if kwargs.get('enable_destroy','no') == 'yes':
            self.upnp_DestroyObject = self.hidden_upnp_DestroyObject

        self.ignore_file_pattern = re.compile('|'.join(['^\..*'] + list(ignore_patterns)))
        parent = None
        self.update_id = 0
        if len(self.content)>1:
            UPnPClass = classChooser('root')
            id = self.getnextID()
            parent = self.store[id] = FSItem( id, parent, 'media', 'root', self.urlbase, UPnPClass, update=True)

        for path in self.content:
            if isinstance(path,(list,tuple)):
                path = path[0]
            if self.ignore_file_pattern.match(path):
                continue
            self.walk(path, parent, self.ignore_file_pattern)

        self.wmc_mapping.update({'14': 0,
                                 '15': 0,
                                 '16': 0,
                                 '17': 0
                                })

        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #45
0
	def __init__(self, device, session, **kwargs):
		self.name = kwargs.get('name', '%s' %(HardwareInfo().get_device_name()) )
		self.metadata = None
		self.player = kwargs.get('player', UPnPPlayer(session, handlePlayback=True))
		self.player.onStateChange.append(self.update)
		self.tags = {}
		self.server = device
		self.playcontainer = None
		self.dlna_caps = ['playcontainer-0-1']
		louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #46
0
파일: base.py 프로젝트: Python3pkg/Cohen
 def remove_device(self, device_type, infos):
   self.info("removed device %s %s", infos['ST'], infos['USN'])
   device = self.get_device_with_usn(infos['USN'])
   if device:
     louie.send('Coherence.UPnP.Device.removed', None, usn=infos['USN'])
     self.devices.remove(device)
     device.remove()
     if infos['ST'] == 'upnp:rootdevice':
       louie.send('Coherence.UPnP.RootDevice.removed', None, usn=infos['USN'])
       self.callback("removed_device", infos['ST'], infos['USN'])
예제 #47
0
    def __init__(self, server, **kwargs):
        BackendStore.__init__(self,server,**kwargs)
        BansheeDB.__init__(self, kwargs.get("db_path"))
        self.update_id = 0
        self.name = kwargs.get('name', 'Banshee')

        self.containers = {}
        self.containers[ROOT_CONTAINER_ID] = Container(ROOT_CONTAINER_ID,
                                                       -1, self.name, store=self)
        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #48
0
	def __init__(self, device, session, **kwargs):
		self.name = kwargs.get('name', '%s' %(HardwareInfo().get_device_name()) )
		self.metadata = None
		self.player = kwargs.get('player', UPnPPlayer(session, handlePlayback=True))
		self.player.onStateChange.append(self.update)
		self.tags = {}
		self.server = device
		self.playcontainer = None
		self.dlna_caps = ['playcontainer-0-1']
		louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #49
0
    def embedded_device_notified(self, device):
        self.info("EmbeddedDevice %r sent notification" % device)
        if self.embedded_device_detection_completed == True:
            return

        self.embedded_device_detection_completed = True
        if self.embedded_device_detection_completed == True and self.service_detection_completed == True:
            louie.send(
                'Coherence.UPnP.EmbeddedDeviceClient.detection_completed',
                None, self)
예제 #50
0
 def notify(self):
     if self.name.startswith('A_ARG_TYPE_'):
         return
     self.info("Variable %s sends notify about new value >%r<" %(self.name, self.value))
     #if self.old_value == '':
     #    return
     louie.send(signal='Coherence.UPnP.StateVariable.%s.changed' % self.name, sender=self.service, variable=self)
     louie.send(signal='Coherence.UPnP.StateVariable.changed',sender=self.service, variable=self)
     for callback in self._callbacks:
         callback( self)
예제 #51
0
    def __init__(self, server, **kwargs):
        BackendStore.__init__(self, server, **kwargs)
        BansheeDB.__init__(self, kwargs.get("db_path"))
        self.update_id = 0
        self.name = kwargs.get('name', 'Banshee')

        self.containers = {}
        self.containers[ROOT_CONTAINER_ID] = Container(ROOT_CONTAINER_ID,
                                                       -1, self.name, store=self)
        louie.send('Coherence.UPnP.Backend.init_completed', None, backend=self)
예제 #52
0
    def fire(self, device):
        """send the query to the device.

        @param device: is the device to which the query goes.
        """
        if callable(self.callback):
            self.callback(device)
        elif isinstance(self.callback, basestring):
            louie.send(self.callback, None, device = device)
        self.fired = True
예제 #53
0
파일: service.py 프로젝트: Python3pkg/Cohen
        def gotPage(x):
            self.scpdXML, headers = x
            try:
                tree = etree.fromstring(self.scpdXML)
            except Exception as e:
                self.warning(
                    "Invalid service description received from %r: %r",
                    self.get_scpd_url(), e)
                return
            ns = UPNP_SERVICE_NS

            for action_node in tree.findall('.//{%s}action' % ns):
                name = action_node.findtext('{%s}name' % ns)
                arguments = []
                for argument in action_node.findall('.//{%s}argument' % ns):
                    arg_name = argument.findtext('{%s}name' % ns)
                    arg_direction = argument.findtext('{%s}direction' % ns)
                    arg_state_var = argument.findtext(
                        '{%s}relatedStateVariable' % ns)
                    arguments.append(
                        action.Argument(arg_name, arg_direction,
                                        arg_state_var))
                self._actions[name] = action.Action(self, name, 'n/a',
                                                    arguments)

            for var_node in tree.findall('.//{%s}stateVariable' % ns):
                send_events = var_node.attrib.get('sendEvents', 'yes')
                name = var_node.findtext('{%s}name' % ns)
                data_type = var_node.findtext('{%s}dataType' % ns)
                values = []
                """ we need to ignore this, as there we don't get there our
                    {urn:schemas-beebits-net:service-1-0}X_withVendorDefines
                    attibute there
                """
                for allowed in var_node.findall('.//{%s}allowedValue' % ns):
                    values.append(allowed.text)
                instance = 0
                self._variables.get(instance)[name] = variable.StateVariable(
                    self, name, 'n/a', instance, send_events, data_type,
                    values)
                """ we need to do this here, as there we don't get there our
                    {urn:schemas-beebits-net:service-1-0}X_withVendorDefines
                    attibute there
                """
                self._variables.get(instance)[name].has_vendor_values = True

            #print 'service parse:', self, self.device
            self.detection_completed = True
            louie.send('Coherence.UPnP.Service.detection_completed',
                       sender=self.device,
                       device=self.device)
            self.info(
                "send signal Coherence.UPnP.Service.detection_completed for %r",
                self)
            """
예제 #54
0
 def notify(self):
     if self.name.startswith('A_ARG_TYPE_'):
         return
     self.info("Variable %s sends notify about new value >%r<", self.name, self.value)
     #if self.old_value == '':
     #    return
     louie.send(signal='Coherence.UPnP.StateVariable.%s.changed' % self.name, sender=self.service, variable=self)
     louie.send(signal='Coherence.UPnP.StateVariable.changed', sender=self.service, variable=self)
     #print "CALLBACKS %s %r %r" % (self.name,self.instance,self._callbacks)
     for callback in self._callbacks:
         callback(self)
예제 #55
0
 def ssdp_deleted(self, device_type, infos, *args, **kwargs):
     device = self._get_device_by_usn(infos['USN'])
     if device:
         louie.send('Coherence.UPnP.Device.removed', None, usn=infos['USN'])
         self._send_event('deleted', args=(device, ))
         self.devices.remove(device)
         device.remove()
         if infos['ST'] == 'upnp:rootdevice':
             louie.send('Coherence.UPnP.RootDevice.removed',
                        None,
                        usn=infos['USN'])
예제 #56
0
    def unRegister(self, usn):
        self.msg("Un-registering %s" % usn)
        st = self.known[usn]['ST']
        if st == 'upnp:rootdevice':
            louie.send('Coherence.UPnP.SSDP.removed_device',
                       None,
                       device_type=st,
                       infos=self.known[usn])
            #self.callback("removed_device", st, self.known[usn])

        del self.known[usn]
예제 #57
0
 def __new__(cls, *args, **kwargs):
     self.debug("BzConnection __new__")
     obj = getattr(cls,'_instance_',None)
     if obj is not None:
         louie.send('Coherence.UPnP.Backend.init_completed', None, backend=kwargs['backend'])
         return obj
     else:
         obj = super(BzConnection, cls).__new__(cls, *args, **kwargs)
         cls._instance_ = obj
         obj.connection = BzFactory(kwargs['backend'])
         reactor.connectTCP( kwargs['host'], kwargs['port'], obj.connection)
         return obj
예제 #58
0
    def check_device( self, device):
        self.info("found device %s of type %s",device.get_friendly_name(), device.get_device_type())
        short_type = device.get_device_type().split(':')[3]
        if short_type == "ZonePlayer":
                self.info("identified ZonePlayer %s", device.get_friendly_name())
                client = SonosZonePlayerClient(device)
                device.set_client(client)
# event sent in self.completed
                louie.send('Coherence.UPnP.ControlPoint.ZonePlayer.detected', None,
                                   client=client,udn=device.get_id())

        ControlPoint.check_device( self, device )
 def service_notified(self, service):
     self.info("Service %r sent notification" % service);
     if self.detection_completed == True:
         return
     if self.switch_power != None:
         if not hasattr(self.switch_power.service, 'last_time_updated'):
             return
         if self.switch_power.service.last_time_updated == None:
             return
     self.detection_completed = True
     louie.send('Coherence.UPnP.DeviceClient.detection_completed', None,
                            client=self,udn=self.device.udn)
예제 #60
0
    def process_event(self,event):
        self.debug("process event %s" % self)
        for var_name, var_value  in event.items():
            if var_name == 'LastChange':
                self.debug("we have a LastChange event %s", var_value)
                self.get_state_variable(var_name, 0).update(var_value)
                tree = utils.parse_xml(var_value, 'utf-8').getroot()
                namespace_uri, tag = tree.tag[1:].split( "}", 1)
                for instance in tree.findall('{%s}InstanceID' % namespace_uri):
                    instance_id = instance.attrib['val']
                    self.debug("instance_id %r %r" % (instance,instance_id))
                    for var in instance.getchildren():
                        self.debug("var %r" % var)
                        namespace_uri, tag = var.tag[1:].split("}", 1)
                        if len(var.attrib) > 1:
                            self.debug("Extended StateVariable %s - %s", var.tag, var.attrib)

                        if var.attrib.has_key('channel') and var.attrib['channel'] != 'Master':
                            # TODO handle attributes that them selves have multiple instances
                            self.info("Skiiping update to %s its not for master channel %s", var.tag, var.attrib)
                            pass
                        else:
                            if self.get_state_variables(instance_id) is None:
                                # TODO Create instance ?
                                self.info("%r Create new service instance %r", self, instance_id)
                                self.create_new_instance(instance_id)

                            if not self.get_state_variables(instance_id).has_key(tag):
                                # SONOS stuff, it returns attributes that are not listed in the 
                                # state description. The soap reply propogates the changes as state updates.
                                nv = variable.StateVariable(self, tag,
                                                               'n/a',
                                                               instance_id, True,
                                                               "string", [])
                                self.get_state_variables(instance_id)[tag] = nv
                                self.info("%r Create new variable %r", self, tag)

                            val = None
                            if var.attrib.has_key('val'):
                                val = var.attrib['val']
                            self.get_state_variable(tag, instance_id).update(val)
                        self.info("updated var %r" % var)
            else:
                # what if not exist
                self.info("updated var %s - %s ", var_name, var_value)
                self.get_state_variable(var_name, 0).update(var_value)

        self.debug("process event complete %s" % self)
        if self.last_time_updated == None:
            self.last_time_updated = time.time()    # needs to be set before louie call.
            louie.send('Coherence.UPnP.DeviceClient.Service.notified', sender=self.device, service=self)
            self.info("send signal Coherence.UPnP.DeviceClient.Service.notified for %r" % self)
        self.last_time_updated = time.time()