ObjXMPP  Diff

Differences From Artifact [50d3cf8f73]:

To Artifact [e6d90230b9]:


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
	[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];
}








>

>
>




>
|
<
|


|
|
<
|
|
|

|
|
|

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








|
|
|
|
|
>
|



|
>
|
>





>
|
|
|
<
<
<

|




>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
	[self sendStanza: iq];
}

- (void)XMPP_handleRoster: (XMPPIQ*)iq
{
	OFXMLElement *rosterElem;
	OFXMLElement *elem;
	XMPPRosterItem *rosterItem = nil;
	OFString *subscription;
	OFEnumerator *enumerator;
	BOOL isPush = ![[iq ID] isEqual: rosterID];

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

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

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

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

		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"] &&
		    (![subscription isEqual: @"remove"] || !isPush))
			subscription = @"none";
		[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];

		if ([subscription isEqual: @"remove"])
			[roster XMPP_deleteRosterItem: rosterItem];
		else
			[roster XMPP_addRosterItem: rosterItem];




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

	if (isPush) {
		XMPPIQ *response = [XMPPIQ IQWithType: @"result"
						   ID: [iq ID]];
		[response setTo: [iq from]];
		[self sendStanza: response];
	} else {
		if ([delegate respondsToSelector:
		    @selector(connectionDidReceiveRoster:)])
			[delegate connectionDidReceiveRoster: self];

		[rosterID release];
		rosterID = nil;
	}
}

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

811
812
813
814
815
816
817





818
819
820
821
822
823
824
825
826
827
828
829
830
{
}

-  (void)connection: (XMPPConnection*)conn
  didReceiveMessage: (XMPPMessage*)msg
{
}






- (void)connectionWasClosed: (XMPPConnection*)conn
{
}

- (void)connectionWillUpgradeToTLS: (XMPPConnection*)conn
{
}

- (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn
{
}
@end







>
>
>
>
>













784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
{
}

-  (void)connection: (XMPPConnection*)conn
  didReceiveMessage: (XMPPMessage*)msg
{
}

-     (void)connection: (XMPPConnection*)conn
  didReceiveRosterItem: (XMPPRosterItem*)rosterItem
{
}

- (void)connectionWasClosed: (XMPPConnection*)conn
{
}

- (void)connectionWillUpgradeToTLS: (XMPPConnection*)conn
{
}

- (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn
{
}
@end