Mercurial > libervia-backend
annotate src/plugins/plugin_xep_0260.py @ 1679:9ff4f60de005
plugin XEP-0277: use bare JIDs to verify publisher
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 25 Nov 2015 17:19:25 +0100 |
parents | 25906c0dbc63 |
children | d2e023da2983 |
rev | line source |
---|---|
1560 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # SAT plugin for Jingle (XEP-0260) | |
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org) | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 from sat.core.i18n import _ | |
21 from sat.core.log import getLogger | |
22 log = getLogger(__name__) | |
23 from sat.core import exceptions | |
24 from wokkel import disco, iwokkel | |
25 from zope.interface import implements | |
26 from twisted.words.xish import domish | |
27 from twisted.words.protocols.jabber import jid | |
28 from twisted.internet import defer | |
29 import uuid | |
30 | |
31 try: | |
32 from twisted.words.protocols.xmlstream import XMPPHandler | |
33 except ImportError: | |
34 from wokkel.subprotocols import XMPPHandler | |
35 | |
36 | |
37 NS_JINGLE_S5B = 'urn:xmpp:jingle:transports:s5b:1' | |
38 | |
39 PLUGIN_INFO = { | |
40 "name": "Jingle SOCKS5 Bytestreams", | |
41 "import_name": "XEP-0260", | |
42 "type": "XEP", | |
43 "protocols": ["XEP-0260"], | |
44 "dependencies": ["XEP-0166", "XEP-0065"], | |
1631
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
45 "recommendations": ["XEP-0261"], # needed for fallback |
1560 | 46 "main": "XEP_0260", |
47 "handler": "yes", | |
48 "description": _("""Implementation of Jingle SOCKS5 Bytestreams""") | |
49 } | |
50 | |
51 | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
52 class ProxyError(Exception): |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
53 pass |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
54 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
55 |
1560 | 56 class XEP_0260(object): |
57 # TODO: udp handling | |
58 | |
59 def __init__(self, host): | |
60 log.info(_("plugin Jingle SOCKS5 Bytestreams")) | |
61 self.host = host | |
62 self._j = host.plugins["XEP-0166"] # shortcut to access jingle | |
63 self._s5b = host.plugins["XEP-0065"] # and socks5 bytestream | |
1631
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
64 try: |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
65 self._jingle_ibb = host.plugins["XEP-0261"] |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
66 except KeyError: |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
67 self._jingle_ibb = None |
1560 | 68 self._j.registerTransport(NS_JINGLE_S5B, self._j.TRANSPORT_STREAMING, self, 100) |
69 | |
70 def getHandler(self, profile): | |
71 return XEP_0260_handler() | |
72 | |
73 def _parseCandidates(self, transport_elt): | |
74 """Parse <candidate> elements | |
75 | |
76 @param transport_elt(domish.Element): parent <transport> element | |
77 @return (list[plugin_xep_0065.Candidate): list of parsed candidates | |
78 """ | |
79 candidates = [] | |
80 for candidate_elt in transport_elt.elements(NS_JINGLE_S5B, 'candidate'): | |
81 try: | |
82 cid = candidate_elt['cid'] | |
83 host = candidate_elt['host'] | |
84 jid_= jid.JID(candidate_elt['jid']) | |
85 port = int(candidate_elt.getAttribute('port', 1080)) | |
86 priority = int(candidate_elt['priority']) | |
87 type_ = candidate_elt.getAttribute('type', self._s5b.TYPE_DIRECT) | |
88 except (KeyError, ValueError): | |
89 raise exceptions.DataError() | |
90 candidate = self._s5b.Candidate(host, port, type_, priority, jid_, cid) | |
91 candidates.append(candidate) | |
92 # self._s5b.registerCandidate(candidate) | |
93 return candidates | |
94 | |
95 def _buildCandidates(self, session, candidates, sid, session_hash, client, mode=None): | |
96 """Build <transport> element with candidates | |
97 | |
98 @param session(dict): jingle session data | |
99 @param candidates(iterator[plugin_xep_0065.Candidate]): iterator of candidates to add | |
100 @param sid(unicode): transport stream id | |
101 @param client: %(doc_client)s | |
102 @param mode(str, None): 'tcp' or 'udp', or None to have no attribute | |
103 @return (domish.Element): parent <transport> element where <candidate> elements must be added | |
104 """ | |
105 proxy = next((candidate for candidate in candidates if candidate.type == self._s5b.TYPE_PROXY), None) | |
106 transport_elt = domish.Element((NS_JINGLE_S5B, "transport")) | |
107 transport_elt['sid'] = sid | |
108 if proxy is not None: | |
109 transport_elt['dstaddr'] = session_hash | |
110 if mode is not None: | |
111 transport_elt['mode'] = 'tcp' # XXX: we only manage tcp for now | |
112 | |
113 for candidate in candidates: | |
114 log.debug(u"Adding candidate: {}".format(candidate)) | |
115 candidate_elt = transport_elt.addElement('candidate', NS_JINGLE_S5B) | |
116 if candidate.id is None: | |
117 candidate.id = unicode(uuid.uuid4()) | |
118 candidate_elt['cid'] = candidate.id | |
119 candidate_elt['host'] = candidate.host | |
120 candidate_elt['jid'] = candidate.jid.full() | |
121 candidate_elt['port'] = unicode(candidate.port) | |
122 candidate_elt['priority'] = unicode(candidate.priority) | |
123 candidate_elt['type'] = candidate.type | |
124 return transport_elt | |
125 | |
126 @defer.inlineCallbacks | |
127 def jingleSessionInit(self, session, content_name, profile): | |
128 client = self.host.getClient(profile) | |
129 content_data = session['contents'][content_name] | |
130 transport_data = content_data['transport_data'] | |
131 sid = transport_data['sid'] = unicode(uuid.uuid4()) | |
1567
268fda4236ca
plugins XE0166, XEP-0234, XEP-0260, XEP-0261: renamed session key managing other peer's jid to "peer_jid" instead of "to_jid"
Goffi <goffi@goffi.org>
parents:
1560
diff
changeset
|
132 session_hash = transport_data['session_hash'] = self._s5b.getSessionHash(client.jid, session['peer_jid'], sid) |
1560 | 133 candidates = transport_data['candidates'] = yield self._s5b.getCandidates(profile) |
134 mode = 'tcp' # XXX: we only manage tcp for now | |
135 transport_elt = self._buildCandidates(session, candidates, sid, session_hash, client, mode) | |
136 | |
137 defer.returnValue(transport_elt) | |
138 | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
139 def _proxyActivatedCb(self, iq_result_elt, candidate, session, content_name, profile): |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
140 """Called when activation confirmation has been received from proxy |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
141 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
142 cf XEP-0260 § 2.4 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
143 """ |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
144 # now that the proxy is activated, we have to inform other peer |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
145 iq_elt, transport_elt = self._j.buildAction(self._j.A_TRANSPORT_INFO, session, content_name, profile) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
146 activated_elt = transport_elt.addElement('activated') |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
147 activated_elt['cid'] = candidate.id |
1631
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
148 iq_elt.send() |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
149 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
150 def _proxyActivatedEb(self, stanza_error, candidate, session, content_name, profile): |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
151 """Called when activation error has been received from proxy |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
152 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
153 cf XEP-0260 § 2.4 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
154 """ |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
155 # TODO: fallback to IBB |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
156 # now that the proxy is activated, we have to inform other peer |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
157 iq_elt, transport_elt = self._j.buildAction(self._j.A_TRANSPORT_INFO, session, content_name, profile) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
158 transport_elt.addElement('proxy-error') |
1631
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
159 iq_elt.send() |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
160 log.warning(u"Can't activate proxy, we need to fallback to IBB") |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
161 client = self.host.getClient(profile) |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
162 self.doFallback(session, content_name, client) |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
163 |
1560 | 164 def _foundPeerCandidate(self, candidate, session, transport_data, content_name, client): |
165 """Called when the best candidate from other peer is found | |
166 | |
167 @param candidate(XEP_0065.Candidate, None): selected candidate, | |
168 or None if no candidate is accessible | |
169 @param session(dict): session data | |
170 @param transport_data(dict): transport data | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
171 @param content_name(unicode): name of the current content |
1560 | 172 @param client(unicode): %(doc_client)s |
173 """ | |
174 | |
175 transport_data['best_candidate'] = candidate | |
176 # we need to disconnect all non selected candidates before removing them | |
177 for c in transport_data['peer_candidates']: | |
178 if c is None or c is candidate: | |
179 continue | |
180 c.discard() | |
181 del transport_data['peer_candidates'] | |
182 iq_elt, transport_elt = self._j.buildAction(self._j.A_TRANSPORT_INFO, session, content_name, client.profile) | |
183 if candidate is None: | |
184 log.warning(u"Can't connect to any peer candidate") | |
185 candidate_elt = transport_elt.addElement('candidate-error') | |
186 else: | |
187 log.info(u"Found best peer candidate: {}".format(unicode(candidate))) | |
188 candidate_elt = transport_elt.addElement('candidate-used') | |
189 candidate_elt['cid'] = candidate.id | |
190 iq_elt.send() # TODO: check result stanza | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
191 self._checkCandidates(session, content_name, transport_data, client) |
1560 | 192 |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
193 def _checkCandidates(self, session, content_name, transport_data, client): |
1560 | 194 """Called when a candidate has been choosed |
195 | |
196 if we have both candidates, we select one, or fallback to an other transport | |
197 @param session(dict): session data | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
198 @param content_name(unicode): name of the current content |
1560 | 199 @param transport_data(dict): transport data |
200 @param client(unicode): %(doc_client)s | |
201 """ | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
202 content_data = session['contents'][content_name] |
1560 | 203 try: |
204 best_candidate = transport_data['best_candidate'] | |
205 except KeyError: | |
206 # we have not our best candidate yet | |
207 return | |
208 try: | |
209 peer_best_candidate = transport_data['peer_best_candidate'] | |
210 except KeyError: | |
211 # we have not peer best candidate yet | |
212 return | |
213 | |
214 # at this point we have both candidates, it's time to choose one | |
215 if best_candidate is None or peer_best_candidate is None: | |
216 choosed_candidate = best_candidate or peer_best_candidate | |
217 else: | |
218 if best_candidate.priority == peer_best_candidate.priority: | |
219 # same priority, we choose initiator one according to XEP-0260 §2.4 #4 | |
220 log.debug(u"Candidates have same priority, we choose the initiator one") | |
221 if session['initiator'] == client.jid: | |
222 choosed_candidate = best_candidate | |
223 else: | |
224 choosed_candidate = peer_best_candidate | |
225 else: | |
226 choosed_candidate = max(best_candidate, peer_best_candidate, key=lambda c:c.priority) | |
227 | |
228 if choosed_candidate is None: | |
229 log.warning(u"Socks5 negociation failed, we need to fallback to IBB") | |
1631
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
230 self.doFallback(session, content_name, client) |
1560 | 231 else: |
1571
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
232 if choosed_candidate == peer_best_candidate: |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
233 # peer_best_candidate was choosed from the candidates we have sent |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
234 # so our_candidate is true if choosed_candidate is peer_best_candidate |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
235 our_candidate = True |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
236 # than also mean that best_candidate must be discarded ! |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
237 try: |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
238 best_candidate.discard() |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
239 except AttributeError: # but it can be None |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
240 pass |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
241 else: |
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
242 our_candidate = False |
1560 | 243 |
244 log.info(u"Socks5 negociation successful, {who} candidate will be used: {candidate}".format( | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
245 who = u'our' if our_candidate else u'other peer', |
1560 | 246 candidate = choosed_candidate)) |
247 del transport_data['best_candidate'] | |
248 del transport_data['peer_best_candidate'] | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
249 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
250 if choosed_candidate.type == self._s5b.TYPE_PROXY: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
251 # the file transfer need to wait for proxy activation |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
252 # (see XEP-0260 § 2.4) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
253 if our_candidate: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
254 d = self._s5b.connectCandidate(choosed_candidate, transport_data['session_hash'], profile=client.profile) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
255 d.addCallback(lambda dummy: choosed_candidate.activate(transport_data['sid'], session['peer_jid'], client)) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
256 args = [choosed_candidate, session, content_name, client.profile] |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
257 d.addCallbacks(self._proxyActivatedCb, self._proxyActivatedEb, args, None, args) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
258 else: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
259 # this Deferred will be called when we'll receive activation confirmation from other peer |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
260 d = transport_data['activation_d'] = defer.Deferred() |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
261 else: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
262 d = defer.succeed(None) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
263 |
1560 | 264 if content_data['senders'] == session['role']: |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
265 # we can now start the file transfer (or start it after proxy activation) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
266 d.addCallback(lambda dummy: choosed_candidate.startTransfer(transport_data['session_hash'])) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
267 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
268 def _candidateInfo(self, candidate_elt, session, content_name, transport_data, client): |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
269 """Called when best candidate has been received from peer (or if none is working) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
270 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
271 @param candidate_elt(domish.Element): candidate-used or candidate-error element |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
272 (see XEP-0260 §2.3) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
273 @param session(dict): session data |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
274 @param content_name(unicode): name of the current content |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
275 @param transport_data(dict): transport data |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
276 @param client(unicode): %(doc_client)s |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
277 """ |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
278 if candidate_elt.name == 'candidate-error': |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
279 # candidate-error, no candidate worked |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
280 transport_data['peer_best_candidate'] = None |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
281 else: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
282 # candidate-used, one candidate was choosed |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
283 try: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
284 cid = candidate_elt.attributes['cid'] |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
285 except KeyError: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
286 log.warning(u"No cid found in <candidate-used>") |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
287 raise exceptions.DataError |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
288 try: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
289 candidate = (c for c in transport_data['candidates'] if c.id == cid).next() |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
290 except StopIteration: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
291 log.warning(u"Given cid doesn't correspond to any known candidate !") |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
292 raise exceptions.DataError # TODO: send an error to other peer, and use better exception |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
293 except KeyError: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
294 # a transport-info can also be intentionaly sent too early by other peer |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
295 # but there is little probability |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
296 log.error(u'"candidates" key doesn\'t exists in transport_data, it should at this point') |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
297 raise exceptions.InternalError |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
298 # at this point we have the candidate choosed by other peer |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
299 transport_data['peer_best_candidate'] = candidate |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
300 log.info(u"Other peer best candidate: {}".format(candidate)) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
301 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
302 del transport_data['candidates'] |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
303 self._checkCandidates(session, content_name, transport_data, client) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
304 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
305 def _proxyActivationInfo(self, proxy_elt, session, content_name, transport_data, client): |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
306 """Called when proxy has been activated (or has sent an error) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
307 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
308 @param proxy_elt(domish.Element): <activated/> or <proxy-error/> element |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
309 (see XEP-0260 §2.4) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
310 @param session(dict): session data |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
311 @param content_name(unicode): name of the current content |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
312 @param transport_data(dict): transport data |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
313 @param client(unicode): %(doc_client)s |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
314 """ |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
315 try: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
316 activation_d = transport_data.pop('activation_d') |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
317 except KeyError: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
318 log.warning(u"Received unexpected transport-info for proxy activation") |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
319 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
320 if proxy_elt.name == 'activated': |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
321 activation_d.callback(None) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
322 else: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
323 activation_d.errback(ProxyError) |
1560 | 324 |
325 @defer.inlineCallbacks | |
326 def jingleHandler(self, action, session, content_name, transport_elt, profile): | |
327 client = self.host.getClient(profile) | |
328 content_data = session['contents'][content_name] | |
329 transport_data = content_data['transport_data'] | |
330 | |
1631
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
331 if action in (self._j.A_ACCEPTED_ACK, self._j.A_PREPARE_RESPONDER): |
1560 | 332 pass |
333 | |
334 elif action == self._j.A_SESSION_ACCEPT: | |
335 # initiator side, we select a candidate in the ones sent by responder | |
336 assert 'peer_candidates' not in transport_data | |
337 transport_data['peer_candidates'] = self._parseCandidates(transport_elt) | |
338 | |
339 # elif action == self._j.A_START: | |
340 elif action == self._j.A_START: | |
341 session_hash = transport_data['session_hash'] | |
342 peer_candidates = transport_data['peer_candidates'] | |
343 file_obj = content_data['file_obj'] | |
344 stream_d = self._s5b.registerHash(session_hash, file_obj, profile) | |
1571
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
345 stream_d.chainDeferred(content_data['finished_d']) |
1560 | 346 d = self._s5b.getBestCandidate(peer_candidates, session_hash, profile) |
347 d.addCallback(self._foundPeerCandidate, session, transport_data, content_name, client) | |
348 | |
349 elif action == self._j.A_SESSION_INITIATE: | |
350 # responder side, we select a candidate in the ones sent by initiator | |
351 # and we give our candidates | |
352 assert 'peer_candidates' not in transport_data | |
353 sid = transport_data['sid'] = transport_elt['sid'] | |
1567
268fda4236ca
plugins XE0166, XEP-0234, XEP-0260, XEP-0261: renamed session key managing other peer's jid to "peer_jid" instead of "to_jid"
Goffi <goffi@goffi.org>
parents:
1560
diff
changeset
|
354 session_hash = transport_data['session_hash'] = self._s5b.getSessionHash(session['peer_jid'], client.jid, sid) |
1560 | 355 peer_candidates = transport_data['peer_candidates'] = self._parseCandidates(transport_elt) |
356 file_obj = content_data['file_obj'] | |
357 stream_d = self._s5b.registerHash(session_hash, file_obj, profile) | |
1571
c668081eba1c
plugins XEP-0234, XEP-0260, XEP-0261: jingle session termination is managed by application (XEP-0234) instead of transport
Goffi <goffi@goffi.org>
parents:
1570
diff
changeset
|
358 stream_d.chainDeferred(content_data['finished_d']) |
1560 | 359 d = self._s5b.getBestCandidate(peer_candidates, session_hash, profile) |
360 d.addCallback(self._foundPeerCandidate, session, transport_data, content_name, client) | |
361 candidates = yield self._s5b.getCandidates(profile) | |
362 # we remove duplicate candidates | |
363 candidates = [candidate for candidate in candidates if candidate not in peer_candidates] | |
364 | |
365 transport_data['candidates'] = candidates | |
366 # we can now build a new <transport> element with our candidates | |
367 transport_elt = self._buildCandidates(session, candidates, sid, session_hash, client) | |
368 | |
369 elif action == self._j.A_TRANSPORT_INFO: | |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
370 # transport-info can be about candidate or proxy activation |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
371 candidate_elt = None |
1560 | 372 |
1570
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
373 for method, names in ((self._candidateInfo, ('candidate-used', 'candidate-error')), |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
374 (self._proxyActivationInfo, ('activated', 'proxy-error'))): |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
375 for name in names: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
376 try: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
377 candidate_elt = transport_elt.elements(NS_JINGLE_S5B, name).next() |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
378 except StopIteration: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
379 continue |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
380 else: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
381 method(candidate_elt, session, content_name, transport_data, client) |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
382 break |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
383 |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
384 if candidate_elt is None: |
37d4be4a9fed
plugins XEP-0260, XEP-0065: proxy handling:
Goffi <goffi@goffi.org>
parents:
1567
diff
changeset
|
385 log.warning(u"Unexpected transport element: {}".format(transport_elt.toXml())) |
1631
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
386 elif action == self._j.A_DESTROY: |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
387 # the transport is remplaced (fallback ?). We need mainly to stop kill XEP-0065 session |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
388 # note that sid argument is not necessary for sessions created by this plugin |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
389 self._s5b.killSession(None, transport_data['session_hash'], None, client) |
1560 | 390 else: |
391 log.warning(u"FIXME: unmanaged action {}".format(action)) | |
392 | |
393 defer.returnValue(transport_elt) | |
394 | |
1631
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
395 def _doFallback(self, feature_checked, session, content_name, client): |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
396 """Do the fallback, method called once feature is checked |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
397 |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
398 @param feature_checked(bool): True if other peer can do IBB |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
399 """ |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
400 if not feature_checked: |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
401 log.warning(u"Other peer can't manage jingle IBB, be have to terminate the session") |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
402 self._j.terminate(self._j.REASON_CONNECTIVITY_ERROR, session, client.profile) |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
403 else: |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
404 self._j.transportReplace(self._jingle_ibb.NAMESPACE, session, content_name, client.profile) |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
405 |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
406 def doFallback(self, session, content_name, client): |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
407 """Fallback to IBB transport, used in last resort |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
408 |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
409 @param session(dict): session data |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
410 @param content_name(unicode): name of the current content |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
411 @param client(unicode): %(doc_client)s |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
412 """ |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
413 if session['role'] != self._j.ROLE_INITIATOR: |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
414 # only initiator must do the fallback, see XEP-0260 §3 |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
415 return |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
416 if self._jingle_ibb is None: |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
417 log.warning(u"Jingle IBB (XEP-0261) plugin is not available, we have to close the session") |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
418 self._j.terminate(self._j.REASON_CONNECTIVITY_ERROR, session, client.profile) |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
419 else: |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
420 d = self.host.hasFeature(self._jingle_ibb.NAMESPACE, session['peer_jid'], client.profile) |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
421 d.addCallback(self._doFallback, session, content_name, client) |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
422 return d |
25906c0dbc63
plugin XEP-0260, XEP-0261: fallback from S5B to IBB is implemented
Goffi <goffi@goffi.org>
parents:
1571
diff
changeset
|
423 |
1560 | 424 |
425 class XEP_0260_handler(XMPPHandler): | |
426 implements(iwokkel.IDisco) | |
427 | |
428 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): | |
429 return [disco.DiscoFeature(NS_JINGLE_S5B)] | |
430 | |
431 def getDiscoItems(self, requestor, target, nodeIdentifier=''): | |
432 return [] |