A little fix with content acceptance ; modified a bit JINGLE_DISCONNECTED

This commit is contained in:
Thibaut GIRKA 2009-09-26 14:14:58 +02:00
parent 08b7f18f50
commit b5c7519740
2 changed files with 19 additions and 9 deletions

View File

@ -364,7 +364,11 @@ class JingleSession(object):
creator = content['creator'] creator = content['creator']
name = content['name'] name = content['name']
if (creator, name) in self.contents: if (creator, name) in self.contents:
self.contents[(creator, name)].destroy() content = self.contents[(creator, name)]
#TODO: this will fail if content is not an RTP content
self.connection.dispatch('JINGLE_DISCONNECTED',
(self.peerjid, self.sid, content.media, 'removed'))
content.destroy()
if len(self.contents) == 0: if len(self.contents) == 0:
reason = xmpp.Node('reason') reason = xmpp.Node('reason')
reason.setTag('success') reason.setTag('success')
@ -399,7 +403,7 @@ class JingleSession(object):
self.__content_reject(content) self.__content_reject(content)
self.contents[(content.creator, content.name)].destroy() self.contents[(content.creator, content.name)].destroy()
self.connection.dispatch('JINGLE_INCOMING', (self.initiator, self.sid, self.connection.dispatch('JINGLE_INCOMING', (self.peerjid, self.sid,
contents)) contents))
def __sessionInitiateCB(self, stanza, jingle, error, action): def __sessionInitiateCB(self, stanza, jingle, error, action):
@ -442,7 +446,7 @@ class JingleSession(object):
self.state = JingleStates.pending self.state = JingleStates.pending
# Send event about starting a session # Send event about starting a session
self.connection.dispatch('JINGLE_INCOMING', (self.initiator, self.sid, self.connection.dispatch('JINGLE_INCOMING', (self.peerjid, self.sid,
contents)) contents))
def __broadcastCB(self, stanza, jingle, error, action): def __broadcastCB(self, stanza, jingle, error, action):
@ -462,7 +466,8 @@ class JingleSession(object):
text = '%s (%s)' % (reason, text) text = '%s (%s)' % (reason, text)
else: else:
text = reason#TODO text = reason#TODO
self.connection.dispatch('JINGLE_DISCONNECTED', (self.peerjid, self.sid, text)) self.connection.dispatch('JINGLE_DISCONNECTED',
(self.peerjid, self.sid, None, text))
def __broadcastAllCB(self, stanza, jingle, error, action): def __broadcastAllCB(self, stanza, jingle, error, action):
''' Broadcast the stanza to all content handlers. ''' ''' Broadcast the stanza to all content handlers. '''
@ -598,7 +603,8 @@ class JingleSession(object):
else: else:
text = reason text = reason
self.connection.delete_jingle(self) self.connection.delete_jingle(self)
self.connection.dispatch('JINGLE_DISCONNECTED', (self.peerjid, self.sid, text)) self.connection.dispatch('JINGLE_DISCONNECTED',
(self.peerjid, self.sid, None, text))
def __content_add(self, content): def __content_add(self, content):
#TODO: test #TODO: test
@ -630,7 +636,9 @@ class JingleSession(object):
stanza, jingle = self.__make_jingle('content-remove') stanza, jingle = self.__make_jingle('content-remove')
self.__append_content(jingle, content) self.__append_content(jingle, content)
self.connection.connection.send(stanza) self.connection.connection.send(stanza)
#TODO: dispatch something? #TODO: this will fail if content is not an RTP content
self.connection.dispatch('JINGLE_DISCONNECTED',
(self.peerjid, self.sid, content.media, 'removed'))
def content_negociated(self, media): def content_negociated(self, media):
self.connection.dispatch('JINGLE_CONNECTED', (self.peerjid, self.sid, self.connection.dispatch('JINGLE_CONNECTED', (self.peerjid, self.sid,

View File

@ -2164,15 +2164,17 @@ class Interface:
def handle_event_jingle_disconnected(self, account, data): def handle_event_jingle_disconnected(self, account, data):
# ('JINGLE_DISCONNECTED', account, (peerjid, sid, reason)) # ('JINGLE_DISCONNECTED', account, (peerjid, sid, reason))
peerjid, sid, reason = data peerjid, sid, media, reason = data
jid = gajim.get_jid_without_resource(peerjid) jid = gajim.get_jid_without_resource(peerjid)
resource = gajim.get_resource_from_jid(peerjid) resource = gajim.get_resource_from_jid(peerjid)
ctrl = self.msg_win_mgr.get_control(peerjid, account) ctrl = self.msg_win_mgr.get_control(peerjid, account)
if not ctrl: if not ctrl:
ctrl = self.msg_win_mgr.get_control(jid, account) ctrl = self.msg_win_mgr.get_control(jid, account)
if ctrl: if ctrl:
ctrl.set_audio_state('stop', sid=sid, reason=reason) if media in ('audio', None):
ctrl.set_video_state('stop', sid=sid, reason=reason) ctrl.set_audio_state('stop', sid=sid, reason=reason)
if media in ('video', None):
ctrl.set_video_state('stop', sid=sid, reason=reason)
dialog = dialogs.VoIPCallReceivedDialog.get_dialog(peerjid, sid) dialog = dialogs.VoIPCallReceivedDialog.get_dialog(peerjid, sid)
if dialog: if dialog:
dialog.dialog.destroy() dialog.dialog.destroy()