From 939e3689f1b52abffebe28ce36b12c3dcfd4422b Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Sun, 22 Oct 2006 17:34:29 +0000 Subject: [PATCH] some little bugs fixed --- .../impl/gui/main/call/CallManager.java | 77 +++++++++++-------- .../impl/gui/main/call/CallPanel.java | 6 +- .../gui/main/call/CallParticipantPanel.java | 13 +++- 3 files changed, 58 insertions(+), 38 deletions(-) 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 a77f444ac..603d2ef73 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 @@ -78,6 +78,8 @@ public class CallManager private boolean isCallMetaContact; + private Timer removeCallTimer; + /** * Creates an instance of CallManager. * @param mainFrame The main application window. @@ -196,26 +198,30 @@ else if (buttonName.equalsIgnoreCase("hangup")) { Call call = selectedCallPanel.getCall(); - activeCalls.remove(call); - mainFrame.removeCallPanel(selectedCallPanel); - updateButtonsStateAccordingToSelectedPanel(); - - ProtocolProviderService pps - = call.getProtocolProvider(); - - OperationSetBasicTelephony telephony - = mainFrame.getTelephony(pps); - - Iterator participants = call.getCallParticipants(); - - while(participants.hasNext()) { - try { - //now we hang up the first call participant in the call - telephony.hangupCallParticipant( - (CallParticipant)participants.next()); - } - catch (OperationFailedException e) { - logger.error("Hang up was not successful: " + e); + if(activeCalls.get(call) != null) { + + if(removeCallTimer.isRunning()) + removeCallTimer.stop(); + + mainFrame.removeCallPanel(selectedCallPanel); + + ProtocolProviderService pps + = call.getProtocolProvider(); + + OperationSetBasicTelephony telephony + = mainFrame.getTelephony(pps); + + Iterator participants = call.getCallParticipants(); + + while(participants.hasNext()) { + try { + //now we hang up the first call participant in the call + telephony.hangupCallParticipant( + (CallParticipant)participants.next()); + } + catch (OperationFailedException e) { + logger.error("Hang up was not successful: " + e); + } } } } @@ -325,11 +331,12 @@ public void callEnded(CallEvent event) SoundLoader.stop(Constants.getDefaultIncomingCallAudio()); Call sourceCall = event.getSourceCall(); - + if(activeCalls.get(sourceCall) != null) { + CallPanel callPanel = (CallPanel) activeCalls.get(sourceCall); - this.removeCallPanel(callPanel); + this.removeCallPanelWait(callPanel); } } @@ -340,14 +347,24 @@ public void outgoingCallCreated(CallEvent event) * Removes the given call panel tab. * @param callPanel the CallPanel to remove */ - public void removeCallPanel(CallPanel callPanel) - { - Timer timer = new Timer(5000, new RemoveCallPanelListener(callPanel)); + public void removeCallPanelWait(CallPanel callPanel) + { + removeCallTimer = new Timer(5000, new RemoveCallPanelListener(callPanel)); - timer.setRepeats(false); - timer.start(); + removeCallTimer.setRepeats(false); + removeCallTimer.start(); } + /** + * Removes the given call panel tab. + * @param callPanel the CallPanel to remove + */ + private void removeCallPanel(CallPanel callPanel) + { + this.activeCalls.remove(callPanel.getCall()); + mainFrame.removeCallPanel(callPanel); + updateButtonsStateAccordingToSelectedPanel(); + } /** * Removes the given CallPanel from the main tabbed pane. @@ -361,10 +378,8 @@ public RemoveCallPanelListener(CallPanel callPanel) } public void actionPerformed(ActionEvent e) - { - activeCalls.remove(callPanel.getCall()); - mainFrame.removeCallPanel(callPanel); - updateButtonsStateAccordingToSelectedPanel(); + { + removeCallPanel(callPanel); } } 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 4218d303d..ffbad2b86 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 @@ -160,13 +160,13 @@ public void callParticipantRemoved(CallParticipantEvent evt) //Create a call record and add it to the call list. GuiCallParticipantRecord participantRecord = new GuiCallParticipantRecord( - participantPanel.getName(), + participantPanel.getParticipantName(), participantPanel.getCallType(), participantPanel.getStartTime(), participantPanel.getEndTime()); - callManager.getMainFrame().getCallList().addItem( - participantRecord, 1); + callManager.getMainFrame().getCallListManager().addCallRecord( + 1, participantRecord); //remove the participant panel for this participant this.participantsPanels.remove(participant); diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallParticipantPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallParticipantPanel.java index 355c462f3..67e09cbf4 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallParticipantPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallParticipantPanel.java @@ -46,6 +46,9 @@ public class CallParticipantPanel extends JPanel private String callType; + private String participantName; + + /** * Creates a CallParticipantPanel for the given call participant. * @@ -64,9 +67,11 @@ public CallParticipantPanel(CallParticipant participant) this.timer.setRepeats(true); if(participant.getDisplayName() != null) - nameLabel.setText(participant.getDisplayName()); + participantName = participant.getDisplayName(); else - nameLabel.setText(participant.getAddress()); + participantName = participant.getAddress(); + + this.nameLabel.setText(participantName); namePanel.add(nameLabel); namePanel.add(stateLabel); @@ -153,8 +158,8 @@ public String getCallType() return GuiCallParticipantRecord.INCOMING_CALL; } - public void setCallType(String callType) + public String getParticipantName() { - this.callType = callType; + return participantName; } }