Beispiel #1
0
    def dump_description(self, dest):
        def sent(res):
            self.log.debug('description sent')
            pass

        self.log.debug('send description')
        #         print(dest['id'])
        if self.description:
            self.log.debug('cached description')
            iq = IQ(self.xmlstream, 'result')
            iq.addRawXml(self.description)
            iq['id'] = dest['id']
        else:
            self.log.debug('generate description')
            iq = IQ(self.xmlstream, 'result')
            query = domish.Element(('urn:schemas-upnp-org:cloud-1-0', 'query'))
            query['type'] = 'described'
            query['name'] = self.device.uuid
            d = tostring(self.device.dump(), encoding='unicode')
            query.addRawXml(d)
            #         print(query.toXml())
            for service in self.device.services:
                s = tostring(service.dump(), encoding='unicode')
                #             print(s)
                query.addRawXml(s)

    #         print(query.toXml())
            self.description = query.toXml()
            iq.addChild(query)
            iq['id'] = dest['id']
#             self.description = iq
#         print(iq.toXml())
        iq.addCallback(sent)
        iq.send(to=dest['from'])
Beispiel #2
0
 def respond_rpc(self, resp, to, queryID):
     #         print('send: %s' % resp)
     #         self.log.debug('respond rpc: %s' % resp[0][39:])
     res = IQ(self.xmlstream, 'result')
     res['id'] = queryID
     if resp:
         for item in resp:
             res.addRawXml(item[39:].decode('utf-8'))  # Skip the xml header
     res.send(to=to)
Beispiel #3
0
def repeat_previous_vcard(stream, iq, previous):
    result = IQ(stream, 'result')
    result['id'] = iq['id']
    to = iq.getAttribute('to')

    if to is not None:
        result["from"] = to

    result.addRawXml(previous.firstChildElement().toXml())
    stream.send(result)
def repeat_previous_vcard(stream, iq, previous):
    result = IQ(stream, 'result')
    result['id'] = iq['id']
    to = iq.getAttribute('to')

    if to is not None:
        result["from"] = to

    result.addRawXml(previous.firstChildElement().toXml())
    stream.send(result)
Beispiel #5
0
 def __call__(self, *args, **kwargs):
     d = defer.Deferred()
     self.ctx, = self.contexts
     self.get_out_object(self.ctx, args, kwargs)
     self.get_out_string(self.ctx)
     self.ctx.in_string = []
     action = IQ(self.url[0], 'set')
     for item in self.ctx.out_string:
         action.addRawXml(item)
     if action.callbacks:
         action.addCallback(self.on_response, d)
     else:
         print('wtf?')
     action.send(to=self.url[1])
     return d