Adjust to ObjFW changes
FossilOrigin-Name: 7a7f60e3e63b1d8bd67b43effb98703320fa689801e4fd575aae26f5354882c9
This commit is contained in:
parent
8e0b20e7b4
commit
6411934685
4 changed files with 49 additions and 34 deletions
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class IRCConnection;
|
@class IRCConnection;
|
||||||
@class IRCUser;
|
@class IRCUser;
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@
|
||||||
- (void)connection: (IRCConnection *)connection
|
- (void)connection: (IRCConnection *)connection
|
||||||
didSeeUser: (IRCUser *)user
|
didSeeUser: (IRCUser *)user
|
||||||
leaveChannel: (OFString *)channel
|
leaveChannel: (OFString *)channel
|
||||||
reason: (OFString *)reason;
|
reason: (nullable OFString *)reason;
|
||||||
- (void)connection: (IRCConnection *)connection
|
- (void)connection: (IRCConnection *)connection
|
||||||
didSeeUser: (IRCUser *)user
|
didSeeUser: (IRCUser *)user
|
||||||
changeNicknameTo: (OFString *)nickname;
|
changeNicknameTo: (OFString *)nickname;
|
||||||
|
@ -49,10 +51,10 @@
|
||||||
didSeeUser: (IRCUser *)user
|
didSeeUser: (IRCUser *)user
|
||||||
kickUser: (OFString *)kickedUser
|
kickUser: (OFString *)kickedUser
|
||||||
channel: (OFString *)channel
|
channel: (OFString *)channel
|
||||||
reason: (OFString *)reason;
|
reason: (nullable OFString *)reason;
|
||||||
- (void)connection: (IRCConnection *)connection
|
- (void)connection: (IRCConnection *)connection
|
||||||
didSeeUserQuit: (IRCUser *)user
|
didSeeUserQuit: (IRCUser *)user
|
||||||
reason: (OFString *)reason;
|
reason: (nullable OFString *)reason;
|
||||||
- (void)connection: (IRCConnection *)connection
|
- (void)connection: (IRCConnection *)connection
|
||||||
didReceiveMessage: (OFString *)msg
|
didReceiveMessage: (OFString *)msg
|
||||||
channel: (OFString *)channel
|
channel: (OFString *)channel
|
||||||
|
@ -75,46 +77,52 @@
|
||||||
@interface IRCConnection: OFObject
|
@interface IRCConnection: OFObject
|
||||||
{
|
{
|
||||||
Class _socketClass;
|
Class _socketClass;
|
||||||
OF_KINDOF(OFTCPSocket) *_socket;
|
OF_KINDOF(OFTCPSocket) *_Nullable _socket;
|
||||||
OFString *_server;
|
OFString *_Nullable _server;
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
OFString *_nickname, *_username, *_realname;
|
OFString *_Nullable _nickname, *_Nullable _username;
|
||||||
|
OFString *_Nullable _realname;
|
||||||
OFMutableDictionary OF_GENERIC(OFString *, OFMutableSet *) *_channels;
|
OFMutableDictionary OF_GENERIC(OFString *, OFMutableSet *) *_channels;
|
||||||
id <IRCConnectionDelegate> _delegate;
|
id <IRCConnectionDelegate> _Nullable _delegate;
|
||||||
of_string_encoding_t _fallbackEncoding;
|
of_string_encoding_t _fallbackEncoding;
|
||||||
of_time_interval_t _pingInterval, _pingTimeout;
|
of_time_interval_t _pingInterval, _pingTimeout;
|
||||||
OFString *_pingData;
|
OFString *_Nullable _pingData;
|
||||||
OFTimer *_pingTimer;
|
OFTimer *_Nullable _pingTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (assign) Class socketClass;
|
@property (readonly, nonatomic) Class socketClass;
|
||||||
@property (nonatomic, copy) OFString *server;
|
@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *server;
|
||||||
@property uint16_t port;
|
@property (nonatomic) uint16_t port;
|
||||||
@property (nonatomic, copy) OFString *nickname, *username, *realname;
|
@property OF_NULLABLE_PROPERTY (copy, nonatomic)
|
||||||
@property (assign) id <IRCConnectionDelegate> delegate;
|
OFString *nickname, *username, *realname;
|
||||||
@property (readonly, nonatomic) OFTCPSocket *socket;
|
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
|
||||||
@property of_string_encoding_t fallbackEncoding;
|
id <IRCConnectionDelegate> delegate;
|
||||||
@property of_time_interval_t pingInterval, pingTimeout;
|
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
|
||||||
|
OF_KINDOF(OFTCPSocket *) socket;
|
||||||
|
@property (nonatomic) of_string_encoding_t fallbackEncoding;
|
||||||
|
@property (nonatomic) of_time_interval_t pingInterval, pingTimeout;
|
||||||
|
|
||||||
+ (instancetype)connection;
|
+ (instancetype)connection;
|
||||||
- (void)sendLine: (OFString *)line;
|
- (void)sendLine: (OFString *)line;
|
||||||
- (void)sendLineWithFormat: (OFConstantString *)line, ...;
|
- (void)sendLineWithFormat: (OFConstantString *)line, ...;
|
||||||
- (void)connect;
|
- (void)connect;
|
||||||
- (void)disconnect;
|
- (void)disconnect;
|
||||||
- (void)disconnectWithReason: (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: (OFString *)reason;
|
reason: (nullable OFString *)reason;
|
||||||
- (void)sendMessage: (OFString *)msg
|
- (void)sendMessage: (OFString *)message
|
||||||
to: (OFString *)to;
|
to: (OFString *)to;
|
||||||
- (void)sendNotice: (OFString *)notice
|
- (void)sendNotice: (OFString *)notice
|
||||||
to: (OFString *)to;
|
to: (OFString *)to;
|
||||||
- (void)kickUser: (OFString *)user
|
- (void)kickUser: (OFString *)user
|
||||||
channel: (OFString *)channel
|
channel: (OFString *)channel
|
||||||
reason: (OFString *)reason;
|
reason: (nullable OFString *)reason;
|
||||||
- (void)changeNicknameTo: (OFString *)nickname;
|
- (void)changeNicknameTo: (OFString *)nickname;
|
||||||
- (void)processLine: (OFString *)line;
|
- (void)processLine: (OFString *)line;
|
||||||
- (void)handleConnection;
|
- (void)handleConnection;
|
||||||
- (OFSet OF_GENERIC(OFString *) *)usersInChannel: (OFString *)channel;
|
- (nullable OFSet OF_GENERIC(OFString *) *)usersInChannel: (OFString *)channel;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -184,12 +184,12 @@
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sendMessage: (OFString *)msg
|
- (void)sendMessage: (OFString *)message
|
||||||
to: (OFString *)to
|
to: (OFString *)to
|
||||||
{
|
{
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
|
|
||||||
for (OFString *line in [msg componentsSeparatedByString: @"\n"])
|
for (OFString *line in [message componentsSeparatedByString: @"\n"])
|
||||||
[self sendLineWithFormat: @"PRIVMSG %@ :%@", to, line];
|
[self sendLineWithFormat: @"PRIVMSG %@ :%@", to, line];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
@ -482,13 +482,13 @@
|
||||||
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 *msg;
|
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)];
|
of_range(1, [from length] - 1)];
|
||||||
msg = [line substringWithRange:
|
message = [line substringWithRange:
|
||||||
of_range(pos + 2, [line length] - pos - 2)];
|
of_range(pos + 2, [line length] - pos - 2)];
|
||||||
user = [IRCUser IRCUserWithString: from];
|
user = [IRCUser IRCUserWithString: from];
|
||||||
|
|
||||||
|
@ -496,14 +496,14 @@
|
||||||
if ([_delegate respondsToSelector: @selector(connection:
|
if ([_delegate respondsToSelector: @selector(connection:
|
||||||
didReceiveMessage:channel:user:)])
|
didReceiveMessage:channel:user:)])
|
||||||
[_delegate connection: self
|
[_delegate connection: self
|
||||||
didReceiveMessage: msg
|
didReceiveMessage: message
|
||||||
channel: to
|
channel: to
|
||||||
user: user];
|
user: user];
|
||||||
} else {
|
} else {
|
||||||
if ([_delegate respondsToSelector: @selector(connection:
|
if ([_delegate respondsToSelector: @selector(connection:
|
||||||
didReceivePrivateMessage:user:)])
|
didReceivePrivateMessage:user:)])
|
||||||
[_delegate connection: self
|
[_delegate connection: self
|
||||||
didReceivePrivateMessage: msg
|
didReceivePrivateMessage: message
|
||||||
user: user];
|
user: user];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,7 +593,8 @@
|
||||||
[socket asyncReadLineWithTarget: self
|
[socket asyncReadLineWithTarget: self
|
||||||
selector: @selector(socket:
|
selector: @selector(socket:
|
||||||
didReceiveLine:
|
didReceiveLine:
|
||||||
exception:)];
|
exception:)
|
||||||
|
context: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -614,7 +615,8 @@
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(socket:
|
selector: @selector(socket:
|
||||||
didReceiveWronglyEncodedLine:
|
didReceiveWronglyEncodedLine:
|
||||||
exception:)];
|
exception:)
|
||||||
|
context: nil];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +637,8 @@
|
||||||
{
|
{
|
||||||
[_socket asyncReadLineWithTarget: self
|
[_socket asyncReadLineWithTarget: self
|
||||||
selector: @selector(socket:didReceiveLine:
|
selector: @selector(socket:didReceiveLine:
|
||||||
exception:)];
|
exception:)
|
||||||
|
context: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFSet OF_GENERIC(OFString *) *)usersInChannel: (OFString *)channel
|
- (OFSet OF_GENERIC(OFString *) *)usersInChannel: (OFString *)channel
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#import <ObjFW/OFObject.h>
|
#import <ObjFW/OFObject.h>
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface IRCUser: OFObject <OFCopying>
|
@interface IRCUser: OFObject <OFCopying>
|
||||||
{
|
{
|
||||||
OFString *_nickname, *_username, *_hostname;
|
OFString *_nickname, *_username, *_hostname;
|
||||||
|
@ -31,5 +33,7 @@
|
||||||
@property (readonly, nonatomic) OFString *nickname, *username, *hostname;
|
@property (readonly, nonatomic) OFString *nickname, *username, *hostname;
|
||||||
|
|
||||||
+ (instancetype)IRCUserWithString: (OFString *)string;
|
+ (instancetype)IRCUserWithString: (OFString *)string;
|
||||||
- initWithString: (OFString *)string;
|
- (instancetype)initWithString: (OFString *)string OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
return [[[self alloc] initWithString: string] autorelease];
|
return [[[self alloc] initWithString: string] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithString: (OFString *)string
|
- (instancetype)initWithString: (OFString *)string
|
||||||
{
|
{
|
||||||
char *tmp2 = NULL;
|
char *tmp2 = NULL;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- copy
|
- (id)copy
|
||||||
{
|
{
|
||||||
return [self retain];
|
return [self retain];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue