Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.sip
Class ContactSipImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.sip.ContactSipImpl
All Implemented Interfaces:
Contact

public class ContactSipImpl
extends Object
implements Contact

A simple, straightforward implementation of a SIP Contact.

Author:
Emil Ivov, Benoit Pradelle, Lubomir Marinov, Grigorii Balutsel

Constructor Summary
ContactSipImpl(javax.sip.address.Address contactAddress, ProtocolProviderServiceSipImpl parentProvider)
          Creates an instance of a meta contact with the specified string used as a name and identifier.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one which in terms of contacts translates to having equal ids.
 String getAddress()
          Returns a String that can be used for identifying the contact.
(package private)  List<Element> getAny()
          Gets the entry custom elements.
 String getDisplayName()
          Returns a String that could be used by any user interacting modules for referring to this contact.
(package private)  EntryType getEntry()
          Gets the entry.
 byte[] getImage()
          Gets a byte array containing an image (most often a photo or an avatar) that the contact uses as a representation.
(package private)  URI getImageUri()
          Gets the image uri.
 ContactGroup getParentContactGroup()
          Returns the group that contains this contact.
 OperationSetPresenceSipImpl getParentPresenceOperationSet()
          Returns the presence operation set that this contact belongs to.
 String getPersistentData()
          Gets the persistent data - for now only the XCAP resolved is needed for restoring the contact data.
 PresenceStatus getPresenceStatus()
          Returns the status of the contact.
 ProtocolProviderService getProtocolProvider()
          Returns a reference to the protocol provider that created the contact.
 javax.sip.address.Address getSipAddress()
          Returns the jain-sip Address instance that this contact is wrapping.
 String getStatusMessage()
          Return the current status message of this contact.
 String getSubscriptionState()
          Current subscription state of the contact.
 String getUri()
          Gets the entry's uri.
 boolean isLocal()
          Determines whether or not this contact represents our own identity.
 boolean isPersistent()
          Determines whether or not this contact is being stored by the server.
 boolean isResolvable()
          Determines whether or not this contact can be resolved against the server.
 boolean isResolved()
          Determines whether or not this contact has been resolved against the server.
 boolean isXCapResolved()
          Gets the value of the xCapResolved property.
(package private)  void setAny(List<Element> any)
          Sets the entry custom elements.
 void setDisplayName(DisplayNameType displayName)
          Sets a String that could be used by any user interacting modules for referring to this contact.
 void setDisplayName(String displayName)
          Sets a String that could be used by any user interacting modules for referring to this contact.
(package private)  void setImage(byte[] image)
          Sets a byte array containing an image (most often a photo or an avatar) that the contact uses as a representation.
(package private)  void setImageUri(URI imageUri)
          Sets the image uri.
(package private)  void setOtherAttributes(Map<QName,String> otherAttributes)
          Sets the entry custom attributes.
(package private)  void setParentGroup(ContactGroupSipImpl newParentGroup)
          This method is only called when the contact is added to a new ContactGroupSipImpl by the ContactGroupSipImpl itself.
 void setPersistent(boolean isPersistent)
          Specifies whether or not this contact is being stored by the server.
 void setPersistentData(String persistentData)
          Sets the persistent data.
 void setPresenceStatus(PresenceStatus sipPresenceStatus)
          Sets sipPresenceStatus as the PresenceStatus that this contact is currently in.
 void setResolvable(boolean resolvable)
          Makes the contact resolvable or unresolvable.
 void setResolved(boolean resolved)
          Makes the contact resolved or unresolved.
 void setSubscriptionState(String subscriptionState)
          Change current subscription state.
 void setXCapResolved(boolean xCapResolved)
          Sets the value of the xCapResolved property.
 String toString()
          Returns a string representation of this contact, containing most of its representative details.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContactSipImpl

public ContactSipImpl(javax.sip.address.Address contactAddress,
                      ProtocolProviderServiceSipImpl parentProvider)
Creates an instance of a meta contact with the specified string used as a name and identifier.

Parameters:
contactAddress - the identifier of this contact (also used as a name).
parentProvider - the provider that created us.
Method Detail

getEntry

EntryType getEntry()
Gets the entry.

Returns:
the entry

getUri

public String getUri()
Gets the entry's uri.

Returns:
the entry' uri.

setParentGroup

void setParentGroup(ContactGroupSipImpl newParentGroup)
This method is only called when the contact is added to a new ContactGroupSipImpl by the ContactGroupSipImpl itself.

Parameters:
newParentGroup - the ContactGroupSipImpl that is now parent of this ContactSipImpl

getAddress

public String getAddress()
Returns a String that can be used for identifying the contact.

Specified by:
getAddress in interface Contact
Returns:
a String id representing and uniquely identifying the contact.

getSipAddress

public javax.sip.address.Address getSipAddress()
Returns the jain-sip Address instance that this contact is wrapping.

Returns:
the jain-sip Address instance that this contact is wrapping.

getDisplayName

public String getDisplayName()
Returns a String that could be used by any user interacting modules for referring to this contact.

Specified by:
getDisplayName in interface Contact
Returns:
a String that can be used for referring to this contact when interacting with the user.

setDisplayName

public void setDisplayName(String displayName)
Sets a String that could be used by any user interacting modules for referring to this contact.

Parameters:
displayName - a human readable name to use for this contact.

setDisplayName

public void setDisplayName(DisplayNameType displayName)
Sets a String that could be used by any user interacting modules for referring to this contact.

Parameters:
displayName - a human readable name to use for this contact.

setOtherAttributes

void setOtherAttributes(Map<QName,String> otherAttributes)
Sets the entry custom attributes.

