Skip to content

Commit

Permalink
Stop ringing imediatelly when cancelling a proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
adigeo committed Oct 7, 2011
1 parent 6d02601 commit bbacd22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 11 additions & 5 deletions SessionController.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,17 @@ def endStream(self, streamHandler):

def cancelProposal(self, stream):
if self.session:
self.cancelledStream = stream
try:
self.session.cancel_proposal()
except IllegalStateError, e:
self.log_info("IllegalStateError: %s" % e)
if self.canCancelProposal():
self.log_info("Cancelling proposal...")
self.cancelledStream = stream
try:
self.session.cancel_proposal()
self.notification_center.post_notification("BlinkWillCancelProposal", sender=self.session)

except IllegalStateError, e:
self.log_info("IllegalStateError: %s" % e)
else:
self.log_info("Cancelling proposal is already in progress")

@property
def ended(self):
Expand Down
5 changes: 4 additions & 1 deletion SessionRinger.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def start(self):
notification_center.add_observer(self, name="CFGSettingsObjectDidChange")
notification_center.add_observer(self, name="ChatViewControllerDidDisplayMessage")
notification_center.add_observer(self, name="ConferenceHasAddedAudio")
notification_center.add_observer(self, name="BlinkWillCancelProposal")

self.started = True

def stop(self):
Expand All @@ -81,6 +83,7 @@ def stop(self):
notification_center.remove_observer(self, name="CFGSettingsObjectDidChange")
notification_center.remove_observer(self, name="ChatViewControllerDidDisplayMessage")
notification_center.remove_observer(self, name="ConferenceHasAddedAudio")
notification_center.remove_observer(self, name="BlinkWillCancelProposal")

def update_playing_ringtones(self):
should_play_incoming = False
Expand Down Expand Up @@ -291,7 +294,7 @@ def handle_notification(self, notification):
NotificationCenter().remove_observer(self, sender=session)
self.active_sessions.discard(session)
self.stop_ringing(session)
elif name in ("SIPSessionGotAcceptProposal", "SIPSessionGotRejectProposal", "SIPSessionHadProposalFailure"):
elif name in ("SIPSessionGotAcceptProposal", "SIPSessionGotRejectProposal", "SIPSessionHadProposalFailure", "BlinkWillCancelProposal"):
self.stop_ringing(session)
elif name == "SIPSessionGotProposal":
stream_types = [stream.type for stream in data.streams]
Expand Down

0 comments on commit bbacd22

Please sign in to comment.