Changeset 3491
- Timestamp:
- 12/27/06 16:02:33 (2 years ago)
- Files:
-
- trunk/Controllers/MVBuddyListController.h (modified) (1 diff)
- trunk/Controllers/MVBuddyListController.m (modified) (4 diffs)
- trunk/Controllers/MVConnectionsController.m (modified) (3 diffs)
- trunk/Models/JVBuddy.h (modified) (2 diffs)
- trunk/Models/JVBuddy.m (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Controllers/MVBuddyListController.h
r3488 r3491 64 64 - (JVBuddy *) buddyForUser:(MVChatUser *) user; 65 65 - (NSArray *) buddies; 66 - (NS Array*) onlineBuddies;66 - (NSSet *) onlineBuddies; 67 67 68 68 - (IBAction) showBuddyPickerSheet:(id) sender; trunk/Controllers/MVBuddyListController.m
r3488 r3491 183 183 } 184 184 185 - (NS Array*) onlineBuddies {186 return [_onlineBuddies allObjects];185 - (NSSet *) onlineBuddies { 186 return _onlineBuddies; 187 187 } 188 188 … … 298 298 MVChatUserWatchRule *rule = [[MVChatUserWatchRule allocWithZone:nil] init]; 299 299 [rule setNickname:[nickname stringValue]]; 300 [rule setApplicableServerDomains:[_addServers allObjects]]; 300 301 NSMutableArray *newServers = [[NSMutableArray allocWithZone:nil] initWithCapacity:[_addServers count]]; 302 NSEnumerator *enumerator = [_addServers objectEnumerator]; 303 NSString *server = nil; 304 305 while( ( server = [enumerator nextObject] ) ) { 306 unsigned int ip = 0; 307 BOOL ipAddress = ( sscanf( [server UTF8String], "%u.%u.%u.%u", &ip, &ip, &ip, &ip ) == 4 ); 308 309 if( ! ipAddress ) { 310 NSArray *parts = [server componentsSeparatedByString:@"."]; 311 unsigned count = [parts count]; 312 if( count > 2 ) 313 server = [NSString stringWithFormat:@"%@.%@", [parts objectAtIndex:(count - 2)], [parts objectAtIndex:(count - 1)]]; 314 } 315 316 [newServers addObject:server]; 317 } 318 319 [rule setApplicableServerDomains:newServers]; 320 [newServers release]; 321 301 322 [buddy addWatchRule:rule]; 302 323 … … 624 645 } else if( [[column identifier] isEqualToString:@"switch"] ) { 625 646 JVBuddy *buddy = [_buddyOrder objectAtIndex:row]; 626 idusers = [buddy users];647 NSSet *users = [buddy users]; 627 648 628 649 if( [users count] >= 2 ) { … … 682 703 683 704 JVBuddy *buddy = [_buddyOrder objectAtIndex:row]; 684 id users = [buddy users]; 685 686 NSMutableArray *ordered = nil; 687 if( [users isKindOfClass:[NSArray class]] ) ordered = [users mutableCopyWithZone:nil]; 688 else if( [users isKindOfClass:[NSSet class]] ) ordered = [[users allObjects] mutableCopyWithZone:nil]; 689 705 NSSet *users = [buddy users]; 706 707 NSMutableArray *ordered = [[users allObjects] mutableCopyWithZone:nil]; 690 708 [ordered sortUsingSelector:@selector( compareByNickname: )]; 691 709 trunk/Controllers/MVConnectionsController.m
r3486 r3491 119 119 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _applicationQuitting: ) name:NSApplicationWillTerminateNotification object:nil]; 120 120 121 // do this later to catch modifier keys being held down to prevent automatic actions 122 [self performSelector:@selector( _loadBookmarkList ) withObject:nil afterDelay:0.]; 121 [self _loadBookmarkList]; 123 122 } 124 123 … … 567 566 id info = nil; 568 567 568 address = [address stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@". \t\n"]]; 569 569 570 while( ( info = [enumerator nextObject] ) ) { 570 571 MVChatConnection *connection = [info objectForKey:@"connection"]; 571 if( [[connection server] compare:address options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch )] == NSOrderedSame ) {572 if( [connection isConnected] )573 return connection;574 }572 NSString *server = [connection server]; 573 NSRange range = [server rangeOfString:address options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch ) range:NSMakeRange( 0, [server length] )]; 574 if( range.location != NSNotFound && ( range.location == 0 || [server characterAtIndex:( range.location - 1 )] == '.' ) ) 575 return connection; 575 576 } 576 577 … … 583 584 id info = nil; 584 585 585 while( ( info = [enumerator nextObject] ) ) 586 if( [[(MVChatConnection *)[info objectForKey:@"connection"] server] compare:address options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch )] == NSOrderedSame ) 587 [ret addObject:[info objectForKey:@"connection"]]; 586 address = [address stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@". \t\n"]]; 587 588 while( ( info = [enumerator nextObject] ) ) { 589 MVChatConnection *connection = [info objectForKey:@"connection"]; 590 NSString *server = [connection server]; 591 NSRange range = [server rangeOfString:address options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch ) range:NSMakeRange( 0, [server length] )]; 592 if( range.location != NSNotFound && ( range.location == 0 || [server characterAtIndex:( range.location - 1 )] == '.' ) ) 593 [ret addObject:connection]; 594 } 588 595 589 596 return ret; trunk/Models/JVBuddy.h
r3488 r3491 23 23 ABPerson *_person; 24 24 NSMutableArray *_rules; 25 NSMutable Array*_users;25 NSMutableSet *_users; 26 26 MVChatUser *_activeUser; 27 27 NSImage *_picture; … … 59 59 - (NSString *) nickname; 60 60 61 - (NS Array*) users;61 - (NSSet *) users; 62 62 63 63 - (NSArray *) watchRules; trunk/Models/JVBuddy.m
r3488 r3491 33 33 if( ( self = [super init] ) ) { 34 34 _rules = [[NSMutableArray allocWithZone:nil] initWithCapacity:5]; 35 _users = [[NSMutable ArrayallocWithZone:nil] initWithCapacity:5];35 _users = [[NSMutableSet allocWithZone:nil] initWithCapacity:5]; 36 36 _uniqueIdentifier = [[NSString locallyUniqueString] retain]; 37 37 … … 308 308 #pragma mark - 309 309 310 - (NS Array*) users {310 - (NSSet *) users { 311 311 return _users; 312 312 } … … 559 559 560 560 if( [[self activeUser] isEqualToChatUser:user] ) 561 [self setActiveUser:[_users lastObject]];561 [self setActiveUser:[_users anyObject]]; 562 562 563 563 if( ! [_users count] ) [[NSNotificationCenter defaultCenter] postNotificationName:JVBuddyWentOfflineNotification object:self userInfo:nil]; … … 591 591 592 592 if( [[[self activeUser] connection] isEqual:connection] ) 593 [self setActiveUser:[_users lastObject]];593 [self setActiveUser:[_users anyObject]]; 594 594 595 595 if( ! [_users count] )
