ObjIRC  Check-in [e7f0831117]

Overview
Comment:Adjust to ObjFW changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e7f0831117b1cb0f56658ca9130df2f12dff6c49dfaf261d3b842c1f2b0265ca
User & Date: js on 2016-05-07 11:21:37
Other Links: manifest | tags
Context
2016-05-07
11:23
Cleaner PONG check-in: aa89dd371b user: js tags: trunk
11:21
Adjust to ObjFW changes check-in: e7f0831117 user: js tags: trunk
2013-07-12
14:12
Adjust to ObjFW API and fix a disconnect bug. check-in: 1813701690 user: js tags: trunk
Changes

Modified src/IRCConnection.h from [aec6e61116] to [0fe0fac278].

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#import <ObjFW/ObjFW.h>

@class IRCConnection;
@class IRCUser;

@protocol IRCConnectionDelegate <OFObject>
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
- (void)connection: (IRCConnection*)connection
    didReceiveLine: (OFString*)line;
- (void)connection: (IRCConnection*)connection
       didSendLine: (OFString*)line;
- (void)connectionWasEstablished: (IRCConnection*)connection;
- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user







<

<







22
23
24
25
26
27
28

29

30
31
32
33
34
35
36

#import <ObjFW/ObjFW.h>

@class IRCConnection;
@class IRCUser;

@protocol IRCConnectionDelegate <OFObject>

@optional

- (void)connection: (IRCConnection*)connection
    didReceiveLine: (OFString*)line;
- (void)connection: (IRCConnection*)connection
       didSendLine: (OFString*)line;
- (void)connectionWasEstablished: (IRCConnection*)connection;
- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
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
	OFString *_server;
	uint16_t _port;
	OFString *_nickname, *_username, *_realname;
	OFMutableDictionary *_channels;
	id <IRCConnectionDelegate> _delegate;
}

#ifdef OF_HAVE_PROPERTIES
@property (copy) OFString *server;
@property (assign) uint16_t port;
@property (copy) OFString *nickname, *username, *realname;
@property (assign) id <IRCConnectionDelegate> delegate;
@property (readonly, retain) OFTCPSocket *socket;
#endif

+ (instancetype)connection;
- (void)setServer: (OFString*)server;
- (OFString*)server;
- (void)setPort: (uint16_t)port;
- (uint16_t)port;
- (void)setNickname: (OFString*)nickname;
- (OFString*)nickname;
- (void)setUsername: (OFString*)username;
- (OFString*)username;
- (void)setRealname: (OFString*)realname;
- (OFString*)realname;
- (void)setDelegate: (id <IRCConnectionDelegate>)delegate;
- (id <IRCConnectionDelegate>)delegate;
- (OFTCPSocket*)socket;
- (void)sendLine: (OFString*)line;
- (void)sendLineWithFormat: (OFConstantString*)line, ...;
- (void)connect;
- (void)disconnect;
- (void)disconnectWithReason: (OFString*)reason;
- (void)joinChannel: (OFString*)channelName;
- (void)leaveChannel: (OFString*)channel;







<





<


<
<
<
<
<
<
<
<
<
<
<
<
<







75
76
77
78
79
80
81

82
83
84
85
86

87
88













89
90
91
92
93
94
95
	OFString *_server;
	uint16_t _port;
	OFString *_nickname, *_username, *_realname;
	OFMutableDictionary *_channels;
	id <IRCConnectionDelegate> _delegate;
}


@property (copy) OFString *server;
@property (assign) uint16_t port;
@property (copy) OFString *nickname, *username, *realname;
@property (assign) id <IRCConnectionDelegate> delegate;
@property (readonly, retain) OFTCPSocket *socket;


+ (instancetype)connection;













- (void)sendLine: (OFString*)line;
- (void)sendLineWithFormat: (OFConstantString*)line, ...;
- (void)connect;
- (void)disconnect;
- (void)disconnectWithReason: (OFString*)reason;
- (void)joinChannel: (OFString*)channelName;
- (void)leaveChannel: (OFString*)channel;
120
121
122
123
124
125
126
127
128
129
	 channel: (OFString*)channel
	  reason: (OFString*)reason;
