ObjXMPP  Diff

Differences From Artifact [004473a420]:

To Artifact [8415025e4d]:


167
168
169
170
171
172
173
174
175
176
177



178
179
180
181
182
183
184
167
168
169
170
171
172
173




174
175
176
177
178
179
180
181
182
183







-
-
-
-
+
+
+







	if (username != nil) {
		char *node;
		Stringprep_rc rc;

		if ((rc = stringprep_profile([username UTF8String], &node,
		    "SASLprep", 0)) != STRINGPREP_OK)
			@throw [XMPPStringPrepFailedException
			    exceptionWithClass: [self class]
				    connection: self
				       profile: @"SASLprep"
					string: username];
			    exceptionWithConnection: self
					    profile: @"SASLprep"
					     string: username];

		@try {
			_username = [[OFString alloc] initWithUTF8String: node];
		} @finally {
			free(node);
		}
	} else
199
200
201
202
203
204
205
206
207
208
209



210
211
212
213
214
215
216
198
199
200
201
202
203
204




205
206
207
208
209
210
211
212
213
214







-
-
-
-
+
+
+







	if (resource != nil) {
		char *res;
		Stringprep_rc rc;

		if ((rc = stringprep_profile([resource UTF8String], &res,
		    "Resourceprep", 0)) != STRINGPREP_OK)
			@throw [XMPPStringPrepFailedException
			    exceptionWithClass: [self class]
				    connection: self
				       profile: @"Resourceprep"
					string: resource];
			    exceptionWithConnection: self
					    profile: @"Resourceprep"
					     string: resource];

		@try {
			_resource = [[OFString alloc] initWithUTF8String: res];
		} @finally {
			free(res);
		}
	} else
249
250
251
252
253
254
255
256
257
258
259



260
261
262
263
264
265
266
247
248
249
250
251
252
253




254
255
256
257
258
259
260
261
262
263







-
-
-
-
+
+
+







	if (domain_ != nil) {
		char *srv;
		Stringprep_rc rc;

		if ((rc = stringprep_profile([domain_ UTF8String], &srv,
		    "Nameprep", 0)) != STRINGPREP_OK)
			@throw [XMPPStringPrepFailedException
			    exceptionWithClass: [self class]
				    connection: self
				       profile: @"Nameprep"
					string: domain_];
			    exceptionWithConnection: self
					    profile: @"Nameprep"
					     string: domain_];

		@try {
			_domain = [[OFString alloc] initWithUTF8String: srv];
		} @finally {
			free(srv);
		}

286
287
288
289
290
291
292
293
294
295
296



297
298
299
300
301
302
303
283
284
285
286
287
288
289




290
291
292
293
294
295
296
297
298
299







-
-
-
-
+
+
+







	if (password != nil) {
		char *pass;
		Stringprep_rc rc;

		if ((rc = stringprep_profile([password UTF8String], &pass,
		    "SASLprep", 0)) != STRINGPREP_OK)
			@throw [XMPPStringPrepFailedException
			    exceptionWithClass: [self class]
				    connection: self
				       profile: @"SASLprep"
					string: password];
			    exceptionWithConnection: self
					    profile: @"SASLprep"
					     string: password];

		@try {
			_password = [[OFString alloc] initWithUTF8String: pass];
		} @finally {
			free(pass);
		}
	} else
335
336
337
338
339
340
341
342

343
344
345
346
347
348
349
350
331
332
333
334
335
336
337

338

339
340
341
342
343
344
345







-
+
-







{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	XMPPSRVEntry *candidate = nil;
	XMPPSRVLookup *SRVLookup = nil;
	OFEnumerator *enumerator;

	if (_socket != nil)
		@throw [OFAlreadyConnectedException
		@throw [OFAlreadyConnectedException exception];
		    exceptionWithClass: [self class]];

	_socket = [[OFTCPSocket alloc] init];

	if (_server)
		[_socket connectToHost: _server
				  port: _port];
	else {
687
688
689
690
691
692
693
694

695
696
697
698
699
700
701
702
703
682
683
684
685
686
687
688

689


690
691
692
693
694
695
696







-
+
-
-







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

- (void)XMPP_startStream
{
869
870
871
872
873
874
875
876
877
878
879



880
881
882
883
884
885
886
862
863
864
865
866
867
868




869
870
871
872
873
874
875
876
877
878







-
-
-
-
+
+
+







			condition = @"undefined";

		reason = [[element
		    elementForName: @"text"
			 namespace: XMPP_NS_XMPP_STREAM] stringValue];

		@throw [XMPPStreamErrorException
		    exceptionWithClass: [self class]
			    connection: self
			     condition: condition
				reason: reason];
		    exceptionWithConnection: self
				  condition: condition
				     reason: reason];
		return;
	}

	assert(0);
}

