ObjIRC  Check-in [e7642f3cbb]

Overview
Comment:Add support for parsing NOTICE.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e7642f3cbb58d7c120ba2282081d99b062d15acfbb2aeadadaa3e77886aa4b60
User & Date: js on 2011-09-10 13:11:00
Other Links: manifest | tags
Context
2011-09-10
13:40
Add support for parsing KICK. check-in: 6f062f7189 user: js tags: trunk
13:11
Add support for parsing NOTICE. check-in: e7642f3cbb user: js tags: trunk
2011-09-09
21:24
Handle nickname changes. check-in: 7b1c2b91a4 user: js tags: trunk
Changes

Modified src/IRCConnection.h from [03be13c7ea] to [1a418d58d3].

52
53
54
55
56
57
58







59
60
61
62
63
64
65
-  (void)connection: (IRCConnection*)connection
  didReceiveMessage: (OFString*)msg
	   fromUser: (IRCUser*)user
	  inChannel: (IRCChannel*)channel;
-	  (void)connection: (IRCConnection*)connection
  didReceivePrivateMessage: (OFString*)msg
		  fromUser: (IRCUser*)user;







@end

@interface IRCConnection: OFObject
{
	OFTCPSocket *sock;
	OFString *server;
	uint16_t port;







>
>
>
>
>
>
>







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-  (void)connection: (IRCConnection*)connection
  didReceiveMessage: (OFString*)msg
	   fromUser: (IRCUser*)user
	  inChannel: (IRCChannel*)channel;
-	  (void)connection: (IRCConnection*)connection
  didReceivePrivateMessage: (OFString*)msg
		  fromUser: (IRCUser*)user;
- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	  fromUser: (IRCUser*)user;
- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	  fromUser: (IRCUser*)user
	 inChannel: (IRCChannel*)channel;
@end

@interface IRCConnection: OFObject
{
	OFTCPSocket *sock;
	OFString *server;
	uint16_t port;

Modified src/IRCConnection.m from [1929310778] to [20dac0f662].

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 +







|







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 +
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
			    [[split objectAtIndex: 1] length] + 1 +
			    to.length;

			from = [from substringWithRange:
			    of_range(1, from.length - 1)];
			msg = [line substringWithRange:
			    of_range(pos + 2, line.length - pos - 2)];

			user = [IRCUser IRCUserWithString: from];

			if (![to isEqual: nickname]) {
				IRCChannel *channel;

				channel = [channels objectForKey: to];








<







302
303
304
305
306
307
308

309
310
311
312
313
314
315
			    [[split objectAtIndex: 1] length] + 1 +
			    to.length;

			from = [from substringWithRange:
			    of_range(1, from.length - 1)];
			msg = [line substringWithRange:
			    of_range(pos + 2, line.length - pos - 2)];

			user = [IRCUser IRCUserWithString: from];

			if (![to isEqual: nickname]) {
				IRCChannel *channel;

				channel = [channels objectForKey: to];

326
327
328
329
330
331
332













































333
334
335
336
337
338
339
				     @selector(connection:
				     didReceivePrivateMessage:fromUser:)])
					[delegate
					    connection: self
					    didReceivePrivateMessage: msg
					    fromUser: user];
			}














































			continue;
		}

		[pool releaseObjects];
	}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
				     @selector(connection:
				     didReceivePrivateMessage:fromUser:)])
					[delegate
					    connection: self
					    didReceivePrivateMessage: msg
					    fromUser: user];
			}

			continue;
		}

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

			from = [from substringWithRange:
			    of_range(1, from.length - 1)];
			notice = [line substringWithRange:
			    of_range(pos + 2, line.length - pos - 2)];

			if (![from containsString: @"!"] || [to isEqual: @"*"])
				/* System message - ignore for now */
				continue;

			user = [IRCUser IRCUserWithString: from];

			if (![to isEqual: nickname]) {
				IRCChannel *channel;

				channel = [channels objectForKey: to];

				if ([delegate respondsToSelector:
				    @selector(connection:didReceiveNotice:
				    fromUser:inChannel:)])
					[delegate connection: self
					    didReceiveNotice: notice
						    fromUser: user
						   inChannel: channel];
			} else {
				if ([delegate respondsToSelector:
				    @selector(connection:didReceiveNotice:
				    fromUser:)])
					[delegate connection: self
					    didReceiveNotice: notice
						    fromUser: user];
			}

			continue;
		}

		[pool releaseObjects];
	}

Modified tests/test.m from [758bd3a438] to [d2000015d6].

104
105
106
107
108
109
110















111

-	  (void)connection: (IRCConnection*)connection
  didReceivePrivateMessage: (OFString*)msg
		  fromUser: (IRCUser*)user
{
	of_log(@"(%@): %@", user, msg);
}















@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

-	  (void)connection: (IRCConnection*)connection
  didReceivePrivateMessage: (OFString*)msg
		  fromUser: (IRCUser*)user
{
	of_log(@"(%@): %@", user, msg);
}

- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	  fromUser: (IRCUser*)user
{
	of_log(@"NOTICE: (%@): %@", user, notice);
}

- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	  fromUser: (IRCUser*)user
	 inChannel: (IRCChannel*)channel
{
	of_log(@"NOTICE: [%@] %@: %@", channel, user, notice);
}
@end