ObjXMPP  Check-in [b9354d7713]

Overview
Comment:Properly handle roster items which are in multiple groups.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b9354d771350e272d2d14e23560229b56af57e447ea341cce3f080e438e145f2
User & Date: js on 2011-03-21 23:37:53
Other Links: manifest | tags
Context
2011-03-24
17:57
Handle nil as argument to XMPPStanza's setters check-in: d6b5e4a4e1 user: florob@babelmonkeys.de tags: trunk
2011-03-21
23:37
Properly handle roster items which are in multiple groups. check-in: b9354d7713 user: js tags: trunk
20:36
Send an error reply for unhandled IQ stanzas. check-in: f4868153e6 user: js tags: trunk
Changes

Modified src/XMPPConnection.m from [072b3550d7] to [a1cc431680].

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
	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];
	rosterID = nil;
}
@end







|
<





<
|
|

>
>
>
>
>
|
>
>
|
|
>
>
>
>
>
>
|
>
>
|
|
|
|

|
>










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
683
684
685
	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];
	rosterID = nil;
}
@end