- (void)changeNicknameTo: (OFString*)nickname;
- (void)processLine: (OFString*)line;
- (void)handleConnection;
- (OFSet*)usersInChannel: (OFString*)channel;
@end

@interface OFObject (IRCConnectionDelegate) <IRCConnectionDelegate>
@end







<
<
<
103
104
105
106
107
108
109



	 channel: (OFString*)channel
	  reason: (OFString*)reason;
- (void)changeNicknameTo: (OFString*)nickname;
- (void)processLine: (OFString*)line;
- (void)handleConnection;
- (OFSet*)usersInChannel: (OFString*)channel;
@end



Modified src/IRCConnection.m from [adb245b3eb] to [59f01b1597].

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40




41
42
43
44
45
46
47

#include <stdarg.h>

#import <ObjFW/OFString.h>
#import <ObjFW/OFArray.h>
#import <ObjFW/OFMutableDictionary.h>
#import <ObjFW/OFTCPSocket.h>
#import <ObjFW/OFAutoreleasePool.h>

#import <ObjFW/OFInvalidEncodingException.h>

#import <ObjFW/macros.h>

#import "IRCConnection.h"
#import "IRCUser.h"

@implementation IRCConnection




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

- init
{







<









>
>
>
>







24
25
26
27
28
29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#include <stdarg.h>

#import <ObjFW/OFString.h>
#import <ObjFW/OFArray.h>
#import <ObjFW/OFMutableDictionary.h>
#import <ObjFW/OFTCPSocket.h>


#import <ObjFW/OFInvalidEncodingException.h>

#import <ObjFW/macros.h>

#import "IRCConnection.h"
#import "IRCUser.h"

@implementation IRCConnection
@synthesize server = _server, port = _port;
@synthesize nickname = _nickname, username = _username, realname = _realname;
@synthesize delegate = _delegate, socket = _socket;

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

- init
{
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161


162
163
164
165
166
167


168
169
170
171


172
173
174


175
176
177
178
179
180
181
182
183
184
185


186
187
188
189
190
191
192
193
194


195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229

230


231
232
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
262
263
264
265
	[_username release];
	[_realname release];
	[_channels release];

	[super dealloc];
}

- (void)setServer: (OFString*)server
{
	OF_SETTER(_server, server, true, 1)
}

- (OFString*)server
{
	OF_GETTER(_server, true)
}

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

- (uint16_t)port
{
	return _port;
}

- (void)setNickname: (OFString*)nickname
{
	OF_SETTER(_nickname, nickname, true, 1)
}

- (OFString*)nickname
{
	OF_GETTER(_nickname, true)
}

- (void)setUsername: (OFString*)username
{
	OF_SETTER(_username, username, true, 1)
}

- (OFString*)username
{
	OF_GETTER(_username, true)
}

- (void)setRealname: (OFString*)realname
{
	OF_SETTER(_realname, realname, true, 1)
}

- (OFString*)realname
{
	OF_GETTER(_realname, true)
}

- (void)setDelegate: (id <IRCConnectionDelegate>)delegate
{
	_delegate = delegate;
}

- (id <IRCConnectionDelegate>)delegate
{
	OF_GETTER(_delegate, false)
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, true)
}

- (void)connect
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	if (_socket != nil)
		@throw [OFAlreadyConnectedException exception];

	_socket = [[OFTCPSocket alloc] init];
	[_socket connectToHost: _server
			  port: _port];

	[self sendLineWithFormat: @"NICK %@", _nickname];
	[self sendLineWithFormat: @"USER %@ * 0 :%@", _username, _realname];

	[pool release];
}

- (void)disconnect
{
	[self disconnectWithReason: nil];
}

- (void)disconnectWithReason: (OFString*)reason
{


	reason = [[reason componentsSeparatedByString: @"\n"] firstObject];

	if (reason == nil)
		[self sendLine: @"QUIT"];
	else
		[self sendLineWithFormat: @"QUIT :%@", reason];


}

- (void)joinChannel: (OFString*)channel
{


	channel = [[channel componentsSeparatedByString: @"\n"] firstObject];

	[self sendLineWithFormat: @"JOIN %@", channel];


}

- (void)leaveChannel: (OFString*)channel
{
	[self leaveChannel: channel
		    reason: nil];
}

