ObjIRC  Check-in [38de3de8ed]

Overview
Comment:IRCConnection: Make the socket class configurable

This makes using TLS possible.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 38de3de8ed2056e1116492cc44443d814ff115d85b81ba5c9014d0bf925a0f83
User & Date: js on 2017-01-22 17:24:18
Other Links: manifest | tags
Context
2017-01-22
20:49
IRCConnection: Make fallback encoding configurable check-in: 0ca6e4f04d user: js tags: trunk
17:24
IRCConnection: Make the socket class configurable check-in: 38de3de8ed user: js tags: trunk
15:20
Do not run tests automatically check-in: 9a8a6a9bf9 user: js tags: trunk
Changes

Modified src/IRCConnection.h from [a68be5271e] to [de62d2cefb].

25
26
27
28
29
30
31


32
33
34
35
36
37
38
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+
+








@class IRCConnection;
@class IRCUser;

@protocol IRCConnectionDelegate <OFObject>
@optional
- (void)connection: (IRCConnection*)connection
   didCreateSocket: (OF_KINDOF(OFTCPSocket)*)socket;
- (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;
68
69
70
71
72
73
74

75

76
77
78
79
80
81
82

83
84
85
86
87
88
89
70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93







+
-
+







+







-	   (void)connection: (IRCConnection*)connection
  didReceiveNamesForChannel: (OFString*)channel;
- (void)connectionWasClosed: (IRCConnection*)connection;
@end

@interface IRCConnection: OFObject
{
	Class _socketClass;
	OFTCPSocket *_socket;
	OF_KINDOF(OFTCPSocket) *_socket;
	OFString *_server;
	uint16_t _port;
	OFString *_nickname, *_username, *_realname;
	OFMutableDictionary *_channels;
	id <IRCConnectionDelegate> _delegate;
}

@property (assign) Class socketClass;
@property (copy) OFString *server;
@property (assign) uint16_t port;
@property (copy) OFString *nickname, *username, *realname;
@property (assign) id <IRCConnectionDelegate> delegate;
@property (readonly, retain) OFTCPSocket *socket;

+ (instancetype)connection;

Modified src/IRCConnection.m from [12ead9fa2b] to [6579a2f540].

34
35
36
37
38
39
40

41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63







+














+








#import <ObjFW/macros.h>

#import "IRCConnection.h"
#import "IRCUser.h"

@implementation IRCConnection
@synthesize socketClass = _socketClass;
@synthesize server = _server, port = _port;
@synthesize nickname = _nickname, username = _username, realname = _realname;
@synthesize delegate = _delegate, socket = _socket;

+ (instancetype)connection
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	@try {
		_socketClass = [OFTCPSocket class];
		_channels = [[OFMutableDictionary alloc] init];
		_port = 6667;
	} @catch (id e) {
		[self release];
		@throw e;
	}

77
78
79
80
81
82
83





84

85
86
87
88
89
90
91
79
80
81
82
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98







+
+
+
+
+
-
+







- (void)connect
{
	void *pool = objc_autoreleasePoolPush();

	if (_socket != nil)
		@throw [OFAlreadyConnectedException exception];

	_socket = [[_socketClass alloc] init];
	if ([_delegate respondsToSelector:
	    @selector(connection:didCreateSocket:)])
		[_delegate connection: self
		      didCreateSocket: _socket];
	_socket = [[OFTCPSocket alloc] init];

	[_socket connectToHost: _server
			  port: _port];

	[self sendLineWithFormat: @"NICK %@", _nickname];
	[self sendLineWithFormat: @"USER %@ * 0 :%@", _username, _realname];

	objc_autoreleasePoolPop(pool);