ObjXMPP  Diff

Differences From Artifact [0f3d82c9ea]:

To Artifact [150ec0f157]:


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

#import <ObjFW/macros.h>

#define BUFFER_LENGTH 512

@interface XMPPConnection_ConnectThread: OFThread
{
	OFThread *sourceThread;
	XMPPConnection *connection;
}

- initWithSourceThread: (OFThread*)sourceThread
	    connection: (XMPPConnection*)connection;
@end

@implementation XMPPConnection_ConnectThread
- initWithSourceThread: (OFThread*)sourceThread_
	    connection: (XMPPConnection*)connection_
{
	self = [super init];

	@try {
		sourceThread = [sourceThread_ retain];
		connection = [connection_ retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[sourceThread release];
	[connection release];

	[super dealloc];
}

- (void)didConnect
{
	[self join];

	[connection handleConnection];
}

- (id)main
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	[connection connect];

	[self performSelector: @selector(didConnect)
		     onThread: sourceThread
		waitUntilDone: false];

	[pool release];

	return nil;
}
@end







|
|







|
|




|
|










|
|








|






|


|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

#import <ObjFW/macros.h>

#define BUFFER_LENGTH 512

@interface XMPPConnection_ConnectThread: OFThread
{
	OFThread *_sourceThread;
	XMPPConnection *_connection;
}

- initWithSourceThread: (OFThread*)sourceThread
	    connection: (XMPPConnection*)connection;
@end

@implementation XMPPConnection_ConnectThread
- initWithSourceThread: (OFThread*)sourceThread
	    connection: (XMPPConnection*)connection
{
	self = [super init];

	@try {
		_sourceThread = [sourceThread retain];
		_connection = [connection retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_sourceThread release];
	[_connection release];

	[super dealloc];
}

- (void)didConnect
{
	[self join];

	[_connection handleConnection];
}

- (id)main
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	[_connection connect];

	[self performSelector: @selector(didConnect)
		     onThread: _sourceThread
		waitUntilDone: false];

	[pool release];

	return nil;
}
@end
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
}

- (OFString*)server
{
	return [[_server copy] autorelease];
}

- (void)setDomain: (OFString*)domain_
{
	OFString *oldDomain = _domain;
	OFString *oldDomainToASCII = _domainToASCII;

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

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

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








|




|



|




|







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
}

- (OFString*)server
{
	return [[_server copy] autorelease];
}

- (void)setDomain: (OFString*)domain
{
	OFString *oldDomain = _domain;
	OFString *oldDomainToASCII = _domainToASCII;

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

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

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

1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
		assert(0);

	[_delegates broadcastSelector: @selector(connection:wasBoundToJID:)
			   withObject: self
			   withObject: _JID];
}

- (OFString*)XMPP_IDNAToASCII: (OFString*)domain_
{
	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
		    exceptionWithConnection: self
				  operation: @"ToASCII"
				     string: domain_];

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








|





|




|







1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
		assert(0);

	[_delegates broadcastSelector: @selector(connection:wasBoundToJID:)
			   withObject: self
			   withObject: _JID];
}

- (OFString*)XMPP_IDNAToASCII: (OFString*)domain
{
	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
		    exceptionWithConnection: self
				  operation: @"ToASCII"
				     string: domain];

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