- (void)leaveChannel: (OFString*)channel
	      reason: (OFString*)reason
{


	channel = [[channel componentsSeparatedByString: @"\n"] firstObject];
	reason = [[reason componentsSeparatedByString: @"\n"] firstObject];

	if (reason == nil)
		[self sendLineWithFormat: @"PART %@", channel];
	else
		[self sendLineWithFormat: @"PART %@ :%@", channel, reason];

	[_channels removeObjectForKey: channel];


}

- (void)sendLine: (OFString*)line
{
	if ([_delegate respondsToSelector: @selector(connection:didSendLine:)])
		[_delegate connection: self
			  didSendLine: line];

	[_socket writeLine: line];
}

- (void)sendLineWithFormat: (OFConstantString*)format, ...
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFString *line;
	va_list args;

	va_start(args, format);
	line = [[[OFString alloc] initWithFormat: format
				       arguments: args] autorelease];
	va_end(args);

	[self sendLine: line];

	[pool release];
}

- (void)sendMessage: (OFString*)msg
		 to: (OFString*)to
{
	OFArray *lines = [msg componentsSeparatedByString: @"\n"];
	OFEnumerator *enumerator = [lines objectEnumerator];
	OFString *line;

	while ((line = [enumerator nextObject]) != nil)

		[self sendLineWithFormat: @"PRIVMSG %@ :%@", to, line];


}

- (void)sendNotice: (OFString*)notice
		to: (OFString*)to
{
	OFArray *lines = [notice componentsSeparatedByString: @"\n"];
	OFEnumerator *enumerator = [lines objectEnumerator];
	OFString *line;

	while ((line = [enumerator nextObject]) != nil)

		[self sendLineWithFormat: @"NOTICE %@ :%@", to, line];


}

- (void)kickUser: (OFString*)user
	 channel: (OFString*)channel
	  reason: (OFString*)reason
{


	reason = [[reason componentsSeparatedByString: @"\n"] firstObject];

	[self sendLineWithFormat: @"KICK %@ %@ :%@", channel, user, reason];


}

- (void)changeNicknameTo: (OFString*)nickname
{


	nickname = [[nickname componentsSeparatedByString: @"\n"]
	    firstObject];

	[self sendLineWithFormat: @"NICK %@", nickname];


}

- (void)IRC_processLine: (OFString*)line
{
	OFArray *components;
	OFString *action = nil;








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


|











|









>
>






>
>




>
>



>
>











>
>









>
>













|










|





|
<
<

<
>

>
>





|
<
<

<
>

>
>






>
>



>
>




>
>




>
>







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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175


176

177
178
179
180
181
182
183
184
185
186


187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
	[_username release];
	[_realname release];
	[_channels release];

	[super dealloc];
}


































































- (void)connect
{
	void *pool = objc_autoreleasePoolPush();

	if (_socket != nil)
		@throw [OFAlreadyConnectedException exception];

	_socket = [[OFTCPSocket alloc] init];
	[_socket connectToHost: _server
			  port: _port];

	[self sendLineWithFormat: @"NICK %@", _nickname];
	[self sendLineWithFormat: @"USER %@ * 0 :%@", _username, _realname];

	objc_autoreleasePoolPop(pool);
}

- (void)disconnect
{
	[self disconnectWithReason: nil];
}

- (void)disconnectWithReason: (OFString*)reason
{
	void *pool = objc_autoreleasePoolPush();

	reason = [[reason componentsSeparatedByString: @"\n"] firstObject];

	if (reason == nil)
		[self sendLine: @"QUIT"];
	else
		[self sendLineWithFormat: @"QUIT :%@", reason];

	objc_autoreleasePoolPop(pool);
}

- (void)joinChannel: (OFString*)channel
{
	void *pool = objc_autoreleasePoolPush();

	channel = [[channel componentsSeparatedByString: @"\n"] firstObject];

	[self sendLineWithFormat: @"JOIN %@", channel];

	objc_autoreleasePoolPop(pool);
}

- (void)leaveChannel: (OFString*)channel
{
	[self leaveChannel: channel
		    reason: nil];
}

