Index: src/XMPPDiscoEntity.h ================================================================== --- src/XMPPDiscoEntity.h +++ src/XMPPDiscoEntity.h @@ -33,10 +33,11 @@ */ @interface XMPPDiscoEntity: XMPPDiscoNode { OFMutableDictionary *_discoNodes; XMPPConnection *_connection; + OFString *_capsNode; } #ifdef OF_HAVE_PROPERTIES /** * \brief The XMPPDiscoNodes this entity provides Services Discovery * responses for @@ -43,10 +44,12 @@ * * This usually contains at least all immediate child nodes, but may contain * any number of nodes nested more deeply. */ @property (readonly) OFDictionary *discoNodes; +/// \brief The node advertised for the entity's capabilites +@property (readonly) OFString *capsNode; #endif /** * \brief Creates a new autoreleased XMPPDiscoEntity with the specified * connection. @@ -55,10 +58,22 @@ * This must already be bound to a resource) * \return A new autoreleased XMPPDiscoEntity */ + discoEntityWithConnection: (XMPPConnection*)connection; +/** + * \brief Creates a new autoreleased XMPPDiscoEntity with the specified + * connection. + * + * \param connection The XMPPConnection to serve responses on. + * This must already be bound to a resource) + * \param capsNode The node advertised for the entity's capabilites + * \return A new autoreleased XMPPDiscoEntity + */ ++ discoEntityWithConnection: (XMPPConnection*)connection + capsNode: (OFString*)capsNode; + /** * \brief Initializes an already allocated XMPPDiscoEntity with the specified * connection. * * \param connection The XMPPConnection to serve responses on. @@ -65,10 +80,22 @@ * This must already be bound to a resource) * \return An initialized XMPPDiscoEntity */ - initWithConnection: (XMPPConnection*)connection; +/** + * \brief Initializes an already allocated XMPPDiscoEntity with the specified + * connection. + * + * \param connection The XMPPConnection to serve responses on. + * This must already be bound to a resource) + * \param capsNode The node advertised for the entity's capabilites + * \return An initialized XMPPDiscoEntity + */ +- initWithConnection: (XMPPConnection*)connection + capsNode: (OFString*)capsNode; + /** * \brief Adds a XMPPDiscoNode to provide responses for. * * \param node The XMPPDiscoNode to provide responses for */ @@ -80,6 +107,7 @@ * \return A OFString containing the capabilities hash */ - (OFString*)capsHash; - (OFDictionary*)discoNodes; +- (OFString*)capsNode; @end Index: src/XMPPDiscoEntity.m ================================================================== --- src/XMPPDiscoEntity.m +++ src/XMPPDiscoEntity.m @@ -28,19 +28,34 @@ @implementation XMPPDiscoEntity + discoEntityWithConnection: (XMPPConnection*)connection { return [[[self alloc] initWithConnection: connection] autorelease]; } + ++ discoEntityWithConnection: (XMPPConnection*)connection + capsNode: (OFString*)capsNode +{ + return [[[self alloc] initWithConnection: connection + capsNode: capsNode] autorelease]; +} + +- initWithConnection: (XMPPConnection*)connection +{ + return [self initWithConnection: connection + capsNode: nil]; +} - initWithConnection: (XMPPConnection*)connection + capsNode: (OFString*)capsNode { self = [super initWithJID: [connection JID] node: nil]; @try { _discoNodes = [OFMutableDictionary new]; _connection = connection; + _capsNode = [capsNode copy]; [_connection addDelegate: self]; } @catch (id e) { [self release]; @throw e; @@ -65,10 +80,15 @@ - (void)addDiscoNode: (XMPPDiscoNode*)node { [_discoNodes setObject: node forKey: [node node]]; } + +- (OFString*)capsNode +{ + OF_GETTER(_capsNode, YES); +} - (OFString*)capsHash { OFMutableString *caps = [OFMutableString string]; OFEnumerator *enumerator; @@ -115,11 +135,18 @@ namespace: XMPP_NS_DISCO_INFO]; if (query != nil) { OFString *node = [[query attributeForName: @"node"] stringValue]; + if (node == nil) + return [self XMPP_handleInfoIQ: IQ + connection: connection]; + + OFString *capsNode = [_capsNode stringByAppendingFormat: @"#%@", + [self capsHash]]; + if ([capsNode isEqual: node]) return [self XMPP_handleInfoIQ: IQ connection: connection]; XMPPDiscoNode *responder = [_discoNodes objectForKey: node]; if (responder != nil) Index: src/XMPPDiscoNode.m ================================================================== --- src/XMPPDiscoNode.m +++ src/XMPPDiscoNode.m @@ -188,16 +188,10 @@ XMPPIQ *resultIQ; OFXMLElement *response; OFEnumerator *enumerator; OFString *feature; XMPPDiscoIdentity *identity; - OFXMLElement *query = [IQ elementForName: @"query" - namespace: XMPP_NS_DISCO_INFO]; - OFString *node = [[query attributeForName: @"node"] stringValue]; - - if (!(node == _node) && ![node isEqual: _node]) - return NO; resultIQ = [IQ resultIQ]; response = [OFXMLElement elementWithName: @"query" namespace: XMPP_NS_DISCO_INFO]; [resultIQ addChild: response];