Properly handle roster items which are in multiple groups.

This commit is contained in:
Jonathan Schleifer 2011-03-22 00:37:53 +01:00
parent 08e9104a17
commit a972fe397e

View file

@ -638,21 +638,21 @@
assert(0);
for (OFXMLElement *elem in rosterElem.children) {
OFString *group;
OFMutableArray *rosterGroup;
OFArray *groups;
if (![elem.name isEqual: @"item"] ||
![elem.ns isEqual: NS_ROSTER])
continue;
group = [[elem
elementsForName: @"group"
namespace: NS_ROSTER].firstObject stringValue];
groups = [elem elementsForName: @"group"
namespace: NS_ROSTER];
if (group == nil)
group = @"";
for (OFXMLElement *groupElem in groups) {
OFString *group = groupElem.stringValue;
OFMutableArray *rosterGroup =
[roster objectForKey: group];
if ((rosterGroup = [roster objectForKey: group]) == nil) {
if (rosterGroup == nil) {
rosterGroup = [OFMutableArray array];
[roster setObject: rosterGroup
forKey: group];
@ -661,6 +661,20 @@
[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];