def on_description(self, iq): # print( # 'Received description from %s: %s' # % (iq['from'], iq.toXml().encode('utf-8'))) pause = IQ(self.xmlstream, 'set') pause['to'] = iq['from'] # enveloppe = domish.Element( # ('http://schemas.xmlsoap.org/soap/envelope/', 'Envelope')) enveloppe = domish.Element( ('http://schemas.xmlsoap.org/soap/envelope/', 'Envelope'), localPrefixes={'s': 'http://schemas.xmlsoap.org/soap/envelope/'}) enveloppe[ 's:encodingStyle'] = "http://schemas.xmlsoap.org/soap/encoding/" header = domish.Element((None, 's:Header')) # header = domish.Element(('http://schemas.xmlsoap.org/soap/envelope/', 'Header')) header['mustUnderstand'] = "1" uc = domish.Element(('urn:schemas-upnp-org:cloud-1-0', 'uc')) uc['serviceId'] = 'urn:av-openhome-org:serviceId:Playlist' header.addChild(uc) enveloppe.addChild(header) body = domish.Element((None, 's:Body')) # body = domish.Element(('http://schemas.xmlsoap.org/soap/envelope/', 'Body')) action = domish.Element( ('urn:av-openhome-org:service:Playlist:1', 'Read'), localPrefixes={'u': 'urn:av-openhome-org:service:Playlist:1'}) # action = domish.Element( # ('urn:av-openhome-org:service:Playlist:1', 'Pause')) body.addChild(action) enveloppe.addChild(body) pause.addChild(enveloppe) pause.addCallback(self.paused) print('send pause') print(pause.toXml()) pause.send()
def on_description(self, iq): # print( # 'Received description from %s: %s' # % (iq['from'], iq.toXml().encode('utf-8'))) pause = IQ(self.xmlstream, 'set') pause['to'] = iq['from'] # enveloppe = domish.Element( # ('http://schemas.xmlsoap.org/soap/envelope/', 'Envelope')) enveloppe = domish.Element( ('http://schemas.xmlsoap.org/soap/envelope/', 'Envelope'), localPrefixes={'s': 'http://schemas.xmlsoap.org/soap/envelope/'}) enveloppe['s:encodingStyle'] = "http://schemas.xmlsoap.org/soap/encoding/" header = domish.Element((None, 's:Header')) # header = domish.Element(('http://schemas.xmlsoap.org/soap/envelope/', 'Header')) header['mustUnderstand'] = "1" uc = domish.Element(('urn:schemas-upnp-org:cloud-1-0', 'uc')) uc['serviceId'] = 'urn:av-openhome-org:serviceId:Playlist' header.addChild(uc) enveloppe.addChild(header) body = domish.Element((None, 's:Body')) # body = domish.Element(('http://schemas.xmlsoap.org/soap/envelope/', 'Body')) action = domish.Element( ('urn:av-openhome-org:service:Playlist:1', 'Read'), localPrefixes={'u': 'urn:av-openhome-org:service:Playlist:1'}) # action = domish.Element( # ('urn:av-openhome-org:service:Playlist:1', 'Pause')) body.addChild(action) enveloppe.addChild(body) pause.addChild(enveloppe) pause.addCallback(self.paused) print('send pause') print(pause.toXml()) pause.send()
def check_users(self): for user, value in self.users.items(): if value['state'] is False: iq = IQ(self.xmlstream, 'set') query = domish.Element(('jabber:iq:roster', 'query')) item = domish.Element((None, 'item')) item['name'] = user item['jid'] = user item.addElement('group', content='hosts') query.addChild(item) iq.addChild(query) iq.addCallback(self.subscribe, user) print('send IQ: %s' % (iq.toXml().encode('utf-8'))) iq.send()