@@ -1,8 +1,8 @@ /* * Copyright (c) 2013, Florian Zeitz - * Copyright (c) 2013, 2016, 2019, Jonathan Schleifer + * Copyright (c) 2013, 2016, 2019, 2021, Jonathan Schleifer * * https://heap.zone/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -33,15 +33,13 @@ @implementation XMPPDiscoNode @synthesize JID = _JID, node = _node, name = _name, identities = _identities; @synthesize features = _features, childNodes = _childNodes; -+ (instancetype)discoNodeWithJID: (XMPPJID *)JID - node: (OFString *)node; ++ (instancetype)discoNodeWithJID: (XMPPJID *)JID node: (OFString *)node; { - return [[[self alloc] initWithJID: JID - node: node] autorelease]; + return [[[self alloc] initWithJID: JID node: node] autorelease]; } + (instancetype)discoNodeWithJID: (XMPPJID *)JID node: (OFString *)node name: (OFString *)name @@ -49,16 +47,13 @@ return [[[self alloc] initWithJID: JID node: node name: name] autorelease]; } -- (instancetype)initWithJID: (XMPPJID *)JID - node: (OFString *)node +- (instancetype)initWithJID: (XMPPJID *)JID node: (OFString *)node { - return [self initWithJID: JID - node: node - name: nil]; + return [self initWithJID: JID node: node name: nil]; } - (instancetype)initWithJID: (XMPPJID *)JID node: (OFString *)node name: (OFString *)name @@ -75,12 +70,12 @@ _name = [name copy]; _identities = [[OFSortedList alloc] init]; _features = [[OFSortedList alloc] init]; _childNodes = [[OFMutableDictionary alloc] init]; - [self addFeature: XMPP_NS_DISCO_ITEMS]; - [self addFeature: XMPP_NS_DISCO_INFO]; + [self addFeature: XMPPDiscoItemsNS]; + [self addFeature: XMPPDiscoInfoNS]; } @catch (id e) { [self release]; @throw e; } @@ -124,25 +119,25 @@ connection: (XMPPConnection *)connection { XMPPIQ *resultIQ; OFXMLElement *response; OFXMLElement *query = [IQ elementForName: @"query" - namespace: XMPP_NS_DISCO_ITEMS]; + namespace: XMPPDiscoItemsNS]; OFString *node = [[query attributeForName: @"node"] stringValue]; if (!(node == _node) && ![node isEqual: _node]) return false; resultIQ = [IQ resultIQ]; response = [OFXMLElement elementWithName: @"query" - namespace: XMPP_NS_DISCO_ITEMS]; + namespace: XMPPDiscoItemsNS]; [resultIQ addChild: response]; for (XMPPDiscoNode *child in _childNodes) { OFXMLElement *item = [OFXMLElement elementWithName: @"item" - namespace: XMPP_NS_DISCO_ITEMS]; + namespace: XMPPDiscoItemsNS]; [item addAttributeWithName: @"jid" stringValue: child.JID.fullJID]; if (child.node != nil) [item addAttributeWithName: @"node" @@ -157,25 +152,24 @@ [connection sendStanza: resultIQ]; return true; } -- (bool)xmpp_handleInfoIQ: (XMPPIQ *)IQ - connection: (XMPPConnection *)connection +- (bool)xmpp_handleInfoIQ: (XMPPIQ *)IQ connection: (XMPPConnection *)connection { XMPPIQ *resultIQ; OFXMLElement *response; resultIQ = [IQ resultIQ]; response = [OFXMLElement elementWithName: @"query" - namespace: XMPP_NS_DISCO_INFO]; + namespace: XMPPDiscoInfoNS]; [resultIQ addChild: response]; for (XMPPDiscoIdentity *identity in _identities) { OFXMLElement *identityElement = [OFXMLElement elementWithName: @"identity" - namespace: XMPP_NS_DISCO_INFO]; + namespace: XMPPDiscoInfoNS]; [identityElement addAttributeWithName: @"category" stringValue: identity.category]; [identityElement addAttributeWithName: @"type" stringValue: identity.type]; @@ -187,11 +181,11 @@ } for (OFString *feature in _features) { OFXMLElement *featureElement = [OFXMLElement elementWithName: @"feature" - namespace: XMPP_NS_DISCO_INFO]; + namespace: XMPPDiscoInfoNS]; [featureElement addAttributeWithName: @"var" stringValue: feature]; [response addChild: featureElement]; }