Parameters:
otherAttributes - the custom attributes.

setAny

void setAny(List<Element> any)
Sets the entry custom elements.

Parameters:
any - the custom elements.

getAny

List<Element> getAny()
Gets the entry custom elements.

Returns:
the custom elements.

getImageUri

URI getImageUri()
Gets the image uri.

Returns:
the image uri.

setImageUri

void setImageUri(URI imageUri)
Sets the image uri.

Parameters:
imageUri - the image uri.

getImage

public byte[] getImage()
Gets a byte array containing an image (most often a photo or an avatar) that the contact uses as a representation.

Specified by:
getImage in interface Contact
Returns:
byte[] an image representing the contact.

setImage

void setImage(byte[] image)
Sets a byte array containing an image (most often a photo or an avatar) that the contact uses as a representation.

Parameters:
image - an image representing the contact.

getPresenceStatus

public PresenceStatus getPresenceStatus()
Returns the status of the contact.

Specified by:
getPresenceStatus in interface Contact
Returns:
always IcqStatusEnum.ONLINE.

setPresenceStatus

public void setPresenceStatus(PresenceStatus sipPresenceStatus)
Sets sipPresenceStatus as the PresenceStatus that this contact is currently in.

Parameters:
sipPresenceStatus - the SipPresenceStatus currently valid for this contact.

getProtocolProvider

public ProtocolProviderService getProtocolProvider()
Returns a reference to the protocol provider that created the contact.

Specified by:
getProtocolProvider in interface Contact
Returns:
a refererence to an instance of the ProtocolProviderService

isLocal

public boolean isLocal()
Determines whether or not this contact represents our own identity.

Returns:
true in case this is a contact that represents ourselves and false otherwise.

getParentContactGroup

public ContactGroup getParentContactGroup()
Returns the group that contains this contact.

Specified by:
getParentContactGroup in interface Contact
Returns:
a reference to the ContactGroupSipImpl that contains this contact.

toString

public String toString()
Returns a string representation of this contact, containing most of its representative details.

Overrides:
toString in class Object
Returns:
a string representation of this contact.

isPersistent

public boolean isPersistent()
Determines whether or not this contact is being stored by the server. Non persistent contacts are common in the case of simple, non-persistent presence operation sets. They could however also be seen in persistent presence operation sets when for example we have received an event from someone not on our contact list. Non persistent contacts are volatile even when coming from a persistent presence op. set. They would only exist until the application is closed and will not be there next time it is loaded.

Specified by:
isPersistent in interface Contact
Returns:
true if the contact is persistent and false otherwise.

setPersistent

public void setPersistent(boolean isPersistent)
Specifies whether or not this contact is being stored by the server. Non persistent contacts are common in the case of simple, non-persistent presence operation sets. They could however also be seen in persistent presence operation sets when for example we have received an event from someone not on our contact list. Non persistent contacts are volatile even when coming from a persistent presence op. set. They would only exist until the application is closed and will not be there next time it is loaded.

Parameters:
isPersistent - true if the contact is persistent and false otherwise.

isXCapResolved

public boolean isXCapResolved()
Gets the value of the xCapResolved property.

Returns:
the xCapResolved property.

setXCapResolved

public void setXCapResolved(boolean xCapResolved)
Sets the value of the xCapResolved property.

Parameters:
xCapResolved - the xCapResolved to set.

getPersistentData

public String getPersistentData()
Gets the persistent data - for now only the XCAP resolved is needed for restoring the contact data. Fields are properties separated by ;

Specified by:
getPersistentData in interface Contact
Returns:
the persistent data

setPersistentData

public void setPersistentData(String persistentData)
Sets the persistent data.

Parameters:
persistentData - the persistent data to set.

isResolved

public boolean isResolved()
Determines whether or not this contact has been resolved against the server. Unresolved contacts are used when initially loading a contact list that has been stored in a local file until the presence operation set has managed to retrieve all the contact list from the server and has properly mapped contacts to their on-line buddies.

Specified by:
isResolved in interface Contact
Returns:
true if the contact has been resolved (mapped against a buddy) and false otherwise.

setResolved

public void setResolved(boolean resolved)
Makes the contact resolved or unresolved.

Parameters:
resolved - true to make the contact resolved; false to make it unresolved

isResolvable

public boolean isResolvable()
Determines whether or not this contact can be resolved against the server.

Returns:
true if the contact can be resolved (mapped against a buddy) and false otherwise.

setResolvable

public void setResolvable(boolean resolvable)
Makes the contact resolvable or unresolvable.

Parameters:
resolvable - true to make the contact resolvable; false to make it unresolvable

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one which in terms of contacts translates to having equal ids. The resolved status of the contacts deliberately ignored so that contacts would be declared equal even if it differs.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this contact has the same id as that of the obj argument.

getParentPresenceOperationSet

public OperationSetPresenceSipImpl getParentPresenceOperationSet()
Returns the presence operation set that this contact belongs to.

Returns:
the OperationSetPresenceSipImpl that this contact belongs to.

getStatusMessage

public String getStatusMessage()
Return the current status message of this contact.

Specified by:
getStatusMessage in interface Contact
Returns:
null as the protocol has currently no support of status messages

getSubscriptionState

public String getSubscriptionState()
Current subscription state of the contact. One of: SubscriptionStateHeader.PENDING, SubscriptionStateHeader.ACTIVE, SubscriptionStateHeader.TERMINATED.

Returns:
current subscription state.

setSubscriptionState

public void setSubscriptionState(String subscriptionState)
Change current subscription state.

Parameters:
subscriptionState - the new state.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.