Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber.extensions.caps
Class EntityCapsManager

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.jabber.extensions.caps.EntityCapsManager

public class EntityCapsManager
extends Object

Keeps track of entity capabilities. This work is based on Jonas Adahl's smack fork.

Author:
Emil Ivov, Lubomir Marinov

Nested Class Summary
static class EntityCapsManager.Caps
          Implements an immutable value which stands for a specific node, a specific hash (algorithm) and a specific ver.
 
Constructor Summary
EntityCapsManager()
           
 
Method Summary
 void addCapsVerListener(CapsVerListener listener)
          Adds listener to the list of CapsVerListeners that we notify when new features occur and the version hash needs to be regenerated.
static void addDiscoverInfoByCaps(EntityCapsManager.Caps caps, org.jivesoftware.smackx.packet.DiscoverInfo info)
          Add DiscoverInfo to our caps database.
 void addPacketListener(org.jivesoftware.smack.XMPPConnection connection)
          Registers this Manager's listener with connection.
 void addUserCapsNodeListener(UserCapsNodeListener listener)
          Adds a specific UserCapsNodeListener to the list of UserCapsNodeListeners interested in events notifying about changes in the list of user caps nodes of this EntityCapsManager.
 void calculateEntityCapsVersion(org.jivesoftware.smackx.packet.DiscoverInfo discoverInfo)
          Calculates the ver string for the specified discoverInfo, identity type, name features, and extendedInfo.
 EntityCapsManager.Caps getCapsByUser(String user)
          Gets the Caps i.e.
 String getCapsVersion()
          Get our own caps version.
static org.jivesoftware.smackx.packet.DiscoverInfo getDiscoverInfoByCaps(EntityCapsManager.Caps caps)
          Retrieve DiscoverInfo for a specific node.
 org.jivesoftware.smackx.packet.DiscoverInfo getDiscoverInfoByUser(String user)
          Get the discover info given a user name.
 String getNode()
          Get our own entity node.
 void removeCapsVerListener(CapsVerListener listener)
          Removes listener from the list of currently registered CapsVerListeners.
 void removeContactCapsNode(Contact contact)
          Remove records telling what entity caps node a contact has.
 void removeUserCapsNode(String user)
          Remove a record telling what entity caps node a user has.
 void removeUserCapsNodeListener(UserCapsNodeListener listener)
          Removes a specific UserCapsNodeListener from the list of UserCapsNodeListeners interested in events notifying about changes in the list of user caps nodes of this EntityCapsManager.
 void setCurrentCapsVersion(org.jivesoftware.smackx.packet.DiscoverInfo discoverInfo, String capsVersion)
          Set our own caps version.
 void setNode(String node)
          Set our own entity node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityCapsManager

public EntityCapsManager()
Method Detail

addDiscoverInfoByCaps

public static void addDiscoverInfoByCaps(EntityCapsManager.Caps caps,
                                         org.jivesoftware.smackx.packet.DiscoverInfo info)
Add DiscoverInfo to our caps database.

Warning: The specified DiscoverInfo is trusted to be valid with respect to the specified Caps for performance reasons because the DiscoverInfo should have already been validated in order to be used elsewhere anyway.

Parameters:
caps - the Caps i.e. the node, the hash and the ver for which a DiscoverInfo is to be added to our caps database.
info - DiscoverInfo for the specified Caps.

addUserCapsNodeListener

public void addUserCapsNodeListener(UserCapsNodeListener listener)
Adds a specific UserCapsNodeListener to the list of UserCapsNodeListeners interested in events notifying about changes in the list of user caps nodes of this EntityCapsManager.

Parameters:
listener - the UserCapsNodeListener which is interested in events notifying about changes in the list of user caps nodes of this EntityCapsManager

removeContactCapsNode

public void removeContactCapsNode(Contact contact)
Remove records telling what entity caps node a contact has.

Parameters:
contact - the contact

removeUserCapsNode

public void removeUserCapsNode(String user)
Remove a record telling what entity caps node a user has.

Parameters:
user - the user (Full JID)

removeUserCapsNodeListener

public void removeUserCapsNodeListener(UserCapsNodeListener listener)
Removes a specific UserCapsNodeListener from the list of UserCapsNodeListeners interested in events notifying about changes in the list of user caps nodes of this EntityCapsManager.

Parameters:
listener - the UserCapsNodeListener which is no longer interested in events notifying about changes in the list of user caps nodes of this EntityCapsManager

getCapsByUser

public EntityCapsManager.Caps getCapsByUser(String user)
Gets the Caps i.e. the node, the hash and the ver of a user.

Parameters:
user - the user (Full JID)
Returns:
the Caps i.e. the node, the hash and the ver of user

getDiscoverInfoByUser

public org.jivesoftware.smackx.packet.DiscoverInfo getDiscoverInfoByUser(String user)
Get the discover info given a user name. The discover info is returned if the user has a node#ver associated with it and the node#ver has a discover info associated with it.

Parameters:
user - user name (Full JID)
Returns:
the discovered info

getCapsVersion

public String getCapsVersion()
Get our own caps version.

Returns:
our own caps version

getNode

public String getNode()
Get our own entity node.

Returns:
our own entity node.

setNode

public void setNode(String node)
Set our own entity node.

Parameters:
node - the new node

getDiscoverInfoByCaps

public static org.jivesoftware.smackx.packet.DiscoverInfo getDiscoverInfoByCaps(EntityCapsManager.Caps caps)
Retrieve DiscoverInfo for a specific node.

Parameters:
caps - the Caps i.e. the node, the hash and the ver
Returns:
The corresponding DiscoverInfo or null if none is known.

addPacketListener

public void addPacketListener(org.jivesoftware.smack.XMPPConnection connection)
Registers this Manager's listener with connection.

Parameters:
connection - the connection that we'd like this manager to register with.

addCapsVerListener

public void addCapsVerListener(CapsVerListener listener)
Adds listener to the list of CapsVerListeners that we notify when new features occur and the version hash needs to be regenerated. The method would also notify listener if our current caps version has been generated and is different than null.

Parameters:
listener - the CapsVerListener we'd like to register.

removeCapsVerListener

public void removeCapsVerListener(CapsVerListener listener)
Removes listener from the list of currently registered CapsVerListeners.

Parameters:
listener - the CapsVerListener we'd like to unregister.

calculateEntityCapsVersion

public void calculateEntityCapsVersion(org.jivesoftware.smackx.packet.DiscoverInfo discoverInfo)
Calculates the ver string for the specified discoverInfo, identity type, name features, and extendedInfo.

Parameters:
discoverInfo - the DiscoverInfo we'd be creating a ver String for

setCurrentCapsVersion

public void setCurrentCapsVersion(org.jivesoftware.smackx.packet.DiscoverInfo discoverInfo,
                                  String capsVersion)
Set our own caps version.

Parameters:
discoverInfo - the DiscoverInfo that we'd like to map to the capsVersion.
capsVersion - the new caps version

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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