Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -636,31 +636,45 @@ if (![rosterElem.name isEqual: @"query"] || ![rosterElem.namespace isEqual: NS_ROSTER]) 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]; - - if (group == nil) - group = @""; - - if ((rosterGroup = [roster objectForKey: group]) == nil) { - rosterGroup = [OFMutableArray array]; - [roster setObject: rosterGroup - forKey: group]; + 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]; } - [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];