106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
}
- (void)disconnect
{
[self disconnectWithReason: nil];
}
- (void)disconnectWithReason: (OFString*)reason
{
void *pool = objc_autoreleasePoolPush();
reason = [[reason componentsSeparatedByString: @"\n"] firstObject];
if (reason == nil)
[self sendLine: @"QUIT"];
else
[self sendLineWithFormat: @"QUIT :%@", reason];
objc_autoreleasePoolPop(pool);
}
- (void)joinChannel: (OFString*)channel
{
void *pool = objc_autoreleasePoolPush();
channel = [[channel componentsSeparatedByString: @"\n"] firstObject];
[self sendLineWithFormat: @"JOIN %@", channel];
objc_autoreleasePoolPop(pool);
}
- (void)leaveChannel: (OFString*)channel
{
[self leaveChannel: channel
reason: nil];
}
- (void)leaveChannel: (OFString*)channel
reason: (OFString*)reason
{
void *pool = objc_autoreleasePoolPush();
channel = [[channel componentsSeparatedByString: @"\n"] firstObject];
reason = [[reason componentsSeparatedByString: @"\n"] firstObject];
if (reason == nil)
[self sendLineWithFormat: @"PART %@", channel];
else
[self sendLineWithFormat: @"PART %@ :%@", channel, reason];
[_channels removeObjectForKey: channel];
objc_autoreleasePoolPop(pool);
}
- (void)sendLine: (OFString*)line
{
if ([_delegate respondsToSelector: @selector(connection:didSendLine:)])
[_delegate connection: self
didSendLine: line];
[_socket writeLine: line];
}
- (void)sendLineWithFormat: (OFConstantString*)format, ...
{
void *pool = objc_autoreleasePoolPush();
OFString *line;
va_list args;
va_start(args, format);
line = [[[OFString alloc] initWithFormat: format
arguments: args] autorelease];
va_end(args);
[self sendLine: line];
objc_autoreleasePoolPop(pool);
}
- (void)sendMessage: (OFString*)msg
to: (OFString*)to
{
void *pool = objc_autoreleasePoolPush();
for (OFString *line in [msg componentsSeparatedByString: @"\n"])
[self sendLineWithFormat: @"PRIVMSG %@ :%@", to, line];
objc_autoreleasePoolPop(pool);
}
- (void)sendNotice: (OFString*)notice
to: (OFString*)to
{
void *pool = objc_autoreleasePoolPush();
for (OFString *line in [notice componentsSeparatedByString: @"\n"])
[self sendLineWithFormat: @"NOTICE %@ :%@", to, line];
objc_autoreleasePoolPop(pool);
}
- (void)kickUser: (OFString*)user
channel: (OFString*)channel
reason: (OFString*)reason
{
void *pool = objc_autoreleasePoolPush();
reason = [[reason componentsSeparatedByString: @"\n"] firstObject];
[self sendLineWithFormat: @"KICK %@ %@ :%@", channel, user, reason];
objc_autoreleasePoolPop(pool);
}
- (void)changeNicknameTo: (OFString*)nickname
{
void *pool = objc_autoreleasePoolPush();
nickname = [[nickname componentsSeparatedByString: @"\n"]
firstObject];
[self sendLineWithFormat: @"NICK %@", nickname];
objc_autoreleasePoolPop(pool);
}
- (void)IRC_processLine: (OFString*)line
{
OFArray *components;
OFString *action = nil;
if ([_delegate respondsToSelector:
@selector(connection:didReceiveLine:)])
[_delegate connection: self
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
}
- (void)disconnect
{
[self disconnectWithReason: nil];
}
- (void)disconnectWithReason: (OFString *)reason
{
void *pool = objc_autoreleasePoolPush();
reason = [[reason componentsSeparatedByString: @"\n"] firstObject];
if (reason == nil)
[self sendLine: @"QUIT"];
else
[self sendLineWithFormat: @"QUIT :%@", reason];
objc_autoreleasePoolPop(pool);
}
- (void)joinChannel: (OFString *)channel
{
void *pool = objc_autoreleasePoolPush();
channel = [[channel componentsSeparatedByString: @"\n"] firstObject];
[self sendLineWithFormat: @"JOIN %@", channel];
objc_autoreleasePoolPop(pool);
}
- (void)leaveChannel: (OFString *)channel
{
[self leaveChannel: channel
reason: nil];
}
- (void)leaveChannel: (OFString *)channel
reason: (OFString *)reason
{
void *pool = objc_autoreleasePoolPush();
channel = [[channel componentsSeparatedByString: @"\n"] firstObject];
reason = [[reason componentsSeparatedByString: @"\n"] firstObject];
if (reason == nil)
[self sendLineWithFormat: @"PART %@", channel];
else
[self sendLineWithFormat: @"PART %@ :%@", channel, reason];
[_channels removeObjectForKey: channel];
objc_autoreleasePoolPop(pool);
}
- (void)sendLine: (OFString *)line
{
if ([_delegate respondsToSelector: @selector(connection:didSendLine:)])
[_delegate connection: self
didSendLine: line];
[_socket writeLine: line];
}
- (void)sendLineWithFormat: (OFConstantString *)format, ...
{
void *pool = objc_autoreleasePoolPush();
OFString *line;
va_list args;
va_start(args, format);
line = [[[OFString alloc] initWithFormat: format
arguments: args] autorelease];
va_end(args);
[self sendLine: line];
objc_autoreleasePoolPop(pool);
}
- (void)sendMessage: (OFString *)msg
to: (OFString *)to
{
void *pool = objc_autoreleasePoolPush();
for (OFString *line in [msg componentsSeparatedByString: @"\n"])
[self sendLineWithFormat: @"PRIVMSG %@ :%@", to, line];
objc_autoreleasePoolPop(pool);
}
- (void)sendNotice: (OFString *)notice
to: (OFString *)to
{
void *pool = objc_autoreleasePoolPush();
for (OFString *line in [notice componentsSeparatedByString: @"\n"])
[self sendLineWithFormat: @"NOTICE %@ :%@", to, line];
objc_autoreleasePoolPop(pool);
}
- (void)kickUser: (OFString *)user
channel: (OFString *)channel
reason: (OFString *)reason
{
void *pool = objc_autoreleasePoolPush();
reason = [[reason componentsSeparatedByString: @"\n"] firstObject];
[self sendLineWithFormat: @"KICK %@ %@ :%@", channel, user, reason];
objc_autoreleasePoolPop(pool);
}
- (void)changeNicknameTo: (OFString *)nickname
{
void *pool = objc_autoreleasePoolPush();
nickname = [[nickname componentsSeparatedByString: @"\n"]
firstObject];
[self sendLineWithFormat: @"NICK %@", nickname];
objc_autoreleasePoolPop(pool);
}
- (void)IRC_processLine: (OFString *)line
{
OFArray *components;
OFString *action = nil;
if ([_delegate respondsToSelector:
@selector(connection:didReceiveLine:)])
[_delegate connection: self
|
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
|
[_delegate connectionWasClosed: self];
[_socket cancelAsyncRequests];
[_socket release];
_socket = nil;
}
- (void)processLine: (OFString*)line
{
void *pool = objc_autoreleasePoolPush();
[self IRC_processLine: line];
objc_autoreleasePoolPop(pool);
}
- (bool)socket: (OFTCPSocket*)socket
didReceiveWronglyEncodedLine: (OFString*)line
exception: (OFException*)exception
{
if (line != nil) {
[self IRC_processLine: line];
[socket asyncReadLineWithTarget: self
selector: @selector(socket:
didReceiveLine:
exception:)];
}
return false;
}
- (bool)socket: (OFTCPSocket*)socket
didReceiveLine: (OFString*)line
exception: (OFException*)exception
{
if (line != nil) {
[self IRC_processLine: line];
return true;
}
if ([exception isKindOfClass: [OFInvalidEncodingException class]]) {
|
|
|
|
|
|
|
|
|
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
|
[_delegate connectionWasClosed: self];
[_socket cancelAsyncRequests];
[_socket release];
_socket = nil;
}
- (void)processLine: (OFString *)line
{
void *pool = objc_autoreleasePoolPush();
[self IRC_processLine: line];
objc_autoreleasePoolPop(pool);
}
- (bool)socket: (OFTCPSocket *)socket
didReceiveWronglyEncodedLine: (OFString *)line
exception: (OFException *)exception
{
if (line != nil) {
[self IRC_processLine: line];
[socket asyncReadLineWithTarget: self
selector: @selector(socket:
didReceiveLine:
exception:)];
}
return false;
}
- (bool)socket: (OFTCPSocket *)socket
didReceiveLine: (OFString *)line
exception: (OFException *)exception
{
if (line != nil) {
[self IRC_processLine: line];
return true;
}
if ([exception isKindOfClass: [OFInvalidEncodingException class]]) {
|
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
}
if ([_delegate respondsToSelector: @selector(connectionWasClosed:)])
[_delegate connectionWasClosed: self];
[_pingTimer invalidate];
[_socket cancelAsyncRequests];
[_socket release];
_socket = nil;
return false;
}
- (void)handleConnection
{
[_socket asyncReadLineWithTarget: self
selector: @selector(socket:didReceiveLine:
exception:)];
}
- (OFSet*)usersInChannel: (OFString*)channel
{
return [[[_channels objectForKey: channel] copy] autorelease];
}
@end
|
|
>
|
|
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
|
}
if ([_delegate respondsToSelector: @selector(connectionWasClosed:)])
[_delegate connectionWasClosed: self];
[_pingTimer invalidate];
[_socket performSelector: @selector(cancelAsyncRequests)
afterDelay: 0];
[_socket release];
_socket = nil;
return false;
}
- (void)handleConnection
{
[_socket asyncReadLineWithTarget: self
selector: @selector(socket:didReceiveLine:
exception:)];
}
- (OFSet OF_GENERIC(OFString *) *)usersInChannel: (OFString *)channel
{
return [[[_channels objectForKey: channel] copy] autorelease];
}
@end
|