ObjIRC  Check-in [50a9cc56c6]

Overview
Comment:API improvements.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 50a9cc56c621bf7f12b423ddbecce9c2dfacea3435bbadf7f484c0eeb3d53821
User & Date: js on 2012-11-24 10:02:32
Other Links: manifest | tags
Context
2012-11-24
11:56
Remove the IRCChannels class. check-in: 620b9b2a30 user: js tags: trunk
10:02
API improvements. check-in: 50a9cc56c6 user: js tags: trunk
2012-11-08
15:57
Revert "Adjust to new async API." check-in: 52008e00b1 user: js tags: trunk
Changes

Modified src/IRCConnection.h from [daa560876d] to [51a0fb5754].

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
- (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
        didSeeUser: (IRCUser*)user
  changeNicknameTo: (OFString*)nickname;
- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
	  kickUser: (OFString*)kickedUser
       fromChannel: (IRCChannel*)channel
	withReason: (OFString*)reason;
- (void)connection: (IRCConnection*)connection
    didSeeUserQuit: (IRCUser*)user
	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;
- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	  fromUser: (IRCUser*)user;
- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	  fromUser: (IRCUser*)user
	 inChannel: (IRCChannel*)channel;
-	   (void)connection: (IRCConnection*)connection
  didReceiveNamesForChannel: (IRCChannel*)channel;
- (void)connectionWasClosed: (IRCConnection*)connection;
@end

@interface IRCConnection: OFObject
{







|






|
|


|


|
|


|


|


|
|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
- (void)connectionWasEstablished: (IRCConnection*)connection;
- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
       joinChannel: (IRCChannel*)channel;
- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
      leaveChannel: (IRCChannel*)channel
	    reason: (OFString*)reason;
- (void)connection: (IRCConnection*)connection
        didSeeUser: (IRCUser*)user
  changeNicknameTo: (OFString*)nickname;
- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
	  kickUser: (OFString*)kickedUser
	   channel: (IRCChannel*)channel
	    reason: (OFString*)reason;
- (void)connection: (IRCConnection*)connection
    didSeeUserQuit: (IRCUser*)user
	    reason: (OFString*)reason;
-  (void)connection: (IRCConnection*)connection
  didReceiveMessage: (OFString*)msg
	       user: (IRCUser*)user
	    channel: (IRCChannel*)channel;
-	  (void)connection: (IRCConnection*)connection
  didReceivePrivateMessage: (OFString*)msg
		      user: (IRCUser*)user;
- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	      user: (IRCUser*)user;
- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	      user: (IRCUser*)user
	   channel: (IRCChannel*)channel;
-	   (void)connection: (IRCConnection*)connection
  didReceiveNamesForChannel: (IRCChannel*)channel;
- (void)connectionWasClosed: (IRCConnection*)connection;
@end

@interface IRCConnection: OFObject
{
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
- (void)sendLineWithFormat: (OFConstantString*)line, ...;
- (void)connect;
- (void)disconnect;
- (void)disconnectWithReason: (OFString*)reason;
- (void)joinChannel: (OFString*)channelName;
- (void)leaveChannel: (IRCChannel*)channel;
- (void)leaveChannel: (IRCChannel*)channel
	  withReason: (OFString*)reason;
- (void)sendMessage: (OFString*)msg
	  toChannel: (IRCChannel*)channel;
- (void)sendMessage: (OFString*)msg
	     toUser: (OFString*)user;
- (void)sendNotice: (OFString*)notice
	    toUser: (OFString*)user;
- (void)sendNotice: (OFString*)notice
	 toChannel: (IRCChannel*)channel;
- (void)kickUser: (OFString*)user
     fromChannel: (IRCChannel*)channel
      withReason: (OFString*)reason;
- (void)changeNicknameTo: (OFString*)nickname;
- (void)processLine: (OFString*)line;
- (void)handleConnection;
@end

@interface OFObject (IRCConnectionDelegate) <IRCConnectionDelegate>
@end







|

|

|

|

|

|
|







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
- (void)sendLineWithFormat: (OFConstantString*)line, ...;
- (void)connect;
- (void)disconnect;
- (void)disconnectWithReason: (OFString*)reason;
- (void)joinChannel: (OFString*)channelName;
- (void)leaveChannel: (IRCChannel*)channel;
- (void)leaveChannel: (IRCChannel*)channel
	      reason: (OFString*)reason;
- (void)sendMessage: (OFString*)msg
	    channel: (IRCChannel*)channel;
- (void)sendMessage: (OFString*)msg
	       user: (OFString*)user;
- (void)sendNotice: (OFString*)notice
	      user: (OFString*)user;
- (void)sendNotice: (OFString*)notice
	   channel: (IRCChannel*)channel;
- (void)kickUser: (OFString*)user
	 channel: (IRCChannel*)channel
	  reason: (OFString*)reason;
- (void)changeNicknameTo: (OFString*)nickname;
- (void)processLine: (OFString*)line;
- (void)handleConnection;
@end

@interface OFObject (IRCConnectionDelegate) <IRCConnectionDelegate>
@end

Modified src/IRCConnection.m from [afa44fa97c] to [5544578885].

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
{
	[self sendLineWithFormat: @"JOIN %@", channelName];
}

- (void)leaveChannel: (IRCChannel*)channel
{
	[self leaveChannel: channel
		withReason: nil];
}

- (void)leaveChannel: (IRCChannel*)channel
          withReason: (OFString*)reason
{
	if (reason == nil)
		[self sendLineWithFormat: @"PART %@", [channel name]];
	else
		[self sendLineWithFormat: @"PART %@ :%@",
					  [channel name], reason];








|



|







150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
{
	[self sendLineWithFormat: @"JOIN %@", channelName];
}

- (void)leaveChannel: (IRCChannel*)channel
{
	[self leaveChannel: channel
		    reason: nil];
}

- (void)leaveChannel: (IRCChannel*)channel
	      reason: (OFString*)reason
{
	if (reason == nil)
		[self sendLineWithFormat: @"PART %@", [channel name]];
	else
		[self sendLineWithFormat: @"PART %@ :%@",
					  [channel name], reason];

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

	[self sendLine: line];

	[pool release];
}

- (void)sendMessage: (OFString*)msg
	  toChannel: (IRCChannel*)channel
{
	[self sendLineWithFormat: @"PRIVMSG %@ :%@", [channel name], msg];
}

- (void)sendMessage: (OFString*)msg
	     toUser: (OFString*)user
{
	[self sendLineWithFormat: @"PRIVMSG %@ :%@", user, msg];
}

- (void)sendNotice: (OFString*)notice
	    toUser: (OFString*)user
{
	[self sendLineWithFormat: @"NOTICE %@ :%@", user, notice];
}

- (void)sendNotice: (OFString*)notice
	 toChannel: (IRCChannel*)channel
{
	[self sendLineWithFormat: @"NOTICE %@ :%@", [channel name], notice];
}

- (void)kickUser: (OFString*)user
     fromChannel: (IRCChannel*)channel
      withReason: (OFString*)reason
{
	[self sendLineWithFormat: @"KICK %@ %@ :%@",
				  [channel name], user, reason];
}

- (void)changeNicknameTo: (OFString*)nickname_
{







|





|





|





|





|
|







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

	[self sendLine: line];

	[pool release];
}

- (void)sendMessage: (OFString*)msg
	    channel: (IRCChannel*)channel
{
	[self sendLineWithFormat: @"PRIVMSG %@ :%@", [channel name], msg];
}

- (void)sendMessage: (OFString*)msg
	       user: (OFString*)user
{
	[self sendLineWithFormat: @"PRIVMSG %@ :%@", user, msg];
}

- (void)sendNotice: (OFString*)notice
	      user: (OFString*)user
{
	[self sendLineWithFormat: @"NOTICE %@ :%@", user, notice];
}

- (void)sendNotice: (OFString*)notice
	   channel: (IRCChannel*)channel
{
	[self sendLineWithFormat: @"NOTICE %@ :%@", [channel name], notice];
}

- (void)kickUser: (OFString*)user
	 channel: (IRCChannel*)channel
	  reason: (OFString*)reason
{
	[self sendLineWithFormat: @"KICK %@ %@ :%@",
				  [channel name], user, reason];
}

- (void)changeNicknameTo: (OFString*)nickname_
{
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
			    of_range(pos + 2, [line length] - pos - 2)];

		[channel IRC_removeUser: [user nickname]];

		[delegate connection: self
			  didSeeUser: user
			leaveChannel: channel
			  withReason: reason];

		return;
	}

	/* KICK */
	if ([action isEqual: @"KICK"] && [components count] >= 4) {
		OFString *who = [components objectAtIndex: 0];







|







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
			    of_range(pos + 2, [line length] - pos - 2)];

		[channel IRC_removeUser: [user nickname]];

		[delegate connection: self
			  didSeeUser: user
			leaveChannel: channel
			      reason: reason];

		return;
	}

	/* KICK */
	if ([action isEqual: @"KICK"] && [components count] >= 4) {
		OFString *who = [components objectAtIndex: 0];
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
			    of_range(pos + 2, [line length] - pos - 2)];

		[channel IRC_removeUser: [user nickname]];

		[delegate connection: self
			  didSeeUser: user
			    kickUser: whom
			 fromChannel: channel
			  withReason: reason];

		return;
	}

	/* QUIT */
	if ([action isEqual: @"QUIT"] && [components count] >= 2) {
		OFString *who = [components objectAtIndex: 0];







|
|







375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
			    of_range(pos + 2, [line length] - pos - 2)];

		[channel IRC_removeUser: [user nickname]];

		[delegate connection: self
			  didSeeUser: user
			    kickUser: whom
			     channel: channel
			      reason: reason];

		return;
	}

	/* QUIT */
	if ([action isEqual: @"QUIT"] && [components count] >= 2) {
		OFString *who = [components objectAtIndex: 0];
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418

		enumerator = [channels keyEnumerator];
		while ((channel = [enumerator nextObject]) != nil)
			[channel IRC_removeUser: [user nickname]];

		[delegate connection: self
		      didSeeUserQuit: user
			  withReason: reason];

		return;
	}

	/* NICK */
	if ([action isEqual: @"NICK"] && [components count] == 3) {
		OFString *who = [components objectAtIndex: 0];







|







404
405
406
407
408
409
410
411
412
413
414
415
416
417
418

		enumerator = [channels keyEnumerator];
		while ((channel = [enumerator nextObject]) != nil)
			[channel IRC_removeUser: [user nickname]];

		[delegate connection: self
		      didSeeUserQuit: user
			      reason: reason];

		return;
	}

	/* NICK */
	if ([action isEqual: @"NICK"] && [components count] == 3) {
		OFString *who = [components objectAtIndex: 0];
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
		if (![to isEqual: nickname]) {
			IRCChannel *channel;

			channel = [channels objectForKey: to];

			[delegate connection: self
			   didReceiveMessage: msg
				    fromUser: user
				   inChannel: channel];
		} else
			[delegate	  connection: self
			    didReceivePrivateMessage: msg
					    fromUser: user];

		return;
	}

	/* NOTICE */
	if ([action isEqual: @"NOTICE"] && [components count] >= 4) {
		OFString *from = [components objectAtIndex: 0];







|
|



|







465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
		if (![to isEqual: nickname]) {
			IRCChannel *channel;

			channel = [channels objectForKey: to];

			[delegate connection: self
			   didReceiveMessage: msg
					user: user
				     channel: channel];
		} else
			[delegate	  connection: self
			    didReceivePrivateMessage: msg
						user: user];

		return;
	}

	/* NOTICE */
	if ([action isEqual: @"NOTICE"] && [components count] >= 4) {
		OFString *from = [components objectAtIndex: 0];
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
		if (![to isEqual: nickname]) {
			IRCChannel *channel;

			channel = [channels objectForKey: to];

			[delegate connection: self
			    didReceiveNotice: notice
				    fromUser: user
				   inChannel: channel];
		} else
			[delegate connection: self
			    didReceiveNotice: notice
				    fromUser: user];

		return;
	}
}

