Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0095.py @ 941:c6d8fc63b1db
core, plugins: host.getClient now raise an exception instead of returning None when no profile is found, plugins have been adapted consequently and a bit cleaned
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 28 Mar 2014 18:07:02 +0100 |
parents | 1a759096ccbd |
children | 301b342c697a |
comparison
equal
deleted
inserted
replaced
940:92e41e7c7e00 | 941:c6d8fc63b1db |
---|---|
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core.constants import Const as C | 21 from sat.core.constants import Const as C |
22 from logging import debug, info, error | 22 from logging import debug, info, error |
23 from twisted.words.xish import domish | 23 from twisted.words.xish import domish |
24 from twisted.internet import protocol | 24 from twisted.words.protocols.jabber import client |
25 from twisted.words.protocols.jabber import client, jid | |
26 from twisted.words.protocols.jabber import error as jab_error | |
27 import os.path | |
28 from twisted.internet import reactor | |
29 import uuid | 25 import uuid |
30 | 26 |
31 from zope.interface import implements | 27 from zope.interface import implements |
32 | 28 |
33 try: | 29 try: |
123 @param err_code: error err_code (see XEP-0095 #4.2) | 119 @param err_code: error err_code (see XEP-0095 #4.2) |
124 @param err_type: one of cancel, modify | 120 @param err_type: one of cancel, modify |
125 @param data: error specific data (dictionary) | 121 @param data: error specific data (dictionary) |
126 @param profile: %(doc_profile)s | 122 @param profile: %(doc_profile)s |
127 """ | 123 """ |
128 _client = self.host.getClient(profile) | 124 client_ = self.host.getClient(profile) |
129 assert(_client) | |
130 result = domish.Element((None, 'iq')) | 125 result = domish.Element((None, 'iq')) |
131 result['type'] = 'result' | 126 result['type'] = 'result' |
132 result['id'] = iq_id | 127 result['id'] = iq_id |
133 result['to'] = to_jid | 128 result['to'] = to_jid |
134 error_el = result.addElement('error') | 129 error_el = result.addElement('error') |
147 elif err_code == 500 and err_type == 'cancel': | 142 elif err_code == 500 and err_type == 'cancel': |
148 condition_el = error_el.addElement((NS_SI, 'undefined-condition')) | 143 condition_el = error_el.addElement((NS_SI, 'undefined-condition')) |
149 if 'custom' in data and data['custom'] == 'failed': | 144 if 'custom' in data and data['custom'] == 'failed': |
150 condition_el.addContent('Stream failed') | 145 condition_el.addContent('Stream failed') |
151 | 146 |
152 _client.xmlstream.send(result) | 147 client_.xmlstream.send(result) |
153 | 148 |
154 def acceptStream(self, iq_id, to_jid, feature_elt, misc_elts=[], profile=C.PROF_KEY_NONE): | 149 def acceptStream(self, iq_id, to_jid, feature_elt, misc_elts=[], profile=C.PROF_KEY_NONE): |
155 """Send the accept stream initiation answer | 150 """Send the accept stream initiation answer |
156 @param iq_id: IQ id | 151 @param iq_id: IQ id |
157 @param feature_elt: domish element 'feature' containing stream method to use | 152 @param feature_elt: domish element 'feature' containing stream method to use |