ObjIRC  Check-in [75e955fa17]

Overview
Comment:Fix method signature mismatch
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 75e955fa17428630e13a1e86609a24456dbb43ca823b8d05e3543e8d3be7e1e7
User & Date: js on 2018-11-11 10:47:12
Other Links: manifest | tags
Context
2018-12-17
21:04
Adjust to ObjFW changes check-in: 42243ac2f7 user: js tags: trunk
2018-11-11
10:47
Fix method signature mismatch check-in: 75e955fa17 user: js tags: trunk
2018-11-06
22:34
Fix compilation with GCC check-in: 77e08a1214 user: js tags: trunk
Changes

Modified src/IRCConnection.m from [688cb09cde] to [e49892a8ab].

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@synthesize pingInterval = _pingInterval, pingTimeout = _pingTimeout;

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

- init
{
	self = [super init];

	@try {
		_socketClass = [OFTCPSocket class];
		_channels = [[OFMutableDictionary alloc] init];
		_port = 6667;







|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@synthesize pingInterval = _pingInterval, pingTimeout = _pingTimeout;

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

- (instancetype)init
{
	self = [super init];

	@try {
		_socketClass = [OFTCPSocket class];
		_channels = [[OFMutableDictionary alloc] init];
		_port = 6667;
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
	    firstObject];

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

	objc_autoreleasePoolPop(pool);
}

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

	if ([_delegate respondsToSelector:
	    @selector(connection:didReceiveLine:)])
		[_delegate connection: self







|







227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
	    firstObject];

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

	objc_autoreleasePoolPop(pool);
}

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

	if ([_delegate respondsToSelector:
	    @selector(connection:didReceiveLine:)])
		[_delegate connection: self
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
	if ([action isEqual: @"001"] && [components count] >= 4) {
		if ([_delegate respondsToSelector:
		    @selector(connectionWasEstablished:)])
			[_delegate connectionWasEstablished: self];

		[OFTimer scheduledTimerWithTimeInterval: _pingInterval
						 target: self
					       selector: @selector(IRC_sendPing)
						repeats: true];

		return;
	}

	/* JOIN */
	if ([action isEqual: @"JOIN"] && [components count] == 3) {







|







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
	if ([action isEqual: @"001"] && [components count] >= 4) {
		if ([_delegate respondsToSelector:
		    @selector(connectionWasEstablished:)])
			[_delegate connectionWasEstablished: self];

		[OFTimer scheduledTimerWithTimeInterval: _pingInterval
						 target: self
					       selector: @selector(irc_sendPing)
						repeats: true];

		return;
	}

	/* JOIN */
	if ([action isEqual: @"JOIN"] && [components count] == 3) {
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588

589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604

605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
						 user: user];
		}

		return;
	}
}

- (void)IRC_sendPing
{
	[_pingData release];
	[_pingTimer release];

	_pingData = [[OFString alloc] initWithFormat: @":%d", rand()];
	[_socket writeFormat: @"PING %@\r\n", _pingData];

	_pingTimer = [[OFTimer
	    scheduledTimerWithTimeInterval: _pingTimeout
				    target: self
				  selector: @selector(IRC_pingTimeout)
				   repeats: false] retain];
}

- (void)IRC_pingTimeout
{
	if ([_delegate respondsToSelector: @selector(connectionWasClosed:)])
		[_delegate connectionWasClosed: self];

	[_socket cancelAsyncRequests];
	[_socket release];
	_socket = nil;
}

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

	[self IRC_processLine: line];

	objc_autoreleasePoolPop(pool);
}

-		  (bool)socket: (OFTCPSocket *)socket
  didReceiveWronglyEncodedLine: (OFString *)line

		     exception: (OFException *)exception
{
	if (line != nil) {
		[self IRC_processLine: line];
		[socket asyncReadLineWithTarget: self
				       selector: @selector(socket:
						     didReceiveLine:
						     exception:)
					context: nil];
	}

	return false;
}

