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: |
e7f0831117b1cb0f56658ca9130df2f1 |
User & Date: | js on 2016-05-07 11:21:37 |
Other Links: | manifest | tags |
Context
2016-05-07
| ||
11:23 | Cleaner PONG check-in: aa89dd371b user: js tags: trunk | |
11:21 | Adjust to ObjFW changes check-in: e7f0831117 user: js tags: trunk | |
2013-07-12
| ||
14:12 | Adjust to ObjFW API and fix a disconnect bug. check-in: 1813701690 user: js tags: trunk | |
Changes
Modified src/IRCConnection.h from [aec6e61116] to [0fe0fac278].
︙ | ︙ | |||
22 23 24 25 26 27 28 | #import <ObjFW/ObjFW.h> @class IRCConnection; @class IRCUser; @protocol IRCConnectionDelegate <OFObject> | < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #import <ObjFW/ObjFW.h> @class IRCConnection; @class IRCUser; @protocol IRCConnectionDelegate <OFObject> @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 |
︙ | ︙ | |||
77 78 79 80 81 82 83 | OFString *_server; uint16_t _port; OFString *_nickname, *_username, *_realname; OFMutableDictionary *_channels; id <IRCConnectionDelegate> _delegate; } | < < < < < < < < < < < < < < < | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | OFString *_server; uint16_t _port; OFString *_nickname, *_username, *_realname; OFMutableDictionary *_channels; id <IRCConnectionDelegate> _delegate; } @property (copy) OFString *server; @property (assign) uint16_t port; @property (copy) OFString *nickname, *username, *realname; @property (assign) id <IRCConnectionDelegate> delegate; @property (readonly, retain) OFTCPSocket *socket; + (instancetype)connection; - (void)sendLine: (OFString*)line; - (void)sendLineWithFormat: (OFConstantString*)line, ...; - (void)connect; - (void)disconnect; - (void)disconnectWithReason: (OFString*)reason; - (void)joinChannel: (OFString*)channelName; - (void)leaveChannel: (OFString*)channel; |
︙ | ︙ | |||
120 121 122 123 124 125 126 | channel: (OFString*)channel reason: (OFString*)reason; - (void)changeNicknameTo: (OFString*)nickname; - (void)processLine: (OFString*)line; - (void)handleConnection; - (OFSet*)usersInChannel: (OFString*)channel; @end | < < < | 103 104 105 106 107 108 109 | channel: (OFString*)channel reason: (OFString*)reason; - (void)changeNicknameTo: (OFString*)nickname; - (void)processLine: (OFString*)line; - (void)handleConnection; - (OFSet*)usersInChannel: (OFString*)channel; @end |
Modified src/IRCConnection.m from [adb245b3eb] to [59f01b1597].
︙ | ︙ | |||
24 25 26 27 28 29 30 | #include <stdarg.h> #import <ObjFW/OFString.h> #import <ObjFW/OFArray.h> #import <ObjFW/OFMutableDictionary.h> #import <ObjFW/OFTCPSocket.h> | < > > > > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #include <stdarg.h> #import <ObjFW/OFString.h> #import <ObjFW/OFArray.h> #import <ObjFW/OFMutableDictionary.h> #import <ObjFW/OFTCPSocket.h> #import <ObjFW/OFInvalidEncodingException.h> #import <ObjFW/macros.h> #import "IRCConnection.h" #import "IRCUser.h" @implementation IRCConnection @synthesize server = _server, port = _port; @synthesize nickname = _nickname, username = _username, realname = _realname; @synthesize delegate = _delegate, socket = _socket; + (instancetype)connection { return [[[self alloc] init] autorelease]; } - init { |
︙ | ︙ | |||
66 67 68 69 70 71 72 | [_username release]; [_realname release]; [_channels release]; [super dealloc]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | > > > > > > > > > > > > | | | < < < > > > | < < < > > > > > > > > > > > | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 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 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 | [_username release]; [_realname release]; [_channels release]; [super dealloc]; } - (void)connect { void *pool = objc_autoreleasePoolPush(); if (_socket != nil) @throw [OFAlreadyConnectedException exception]; _socket = [[OFTCPSocket alloc] init]; [_socket connectToHost: _server port: _port]; [self sendLineWithFormat: @"NICK %@", _nickname]; [self sendLineWithFormat: @"USER %@ * 0 :%@", _username, _realname]; objc_autoreleasePoolPop(pool); } - (void)disconnect { [self disconnectWithReason: nil]; } - (void)disconnectWithReason: (OFString*)reason { void *pool = objc_autoreleasePoolPush(); reason = [[reason componentsSeparatedByString: @"\n"] firstObject]; if (reason == nil) [self sendLine: @"QUIT"]; else [self sendLineWithFormat: @"QUIT :%@", reason]; objc_autoreleasePoolPop(pool); } - (void)joinChannel: (OFString*)channel { void *pool = objc_autoreleasePoolPush(); channel = [[channel componentsSeparatedByString: @"\n"] firstObject]; [self sendLineWithFormat: @"JOIN %@", channel]; objc_autoreleasePoolPop(pool); } - (void)leaveChannel: (OFString*)channel { [self leaveChannel: channel reason: nil]; } - (void)leaveChannel: (OFString*)channel reason: (OFString*)reason { void *pool = objc_autoreleasePoolPush(); channel = [[channel componentsSeparatedByString: @"\n"] firstObject]; reason = [[reason componentsSeparatedByString: @"\n"] firstObject]; if (reason == nil) [self sendLineWithFormat: @"PART %@", channel]; else [self sendLineWithFormat: @"PART %@ :%@", channel, reason]; [_channels removeObjectForKey: channel]; objc_autoreleasePoolPop(pool); } - (void)sendLine: (OFString*)line { if ([_delegate respondsToSelector: @selector(connection:didSendLine:)]) [_delegate connection: self didSendLine: line]; [_socket writeLine: line]; } - (void)sendLineWithFormat: (OFConstantString*)format, ... { void *pool = objc_autoreleasePoolPush(); OFString *line; va_list args; va_start(args, format); line = [[[OFString alloc] initWithFormat: format arguments: args] autorelease]; va_end(args); [self sendLine: line]; objc_autoreleasePoolPop(pool); } - (void)sendMessage: (OFString*)msg to: (OFString*)to { void *pool = objc_autoreleasePoolPush(); for (OFString *line in [msg componentsSeparatedByString: @"\n"]) [self sendLineWithFormat: @"PRIVMSG %@ :%@", to, line]; objc_autoreleasePoolPop(pool); } - (void)sendNotice: (OFString*)notice to: (OFString*)to { void *pool = objc_autoreleasePoolPush(); for (OFString *line in [notice componentsSeparatedByString: @"\n"]) [self sendLineWithFormat: @"NOTICE %@ :%@", to, line]; objc_autoreleasePoolPop(pool); } - (void)kickUser: (OFString*)user channel: (OFString*)channel reason: (OFString*)reason { void *pool = objc_autoreleasePoolPush(); reason = [[reason componentsSeparatedByString: @"\n"] firstObject]; [self sendLineWithFormat: @"KICK %@ %@ :%@", channel, user, reason]; objc_autoreleasePoolPop(pool); } - (void)changeNicknameTo: (OFString*)nickname { void *pool = objc_autoreleasePoolPush(); nickname = [[nickname componentsSeparatedByString: @"\n"] firstObject]; [self sendLineWithFormat: @"NICK %@", nickname]; objc_autoreleasePoolPop(pool); } - (void)IRC_processLine: (OFString*)line { OFArray *components; OFString *action = nil; |
︙ | ︙ | |||
323 324 325 326 327 328 329 | /* NAMES reply */ if ([action isEqual: @"353"] && [components count] >= 6) { OFString *where; OFMutableSet *channel; OFArray *users; size_t pos; | < < | < | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | /* NAMES reply */ if ([action isEqual: @"353"] && [components count] >= 6) { OFString *where; OFMutableSet *channel; OFArray *users; size_t pos; where = [components objectAtIndex: 4]; if ((channel = [_channels objectForKey: where]) == nil) { /* We did not request that */ return; } 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: of_range(pos, [line length] - pos)] componentsSeparatedByString: @" "]; for (OFString *user in users) { if ([user hasPrefix: @"@"] || [user hasPrefix: @"+"] || [user hasPrefix: @"%"] || [user hasPrefix: @"*"]) user = [user substringWithRange: of_range(1, [user length] - 1)]; [channel addObject: user]; } |
︙ | ︙ | |||
431 432 433 434 435 436 437 | /* QUIT */ 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]; | < < | < < < | < | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | /* QUIT */ 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 substringWithRange: of_range(1, [who length] - 1)]; user = [IRCUser IRCUserWithString: who]; if ([components count] > 2) reason = [line substringWithRange: of_range(pos + 2, [line length] - pos - 2)]; for (OFMutableSet *channel in _channels) [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 substringWithRange: of_range(1, [who length] - 1)]; nickname = [nickname substringWithRange: of_range(1, [nickname length] - 1)]; user = [IRCUser IRCUserWithString: who]; if ([[user nickname] isEqual: _nickname]) { [_nickname release]; _nickname = [nickname copy]; } for (OFMutableSet *channel in _channels) { if ([channel containsObject: [user nickname]]) { [channel removeObject: [user nickname]]; [channel addObject: nickname]; } } if ([_delegate respondsToSelector: |
︙ | ︙ | |||
565 566 567 568 569 570 571 | return; } } - (void)processLine: (OFString*)line { | | | | 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | return; } } - (void)processLine: (OFString*)line { void *pool = objc_autoreleasePoolPush(); [self IRC_processLine: line]; objc_autoreleasePoolPop(pool); } - (bool)socket: (OFTCPSocket*)socket didReceiveISO88591Line: (OFString*)line exception: (OFException*)exception { if (line != nil) { |
︙ | ︙ |
Modified src/IRCUser.h from [b31edf76a9] to [b2083930e4].
︙ | ︙ | |||
23 24 25 26 27 28 29 | #import <ObjFW/OFObject.h> @interface IRCUser: OFObject <OFCopying> { OFString *_nickname, *_username, *_hostname; } | < < < < < | 23 24 25 26 27 28 29 30 31 32 33 34 | #import <ObjFW/OFObject.h> @interface IRCUser: OFObject <OFCopying> { OFString *_nickname, *_username, *_hostname; } @property (copy, readonly) OFString *nickname, *username, *hostname; + (instancetype)IRCUserWithString: (OFString*)string; - initWithString: (OFString*)string; @end |
Modified src/IRCUser.m from [1fa74637a1] to [d43c26daf1].
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #import <ObjFW/OFOutOfMemoryException.h> #import <ObjFW/macros.h> #import "IRCUser.h" @implementation IRCUser + (instancetype)IRCUserWithString: (OFString*)string { return [[[self alloc] initWithString: string] autorelease]; } - initWithString: (OFString*)string { | > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #import <ObjFW/OFOutOfMemoryException.h> #import <ObjFW/macros.h> #import "IRCUser.h" @implementation IRCUser @synthesize username = _username, nickname = _nickname, hostname = _hostname; + (instancetype)IRCUserWithString: (OFString*)string { return [[[self alloc] initWithString: string] autorelease]; } - initWithString: (OFString*)string { |
︙ | ︙ | |||
81 82 83 84 85 86 87 | [_nickname release]; [_username release]; [_hostname release]; [super dealloc]; } | < < < < < < < < < < < < < < < | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | [_nickname release]; [_username release]; [_hostname release]; [super dealloc]; } - copy { return [self retain]; } - (OFString*)description { return [OFString stringWithFormat: @"%@!%@@%@", _nickname, _username, _hostname]; } @end |
Modified tests/test.m from [4612327517] to [9f9c8d8d61].
︙ | ︙ | |||
23 24 25 26 27 28 29 | #import <ObjFW/OFString.h> #import <ObjFW/OFApplication.h> #import <ObjFW/OFFile.h> #import "IRCConnection.h" #import "IRCUser.h" | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #import <ObjFW/OFString.h> #import <ObjFW/OFApplication.h> #import <ObjFW/OFFile.h> #import "IRCConnection.h" #import "IRCUser.h" @interface TestApp: OFObject <OFApplicationDelegate, IRCConnectionDelegate> @end OF_APPLICATION_DELEGATE(TestApp) @implementation TestApp - (void)applicationDidFinishLaunching { |
︙ | ︙ |