ObjIRC  Diff

Differences From Artifact [5c9189780c]:

To Artifact [d49c16f293]:


141
142
143
144
145
146
147


148
149
150
151
152
153
154
- (void)handleConnection
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFString *line;
	OFArray *split;

	for (;;) {


		@try {
			line = [sock readLine];
		} @catch (OFInvalidEncodingException *e) {
			[e dealloc];
			line = [sock readLineWithEncoding:
			    OF_STRING_ENCODING_WINDOWS_1252];
		}







>
>







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
- (void)handleConnection
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFString *line;
	OFArray *split;

	for (;;) {
		OFString *action = nil;

		@try {
			line = [sock readLine];
		} @catch (OFInvalidEncodingException *e) {
			[e dealloc];
			line = [sock readLineWithEncoding:
			    OF_STRING_ENCODING_WINDOWS_1252];
		}
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
			[s replaceOccurrencesOfString: @"PING"
					   withString: @"PONG"];
			[self sendLine: s];

			continue;
		}



		/* Connected */
		if (split.count >= 4 &&
		    [[split objectAtIndex: 1] isEqual: @"001"]) {
			if ([delegate respondsToSelector:
			    @selector(connectionWasEstablished:)])
				[delegate connectionWasEstablished: self];

			continue;
		}

		/* JOIN */
		if (split.count == 3 &&
		    [[split objectAtIndex: 1] isEqual: @"JOIN"]) {
			OFString *who = [split objectAtIndex: 0];
			OFString *where = [split objectAtIndex: 2];
			IRCUser *user;
			IRCChannel *channel;

			who = [who substringWithRange:
			    of_range(1, who.length - 1)];







>
>

|
<








|
<







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
			[s replaceOccurrencesOfString: @"PING"
					   withString: @"PONG"];
			[self sendLine: s];

			continue;
		}

		action = [[split objectAtIndex: 1] uppercaseString];

		/* Connected */
		if ([action isEqual: @"001"] && split.count >= 4) {

			if ([delegate respondsToSelector:
			    @selector(connectionWasEstablished:)])
				[delegate connectionWasEstablished: self];

			continue;
		}

		/* JOIN */
		if ([action isEqual: @"JOIN"] && split.count == 3) {

			OFString *who = [split objectAtIndex: 0];
			OFString *where = [split objectAtIndex: 2];
			IRCUser *user;
			IRCChannel *channel;

			who = [who substringWithRange:
			    of_range(1, who.length - 1)];
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
					  didSeeUser: user
					 joinChannel: channel];

			continue;
		}

		/* PART */
		if (split.count >= 3 &&
		    [[split objectAtIndex: 1] isEqual: @"PART"]) {
			OFString *who = [split objectAtIndex: 0];
			OFString *where = [split objectAtIndex: 2];
			IRCUser *user;
			IRCChannel *channel;
			OFString *reason = nil;
			size_t pos = who.length + 1 +
			    [[split objectAtIndex: 1] length] + 1 +







|
<







213
214
215
216
217
218
219
220

221
222
223
224
225
226
227
					  didSeeUser: user
					 joinChannel: channel];

			continue;
		}

		/* PART */
		if ([action isEqual: @"part"] && split.count >= 3) {

			OFString *who = [split objectAtIndex: 0];
			OFString *where = [split objectAtIndex: 2];
			IRCUser *user;
			IRCChannel *channel;
			OFString *reason = nil;
			size_t pos = who.length + 1 +
			    [[split objectAtIndex: 1] length] + 1 +
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
					leaveChannel: channel
					  withReason: reason];

			continue;
		}

		/* QUIT */
		if (split.count >= 2 &&
		    [[split objectAtIndex: 1] isEqual: @"QUIT"]) {
			OFString *who = [split objectAtIndex: 0];
			IRCUser *user;
			OFString *reason = nil;
			size_t pos = who.length + 1 +
			    [[split objectAtIndex: 1] length];

			who = [who substringWithRange:







|
<







244
245
246
247
248
249
250
251

252
253
254
255
256
257
258
					leaveChannel: channel
					  withReason: reason];

			continue;
		}

		/* QUIT */
		if ([action isEqual: @"QUIT"] && split.count >= 2) {

			OFString *who = [split objectAtIndex: 0];
			IRCUser *user;
			OFString *reason = nil;
			size_t pos = who.length + 1 +
			    [[split objectAtIndex: 1] length];

			who = [who substringWithRange:
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
				      didSeeUserQuit: user
					  withReason: reason];

			continue;
		}

		/* PRIVMSG */
		if (split.count >= 4 &&
		    [[split objectAtIndex: 1] isEqual: @"PRIVMSG"]) {
			OFString *from = [split objectAtIndex: 0];
			OFString *to = [split objectAtIndex: 2];
			IRCUser *user;
			OFString *msg;
			size_t pos = from.length + 1 +
			    [[split objectAtIndex: 1] length] + 1 +
			    to.length;







|
<







269
270
271
272
273
274
275
276

277
278
279
280
281
282
283
				      didSeeUserQuit: user
					  withReason: reason];

			continue;
		}

		/* PRIVMSG */
		if ([action isEqual: @"PRIVMSG"] && split.count >= 4) {

			OFString *from = [split objectAtIndex: 0];
			OFString *to = [split objectAtIndex: 2];
			IRCUser *user;
			OFString *msg;
			size_t pos = from.length + 1 +
			    [[split objectAtIndex: 1] length] + 1 +
			    to.length;