# HG changeset patch # User Goffi # Date 1486227555 -3600 # Node ID f0bc29dc81570f6876a82d21cf7691d77485dd37 # Parent 6a66c8c5a5676ab3c6761b261fdabf5ab415023e added "send" trigger point as the last one before sending, can be used for e2e encryption diff -r 6a66c8c5a567 -r f0bc29dc8157 src/core/xmpp.py --- a/src/core/xmpp.py Sat Feb 04 17:59:13 2017 +0100 +++ b/src/core/xmpp.py Sat Feb 04 17:59:15 2017 +0100 @@ -25,6 +25,7 @@ from twisted.words.protocols.jabber import xmlstream from twisted.words.protocols.jabber import error from twisted.words.protocols.jabber import jid +from twisted.words.xish import domish from twisted.python import failure from wokkel import client as wokkel_client, disco, xmppim, generic, iwokkel from wokkel import delay @@ -93,6 +94,21 @@ iq_error_elt = error.StanzaError(condition).toResponse(iq_elt) self.xmlstream.send(iq_error_elt) + def send(self, obj): + # original send method accept string + # but we restrict to domish.Element to make trigger treatments easier + assert isinstance(obj, domish.Element) + # XXX: this trigger is the last one before sending stanza on wire + # is it is intended for things like end 2 end encryption. + # *DO NOT* cancel (i.e. return False) without very good reason + # (out of band transmission for instance). + # e2e should have a priority of 0 here, and out of band transmission + # a lower priority + if not self.host_app.trigger.point("send", self, obj): + return + return super(SatXMPPClient, self).send(obj) + + def _authd(self, xmlstream): if not self.host_app.trigger.point("XML Initialized", xmlstream, self.profile): return