# HG changeset patch # User Goffi # Date 1383687655 -3600 # Node ID 2a7185b8452c1850c6f5ce815b94250c7d701b4f # Parent 6a64e0a759e614b805fd8d3a360c91d6ae20c942 core: added SatIdentityHandler for Disco Identity, and set identity to "client/pc/Salut à Toi" diff -r 6a64e0a759e6 -r 2a7185b8452c src/core/sat_main.py --- a/src/core/sat_main.py Tue Nov 05 22:40:46 2013 +0100 +++ b/src/core/sat_main.py Tue Nov 05 22:40:55 2013 +0100 @@ -247,6 +247,9 @@ 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(): diff -r 6a64e0a759e6 -r 2a7185b8452c src/core/xmpp.py --- a/src/core/xmpp.py Tue Nov 05 22:40:46 2013 +0100 +++ b/src/core/xmpp.py Tue Nov 05 22:40:55 2013 +0100 @@ -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 @@ # 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 []