Lines Matching refs:stanza
93 def FeedStanza(self, stanza):
95 print stanza.toprettyxml()
149 stanza = ParseXml(xml_text)
150 self._delegate.FeedStanza(stanza)
151 # Needed because stanza may have cycles.
152 stanza.unlink()
255 def FeedStanza(self, stanza):
256 """Inspects the given stanza and changes the handshake state if needed.
258 Called when a stanza is received from the client. Inspects the
259 stanza to make sure it has the expected attributes given the
263 def ExpectStanza(stanza, name):
264 if stanza.tagName != name:
265 raise UnexpectedXml(stanza)
267 def ExpectIq(stanza, type, name):
268 ExpectStanza(stanza, 'iq')
269 if (stanza.getAttribute('type') != type or
270 stanza.firstChild.tagName != name):
271 raise UnexpectedXml(stanza)
273 def GetStanzaId(stanza):
274 return stanza.getAttribute('id')
276 def HandleStream(stanza):
277 ExpectStanza(stanza, 'stream:stream')
278 domain = stanza.getAttribute('to')
288 def GetUserDomain(stanza):
289 encoded_username_password = stanza.firstChild.data
309 HandleStream(stanza)
314 ExpectStanza(stanza, 'auth')
315 (self._username, self._domain) = GetUserDomain(stanza)
320 HandleStream(stanza)
325 ExpectIq(stanza, 'set', 'bind')
326 stanza_id = GetStanzaId(stanza)
327 resource_element = stanza.getElementsByTagName('resource')[0]
339 ExpectIq(stanza, 'set', 'session')
340 stanza_id = GetStanzaId(stanza)
417 def FeedStanza(self, stanza):
419 self._handshake_task.FeedStanza(stanza)
420 elif stanza.tagName == 'iq' and stanza.getAttribute('type') == 'result':
423 elif (stanza.firstChild and
424 stanza.firstChild.namespaceURI == 'google:push'):
425 self._HandlePushCommand(stanza)
427 raise UnexpectedXml(stanza)
436 def _HandlePushCommand(self, stanza):
437 if stanza.tagName == 'iq' and stanza.firstChild.tagName == 'subscribe':
439 self._SendIqResponseStanza(stanza)
440 elif stanza.tagName == 'message' and stanza.firstChild.tagName == 'push':
442 self._delegate.ForwardNotification(self, stanza)
447 stanza = CloneXml(self._IQ_RESPONSE_STANZA)
448 stanza.setAttribute('from', str(self._jid.GetBareJid()))
449 stanza.setAttribute('id', iq.getAttribute('id'))
450 self.SendStanza(stanza)
452 def SendStanza(self, stanza, unlink=True):
453 """Sends a stanza to the client.
456 stanza: The stanza to send.
457 unlink: Whether to unlink stanza after sending it. (Pass in
458 False if stanza is a constant.)
460 self.SendData(stanza.toxml())
462 stanza.unlink()