634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
|
rosterElem = iq.children.firstObject;
if (![rosterElem.name isEqual: @"query"] ||
![rosterElem.namespace isEqual: NS_ROSTER])
assert(0);
for (OFXMLElement *elem in rosterElem.children) {
OFString *group;
OFMutableArray *rosterGroup;
if (![elem.name isEqual: @"item"] ||
![elem.ns isEqual: NS_ROSTER])
continue;
group = [[elem
elementsForName: @"group"
namespace: NS_ROSTER].firstObject stringValue];
if (group == nil)
group = @"";
if ((rosterGroup = [roster objectForKey: group]) == nil) {
rosterGroup = [OFMutableArray array];
[roster setObject: rosterGroup
forKey: group];
}
[rosterGroup addObject: elem];
}
if ([delegate respondsToSelector:
@selector(connectionDidReceiveRoster:)])
[delegate connectionDidReceiveRoster: self];
[rosterID release];
|
|
<
<
|
|
>
>
>
>
>
|
>
>
|
|
>
>
>
>
>
>
|
>
>
|
|
|
|
|
>
|
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
|
rosterElem = iq.children.firstObject;
if (![rosterElem.name isEqual: @"query"] ||
![rosterElem.namespace isEqual: NS_ROSTER])
assert(0);
for (OFXMLElement *elem in rosterElem.children) {
OFArray *groups;
if (![elem.name isEqual: @"item"] ||
![elem.ns isEqual: NS_ROSTER])
continue;
groups = [elem elementsForName: @"group"
namespace: NS_ROSTER];
for (OFXMLElement *groupElem in groups) {
OFString *group = groupElem.stringValue;
OFMutableArray *rosterGroup =
[roster objectForKey: group];
if (rosterGroup == nil) {
rosterGroup = [OFMutableArray array];
[roster setObject: rosterGroup
forKey: group];
}
[rosterGroup addObject: elem];
}
if (groups.count == 0) {
OFMutableArray *rosterGroup =
[roster objectForKey: @""];
if (rosterGroup == nil) {
rosterGroup = [OFMutableArray array];
[roster setObject: rosterGroup
forKey: @""];
}
[rosterGroup addObject: elem];
}
}
if ([delegate respondsToSelector:
@selector(connectionDidReceiveRoster:)])
[delegate connectionDidReceiveRoster: self];
[rosterID release];
|