From 968d7410db20adb50f4bab7da214024929061b46 Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Wed, 14 Oct 2009 14:20:22 +0000 Subject: [PATCH] - Stop the call duration timer when the last peer is removed. - Fix calling a meta contact, which was broken from my last commit introducing call conferencing code. --- .../impl/gui/main/call/CallDialog.java | 16 +++-- .../impl/gui/main/call/MainCallPanel.java | 63 ++++++++----------- 2 files changed, 38 insertions(+), 41 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 da2cca0de..b5c5b7d1a 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 @@ -60,7 +60,7 @@ public class CallDialog private boolean isCallTimerStarted = false; - private Timer timer; + private Timer callDurationTimer; /** * Creates a CallDialog by specifying the underlying call panel. @@ -152,8 +152,8 @@ public CallDialog(Call call) buttonsPanel.setBorder( new ExtendedEtchedBorder(EtchedBorder.LOWERED, 1, 0, 0, 0)); - this.timer = new Timer(1000, new CallTimerListener()); - this.timer.setRepeats(true); + this.callDurationTimer = new Timer(1000, new CallTimerListener()); + this.callDurationTimer.setRepeats(true); } @@ -411,6 +411,12 @@ public void callPeerRemoved(CallPeerEvent evt) timer.setRepeats(false); timer.start(); + + // The call is finished when that last peer is removed. + if (call.getCallPeerCount() == 0) + { + this.stopCallTimer(); + } } } @@ -449,7 +455,7 @@ private boolean isConference() public void startCallTimer() { this.callStartDate = new Date(); - this.timer.start(); + this.callDurationTimer.start(); this.isCallTimerStarted = true; } @@ -458,7 +464,7 @@ public void startCallTimer() */ public void stopCallTimer() { - this.timer.stop(); + this.callDurationTimer.stop(); } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/call/MainCallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/MainCallPanel.java index 50f860598..05a00e901 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/MainCallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/MainCallPanel.java @@ -174,46 +174,37 @@ public void actionPerformed(ActionEvent evt) // call button is pressed when a meta contact is selected if (isCallMetaContact) { - Object[] selectedContacts = mainFrame.getContactListPanel() - .getContactList().getSelectedValues(); - - java.util.List telephonyContacts = - new Vector(); + // We don't support conferencing from multiple selection for + // now. That would suppose to make choices on which protocol + // provider should be used to establish the call, so until we're + // not able to fully implement the feature we'll consider only + // one selected contact. + Object selectedContact = mainFrame.getContactListPanel() + .getContactList().getSelectedValue(); - for (Object o : selectedContacts) + if (selectedContact instanceof MetaContact) { - if (o instanceof MetaContact) + Contact contact = ((MetaContact) selectedContact) + .getDefaultContact(OperationSetBasicTelephony.class); + + if (contact != null) { - Contact contact = ((MetaContact) o) - .getDefaultContact( - OperationSetBasicTelephony.class); - - if (contact != null) - telephonyContacts.add(contact.getAddress()); - else - { - new ErrorDialog( - this.mainFrame, - GuiActivator.getResources() - .getI18NString("service.gui.WARNING"), - GuiActivator.getResources().getI18NString( - "service.gui.CONTACT_NOT_SUPPORTING_TELEPHONY", - new String[] - { ((MetaContact) o).getDisplayName() })) - .showDialog(); - } + CallManager.createCall( + contact.getProtocolProvider(), contact); + } + else + { + new ErrorDialog( + this.mainFrame, + GuiActivator.getResources() + .getI18NString("service.gui.WARNING"), + GuiActivator.getResources().getI18NString( + "service.gui.CONTACT_NOT_SUPPORTING_TELEPHONY", + new String[] + { ((MetaContact) selectedContact) + .getDisplayName() })) + .showDialog(); } - } - - if (telephonyContacts.size() > 0) - { - String[] contactAddressStrings - = new String[telephonyContacts.size()]; - contactAddressStrings - = telephonyContacts.toArray(contactAddressStrings); - - CallManager.createConferenceCall( - contactAddressStrings, protocolProvider); } } else if (!phoneNumberCombo.isComboFieldEmpty())