From 3e6e886b7490d6eab58e6b10f7dde3f98be2612b Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Mon, 22 Oct 2012 20:51:16 +0000 Subject: [PATCH] Makes call window wait after a hang up only if there was no user intervention. Makes the window disappear immediately if the X button has been pressed. --- .../impl/gui/main/call/CallDialog.java | 12 +++++++ .../impl/gui/main/call/CallManager.java | 34 ++++++++++++++++++- .../impl/gui/main/call/CallPanel.java | 26 ++++++++++++-- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java index d23024421..d3b3c116c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java @@ -86,6 +86,18 @@ public void callTitleChanged(CallPanel callPanel) @Override protected void close(boolean escape) { + // If the window has been closed by clicking the X button or pressing + // the key combination corresponding to the same button we close the + // window first and then perform all hang up operations. + if (!escape) + { + this.callPanel.disposeCallInfoFrame(); + // We hide the window here. It will be disposed when the call has + // been ended. + setVisible(false); + } + + // Then perform hang up operations. callPanel.actionPerformedOnHangupButton(escape); } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java index 9d74398a2..9c36631bc 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java @@ -202,7 +202,7 @@ public void callEndedInEventDispatchThread(CallEvent ev) { Call sourceCall = ev.getSourceCall(); - closeCallContainerIfNotNecessary(sourceCall, true); + closeCallContainerIfNotNecessary(sourceCall); /* * Notify the existing CallPanels about the CallEvent (in case @@ -1044,6 +1044,38 @@ public static void transferCall(CallPeer peer, String target) } } + /** + * Closes the CallPanel of a specific Call if it is no + * longer necessary (i.e. is not used by other Calls participating + * in the same telephony conference as the specified Call.) + * + * @param call the Call which is to have its associated + * CallPanel, if any, closed + * {@link CallContainer#closeWait(CallPanel)} or false to use + * {@link CallContainer#close(CallPanel)} + */ + private static void closeCallContainerIfNotNecessary(final Call call) + { + if (!SwingUtilities.isEventDispatchThread()) + { + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + closeCallContainerIfNotNecessary(call); + } + }); + return; + } + + CallPanel callPanel = callPanels.get(call.getConference()); + + if (callPanel != null) + closeCallContainerIfNotNecessary( + call, callPanel.isCloseWaitAfterHangup()); + } + /** * Closes the CallPanel of a specific Call if it is no * longer necessary (i.e. is not used by other Calls participating diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java index b95aa37d0..7c3946367 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java @@ -263,6 +263,14 @@ public class CallPanel */ private final UIVideoHandler2 uiVideoHandler; + /** + * Indicates if this call panel should be closed immediately after hang up + * or should wait some time so that the user can be notified of the last + * state. By default we wait, so that the user can be notified of the + * current state of the call. + */ + private boolean isCloseWaitAfterHangup = true; + /** * The Observer which listens to {@link #uiVideoHandler} about * changes in the video-related information. @@ -445,14 +453,28 @@ else if (buttonName.equals(INFO_BUTTON)) */ public void actionPerformedOnHangupButton(boolean closeWait) { - this.disposeCallInfoFrame(); + isCloseWaitAfterHangup = closeWait; - CallManager.hangupCalls(callConference); + this.disposeCallInfoFrame(); /* * XXX It is the responsibility of CallManager to close this CallPanel * when a Call is ended. */ + CallManager.hangupCalls(callConference); + } + + /** + * Indicates if this call panel should be closed immediately after hang up + * or should wait some time so that the user can be notified of the last + * state. + * + * @return true to indicate that when hanged up this call panel + * should not be closed immediately, false - otherwise + */ + public boolean isCloseWaitAfterHangup() + { + return isCloseWaitAfterHangup; } /**