Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0261.py @ 1556:cbfbe028d099
plugin XEP-0166, XEP-0234, XEP-0261:
- transport and application data are now managed in separate dictionaries
- new client.IQ method is used
- new buildAction helper method for applications and transports
- "role" is now stored in session_data
- "senders" is now stored in content_data
- plugin XEP-0166: "transport-info" action is now managed
- plugin XEP-0166: application namespace and handler are now managed in a namedtuple
- plugin XEP-0234: <range/> element is added by responder if not already present
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Nov 2015 22:02:41 +0100 |
parents | bfef1934a8f3 |
children | 268fda4236ca |
comparison
equal
deleted
inserted
replaced
1555:eb8aae35085b | 1556:cbfbe028d099 |
---|---|
58 return XEP_0261_handler() | 58 return XEP_0261_handler() |
59 | 59 |
60 def jingleSessionInit(self, session, content_name, profile): | 60 def jingleSessionInit(self, session, content_name, profile): |
61 transport_elt = domish.Element((NS_JINGLE_IBB, "transport")) | 61 transport_elt = domish.Element((NS_JINGLE_IBB, "transport")) |
62 content_data = session['contents'][content_name] | 62 content_data = session['contents'][content_name] |
63 content_data['ibb_block_size'] = self._ibb.BLOCK_SIZE | 63 transport_data = content_data['transport_data'] |
64 transport_elt['block-size'] = unicode(content_data['ibb_block_size']) | 64 transport_data['block_size'] = self._ibb.BLOCK_SIZE |
65 transport_elt['sid'] = content_data['ibb_sid'] = unicode(uuid.uuid4()) | 65 transport_elt['block-size'] = unicode(transport_data['block_size']) |
66 transport_elt['sid'] = transport_data['sid'] = unicode(uuid.uuid4()) | |
66 return transport_elt | 67 return transport_elt |
67 | 68 |
68 def jingleHandler(self, action, session, content_name, transport_elt, profile): | 69 def jingleHandler(self, action, session, content_name, transport_elt, profile): |
69 content_data = session['contents'][content_name] | 70 content_data = session['contents'][content_name] |
71 transport_data = content_data['transport_data'] | |
70 if action in (self._j.A_SESSION_ACCEPT, self._j.A_ACCEPTED_ACK): | 72 if action in (self._j.A_SESSION_ACCEPT, self._j.A_ACCEPTED_ACK): |
71 pass | 73 pass |
72 elif action == self._j.A_SESSION_INITIATE: | 74 elif action == self._j.A_SESSION_INITIATE: |
73 content_data['ibb_sid'] = transport_elt['sid'] | 75 transport_data['sid'] = transport_elt['sid'] |
74 elif action in (self._j.A_START, self._j.A_PREPARE_RESPONDER): | 76 elif action in (self._j.A_START, self._j.A_PREPARE_RESPONDER): |
75 to_jid = session['to_jid'] | 77 to_jid = session['to_jid'] |
76 sid = content_data['ibb_sid'] | 78 sid = transport_data['sid'] |
77 file_obj = content_data['file_obj'] | 79 file_obj = content_data['file_obj'] |
78 args = [session, content_name, profile] | 80 args = [session, content_name, profile] |
79 if action == self._j.A_START: | 81 if action == self._j.A_START: |
80 block_size = content_data['ibb_block_size'] | 82 block_size = transport_data['block_size'] |
81 d = self._ibb.startStream(file_obj, to_jid, sid, block_size, profile) | 83 d = self._ibb.startStream(file_obj, to_jid, sid, block_size, profile) |
82 d.addErrback(self._streamEb, *args) | 84 d.addErrback(self._streamEb, *args) |
83 else: | 85 else: |
84 d = self._ibb.createSession(file_obj, to_jid, sid, profile) | 86 d = self._ibb.createSession(file_obj, to_jid, sid, profile) |
85 d.addCallbacks(self._streamCb, self._streamEb, args, None, args) | 87 d.addCallbacks(self._streamCb, self._streamEb, args, None, args) |