ObjXMPP  Diff

Differences From Artifact [be8ca31728]:

To Artifact [3fbb4082fa]:


32
33
34
35
36
37
38

39
40
41
42
43
44
45
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46







+







#import "XMPPSCRAMAuth.h"
#import "XMPPPLAINAuth.h"
#import "XMPPStanza.h"
#import "XMPPJID.h"
#import "XMPPIQ.h"
#import "XMPPMessage.h"
#import "XMPPPresence.h"
#import "XMPPRosterItem.h"
#import "XMPPExceptions.h"

#define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind"
#define NS_CLIENT @"jabber:client"
#define NS_ROSTER @"jabber:iq:roster"
#define NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl"
#define NS_STARTTLS @"urn:ietf:params:xml:ns:xmpp-tls"
627
628
629
630
631
632
633

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
628
629
630
631
632
633
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
686
687
688







+
-
+





+
+
-
-
+
+
+
+
+

-
-
+
+
+

-
+




-
+


-
+

+
+











-
+











	rosterElem = iq.children.firstObject;

	if (![rosterElem.name isEqual: @"query"] ||
	    ![rosterElem.namespace isEqual: NS_ROSTER])
		assert(0);

	for (OFXMLElement *elem in rosterElem.children) {
		XMPPRosterItem *rosterItem;
		OFArray *groups;
		OFMutableArray *groups = [OFMutableArray array];

		if (![elem.name isEqual: @"item"] ||
		    ![elem.ns isEqual: NS_ROSTER])
			continue;

		rosterItem = [XMPPRosterItem rosterItem];
		rosterItem.JID = [XMPPJID JIDWithString:
		groups = [elem elementsForName: @"group"
				     namespace: NS_ROSTER];
		    [rosterElem attributeForName: @"jid"].stringValue];
		rosterItem.name =
		    [rosterElem attributeForName: @"name"].stringValue;
		rosterItem.subscription =
		    [rosterElem attributeForName: @"subscription"].stringValue;

		for (OFXMLElement *groupElem in groups) {
			OFString *group = groupElem.stringValue;
		for (OFXMLElement *groupElem in
		     [elem elementsForName: @"group"
				 namespace: NS_ROSTER]) {
			OFMutableArray *rosterGroup =
			    [roster objectForKey: group];
			     [roster objectForKey: rosterElem.stringValue];

			if (rosterGroup == nil) {
				rosterGroup = [OFMutableArray array];
				[roster setObject: rosterGroup
					   forKey: group];
					   forKey: rosterElem.stringValue];
			}

			[rosterGroup addObject: elem];
			[rosterGroup addObject: rosterItem];
		}

		rosterItem.groups = groups;

		if (groups.count == 0) {
			OFMutableArray *rosterGroup =
			    [roster objectForKey: @""];

			if (rosterGroup == nil) {
				rosterGroup = [OFMutableArray array];
				[roster setObject: rosterGroup
					   forKey: @""];
			}

			[rosterGroup addObject: elem];
			[rosterGroup addObject: rosterItem];
		}
	}

	if ([delegate respondsToSelector:
	    @selector(connectionDidReceiveRoster:)])
		[delegate connectionDidReceiveRoster: self];

	[rosterID release];
	rosterID = nil;
}
@end