ObjXMPP  Diff

Differences From Artifact [a3a4d92ecf]:

To Artifact [50d3cf8f73]:


433
434
435
436
437
438
439
440

441
442
443
444
445
446
447
	}

	if ([[iq ID] isEqual: sessionID]) {
		[self XMPP_handleSession: iq];
		return;
	}

	if ([[iq ID] isEqual: rosterID]) {

		[self XMPP_handleRoster: iq];
		return;
	}

	if ([delegate respondsToSelector: @selector(connection:didReceiveIQ:)])
		handled = [delegate connection: self
				  didReceiveIQ: iq];







|
>







433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
	}

	if ([[iq ID] isEqual: sessionID]) {
		[self XMPP_handleSession: iq];
		return;
	}

	if ([iq elementForName: @"query"
		     namespace: XMPP_NS_ROSTER]) {
		[self XMPP_handleRoster: iq];
		return;
	}

	if ([delegate respondsToSelector: @selector(connection:didReceiveIQ:)])
		handled = [delegate connection: self
				  didReceiveIQ: iq];
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
689
690




691
692
693
694

695
696
697
698
699
700
701
702
703
704
					  namespace: XMPP_NS_ROSTER]];
	[self sendStanza: iq];
}

- (void)XMPP_handleRoster: (XMPPIQ*)iq
{
	OFXMLElement *rosterElem;
	OFEnumerator *enumerator;
	OFXMLElement *elem;

	assert([[iq type] isEqual: @"result"]);

	rosterElem = [iq elementForName: @"query"
			      namespace: XMPP_NS_ROSTER];



	assert(rosterElem != nil);


	enumerator = [[rosterElem children] objectEnumerator];
	while ((elem = [enumerator nextObject]) != nil) {












































		XMPPRosterItem *rosterItem;
		OFMutableArray *groups = [OFMutableArray array];
		OFEnumerator *groupEnumerator;
		OFXMLElement *groupElem;


		if (![[elem name] isEqual: @"item"] ||
		    ![[elem namespace] isEqual: XMPP_NS_ROSTER])
			continue;


		rosterItem = [XMPPRosterItem rosterItem];
		[rosterItem setJID: [XMPPJID JIDWithString:
		    [[elem attributeForName: @"jid"] stringValue]]];
		[rosterItem setName:
		    [[elem attributeForName: @"name"] stringValue]];
		[rosterItem setSubscription:

		    [[elem attributeForName: @"subscription"] stringValue]];







		groupEnumerator =
		    [[elem elementsForName: @"group"
				 namespace: XMPP_NS_ROSTER] objectEnumerator];
		while ((groupElem = [groupEnumerator nextObject]) != nil)
			[groups addObject: [groupElem stringValue]];

		if ([groups count] > 0)
			[rosterItem setGroups: groups];

		[roster XMPP_addRosterItem: rosterItem];
	}





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


	[rosterID release];
	rosterID = nil;
}

- (XMPPJID*)JID
{
	return [[JID copy] autorelease];
}








<

|
<




>
>
|
>

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




>

|
<
<

>





|
>
|
>
>
>
>
>
>










|
|
>
>
>
>

|
|
|
>
|
<
<







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
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715


716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753


754
755
756
757
758
759
760
					  namespace: XMPP_NS_ROSTER]];
	[self sendStanza: iq];
}

- (void)XMPP_handleRoster: (XMPPIQ*)iq
{
	OFXMLElement *rosterElem;

	OFXMLElement *elem;
	OFString *subscription;


	rosterElem = [iq elementForName: @"query"
			      namespace: XMPP_NS_ROSTER];

	if ([[iq ID] isEqual: rosterID]) {
		OFEnumerator *enumerator;

		assert([[iq type] isEqual: @"result"]);

		enumerator = [[rosterElem children] objectEnumerator];
		while ((elem = [enumerator nextObject]) != nil) {
			XMPPRosterItem *rosterItem;
			OFMutableArray *groups = [OFMutableArray array];
			OFEnumerator *groupEnumerator;
			OFXMLElement *groupElem;

			if (![[elem name] isEqual: @"item"] ||
			    ![[elem namespace] isEqual: XMPP_NS_ROSTER])
				continue;

			rosterItem = [XMPPRosterItem rosterItem];
			[rosterItem setJID: [XMPPJID JIDWithString:
			    [[elem attributeForName: @"jid"] stringValue]]];
			[rosterItem setName:
			    [[elem attributeForName: @"name"] stringValue]];

			subscription = [[elem attributeForName:
				@"subscription"] stringValue];
			if ([subscription isEqual: @"none"] ||
			    [subscription isEqual: @"to"] ||
			    [subscription isEqual: @"from"] ||
			    [subscription isEqual: @"both"])
				[rosterItem setSubscription: subscription];

			groupEnumerator =
			    [[elem elementsForName: @"group"
					 namespace: XMPP_NS_ROSTER]
				objectEnumerator];
			while ((groupElem = [groupEnumerator nextObject])
					!= nil)
				[groups addObject: [groupElem stringValue]];

			if ([groups count] > 0)
				[rosterItem setGroups: groups];

			[roster XMPP_addRosterItem: rosterItem];
		}

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

		[rosterID release];
		rosterID = nil;
	} else {
		XMPPRosterItem *rosterItem;
		OFMutableArray *groups = [OFMutableArray array];
		OFEnumerator *groupEnumerator;
		OFXMLElement *groupElem;
		XMPPIQ *response;

		assert([[iq type] isEqual: @"set"]);



		elem = [[rosterElem children] firstObject];
		rosterItem = [XMPPRosterItem rosterItem];
		[rosterItem setJID: [XMPPJID JIDWithString:
		    [[elem attributeForName: @"jid"] stringValue]]];
		[rosterItem setName:
		    [[elem attributeForName: @"name"] stringValue]];

		subscription = [[elem attributeForName:
			@"subscription"] stringValue];
		if ([subscription isEqual: @"none"] ||
		    [subscription isEqual: @"to"] ||
		    [subscription isEqual: @"from"] ||
		    [subscription isEqual: @"both"] ||
		    [subscription isEqual: @"remove"])
			[rosterItem setSubscription: subscription];

		groupEnumerator =
		    [[elem elementsForName: @"group"
				 namespace: XMPP_NS_ROSTER] objectEnumerator];
		while ((groupElem = [groupEnumerator nextObject]) != nil)
			[groups addObject: [groupElem stringValue]];

		if ([groups count] > 0)
			[rosterItem setGroups: groups];

		[roster XMPP_updateRosterItem: rosterItem];

		response = [XMPPIQ IQWithType: @"result"
					   ID: [iq ID]];
		[response setTo: [iq from]];
		[self sendStanza: response];

		if ([delegate respondsToSelector:
		    @selector(connection:didReceiveRosterItem:)])
			[delegate connection:self
			didReceiveRosterItem: rosterItem];
	}


}

- (XMPPJID*)JID
{
	return [[JID copy] autorelease];
}