Call gui improvements including:

- fix for the bug reported by Symphorien - not complete handling of OperationFailedException in createOutgoingCall
- differentiate call event start date and conversation start date - NullPointerException fixed
- wrap class added to provide unique inteface for the gui for unresolved and real call participants.
- some comments added
cusax-fix
Yana Stamcheva 19 years ago
parent 042b82b357
commit 720133df02

@ -90,26 +90,26 @@ public Component getListCellRendererComponent(JList list, Object value,
if (value instanceof GuiCallParticipantRecord) {
GuiCallParticipantRecord participant
GuiCallParticipantRecord callRecord
= (GuiCallParticipantRecord) value;
this.direction = participant.getDirection();
this.direction = callRecord.getDirection();
if(direction.equals(GuiCallParticipantRecord.INCOMING_CALL))
iconLabel.setIcon(incomingIcon);
else
iconLabel.setIcon(outgoingIcon);
this.nameLabel.setText(participant.getParticipantName());
this.nameLabel.setText(callRecord.getParticipantName());
this.timeLabel.setText(
Messages.getI18NString("at").getText() + " " +
GuiUtils.formatTime(
participant.getStartTime()));
callRecord.getStartTime()));
this.durationLabel.setText(
Messages.getI18NString("duration").getText() + " " +
GuiUtils.formatTime(participant.getCallTime()));
GuiUtils.formatTime(callRecord.getDuration()));
//this.nameLabel.setIcon(listModel
// .getMetaContactStatusIcon(contactItem));

@ -204,8 +204,9 @@ else if (selectedPanel != null
CallListPanel callListPanel = (CallListPanel) selectedPanel;
GuiCallParticipantRecord callRecord = (GuiCallParticipantRecord) callListPanel
.getCallList().getSelectedValue();
GuiCallParticipantRecord callRecord
= (GuiCallParticipantRecord) callListPanel
.getCallList().getSelectedValue();
String stringContact = callRecord.getParticipantName();
@ -515,7 +516,6 @@ public void callEnded(CallEvent event)
if (activeCalls.get(sourceCall) != null)
{
CallPanel callPanel = (CallPanel) activeCalls.get(sourceCall);
this.removeCallPanelWait(callPanel);
@ -766,38 +766,76 @@ public void run()
{
if (telephony == null)
return;
Call createdCall = null;
try
if (contacts != null)
{
Call createdCall;
if (contacts != null)
Contact contact = (Contact) contacts.get(0);
// NOTE: The multi user call is not yet implemented!
// We just get the first contact and create a call for him.
try
{
createdCall = telephony.createCall(contact);
}
catch (OperationFailedException e)
{
// in the future here we will have the posibility to call
// more than one contact
Contact contact = (Contact) contacts.get(0);
logger.error("The call could not be created: " + e);
createdCall = telephony.createCall(contact);
callPanel.getParticipantPanel(contact.getDisplayName())
.setState(e.getMessage());
removeCallPanelWait(callPanel);
}
else
createdCall = telephony.createCall(stringContact);
// If the call is successfully created we set the created
// Call instance to the already existing CallPanel and we
// add this call to the active calls.
if (createdCall != null)
{
callPanel.setCall(createdCall,
GuiCallParticipantRecord.OUTGOING_CALL);
activeCalls.put(createdCall, callPanel);
}
}
}
catch (OperationFailedException e)
else
{
logger.error("The call could not be created: " + e);
}
catch (ParseException e)
{
logger.error("The call could not be created: " + e);
}
try
{
createdCall = telephony.createCall(stringContact);
}
catch (ParseException e)
{
logger.error("The call could not be created: " + e);
callPanel.getParticipantPanel(stringContact)
.setState(e.getMessage());
removeCallPanelWait(callPanel);
}
catch (OperationFailedException e)
{
logger.error("The call could not be created: " + e);
callPanel.getParticipantPanel(stringContact)
.setState(e.getMessage());
removeCallPanelWait(callPanel);
}
// If the call is successfully created we set the created
// Call instance to the already existing CallPanel and we
// add this call to the active calls.
if (createdCall != null)
{
callPanel.setCall(createdCall,
GuiCallParticipantRecord.OUTGOING_CALL);
activeCalls.put(createdCall, callPanel);
}
}
}
}

