Don't implement IRCConnectionDelegate on OFObject.

FossilOrigin-Name: c99e07382f3d50e498f16baf600180109fac6f844aa79b3ce0fa7068e32f7a2a
This commit is contained in:
Jonathan Schleifer 2013-02-14 00:32:02 +00:00
parent 97b6edeb00
commit 0ed61817fa
2 changed files with 71 additions and 131 deletions

View file

@ -25,11 +25,7 @@
@class IRCConnection;
@class IRCUser;
#ifndef IRC_CONNECTION_M
@protocol IRCConnectionDelegate <OFObject>
#else
@protocol IRCConnectionDelegate
#endif
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif

View file

@ -188,6 +188,7 @@
- (void)sendLine: (OFString*)line
{
if ([_delegate respondsToSelector: @selector(connection:didSendLine:)])
[_delegate connection: self
didSendLine: line];
@ -254,6 +255,8 @@
OFArray *components;
OFString *action = nil;
if ([_delegate respondsToSelector:
@selector(connection:didReceiveLine:)])
[_delegate connection: self
didReceiveLine: line];
@ -274,7 +277,10 @@
/* Connected */
if ([action isEqual: @"001"] && [components count] >= 4) {
if ([_delegate respondsToSelector:
@selector(connectionWasEstablished:)])
[_delegate connectionWasEstablished: self];
return;
}
@ -298,6 +304,8 @@
[channel addObject: [user nickname]];
if ([_delegate respondsToSelector:
@selector(connection:didSeeUser:joinChannel:)])
[_delegate connection: self
didSeeUser: user
joinChannel: where];
@ -341,6 +349,8 @@
[channel addObject: user];
}
if ([_delegate respondsToSelector:
@selector(connection:didReceiveNamesForChannel:)])
[_delegate connection: self
didReceiveNamesForChannel: where];
@ -367,6 +377,8 @@
[channel removeObject: [user nickname]];
if ([_delegate respondsToSelector:
@selector(connection:didSeeUser:leaveChannel:reason:)])
[_delegate connection: self
didSeeUser: user
leaveChannel: where
@ -397,6 +409,8 @@
[channel removeObject: [user nickname]];
if ([_delegate respondsToSelector:
@selector(connection:didSeeUser:kickUser:channel:reason:)])
[_delegate connection: self
didSeeUser: user
kickUser: whom
@ -427,6 +441,8 @@
while ((channel = [enumerator nextObject]) != nil)
[channel removeObject: [user nickname]];
if ([_delegate respondsToSelector:
@selector(connection:didSeeUserQuit:reason:)])
[_delegate connection: self
didSeeUserQuit: user
reason: reason];
@ -461,6 +477,8 @@
}
}
if ([_delegate respondsToSelector:
@selector(connection:didSeeUser:changeNicknameTo:)])
[_delegate connection: self
didSeeUser: user
changeNicknameTo: nickname];
@ -483,15 +501,20 @@
of_range(pos + 2, [line length] - pos - 2)];
user = [IRCUser IRCUserWithString: from];
if (![to isEqual: _nickname])
if (![to isEqual: _nickname]) {
if ([_delegate respondsToSelector: @selector(connection:
didReceiveMessage:channel:user:)])
[_delegate connection: self
didReceiveMessage: msg
channel: to
user: user];
else
} else {
if ([_delegate respondsToSelector: @selector(connection:
didReceivePrivateMessage:user:)])
[_delegate connection: self
didReceivePrivateMessage: msg
user: user];
}
return;
}
@ -517,15 +540,20 @@
user = [IRCUser IRCUserWithString: from];
if (![to isEqual: _nickname])
if (![to isEqual: _nickname]) {
if ([_delegate respondsToSelector: @selector(connection:
didReceiveNotice:channel:user:)])
[_delegate connection: self
didReceiveNotice: notice
channel: to
user: user];
else
} else {
if ([_delegate respondsToSelector:
@selector(connection:didReceiveNotice:user:)])
[_delegate connection: self
didReceiveNotice: notice
user: user];
}
return;
}
@ -586,87 +614,3 @@
return [[[_channels objectForKey: channel] copy] autorelease];
}
@end
@implementation OFObject (IRCConnectionDelegate)
- (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
joinChannel: (OFString*)channel
{
}
- (void)connection: (IRCConnection*)connection
didSeeUser: (IRCUser*)user
leaveChannel: (OFString*)channel
reason: (OFString*)reason
{
}
- (void)connection: (IRCConnection*)connection
didSeeUser: (IRCUser*)user
changeNicknameTo: (OFString*)nickname
{
}
- (void)connection: (IRCConnection*)connection
didSeeUser: (IRCUser*)user
kickUser: (OFString*)kickedUser
channel: (OFString*)channel
reason: (OFString*)reason
{
}
- (void)connection: (IRCConnection*)connection
didSeeUserQuit: (IRCUser*)user
reason: (OFString*)reason
{
}
- (void)connection: (IRCConnection*)connection
didReceiveMessage: (OFString*)msg
channel: (OFString*)channel
user: (IRCUser*)user
{
}
- (void)connection: (IRCConnection*)connection
didReceivePrivateMessage: (OFString*)msg
user: (IRCUser*)user
{
}
- (void)connection: (IRCConnection*)connection
didReceiveNotice: (OFString*)notice
channel: (OFString*)channel
user: (IRCUser*)user
{
}
- (void)connection: (IRCConnection*)connection
didReceiveNotice: (OFString*)notice
user: (IRCUser*)user
{
}
- (void)connection: (IRCConnection*)connection
didReceiveNamesForChannel: (OFString*)channel
{
}
- (void)connectionWasClosed: (IRCConnection*)connection
{
}
@end