- (void)XMPP_handleTLS: (OFXMLElement*)element
911
912
913
914
915
916
917
918

919
920
921
922
923
924
925
903
904
905
906
907
908
909

910
911
912
913
914
915
916
917







-
+







		[self XMPP_startStream];

		return;
	}

	if ([[element name] isEqual: @"failure"])
		/* TODO: Find/create an exception to throw here */
		@throw [OFException exceptionWithClass: [self class]];
		@throw [OFException exception];

	assert(0);
}

- (void)XMPP_handleSASL: (OFXMLElement*)element
{
	if ([[element name] isEqual: @"challenge"]) {
957
958
959
960
961
962
963
964
965
966


967
968
969
970
971
972
973
949
950
951
952
953
954
955



956
957
958
959
960
961
962
963
964







-
-
-
+
+







		return;
	}

	if ([[element name] isEqual: @"failure"]) {
		of_log(@"Auth failed!");
		// FIXME: Do more parsing/handling
		@throw [XMPPAuthFailedException
		    exceptionWithClass: [self class]
			    connection: self
				reason: [element XMLString]];
		    exceptionWithConnection: self
				     reason: [element XMLString]];
	}

	assert(0);
}

- (void)XMPP_handleIQ: (XMPPIQ*)iq
{
1024
1025
1026
1027
1028
1029
1030
1031

1032
1033
1034
1035
1036
1037
1038
1015
1016
1017
1018
1019
1020
1021

1022
1023
1024
1025
1026
1027
1028
1029







-
+







		    [OFXMLElement elementWithName: @"starttls"
					namespace: XMPP_NS_STARTTLS]];
		return;
	}

	if (_encryptionRequired && !_encrypted)
		/* TODO: Find/create an exception to throw here */
		@throw [OFException exceptionWithClass: [self class]];
		@throw [OFException exception];

	if ([element elementForName: @"ver"
			  namespace: XMPP_NS_ROSTERVER] != nil)
		_supportsRosterVersioning = YES;

	if ([element elementForName: @"sm"
			  namespace: XMPP_NS_SM] != nil)
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227



1228
1229
1230
1231
1232
1233
1234
1208
1209
1210
1211
1212
1213
1214




1215
1216
1217
1218
1219
1220
1221
1222
1223
1224







-
-
-
-
+
+
+







	OFString *ret;
	char *cDomain;
	Idna_rc rc;

	if ((rc = idna_to_ascii_8z([domain_ UTF8String],
	    &cDomain, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS)
		@throw [XMPPIDNATranslationFailedException
		    exceptionWithClass: [self class]
			    connection: self
			     operation: @"ToASCII"
				string: domain_];
		    exceptionWithConnection: self
				  operation: @"ToASCII"
				     string: domain_];

	@try {
		ret = [[OFString alloc] initWithUTF8String: cDomain];
	} @finally {
		free(cDomain);
	}

1249
1250
1251
1252
1253
1254
1255

1256

1257
1258
1259
1260
1261
1262
1263
1264
1239
1240
1241
1242
1243
1244
1245
1246

1247

1248
1249
1250
1251
1252
1253
1254







+
-
+
-







{
	return _port;
}

- (void)setDataStorage: (id <XMPPStorage>)dataStorage
{
	if (_streamOpen)
		/* FIXME: Find a better exception! */
		@throw [OFInvalidArgumentException
		@throw [OFInvalidArgumentException exception];
		    exceptionWithClass: [self class]];

	_dataStorage = dataStorage;
}

- (id <XMPPStorage>)dataStorage
{
	return _dataStorage;