Package org.jivesoftware.smackx.caps
Class EntityCapsManager
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smackx.caps.EntityCapsManager
-
public final class EntityCapsManager extends Manager
Keeps track of entity capabilities.- See Also:
- XEP-0115: Entity Capabilities
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EntityCapsManager.NodeVerHash
-
Field Summary
Fields Modifier and Type Field Description static String
ELEMENT
static String
NAMESPACE
protected static EntityCapsPersistentCache
persistentCache
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areEntityCapsSupported(Jid jid)
Returns true if Entity Caps are supported by a given JID.boolean
areEntityCapsSupportedByServer()
Returns true if Entity Caps are supported by the local service/server.static void
clearMemoryCache()
Clears the memory cache.void
disableEntityCaps()
void
enableEntityCaps()
boolean
entityCapsEnabled()
protected static CapsVersionAndHash
generateVerificationString(DiscoverInfoView discoverInfo)
protected static CapsVersionAndHash
generateVerificationString(DiscoverInfoView discoverInfo, String hash)
Generates a XEP-115 Verification StringCapsVersionAndHash
getCapsVersionAndHash()
Get our own caps version.static DiscoverInfo
getDiscoverInfoByUser(Jid user)
Get the discover info given a user name.static DiscoverInfo
getDiscoveryInfoByNodeVer(String nodeVer)
Retrieve DiscoverInfo for a specific node.static EntityCapsManager
getInstanceFor(XMPPConnection connection)
String
getLocalNodeVer()
Returns the local entity's NodeVer (e.g.static EntityCapsManager.NodeVerHash
getNodeVerHashByJid(Jid jid)
static String
getNodeVersionByJid(Jid jid)
Get the Node version (node#ver) of a JID.static void
removeUserCapsNode(Jid user)
Remove a record telling what entity caps node a user has.static void
setDefaultEntityNode(String entityNode)
Set the default entity node that will be used for new EntityCapsManagers.static void
setMaxsCacheSizes(int maxJidToNodeVerSize, int maxCapsCacheSize)
Sets the maximum cache sizes.static void
setPersistentCache(EntityCapsPersistentCache cache)
Set the persistent cache implementation.static boolean
verifyDiscoverInfoVersion(String ver, String hash, DiscoverInfo info)
Verify DiscoverInfo and Caps Node as defined in XEP-0115 5.4 Processing Method.-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Field Detail
-
NAMESPACE
public static final String NAMESPACE
- See Also:
- Constant Field Values
-
ELEMENT
public static final String ELEMENT
- See Also:
- Constant Field Values
-
persistentCache
protected static EntityCapsPersistentCache persistentCache
-
-
Method Detail
-
setDefaultEntityNode
public static void setDefaultEntityNode(String entityNode)
Set the default entity node that will be used for new EntityCapsManagers.- Parameters:
entityNode
- TODO javadoc me please
-
getNodeVersionByJid
public static String getNodeVersionByJid(Jid jid)
Get the Node version (node#ver) of a JID. Returns a String or null if EntiyCapsManager does not have any information.- Parameters:
jid
- TODO javadoc me please the user (Full JID)- Returns:
- the node version (node#ver) or null
-
getNodeVerHashByJid
public static EntityCapsManager.NodeVerHash getNodeVerHashByJid(Jid jid)
-
getDiscoverInfoByUser
public static DiscoverInfo getDiscoverInfoByUser(Jid 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
- TODO javadoc me please user name (Full JID)- Returns:
- the discovered info
-
getDiscoveryInfoByNodeVer
public static DiscoverInfo getDiscoveryInfoByNodeVer(String nodeVer)
Retrieve DiscoverInfo for a specific node.- Parameters:
nodeVer
- TODO javadoc me please The node name (e.g. "http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w=").- Returns:
- The corresponding DiscoverInfo or null if none is known.
-
setPersistentCache
public static void setPersistentCache(EntityCapsPersistentCache cache)
Set the persistent cache implementation.- Parameters:
cache
- TODO javadoc me please
-
setMaxsCacheSizes
public static void setMaxsCacheSizes(int maxJidToNodeVerSize, int maxCapsCacheSize)
Sets the maximum cache sizes.- Parameters:
maxJidToNodeVerSize
- TODO javadoc me pleasemaxCapsCacheSize
- TODO javadoc me please
-
clearMemoryCache
public static void clearMemoryCache()
Clears the memory cache.
-
getInstanceFor
public static EntityCapsManager getInstanceFor(XMPPConnection connection)
-
enableEntityCaps
public void enableEntityCaps()
-
disableEntityCaps
public void disableEntityCaps()
-
entityCapsEnabled
public boolean entityCapsEnabled()
-
removeUserCapsNode
public static void removeUserCapsNode(Jid user)
Remove a record telling what entity caps node a user has.- Parameters:
user
- TODO javadoc me please the user (Full JID)
-
getCapsVersionAndHash
public CapsVersionAndHash getCapsVersionAndHash()
Get our own caps version. The version depends on the enabled features. A caps version looks like '66/0NaeaBKkwk85efJTGmU47vXI='- Returns:
- our own caps version
-
getLocalNodeVer
public String getLocalNodeVer()
Returns the local entity's NodeVer (e.g. "http://www.igniterealtime.org/projects/smack/#66/0NaeaBKkwk85efJTGmU47vXI= )- Returns:
- the local NodeVer
-
areEntityCapsSupported
public boolean areEntityCapsSupported(Jid jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Returns true if Entity Caps are supported by a given JID.- Parameters:
jid
- TODO javadoc me please- Returns:
- true if the entity supports Entity Capabilities.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
areEntityCapsSupportedByServer
public boolean areEntityCapsSupportedByServer() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Returns true if Entity Caps are supported by the local service/server.- Returns:
- true if the user's server supports Entity Capabilities.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
verifyDiscoverInfoVersion
public static boolean verifyDiscoverInfoVersion(String ver, String hash, DiscoverInfo info)
Verify DiscoverInfo and Caps Node as defined in XEP-0115 5.4 Processing Method.- Parameters:
ver
- TODO javadoc me pleasehash
- TODO javadoc me pleaseinfo
- TODO javadoc me please- Returns:
- true if it's valid and should be cache, false if not
- See Also:
- XEP-0115 5.4 Processing Method
-
generateVerificationString
protected static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo)
-
generateVerificationString
protected static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo, String hash)
Generates a XEP-115 Verification String- Parameters:
discoverInfo
- TODO javadoc me pleasehash
- TODO javadoc me please the used hash function, if null, default hash will be used- Returns:
- The generated verification String or null if the hash is not supported
- See Also:
- XEP-115 Verification String
-
-