Rename to slixmpp
[slixmpp.git] / slixmpp / plugins / xep_0258 / security_labels.py
blob07783b474b31952a727053ac3cea6e4f56a9a92d
1 """
2 Slixmpp: The Slick XMPP Library
3 Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of Slixmpp.
6 See the file LICENSE for copying permission.
7 """
9 import logging
11 from slixmpp import Iq, Message
12 from slixmpp.plugins import BasePlugin
13 from slixmpp.xmlstream import register_stanza_plugin
14 from slixmpp.plugins.xep_0258 import stanza, SecurityLabel, Catalog
17 log = logging.getLogger(__name__)
20 class XEP_0258(BasePlugin):
22 name = 'xep_0258'
23 description = 'XEP-0258: Security Labels in XMPP'
24 dependencies = set(['xep_0030'])
25 stanza = stanza
27 def plugin_init(self):
28 register_stanza_plugin(Message, SecurityLabel)
29 register_stanza_plugin(Iq, Catalog)
31 def plugin_end(self):
32 self.xmpp['xep_0030'].del_feature(feature=SecurityLabel.namespace)
34 def session_bind(self, jid):
35 self.xmpp['xep_0030'].add_feature(SecurityLabel.namespace)
37 def get_catalog(self, jid, ifrom=None, block=True,
38 callback=None, timeout=None):
39 iq = self.xmpp.Iq()
40 iq['to'] = jid
41 iq['from'] = ifrom
42 iq['type'] = 'get'
43 iq.enable('security_label_catalog')
44 return iq.send(block=block, callback=callback, timeout=timeout)