Index: src/XMPPDiscoEntity.h ================================================================== --- src/XMPPDiscoEntity.h +++ src/XMPPDiscoEntity.h @@ -72,7 +72,14 @@ * * \param node The XMPPDiscoNode to provide responses for */ - (void)addDiscoNode: (XMPPDiscoNode*)node; +/** + * \brief Calculates the Entity Capabilities Hash of the entity + * + * \return A OFString containing the capabilities hash + */ +- (OFString*)capsHash; + - (OFDictionary*)discoNodes; @end Index: src/XMPPDiscoEntity.m ================================================================== --- src/XMPPDiscoEntity.m +++ src/XMPPDiscoEntity.m @@ -19,10 +19,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #import "XMPPDiscoEntity.h" +#import "XMPPDiscoIdentity.h" #import "XMPPIQ.h" #import "namespaces.h" @implementation XMPPDiscoEntity + discoEntityWithConnection: (XMPPConnection*)connection @@ -64,10 +65,29 @@ - (void)addDiscoNode: (XMPPDiscoNode*)node { [_discoNodes setObject: node forKey: [node node]]; } + +- (OFString*)capsHash +{ + OFMutableString *caps = [OFMutableString string]; + OFEnumerator *enumerator; + XMPPDiscoIdentity *identity; + OFString *feature; + + enumerator = [_identities objectEnumerator]; + while ((identity = [enumerator nextObject]) != nil) + [caps appendFormat: @"%@/%@//%@<", [identity category], + [identity type], [identity name]]; + + enumerator = [_features objectEnumerator]; + while ((feature = [enumerator nextObject]) != nil) + [caps appendFormat: @"%@<", feature]; + + return [caps SHA1Hash]; +} - (BOOL)connection: (XMPPConnection*)connection didReceiveIQ: (XMPPIQ*)IQ { of_log(@"Called connection:didReceiveIQ:... %@ %@", [IQ to], _JID);