ObjIRC  Check-in [92093d341f]

Overview
Comment:Add support for handling PART and fix parsing of JOIN.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 92093d341f66e0a9f0227e44f122b8caca3ced8aff1f50d88b4bb7d4a4a4ba81
User & Date: js on 2011-09-09 16:23:51
Other Links: manifest | tags
Context
2011-09-09
16:29
Update tests. check-in: 7dcca7532e user: js tags: trunk
16:23
Add support for handling PART and fix parsing of JOIN. check-in: 92093d341f user: js tags: trunk
16:18
Add -[description] to IRCChannel. check-in: 0d1dcda269 user: js tags: trunk
Changes

Modified src/IRCConnection.h from [7791c3eea9] to [26bbbf5e84].

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




42
43
44
45
46
47
48
49
50
51
52
53
@class OFTCPSocket;
@class IRCConnection;
@class IRCUser;
@class IRCChannel;

@protocol IRCConnectionDelegate
@optional
- (void)connection: (IRCConnection*)conn
    didReceiveLine: (OFString*)line;
- (void)connection: (IRCConnection*)conn
       didSendLine: (OFString*)line;
- (void)connectionWasEstablished: (IRCConnection*)conn;
- (void)connection: (IRCConnection*)conn
	didSeeUser: (IRCUser*)user
       joinChannel: (IRCChannel*)channel;




-  (void)connection: (IRCConnection*)conn
  didReceiveMessage: (OFString*)msg
	   fromUser: (IRCUser*)user
	  inChannel: (IRCChannel*)channel;
-	  (void)connection: (IRCConnection*)conn
  didReceivePrivateMessage: (OFString*)msg
		  fromUser: (IRCUser*)user;
@end

@interface IRCConnection: OFObject
{
	OFTCPSocket *sock;







|

|

|
|


>
>
>
>
|



|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@class OFTCPSocket;
@class IRCConnection;
@class IRCUser;
@class IRCChannel;

@protocol IRCConnectionDelegate
@optional
- (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: (IRCChannel*)channel;
- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
      leaveChannel: (IRCChannel*)channel
	withReason: (OFString*)reason;
-  (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;

Modified src/IRCConnection.m from [4ee7d8dea1] to [0c31043ae7].

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
			OFString *who = [splitted objectAtIndex: 0];
			OFString *where = [splitted objectAtIndex: 2];
			IRCUser *user;
			IRCChannel *channel;

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

			user = [IRCUser IRCUserWithString: who];

			if ([who hasPrefix:
			    [nickname stringByAppendingString: @"!"]]) {
				channel = [IRCChannel channelWithName: where];
				[channels setObject: channel
					     forKey: where];
			} else
				channel = [channels objectForKey: where];

			if ([delegate respondsToSelector:
			    @selector(connection:didSeeUser:joinChannel:)])
				[delegate connection: self
					  didSeeUser: user
					 joinChannel: channel];

































			continue;
		}

		/* PRIVMSG */
		if (splitted.count >= 4 &&
		    [[splitted objectAtIndex: 1] isEqual: @"PRIVMSG"]) {
			OFString *from = [splitted objectAtIndex: 0];







<
<
<
















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







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
			OFString *who = [splitted objectAtIndex: 0];
			OFString *where = [splitted objectAtIndex: 2];
			IRCUser *user;
			IRCChannel *channel;

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



			user = [IRCUser IRCUserWithString: who];

			if ([who hasPrefix:
			    [nickname stringByAppendingString: @"!"]]) {
				channel = [IRCChannel channelWithName: where];
				[channels setObject: channel
					     forKey: where];
			} else
				channel = [channels objectForKey: where];

			if ([delegate respondsToSelector:
			    @selector(connection:didSeeUser:joinChannel:)])
				[delegate connection: self
					  didSeeUser: user
					 joinChannel: channel];

			continue;
		}

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

			who = [who substringWithRange:
			    of_range(1, who.length - 1)];
			user = [IRCUser IRCUserWithString: who];
			channel = [channels objectForKey: where];

			if (splitted.count > 3)
				reason = [line substringWithRange:
				    of_range(pos + 2, line.length - pos - 2)];

			if ([delegate respondsToSelector:
			    @selector(connection:didSeeUser:leaveChannel:
			    withReason:)])
				[delegate connection: self
					  didSeeUser: user
					leaveChannel: channel
					  withReason: reason];

			continue;
		}

		/* PRIVMSG */
		if (splitted.count >= 4 &&
		    [[splitted objectAtIndex: 1] isEqual: @"PRIVMSG"]) {
			OFString *from = [splitted objectAtIndex: 0];