Overview
Comment: | Adjust to ObjFW changes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bd405f3759e055a6385f2296dbabf1bf |
User & Date: | js on 2024-05-04 21:18:40 |
Other Links: | manifest | tags |
Context
2024-05-04
| ||
21:19 | Update copyright check-in: b548b2689f user: js tags: trunk | |
21:18 | Adjust to ObjFW changes check-in: bd405f3759 user: js tags: trunk | |
21:05 | Update buildsys check-in: a13b2c4a76 user: js tags: trunk | |
Changes
Modified src/IRCConnection.m from [67857e94b2] to [2f9d06f05e].
︙ | ︙ | |||
21 22 23 24 25 26 27 | * POSSIBILITY OF SUCH DAMAGE. */ #define IRC_CONNECTION_M #include <stdarg.h> | | < < < < < < < | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | * POSSIBILITY OF SUCH DAMAGE. */ #define IRC_CONNECTION_M #include <stdarg.h> #import <ObjFW/ObjFW.h> #import "IRCConnection.h" #import "IRCUser.h" @interface IRCConnection () <OFTCPSocketDelegate> @end |
︙ | ︙ | |||
87 88 89 90 91 92 93 | } - (void)connect { void *pool = objc_autoreleasePoolPush(); if (_socket != nil) | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | } - (void)connect { void *pool = objc_autoreleasePoolPush(); if (_socket != nil) @throw [OFAlreadyOpenException exceptionWithObject: self]; _socket = [[_socketClass alloc] init]; [_socket setDelegate: self]; [_socket asyncConnectToHost: _server port: _port]; objc_autoreleasePoolPop(pool); } |
︙ | ︙ | |||
252 253 254 255 256 257 258 | if ([_delegate respondsToSelector: @selector(connection:didReceiveLine:)]) [_delegate connection: self didReceiveLine: line]; components = [line componentsSeparatedByString: @" "]; /* PING */ | | | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | if ([_delegate respondsToSelector: @selector(connection:didReceiveLine:)]) [_delegate connection: self didReceiveLine: line]; components = [line componentsSeparatedByString: @" "]; /* PING */ if (components.count == 2 && [components.firstObject isEqual: @"PING"]) { OFMutableString *s = [[line mutableCopy] autorelease]; [s replaceCharactersInRange: OFMakeRange(0, 4) withString: @"PONG"]; [self sendLine: s]; return; } /* PONG */ |
︙ | ︙ | |||
298 299 300 301 302 303 304 | /* JOIN */ if ([action isEqual: @"JOIN"] && components.count == 3) { OFString *who = [components objectAtIndex: 0]; OFString *where = [components objectAtIndex: 2]; IRCUser *user; OFMutableSet *channel; | | | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | /* JOIN */ if ([action isEqual: @"JOIN"] && components.count == 3) { OFString *who = [components objectAtIndex: 0]; OFString *where = [components objectAtIndex: 2]; IRCUser *user; OFMutableSet *channel; who = [who substringFromIndex: 1]; user = [IRCUser IRCUserWithString: who]; if ([who hasPrefix: [_nickname stringByAppendingString: @"!"]]) { channel = [OFMutableSet set]; [_channels setObject: channel forKey: where]; } else |
︙ | ︙ | |||
340 341 342 343 344 345 346 | pos = [[components objectAtIndex: 0] length] + [[components objectAtIndex: 1] length] + [[components objectAtIndex: 2] length] + [[components objectAtIndex: 3] length] + [[components objectAtIndex: 4] length] + 6; users = [[line substringWithRange: | | | < | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | pos = [[components objectAtIndex: 0] length] + [[components objectAtIndex: 1] length] + [[components objectAtIndex: 2] length] + [[components objectAtIndex: 3] length] + [[components objectAtIndex: 4] length] + 6; users = [[line substringWithRange: OFMakeRange(pos, line.length - pos)] componentsSeparatedByString: @" "]; for (OFString *user in users) { if ([user hasPrefix: @"@"] || [user hasPrefix: @"+"] || [user hasPrefix: @"%"] || [user hasPrefix: @"*"]) user = [user substringFromIndex: 1]; [channel addObject: user]; } if ([_delegate respondsToSelector: @selector(connection:didReceiveNamesForChannel:)]) [_delegate connection: self |
︙ | ︙ | |||
370 371 372 373 374 375 376 | OFString *where = [components objectAtIndex: 2]; IRCUser *user; OFMutableSet *channel; OFString *reason = nil; size_t pos = who.length + 1 + [[components objectAtIndex: 1] length] + 1 + where.length; | | | < | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | OFString *where = [components objectAtIndex: 2]; IRCUser *user; OFMutableSet *channel; OFString *reason = nil; size_t pos = who.length + 1 + [[components objectAtIndex: 1] length] + 1 + where.length; who = [who substringFromIndex: 1]; user = [IRCUser IRCUserWithString: who]; channel = [_channels objectForKey: where]; if (components.count > 3) reason = [line substringFromIndex: pos + 2]; [channel removeObject: user.nickname]; if ([_delegate respondsToSelector: @selector(connection:didSeeUser:leaveChannel:reason:)]) [_delegate connection: self didSeeUser: user |
︙ | ︙ | |||
402 403 404 405 406 407 408 | IRCUser *user; OFMutableSet *channel; OFString *reason = nil; size_t pos = who.length + 1 + [[components objectAtIndex: 1] length] + 1 + where.length + 1 + whom.length; | | | | < | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | IRCUser *user; OFMutableSet *channel; OFString *reason = nil; size_t pos = who.length + 1 + [[components objectAtIndex: 1] length] + 1 + where.length + 1 + whom.length; who = [who substringFromIndex: 1]; user = [IRCUser IRCUserWithString: who]; channel = [_channels objectForKey: where]; if (components.count > 4) reason = [line substringFromIndex: pos + 2]; [channel removeObject: user.nickname]; if ([_delegate respondsToSelector: @selector(connection:didSeeUser:kickUser:channel:reason:)]) [_delegate connection: self didSeeUser: user |
︙ | ︙ | |||
431 432 433 434 435 436 437 | if ([action isEqual: @"QUIT"] && components.count >= 2) { OFString *who = [components objectAtIndex: 0]; IRCUser *user; OFString *reason = nil; size_t pos = who.length + 1 + [[components objectAtIndex: 1] length]; | | | < | | < | 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | if ([action isEqual: @"QUIT"] && components.count >= 2) { OFString *who = [components objectAtIndex: 0]; IRCUser *user; OFString *reason = nil; size_t pos = who.length + 1 + [[components objectAtIndex: 1] length]; who = [who substringFromIndex: 1]; user = [IRCUser IRCUserWithString: who]; if ([components count] > 2) reason = [line substringFromIndex: pos + 2]; for (OFString *channel in _channels) [[_channels objectForKey: channel] removeObject: user.nickname]; if ([_delegate respondsToSelector: @selector(connection:didSeeUserQuit:reason:)]) [_delegate connection: self didSeeUserQuit: user reason: reason]; return; } /* NICK */ if ([action isEqual: @"NICK"] && components.count == 3) { OFString *who = [components objectAtIndex: 0]; OFString *nickname = [components objectAtIndex: 2]; IRCUser *user; who = [who substringFromIndex: 1]; nickname = [nickname substringFromIndex: 1]; user = [IRCUser IRCUserWithString: who]; if ([user.nickname isEqual: _nickname]) { [_nickname release]; _nickname = [nickname copy]; } |
︙ | ︙ | |||
493 494 495 496 497 498 499 | OFString *from = [components objectAtIndex: 0]; OFString *to = [components objectAtIndex: 2]; IRCUser *user; OFString *message; size_t pos = from.length + 1 + [[components objectAtIndex: 1] length] + 1 + to.length; | | < | < | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | OFString *from = [components objectAtIndex: 0]; OFString *to = [components objectAtIndex: 2]; IRCUser *user; OFString *message; size_t pos = from.length + 1 + [[components objectAtIndex: 1] length] + 1 + to.length; from = [from substringFromIndex: 1]; message = [line substringFromIndex: pos + 2]; user = [IRCUser IRCUserWithString: from]; if (![to isEqual: _nickname]) { if ([_delegate respondsToSelector: @selector(connection: didReceiveMessage:channel:user:)]) [_delegate connection: self didReceiveMessage: message |
︙ | ︙ | |||
526 527 528 529 530 531 532 | OFString *from = [components objectAtIndex: 0]; OFString *to = [components objectAtIndex: 2]; IRCUser *user = nil; OFString *notice; size_t pos = from.length + 1 + [[components objectAtIndex: 1] length] + 1 + to.length; | | < | < | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | OFString *from = [components objectAtIndex: 0]; OFString *to = [components objectAtIndex: 2]; IRCUser *user = nil; OFString *notice; size_t pos = from.length + 1 + [[components objectAtIndex: 1] length] + 1 + to.length; from = [from substringFromIndex: 1]; notice = [line substringFromIndex: pos + 2]; if (![from containsString: @"!"] || [to isEqual: @"*"]) { /* System message - ignore for now */ return; } user = [IRCUser IRCUserWithString: from]; |
︙ | ︙ |
Modified tests/tests.m from [8932bff494] to [2c0a9b5233].
︙ | ︙ | |||
29 30 31 32 33 34 35 | @interface TestApp: OFObject <OFApplicationDelegate, IRCConnectionDelegate> @end OF_APPLICATION_DELEGATE(TestApp) @implementation TestApp | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | @interface TestApp: OFObject <OFApplicationDelegate, IRCConnectionDelegate> @end OF_APPLICATION_DELEGATE(TestApp) @implementation TestApp - (void)applicationDidFinishLaunching: (OFNotification *)notification { IRCConnection *connection = [[IRCConnection alloc] init]; connection.server = @"irc.freenode.net"; connection.nickname = @"ObjIRC"; connection.username = @"ObjIRC"; connection.realname = @"ObjIRC"; |
︙ | ︙ |