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.i18n import _
|
||||||
from sat.core.constants import Const as C
|
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 sat.core import exceptions
|
||||||
from logging import debug, info, warning, error
|
from logging import debug, info, warning, error
|
||||||
|
|
||||||
|
|
@ -58,11 +58,17 @@ class XEP_0092(object):
|
||||||
- os: operating system of the queried entity
|
- os: operating system of the queried entity
|
||||||
"""
|
"""
|
||||||
client = self.host.getClient(profile_key)
|
client = self.host.getClient(profile_key)
|
||||||
iq_elt = compat.IQ(client.xmlstream, 'get')
|
def getVersion(available):
|
||||||
iq_elt['to'] = jid_.full()
|
if not available:
|
||||||
query_elt = iq_elt.addElement("query", NS_VERSION)
|
raise exceptions.FeatureNotFound
|
||||||
d = iq_elt.send()
|
iq_elt = compat.IQ(client.xmlstream, 'get')
|
||||||
d.addCallback(self._gotVersion)
|
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
|
return d
|
||||||
|
|
||||||
def _gotVersion(self, iq_elt):
|
def _gotVersion(self, iq_elt):
|
||||||
|
|
@ -92,7 +98,8 @@ class XEP_0092(object):
|
||||||
if os:
|
if os:
|
||||||
whois_msg.append(_("Operating system: %s") % os)
|
whois_msg.append(_("Operating system: %s") % os)
|
||||||
def versionEb(failure):
|
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 = self.getVersion(target_jid, profile)
|
||||||
d.addCallbacks(versionCb, versionEb)
|
d.addCallbacks(versionCb, versionEb)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue