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 IRCConnection;
@class IRCUser; @class IRCUser;
#ifndef IRC_CONNECTION_M
@protocol IRCConnectionDelegate <OFObject> @protocol IRCConnectionDelegate <OFObject>
#else
@protocol IRCConnectionDelegate
#endif
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS #ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional @optional
#endif #endif

View file

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