@ -6,6 +6,8 @@
* /
package net.java.sip.communicator.impl.protocol.jabber ;
import net.java.sip.communicator.service.protocol.* ;
import net.java.sip.communicator.service.protocol.event.* ;
import net.java.sip.communicator.service.protocol.media.* ;
import net.java.sip.communicator.util.* ;
@ -17,14 +19,12 @@
* of Jabber and Gtalk protocols .
*
* @author Vincent Lucas
* @author Lyubomir Marinov
* /
public abstract class AbstractCallPeerJabberGTalkImpl
< T extends AbstractCallJabberGTalkImpl < ? > ,
U extends AbstractCallPeerMediaHandlerJabberGTalkImpl < ? > >
extends MediaAwareCallPeer <
T ,
U ,
ProtocolProviderServiceJabberImpl >
U extends AbstractCallPeerMediaHandlerJabberGTalkImpl < ? > >
extends MediaAwareCallPeer < T , U , ProtocolProviderServiceJabberImpl >
{
/ * *
* The < tt > Logger < / tt > used by the < tt > AbstractCallPeerJabberGTalkImpl < / tt >
@ -34,14 +34,20 @@ public abstract class AbstractCallPeerJabberGTalkImpl
= Logger . getLogger ( AbstractCallPeerJabberGTalkImpl . class ) ;
/ * *
* The jabber address of this peer
* Any discovery information that we have for this peer .
* /
pr otected String peerJID = null ;
pr ivate DiscoverInfo discoverInfo ;
/ * *
* Any discovery information that we have for this peer .
* The indicator which determines whether this peer was initiated the
* session .
* /
private DiscoverInfo discoverInfo ;
protected boolean initiator = false ;
/ * *
* The jabber address of this peer
* /
protected String peerJID ;
/ * *
* Creates a new call peer with address < tt > peerAddress < / tt > .
@ -50,9 +56,7 @@ public abstract class AbstractCallPeerJabberGTalkImpl
* peer .
* @param owningCall the call that contains this call peer .
* /
protected AbstractCallPeerJabberGTalkImpl (
String peerAddress ,
T owningCall )
protected AbstractCallPeerJabberGTalkImpl ( String peerAddress , T owningCall )
{
super ( owningCall ) ;
@ -60,14 +64,29 @@ protected AbstractCallPeerJabberGTalkImpl(
}
/ * *
* Sets the service discovery information that we have for this peer .
* Returns a String locator for that peer .
*
* @param discoverInfo the discovery information that we have obtained for
* this peer .
* @return the peer ' s address or phone number .
* /
public void setDiscoverInfo ( DiscoverInfo discoverInfo )
public String getAddress ( )
{
this . discoverInfo = discoverInfo ;
return peerJID ;
}
/ * *
* Returns the contact corresponding to this peer or null if no
* particular contact has been associated .
* < p >
* @return the < tt > Contact < / tt > corresponding to this peer or null
* if no particular contact has been associated .
* /
public Contact getContact ( )
{
ProtocolProviderService pps = getCall ( ) . getProtocolProvider ( ) ;
OperationSetPresence opSetPresence
= pps . getOperationSet ( OperationSetPresence . class ) ;
return opSetPresence . findContactByID ( getAddress ( ) ) ;
}
/ * *
@ -81,7 +100,46 @@ public DiscoverInfo getDiscoverInfo()
}
/ * *
* Retrives the DiscoverInfo for a given peer identified by its URI .
* Returns a human readable name representing this peer .
*
* @return a String containing a name for that peer .
* /
public String getDisplayName ( )
{
if ( getCall ( ) ! = null )
{
Contact contact = getContact ( ) ;
if ( contact ! = null )
return contact . getDisplayName ( ) ;
}
return peerJID ;
}
/ * *
* Returns full URI of the address .
*
* @return full URI of the address
* /
public String getURI ( )
{
return "xmpp:" + peerJID ;
}
/ * *
* Determines whether this peer initiated the session . Note that if this
* peer is the initiator of the session , then we are the responder !
*
* @return < tt > true < / tt > if this peer initiated the session ; < tt > false < / tt > ,
* otherwise ( i . e . if _we_ initiated the session ) .
* /
public boolean isInitiator ( )
{
return initiator ;
}
/ * *
* Retrieves the DiscoverInfo for a given peer identified by its URI .
*
* @param calleeURI The URI of the call peer .
* @param ppsJabberImpl The call protocol provider service .
@ -105,4 +163,37 @@ protected void retrieveDiscoverInfo(String calleeURI)
logger . warn ( "could not retrieve info for " + calleeURI , ex ) ;
}
}
/ * *
* Specifies the address , phone number , or other protocol specific
* identifier that represents this call peer . This method is to be
* used by service users and MUST NOT be called by the implementation .
*
* @param address The address of this call peer .
* /
public void setAddress ( String address )
{
if ( ! peerJID . equals ( address ) )
{
String oldAddress = getAddress ( ) ;
peerJID = address ;
fireCallPeerChangeEvent (
CallPeerChangeEvent . CALL_PEER_ADDRESS_CHANGE ,
oldAddress ,
address ) ;
}
}
/ * *
* Sets the service discovery information that we have for this peer .
*
* @param discoverInfo the discovery information that we have obtained for
* this peer .
* /
public void setDiscoverInfo ( DiscoverInfo discoverInfo )
{
this . discoverInfo = discoverInfo ;
}
}