From 0d9fb0f5e1c25368bf236425940675d437d68419 Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Mon, 23 Oct 2006 16:22:31 +0000 Subject: [PATCH] Working on the JMF implementation of the media service. added a method for retrieving a transport address (may remove later) --- .../protocol/sip/CallParticipantSipImpl.java | 81 ++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallParticipantSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallParticipantSipImpl.java index 191947891..633cf9a53 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallParticipantSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallParticipantSipImpl.java @@ -14,6 +14,7 @@ import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; import javax.sip.*; +import java.net.*; /** * Our SIP implementation of the default CallParticipant; @@ -52,7 +53,7 @@ public class CallParticipantSipImpl private String participantID; /** - * The call participant belongs to. + * The call this participant belongs to. */ private CallSipImpl call; @@ -81,6 +82,13 @@ public class CallParticipantSipImpl */ private SipProvider jainSipProvider = null; + /** + * The transport address that we are using to address the participant or the + * first one that we'll try when we next send them a message (could be the + * address of our sip registrar). + */ + private InetSocketAddress transportAddress = null; + /** * Creates a new call participant with address participantAddress. * @@ -181,6 +189,7 @@ protected void setState(CallParticipantState newState) } + /** * Returns the date (time) when this call participant acquired its * current status. @@ -200,7 +209,10 @@ public Date getCurrentStateStartDate() */ public String getDisplayName() { - return participantAddress.getDisplayName(); + String displayName = participantAddress.getDisplayName(); + return (displayName == null) + ? participantAddress.getURI().toString() + : displayName; } /** @@ -396,4 +408,69 @@ public SipProvider getJainSipProvider() { return jainSipProvider; } + + /** + * The address that we have used to contact this participant. In cases + * where no direct connection has been established with the participant, + * this method will return the address that will be first tried when + * connection is established (often the one used to connect with the + * protocol server). The address may change during a session and + * + * @param transportAddress The address that we have used to contact this + * participant. + */ + public void setTransportAddress(InetSocketAddress transportAddress) + { + InetSocketAddress oldTransportAddress = this.transportAddress; + this.transportAddress = transportAddress; + + this.fireCallParticipantChangeEvent( + CallParticipantChangeEvent + .CALL_PARTICIPANT_TRANSPORT_ADDRESS_CHANGE + , oldTransportAddress + , transportAddress); + } + + /** + * The address that we have used to contact this participant. In cases + * where no direct connection has been established with the participant, + * this method will return the address that will be first tried when + * connection is established (often the one used to connect with the + * protocol server). The address may change during a session and + * + * @return The address that we have used to contact this participant. + */ + public InetSocketAddress getLocalTransportAddress() + { + /** @todo this is ugly as we don't really know which listening point + * we're using. will do until we implement ice. */ + int defaultLpPort + = ((ProtocolProviderServiceSipImpl)getProtocolProvider()) + .getDefaultListeningPoint().getPort(); + + return new InetSocketAddress(defaultLpPort); + } + + /** + * Returns the protocol provider that this participant belongs to. + * @return a reference to the ProtocolProviderService that this participant + * belongs to. + */ + public ProtocolProviderService getProtocolProvider() + { + return this.getCall().getProtocolProvider(); + } + + /** + * Returns the contact corresponding to this participant or null if no + * particular contact has been associated. + *

+ * @return the Contact corresponding to this participant or null + * if no particular contact has been associated. + */ + public Contact getContact() + { + return null; + } + }