annotate src/plugins/plugin_xep_0166.py @ 1615:a1e5bcd9a6eb

jingle XEP-0166: fixed session creation on non session-initiate actions
author Goffi <goffi@goffi.org>
date Tue, 17 Nov 2015 19:39:08 +0100
parents 1ced93821c35
children 1e05b776a55b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
3
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT plugin for Jingle (XEP-0166)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
6
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
11
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
16
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
19
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from sat.core.i18n import _, D_
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from sat.core.constants import Const as C
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from sat.core.log import getLogger
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from sat.tools import xml_tools
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
24 log = getLogger(__name__)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from sat.core import exceptions
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from twisted.words.protocols.jabber import jid
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from twisted.internet import defer
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
28 # from wokkel import disco, iwokkel, data_form, compat
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
29 from wokkel import disco, iwokkel
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from twisted.words.protocols.jabber import error
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from twisted.words.protocols.jabber import xmlstream
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
32 from twisted.python import failure
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from collections import namedtuple
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
34 import uuid
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
35 import time
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
36
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from zope.interface import implements
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
38
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
39
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
40
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
41 IQ_SET = '/iq[@type="set"]'
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
42 NS_JINGLE = "urn:xmpp:jingle:1"
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
43 NS_JINGLE_ERROR = "urn:xmpp:jingle:errors:1"
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
44 JINGLE_REQUEST = IQ_SET + '/jingle[@xmlns="' + NS_JINGLE + '"]'
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
45 STATE_PENDING = "PENDING"
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
46 STATE_ACTIVE = "ACTIVE"
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
47 STATE_ENDED = "ENDED"
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
48 CONFIRM_TXT = D_("{entity} want to start a jingle session with you, do you accept ?")
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
49
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
50 PLUGIN_INFO = {
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
51 "name": "Jingle",
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
52 "import_name": "XEP-0166",
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
53 "type": "XEP",
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
54 "protocols": ["XEP-0166"],
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
55 "main": "XEP_0166",
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
56 "handler": "yes",
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
57 "description": _("""Implementation of Jingle""")
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
58 }
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
59
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
60
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
61 ApplicationData = namedtuple('ApplicationData', ('namespace', 'handler'))
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
62 TransportData = namedtuple('TransportData', ('namespace', 'handler', 'priority'))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
63
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
64
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
65 class XEP_0166(object):
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
66 ROLE_INITIATOR = "initiator"
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
67 ROLE_RESPONDER = "responder"
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
68 TRANSPORT_DATAGRAM='UDP'
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
69 TRANSPORT_STREAMING='TCP'
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
70 REASON_SUCCESS='success'
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
71 REASON_DECLINE='decline'
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
72 REASON_FAILED_APPLICATION='failed-application'
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
73 REASON_FAILED_TRANSPORT='failed-transport'
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
74 A_SESSION_INITIATE = "session-initiate"
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
75 A_SESSION_ACCEPT = "session-accept"
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
76 A_SESSION_TERMINATE = "session-terminate"
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
77 A_TRANSPORT_INFO = "transport-info"
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
78 # non standard actions
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
79 A_PREPARE_INITIATOR = "prepare-initiator" # initiator must prepare tranfer
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
80 A_PREPARE_RESPONDER = "prepare-responder" # responder must prepare tranfer
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
81 A_ACCEPTED_ACK = "accepted-ack" # session accepted ack has been received from initiator
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
82 A_START = "start" # application can start
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
83
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
84 def __init__(self, host):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
85 log.info(_("plugin Jingle initialization"))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
86 self.host = host
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
87 self._applications = {} # key: namespace, value: application data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
88 self._transports = {} # key: namespace, value: transport data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
89 # we also keep transports by type, they are then sorted by priority
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
90 self._type_transports = { XEP_0166.TRANSPORT_DATAGRAM: [],
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
91 XEP_0166.TRANSPORT_STREAMING: [],
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
92 }
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
93
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
94 def profileConnected(self, profile):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
95 client = self.host.getClient(profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
96 client.jingle_sessions = {} # key = sid, value = session_data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
97
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
98 def getHandler(self, profile):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
99 return XEP_0166_handler(self)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
100
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
101 def _delSession(self, client, sid):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
102 try:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
103 del client.jingle_sessions[sid]
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
104 except KeyError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
105 log.debug(u"Jingle session id [{}] is unknown, nothing to delete".format(sid))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
106 else:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
107 log.debug(u"Jingle session id [{}] deleted".format(sid))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
108
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
109 ## helpers methods to build stanzas ##
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
110
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
111 def _buildJingleElt(self, client, session, action):
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
112 iq_elt = client.IQ('set')
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
113 iq_elt['from'] = client.jid.full()
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: 1556
diff changeset
114 iq_elt['to'] = session['peer_jid'].full()
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
115 jingle_elt = iq_elt.addElement("jingle", NS_JINGLE)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
116 jingle_elt["sid"] = session['id']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
117 jingle_elt['action'] = action
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
118 return iq_elt, jingle_elt
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
119
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
120 def sendError(self, error_condition, sid, request, jingle_condition=None, profile=C.PROF_KEY_NONE):
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
121 """Send error stanza
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
122
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
123 @param error_condition: one of twisted.words.protocols.jabber.error.STANZA_CONDITIONS keys
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
124 @param sid(unicode,None): jingle session id, or None, if session must not be destroyed
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
125 @param request(domish.Element): original request
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
126 @param jingle_condition(None, unicode): if not None, additional jingle-specific error information
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
127 @param profile: %(doc_profile)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
128 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
129 client = self.host.getClient(profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
130 iq_elt = error.StanzaError(error_condition).toResponse(request)
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
131 if jingle_condition is not None:
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
132 iq_elt.error.addElement((NS_JINGLE_ERROR, jingle_condition))
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
133 if error.STANZA_CONDITIONS[error_condition]['type'] == 'cancel' and sid:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
134 self._delSession(client, sid)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
135 log.warning(u"Error while managing jingle session, cancelling: {condition}".format(error_condition))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
136 client.xmlstream.send(iq_elt)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
137
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
138 def terminate(self, reason, session, profile):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
139 """Terminate the session
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
140
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
141 send the session-terminate action, and delete the session data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
142 @param reason(unicode, list[domish.Element]): if unicode, will be transformed to an element
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
143 if a list of element, add them as children of the <reason/> element
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
144 @param session(dict): data of the session
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
145 @param profile: %(doc_profile)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
146 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
147 client = self.host.getClient(profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
148 iq_elt, jingle_elt = self._buildJingleElt(client, session, XEP_0166.A_SESSION_TERMINATE)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
149 reason_elt = jingle_elt.addElement('reason')
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
150 if isinstance(reason, basestring):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
151 reason_elt.addElement(reason)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
152 else:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
153 for elt in reason:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
154 reason_elt.addChild(elt)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
155 self._delSession(client, session['id'])
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
156 d = iq_elt.send()
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
157 return d
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
158
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
159 ## errors which doesn't imply a stanza sending ##
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
160
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
161 def _iqError(self, failure_, sid, client):
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
162 """Called when we got an <iq/> error
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
163
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
164 @param failure_(failure.Failure): the exceptions raised
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
165 @param sid(unicode): jingle session id
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
166 @param profile: %(doc_client)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
167 """
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
168 log.warning(u"Error while sending jingle <iq/> stanza: {failure_}".format(failure_=failure_.value))
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
169 self._delSession(client, sid)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
170
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
171 def _jingleErrorCb(self, fail, sid, request, client):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
172 """Called when something is going wrong while parsing jingle request
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
173
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
174 The error condition depend of the exceptions raised:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
175 exceptions.DataError raise a bad-request condition
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
176 @param fail(failure.Failure): the exceptions raised
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
177 @param sid(unicode): jingle session id
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
178 @param request(domsih.Element): jingle request
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
179 @param client: %(doc_client)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
180 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
181 log.warning("Error while processing jingle request")
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
182 if isinstance(fail, exceptions.DataError):
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
183 self.sendError('bad-request', sid, request, profile=client.profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
184 else:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
185 log.error("Unmanaged jingle exception")
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
186 self._delSession(client, sid)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
187 raise fail
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
188
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
189 ## methods used by other plugins ##
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
190
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
191 def registerApplication(self, namespace, handler):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
192 """Register an application plugin
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
193
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
194 @param namespace(unicode): application namespace managed by the plugin
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
195 @param handler(object): instance of a class which manage the application.
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
196 May have the following methods:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
197 - requestConfirmation(session, desc_elt, client):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
198 - if present, it is called on when session must be accepted.
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
199 - if it return True the session is accepted, else rejected.
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
200 A Deferred can be returned
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
201 - if not present, a generic accept dialog will be used
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
202 - jingleSessionInit(self, session, content_name[, *args, **kwargs], profile): must return the domish.Element used for initial content
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
203 - jingleHandler(self, action, session, content_name, transport_elt, profile):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
204 called on several action to negociate the application or transport
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
205 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
206 if namespace in self._applications:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
207 raise exceptions.ConflictError(u"Trying to register already registered namespace {}".format(namespace))
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
208 self._applications[namespace] = ApplicationData(namespace=namespace, handler=handler)
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
209 log.debug(u"new jingle application registered")
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
210
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
211 def registerTransport(self, namespace, transport_type, handler, priority=0):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
212 """Register a transport plugin
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
213
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
214 @param namespace(unicode): the XML namespace used for this transport
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
215 @param transport_type(unicode): type of transport to use (see XEP-0166 §8)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
216 @param handler(object): instance of a class which manage the application.
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
217 Must have the following methods:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
218 - jingleSessionInit(self, session, content_name[, *args, **kwargs], profile): must return the domish.Element used for initial content
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
219 - jingleHandler(self, action, session, content_name, transport_elt, profile):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
220 called on several action to negociate the application or transport
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
221 @param priority(int): priority of this transport
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
222 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
223 assert transport_type in (XEP_0166.TRANSPORT_DATAGRAM, XEP_0166.TRANSPORT_STREAMING)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
224 if namespace in self._transports:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
225 raise exceptions.ConflictError(u"Trying to register already registered namespace {}".format(namespace))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
226 transport_data = TransportData(namespace=namespace, handler=handler, priority=priority)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
227 self._type_transports[transport_type].append(transport_data)
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
228 self._type_transports[transport_type].sort(key=lambda transport_data: transport_data.priority, reverse=True)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
229 self._transports[namespace] = transport_data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
230 log.debug(u"new jingle transport registered")
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
231
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
232 def buildAction(self, action, session, content_name, profile=C.PROF_KEY_NONE):
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
233 """Build an element according to requested action
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
234
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
235 @param action(unicode): a jingle action (see XEP-0166 §7.2),
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
236 session-* actions are not managed here
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
237 @param session(dict): jingle session data
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
238 @param content_name(unicode): name of the content
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
239 @param profile: %(doc_profile)s
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
240 @return (tuple[domish.Element, domish.Element]): parent <iq> element, <transport> or <description> element, according to action
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
241 """
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
242 client = self.host.getClient(profile)
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
243
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
244 # we first build iq, jingle and content element which are the same in every cases
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
245 iq_elt, jingle_elt = self._buildJingleElt(client, session, action)
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
246 # FIXME: XEP-0260 § 2.3 Ex 5 has an initiator attribute, but it should not according to XEP-0166 §7.1 table 1, must be checked
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
247 content_data= session['contents'][content_name]
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
248 content_elt = jingle_elt.addElement('content')
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
249 content_elt['name'] = content_name
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
250 content_elt['creator'] = content_data['creator']
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
251
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
252 if action == XEP_0166.A_TRANSPORT_INFO:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
253 context_elt = transport_elt = content_elt.addElement('transport', content_data['transport'].namespace)
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
254 transport_elt['sid'] = content_data['transport_data']['sid']
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
255 else:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
256 raise exceptions.InternalError(u"unmanaged action {}".format(action))
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
257
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
258 return iq_elt, context_elt
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
259
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
260 @defer.inlineCallbacks
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: 1556
diff changeset
261 def initiate(self, peer_jid, contents, profile=C.PROF_KEY_NONE):
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
262 """Send a session initiation request
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
263
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: 1556
diff changeset
264 @param peer_jid(jid.JID): jid to establith session with
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
265 @param contents(list[dict]): list of contents to use:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
266 The dict must have the following keys:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
267 - app_ns(unicode): namespace of the application
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
268 the following keys are optional:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
269 - transport_type(unicode): type of transport to use (see XEP-0166 §8)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
270 default to TRANSPORT_STREAMING
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
271 - name(unicode): name of the content
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
272 - senders(unicode): One of XEP_0166.ROLE_INITIATOR, XEP_0166.ROLE_RESPONDER, both or none
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
273 default to BOTH (see XEP-0166 §7.3)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
274 - app_args(list): args to pass to the application plugin
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
275 - app_kwargs(dict): keyword args to pass to the application plugin
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
276 @param profile: %(doc_profile)s
1585
846a39900fa6 plugins XEP-0096, XEP-0260, file: sendFile method is managed by file plugin, which choose the best available method + progress_id fix
Goffi <goffi@goffi.org>
parents: 1567
diff changeset
277 @return D(unicode): jingle session id
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
278 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
279 assert contents # there must be at least one content
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
280 client = self.host.getClient(profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
281 initiator = client.jid
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
282 sid = unicode(uuid.uuid4())
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
283 # TODO: session cleaning after timeout ?
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
284 session = client.jingle_sessions[sid] = {'id': sid,
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
285 'state': STATE_PENDING,
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
286 'initiator': initiator,
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
287 'role': XEP_0166.ROLE_INITIATOR,
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: 1556
diff changeset
288 'peer_jid': peer_jid,
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
289 'started': time.time(),
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
290 'contents': {}
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
291 }
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
292 iq_elt, jingle_elt = self._buildJingleElt(client, session, XEP_0166.A_SESSION_INITIATE)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
293 jingle_elt["initiator"] = initiator.full()
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
294
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
295 contents_dict = session['contents']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
296
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
297 for content in contents:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
298 # we get the application plugin
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
299 app_ns = content['app_ns']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
300 try:
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
301 application = self._applications[app_ns]
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
302 except KeyError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
303 raise exceptions.InternalError(u"No application registered for {}".format(app_ns))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
304
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
305 # and the transport plugin
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
306 transport_type = content.get('transport_type', XEP_0166.TRANSPORT_STREAMING)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
307 try:
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
308 transport = self._type_transports[transport_type][0]
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
309 except IndexError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
310 raise exceptions.InternalError(u"No transport registered for {}".format(transport_type))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
311
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
312 # we build the session data
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
313 content_data = {'application': application,
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
314 'application_data': {},
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
315 'transport': transport,
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
316 'transport_data': {},
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
317 'creator': XEP_0166.ROLE_INITIATOR,
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
318 'senders': content.get('senders', 'both'),
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
319 }
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
320 try:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
321 content_name = content['name']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
322 except KeyError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
323 content_name = unicode(uuid.uuid4())
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
324 else:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
325 if content_name in contents_dict:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
326 raise exceptions.InternalError('There is already a content with this name')
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
327 contents_dict[content_name] = content_data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
328
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
329 # we construct the content element
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
330 content_elt = jingle_elt.addElement('content')
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
331 content_elt['creator'] = content_data['creator']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
332 content_elt['name'] = content_name
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
333 try:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
334 content_elt['senders'] = content['senders']
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
335 except KeyError:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
336 pass
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
337
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
338 # then the description element
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
339 app_args = content.get('app_args', [])
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
340 app_kwargs = content.get('app_kwargs', {})
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
341 app_kwargs['profile'] = profile
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
342 desc_elt = yield application.handler.jingleSessionInit(session, content_name, *app_args, **app_kwargs)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
343 content_elt.addChild(desc_elt)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
344
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
345 # and the transport one
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
346 transport_elt = yield transport.handler.jingleSessionInit(session, content_name, profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
347 content_elt.addChild(transport_elt)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
348
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
349 d = iq_elt.send()
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
350 d.addErrback(self._iqError, sid, client)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
351 yield d
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
352
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
353 def contentTerminate(self, session, content_name, reason=REASON_SUCCESS, profile=C.PROF_KEY_NONE):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
354 """Terminate and remove a content
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
355
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
356 if there is no more content, then session is terminated
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
357 @param session(dict): jingle session
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
358 @param content_name(unicode): name of the content terminated
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
359 @param reason(unicode): reason of the termination
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
360 @param profile: %(doc_profile)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
361 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
362 contents = session['contents']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
363 del contents[content_name]
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
364 if not contents:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
365 self.terminate(reason, session, profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
366
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
367 ## defaults methods called when plugin doesn't have them ##
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
368
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
369 def jingleRequestConfirmationDefault(self, action, session, content_name, desc_elt, profile):
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
370 """This method request confirmation for a jingle session"""
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
371 log.debug(u"Using generic jingle confirmation method")
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: 1556
diff changeset
372 return xml_tools.deferConfirm(self.host, _(CONFIRM_TXT).format(entity=session['peer_jid'].full()), _('Confirm Jingle session'), profile=profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
373
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
374 ## jingle events ##
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
375
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
376 def _onJingleRequest(self, request, profile):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
377 """Called when any jingle request is received
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
378
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
379 The request will the be dispatched to appropriate method
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
380 according to current state
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
381 @param request(domish.Element): received IQ request
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
382 @para profile: %(doc_profile)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
383 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
384 client = self.host.getClient(profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
385 request.handled = True
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
386 jingle_elt = request.elements(NS_JINGLE, 'jingle').next()
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
387
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
388 # first we need the session id
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
389 try:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
390 sid = jingle_elt['sid']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
391 if not sid:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
392 raise KeyError
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
393 except KeyError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
394 log.warning(u"Received jingle request has no sid attribute")
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
395 self.sendError('bad-request', None, request, profile=profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
396 return
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
397
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
398 # then the action
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
399 try:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
400 action = jingle_elt['action']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
401 if not action:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
402 raise KeyError
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
403 except KeyError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
404 log.warning(u"Received jingle request has no action")
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
405 self.sendError('bad-request', None, request, profile=profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
406 return
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
407
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: 1556
diff changeset
408 peer_jid = jid.JID(request['from'])
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
409
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
410 # we get or create the session
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
411 try:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
412 session = client.jingle_sessions[sid]
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
413 except KeyError:
1615
a1e5bcd9a6eb jingle XEP-0166: fixed session creation on non session-initiate actions
Goffi <goffi@goffi.org>
parents: 1614
diff changeset
414 if action != XEP_0166.A_SESSION_INITIATE:
a1e5bcd9a6eb jingle XEP-0166: fixed session creation on non session-initiate actions
Goffi <goffi@goffi.org>
parents: 1614
diff changeset
415 log.warning(u"Received request for an unknown session id: {}".format(sid))
a1e5bcd9a6eb jingle XEP-0166: fixed session creation on non session-initiate actions
Goffi <goffi@goffi.org>
parents: 1614
diff changeset
416 self.sendError('not-acceptable', None, request, profile=profile)
a1e5bcd9a6eb jingle XEP-0166: fixed session creation on non session-initiate actions
Goffi <goffi@goffi.org>
parents: 1614
diff changeset
417 return
a1e5bcd9a6eb jingle XEP-0166: fixed session creation on non session-initiate actions
Goffi <goffi@goffi.org>
parents: 1614
diff changeset
418
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
419 session = client.jingle_sessions[sid] = {'id': sid,
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
420 'state': STATE_PENDING,
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: 1556
diff changeset
421 'initiator': peer_jid,
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
422 'role': XEP_0166.ROLE_RESPONDER,
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: 1556
diff changeset
423 'peer_jid': peer_jid,
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
424 'started': time.time(),
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
425 }
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
426 else:
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: 1556
diff changeset
427 if session['peer_jid'] != peer_jid:
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
428 log.warning(u"sid conflict ({}), the jid doesn't match. Can be a collision, a hack attempt, or a bad sid generation".format(sid))
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
429 self.sendError('service-unavailable', sid, request, profile=profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
430 return
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
431 if session['id'] != sid:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
432 log.error(u"session id doesn't match")
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
433 self.sendError('service-unavailable', sid, request, profile=profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
434 raise exceptions.InternalError
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
435
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
436 if action == XEP_0166.A_SESSION_INITIATE:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
437 self.onSessionInitiate(client, request, jingle_elt, session)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
438 elif action == XEP_0166.A_SESSION_TERMINATE:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
439 self.onSessionTerminate(client, request, jingle_elt, session)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
440 elif action == XEP_0166.A_SESSION_ACCEPT:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
441 self.onSessionAccept(client, request, jingle_elt, session)
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
442 elif action == XEP_0166.A_TRANSPORT_INFO:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
443 self.onTransportInfo(client, request, jingle_elt, session)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
444 else:
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
445 raise exceptions.InternalError(u"Unknown action {}".format(action))
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
446
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
447 ## Actions callbacks ##
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
448
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
449 def _parseElements(self, jingle_elt, session, request, client, new=False, creator=ROLE_INITIATOR, with_application=True, with_transport=True):
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
450 """Parse contents elements and fill contents_dict accordingly
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
451
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
452 after the parsing, contents_dict will containt handlers, "desc_elt" and "transport_elt"
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
453 @param jingle_elt(domish.Element): parent <jingle> element, containing one or more <content>
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
454 @param session(dict): session data
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
455 @param request(domish.Element): the whole request
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
456 @param client: %(doc_client)s
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
457 @param new(bool): if new the content is new and must be created,
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
458 else the content must exists, and session data will be filled
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
459 @param creator(unicode): only used if new is True: creating pear (see § 7.3)
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
460 @param with_application(bool): if True, raise an error if there is no <description> element else ignore it
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
461 @param with_transport(bool): if True, raise an error if there is no <transport> element else ignore it
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
462 @raise exceptions.CancelError: the error is treated the calling method can cancel the treatment (i.e. return)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
463 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
464 contents_dict = session['contents']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
465 content_elts = jingle_elt.elements(NS_JINGLE, 'content')
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
466
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
467 for content_elt in content_elts:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
468 name = content_elt['name']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
469
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
470 if new:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
471 # the content must not exist, we check it
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
472 if not name or name in contents_dict:
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
473 self.sendError('bad-request', session['id'], request, profile=client.profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
474 raise exceptions.CancelError
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
475 content_data = contents_dict[name] = {'creator': creator,
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
476 'senders': content_elt.attributes.get('senders', 'both'),
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
477 }
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
478 else:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
479 # the content must exist, we check it
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
480 try:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
481 content_data = contents_dict[name]
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
482 except KeyError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
483 log.warning(u"Other peer try to access an unknown content")
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
484 self.sendError('bad-request', session['id'], request, profile=client.profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
485 raise exceptions.CancelError
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
486
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
487 # application
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
488 if with_application:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
489 desc_elt = content_elt.description
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
490 if not desc_elt:
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
491 self.sendError('bad-request', session['id'], request, profile=client.profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
492 raise exceptions.CancelError
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
493
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
494 if new:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
495 # the content is new, we need to check and link the application
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
496 app_ns = desc_elt.uri
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
497 if not app_ns or app_ns == NS_JINGLE:
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
498 self.sendError('bad-request', session['id'], request, profile=client.profile)
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
499 raise exceptions.CancelError
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
500
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
501 try:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
502 application = self._applications[app_ns]
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
503 except KeyError:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
504 log.warning(u"Unmanaged application namespace [{}]".format(app_ns))
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
505 self.sendError('service-unavailable', session['id'], request, profile=client.profile)
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
506 raise exceptions.CancelError
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
507
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
508 content_data['application'] = application
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
509 content_data['application_data'] = {}
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
510 else:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
511 # the content exists, we check that we have not a former desc_elt
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
512 if 'desc_elt' in content_data:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
513 raise exceptions.InternalError(u"desc_elt should not exist at this point")
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
514
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
515 content_data['desc_elt'] = desc_elt
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
516
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
517 # transport
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
518 if with_transport:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
519 transport_elt = content_elt.transport
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
520 if not transport_elt:
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
521 self.sendError('bad-request', session['id'], request, profile=client.profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
522 raise exceptions.CancelError
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
523
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
524 if new:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
525 # the content is new, we need to check and link the transport
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
526 transport_ns = transport_elt.uri
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
527 if not app_ns or app_ns == NS_JINGLE:
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
528 self.sendError('bad-request', session['id'], request, profile=client.profile)
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
529 raise exceptions.CancelError
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
530
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
531 try:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
532 transport = self._transports[transport_ns]
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
533 except KeyError:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
534 raise exceptions.InternalError(u"No transport registered for namespace {}".format(transport_ns))
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
535 content_data['transport'] = transport
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
536 content_data['transport_data'] = {}
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
537 else:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
538 # the content exists, we check that we have not a former transport_elt
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
539 if 'transport_elt' in content_data:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
540 raise exceptions.InternalError(u"desc_elt should not exist at this point")
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
541
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
542 content_data['transport_elt'] = transport_elt
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
543
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
544 def _callPlugins(self, action, session, app_method_name='jingleHandler', transp_method_name='jingleHandler', app_default_cb=None, transp_default_cb=None, delete=True, elements=True, profile=C.PROF_KEY_NONE):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
545 """Call application and transport plugin methods for all contents
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
546
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
547 @param action(unicode): jingle action name
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
548 @param session(dict): jingle session data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
549 @param app_method_name(unicode, None): name of the method to call for applications
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
550 None to ignore
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
551 @param transp_method_name(unicode, None): name of the method to call for transports
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
552 None to ignore
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
553 @param app_default_cb(callable, None): default callback to use if plugin has not app_method_name
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
554 None to raise an exception instead
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
555 @param transp_default_cb(callable, None): default callback to use if plugin has not transp_method_name
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
556 None to raise an exception instead
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
557 @param delete(bool): if True, remove desc_elt and transport_elt from session
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
558 ignored if elements is False
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
559 @param elements(bool): True if elements(desc_elt and tranport_elt) must be managed
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
560 must be True if _callPlugins is use in a request, and False if it used after a request (i.e. on <iq> result or error)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
561 @param profile(unicode): %(doc_profile)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
562 @return (list[defer.Deferred]): list of launched Deferred
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
563 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
564 contents_dict = session['contents']
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
565 defers_list = []
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
566 for content_name, content_data in contents_dict.iteritems():
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
567 for method_name, handler_key, default_cb, elt_name in (
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
568 (app_method_name, 'application', app_default_cb, 'desc_elt'),
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
569 (transp_method_name, 'transport', transp_default_cb, 'transport_elt')):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
570 if method_name is None:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
571 continue
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
572
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
573 handler = content_data[handler_key].handler
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
574 try:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
575 method = getattr(handler, method_name)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
576 except AttributeError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
577 if default_cb is not None:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
578 method = default_cb
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
579 else:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
580 raise exceptions.InternalError(u'{} not implemented !'.format(method_name))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
581 finally:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
582 if elements:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
583 elt = content_data.pop(elt_name) if delete else content_data[elt_name]
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
584 else:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
585 elt = None
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
586 d = defer.maybeDeferred(method, action, session, content_name, elt, profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
587 defers_list.append(d)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
588
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
589 return defers_list
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
590
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
591 def onSessionInitiate(self, client, request, jingle_elt, session):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
592 """Called on session-initiate action
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
593
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
594 The "jingleRequestConfirmation" method of each application will be called
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
595 (or self.jingleRequestConfirmationDefault if the former doesn't exist).
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
596 The session is only accepted if all application are confirmed.
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
597 The application must manage itself multiple contents scenari (e.g. audio/video).
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
598 @param client: %(doc_client)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
599 @param request(domish.Element): full request
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
600 @param jingle_elt(domish.Element): <jingle> element
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
601 @param session(dict): session data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
602 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
603 if 'contents' in session:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
604 raise exceptions.InternalError("Contents dict should not already exist at this point")
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
605 session['contents'] = contents_dict = {}
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
606
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
607 try:
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
608 self._parseElements(jingle_elt, session, request, client, True, XEP_0166.ROLE_INITIATOR)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
609 except exceptions.CancelError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
610 return
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
611
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
612 if not contents_dict:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
613 # there MUST be at least one content
1614
1ced93821c35 plugin XEP-0166: sendError now manage jingle conditions
Goffi <goffi@goffi.org>
parents: 1585
diff changeset
614 self.sendError('bad-request', session['id'], request, profile=client.profile)
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
615 return
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
616
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
617 # at this point we can send the <iq/> result to confirm reception of the request
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
618 client.xmlstream.send(xmlstream.toResponse(request, 'result'))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
619
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
620 # we now request each application plugin confirmation
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
621 # and if all are accepted, we can accept the session
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
622 confirm_defers = self._callPlugins(XEP_0166.A_SESSION_INITIATE, session, 'jingleRequestConfirmation', None, self.jingleRequestConfirmationDefault, delete=False, profile=client.profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
623
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
624 confirm_dlist = defer.gatherResults(confirm_defers)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
625 confirm_dlist.addCallback(self._confirmationCb, session, jingle_elt, client)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
626 confirm_dlist.addErrback(self._jingleErrorCb, session['id'], request, client)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
627
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
628 def _confirmationCb(self, confirm_results, session, jingle_elt, client):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
629 """Method called when confirmation from user has been received
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
630
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
631 This method is only called for the responder
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
632 @param confirm_results(list[bool]): all True if session is accepted
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
633 @param session(dict): session data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
634 @param jingle_elt(domish.Element): jingle data of this session
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
635 @param client: %(doc_client)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
636 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
637 confirmed = all(confirm_results)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
638 if not confirmed:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
639 return self.terminate(XEP_0166.REASON_DECLINE, session, client.profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
640
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
641 iq_elt, jingle_elt = self._buildJingleElt(client, session, XEP_0166.A_SESSION_ACCEPT)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
642 jingle_elt['responder'] = client.jid.full()
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
643
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
644 # contents
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
645
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
646 def addElement(domish_elt, content_elt):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
647 content_elt.addChild(domish_elt)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
648
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
649 defers_list = []
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
650
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
651 for content_name, content_data in session['contents'].iteritems():
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
652 content_elt = jingle_elt.addElement('content')
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
653 content_elt['creator'] = XEP_0166.ROLE_INITIATOR
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
654 content_elt['name'] = content_name
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
655
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
656 application = content_data['application']
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
657 app_session_accept_cb = application.handler.jingleHandler
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
658
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
659 app_d = defer.maybeDeferred(app_session_accept_cb,
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
660 XEP_0166.A_SESSION_INITIATE, session, content_name, content_data.pop('desc_elt'), client.profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
661 app_d.addCallback(addElement, content_elt)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
662 defers_list.append(app_d)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
663
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
664 transport = content_data['transport']
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
665 transport_session_accept_cb = transport.handler.jingleHandler
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
666
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
667 transport_d = defer.maybeDeferred(transport_session_accept_cb,
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
668 XEP_0166.A_SESSION_INITIATE, session, content_name, content_data.pop('transport_elt'), client.profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
669 transport_d.addCallback(addElement, content_elt)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
670 defers_list.append(transport_d)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
671
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
672 d_list = defer.DeferredList(defers_list)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
673 d_list.addCallback(lambda dummy: self._callPlugins(XEP_0166.A_PREPARE_RESPONDER, session, app_method_name=None, elements=False, profile=client.profile))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
674 d_list.addCallback(lambda dummy: iq_elt.send())
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
675 def changeState(dummy, session):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
676 session['state'] = STATE_ACTIVE
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
677
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
678 d_list.addCallback(changeState, session)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
679 d_list.addCallback(lambda dummy: self._callPlugins(XEP_0166.A_ACCEPTED_ACK, session, elements=False, profile=client.profile))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
680 d_list.addErrback(self._iqError, session['id'], client)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
681 return d_list
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
682
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
683 def onSessionTerminate(self, client, request, jingle_elt, session):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
684 # TODO: check reason, display a message to user if needed
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
685 log.debug("Jingle Session {} terminated".format(session['id']))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
686 self._delSession(client, session['id'])
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
687 client.xmlstream.send(xmlstream.toResponse(request, 'result'))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
688
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
689 def onSessionAccept(self, client, request, jingle_elt, session):
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
690 """Method called once session is accepted
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
691
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
692 This method is only called for initiator
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
693 @param client: %(doc_client)s
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
694 @param request(domish.Element): full <iq> request
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
695 @param jingle_elt(domish.Element): the <jingle> element
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
696 @param session(dict): session data
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
697 """
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
698 log.debug(u"Jingle session {} has been accepted".format(session['id']))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
699
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
700 try:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
701 self._parseElements(jingle_elt, session, request, client)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
702 except exceptions.CancelError:
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
703 return
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
704
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
705 # at this point we can send the <iq/> result to confirm reception of the request
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
706 client.xmlstream.send(xmlstream.toResponse(request, 'result'))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
707 # and change the state
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
708 session['state'] = STATE_ACTIVE
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
709
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
710 negociate_defers = []
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
711 negociate_defers = self._callPlugins(XEP_0166.A_SESSION_ACCEPT, session, profile=client.profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
712
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
713 negociate_dlist = defer.DeferredList(negociate_defers)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
714
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
715 # after negociations we start the transfer
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
716 negociate_dlist.addCallback(lambda dummy: self._callPlugins(XEP_0166.A_START, session, app_method_name=None, elements=False, profile=client.profile))
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
717
1556
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
718 def onTransportInfo(self, client, request, jingle_elt, session):
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
719 """Method called when a transport-info action is received from other peer
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
720
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
721 The request is parsed, and jingleHandler is called on concerned transport plugin(s)
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
722 @param client: %(doc_client)s
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
723 @param request(domish.Element): full <iq> request
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
724 @param jingle_elt(domish.Element): the <jingle> element
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
725 @param session(dict): session data
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
726 """
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
727 log.debug(u"Jingle session {} has been accepted".format(session['id']))
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
728
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
729 try:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
730 self._parseElements(jingle_elt, session, request, client, with_application=False)
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
731 except exceptions.CancelError:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
732 return
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
733
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
734 # The parsing was OK, we send the <iq> result
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
735 client.xmlstream.send(xmlstream.toResponse(request, 'result'))
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
736
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
737 for content_name, content_data in session['contents'].iteritems():
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
738 try:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
739 transport_elt = content_data.pop('transport_elt')
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
740 except KeyError:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
741 continue
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
742 else:
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
743 content_data['transport'].handler.jingleHandler(XEP_0166.A_TRANSPORT_INFO, session, content_name, transport_elt, client.profile)
cbfbe028d099 plugin XEP-0166, XEP-0234, XEP-0261:
Goffi <goffi@goffi.org>
parents: 1523
diff changeset
744
1523
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
745
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
746 class XEP_0166_handler(xmlstream.XMPPHandler):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
747 implements(iwokkel.IDisco)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
748
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
749 def __init__(self, plugin_parent):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
750 self.plugin_parent = plugin_parent
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
751
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
752 def connectionInitialized(self):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
753 self.xmlstream.addObserver(JINGLE_REQUEST, self.plugin_parent._onJingleRequest, profile=self.parent.profile)
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
754
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
755 def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
756 return [disco.DiscoFeature(NS_JINGLE)]
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
757
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
758 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
0209f8d35873 plugin XEP-0166: (jingle) first draft. Not all actions are managed yet
Goffi <goffi@goffi.org>
parents:
diff changeset
759 return []