stanza.py 952 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. """
  2. SleekXMPP: The Sleek XMPP Library
  3. Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
  4. This file is part of SleekXMPP.
  5. See the file LICENSE for copying permission.
  6. """
  7. from sleekxmpp.xmlstream import ElementBase, ET
  8. class Attention(ElementBase):
  9. """
  10. """
  11. name = 'attention'
  12. namespace = 'urn:xmpp:attention:0'
  13. plugin_attrib = 'attention'
  14. interfaces = set(('attention',))
  15. is_extension = True
  16. def setup(self, xml):
  17. return True
  18. def set_attention(self, value):
  19. if value:
  20. xml = ET.Element(self.tag_name())
  21. self.parent().xml.append(xml)
  22. else:
  23. self.del_attention()
  24. def get_attention(self):
  25. xml = self.parent().xml.find(self.tag_name())
  26. return xml is not None
  27. def del_attention(self):
  28. xml = self.parent().xml.find(self.tag_name())
  29. if xml is not None:
  30. self.parent().xml.remove(xml)