stream_features.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """
  2. SleekXMPP: The Sleek XMPP Library
  3. Copyright (C) 2010 Nathanael C. Fritz
  4. This file is part of SleekXMPP.
  5. See the file LICENSE for copying permission.
  6. """
  7. from sleekxmpp.thirdparty import OrderedDict
  8. from sleekxmpp.xmlstream import StanzaBase
  9. class StreamFeatures(StanzaBase):
  10. """
  11. """
  12. name = 'features'
  13. namespace = 'http://etherx.jabber.org/streams'
  14. interfaces = set(('features', 'required', 'optional'))
  15. sub_interfaces = interfaces
  16. plugin_tag_map = {}
  17. plugin_attrib_map = {}
  18. def setup(self, xml):
  19. StanzaBase.setup(self, xml)
  20. self.values = self.values
  21. def get_features(self):
  22. """
  23. """
  24. features = OrderedDict()
  25. for (name, lang), plugin in self.plugins.items():
  26. features[name] = plugin
  27. return features
  28. def set_features(self, value):
  29. """
  30. """
  31. pass
  32. def del_features(self):
  33. """
  34. """
  35. pass
  36. def get_required(self):
  37. """
  38. """
  39. features = self['features']
  40. return [f for n, f in features.items() if f['required']]
  41. def get_optional(self):
  42. """
  43. """
  44. features = self['features']
  45. return [f for n, f in features.items() if not f['required']]