- (void)leaveChannel: (OFString*)channel
	      reason: (OFString*)reason
{
	void *pool = objc_autoreleasePoolPush();

	channel = [[channel componentsSeparatedByString: @"\n"] firstObject];
	reason = [[reason componentsSeparatedByString: @"\n"] firstObject];

	if (reason == nil)
		[self sendLineWithFormat: @"PART %@", channel];
	else
		[self sendLineWithFormat: @"PART %@ :%@", channel, reason];

	[_channels removeObjectForKey: channel];

	objc_autoreleasePoolPop(pool);
}

- (void)sendLine: (OFString*)line
{
	if ([_delegate respondsToSelector: @selector(connection:didSendLine:)])
		[_delegate connection: self
			  didSendLine: line];

	[_socket writeLine: line];
}

- (void)sendLineWithFormat: (OFConstantString*)format, ...
{
	void *pool = objc_autoreleasePoolPush();
	OFString *line;
	va_list args;

	va_start(args, format);
	line = [[[OFString alloc] initWithFormat: format
				       arguments: args] autorelease];
	va_end(args);

	[self sendLine: line];

	objc_autoreleasePoolPop(pool);
}

- (void)sendMessage: (OFString*)msg
		 to: (OFString*)to
{
	void *pool = objc_autoreleasePoolPush();




	for (OFString *line in [msg componentsSeparatedByString: @"\n"])
		[self sendLineWithFormat: @"PRIVMSG %@ :%@", to, line];

	objc_autoreleasePoolPop(pool);
}

- (void)sendNotice: (OFString*)notice
		to: (OFString*)to
{
	void *pool = objc_autoreleasePoolPush();




	for (OFString *line in [notice componentsSeparatedByString: @"\n"])
		[self sendLineWithFormat: @"NOTICE %@ :%@", to, line];

	objc_autoreleasePoolPop(pool);
}

- (void)kickUser: (OFString*)user
	 channel: (OFString*)channel
	  reason: (OFString*)reason
{
	void *pool = objc_autoreleasePoolPush();

	reason = [[reason componentsSeparatedByString: @"\n"] firstObject];

	[self sendLineWithFormat: @"KICK %@ %@ :%@", channel, user, reason];

	objc_autoreleasePoolPop(pool);
}

- (void)changeNicknameTo: (OFString*)nickname
{
	void *pool = objc_autoreleasePoolPush();

	nickname = [[nickname componentsSeparatedByString: @"\n"]
	    firstObject];

	[self sendLineWithFormat: @"NICK %@", nickname];

	objc_autoreleasePoolPop(pool);
}

