Changeset 3550
- Timestamp:
- 01/14/07 12:17:48 (2 years ago)
- Files:
-
- trunk/Chat Core/MVIRCChatConnection.m (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core/MVIRCChatConnection.m
r3549 r3550 26 26 #define JVWatchedUserWHOISDelay 300. 27 27 #define JVWatchedUserISONDelay 60. 28 #define JVMaximumISONCommandLength 510 28 #define JVMaximumCommandLength 510 29 #define JVMaximumISONCommandLength JVMaximumCommandLength 30 #define JVMaximumWatchCommandLength JVMaximumCommandLength 29 31 #define JVMaximumMembersForWhoRequest 100 32 #define JVFirstViableTimestamp 631138520 30 33 #define JVFallbackEncoding NSISOLatin1StringEncoding 31 34 … … 496 499 - (void) setAwayStatusMessage:(NSAttributedString *) message { 497 500 if( [[message string] length] ) { 498 [[self localUser] _setStatus:MVChatUserAwayStatus];499 500 501 MVSafeCopyAssign( &_awayMessage, message ); 501 502 502 503 NSData *msg = [[self class] _flattenedIRCDataForMessage:message withEncoding:[self encoding] andChatFormat:[self outgoingChatFormat]]; 503 504 [self sendRawMessageImmediatelyWithComponents:@"AWAY :", msg, nil]; 505 506 [[self localUser] _setAwayStatusMessage:msg]; 507 [[self localUser] _setStatus:MVChatUserAwayStatus]; 504 508 } else { 505 509 MVSafeAssign( &_awayMessage, nil ); 510 511 [self sendRawMessage:@"AWAY" immediately:YES]; 512 513 [[self localUser] _setAwayStatusMessage:nil]; 506 514 [[self localUser] _setStatus:MVChatUserAvailableStatus]; 507 [self sendRawMessage:@"AWAY" immediately:YES];508 515 } 509 516 } … … 882 889 // for the command and its parameters. 883 890 884 if( [data length] > 510 ) [data setLength:510];891 if( [data length] > JVMaximumCommandLength ) [data setLength:JVMaximumCommandLength]; 885 892 [data appendBytes:"\x0D\x0A" length:2]; 886 893 … … 1304 1311 _watchCommandSupported = YES; 1305 1312 1306 NSMutableString *request = [[NSMutableString allocWithZone:nil] initWithCapacity: 510];1313 NSMutableString *request = [[NSMutableString allocWithZone:nil] initWithCapacity:JVMaximumWatchCommandLength]; 1307 1314 [request setString:@"WATCH "]; 1308 1315 … … 1314 1321 NSString *nick = [rule nickname]; 1315 1322 if( nick && ! [rule nicknameIsRegularExpression] ) { 1316 if( ( [nick length] + [request length] + 1 ) > 510) {1323 if( ( [nick length] + [request length] + 1 ) > JVMaximumWatchCommandLength ) { 1317 1324 [self sendRawMessage:request]; 1318 1325 [request release]; 1319 1326 1320 request = [[NSMutableString allocWithZone:nil] initWithCapacity: 510];1327 request = [[NSMutableString allocWithZone:nil] initWithCapacity:JVMaximumWatchCommandLength]; 1321 1328 [request setString:@"WATCH "]; 1322 1329 } … … 1584 1591 #elif __i386__ 1585 1592 NSString *processor = @"Intel"; 1593 #elif __arm__ 1594 NSString *processor = @"ARM"; 1586 1595 #else 1587 1596 NSString *processor = @"Unknown Architecture"; … … 2000 2009 if( [parameters count] == 2 && [sender isKindOfClass:[MVChatUser class]] ) { 2001 2010 MVChatRoom *room = [self joinedChatRoomWithName:[parameters objectAtIndex:0]]; 2002 [room _setTopic:[parameters objectAtIndex:1]]; 2011 NSData *topic = [parameters objectAtIndex:1]; 2012 if( ! [topic isKindOfClass:[NSData class]] ) topic = nil; 2013 [room _setTopic:topic]; 2003 2014 [room _setTopicAuthor:sender]; 2004 2015 [room _setTopicDate:[NSDate date]]; … … 2018 2029 unsigned int i = 0, count = [parameters count]; 2019 2030 while( i < count ) { 2020 NSString *param = [ parameters objectAtIndex:i++];2031 NSString *param = [self _stringFromPossibleData:[parameters objectAtIndex:i++]]; 2021 2032 if( [param length] ) { 2022 2033 char chr = [param characterAtIndex:0]; … … 2150 2161 [self _parseRoomModes:[parameters subarrayWithRange:NSMakeRange( 1, [parameters count] - 1)] forRoom:room fromSender:sender]; 2151 2162 } else { 2152 // user modes 2163 // user modes not handled yet 2153 2164 } 2154 2165 } … … 2293 2304 if( [parameters count] == 3 ) { 2294 2305 MVChatUser *user = [self chatUserWithUniqueIdentifier:[parameters objectAtIndex:1]]; 2295 if( ! [[user awayStatusMessage] isEqual:[parameters objectAtIndex:2]] ) { 2306 NSData *awayMsg = [parameters objectAtIndex:2]; 2307 if( ! [awayMsg isKindOfClass:[NSData class]] ) awayMsg = nil; 2308 2309 if( ! [[user awayStatusMessage] isEqual:awayMsg] ) { 2310 [user _setAwayStatusMessage:awayMsg]; 2296 2311 [user _setStatus:MVChatUserAwayStatus]; 2297 [user _setAwayStatusMessage:[parameters objectAtIndex:2]]; 2312 2298 2313 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatUserAwayStatusMessageChangedNotification object:user userInfo:nil]; 2299 2314 } … … 2303 2318 - (void) _handle305WithParameters:(NSArray *) parameters fromSender:(id) sender { // RPL_UNAWAY 2304 2319 MVAssertCorrectThreadRequired( _connectionThread ); 2320 2321 [[self localUser] _setAwayStatusMessage:nil]; 2322 [[self localUser] _setStatus:MVChatUserAvailableStatus]; 2323 2305 2324 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 2306 2325 } … … 2308 2327 - (void) _handle306WithParameters:(NSArray *) parameters fromSender:(id) sender { // RPL_NOWAWAY 2309 2328 MVAssertCorrectThreadRequired( _connectionThread ); 2329 2330 [[self localUser] _setStatus:MVChatUserAwayStatus]; 2331 2310 2332 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 2311 2333 } … … 2419 2441 2420 2442 if( [parameters count] >= 2 ) { 2421 MVChatRoom *room = [self joinedChatRoomWithName:[ parameters objectAtIndex:1]];2443 MVChatRoom *room = [self joinedChatRoomWithName:[self _stringFromPossibleData:[parameters objectAtIndex:1]]]; 2422 2444 if( room ) [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomMemberUsersSyncedNotification object:room]; 2423 2445 } … … 2456 2478 NSString *dateString = [self _stringFromPossibleData:[parameters objectAtIndex:4]]; 2457 2479 NSTimeInterval time = [dateString doubleValue]; 2458 if( time > 631138520 ) // this makes sure it is a viable date2480 if( time > JVFirstViableTimestamp ) 2459 2481 [user setAttribute:[NSDate dateWithTimeIntervalSince1970:time] forKey:MVChatUserBanDateAttribute]; 2460 2482 } … … 2471 2493 2472 2494 if( [parameters count] >= 2 ) { 2473 MVChatRoom *room = [self joinedChatRoomWithName:[ parameters objectAtIndex:1]];2495 MVChatRoom *room = [self joinedChatRoomWithName:[self _stringFromPossibleData:[parameters objectAtIndex:1]]]; 2474 2496 [room _setBansSynced:YES]; 2475 2497 if( room ) [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomBannedUsersSyncedNotification object:room]; … … 2485 2507 if( [parameters count] == 3 ) { 2486 2508 MVChatRoom *room = [self joinedChatRoomWithName:[parameters objectAtIndex:1]]; 2487 [room _setTopic:[parameters objectAtIndex:2]]; 2509 NSData *topic = [parameters objectAtIndex:2]; 2510 if( ! [topic isKindOfClass:[NSData class]] ) topic = nil; 2511 [room _setTopic:topic]; 2488 2512 } 2489 2513 } … … 2496 2520 MVChatUser *author = [MVChatUser wildcardUserFromString:[parameters objectAtIndex:2]]; 2497 2521 [room _setTopicAuthor:author]; 2498 if( [[parameters objectAtIndex:3] doubleValue] > 631138520 ) 2499 [room _setTopicDate:[NSDate dateWithTimeIntervalSince1970:[[parameters objectAtIndex:3] doubleValue]]]; 2522 2523 NSString *setTime = [self _stringFromPossibleData:[parameters objectAtIndex:3]]; 2524 NSTimeInterval time = [setTime doubleValue]; 2525 if( time > JVFirstViableTimestamp ) 2526 [room _setTopicDate:[NSDate dateWithTimeIntervalSince1970:time]]; 2527 2500 2528 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomTopicChangedNotification object:room userInfo:nil]; 2501 2529 } … … 2529 2557 if( [parameters count] >= 3 ) { 2530 2558 MVChatUser *user = [self chatUserWithUniqueIdentifier:[parameters objectAtIndex:1]]; 2531 [user _setServerAddress:[ parameters objectAtIndex:2]];2559 [user _setServerAddress:[self _stringFromPossibleData:[parameters objectAtIndex:2]]]; 2532 2560 } 2533 2561 } … … 2547 2575 if( [parameters count] >= 3 ) { 2548 2576 MVChatUser *user = [self chatUserWithUniqueIdentifier:[parameters objectAtIndex:1]]; 2549 [user _setIdleTime:[[parameters objectAtIndex:2] doubleValue]]; 2577 NSString *idleTime = [self _stringFromPossibleData:[parameters objectAtIndex:2]]; 2578 [user _setIdleTime:[idleTime doubleValue]]; 2550 2579 [user _setDateConnected:nil]; 2551 2580 … … 2554 2583 NSString *connectedTime = [self _stringFromPossibleData:[parameters objectAtIndex:3]]; 2555 2584 NSTimeInterval time = [connectedTime doubleValue]; 2556 // prevent showing 34+ years connected time, this makes sure it is a viable date2557 if( time > 631138520 )[user _setDateConnected:[NSDate dateWithTimeIntervalSince1970:time]];2585 if( time > JVFirstViableTimestamp ) 2586 [user _setDateConnected:[NSDate dateWithTimeIntervalSince1970:time]]; 2558 2587 } 2559 2588 }