@ -140,14 +140,24 @@ public CallPanel(CallManager callManager, String contactString)
*/
private CallParticipantPanel addCallParticipant(
String participantName, String callType)
{
{
CallParticipantPanel participantPanel
= new CallParticipantPanel(participantName);
this.mainPanel.add(participantPanel);
participantPanel.setCallType(callType);
= getParticipantPanel(participantName);
if(participantPanel == null)
{
participantPanel
= new CallParticipantPanel(participantName);
this.mainPanel.add(participantPanel);
participantPanel.setCallType(callType);
this.participantsPanels.put(
new CallParticipantWrapper(participantName),
participantPanel);
}
return participantPanel;
}
@ -155,17 +165,28 @@ private CallParticipantPanel addCallParticipant(
* Cteates and adds a panel for a call participant.
*
* @param participant the call participant
* @param callType the type of call - INCOMING of OUTGOING
*/
private CallParticipantPanel addCallParticipant(
CallParticipant participant, String callType)
{
CallParticipantPanel participantPanel
= new CallParticipantPanel(participant);
this.mainPanel.add(participantPanel);
participantPanel.setCallType(callType);
= getParticipantPanel(participant);
if(participantPanel == null)
{
participantPanel
= new CallParticipantPanel(participant);
this.mainPanel.add(participantPanel);
participantPanel.setCallType(callType);
this.participantsPanels.put(
new CallParticipantWrapper(participant),
participantPanel);
}
return participantPanel;
}
@ -189,7 +210,7 @@ public void callParticipantAdded(CallParticipantEvent evt)
{
if(evt.getSourceCall() == call) {
this.addCallParticipant(
evt.getSourceCallParticipant().getDisplayName(), null);
evt.getSourceCallParticipant(), null);
this.revalidate();
this.repaint();
@ -203,14 +224,15 @@ public void callParticipantAdded(CallParticipantEvent evt)
*/
public void callParticipantRemoved(CallParticipantEvent evt)
{
if(evt.getSourceCall() == call) {
if(evt.getSourceCall() == call)
{
CallParticipant participant = evt.getSourceCallParticipant();
CallParticipantPanel participantPanel
= (CallParticipantPanel)participantsPanels.get(participant);
if(participantPanel != null) {
= getParticipantPanel(participant);
if(participantPanel != null)
{
CallParticipantState state = participant.getState();
participantPanel.setState(state.getStateString());
@ -222,18 +244,17 @@ public void callParticipantRemoved(CallParticipantEvent evt)
= new GuiCallParticipantRecord(
participantPanel.getParticipantName(),
participantPanel.getCallType(),
participantPanel.getStartTime(),
participantPanel.getTime());
participantPanel.getCallStartTime(),
participantPanel.getCallDuration());
callManager.getMainFrame().getCallListManager().addCallRecord(
0, participantRecord);
//remove the participant panel for this participant
this.participantsPanels.remove(participant);
if(participantsPanels.size() != 0) {
if(participantsPanels.size() != 0)
{
Timer timer = new Timer(5000,
new RemoveParticipantPanelListener(participantPanel));
new RemoveParticipantPanelListener(
getParticipantWrapper(participant)));
timer.setRepeats(false);
timer.start();
@ -261,7 +282,7 @@ public void participantStateChanged(CallParticipantChangeEvent evt)
return;
CallParticipantPanel participantPanel
= (CallParticipantPanel)participantsPanels.get(sourceParticipant);
= getParticipantPanel(sourceParticipant);
participantPanel.setState(
sourceParticipant.getState().getStateString());
@ -330,6 +351,12 @@ public Call getCall()
return call;
}
/**
* Sets the <tt>Call</tt> corresponding to this <tt>CallPanel</tt>.
*
* @param call the <tt>Call</tt> corresponding to this <tt>CallPanel</tt>
* @param callType the call type - INCOMING or OUTGOING
*/
public void setCall(Call call, String callType)
{
this.call = call;
@ -337,6 +364,8 @@ public void setCall(Call call, String callType)
this.call.addCallChangeListener(this);
// Remove all previously added participant panels, because they do not
// correspond to real participants.
this.mainPanel.removeAll();
Iterator participants = call.getCallParticipants();
@ -345,15 +374,9 @@ public void setCall(Call call, String callType)
CallParticipant participant = (CallParticipant) participants.next();
if(participantsPanels.contains(participant))
return;
participant.addCallParticipantListener(this);
CallParticipantPanel participantPanel = this.addCallParticipant(
participant, callType);
this.participantsPanels.put(participant, participantPanel);
this.addCallParticipant(participant, callType);
}
}
@ -375,21 +398,114 @@ public void participantTransportAddressChanged(CallParticipantChangeEvent
*/
private class RemoveParticipantPanelListener implements ActionListener
{
private JPanel participantPanel;
public RemoveParticipantPanelListener(JPanel participantPanel)
private CallParticipantWrapper participantWrapper;
public RemoveParticipantPanelListener(
CallParticipantWrapper participantWrapper)
{
this.participantPanel = participantPanel;
this.participantWrapper = participantWrapper;
}
public void actionPerformed(ActionEvent e)
{
{
CallParticipantPanel participantPanel
= (CallParticipantPanel) participantsPanels
.get(participantWrapper);
mainPanel.remove(participantPanel);
//remove the participant panel from the list of panels
participantsPanels.remove(participantWrapper);
}
}
/**
* Returns all participant panels contained in this call panel.
* @return an <tt>Iterator</tt> over a list of all participant panels
* contained in this call panel
*/
public Iterator getParticipantsPanels()
{
return participantsPanels.values().iterator();
}
/**
* Returns the <tt>CallParticipantPanel</tt>, which correspond to the given
* participant.
*
* @param participant the <tt>CallParticipant</tt> we're looking for
* @return the <tt>CallParticipantPanel</tt>, which correspond to the given
* participant
*/
public CallParticipantPanel getParticipantPanel(CallParticipant participant)
{
Iterator participants = participantsPanels.entrySet().iterator();
while(participants.hasNext())
{
Map.Entry participantEntry = (Map.Entry) participants.next();
CallParticipantWrapper participantWrapper
= (CallParticipantWrapper) participantEntry.getKey();
if(participantWrapper.getCallParticipant() != null
&& participantWrapper.getCallParticipant().equals(participant))
return (CallParticipantPanel) participantEntry.getValue();
}
return null;
}
/**
* Returns the <tt>CallParticipantPanel</tt>, which correspond to the given
* participant name.
*
* @param participantName the name of the participant we're looking for
* @return the <tt>CallParticipantPanel</tt>, which correspond to the given
* participant name
*/
public CallParticipantPanel getParticipantPanel(String participantName)
{
Iterator participants = participantsPanels.entrySet().iterator();
while(participants.hasNext())
{
Map.Entry participantEntry = (Map.Entry) participants.next();
CallParticipantWrapper participantWrapper
= (CallParticipantWrapper) participantEntry.getKey();
if(participantWrapper.getParticipantName().equals(participantName))
return (CallParticipantPanel) participantEntry.getValue();
}
return null;
}
/**
* Returns the <tt>CallParticipantWrapper</tt>, which correspond to the given
* participant.
*
* @param participant the <tt>CallParticipant</tt> we're looking for
* @return the <tt>CallParticipantWrapper</tt>, which correspond to the given
* participant
*/
private CallParticipantWrapper getParticipantWrapper(
CallParticipant participant)
{
Iterator participants = participantsPanels.entrySet().iterator();
while(participants.hasNext())
{
Map.Entry participantEntry = (Map.Entry) participants.next();
CallParticipantWrapper participantWrapper
= (CallParticipantWrapper) participantEntry.getKey();
if(participantWrapper.getCallParticipant().equals(participant))
return participantWrapper;
}
return null;
}
}

@ -38,9 +38,11 @@ public class CallParticipantPanel extends JPanel
private JLabel photoLabel = new JLabel(new ImageIcon(
ImageLoader.getImage(ImageLoader.DEFAULT_USER_PHOTO)));
private Date startDate;
private Date callStartTime;
private Date callTime;
private Date conversationStartTime;
private Date callDuration;
private Timer timer;
@ -68,6 +70,11 @@ public CallParticipantPanel(String participantName)
{
super(new BorderLayout());
// Initialize the call start time. This date is meant to be used in
// the GuiCallParticipantRecord, which is added to the CallList after
// a call.
this.callStartTime = new Date(System.currentTimeMillis());
this.participantName = participantName;
this.nameLabel.setText(participantName);
@ -80,7 +87,7 @@ public CallParticipantPanel(String participantName)
//hour is intialized to 1.
Calendar c = Calendar.getInstance();
c.set(0, 0, 0, 0, 0, 0);
this.callTime = c.getTime();
this.callDuration = c.getTime();
namePanel.add(nameLabel);
namePanel.add(stateLabel);
@ -107,7 +114,7 @@ public void setState(String state)
*/
public void startCallTimer()
{
this.startDate = new Date(System.currentTimeMillis());
this.conversationStartTime = new Date(System.currentTimeMillis());
this.timer.start();
}
@ -129,32 +136,47 @@ public void actionPerformed(ActionEvent e)
{
Date time = GuiUtils.substractDates(
new Date(System.currentTimeMillis()),
startDate);
conversationStartTime);
callTime.setTime(time.getTime());
callDuration.setTime(time.getTime());
timeLabel.setText(GuiUtils.formatTime(time));
}
}
/**
* Returns the start time of the contained participant call.
* Returns the start time of the conversation. If no conversation was made
* will return null.
*
* @return the start time of the contained participant call
* @return the start time of the conversation
*/
public Date getStartTime()
public Date getConversationStartTime()
{
return startDate;
return conversationStartTime;
}
/**
* Returns the start time of the contained participant call.
* Returns the start time of the contained participant call. Note that the
* start time of the call is different from the conversation start time.
* For example if we receive a call, the call start time is when the call
* is received and the conversation start time would be when we accept the
* call.
*
* @return the start time of the contained participant call
*/
public Date getTime()
public Date getCallStartTime()
{
return callStartTime;
}
/**
* Returns the duration of the contained participant call.
*
* @return the duration of the contained participant call
*/
public Date getCallDuration()
{
return callTime;
return callDuration;
}
/**
@ -164,17 +186,29 @@ public Date getTime()
*/
public String getCallType()
{
if(callTime != null)
if(callDuration != null)
return callType;
else
return GuiCallParticipantRecord.INCOMING_CALL;
}
/**
* Sets the type of the call. Call type could be
* <tt>GuiCallParticipantRecord.INCOMING_CALL</tt> or
* <tt>GuiCallParticipantRecord.INCOMING_CALL</tt>.
*
* @param callType the type of call to set
*/
public void setCallType(String callType)
{
this.callType = callType;
}
/**
* Returns the name of the participant, contained in this panel.
*
* @return the name of the participant, contained in this panel
*/
public String getParticipantName()
{
return participantName;

@ -0,0 +1,53 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main.call;
import net.java.sip.communicator.service.protocol.*;
/**
* Wraps the {@link CallParticipant} class in order to provide an identical key
* value corresponding to a <tt>CallParticipantPanel</tt>.
*
* @author Yana Stamcheva
*/
public class CallParticipantWrapper
{
private String participantName;
private CallParticipant callParticipant;
public CallParticipantWrapper(String participantName)
{
this.participantName = participantName;
}
public CallParticipantWrapper(CallParticipant participant)
{
this.callParticipant = participant;
this.participantName = participant.getDisplayName();
}
public CallParticipant getCallParticipant()
{
return callParticipant;
}
public void setCallParticipant(CallParticipant callParticipant)
{
this.callParticipant = callParticipant;
}
public String getParticipantName()
{
return participantName;
}
public void setParticipantName(String participantName)
{
this.participantName = participantName;
}
}

@ -30,12 +30,12 @@ public class GuiCallParticipantRecord
private Date startTime;
private Date callTime;
private Date callDuration;
public GuiCallParticipantRecord(String participantName,
String direction,
Date startTime,
Date callTime)
Date callDuration)
{
this.direction = direction;
@ -43,7 +43,7 @@ public GuiCallParticipantRecord(String participantName,
this.startTime = startTime;
this.callTime = callTime;
this.callDuration = callDuration;
}
public GuiCallParticipantRecord(CallParticipantRecord participantRecord,
@ -55,7 +55,7 @@ public GuiCallParticipantRecord(CallParticipantRecord participantRecord,
this.startTime = participantRecord.getStartTime();
this.callTime = GuiUtils.substractDates(
this.callDuration = GuiUtils.substractDates(
participantRecord.getEndTime(), startTime);
}
@ -64,9 +64,14 @@ public String getDirection()
return direction;
}
public Date getCallTime()
/**
* Returns the duration of the contained participant call.
*
* @return the duration of the contained participant call
*/
public Date getDuration()
{
return callTime;
return callDuration;
}
public String getParticipantName()

Loading…
Cancel
Save