core (client): added a sendError method to easily build error response from <IQ\> stanza

This commit is contained in:
Goffi 2015-11-11 14:56:05 +01:00
commit f21c94b205

View file

@ -21,6 +21,7 @@ from sat.core.i18n import _
from sat.core.constants import Const as C
from twisted.internet import task, defer
from twisted.words.protocols.jabber import jid, xmlstream
from twisted.words.protocols.jabber import error
from wokkel import client, disco, xmppim, generic, delay, iwokkel
from sat.core.log import getLogger
log = getLogger(__name__)
@ -59,6 +60,15 @@ class SatXMPPClient(client.XMPPClient):
iq_elt.timeout = timeout
return iq_elt
def sendError(self, iq_elt, condition):
"""Send error stanza build from iq_elt
@param iq_elt(domish.Element): initial IQ element
@param condition(unicode): error condition
"""
iq_error_elt = error.StanzaError(condition).toResponse(iq_elt)
self.xmlstream.send(iq_error_elt)
def _authd(self, xmlstream):
if not self.host_app.trigger.point("XML Initialized", xmlstream, self.profile):
return