From 109d61352feeaf5e7ac96c6fcd4212cf542a6428 Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 5 Nov 2013 22:40:55 +0100 Subject: [PATCH] =?UTF-8?q?core:=20added=20SatIdentityHandler=20for=20Disc?= =?UTF-8?q?o=20Identity,=20and=20set=20identity=20to=20"client/pc/Salut=20?= =?UTF-8?q?=C3=A0=20Toi"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/sat_main.py | 3 +++ src/core/xmpp.py | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/core/sat_main.py b/src/core/sat_main.py index 695af817..0999c0aa 100644 --- a/src/core/sat_main.py +++ b/src/core/sat_main.py @@ -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(): diff --git a/src/core/xmpp.py b/src/core/xmpp.py index 10b0ea3e..6b11527e 100644 --- a/src/core/xmpp.py +++ b/src/core/xmpp.py @@ -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 []