- (void)IRC_processLine: (OFString*)line
{
	OFArray *components;
	OFString *action = nil;

323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358

	/* NAMES reply */
	if ([action isEqual: @"353"] && [components count] >= 6) {
		OFString *where;
		OFMutableSet *channel;
		OFArray *users;
		size_t pos;
		OFEnumerator *enumerator;
		OFString *user;

		where = [components objectAtIndex: 4];

		if ((channel = [_channels objectForKey: where]) == nil) {
			/* We did not request that */
			return;
		}

		pos = [[components objectAtIndex: 0] length] +
		    [[components objectAtIndex: 1] length] +
		    [[components objectAtIndex: 2] length] +
		    [[components objectAtIndex: 3] length] +
		    [[components objectAtIndex: 4] length] + 6;

		users = [[line substringWithRange:
		    of_range(pos, [line length] - pos)]
		    componentsSeparatedByString: @" "];

		enumerator = [users objectEnumerator];
		while ((user = [enumerator nextObject]) != nil) {
			if ([user hasPrefix: @"@"] || [user hasPrefix: @"+"] ||
			    [user hasPrefix: @"%"] || [user hasPrefix: @"*"])
				user = [user substringWithRange:
				    of_range(1, [user length] - 1)];

			[channel addObject: user];
		}







<
<


















|
<







281
282
283
284
285
286
287


288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306

307
308
309
310
311
312
313

	/* NAMES reply */
	if ([action isEqual: @"353"] && [components count] >= 6) {
		OFString *where;
		OFMutableSet *channel;
		OFArray *users;
		size_t pos;



		where = [components objectAtIndex: 4];

		if ((channel = [_channels objectForKey: where]) == nil) {
			/* We did not request that */
			return;
		}

		pos = [[components objectAtIndex: 0] length] +
		    [[components objectAtIndex: 1] length] +
		    [[components objectAtIndex: 2] length] +
		    [[components objectAtIndex: 3] length] +
		    [[components objectAtIndex: 4] length] + 6;

		users = [[line substringWithRange:
		    of_range(pos, [line length] - pos)]
		    componentsSeparatedByString: @" "];

		for (OFString *user in users) {

			if ([user hasPrefix: @"@"] || [user hasPrefix: @"+"] ||
			    [user hasPrefix: @"%"] || [user hasPrefix: @"*"])
				user = [user substringWithRange:
				    of_range(1, [user length] - 1)];

			[channel addObject: user];
		}
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
	/* QUIT */
	if ([action isEqual: @"QUIT"] && [components count] >= 2) {
		OFString *who = [components objectAtIndex: 0];
		IRCUser *user;
		OFString *reason = nil;
		size_t pos = [who length] + 1 +
		    [[components objectAtIndex: 1] length];
		OFEnumerator *enumerator;
		OFMutableSet *channel;

		who = [who substringWithRange: of_range(1, [who length] - 1)];
		user = [IRCUser IRCUserWithString: who];

		if ([components count] > 2)
			reason = [line substringWithRange:
			    of_range(pos + 2, [line length] - pos - 2)];

		enumerator = [_channels objectEnumerator];
		while ((channel = [enumerator nextObject]) != nil)
			[channel removeObject: [user nickname]];

		if ([_delegate respondsToSelector:
		    @selector(connection:didSeeUserQuit:reason:)])
			[_delegate connection: self
			       didSeeUserQuit: user
				       reason: reason];

		return;
	}

	/* NICK */
	if ([action isEqual: @"NICK"] && [components count] == 3) {
		OFString *who = [components objectAtIndex: 0];
		OFString *nickname = [components objectAtIndex: 2];
		IRCUser *user;
		OFEnumerator *enumerator;
		OFMutableSet *channel;

		who = [who substringWithRange: of_range(1, [who length] - 1)];
		nickname = [nickname substringWithRange:
		    of_range(1, [nickname length] - 1)];

		user = [IRCUser IRCUserWithString: who];

		if ([[user nickname] isEqual: _nickname]) {
			[_nickname release];
			_nickname = [nickname copy];
		}

		enumerator = [_channels objectEnumerator];
		while ((channel = [enumerator nextObject]) != nil) {
			if ([channel containsObject: [user nickname]]) {
				[channel removeObject: [user nickname]];
				[channel addObject: nickname];
			}
		}

		if ([_delegate respondsToSelector:







<
<








|
<
















<
<












|
<







386
387
388
389
390
391
392


393
394
395
396
397
398
399
400
401

402
403
404
405
406
407
408
409
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
	/* QUIT */
	if ([action isEqual: @"QUIT"] && [components count] >= 2) {
		OFString *who = [components objectAtIndex: 0];
		IRCUser *user;
		OFString *reason = nil;
		size_t pos = [who length] + 1 +
		    [[components objectAtIndex: 1] length];



		who = [who substringWithRange: of_range(1, [who length] - 1)];
		user = [IRCUser IRCUserWithString: who];

		if ([components count] > 2)
			reason = [line substringWithRange:
			    of_range(pos + 2, [line length] - pos - 2)];

		for (OFMutableSet *channel in _channels)

			[channel removeObject: [user nickname]];

		if ([_delegate respondsToSelector:
		    @selector(connection:didSeeUserQuit:reason:)])
			[_delegate connection: self
			       didSeeUserQuit: user
				       reason: reason];

		return;
	}

	/* NICK */
	if ([action isEqual: @"NICK"] && [components count] == 3) {
		OFString *who = [components objectAtIndex: 0];
		OFString *nickname = [components objectAtIndex: 2];
		IRCUser *user;



		who = [who substringWithRange: of_range(1, [who length] - 1)];
		nickname = [nickname substringWithRange:
		    of_range(1, [nickname length] - 1)];

		user = [IRCUser IRCUserWithString: who];

		if ([[user nickname] isEqual: _nickname]) {
			[_nickname release];
			_nickname = [nickname copy];
		}

		for (OFMutableSet *channel in _channels) {

			if ([channel containsObject: [user nickname]]) {
				[channel removeObject: [user nickname]];
				[channel addObject: nickname];
			}
		}

		if ([_delegate respondsToSelector:
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583

		return;
	}
}

- (void)processLine: (OFString*)line
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	[self IRC_processLine: line];

	[pool release];
}

-	    (bool)socket: (OFTCPSocket*)socket
  didReceiveISO88591Line: (OFString*)line
	       exception: (OFException*)exception
{
	if (line != nil) {







|



|







514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532

		return;
	}
}

- (void)processLine: (OFString*)line
{
	void *pool = objc_autoreleasePoolPush();

	[self IRC_processLine: line];

	objc_autoreleasePoolPop(pool);
}

-	    (bool)socket: (OFTCPSocket*)socket
  didReceiveISO88591Line: (OFString*)line
	       exception: (OFException*)exception
{
	if (line != nil) {

Modified src/IRCUser.h from [b31edf76a9] to [b2083930e4].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#import <ObjFW/OFObject.h>

@interface IRCUser: OFObject <OFCopying>
{
	OFString *_nickname, *_username, *_hostname;
}

#ifdef OF_HAVE_PROPERTIES
@property (copy, readonly) OFString *nickname, *username, *hostname;
#endif

+ (instancetype)IRCUserWithString: (OFString*)string;
- initWithString: (OFString*)string;
- (OFString*)nickname;
- (OFString*)username;
- (OFString*)hostname;
@end







<

<



<
<
<

23
24
25
26
27
28
29

30

31
32
33



34
#import <ObjFW/OFObject.h>

@interface IRCUser: OFObject <OFCopying>
{
	OFString *_nickname, *_username, *_hostname;
}


@property (copy, readonly) OFString *nickname, *username, *hostname;


+ (instancetype)IRCUserWithString: (OFString*)string;
- initWithString: (OFString*)string;



@end

Modified src/IRCUser.m from [1fa74637a1] to [d43c26daf1].

29
30
31
32
33
34
35


36
37
38
39
40
41
42
#import <ObjFW/OFOutOfMemoryException.h>

#import <ObjFW/macros.h>

#import "IRCUser.h"

@implementation IRCUser


+ (instancetype)IRCUserWithString: (OFString*)string
{
	return [[[self alloc] initWithString: string] autorelease];
}

- initWithString: (OFString*)string
{







>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#import <ObjFW/OFOutOfMemoryException.h>

#import <ObjFW/macros.h>

#import "IRCUser.h"

@implementation IRCUser
@synthesize username = _username, nickname = _nickname, hostname = _hostname;

+ (instancetype)IRCUserWithString: (OFString*)string
{
	return [[[self alloc] initWithString: string] autorelease];
}

- initWithString: (OFString*)string
{
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
	[_nickname release];
	[_username release];
	[_hostname release];

	[super dealloc];
}

- (OFString*)username
{
	OF_GETTER(_username, true)
}

- (OFString*)nickname
{
	OF_GETTER(_nickname, true)
}

- (OFString*)hostname
{
	OF_GETTER(_hostname, true)
}

- copy
{
	return [self retain];
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"%@!%@@%@",
					   _nickname, _username, _hostname];
}
@end







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<











83
84
85
86
87
88
89















90
91
92
93
94
95
96
97
98
99
100
	[_nickname release];
	[_username release];
	[_hostname release];

	[super dealloc];
}
















- copy
{
	return [self retain];
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"%@!%@@%@",
					   _nickname, _username, _hostname];
}
@end

Modified tests/test.m from [4612327517] to [9f9c8d8d61].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import <ObjFW/OFString.h>
#import <ObjFW/OFApplication.h>
#import <ObjFW/OFFile.h>

#import "IRCConnection.h"
#import "IRCUser.h"

@interface TestApp: OFObject
@end

OF_APPLICATION_DELEGATE(TestApp)

@implementation TestApp
- (void)applicationDidFinishLaunching
{







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import <ObjFW/OFString.h>
#import <ObjFW/OFApplication.h>
#import <ObjFW/OFFile.h>

#import "IRCConnection.h"
#import "IRCUser.h"

@interface TestApp: OFObject <OFApplicationDelegate, IRCConnectionDelegate>
@end

OF_APPLICATION_DELEGATE(TestApp)

@implementation TestApp
- (void)applicationDidFinishLaunching
{