Package org.jivesoftware.smackx.caps
Class EntityCapsManager
java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.caps.EntityCapsManager
Manages own and others Entity Capabilities (XEP-0115).
Entity Capabilities is an XMPP extension which, in order to minimize network impact, caches the capabilities of
remote XMPP entities. Those capabilities are determine with the help of the Service Discovery Protocol
(XEP-0030, ServiceDiscoveryManager).
Usage
Entity Capabilities work silently in the background when enabled. If the remote XMPP entity does not support XEP-0115 but XEP-0030 then XEP-0030 mechanisms are transparently used.
The caches used by Smack for Entity Capabilities is non-persistent per default. However, it is is also possible to set a persistent Entity Capabilities cache, which is recommended.
Examples
Enable Entity Capabilities
// Get an instance of entity caps manager for the specified connection
EntityCapsManager mgr = EntityCapsManager.getInstanceFor(connection);
// Enable entity capabilities
mgr.enableEntityCaps();
Configure a persistent cache for Entity Capabilities
// Get an instance of entity caps manager for the specified connection
EntityCapsManager mgr = EntityCapsManager.getInstanceFor(connection);
// Create an cache, see smackx.entitycaps.cache for pre-defined cache implementations
EntityCapsPersistentCache cache = new SimpleDirectoryPersistentCache(new File("/foo/cachedir"));
// Set the cache
mgr.setPersistentCache(cache);
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if Entity Caps are supported by a given JID.booleanReturns true if Entity Caps are supported by the local service/server.static voidClears the memory cache.voidvoidbooleanGet our own caps version ornullif none is yet set.static DiscoverInfogetDiscoverInfoByUser(Jid user) Get the discover info given a user name.static DiscoverInfogetDiscoveryInfoByNodeVer(String nodeVer) Retrieve DiscoverInfo for a specific node.static EntityCapsManagergetInstanceFor(XMPPConnection connection) Returns the local entity's NodeVer (e.g.getNodeVerHashByJid(Jid jid) static StringgetNodeVersionByJid(Jid jid) Get the Node version (node#ver) of a JID.static voidremoveUserCapsNode(Jid user) Remove a record telling what entity caps node a user has.static voidsetDefaultEntityNode(String entityNode) Set the default entity node that will be used for new EntityCapsManagers.static voidsetMaxsCacheSizes(int maxJidToNodeVerSize, int maxCapsCacheSize) Sets the maximum cache sizes.static voidSet the persistent cache implementation.static booleanverifyDiscoverInfoVersion(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 Details
-
NAMESPACE
- See Also:
-
ELEMENT
- See Also:
-
-
Method Details
-
setDefaultEntityNode
Set the default entity node that will be used for new EntityCapsManagers.- Parameters:
entityNode- TODO javadoc me please
-
getNodeVersionByJid
Get the Node version (node#ver) of a JID. Returns a String or null if EntityCapsManager does not have any information.- Parameters:
jid- TODO javadoc me please the user (Full JID)- Returns:
- the node version (node#ver) or null
-
getNodeVerHashByJid
-
getDiscoverInfoByUser
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
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
Set the persistent cache implementation.- Parameters:
cache- TODO javadoc me please
-
setMaxsCacheSizes
Sets the maximum cache sizes.- Parameters:
maxJidToNodeVerSize- TODO javadoc me pleasemaxCapsCacheSize- TODO javadoc me please
-
clearMemoryCache
Clears the memory cache. -
getInstanceFor
-
enableEntityCaps
-
disableEntityCaps
-
entityCapsEnabled
-
removeUserCapsNode
Remove a record telling what entity caps node a user has.- Parameters:
user- TODO javadoc me please the user (Full JID)
-
getCapsVersionAndHash
Get our own caps version ornullif none is yet set. The version depends on the enabled features. A caps version looks like '66/0NaeaBKkwk85efJTGmU47vXI='- Returns:
- our own caps version or
null.
-
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, InterruptedExceptionReturns 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
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:
-