com.beem.project.beem.smack.avatar
Class AvatarManager

Package class diagram package AvatarManager
java.lang.Object
  extended by com.beem.project.beem.smack.avatar.AvatarManager
Direct Known Subclasses:
BeemAvatarManager

public class AvatarManager
extends Object

This class deals with the avatar data. It can be configured to auto retrieve the avatar and put it in cache.


Field Summary
static String AVATARDATA_NODE
          The pubsub node for avatar data.
static String AVATARMETADATA_NODE
          The pubsub node for avatar metadata.
 
Constructor Summary
  AvatarManager(Connection con, PepSubManager pepMgr, AvatarCache cache, boolean autoDownload)
          Create an AvatarManager.
protected AvatarManager(Connection con, PepSubManager pepMgr, boolean autoDownload)
          Create an AvatarManager.
 
Method Summary
 void addAvatarListener(AvatarListener listener)
          Add an AvatarListener.
 void disableAvatarPublishing()
          Disable the diffusion of your avatar.
 boolean downloadAvatar(String from, String avatarId, AvatarMetadataExtension.Info info)
          Download an avatar.
 byte[] getAvatar(String avatarId)
          Get an avatar from the cache.
protected  String getAvatarId(byte[] data)
          Get the id corresponding to this avatar data.
 boolean publishAvatarData(byte[] data)
          Send an avatar image to the pep server.
 void publishAvatarMetaData(String id, AvatarMetadataExtension metadata)
          Send the metadata of the avatar you want to publish.
 void removeAvatarListener(AvatarListener listener)
          Remove an AvatarListener.
protected  AvatarMetadataExtension.Info selectAvatar(List<AvatarMetadataExtension.Info> available)
          Select the avatar to download.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AVATARDATA_NODE

public static final String AVATARDATA_NODE
The pubsub node for avatar data.

See Also:
Constant Field Values

AVATARMETADATA_NODE

public static final String AVATARMETADATA_NODE
The pubsub node for avatar metadata.

See Also:
Constant Field Values
Constructor Detail

AvatarManager

public AvatarManager(Connection con,
                     PepSubManager pepMgr,
                     AvatarCache cache,
                     boolean autoDownload)
Create an AvatarManager.

Parameters:
con - the connection
pepMgr - the PepSubManager of the Connection
cache - the cache which will store the avatars
autoDownload - true to enable auto download of avatars

AvatarManager

protected AvatarManager(Connection con,
                        PepSubManager pepMgr,
                        boolean autoDownload)
Create an AvatarManager.

Parameters:
con - the connection
pepMgr - the PepSubManager of the Connection
autoDownload - true to enable auto download of avatars
Method Detail

getAvatar

public byte[] getAvatar(String avatarId)
Get an avatar from the cache.

Parameters:
avatarId - the id of the avatar
Returns:
the avatar or null if it cannot be retrieved from the cache

addAvatarListener

public void addAvatarListener(AvatarListener listener)
Add an AvatarListener.

Parameters:
listener - the AvatarListener to add

removeAvatarListener

public void removeAvatarListener(AvatarListener listener)
Remove an AvatarListener.

Parameters:
listener - the AvatarListener to remove

downloadAvatar

public boolean downloadAvatar(String from,
                              String avatarId,
                              AvatarMetadataExtension.Info info)
Download an avatar.

Parameters:
from - The jid of the user
avatarId - the id of the avatar
info - the metadata information of the avatar to download
Returns:
true if the download was successfull

disableAvatarPublishing

public void disableAvatarPublishing()
Disable the diffusion of your avatar.


publishAvatarData

public boolean publishAvatarData(byte[] data)
Send an avatar image to the pep server.

Parameters:
data - the image data.
Returns:
true if the image where successfully sent. false otherwise

publishAvatarMetaData

public void publishAvatarMetaData(String id,
                                  AvatarMetadataExtension metadata)
Send the metadata of the avatar you want to publish. By sending this metadata, you publish an avatar.

Parameters:
id - the id of the metadata item
metadata - the metadata to publish

selectAvatar

protected AvatarMetadataExtension.Info selectAvatar(List<AvatarMetadataExtension.Info> available)
Select the avatar to download. Subclass should override this method to take control over the selection process. This implementation select the first element.

Parameters:
available - list of the avatar metadata information
Returns:
the metadata of the avatar to download

getAvatarId

protected String getAvatarId(byte[] data)
                      throws NoSuchAlgorithmException
Get the id corresponding to this avatar data.

Parameters:
data - the avatar data
Returns:
the id
Throws:
NoSuchAlgorithmException - if the sha-1 algorithm is unavailable


Copyright © 2009 Beem-project.com. All Rights Reserved.