[Jingle] Renamed callbacks to match name conventions
This commit is contained in:
parent
0edb624fec
commit
ee452a57a2
|
@ -86,7 +86,7 @@ class ConnectionJingle(object):
|
||||||
id = stanza.getID()
|
id = stanza.getID()
|
||||||
|
|
||||||
if (jid, id) in self.__iq_responses.keys():
|
if (jid, id) in self.__iq_responses.keys():
|
||||||
self.__iq_responses[(jid, id)].stanzaCB(stanza)
|
self.__iq_responses[(jid, id)].on_stanza(stanza)
|
||||||
del self.__iq_responses[(jid, id)]
|
del self.__iq_responses[(jid, id)]
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class ConnectionJingle(object):
|
||||||
self.add_jingle(newjingle)
|
self.add_jingle(newjingle)
|
||||||
|
|
||||||
# we already have such session in dispatcher...
|
# we already have such session in dispatcher...
|
||||||
self.__sessions[(jid, sid)].stanzaCB(stanza)
|
self.__sessions[(jid, sid)].on_stanza(stanza)
|
||||||
|
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
|
||||||
|
|
|
@ -48,18 +48,18 @@ class JingleContent(object):
|
||||||
|
|
||||||
self.callbacks = {
|
self.callbacks = {
|
||||||
# these are called when *we* get stanzas
|
# these are called when *we* get stanzas
|
||||||
'content-accept': [self.__transportInfoCB],
|
'content-accept': [self.__on_transport_info],
|
||||||
'content-add': [self.__transportInfoCB],
|
'content-add': [self.__on_transport_info],
|
||||||
'content-modify': [],
|
'content-modify': [],
|
||||||
'content-reject': [],
|
'content-reject': [],
|
||||||
'content-remove': [],
|
'content-remove': [],
|
||||||
'description-info': [],
|
'description-info': [],
|
||||||
'security-info': [],
|
'security-info': [],
|
||||||
'session-accept': [self.__transportInfoCB],
|
'session-accept': [self.__on_transport_info],
|
||||||
'session-info': [],
|
'session-info': [],
|
||||||
'session-initiate': [self.__transportInfoCB],
|
'session-initiate': [self.__on_transport_info],
|
||||||
'session-terminate': [],
|
'session-terminate': [],
|
||||||
'transport-info': [self.__transportInfoCB],
|
'transport-info': [self.__on_transport_info],
|
||||||
'transport-replace': [],
|
'transport-replace': [],
|
||||||
'transport-accept': [],
|
'transport-accept': [],
|
||||||
'transport-reject': [],
|
'transport-reject': [],
|
||||||
|
@ -82,7 +82,7 @@ class JingleContent(object):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def stanzaCB(self, stanza, content, error, action):
|
def on_stanza(self, stanza, content, error, action):
|
||||||
"""
|
"""
|
||||||
Called when something related to our content was sent by peer
|
Called when something related to our content was sent by peer
|
||||||
"""
|
"""
|
||||||
|
@ -90,7 +90,7 @@ class JingleContent(object):
|
||||||
for callback in self.callbacks[action]:
|
for callback in self.callbacks[action]:
|
||||||
callback(stanza, content, error, action)
|
callback(stanza, content, error, action)
|
||||||
|
|
||||||
def __transportInfoCB(self, stanza, content, error, action):
|
def __on_transport_info(self, stanza, content, error, action):
|
||||||
"""
|
"""
|
||||||
Got a new transport candidate
|
Got a new transport candidate
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -47,14 +47,14 @@ class JingleRTPContent(JingleContent):
|
||||||
|
|
||||||
self.candidates_ready = False # True when local candidates are prepared
|
self.candidates_ready = False # True when local candidates are prepared
|
||||||
|
|
||||||
self.callbacks['session-initiate'] += [self.__getRemoteCodecsCB]
|
self.callbacks['session-initiate'] += [self.__on_remote_codecs]
|
||||||
self.callbacks['content-add'] += [self.__getRemoteCodecsCB]
|
self.callbacks['content-add'] += [self.__on_remote_codecs]
|
||||||
self.callbacks['content-accept'] += [self.__getRemoteCodecsCB,
|
self.callbacks['content-accept'] += [self.__on_remote_codecs,
|
||||||
self.__contentAcceptCB]
|
self.__on_content_accept]
|
||||||
self.callbacks['session-accept'] += [self.__getRemoteCodecsCB,
|
self.callbacks['session-accept'] += [self.__on_remote_codecs,
|
||||||
self.__contentAcceptCB]
|
self.__on_content_accept]
|
||||||
self.callbacks['session-accept-sent'] += [self.__contentAcceptCB]
|
self.callbacks['session-accept-sent'] += [self.__on_content_accept]
|
||||||
self.callbacks['content-accept-sent'] += [self.__contentAcceptCB]
|
self.callbacks['content-accept-sent'] += [self.__on_content_accept]
|
||||||
self.callbacks['session-terminate'] += [self.__stop]
|
self.callbacks['session-terminate'] += [self.__stop]
|
||||||
self.callbacks['session-terminate-sent'] += [self.__stop]
|
self.callbacks['session-terminate-sent'] += [self.__stop]
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ class JingleRTPContent(JingleContent):
|
||||||
else:
|
else:
|
||||||
print name
|
print name
|
||||||
|
|
||||||
def __contentAcceptCB(self, stanza, content, error, action):
|
def __on_content_accept(self, stanza, content, error, action):
|
||||||
if self.accepted:
|
if self.accepted:
|
||||||
if self.transport.remote_candidates:
|
if self.transport.remote_candidates:
|
||||||
self.p2pstream.set_remote_candidates(self.transport.remote_candidates)
|
self.p2pstream.set_remote_candidates(self.transport.remote_candidates)
|
||||||
|
@ -181,7 +181,7 @@ class JingleRTPContent(JingleContent):
|
||||||
self.p2pstream.set_property('direction', farsight.DIRECTION_BOTH)
|
self.p2pstream.set_property('direction', farsight.DIRECTION_BOTH)
|
||||||
self.session.content_negociated(self.media)
|
self.session.content_negociated(self.media)
|
||||||
|
|
||||||
def __getRemoteCodecsCB(self, stanza, content, error, action):
|
def __on_remote_codecs(self, stanza, content, error, action):
|
||||||
''' Get peer codecs from what we get from peer. '''
|
''' Get peer codecs from what we get from peer. '''
|
||||||
if self.got_codecs:
|
if self.got_codecs:
|
||||||
return
|
return
|
||||||
|
|
|
@ -89,28 +89,28 @@ class JingleSession(object):
|
||||||
# use .prepend() to add new callbacks, especially when you're going
|
# use .prepend() to add new callbacks, especially when you're going
|
||||||
# to send error instead of ack
|
# to send error instead of ack
|
||||||
self.callbacks = {
|
self.callbacks = {
|
||||||
'content-accept': [self.__contentAcceptCB, self.__broadcastCB,
|
'content-accept': [self.__on_content_accept, self.__broadcast,
|
||||||
self.__defaultCB],
|
self.__ack],
|
||||||
'content-add': [self.__contentAddCB, self.__broadcastCB,
|
'content-add': [self.__on_content_add, self.__broadcast,
|
||||||
self.__defaultCB], #TODO
|
self.__ack], #TODO
|
||||||
'content-modify': [self.__defaultCB], #TODO
|
'content-modify': [self.__ack], #TODO
|
||||||
'content-reject': [self.__defaultCB, self.__contentRemoveCB], #TODO
|
'content-reject': [self.__ack, self.__on_content_remove], #TODO
|
||||||
'content-remove': [self.__defaultCB, self.__contentRemoveCB],
|
'content-remove': [self.__ack, self.__on_content_remove],
|
||||||
'description-info': [self.__broadcastCB, self.__defaultCB], #TODO
|
'description-info': [self.__broadcast, self.__ack], #TODO
|
||||||
'security-info': [self.__defaultCB], #TODO
|
'security-info': [self.__ack], #TODO
|
||||||
'session-accept': [self.__sessionAcceptCB, self.__contentAcceptCB,
|
'session-accept': [self.__on_session_accept, self.__on_content_accept,
|
||||||
self.__broadcastCB, self.__defaultCB],
|
self.__broadcast, self.__ack],
|
||||||
'session-info': [self.__sessionInfoCB, self.__broadcastCB, self.__defaultCB],
|
'session-info': [self.__on_session_info, self.__broadcast, self.__ack],
|
||||||
'session-initiate': [self.__sessionInitiateCB, self.__broadcastCB,
|
'session-initiate': [self.__on_session_initiate, self.__broadcast,
|
||||||
self.__defaultCB],
|
self.__ack],
|
||||||
'session-terminate': [self.__sessionTerminateCB, self.__broadcastAllCB,
|
'session-terminate': [self.__on_session_terminate, self.__broadcast_all,
|
||||||
self.__defaultCB],
|
self.__ack],
|
||||||
'transport-info': [self.__broadcastCB, self.__defaultCB],
|
'transport-info': [self.__broadcast, self.__ack],
|
||||||
'transport-replace': [self.__broadcastCB, self.__transportReplaceCB], #TODO
|
'transport-replace': [self.__broadcast, self.__on_transport_replace], #TODO
|
||||||
'transport-accept': [self.__defaultCB], #TODO
|
'transport-accept': [self.__ack], #TODO
|
||||||
'transport-reject': [self.__defaultCB], #TODO
|
'transport-reject': [self.__ack], #TODO
|
||||||
'iq-result': [],
|
'iq-result': [],
|
||||||
'iq-error': [self.__errorCB],
|
'iq-error': [self.__on_error],
|
||||||
}
|
}
|
||||||
|
|
||||||
def approve_session(self):
|
def approve_session(self):
|
||||||
|
@ -262,7 +262,7 @@ class JingleSession(object):
|
||||||
jingle.addChild(node=content)
|
jingle.addChild(node=content)
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
|
|
||||||
def stanzaCB(self, stanza):
|
def on_stanza(self, stanza):
|
||||||
"""
|
"""
|
||||||
A callback for ConnectionJingle. It gets stanza, then tries to send it to
|
A callback for ConnectionJingle. It gets stanza, then tries to send it to
|
||||||
all internally registered callbacks. First one to raise
|
all internally registered callbacks. First one to raise
|
||||||
|
@ -300,14 +300,14 @@ class JingleSession(object):
|
||||||
# FIXME
|
# FIXME
|
||||||
self.__send_error(stanza, 'unexpected-request', 'out-of-order')
|
self.__send_error(stanza, 'unexpected-request', 'out-of-order')
|
||||||
|
|
||||||
def __defaultCB(self, stanza, jingle, error, action):
|
def __ack(self, stanza, jingle, error, action):
|
||||||
"""
|
"""
|
||||||
Default callback for action stanzas -- simple ack and stop processing
|
Default callback for action stanzas -- simple ack and stop processing
|
||||||
"""
|
"""
|
||||||
response = stanza.buildReply('result')
|
response = stanza.buildReply('result')
|
||||||
self.connection.connection.send(response)
|
self.connection.connection.send(response)
|
||||||
|
|
||||||
def __errorCB(self, stanza, jingle, error, action):
|
def __on_error(self, stanza, jingle, error, action):
|
||||||
# FIXME
|
# FIXME
|
||||||
text = error.getTagData('text')
|
text = error.getTagData('text')
|
||||||
jingle_error = None
|
jingle_error = None
|
||||||
|
@ -322,7 +322,7 @@ class JingleSession(object):
|
||||||
if xmpp_error == 'item-not-found':
|
if xmpp_error == 'item-not-found':
|
||||||
self.connection.delete_jingle_session(self.peerjid, self.sid)
|
self.connection.delete_jingle_session(self.peerjid, self.sid)
|
||||||
|
|
||||||
def __transportReplaceCB(self, stanza, jingle, error, action):
|
def __on_transport_replace(self, stanza, jingle, error, action):
|
||||||
for content in jingle.iterTags('content'):
|
for content in jingle.iterTags('content'):
|
||||||
creator = content['creator']
|
creator = content['creator']
|
||||||
name = content['name']
|
name = content['name']
|
||||||
|
@ -350,14 +350,14 @@ class JingleSession(object):
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
|
||||||
def __sessionInfoCB(self, stanza, jingle, error, action):
|
def __on_session_info(self, stanza, jingle, error, action):
|
||||||
# TODO: ringing, active, (un)hold, (un)mute
|
# TODO: ringing, active, (un)hold, (un)mute
|
||||||
payload = jingle.getPayload()
|
payload = jingle.getPayload()
|
||||||
if len(payload) > 0:
|
if len(payload) > 0:
|
||||||
self.__send_error(stanza, 'feature-not-implemented', 'unsupported-info')
|
self.__send_error(stanza, 'feature-not-implemented', 'unsupported-info')
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
|
||||||
def __contentRemoveCB(self, stanza, jingle, error, action):
|
def __on_content_remove(self, stanza, jingle, error, action):
|
||||||
for content in jingle.iterTags('content'):
|
for content in jingle.iterTags('content'):
|
||||||
creator = content['creator']
|
creator = content['creator']
|
||||||
name = content['name']
|
name = content['name']
|
||||||
|
@ -372,13 +372,13 @@ class JingleSession(object):
|
||||||
reason.setTag('success')
|
reason.setTag('success')
|
||||||
self._session_terminate(reason)
|
self._session_terminate(reason)
|
||||||
|
|
||||||
def __sessionAcceptCB(self, stanza, jingle, error, action):
|
def __on_session_accept(self, stanza, jingle, error, action):
|
||||||
# FIXME
|
# FIXME
|
||||||
if self.state != JingleStates.pending:
|
if self.state != JingleStates.pending:
|
||||||
raise OutOfOrder
|
raise OutOfOrder
|
||||||
self.state = JingleStates.active
|
self.state = JingleStates.active
|
||||||
|
|
||||||
def __contentAcceptCB(self, stanza, jingle, error, action):
|
def __on_content_accept(self, stanza, jingle, error, action):
|
||||||
"""
|
"""
|
||||||
Called when we get content-accept stanza or equivalent one (like
|
Called when we get content-accept stanza or equivalent one (like
|
||||||
session-accept)
|
session-accept)
|
||||||
|
@ -389,7 +389,7 @@ class JingleSession(object):
|
||||||
# TODO
|
# TODO
|
||||||
name = content['name']
|
name = content['name']
|
||||||
|
|
||||||
def __contentAddCB(self, stanza, jingle, error, action):
|
def __on_content_add(self, stanza, jingle, error, action):
|
||||||
if self.state == JingleStates.ended:
|
if self.state == JingleStates.ended:
|
||||||
raise OutOfOrder
|
raise OutOfOrder
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ class JingleSession(object):
|
||||||
self.connection.dispatch('JINGLE_INCOMING', (self.peerjid, self.sid,
|
self.connection.dispatch('JINGLE_INCOMING', (self.peerjid, self.sid,
|
||||||
contents))
|
contents))
|
||||||
|
|
||||||
def __sessionInitiateCB(self, stanza, jingle, error, action):
|
def __on_session_initiate(self, stanza, jingle, error, action):
|
||||||
"""
|
"""
|
||||||
We got a jingle session request from other entity, therefore we are the
|
We got a jingle session request from other entity, therefore we are the
|
||||||
receiver... Unpack the data, inform the user
|
receiver... Unpack the data, inform the user
|
||||||
|
@ -433,7 +433,7 @@ class JingleSession(object):
|
||||||
# TODO: http://xmpp.org/extensions/xep-0166.html#session-terminate
|
# TODO: http://xmpp.org/extensions/xep-0166.html#session-terminate
|
||||||
reason = xmpp.Node('reason')
|
reason = xmpp.Node('reason')
|
||||||
reason.setTag('unsupported-applications')
|
reason.setTag('unsupported-applications')
|
||||||
self.__defaultCB(stanza, jingle, error, action)
|
self.__ack(stanza, jingle, error, action)
|
||||||
self._session_terminate(reason)
|
self._session_terminate(reason)
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ class JingleSession(object):
|
||||||
# TODO: http://xmpp.org/extensions/xep-0166.html#session-terminate
|
# TODO: http://xmpp.org/extensions/xep-0166.html#session-terminate
|
||||||
reason = xmpp.Node('reason')
|
reason = xmpp.Node('reason')
|
||||||
reason.setTag('unsupported-transports')
|
reason.setTag('unsupported-transports')
|
||||||
self.__defaultCB(stanza, jingle, error, action)
|
self.__ack(stanza, jingle, error, action)
|
||||||
self._session_terminate(reason)
|
self._session_terminate(reason)
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ class JingleSession(object):
|
||||||
self.connection.dispatch('JINGLE_INCOMING', (self.peerjid, self.sid,
|
self.connection.dispatch('JINGLE_INCOMING', (self.peerjid, self.sid,
|
||||||
contents))
|
contents))
|
||||||
|
|
||||||
def __broadcastCB(self, stanza, jingle, error, action):
|
def __broadcast(self, stanza, jingle, error, action):
|
||||||
"""
|
"""
|
||||||
Broadcast the stanza contents to proper content handlers
|
Broadcast the stanza contents to proper content handlers
|
||||||
"""
|
"""
|
||||||
|
@ -459,9 +459,9 @@ class JingleSession(object):
|
||||||
name = content['name']
|
name = content['name']
|
||||||
creator = content['creator']
|
creator = content['creator']
|
||||||
cn = self.contents[(creator, name)]
|
cn = self.contents[(creator, name)]
|
||||||
cn.stanzaCB(stanza, content, error, action)
|
cn.on_stanza(stanza, content, error, action)
|
||||||
|
|
||||||
def __sessionTerminateCB(self, stanza, jingle, error, action):
|
def __on_session_terminate(self, stanza, jingle, error, action):
|
||||||
self.connection.delete_jingle_session(self.peerjid, self.sid)
|
self.connection.delete_jingle_session(self.peerjid, self.sid)
|
||||||
reason, text = self.__reason_from_stanza(jingle)
|
reason, text = self.__reason_from_stanza(jingle)
|
||||||
if reason not in ('success', 'cancel', 'decline'):
|
if reason not in ('success', 'cancel', 'decline'):
|
||||||
|
@ -473,12 +473,12 @@ class JingleSession(object):
|
||||||
self.connection.dispatch('JINGLE_DISCONNECTED',
|
self.connection.dispatch('JINGLE_DISCONNECTED',
|
||||||
(self.peerjid, self.sid, None, text))
|
(self.peerjid, self.sid, None, text))
|
||||||
|
|
||||||
def __broadcastAllCB(self, stanza, jingle, error, action):
|
def __broadcast_all(self, stanza, jingle, error, action):
|
||||||
"""
|
"""
|
||||||
Broadcast the stanza to all content handlers
|
Broadcast the stanza to all content handlers
|
||||||
"""
|
"""
|
||||||
for content in self.contents.itervalues():
|
for content in self.contents.itervalues():
|
||||||
content.stanzaCB(stanza, None, error, action)
|
content.on_stanza(stanza, None, error, action)
|
||||||
|
|
||||||
def __parse_contents(self, jingle):
|
def __parse_contents(self, jingle):
|
||||||
#TODO: Needs some reworking
|
#TODO: Needs some reworking
|
||||||
|
@ -572,7 +572,7 @@ class JingleSession(object):
|
||||||
assert self.state == JingleStates.ended
|
assert self.state == JingleStates.ended
|
||||||
stanza, jingle = self.__make_jingle('session-initiate')
|
stanza, jingle = self.__make_jingle('session-initiate')
|
||||||
self.__append_contents(jingle)
|
self.__append_contents(jingle)
|
||||||
self.__broadcastCB(stanza, jingle, None, 'session-initiate-sent')
|
self.__broadcast(stanza, jingle, None, 'session-initiate-sent')
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
self.state = JingleStates.pending
|
self.state = JingleStates.pending
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ class JingleSession(object):
|
||||||
assert self.state == JingleStates.pending
|
assert self.state == JingleStates.pending
|
||||||
stanza, jingle = self.__make_jingle('session-accept')
|
stanza, jingle = self.__make_jingle('session-accept')
|
||||||
self.__append_contents(jingle)
|
self.__append_contents(jingle)
|
||||||
self.__broadcastCB(stanza, jingle, None, 'session-accept-sent')
|
self.__broadcast(stanza, jingle, None, 'session-accept-sent')
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
self.state = JingleStates.active
|
self.state = JingleStates.active
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ class JingleSession(object):
|
||||||
stanza, jingle = self.__make_jingle('session-terminate')
|
stanza, jingle = self.__make_jingle('session-terminate')
|
||||||
if reason is not None:
|
if reason is not None:
|
||||||
jingle.addChild(node=reason)
|
jingle.addChild(node=reason)
|
||||||
self.__broadcastAllCB(stanza, jingle, None, 'session-terminate-sent')
|
self.__broadcast_all(stanza, jingle, None, 'session-terminate-sent')
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
reason, text = self.__reason_from_stanza(jingle)
|
reason, text = self.__reason_from_stanza(jingle)
|
||||||
if reason not in ('success', 'cancel', 'decline'):
|
if reason not in ('success', 'cancel', 'decline'):
|
||||||
|
@ -614,7 +614,7 @@ class JingleSession(object):
|
||||||
assert self.state != JingleStates.ended
|
assert self.state != JingleStates.ended
|
||||||
stanza, jingle = self.__make_jingle('content-add')
|
stanza, jingle = self.__make_jingle('content-add')
|
||||||
self.__append_content(jingle, content)
|
self.__append_content(jingle, content)
|
||||||
self.__broadcastCB(stanza, jingle, None, 'content-add-sent')
|
self.__broadcast(stanza, jingle, None, 'content-add-sent')
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
|
|
||||||
def __content_accept(self, content):
|
def __content_accept(self, content):
|
||||||
|
@ -622,7 +622,7 @@ class JingleSession(object):
|
||||||
assert self.state != JingleStates.ended
|
assert self.state != JingleStates.ended
|
||||||
stanza, jingle = self.__make_jingle('content-accept')
|
stanza, jingle = self.__make_jingle('content-accept')
|
||||||
self.__append_content(jingle, content)
|
self.__append_content(jingle, content)
|
||||||
self.__broadcastCB(stanza, jingle, None, 'content-accept-sent')
|
self.__broadcast(stanza, jingle, None, 'content-accept-sent')
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
|
|
||||||
def __content_reject(self, content):
|
def __content_reject(self, content):
|
||||||
|
|
Loading…
Reference in New Issue