-   (bool)socket: (OFTCPSocket *)socket
  didReceiveLine: (OFString *)line

       exception: (OFException *)exception
{
	if (line != nil) {
		[self IRC_processLine: line];
		return true;
	}

	if ([exception isKindOfClass: [OFInvalidEncodingException class]]) {
		[socket
		    asyncReadLineWithEncoding: _fallbackEncoding
				       target: self
				     selector: @selector(socket:
						   didReceiveWronglyEncodedLine:
						   exception:)
				      context: nil];
		return false;
	}

	if ([_delegate respondsToSelector: @selector(connectionWasClosed:)])
		[_delegate connectionWasClosed: self];

	[_pingTimer invalidate];

	[_socket performSelector: @selector(cancelAsyncRequests)
		      afterDelay: 0];
	[_socket release];
	_socket = nil;

	return false;
}

- (void)handleConnection
{
	[_socket asyncReadLineWithTarget: self
				selector: @selector(socket:didReceiveLine:
					      exception:)
				 context: nil];
}

- (OFSet OF_GENERIC(OFString *) *)usersInChannel: (OFString *)channel
{
	return [[[_channels objectForKey: channel] copy] autorelease];
}
@end







|










|



|













|




|

>



|

|
|







|
|
>
|


|







|

|




















|
|








546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
						 user: user];
		}

		return;
	}
}

- (void)irc_sendPing
{
	[_pingData release];
	[_pingTimer release];

	_pingData = [[OFString alloc] initWithFormat: @":%d", rand()];
	[_socket writeFormat: @"PING %@\r\n", _pingData];

	_pingTimer = [[OFTimer
	    scheduledTimerWithTimeInterval: _pingTimeout
				    target: self
				  selector: @selector(irc_pingTimeout)
				   repeats: false] retain];
}

- (void)irc_pingTimeout
{
	if ([_delegate respondsToSelector: @selector(connectionWasClosed:)])
		[_delegate connectionWasClosed: self];

	[_socket cancelAsyncRequests];
	[_socket release];
	_socket = nil;
}

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

	[self irc_processLine: line];

	objc_autoreleasePoolPop(pool);
}

-	      (bool)irc_socket: (OFTCPSocket *)socket
  didReceiveWronglyEncodedLine: (OFString *)line
		       context: (id)context
		     exception: (OFException *)exception
{
	if (line != nil) {
		[self irc_processLine: line];
		[socket asyncReadLineWithTarget: self
				       selector: @selector(irc_socket:
						     didReceiveLine:context:
						     exception:)
					context: nil];
	}

	return false;
}

- (bool)irc_socket: (OFTCPSocket *)socket
    didReceiveLine: (OFString *)line
	   context: (id)context
	 exception: (OFException *)exception
{
	if (line != nil) {
		[self irc_processLine: line];
		return true;
	}

	if ([exception isKindOfClass: [OFInvalidEncodingException class]]) {
		[socket
		    asyncReadLineWithEncoding: _fallbackEncoding
				       target: self
				     selector: @selector(irc_socket:
						   didReceiveWronglyEncodedLine:
						   context:exception:)
				      context: nil];
		return false;
	}

	if ([_delegate respondsToSelector: @selector(connectionWasClosed:)])
		[_delegate connectionWasClosed: self];

	[_pingTimer invalidate];

	[_socket performSelector: @selector(cancelAsyncRequests)
		      afterDelay: 0];
	[_socket release];
	_socket = nil;

	return false;
}

- (void)handleConnection
{
	[_socket asyncReadLineWithTarget: self
				selector: @selector(irc_socket:didReceiveLine:
					      context:exception:)
				 context: nil];
}

- (OFSet OF_GENERIC(OFString *) *)usersInChannel: (OFString *)channel
{
	return [[[_channels objectForKey: channel] copy] autorelease];
}
@end