ObjXMPP  Diff

Differences From Artifact [d30b689c50]:

To Artifact [187819bc21]:


302
303
304
305
306
307
308
309

310
311
312
313
314
315
316
302
303
304
305
306
307
308

309
310
311
312
313
314
315
316







-
+







}

- (void)parseBuffer: (const char*)buffer
	 withLength: (size_t)length
{
	if (length < 1) {
		[delegates broadcastSelector: @selector(connectionWasClosed:)
			       forConnection: self];
				  withObject: self];
		return;
	}

	[parser parseBuffer: buffer
		 withLength: length];

	[oldParser release];
372
373
374
375
376
377
378
379

380
381
382
383
384
385
386
372
373
374
375
376
377
378

379
380
381
382
383
384
385
386







-
+







		    exceptionWithClass: isa
				reason: @"No matching identifier"];
}

- (void)sendStanza: (OFXMLElement*)element
{
	[delegates broadcastSelector: @selector(connection:didSendElement:)
		       forConnection: self
			  withObject: self
			  withObject: element];

	[sock writeString: [element XMLString]];
}

-	(void)sendIQ: (XMPPIQ*)iq
  withCallbackObject: (id)object
482
483
484
485
486
487
488
489

490
491
492
493
494
495
496
482
483
484
485
486
487
488

489
490
491
492
493
494
495
496







-
+







		return;

	[element setDefaultNamespace: XMPP_NS_CLIENT];
	[element setPrefix: @"stream"
	      forNamespace: XMPP_NS_STREAM];

	[delegates broadcastSelector: @selector(connection:didReceiveElement:)
		       forConnection: self
			  withObject: self
			  withObject: element];

	if ([[element namespace] isEqual: XMPP_NS_CLIENT])
		[self XMPP_handleStanza: element];

	if ([[element namespace] isEqual: XMPP_NS_STREAM])
		[self XMPP_handleStream: element];
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
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







-
+











-
+







{
	if ([[element name] isEqual: @"proceed"]) {
		/* FIXME: Catch errors here */
		SSLSocket *newSock;

		[delegates broadcastSelector: @selector(
						  connectionWillUpgradeToTLS:)
			       forConnection: self];
				  withObject: self];

		newSock = [[SSLSocket alloc] initWithSocket: sock
					     privateKeyFile: privateKeyFile
					    certificateFile: certificateFile];
		[sock release];
		sock = newSock;

		encrypted = YES;

		[delegates broadcastSelector: @selector(
						  connectionDidUpgradeToTLS:)
			       forConnection: self];
				  withObject: self];

		/* Stream restart */
		[self XMPP_startStream];

		return;
	}

740
741
742
743
744
745
746
747

748
749
750
751
752
753
754
740
741
742
743
744
745
746

747
748
749
750
751
752
753
754







-
+








	if ([[element name] isEqual: @"success"]) {
		[authModule continueWithData: [OFDataArray
		    dataArrayWithBase64EncodedString: [element stringValue]]];

		[delegates broadcastSelector: @selector(
						  connectionWWasAuthenticated:)
			       forConnection: self];
				  withObject: self];

		/* Stream restart */
		[self XMPP_startStream];

		return;
	}

773
774
775
776
777
778
779
780

781
782
783
784
785
786
787
788
789
790
791
792
793

794
795
796
797
798
799
800

801
802
803
804
805
806
807
773
774
775
776
777
778
779

780
781
782
783
784
785
786
787
788
789
790
791
792

793
794
795
796
797
798
799

800
801
802
803
804
805
806
807







-
+












-
+






-
+







		[callback runWithIQ: iq];
		[callbacks removeObjectForKey: [iq ID]];
		return;
	}

	handled = [delegates broadcastSelector: @selector(
						    connection:didReceiveIQ:)
				 forConnection: self
				    withObject: self
				    withObject: iq];

	if (!handled && ![[iq type] isEqual: @"error"] &&
	    ![[iq type] isEqual: @"result"]) {
		[self sendStanza: [iq errorIQWithType: @"cancel"
					    condition: @"service-unavailable"]];
	}
}

- (void)XMPP_handleMessage: (XMPPMessage*)message
{
	[delegates broadcastSelector: @selector(connection:didReceiveMessage:)
		       forConnection: self
			  withObject: self
			  withObject: message];
}

- (void)XMPP_handlePresence: (XMPPPresence*)presence
{
	[delegates broadcastSelector: @selector(connection:didReceivePresence:)
		       forConnection: self
			  withObject: self
			  withObject: presence];
}

- (void)XMPP_handleFeatures: (OFXMLElement*)element
{
	OFXMLElement *starttls = [element elementForName: @"starttls"
					       namespace: XMPP_NS_STARTTLS];
964
965
966
967
968
969
970
971

972
973
974
975
976
977
978
964
965
966
967
968
969
970

971
972
973
974
975
976
977
978







-
+








	if (needsSession) {
		[self XMPP_sendSession];
		return;
	}

	[delegates broadcastSelector: @selector(connection:wasBoundToJID:)
		       forConnection: self
			  withObject: self
			  withObject: JID];
}

- (void)XMPP_sendSession
{
	XMPPIQ *iq;

987
988
989
990
991
992
993
994

995
996
997
998
999
1000
1001
987
988
989
990
991
992
993

994
995
996
997
998
999
1000
1001







-
+








- (void)XMPP_handleSession: (XMPPIQ*)iq
{
	if (![[iq type] isEqual: @"result"])
		assert(0);

	[delegates broadcastSelector: @selector(connection:wasBoundToJID:)
		       forConnection: self
			  withObject: self
			  withObject: JID];
}

- (OFString*)XMPP_IDNAToASCII: (OFString*)domain_
{
	OFString *ret;
	char *cDomain;