ObjXMPP  Diff

Differences From Artifact [edad7fe838]:

To Artifact [aeb34f13f6]:


61
62
63
64
65
66
67

68
69
70
71
72
73
74
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75







+







{
	self = [super init];

	@try {
		sock = [[OFTCPSocket alloc] init];
		port = 5222;
		encrypted = NO;
		streamOpen = NO;
		callbacks = [[OFMutableDictionary alloc] init];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
311
312
313
314
315
316
317





318
319
320
321
322
323
324
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330







+
+
+
+
+







	encryptionRequired = required;
}

- (BOOL)encrypted
{
	return encrypted;
}

- (BOOL)streamOpen
{
	return streamOpen;
}

- (void)checkCertificate
{
	X509Certificate *cert;
	OFDictionary *SANs;
	BOOL serviceSpecific = NO;

457
458
459
460
461
462
463
464

465
466
467


468
469
470
471
472
473
474
463
464
465
466
467
468
469

470
471
472
473
474
475
476
477
478
479
480
481
482







-
+



+
+








- (void)elementBuilder: (OFXMLElementBuilder *)builder
  didNotExpectCloseTag: (OFString *)name
	    withPrefix: (OFString *)prefix
	     namespace: (OFString *)ns
{
	if (![name isEqual: @"stream"] || ![prefix isEqual: @"stream"] ||
	    ![ns isEqual: XMPP_NS_STREAM]) {
	    ![ns isEqual: XMPP_NS_STREAM])
		@throw [OFMalformedXMLException
		    exceptionWithClass: [builder class]
				parser: nil];
	else {
		[self close];
	}
}

- (void)XMPP_startStream
{
	/* Make sure we don't get any old events */
	[parser setDelegate: nil];
492
493
494
495
496
497
498









499
500
501
502
503
504
505
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522







+
+
+
+
+
+
+
+
+







	roster = [[XMPPRoster alloc] initWithConnection: self];

	[sock writeFormat: @"<?xml version='1.0'?>\n"
			   @"<stream:stream to='%@' "
			   @"xmlns='" XMPP_NS_CLIENT @"' "
			   @"xmlns:stream='" XMPP_NS_STREAM @"' "
			   @"version='1.0'>", domain];
	streamOpen = YES;
}

- (void)close
{
	if (streamOpen) {
		[sock writeString: @"</stream:stream>"];
		streamOpen = NO;
	}
}

- (void)XMPP_handleStanza: (OFXMLElement*)element
{
	if ([[element name] isEqual: @"iq"]) {
		[self XMPP_handleIQ: [XMPPIQ stanzaWithElement: element]];
		return;
526
527
528
529
530
531
532
533

534
535

536
537
538
539
540
541
542
543
544
545
546
547
548
549

550


551
552
553
554
555
556
557
558







-
+
-
-
+







	if ([[element name] isEqual: @"features"]) {
		[self XMPP_handleFeatures: element];
		return;
	}

	if ([[element name] isEqual: @"error"]) {
		OFString *condition, *reason;
		[parser setDelegate: self];
		[self close];
		[sock writeString: @"</stream:stream>"];
		[sock close];
		[sock close]; // Remote has already closed his stream

		if ([element elementForName: @"bad-format"
				  namespace: XMPP_NS_XMPP_STREAM])
			condition = @"bad-format";
		else if ([element elementForName: @"bad-namespace-prefix"
				       namespace: XMPP_NS_XMPP_STREAM])
			condition = @"bad-namespace-prefix";