Make use of -[elementsForName:].
This commit is contained in:
parent
cfea8d5362
commit
a2cf5e17e7
1 changed files with 12 additions and 16 deletions
|
@ -223,13 +223,6 @@
|
||||||
parser.delegate = elementBuilder;
|
parser.delegate = elementBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_addAuthMechanisms: (OFXMLElement*)mechanisms_
|
|
||||||
{
|
|
||||||
for (OFXMLElement *mechanism in mechanisms_.children)
|
|
||||||
[mechanisms addObject:
|
|
||||||
[mechanism.children.firstObject stringValue]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_sendPLAINAuth
|
- (void)_sendPLAINAuth
|
||||||
{
|
{
|
||||||
OFXMLElement *authTag;
|
OFXMLElement *authTag;
|
||||||
|
@ -261,7 +254,8 @@
|
||||||
|
|
||||||
- (void)_sendResourceBind
|
- (void)_sendResourceBind
|
||||||
{
|
{
|
||||||
XMPPIQ *iq = [XMPPIQ IQWithType: @"set" ID: @"bind0"];
|
XMPPIQ *iq = [XMPPIQ IQWithType: @"set"
|
||||||
|
ID: @"bind0"];
|
||||||
OFXMLElement *bind = [OFXMLElement elementWithName: @"bind"
|
OFXMLElement *bind = [OFXMLElement elementWithName: @"bind"
|
||||||
namespace: NS_BIND];
|
namespace: NS_BIND];
|
||||||
if (resource)
|
if (resource)
|
||||||
|
@ -287,17 +281,19 @@
|
||||||
|
|
||||||
- (void)_handleFeatures: (OFXMLElement*)elem
|
- (void)_handleFeatures: (OFXMLElement*)elem
|
||||||
{
|
{
|
||||||
for (OFXMLElement *child in elem.children) {
|
OFArray *mechs = [elem elementsForName: @"mechanisms"
|
||||||
if ([[child name] isEqual: @"mechanisms"] &&
|
namespace: NS_SASL];
|
||||||
[[child namespace] isEqual: NS_SASL])
|
OFXMLElement *bind = [elem elementsForName: @"bind"
|
||||||
[self _addAuthMechanisms: child];
|
namespace: NS_BIND].firstObject;
|
||||||
else if ([[child name] isEqual: @"bind"] &&
|
|
||||||
[[child namespace] isEqual: NS_BIND])
|
for (OFXMLElement *mech in mechs)
|
||||||
[self _sendResourceBind];
|
[mechanisms addObject: mech.name];
|
||||||
}
|
|
||||||
|
|
||||||
if ([mechanisms containsObject: @"PLAIN"])
|
if ([mechanisms containsObject: @"PLAIN"])
|
||||||
[self _sendPLAINAuth];
|
[self _sendPLAINAuth];
|
||||||
|
|
||||||
|
if (bind != nil)
|
||||||
|
[self _sendResourceBind];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)elementBuilder: (OFXMLElementBuilder*)b
|
- (void)elementBuilder: (OFXMLElementBuilder*)b
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue