jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version

This commit is contained in:
Goffi 2014-04-02 12:31:15 +02:00
commit ec08d50aba
4 changed files with 61 additions and 7 deletions

View file

@ -20,6 +20,7 @@
from sat.core.i18n import _
from sat.core.constants import Const as C
from twisted.internet import reactor, defer
from twisted.words.protocols.jabber import jid
from wokkel import compat
from sat.core import exceptions
from logging import debug, info, warning, error
@ -45,16 +46,25 @@ class XEP_0092(object):
def __init__(self, host):
info(_("Plugin XEP_0092 initialization"))
self.host = host
host.bridge.addMethod("getSoftwareVersion", ".plugin", in_sign='ss', out_sign='(sss)', method=self._getVersion, async=True)
try:
self.host.plugins[C.TEXT_CMDS].addWhoIsCb(self._whois, 50)
except KeyError:
info(_("Text commands not available"))
def _getVersion(self, entity_jid_s, profile_key):
def prepareForBridge(data):
name, version, os = data
return (name or '', version or '', os or '')
d = self.getVersion(jid.JID(entity_jid_s), profile_key)
d.addCallback(prepareForBridge)
return d
def getVersion(self, jid_, profile_key=C.PROF_KEY_NONE):
""" Ask version of the client that jid_ is running
@param jid_: jid from who we want to know client's version
@param profile_key: %(doc_profile_key)s
@return: a defered which fire tuple with the following data (None if not available):
@return (tuple): a defered which fire a tuple with the following data (None if not available):
- name: Natural language name of the software
- version: specific version of the software
- os: operating system of the queried entity