Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.msn
Class ContactMsnImpl

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

public class ContactMsnImpl
extends Object
implements Contact

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

Author:
Damian Minkov

Constructor Summary
ContactMsnImpl(net.sf.jml.MsnContact contact, ServerStoredContactListMsnImpl ssclCallback, boolean isPersistent, boolean isResolved)
          Creates an MsnContactImpl
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 String getAddress()
          Returns the Msn 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.
(package private)  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 suppord 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)  net.sf.jml.MsnContact getSourceContact()
          Get source contact
 String getStatusMessage()
          Return the current status message of this contact.
 int hashCode()
          Returns a hashCode for this contact.
 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.
(package private)  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)
           
(package private)  void setResolved(net.sf.jml.MsnContact entry)
          Resolve this contact against the given entry
 void setStatusMessage(String newStatusMessage)
          Changes the current status message of 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

ContactMsnImpl

ContactMsnImpl(net.sf.jml.MsnContact contact,
               ServerStoredContactListMsnImpl ssclCallback,
               boolean isPersistent,
               boolean isResolved)
Creates an MsnContactImpl

Parameters:
contact - the contact 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
Method Detail

getAddress

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

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

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

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

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

Parameters:
imgBytes - the new image we'd like to assign this contact.

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 MsnStatusEnum 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.

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 suppord 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 suppord 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(net.sf.jml.MsnContact 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)

getSourceContact

net.sf.jml.MsnContact getSourceContact()
Get source contact

Returns:
MsnContact

getStatusMessage

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

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

setStatusMessage

public void setStatusMessage(String newStatusMessage)
Changes the current status message of this contact.

Parameters:
newStatusMessage - the new message.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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