Adjust to ObjFW changes

FossilOrigin-Name: 3bf621892c7234955008d682211b3985069b4116cc13739081e96c86514ccab2
This commit is contained in:
Jonathan Schleifer 2021-04-29 00:48:45 +00:00
parent e3e8e886a7
commit f6197a27f1
4 changed files with 89 additions and 107 deletions

View file

@ -34,8 +34,7 @@ OF_ASSUME_NONNULL_BEGIN
didCreateSocket: (OF_KINDOF(OFTCPSocket *))socket; didCreateSocket: (OF_KINDOF(OFTCPSocket *))socket;
- (void)connection: (IRCConnection *)connection - (void)connection: (IRCConnection *)connection
didReceiveLine: (OFString *)line; didReceiveLine: (OFString *)line;
- (void)connection: (IRCConnection *)connection - (void)connection: (IRCConnection *)connection didSendLine: (OFString *)line;
didSendLine: (OFString *)line;
- (void)connectionWasEstablished: (IRCConnection *)connection; - (void)connectionWasEstablished: (IRCConnection *)connection;
- (void)connection: (IRCConnection *)connection - (void)connection: (IRCConnection *)connection
didFailToConnectWithException: (id)exception; didFailToConnectWithException: (id)exception;
@ -86,8 +85,8 @@ OF_ASSUME_NONNULL_BEGIN
OFString *_Nullable _realname; OFString *_Nullable _realname;
OFMutableDictionary OF_GENERIC(OFString *, OFMutableSet *) *_channels; OFMutableDictionary OF_GENERIC(OFString *, OFMutableSet *) *_channels;
id <IRCConnectionDelegate> _Nullable _delegate; id <IRCConnectionDelegate> _Nullable _delegate;
of_string_encoding_t _fallbackEncoding; OFStringEncoding _fallbackEncoding;
of_time_interval_t _pingInterval, _pingTimeout; OFTimeInterval _pingInterval, _pingTimeout;
OFString *_Nullable _pingData; OFString *_Nullable _pingData;
OFTimer *_Nullable _pingTimer; OFTimer *_Nullable _pingTimer;
bool _fallbackEncodingUsed; bool _fallbackEncodingUsed;
@ -102,8 +101,8 @@ OF_ASSUME_NONNULL_BEGIN
id <IRCConnectionDelegate> delegate; id <IRCConnectionDelegate> delegate;
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) @property OF_NULLABLE_PROPERTY (readonly, nonatomic)
OF_KINDOF(OFTCPSocket *) socket; OF_KINDOF(OFTCPSocket *) socket;
@property (nonatomic) of_string_encoding_t fallbackEncoding; @property (nonatomic) OFStringEncoding fallbackEncoding;
@property (nonatomic) of_time_interval_t pingInterval, pingTimeout; @property (nonatomic) OFTimeInterval pingInterval, pingTimeout;
+ (instancetype)connection; + (instancetype)connection;
- (void)sendLine: (OFString *)line; - (void)sendLine: (OFString *)line;
@ -113,12 +112,9 @@ OF_ASSUME_NONNULL_BEGIN
- (void)disconnectWithReason: (nullable OFString *)reason; - (void)disconnectWithReason: (nullable OFString *)reason;
- (void)joinChannel: (OFString *)channelName; - (void)joinChannel: (OFString *)channelName;
- (void)leaveChannel: (OFString *)channel; - (void)leaveChannel: (OFString *)channel;
- (void)leaveChannel: (OFString *)channel - (void)leaveChannel: (OFString *)channel reason: (nullable OFString *)reason;
reason: (nullable OFString *)reason; - (void)sendMessage: (OFString *)message to: (OFString *)to;
- (void)sendMessage: (OFString *)message - (void)sendNotice: (OFString *)notice to: (OFString *)to;
to: (OFString *)to;
- (void)sendNotice: (OFString *)notice
to: (OFString *)to;
- (void)kickUser: (OFString *)user - (void)kickUser: (OFString *)user
channel: (OFString *)channel channel: (OFString *)channel
reason: (nullable OFString *)reason; reason: (nullable OFString *)reason;

