core: added SatIdentityHandler for Disco Identity, and set identity to "client/pc/Salut à Toi"

This commit is contained in:
Goffi 2013-11-05 22:40:55 +01:00
commit 109d61352f
2 changed files with 23 additions and 1 deletions

View file

@ -247,6 +247,9 @@ class SAT(service.Service):
self.get_const('client_version'))
current.versionHandler.setHandlerParent(current)
current.identityHandler = xmpp.SatIdentityHandler()
current.identityHandler.setHandlerParent(current)
debug(_("setting plugins parents"))
for plugin in self.plugins.iteritems():

View file

@ -19,13 +19,19 @@
from twisted.internet import task, defer
from twisted.words.protocols.jabber import jid, xmlstream
from wokkel import client, disco, xmppim, generic, compat, delay
from wokkel import client, disco, xmppim, generic, compat, delay, iwokkel
from logging import debug, info, warning, error
from sat.core import exceptions
from calendar import timegm
from zope.interface import implements
try:
from twisted.words.protocols.xmlstream import XMPPHandler
except ImportError:
from wokkel.subprotocols import XMPPHandler
class SatXMPPClient(client.XMPPClient):
implements(iwokkel.IDisco)
def __init__(self, host_app, profile, user_jid, password, host=None, port=5222):
client.XMPPClient.__init__(self, user_jid, password, host, port)
@ -451,3 +457,16 @@ class SatVersionHandler(generic.VersionHandler):
# disco features, and when the server (seen on ejabberd) generate its own hash for security check
# it reject our features (resulting in e.g. no notification on PEP)
return generic.VersionHandler.getDiscoInfo(self, requestor, target, None)
class SatIdentityHandler(XMPPHandler):
""" Manage disco Identity of SàT. Currently, we use "client/pc/Salut à Toi", but as
SàT is multi-frontends and can be used on mobile devices, as a bot, with a web frontend,
etc, we should implement a way to dynamically update identities through the bridge """
#TODO: dynamic identity update (see docstring). Note that a XMPP entity can have several identities
implements(iwokkel.IDisco)
def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
return [disco.DiscoIdentity(u"client", u"pc", u"Salut à Toi")]
def getDiscoItems(self, requestor, target, nodeIdentifier=''):
return []