plugin XEP-0092: feature check before requesting version
This commit is contained in:
parent
95678d7967
commit
5d634df2f7
1 changed files with 14 additions and 7 deletions
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
from sat.core.i18n import _
|
||||
from sat.core.constants import Const as C
|
||||
from wokkel import disco, iwokkel, data_form, compat
|
||||
from wokkel import compat
|
||||
from sat.core import exceptions
|
||||
from logging import debug, info, warning, error
|
||||
|
||||
|
|
@ -58,11 +58,17 @@ class XEP_0092(object):
|
|||
- os: operating system of the queried entity
|
||||
"""
|
||||
client = self.host.getClient(profile_key)
|
||||
iq_elt = compat.IQ(client.xmlstream, 'get')
|
||||
iq_elt['to'] = jid_.full()
|
||||
query_elt = iq_elt.addElement("query", NS_VERSION)
|
||||
d = iq_elt.send()
|
||||
d.addCallback(self._gotVersion)
|
||||
def getVersion(available):
|
||||
if not available:
|
||||
raise exceptions.FeatureNotFound
|
||||
iq_elt = compat.IQ(client.xmlstream, 'get')
|
||||
iq_elt['to'] = jid_.full()
|
||||
iq_elt.addElement("query", NS_VERSION)
|
||||
d = iq_elt.send()
|
||||
d.addCallback(self._gotVersion)
|
||||
return d
|
||||
d = self.host.hasFeature(NS_VERSION, jid_, client.profile)
|
||||
d.addCallback(getVersion)
|
||||
return d
|
||||
|
||||
def _gotVersion(self, iq_elt):
|
||||
|
|
@ -92,7 +98,8 @@ class XEP_0092(object):
|
|||
if os:
|
||||
whois_msg.append(_("Operating system: %s") % os)
|
||||
def versionEb(failure):
|
||||
whois_msg.append(_("Can't find software informations"))
|
||||
failure.trap(exceptions.FeatureNotFound)
|
||||
whois_msg.append(_("Software informations not available"))
|
||||
|
||||
d = self.getVersion(target_jid, profile)
|
||||
d.addCallbacks(versionCb, versionEb)
|
||||
|
|
|
|||
Loading…
Reference in a new issue