ObjXMPP  Check-in [65623177b5]

Overview
Comment:Generate stanza errors
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 65623177b543f70e5246ae3e7311b63e3ac404a16a67072b08a3edd6369c101c
User & Date: florob@babelmonkeys.de on 2012-01-25 14:05:09
Other Links: manifest | tags
Context
2012-01-25
15:42
Implement SASL EXTERNAL check-in: 1f5b2b1bd8 user: florob@babelmonkeys.de tags: trunk
14:05
Generate stanza errors check-in: 65623177b5 user: florob@babelmonkeys.de tags: trunk
12:18
Add -close method check-in: d876014b9d user: florob@babelmonkeys.de tags: trunk
Changes

Modified src/XMPPConnection.h from [a494cf7439] to [628096fdc8].

212
213
214
215
216
217
218



219
220
221
222
223
224
225
226
227
228
229
230
212
213
214
215
216
217
218
219
220
221
222
223
224
225

226
227
228
229
230
231
232







+
+
+




-








- (void)XMPP_startStream;
- (void)XMPP_handleStream: (OFXMLElement*)element;
- (void)XMPP_handleTLS: (OFXMLElement*)element;
- (void)XMPP_handleSASL: (OFXMLElement*)element;
- (void)XMPP_handleStanza: (OFXMLElement*)element;
- (void)XMPP_sendAuth: (OFString*)authName;
- (void)XMPP_sendResourceBind;
- (void)XMPP_sendStreamError: (OFString*)condition
			text: (OFString*)text;
- (void)XMPP_handleIQ: (XMPPIQ*)iq;
- (void)XMPP_handleMessage: (XMPPMessage*)message;
- (void)XMPP_handlePresence: (XMPPPresence*)presence;
- (void)XMPP_handleFeatures: (OFXMLElement*)element;
- (void)XMPP_sendResourceBind;
- (void)XMPP_handleResourceBind: (XMPPIQ*)iq;
- (void)XMPP_sendSession;
- (void)XMPP_handleSession: (XMPPIQ*)iq;
- (OFString*)XMPP_IDNAToASCII: (OFString*)domain;
@end

@interface OFObject (XMPPConnectionDelegate) <XMPPConnectionDelegate>

Modified src/XMPPConnection.m from [aeb34f13f6] to [938031a215].

410
411
412
413
414
415
416
417
418
419
420

















421
422
423
424
425
426
427
428









429
430
431
432
433
434
435
410
411
412
413
414
415
416




417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439


440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455







-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+






-
-
+
+
+
+
+
+
+
+
+







       withPrefix: (OFString*)prefix
	namespace: (OFString*)ns
       attributes: (OFArray*)attributes
{
	OFEnumerator *enumerator;
	OFXMLAttribute *attribute;

	if (![name isEqual: @"stream"] || ![prefix isEqual: @"stream"] ||
	    ![ns isEqual: XMPP_NS_STREAM]) {
		of_log(@"Did not get expected stream start!");
		assert(0);
	if (![name isEqual: @"stream"]) {
		// No dedicated stream error for this, may not even be XMPP
		[self close];
		[sock close];
		return;
	}

	if (![prefix isEqual: @"stream"]) {
		[self XMPP_sendStreamError: @"bad-namespace-prefix"
				      text: nil];
		return;
	}

	if (![ns isEqual: XMPP_NS_STREAM]) {
		[self XMPP_sendStreamError: @"invalid-namespace"
				      text: nil];
		return;
	}

	enumerator = [attributes objectEnumerator];
	while ((attribute = [enumerator nextObject]) != nil) {
		if ([[attribute name] isEqual: @"from"] &&
		    ![[attribute stringValue] isEqual: domain]) {
			of_log(@"Got invalid from in stream start!");
			assert(0);
			[self XMPP_sendStreamError: @"invalid-from"
					      text: nil];
			return;
		}
		if ([[attribute name] isEqual: @"version"] &&
		    ![[attribute stringValue] isEqual: @"1.0"]) {
			[self XMPP_sendStreamError: @"unsupported-version"
					      text: nil];
			return;
		}
	}

	[parser setDelegate: elementBuilder];
}

- (void)elementBuilder: (OFXMLElementBuilder*)builder
530
531
532
533
534
535
536

537

538
539
540
541
542
543
544
550
551
552
553
554
555
556
557

558
559
560
561
562
563
564
565







+
-
+








	if ([[element name] isEqual: @"presence"]) {
		[self XMPP_handlePresence:
		    [XMPPPresence stanzaWithElement: element]];
		return;
	}

	[self XMPP_sendStreamError: @"unsupported-stanza-type"
	assert(0);
			      text: nil];
}


- (void)XMPP_handleStream: (OFXMLElement*)element
{
	if ([[element name] isEqual: @"features"]) {
		[self XMPP_handleFeatures: element];
880
881
882
883
884
885
886




















887
888
889
890
891
892
893
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








	[iq addChild: bind];

	[self sendIQ: iq
  withCallbackObject: self
	    selector: @selector(XMPP_handleResourceBind:)];
}

- (void)XMPP_sendStreamError: (OFString*)condition
			text: (OFString*)text
{
	OFXMLElement *error = [OFXMLElement
	    elementWithName: @"error"
		  namespace: XMPP_NS_STREAM];
	[error setPrefix: @"stream"
	    forNamespace: XMPP_NS_STREAM];
	[error addChild: [OFXMLElement elementWithName: condition
					     namespace: XMPP_NS_XMPP_STREAM]];
	if (text)
		[error addChild: [OFXMLElement
		    elementWithName: @"text"
			  namespace: XMPP_NS_XMPP_STREAM
			stringValue: text]];
	[parser setDelegate: nil];
	[self sendStanza: error];
	[self close];
}

- (void)XMPP_handleResourceBind: (XMPPIQ*)iq
{
	OFXMLElement *bindElement;
	OFXMLElement *jidElement;

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