Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber
Class ContactJabberImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.jabber.ContactJabberImpl
All Implemented Interfaces:
Contact
Direct Known Subclasses:
VolatileContactJabberImpl

public class ContactJabberImpl
extends Object
implements Contact

The Jabber implementation of the service.protocol.Contact interface.

Author:
Damian Minkov, Lubomir Marinov

Constructor Summary
ContactJabberImpl(org.jivesoftware.smack.RosterEntry rosterEntry, ServerStoredContactListJabberImpl ssclCallback, boolean isPersistent, boolean isResolved)
          Creates an JabberContactImpl
ContactJabberImpl(String id, ServerStoredContactListJabberImpl ssclCallback, boolean isPersistent)
          Used to create unresolved contacts with specified id.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 String getAddress()
          Returns the Jabber Userid of this contact
 String getDisplayName()
          Returns a String that could be used by any user interacting modules for referring to this contact.
 byte[] getImage()
          Returns an avatar if one is already present or null in case it is not in which case it the method also queues the contact for image updates.
 byte[] getImage(boolean retrieveIfNecessary)
          Returns a reference to the image assigned to this contact.
 ContactGroup getParentContactGroup()
          Returns a reference to the contact group that this contact is currently a child of or null if the underlying protocol does not support persistent presence.
 String getPersistentData()
          Returns the persistent data
 PresenceStatus getPresenceStatus()
          Returns the status of the contact as per the last status update we've received for it.
 ProtocolProviderService getProtocolProvider()
          Returns a reference to the protocol provider that created the contact.
(package private)  String getServerDisplayName()
          Returns the display name used when the contact was resolved.
(package private)  org.jivesoftware.smack.RosterEntry getSourceEntry()
          Get source entry
 String getStatusMessage()
          Return the current status message of this contact.
 int hashCode()
          Returns a hashCode for this contact.
 boolean isLocal()
          Determines whether or not this Contact instance represents the user used by this protocol provider to connect to the service.
 boolean isPersistent()
          Determines whether or not this contact is being stored by the server.
 boolean isResolved()
          Determines whether or not this contact has been resolved against the server.
 void setImage(byte[] imgBytes)
          Set the image of the contact
(package private)  void setPersistent(boolean persistent)
          Specifies whether this contact is to be considered persistent or not.
 void setPersistentData(String persistentData)
          Not used.
(package private)  void setResolved(org.jivesoftware.smack.RosterEntry entry)
          Resolve this contact against the given entry
(package private)  void setServerDisplayName(String newValue)
          Changes locally stored server display name.
protected  void setStatusMessage(String statusMessage)
          Sets the current status message for this contact
 String toString()
          Returns a string representation of this contact, containing most of its representative details.
(package private)  void updatePresenceStatus(PresenceStatus status)
          Sets the status that this contact is currently in.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContactJabberImpl

ContactJabberImpl(org.jivesoftware.smack.RosterEntry rosterEntry,
                  ServerStoredContactListJabberImpl ssclCallback,
                  boolean isPersistent,
                  boolean isResolved)
Creates an JabberContactImpl

Parameters:
rosterEntry - the RosterEntry object that we will be encapsulating.
ssclCallback - a reference to the ServerStoredContactListImpl instance that created us.
isPersistent - determines whether this contact is persistent or not.
isResolved - specifies whether the contact has been resolved against the server contact list

ContactJabberImpl

ContactJabberImpl(String id,
                  ServerStoredContactListJabberImpl ssclCallback,
                  boolean isPersistent)
Used to create unresolved contacts with specified id.

Parameters:
id - contact id
ssclCallback - the contact list handler that creates us.
isPersistent - is the contact persistent.
Method Detail

getAddress

public String getAddress()
Returns the Jabber Userid of this contact

Specified by:
getAddress in interface Contact
Returns:
the Jabber Userid of this contact

isLocal

public boolean isLocal()
Determines whether or not this Contact instance represents the user used by this protocol provider to connect to the service.

Returns:
true if this Contact represents us (the local user) and false otherwise.

getImage

public byte[] getImage()
Returns an avatar if one is already present or null in case it is not in which case it the method also queues the contact for image updates.

Specified by:
getImage in interface Contact
Returns:
the avatar of this contact or null if no avatar is currently available.

getImage

public byte[] getImage(boolean retrieveIfNecessary)
Returns a reference to the image assigned to this contact. If no image is present and the retrieveIfNecessary flag is true, we schedule the image for retrieval from the server.

Parameters:
retrieveIfNecessary - specifies whether the method should queue this contact for avatar update from the server.
Returns:
a reference to the image currently stored by this contact.

setImage

public void setImage(byte[] imgBytes)
Set the image of the contact

Parameters:
imgBytes - the bytes of the image that we'd like to set.

hashCode

public int hashCode()
Returns a hashCode for this contact. The returned hashcode is actually that of the Contact's Address

Overrides:
hashCode in class Object
Returns:
the hashcode of this Contact

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

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.

updatePresenceStatus

void updatePresenceStatus(PresenceStatus status)
Sets the status that this contact is currently in. The method is to only be called as a result of a status update received from the server.

Parameters:
status - the JabberStatusEnum that this contact is currently in.

getPresenceStatus

public PresenceStatus getPresenceStatus()
Returns the status of the contact as per the last status update we've received for it. Note that this method is not to perform any network operations and will simply return the status received in the last status update message. If you want a reliable way of retrieving someone's status, you should use the queryContactStatus() method in OperationSetPresence.

Specified by:
getPresenceStatus in interface Contact
Returns:
the PresenceStatus that we've received in the last status update pertaining to this contact.

getDisplayName

public String getDisplayName()
Returns a String that could be used by any user interacting modules for referring to this contact. An alias is not necessarily unique but is often more human readable than an address (or id).

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

getServerDisplayName

String getServerDisplayName()
Returns the display name used when the contact was resolved. Used to detect renames.

Returns:
the display name.

setServerDisplayName

void setServerDisplayName(String newValue)
Changes locally stored server display name.

Parameters:
newValue -

getParentContactGroup

public ContactGroup getParentContactGroup()
Returns a reference to the contact group that this contact is currently a child of or null if the underlying protocol does not support persistent presence.

Specified by:
getParentContactGroup in interface Contact
Returns:
a reference to the contact group that this contact is currently a child of or null if the underlying protocol does not support persistent presence.

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

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

void setPersistent(boolean persistent)
Specifies whether this contact is to be considered persistent or not. The method is to be used _only_ when a non-persistent contact has been added to the contact list and its encapsulated VolatileBuddy has been repalced with a standard buddy.

Parameters:
persistent - true if the buddy is to be considered persistent and false for volatile.

setResolved

void setResolved(org.jivesoftware.smack.RosterEntry entry)
Resolve this contact against the given entry

Parameters:
entry - the server stored entry

getPersistentData

public String getPersistentData()
Returns the persistent data

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

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.

setPersistentData

public void setPersistentData(String persistentData)
Not used.

Parameters:
persistentData - the persistent data.

getSourceEntry

org.jivesoftware.smack.RosterEntry getSourceEntry()
Get source entry

Returns:
RosterEntry

getStatusMessage

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

Specified by:
getStatusMessage in interface Contact
Returns:
the current status message

setStatusMessage

protected void setStatusMessage(String statusMessage)
Sets the current status message for this contact

Parameters:
statusMessage - the message

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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