Class jabberwerx.CapabilitiesController
Extends
jabberwerx.Controller.
Controller class for capability functionality. This class is responsible for attaching the capabilities element to all outgoing presence stanzas. It also registers for disco info iq messages and responds with the identity and list of supported capabilities of this client. The feature set for this client can be modified using the add and remove Feature methods, or by modifying the jabberwerx_config option before loading the library. This is referred to as "Outgoing Caps."
Any incoming caps information from a presence packet will be stored in this controller. If the hash referred to in the caps portion of the presence is not known, a disco#info iq will be sent out to the owner of the unknown hash. The caps hash will have a list of associated JIDs and a list of the capabilities associated with the hash. This is referred to as "Incoming Caps."
All methods that are Incoming Caps will not wait for the disco#info request before returning. They return the current information for that particular JID at the time of the method call. It is best to call the Incoming Caps methods in the "entityUpdated" event callback.
Constructor Attributes | Constructor Name and Description |
---|---|
Creates a new CapabilitiesController with the given client.
|
Field Attributes | Field Name and Description |
---|---|
This simple object defines the identity to use in disco#info messages.
|
|
This is the node value sent out as part of the capabilities of this client. |
- Fields borrowed from class jabberwerx.Controller:
- client, name
Method Attributes | Method Name and Description |
---|---|
addFeature(feature)
Add a feature to the feature set. |
|
addFeatureToJid(jid, feature)
Add a feature to the feature set for the given jid. |
|
containsFeature(feature)
Returns true if the feature is in the feature set, or false if not present. |
|
containsFeatureForJid(jid, feature)
Checks to see if the given feature is in the list for the given jid. |
|
destroy()
Destroys this CapabilitiesController.
|
|
generateVerificationString(features)
Generate the verification string according to XEP-0115 Section 5. |
|
getFeatures(jid)
Get Features for the given JID.
|
|
Get the alphabetically sorted array of features in the feature set This is an Outgoing Caps method. |
|
This function returns set of features for the given verification string. |
|
getIdentities(jid)
Get Identities for the given JID.
|
|
getSupportedResources(jid, feature)
Fetch all resources of the given jid that support the requested feature. |
|
getVerificationString(nodeVal)
This functions returns verification string based on node value passed. |
|
Helper function used in unit tests which returns verification string for the given jid. |
|
isSupportedFeature(jid, feature)
Checks capablility information of given JID for requested feature. |
|
removeFeature(feature)
Remove feature from the feature set. |
|
removeFeatureFromJid(jid, feature)
Remove feature from the feature set for the given jid. |
- Methods borrowed from class jabberwerx.Controller:
- cleanupEntity, removeEntity, updateEntity
- Methods borrowed from class jabberwerx.JWModel:
- applyEvent, event, shouldBeSavedWithGraph
- Methods borrowed from class jabberwerx.JWBase:
- getClassName, graphUnserialized, init, invocation, shouldBeSerializedInline, toString, wasUnserialized, willBeSerialized
- Parameters:
- {jabberwerx.Client} client
- The owning client
- Throws:
- {TypeError}
- If {client} is not valid
This is an Outgoing Caps property.
This is the node value sent out as part of the capabilities of this client. It defaults to 'http://jabber.cisco.com/caxl'. Most clients will want to change this value. It can be modified directly via jabberwerx.client.controller['capabilities'].node, or through the jabberwerx_config object.
This is an Outgoing Caps property.
Add a feature to the feature set. If the feature already exists within the set then it will not be added again and false will be returned.
This is an Outgoing Caps method.
- Parameters:
- {String} feature
- Feature to add to feature set
- Returns:
- {Boolean} true if successfully added, false if unsuccessful
Add a feature to the feature set for the given jid. If the feature already exists within the set then it will not be added again and false will be returned.
This is an Outgoing Caps method.
- Parameters:
- {String|jabberwerx.JID} jid
- The jid for which to add feature
- {String} feature
- Feature to add to feature set
- Throws:
- {TypeError}
- If feature is not a non empty string.
- {jabberwerx.JID.InvalidJIDError}
- If {jid} could not be converted into a JID
- Returns:
- {Boolean} true if successfully added, false if unsuccessful
Returns true if the feature is in the feature set, or false if not present.
This is an Outgoing Caps method.
- Parameters:
- {String} feature
- for which to check for
- Returns:
- {Boolean} true if present, otherwise false
Checks to see if the given feature is in the list for the given jid.
This is an Outgoing Caps method.
- Parameters:
- {String|jabberwerx.JID} jid
- The jid for which to lookup a feature
- {String} feature
- Feature to look up
- Throws:
- {TypeError}
- If feature is not a non empty string.
- {jabberwerx.JID.InvalidJIDError}
- If {jid} could not be converted into a JID
- Returns:
- {Boolean} true if found, false otherwise
Generate the verification string according to XEP-0115 Section 5. Uses the SHA-1 algorithm. Uses the feature set and identity to determine the verification string.
This is an Outgoing Caps method.
- Parameters:
- {Array} features Optional
- Array of features
- Returns:
- {String} the verification string
This is an Incomming Caps method.
- Parameters:
- {jabberwerx.JID|String} jid
- the bare or full JID to query
- Throws:
- {TypeError}
- if jid is not a valid jabberwerx.JID
- Returns:
- {Array} unique feature strings, may be empty if no matches or features were found.
- See:
- http://xmpp.org/extensions/xep-0030.html for complete discussion of entity features.
Get the alphabetically sorted array of features in the feature set
This is an Outgoing Caps method.
- Returns:
- {String[]} Alphabetically sorted set of features
This function returns set of features for the given verification string.
This is an Outgoing Caps method.
- Parameters:
- {String} ver
- Verification string for which to return the set of features for.
- Throws:
- {TypeError}
- if ver is not a non empty String.
- Returns:
- {String[]} Alphabetically sorted set of features
The returned identity object is defined
{ category {String} The identity category. type {String} The category's type name {String} The human readable name for this identity xmlLang {String} The language code for the name property. }All properties will exist but their value may be an empty String.
This is an Incomming Caps method.
- Parameters:
- {jabberwerx.JID|String} jid
- the bare or full JID to query
- Throws:
- {TypeError}
- if jid is not a valid jabberwerx.JID
- Returns:
- {Array} Identity array, may be empty if no matches were found.
- See:
- http://xmpp.org/extensions/xep-0030.html for complete discussion of entity identities.
- http://xmpp.org/registrar/disco-categories.html for registered categories and corresponding types.
Fetch all resources of the given jid that support the requested feature. Given JID is coerced to bare.
This is an Incoming Caps method.
- Parameters:
- {String|jabberwerx.JID} jid
- base jid for resource search
- {String} feature
- Supported feature
- Throws:
- {TypeError}
- if given feature is not a non-empty string
- {TypeError}
- if given jid is not valid
- Returns:
- {JID[]} of supporting resources. may be empty
This functions returns verification string based on node value passed.
This is an Outgoing Caps method.
- Parameters:
- {String} nodeVal
- for which to return the verification string for
- Returns:
- {String} Returns null if match is not found, otherwise returns verification string
Helper function used in unit tests which returns verification string for the given jid.
This is an Outgoing Caps method.
- Parameters:
- {jabberwerx.JID|String} jid
- The jid for which to return the verification string for.
- Throws:
- {jabberwerx.JID.InvalidJIDError}
- If {jid} could not be converted into a JID
- Returns:
- {String} Returns null if match is not found, otherwise returns verification string
Checks capablility information of given JID for requested feature. All resources of a given bare jid are checked until one supports the feature. A full jid selects at most one caps info.
This is an Incoming Caps method.
- Parameters:
- {String|jabberwerx.JID} jid
- entity to check for features
- {String} feature
- requested feature to search jid's capsinfo for
- Throws:
- {TypeError}
- if feature is not a non empty string.
- Returns:
- {Boolean} true if jid's capsinfo has the given feature
Remove feature from the feature set.
This is an Outgoing Caps method.
- Parameters:
- {String} feature
- The feature in the feature set to remove
- Returns:
- {Boolean} true if successfully removed feature, false if unsuccessful
Remove feature from the feature set for the given jid.
This is an Outgoing Caps method.
- Parameters:
- {String|jabberwerx.JID} jid
- The jid for which to lookup a feature
- {String} feature
- The feature in the feature set to remove
- Throws:
- {TypeError}
- If feature is not a non empty string.
- {jabberwerx.JID.InvalidJIDError}
- If {jid} could not be converted into a JID
- Returns:
- {Boolean} true if successfully removed feature, false otherwise