IRCConnection: Make fallback encoding configurable
FossilOrigin-Name: 0ca6e4f04d891d2bcc17cacb15ad6e17090624bf65efed09999a26e9c9998192
This commit is contained in:
parent
21784a8d30
commit
0dd8cdc46a
2 changed files with 14 additions and 9 deletions
|
@ -81,14 +81,16 @@
|
|||
OFString *_nickname, *_username, *_realname;
|
||||
OFMutableDictionary *_channels;
|
||||
id <IRCConnectionDelegate> _delegate;
|
||||
of_string_encoding_t _fallbackEncoding;
|
||||
}
|
||||
|
||||
@property (assign) Class socketClass;
|
||||
@property (copy) OFString *server;
|
||||
@property (assign) uint16_t port;
|
||||
@property uint16_t port;
|
||||
@property (copy) OFString *nickname, *username, *realname;
|
||||
@property (assign) id <IRCConnectionDelegate> delegate;
|
||||
@property (readonly, retain) OFTCPSocket *socket;
|
||||
@property of_string_encoding_t fallbackEncoding;
|
||||
|
||||
+ (instancetype)connection;
|
||||
- (void)sendLine: (OFString*)line;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
@synthesize server = _server, port = _port;
|
||||
@synthesize nickname = _nickname, username = _username, realname = _realname;
|
||||
@synthesize delegate = _delegate, socket = _socket;
|
||||
@synthesize fallbackEncoding = _fallbackEncoding;
|
||||
|
||||
+ (instancetype)connection
|
||||
{
|
||||
|
@ -56,6 +57,7 @@
|
|||
_socketClass = [OFTCPSocket class];
|
||||
_channels = [[OFMutableDictionary alloc] init];
|
||||
_port = 6667;
|
||||
_fallbackEncoding = OF_STRING_ENCODING_ISO_8859_1;
|
||||
} @catch (id e) {
|
||||
[self release];
|
||||
@throw e;
|
||||
|
@ -535,7 +537,7 @@
|
|||
}
|
||||
|
||||
- (bool)socket: (OFTCPSocket*)socket
|
||||
didReceiveISO88591Line: (OFString*)line
|
||||
didReceiveWronglyEncodedLine: (OFString*)line
|
||||
exception: (OFException*)exception
|
||||
{
|
||||
if (line != nil) {
|
||||
|
@ -559,10 +561,11 @@
|
|||
}
|
||||
|
||||
if ([exception isKindOfClass: [OFInvalidEncodingException class]]) {
|
||||
[socket asyncReadLineWithEncoding: OF_STRING_ENCODING_ISO_8859_1
|
||||
[socket
|
||||
asyncReadLineWithEncoding: _fallbackEncoding
|
||||
target: self
|
||||
selector: @selector(socket:
|
||||
didReceiveISO88591Line:
|
||||
didReceiveWronglyEncodedLine:
|
||||
exception:)];
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue