ObjXMPP  Diff

Differences From Artifact [cd38c39db4]:

To Artifact [52b20891be]:


1
2


3
4
5

6
7
8
9
10
11
12
1

2
3
4
5

6
7
8
9
10
11
12
13

-
+
+


-
+







/*
 * Copyright (c) 2010, 2011, 2012, Jonathan Schleifer <js@webkeks.org>
 * Copyright (c) 2010, 2011, 2012, 2013, 2015, 2016
 *   Jonathan Schleifer <js@heap.zone>
 * Copyright (c) 2011, 2012, Florian Zeitz <florob@babelmonkeys.de>
 *
 * https://webkeks.org/git/?p=objxmpp.git
 * https://heap.zone/git/?p=objxmpp.git
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
113
114
115
116
117
118
119






120
121
122
123
124
125
126
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133







+
+
+
+
+
+







	[pool release];

	return nil;
}
@end

@implementation XMPPConnection
@synthesize language = _language, privateKeyFile = _privateKeyFile;
@synthesize certificateFile = _certificateFile, socket = _socket;
@synthesize encryptionRequired = _encryptionRequired, encrypted = _encrypted;
@synthesize supportsRosterVersioning = _supportsRosterVersioning;
@synthesize supportsStreamManagement = _supportsStreamManagement;

+ (instancetype)connection
{
	return [[[self alloc] init] autorelease];
}

- init
{
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
308
309
310
311
312
313
314




















315
316
317
318
319
320
321







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







}

- (OFString*)password
{
	return [[_password copy] autorelease];
}

- (void)setPrivateKeyFile: (OFString*)privateKeyFile
{
	OF_SETTER(_privateKeyFile, privateKeyFile, true, 1)
}

- (OFString*)privateKeyFile
{
	OF_GETTER(_privateKeyFile, true)
}

- (void)setCertificateFile: (OFString*)certificateFile
{
	OF_SETTER(_certificateFile, certificateFile, true, 1)
}

- (OFString*)certificateFile
{
	OF_GETTER(_certificateFile, true)
}

- (void)connect
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	XMPPSRVEntry *candidate = nil;
	XMPPSRVLookup *SRVLookup = nil;
	OFEnumerator *enumerator;

473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
460
461
462
463
464
465
466




















467
468
469
470
471










472
473
474
475
476
477
478







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-





-
-
-
-
-
-
-
-
-
-








		return false;
	}

	return true;
}

- (OFTCPSocket*)socket
{
	return [[_socket retain] autorelease];
}

- (bool)encryptionRequired
{
	return _encryptionRequired;
}

- (void)setEncryptionRequired: (bool)encryptionRequired
{
	_encryptionRequired = encryptionRequired;
}

- (bool)encrypted
{
	return _encrypted;
}

- (bool)streamOpen
{
	return _streamOpen;
}

- (bool)supportsRosterVersioning
{
	return _supportsRosterVersioning;
}

- (bool)supportsStreamManagement
{
	return _supportsStreamManagement;
}

- (bool)checkCertificateAndGetReason: (OFString**)reason
{
	X509Certificate *cert;
	OFDictionary *SANs;
	bool serviceSpecific = false;

	@try {
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1208
1209
1210
1211
1212
1213
1214















1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228










1229
1230
1231
1232
1233
1234
1235







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-














-
-
-
-
-
-
-
-
-
-







	} @finally {
		free(cDomain);
	}

	return ret;
}

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

- (void)setPort: (uint16_t)port
{
	_port = port;
}

- (uint16_t)port
{
	return _port;
}

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

	_dataStorage = dataStorage;
}

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

- (void)setLanguage: (OFString*)language
{
	OF_SETTER(_language, language, true, 1)
}

- (OFString*)language
{
	OF_GETTER(_language, true)
}

- (void)addDelegate: (id <XMPPConnectionDelegate>)delegate
{
	[_delegates addDelegate: delegate];
}

- (void)removeDelegate: (id <XMPPConnectionDelegate>)delegate
{