2 Slixmpp: The Slick XMPP Library
3 Copyright (C) 2010 Nathanael C. Fritz
4 This file is part of Slixmpp.
6 See the file LICENSE for copying permission.
12 from slixmpp
import Iq
13 from slixmpp
.xmlstream
import register_stanza_plugin
14 from slixmpp
.xmlstream
.handler
import Callback
15 from slixmpp
.xmlstream
.matcher
import StanzaPath
16 from slixmpp
.plugins
import BasePlugin
17 from slixmpp
.plugins
.xep_0092
import Version
, stanza
20 log
= logging
.getLogger(__name__
)
23 class XEP_0092(BasePlugin
):
26 XEP-0092: Software Version
30 description
= 'XEP-0092: Software Version'
31 dependencies
= set(['xep_0030'])
34 'software_name': 'Slixmpp',
35 'version': slixmpp
.__version
__,
39 def plugin_init(self
):
41 Start the XEP-0092 plugin.
43 if 'name' in self
.config
:
44 self
.software_name
= self
.config
['name']
46 self
.xmpp
.register_handler(
47 Callback('Software Version',
48 StanzaPath('iq@type=get/software_version'),
49 self
._handle
_version
))
51 register_stanza_plugin(Iq
, Version
)
54 self
.xmpp
.remove_handler('Software Version')
55 self
.xmpp
['xep_0030'].del_feature(feature
='jabber:iq:version')
57 def session_bind(self
, jid
):
58 self
.xmpp
.plugin
['xep_0030'].add_feature('jabber:iq:version')
60 def _handle_version(self
, iq
):
62 Respond to a software version query.
65 iq -- The Iq stanza containing the software version query.
68 iq
['software_version']['name'] = self
.software_name
69 iq
['software_version']['version'] = self
.version
70 iq
['software_version']['os'] = self
.os
73 def get_version(self
, jid
, ifrom
=None, block
=True, timeout
=None, callback
=None):
75 Retrieve the software version of a remote agent.
78 jid -- The JID of the entity to query.
84 iq
['query'] = Version
.namespace
85 return iq
.send(block
=block
, timeout
=timeout
, callback
=callback
)