View file

@ -61,7 +61,7 @@
_socketClass = [OFTCPSocket class]; _socketClass = [OFTCPSocket class];
_channels = [[OFMutableDictionary alloc] init]; _channels = [[OFMutableDictionary alloc] init];
_port = 6667; _port = 6667;
_fallbackEncoding = OF_STRING_ENCODING_ISO_8859_1; _fallbackEncoding = OFStringEncodingISO8859_1;
_pingInterval = 120; _pingInterval = 120;
_pingTimeout = 30; _pingTimeout = 30;
} @catch (id e) { } @catch (id e) {
@ -95,8 +95,7 @@
_socket = [[_socketClass alloc] init]; _socket = [[_socketClass alloc] init];
[_socket setDelegate: self]; [_socket setDelegate: self];
[_socket asyncConnectToHost: _server [_socket asyncConnectToHost: _server port: _port];
port: _port];
objc_autoreleasePoolPop(pool); objc_autoreleasePoolPop(pool);
} }
@ -117,8 +116,7 @@
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(connection:didCreateSocket:)]) @selector(connection:didCreateSocket:)])
[_delegate connection: self [_delegate connection: self didCreateSocket: _socket];
didCreateSocket: _socket];
[self sendLineWithFormat: @"NICK %@", _nickname]; [self sendLineWithFormat: @"NICK %@", _nickname];
[self sendLineWithFormat: @"USER %@ * 0 :%@", _username, _realname]; [self sendLineWithFormat: @"USER %@ * 0 :%@", _username, _realname];
@ -149,7 +147,7 @@
{ {
void *pool = objc_autoreleasePoolPush(); void *pool = objc_autoreleasePoolPush();
channel = [[channel componentsSeparatedByString: @"\n"] firstObject]; channel = [channel componentsSeparatedByString: @"\n"].firstObject;
[self sendLineWithFormat: @"JOIN %@", channel]; [self sendLineWithFormat: @"JOIN %@", channel];
@ -158,17 +156,15 @@
- (void)leaveChannel: (OFString *)channel - (void)leaveChannel: (OFString *)channel
{ {
[self leaveChannel: channel [self leaveChannel: channel reason: nil];
reason: nil];
} }
- (void)leaveChannel: (OFString *)channel - (void)leaveChannel: (OFString *)channel reason: (OFString *)reason
reason: (OFString *)reason
{ {
void *pool = objc_autoreleasePoolPush(); void *pool = objc_autoreleasePoolPush();
channel = [[channel componentsSeparatedByString: @"\n"] firstObject]; channel = [channel componentsSeparatedByString: @"\n"].firstObject;
reason = [[reason componentsSeparatedByString: @"\n"] firstObject]; reason = [reason componentsSeparatedByString: @"\n"].firstObject;
if (reason == nil) if (reason == nil)
[self sendLineWithFormat: @"PART %@", channel]; [self sendLineWithFormat: @"PART %@", channel];
@ -183,8 +179,7 @@
- (void)sendLine: (OFString *)line - (void)sendLine: (OFString *)line
{ {
if ([_delegate respondsToSelector: @selector(connection:didSendLine:)]) if ([_delegate respondsToSelector: @selector(connection:didSendLine:)])
[_delegate connection: self [_delegate connection: self didSendLine: line];
didSendLine: line];
[_socket writeLine: line]; [_socket writeLine: line];
} }
@ -205,8 +200,7 @@
objc_autoreleasePoolPop(pool); objc_autoreleasePoolPop(pool);
} }
- (void)sendMessage: (OFString *)message - (void)sendMessage: (OFString *)message to: (OFString *)to
to: (OFString *)to
{ {
void *pool = objc_autoreleasePoolPush(); void *pool = objc_autoreleasePoolPush();
@ -216,8 +210,7 @@
objc_autoreleasePoolPop(pool); objc_autoreleasePoolPop(pool);
} }
- (void)sendNotice: (OFString *)notice - (void)sendNotice: (OFString *)notice to: (OFString *)to
to: (OFString *)to
{ {
void *pool = objc_autoreleasePoolPush(); void *pool = objc_autoreleasePoolPush();
@ -244,8 +237,7 @@
{ {
void *pool = objc_autoreleasePoolPush(); void *pool = objc_autoreleasePoolPush();
nickname = [[nickname componentsSeparatedByString: @"\n"] nickname = [nickname componentsSeparatedByString: @"\n"].firstObject;
firstObject];
[self sendLineWithFormat: @"NICK %@", nickname]; [self sendLineWithFormat: @"NICK %@", nickname];
@ -259,8 +251,7 @@
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(connection:didReceiveLine:)]) @selector(connection:didReceiveLine:)])
[_delegate connection: self [_delegate connection: self didReceiveLine: line];
didReceiveLine: line];
components = [line componentsSeparatedByString: @" "]; components = [line componentsSeparatedByString: @" "];
@ -268,7 +259,7 @@
if ([components count] == 2 && if ([components count] == 2 &&
[[components firstObject] isEqual: @"PING"]) { [[components firstObject] isEqual: @"PING"]) {
OFMutableString *s = [[line mutableCopy] autorelease]; OFMutableString *s = [[line mutableCopy] autorelease];
[s replaceCharactersInRange: of_range(0, 4) [s replaceCharactersInRange: OFRangeMake(0, 4)
withString: @"PONG"]; withString: @"PONG"];
[self sendLine: s]; [self sendLine: s];
@ -276,7 +267,7 @@
} }
/* PONG */ /* PONG */
if ([components count] == 4 && if (components.count == 4 &&
[[components objectAtIndex: 1] isEqual: @"PONG"] && [[components objectAtIndex: 1] isEqual: @"PONG"] &&
[[components objectAtIndex: 3] isEqual: _pingData]) { [[components objectAtIndex: 3] isEqual: _pingData]) {
[_pingTimer invalidate]; [_pingTimer invalidate];
@ -291,7 +282,7 @@
action = [[components objectAtIndex: 1] uppercaseString]; action = [[components objectAtIndex: 1] uppercaseString];
/* Connected */ /* Connected */
if ([action isEqual: @"001"] && [components count] >= 4) { if ([action isEqual: @"001"] && components.count >= 4) {
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(connectionWasEstablished:)]) @selector(connectionWasEstablished:)])
[_delegate connectionWasEstablished: self]; [_delegate connectionWasEstablished: self];
@ -305,24 +296,23 @@
} }
/* JOIN */ /* JOIN */
if ([action isEqual: @"JOIN"] && [components count] == 3) { if ([action isEqual: @"JOIN"] && components.count == 3) {
OFString *who = [components objectAtIndex: 0]; OFString *who = [components objectAtIndex: 0];
OFString *where = [components objectAtIndex: 2]; OFString *where = [components objectAtIndex: 2];
IRCUser *user; IRCUser *user;
OFMutableSet *channel; OFMutableSet *channel;
who = [who substringWithRange: of_range(1, [who length] - 1)]; who = [who substringWithRange: OFRangeMake(1, who.length - 1)];
user = [IRCUser IRCUserWithString: who]; user = [IRCUser IRCUserWithString: who];
if ([who hasPrefix: if ([who hasPrefix:
[_nickname stringByAppendingString: @"!"]]) { [_nickname stringByAppendingString: @"!"]]) {
channel = [OFMutableSet set]; channel = [OFMutableSet set];
[_channels setObject: channel [_channels setObject: channel forKey: where];
forKey: where];
} else } else
channel = [_channels objectForKey: where]; channel = [_channels objectForKey: where];
[channel addObject: [user nickname]]; [channel addObject: user.nickname];
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(connection:didSeeUser:joinChannel:)]) @selector(connection:didSeeUser:joinChannel:)])
@ -334,7 +324,7 @@
} }
/* NAMES reply */ /* NAMES reply */
if ([action isEqual: @"353"] && [components count] >= 6) { if ([action isEqual: @"353"] && components.count >= 6) {
OFString *where; OFString *where;
OFMutableSet *channel; OFMutableSet *channel;
OFArray *users; OFArray *users;
@ -354,14 +344,14 @@
[[components objectAtIndex: 4] length] + 6; [[components objectAtIndex: 4] length] + 6;
users = [[line substringWithRange: users = [[line substringWithRange:
of_range(pos, [line length] - pos)] OFRangeMake(pos, line.length - pos)]
componentsSeparatedByString: @" "]; componentsSeparatedByString: @" "];
for (OFString *user in users) { for (OFString *user in users) {
if ([user hasPrefix: @"@"] || [user hasPrefix: @"+"] || if ([user hasPrefix: @"@"] || [user hasPrefix: @"+"] ||
[user hasPrefix: @"%"] || [user hasPrefix: @"*"]) [user hasPrefix: @"%"] || [user hasPrefix: @"*"])
user = [user substringWithRange: user = [user substringWithRange:
of_range(1, [user length] - 1)]; OFRangeMake(1, user.length - 1)];
[channel addObject: user]; [channel addObject: user];
} }
@ -381,18 +371,18 @@
IRCUser *user; IRCUser *user;
OFMutableSet *channel; OFMutableSet *channel;
OFString *reason = nil; OFString *reason = nil;
size_t pos = [who length] + 1 + size_t pos = who.length + 1 +
[[components objectAtIndex: 1] length] + 1 + [where length]; [[components objectAtIndex: 1] length] + 1 + where.length;
who = [who substringWithRange: of_range(1, [who length] - 1)]; who = [who substringWithRange: OFRangeMake(1, who.length - 1)];
user = [IRCUser IRCUserWithString: who]; user = [IRCUser IRCUserWithString: who];
channel = [_channels objectForKey: where]; channel = [_channels objectForKey: where];
if ([components count] > 3) if (components.count > 3)
reason = [line substringWithRange: reason = [line substringWithRange:
of_range(pos + 2, [line length] - pos - 2)]; OFRangeMake(pos + 2, line.length - pos - 2)];
[channel removeObject: [user nickname]]; [channel removeObject: user.nickname];
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(connection:didSeeUser:leaveChannel:reason:)]) @selector(connection:didSeeUser:leaveChannel:reason:)])
@ -405,26 +395,26 @@
} }
/* KICK */ /* KICK */
if ([action isEqual: @"KICK"] && [components count] >= 4) { if ([action isEqual: @"KICK"] && components.count >= 4) {
OFString *who = [components objectAtIndex: 0]; OFString *who = [components objectAtIndex: 0];
OFString *where = [components objectAtIndex: 2]; OFString *where = [components objectAtIndex: 2];
OFString *whom = [components objectAtIndex: 3]; OFString *whom = [components objectAtIndex: 3];
IRCUser *user; IRCUser *user;
OFMutableSet *channel; OFMutableSet *channel;
OFString *reason = nil; OFString *reason = nil;
size_t pos = [who length] + 1 + size_t pos = who.length + 1 +
[[components objectAtIndex: 1] length] + 1 + [[components objectAtIndex: 1] length] + 1 +
[where length] + 1 + [whom length]; where.length + 1 + whom.length;
who = [who substringWithRange: of_range(1, [who length] - 1)]; who = [who substringWithRange: OFRangeMake(1, who.length - 1)];
user = [IRCUser IRCUserWithString: who]; user = [IRCUser IRCUserWithString: who];
channel = [_channels objectForKey: where]; channel = [_channels objectForKey: where];
if ([components count] > 4) if ([components count] > 4)
reason = [line substringWithRange: reason = [line substringWithRange:
of_range(pos + 2, [line length] - pos - 2)]; OFRangeMake(pos + 2, line.length - pos - 2)];
[channel removeObject: [user nickname]]; [channel removeObject: user.nickname];
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(connection:didSeeUser:kickUser:channel:reason:)]) @selector(connection:didSeeUser:kickUser:channel:reason:)])
@ -438,23 +428,23 @@
} }
/* QUIT */ /* QUIT */
if ([action isEqual: @"QUIT"] && [components count] >= 2) { if ([action isEqual: @"QUIT"] && components.count >= 2) {
OFString *who = [components objectAtIndex: 0]; OFString *who = [components objectAtIndex: 0];
IRCUser *user; IRCUser *user;
OFString *reason = nil; OFString *reason = nil;
size_t pos = [who length] + 1 + size_t pos = who.length + 1 +
[[components objectAtIndex: 1] length]; [[components objectAtIndex: 1] length];
who = [who substringWithRange: of_range(1, [who length] - 1)]; who = [who substringWithRange: OFRangeMake(1, who.length - 1)];
user = [IRCUser IRCUserWithString: who]; user = [IRCUser IRCUserWithString: who];
if ([components count] > 2) if ([components count] > 2)
reason = [line substringWithRange: reason = [line substringWithRange:
of_range(pos + 2, [line length] - pos - 2)]; OFRangeMake(pos + 2, line.length - pos - 2)];
for (OFString *channel in _channels) for (OFString *channel in _channels)
[[_channels objectForKey: channel] [[_channels objectForKey: channel]
removeObject: [user nickname]]; removeObject: user.nickname];
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(connection:didSeeUserQuit:reason:)]) @selector(connection:didSeeUserQuit:reason:)])
@ -466,25 +456,25 @@
} }
/* NICK */ /* NICK */
if ([action isEqual: @"NICK"] && [components count] == 3) { if ([action isEqual: @"NICK"] && components.count == 3) {
OFString *who = [components objectAtIndex: 0]; OFString *who = [components objectAtIndex: 0];
OFString *nickname = [components objectAtIndex: 2]; OFString *nickname = [components objectAtIndex: 2];
IRCUser *user; IRCUser *user;
who = [who substringWithRange: of_range(1, [who length] - 1)]; who = [who substringWithRange: OFRangeMake(1, who.length - 1)];
nickname = [nickname substringWithRange: nickname = [nickname substringWithRange:
of_range(1, [nickname length] - 1)]; OFRangeMake(1, nickname.length - 1)];
user = [IRCUser IRCUserWithString: who]; user = [IRCUser IRCUserWithString: who];
if ([[user nickname] isEqual: _nickname]) { if ([user.nickname isEqual: _nickname]) {
[_nickname release]; [_nickname release];
_nickname = [nickname copy]; _nickname = [nickname copy];
} }
for (OFMutableSet *channel in _channels) { for (OFMutableSet *channel in _channels) {
if ([channel containsObject: [user nickname]]) { if ([channel containsObject: user.nickname]) {
[channel removeObject: [user nickname]]; [channel removeObject: user.nickname];
[channel addObject: nickname]; [channel addObject: nickname];
} }
} }
@ -499,18 +489,18 @@
} }
/* PRIVMSG */ /* PRIVMSG */
if ([action isEqual: @"PRIVMSG"] && [components count] >= 4) { if ([action isEqual: @"PRIVMSG"] && components.count >= 4) {
OFString *from = [components objectAtIndex: 0]; OFString *from = [components objectAtIndex: 0];
OFString *to = [components objectAtIndex: 2]; OFString *to = [components objectAtIndex: 2];
IRCUser *user; IRCUser *user;
OFString *message; OFString *message;
size_t pos = [from length] + 1 + size_t pos = from.length + 1 +
[[components objectAtIndex: 1] length] + 1 + [to length]; [[components objectAtIndex: 1] length] + 1 + to.length;
from = [from substringWithRange: from = [from substringWithRange:
of_range(1, [from length] - 1)]; OFRangeMake(1, from.length - 1)];
message = [line substringWithRange: message = [line substringWithRange:
of_range(pos + 2, [line length] - pos - 2)]; OFRangeMake(pos + 2, line.length - pos - 2)];
user = [IRCUser IRCUserWithString: from]; user = [IRCUser IRCUserWithString: from];
if (![to isEqual: _nickname]) { if (![to isEqual: _nickname]) {
@ -532,18 +522,18 @@
} }
/* NOTICE */ /* NOTICE */
if ([action isEqual: @"NOTICE"] && [components count] >= 4) { if ([action isEqual: @"NOTICE"] && components.count >= 4) {
OFString *from = [components objectAtIndex: 0]; OFString *from = [components objectAtIndex: 0];
OFString *to = [components objectAtIndex: 2]; OFString *to = [components objectAtIndex: 2];
IRCUser *user = nil; IRCUser *user = nil;
OFString *notice; OFString *notice;
size_t pos = [from length] + 1 + size_t pos = from.length + 1 +
[[components objectAtIndex: 1] length] + 1 + [to length]; [[components objectAtIndex: 1] length] + 1 + to.length;
from = [from substringWithRange: from = [from substringWithRange:
of_range(1, [from length] - 1)]; OFRangeMake(1, from.length - 1)];
notice = [line substringWithRange: notice = [line substringWithRange:
of_range(pos + 2, [line length] - pos - 2)]; OFRangeMake(pos + 2, line.length - pos - 2)];
if (![from containsString: @"!"] || [to isEqual: @"*"]) { if (![from containsString: @"!"] || [to isEqual: @"*"]) {
/* System message - ignore for now */ /* System message - ignore for now */
@ -575,6 +565,8 @@
{ {
[_pingData release]; [_pingData release];
[_pingTimer release]; [_pingTimer release];
_pingData = nil;
_pingTimer = nil;
_pingData = [[OFString alloc] initWithFormat: @":%d", rand()]; _pingData = [[OFString alloc] initWithFormat: @":%d", rand()];
[_socket writeFormat: @"PING %@\r\n", _pingData]; [_socket writeFormat: @"PING %@\r\n", _pingData];
@ -623,8 +615,7 @@
[_pingTimer invalidate]; [_pingTimer invalidate];
[_socket performSelector: @selector(cancelAsyncRequests) [_socket performSelector: @selector(cancelAsyncRequests) afterDelay: 0];
afterDelay: 0];
[_socket release]; [_socket release];
_socket = nil; _socket = nil;

View file

@ -50,10 +50,7 @@
@try { @try {
char *tmp; char *tmp;
if ((tmp2 = strdup([string UTF8String])) == NULL) tmp2 = OFStrDup(string.UTF8String);
@throw [OFOutOfMemoryException
exceptionWithRequestedSize:
[string UTF8StringLength]];
if ((tmp = strchr(tmp2, '@')) == NULL) if ((tmp = strchr(tmp2, '@')) == NULL)
@throw [OFInvalidFormatException exception]; @throw [OFInvalidFormatException exception];

View file

@ -37,25 +37,23 @@ OF_APPLICATION_DELEGATE(TestApp)
{ {
IRCConnection *connection = [[IRCConnection alloc] init]; IRCConnection *connection = [[IRCConnection alloc] init];
[connection setServer: @"irc.freenode.net"]; connection.server = @"irc.freenode.net";
[connection setNickname: @"ObjIRC"]; connection.nickname = @"ObjIRC";
[connection setUsername: @"ObjIRC"]; connection.username = @"ObjIRC";
[connection setRealname: @"ObjIRC"]; connection.realname = @"ObjIRC";
[connection setDelegate: self]; connection.delegate = self;
[connection connect]; [connection connect];
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection didReceiveLine: (OFString*)line
didReceiveLine: (OFString*)line
{ {
[of_stderr writeFormat: @"> %@\n", line]; [OFStdErr writeFormat: @"> %@\n", line];
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection didSendLine: (OFString*)line
didSendLine: (OFString*)line
{ {
[of_stderr writeFormat: @"< %@\n", line]; [OFStdErr writeFormat: @"< %@\n", line];
} }
- (void)connectionWasEstablished: (IRCConnection*)connection - (void)connectionWasEstablished: (IRCConnection*)connection
@ -66,7 +64,7 @@ OF_APPLICATION_DELEGATE(TestApp)
- (void)connection: (IRCConnection *)connection - (void)connection: (IRCConnection *)connection
didFailToConnectWithException: (id)exception didFailToConnectWithException: (id)exception
{ {
[of_stderr writeFormat: @"Failed to connect: %@\n", exception]; [OFStdErr writeFormat: @"Failed to connect: %@\n", exception];
[OFApplication terminateWithStatus: 1]; [OFApplication terminateWithStatus: 1];
} }
@ -75,7 +73,7 @@ OF_APPLICATION_DELEGATE(TestApp)
didSeeUser: (IRCUser*)user didSeeUser: (IRCUser*)user
joinChannel: (OFString*)channel joinChannel: (OFString*)channel
{ {
of_log(@"%@ joined %@.", user, channel); OFLog(@"%@ joined %@.", user, channel);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
@ -83,7 +81,7 @@ OF_APPLICATION_DELEGATE(TestApp)
leaveChannel: (OFString*)channel leaveChannel: (OFString*)channel
reason: (OFString*)reason reason: (OFString*)reason
{ {
of_log(@"%@ left %@ (%@).", user, channel, reason); OFLog(@"%@ left %@ (%@).", user, channel, reason);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
@ -92,21 +90,21 @@ OF_APPLICATION_DELEGATE(TestApp)
channel: (OFString*)channel channel: (OFString*)channel
reason: (OFString*)reason reason: (OFString*)reason
{ {
of_log(@"%@ kicked %@ from %@: %@", user, kickedUser, channel, reason); OFLog(@"%@ kicked %@ from %@: %@", user, kickedUser, channel, reason);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didSeeUserQuit: (IRCUser*)user didSeeUserQuit: (IRCUser*)user
reason: (OFString*)reason reason: (OFString*)reason
{ {
of_log(@"%@ quit (%@).", user, reason); OFLog(@"%@ quit (%@).", user, reason);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didSeeUser: (IRCUser*)user didSeeUser: (IRCUser*)user
changeNicknameTo: (OFString *)nickname changeNicknameTo: (OFString *)nickname
{ {
of_log(@"%@ changed nick to %@.", user, nickname); OFLog(@"%@ changed nick to %@.", user, nickname);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
@ -114,14 +112,14 @@ OF_APPLICATION_DELEGATE(TestApp)
channel: (OFString*)channel channel: (OFString*)channel
user: (IRCUser*)user user: (IRCUser*)user
{ {
of_log(@"[%@] %@: %@", channel, [user nickname], msg); OFLog(@"[%@] %@: %@", channel, [user nickname], msg);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didReceivePrivateMessage: (OFString*)msg didReceivePrivateMessage: (OFString*)msg
user: (IRCUser*)user user: (IRCUser*)user
{ {
of_log(@"(%@): %@", user, msg); OFLog(@"(%@): %@", user, msg);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
@ -129,26 +127,26 @@ OF_APPLICATION_DELEGATE(TestApp)
channel: (OFString*)channel channel: (OFString*)channel
user: (IRCUser*)user user: (IRCUser*)user
{ {
of_log(@"NOTICE: [%@] %@: %@", channel, [user nickname], notice); OFLog(@"NOTICE: [%@] %@: %@", channel, [user nickname], notice);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didReceiveNotice: (OFString*)notice didReceiveNotice: (OFString*)notice
user: (IRCUser*)user user: (IRCUser*)user
{ {
of_log(@"NOTICE: (%@): %@", user, notice); OFLog(@"NOTICE: (%@): %@", user, notice);
} }
- (void)connection: (IRCConnection*)connection - (void)connection: (IRCConnection*)connection
didReceiveNamesForChannel: (OFString*)channel didReceiveNamesForChannel: (OFString*)channel
{ {
of_log(@"Users in %@: %@", channel, OFLog(@"Users in %@: %@", channel,
[connection usersInChannel: channel]); [connection usersInChannel: channel]);
} }
- (void)connectionWasClosed: (IRCConnection*)connection - (void)connectionWasClosed: (IRCConnection*)connection
{ {
of_log(@"Disconnected!"); OFLog(@"Disconnected!");
[OFApplication terminate]; [OFApplication terminate];
} }