diff options
author | Louis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk> | 2010-10-21 17:11:37 -0400 |
---|---|---|
committer | Louis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk> | 2010-12-03 15:50:39 -0500 |
commit | a2914aa8294c93cc404e323f56cb02e623e4787c (patch) | |
tree | 9cee897113ae5ddfa0a6d3b58becd6ad1e3978f9 /butterfly | |
parent | 68e6aa2dd7f1adcb2f0741db2b5d9b9d71f070aa (diff) |
media: make sure the call is disposed and ended only once
Diffstat (limited to 'butterfly')
-rw-r--r-- | butterfly/channel/media.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/butterfly/channel/media.py b/butterfly/channel/media.py index 3ffb2fd..b2b64d6 100644 --- a/butterfly/channel/media.py +++ b/butterfly/channel/media.py @@ -104,7 +104,8 @@ class ButterflyMediaChannel( def Close(self): logger.info("Channel closed by client") - self._call.end() + if self._call: + self._call.end() def GetSessionHandlers(self): return [(self._session_handler, self._session_handler.subtype)] @@ -123,6 +124,11 @@ class ButterflyMediaChannel( self._handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, handle) streams = dbus.Array([], signature="a(uuuuuu)") + + if self._call is None: + logger.warning("Call has already been closed") + return streams + for type in types: handler = self._session_handler.CreateStream(type, 3) handler.connect("state-changed", self.on_stream_state_changed) @@ -188,6 +194,7 @@ class ButterflyMediaChannel( #papyon.event.call.CallEventInterface def on_call_ended(self): logger.info("Call has ended") + self._call = None telepathy.server.ChannelTypeStreamedMedia.Close(self) self._session_handler.remove_from_connection() @@ -218,7 +225,7 @@ class ButterflyMediaChannel( #papyon.event.media.ContactEventInterface def on_contact_presence_changed(self, contact): - if contact == self._call.peer and \ + if self._call is not None and contact == self._call.peer and \ contact.presence == papyon.Presence.OFFLINE: logger.info("%s is now offline, closing channel" % contact) self.Close() @@ -228,7 +235,8 @@ class ButterflyMediaChannel( self.StreamError(handler.id, error, message) # TODO: properly remove the stream without ending the whole # call unless it was the last stream of the session. - self._call.end() + if self._call is not None: + self._call.end() #StreamHandler event def on_stream_state_changed(self, handler, state): |