From 96b103b27599e5af247c1e3b95d62c80c1e32a63 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Wed, 3 Jun 2009 22:56:51 +0000 Subject: moved seesmic branch to trunk --- sleekxmpp/plugins/xep_0086.py | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sleekxmpp/plugins/xep_0086.py (limited to 'sleekxmpp/plugins/xep_0086.py') diff --git a/sleekxmpp/plugins/xep_0086.py b/sleekxmpp/plugins/xep_0086.py new file mode 100644 index 00000000..6871ef3f --- /dev/null +++ b/sleekxmpp/plugins/xep_0086.py @@ -0,0 +1,49 @@ + +from __future__ import with_statement +import base +import logging +from xml.etree import cElementTree as ET +import copy + +class xep_0086(base.base_plugin): + """ + XEP-0086 Error Condition Mappings + """ + + def plugin_init(self): + self.xep = '0086' + self.description = 'Error Condition Mappings' + self.error_map = { + 'bad-request':('modify','400'), + 'conflict':('cancel','409'), + 'feature-not-implemented':('cancel','501'), + 'forbidden':('auth','403'), + 'gone':('modify','302'), + 'internal-server-error':('wait','500'), + 'item-not-found':('cancel','404'), + 'jid-malformed':('modify','400'), + 'not-acceptable':('modify','406'), + 'not-allowed':('cancel','405'), + 'not-authorized':('auth','401'), + 'payment-required':('auth','402'), + 'recipient-unavailable':('wait','404'), + 'redirect':('modify','302'), + 'registration-required':('auth','407'), + 'remote-server-not-found':('cancel','404'), + 'remote-server-timeout':('wait','504'), + 'resource-constraint':('wait','500'), + 'service-unavailable':('cancel','503'), + 'subscription-required':('auth','407'), + 'undefined-condition':(None,'500'), + 'unexpected-request':('wait','400') + } + + + def makeError(self, condition, cdata=None, errorType=None, text=None, customElem=None): + conditionElem = self.xmpp.makeStanzaErrorCondition(condition, cdata) + if errorType is None: + error = self.xmpp.makeStanzaError(conditionElem, self.error_map[condition][0], self.error_map[condition][1], text, customElem) + else: + error = self.xmpp.makeStanzaError(conditionElem, errorType, self.error_map[condition][1], text, customElem) + error.append(conditionElem) + return error -- cgit v1.2.3