- (void)processLine: (OFString*)line
{







|
|



|







503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
		if (![to isEqual: nickname]) {
			IRCChannel *channel;

			channel = [channels objectForKey: to];

			[delegate connection: self
			    didReceiveNotice: notice
					user: user
				     channel: channel];
		} else
			[delegate connection: self
			    didReceiveNotice: notice
					user: user];

		return;
	}
}

- (void)processLine: (OFString*)line
{
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
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
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
       joinChannel: (IRCChannel*)channel
{
}

- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
      leaveChannel: (IRCChannel*)channel
	withReason: (OFString*)reason
{
}

- (void)connection: (IRCConnection*)connection
        didSeeUser: (IRCUser*)user
  changeNicknameTo: (OFString*)nickname
{
}

- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
	  kickUser: (OFString*)kickedUser
       fromChannel: (IRCChannel*)channel
	withReason: (OFString*)reason
{
}

- (void)connection: (IRCConnection*)connection
    didSeeUserQuit: (IRCUser*)user
	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
{
}

- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	  fromUser: (IRCUser*)user
{
}

- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	  fromUser: (IRCUser*)user
	 inChannel: (IRCChannel*)channel
{
}

-	   (void)connection: (IRCConnection*)connection
  didReceiveNamesForChannel: (IRCChannel*)channel
{
}

- (void)connectionWasClosed: (IRCConnection*)connection
{
}
@end







|












|
|





|






|





|





|





|
|












601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
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
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
       joinChannel: (IRCChannel*)channel
{
}

- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
      leaveChannel: (IRCChannel*)channel
	    reason: (OFString*)reason
{
}

- (void)connection: (IRCConnection*)connection
        didSeeUser: (IRCUser*)user
  changeNicknameTo: (OFString*)nickname
{
}

- (void)connection: (IRCConnection*)connection
	didSeeUser: (IRCUser*)user
	  kickUser: (OFString*)kickedUser
	   channel: (IRCChannel*)channel
	    reason: (OFString*)reason
{
}

- (void)connection: (IRCConnection*)connection
    didSeeUserQuit: (IRCUser*)user
	    reason: (OFString*)reason
{
}

-  (void)connection: (IRCConnection*)connection
  didReceiveMessage: (OFString*)msg
	   fromUser: (IRCUser*)user
	    channel: (IRCChannel*)channel
{
}

-	  (void)connection: (IRCConnection*)connection
  didReceivePrivateMessage: (OFString*)msg
		      user: (IRCUser*)user
{
}

- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	      user: (IRCUser*)user
{
}

- (void)connection: (IRCConnection*)connection
  didReceiveNotice: (OFString*)notice
	      user: (IRCUser*)user
	   channel: (IRCChannel*)channel
{
}

-	   (void)connection: (IRCConnection*)connection
  didReceiveNamesForChannel: (IRCChannel*)channel
{
}

- (void)connectionWasClosed: (IRCConnection*)connection
{
}
@end