Changeset 3484
- Timestamp:
- 12/24/06 23:39:31 (2 years ago)
- Files:
-
- trunk/Chat Core/MVChatConnection.m (modified) (5 diffs)
- trunk/Chat Core/MVChatUserWatchRule.m (modified) (1 diff)
- trunk/Controllers/MVBuddyListController.h (modified) (1 diff)
- trunk/Controllers/MVBuddyListController.m (modified) (8 diffs)
- trunk/Inspectors/JVBuddyInspector.m (modified) (2 diffs)
- trunk/Models/JVBuddy.h (modified) (5 diffs)
- trunk/Models/JVBuddy.m (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core/MVChatConnection.m
r3457 r3484 921 921 if( [user _onlineNotificationSent] ) return; 922 922 if( [user isWatched] || [self _watchRulesMatchingUser:user] ) { 923 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionWatchedUserOnlineNotification object:user userInfo:nil];924 923 [user _setOnlineNotificationSent:YES]; 925 924 [user _setDateDisconnected:nil]; … … 928 927 if( ! [user dateDisconnected] ) 929 928 [user _setDateConnected:[NSDate date]]; 929 930 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionWatchedUserOnlineNotification object:user userInfo:nil]; 930 931 } 931 932 } … … 934 935 if( ! [user _onlineNotificationSent] ) return; 935 936 if( [user isWatched] ) { 936 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionWatchedUserOfflineNotification object:user userInfo:nil];937 937 [user _setOnlineNotificationSent:NO]; 938 938 [user _setWatched:NO]; … … 941 941 [user _setDateDisconnected:[NSDate date]]; 942 942 [user _setStatus:MVChatUserOfflineStatus]; 943 944 [user retain]; // retain since removeMatchedUser might hold the last reference 943 945 944 946 @synchronized( _chatUserWatchRules ) { … … 948 950 [rule removeMatchedUser:user]; 949 951 } 952 953 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionWatchedUserOfflineNotification object:user userInfo:nil]; 954 955 [user release]; 950 956 } 951 957 } trunk/Chat Core/MVChatUserWatchRule.m
r3457 r3484 37 37 - (NSDictionary *) dictionaryRepresentation { 38 38 NSMutableDictionary *dictionary = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:5]; 39 if( _username ) [dictionary setObject:_ nickname forKey:@"username"];39 if( _username ) [dictionary setObject:_username forKey:@"username"]; 40 40 if( _nickname ) [dictionary setObject:_nickname forKey:@"nickname"]; 41 if( _realName ) [dictionary setObject:_ nickname forKey:@"realName"];42 if( _address ) [dictionary setObject:_ nicknameforKey:@"address"];43 if( _publicKey ) [dictionary setObject:_ nicknameforKey:@"publicKey"];41 if( _realName ) [dictionary setObject:_realName forKey:@"realName"]; 42 if( _address ) [dictionary setObject:_address forKey:@"address"]; 43 if( _publicKey ) [dictionary setObject:_publicKey forKey:@"publicKey"]; 44 44 if( _interim ) [dictionary setObject:[NSNumber numberWithBool:_interim] forKey:@"interim"]; 45 45 if( _applicableServerDomains ) [dictionary setObject:_applicableServerDomains forKey:@"applicableServerDomains"]; trunk/Controllers/MVBuddyListController.h
r3072 r3484 53 53 + (MVBuddyListController *) sharedBuddyList; 54 54 55 - (void) save; 56 55 57 - (IBAction) getInfo:(id) sender; 56 58 trunk/Controllers/MVBuddyListController.m
r3460 r3484 19 19 20 20 @interface MVBuddyListController (MVBuddyListControllerPrivate) 21 - (void) _saveBuddyList;22 21 - (void) _loadBuddyList; 23 22 - (void) _sortBuddies; … … 78 77 79 78 - (void) dealloc { 80 [self _saveBuddyList];79 [self save]; 81 80 82 81 [[NSNotificationCenter defaultCenter] removeObserver:self]; … … 129 128 [buddies reloadData]; 130 129 [self _setBuddiesNeedSortAnimated]; 130 } 131 132 #pragma mark - 133 134 - (void) save { 135 NSMutableArray *list = [[NSMutableArray allocWithZone:nil] initWithCapacity:[_buddyList count]]; 136 NSEnumerator *enumerator = [_buddyList objectEnumerator]; 137 JVBuddy *buddy = nil; 138 139 while( ( buddy = [enumerator nextObject] ) ) { 140 NSDictionary *buddyRep = [buddy dictionaryRepresentation]; 141 if( buddyRep ) [list addObject:buddyRep]; 142 } 143 144 [list writeToFile:[@"~/Library/Application Support/Colloquy/Buddy List.plist" stringByExpandingTildeInPath] atomically:YES]; 145 [list release]; 131 146 } 132 147 … … 233 248 // JVBuddy *buddy = [JVBuddy buddyWithPerson:person]; 234 249 // [self _addBuddyToList:buddy]; 235 [self _saveBuddyList];250 [self save]; 236 251 } 237 252 } … … 338 353 // JVBuddy *buddy = [JVBuddy buddyWithPerson:person]; 339 354 // [self _addBuddyToList:buddy]; 340 [self _saveBuddyList];355 [self save]; 341 356 } 342 357 … … 583 598 [buddy release]; 584 599 [self _manuallySortAndUpdate]; 585 [self _saveBuddyList];600 [self save]; 586 601 } 587 602 … … 966 981 } 967 982 968 - (void) _saveBuddyList {969 NSMutableArray *list = [[NSMutableArray allocWithZone:nil] initWithCapacity:[_buddyList count]];970 NSEnumerator *enumerator = [_buddyList objectEnumerator];971 JVBuddy *buddy = nil;972 973 while( ( buddy = [enumerator nextObject] ) )974 [list addObject:[buddy dictionaryRepresentation]];975 976 [list writeToFile:[@"~/Library/Application Support/Colloquy/Buddy List.plist" stringByExpandingTildeInPath] atomically:YES];977 [list release];978 }979 980 983 - (void) _loadBuddyList { 981 984 NSArray *list = [[NSArray allocWithZone:nil] initWithContentsOfFile:[@"~/Library/Application Support/Colloquy/Buddy List.plist" stringByExpandingTildeInPath]]; … … 1029 1032 [buddy release]; 1030 1033 [self _manuallySortAndUpdate]; 1031 [self _saveBuddyList];1034 [self save]; 1032 1035 } 1033 1036 trunk/Inspectors/JVBuddyInspector.m
r3418 r3484 1 1 #import "MVConnectionsController.h" 2 #import "MVBuddyListController.h" 2 3 #import "JVBuddyInspector.h" 3 4 … … 83 84 - (BOOL) shouldUnload { 84 85 [[view window] makeFirstResponder:view]; 86 [[MVBuddyListController sharedBuddyList] save]; 85 87 return YES; 86 88 } trunk/Models/JVBuddy.h
r3418 r3484 10 10 11 11 @class ABPerson; 12 @class MVChatUserWatchRule;13 12 14 13 extern NSString * const JVBuddyAddressBookIRCNicknameProperty; … … 26 25 NSMutableArray *_users; 27 26 MVChatUser *_activeUser; 27 NSImage *_picture; 28 NSString *_firstName; 29 NSString *_lastName; 30 NSString *_primaryEmail; 31 NSString *_givenNickname; 32 NSString *_speechVoice; 33 NSString *_uniqueIdentifier; 28 34 } 29 35 + (JVBuddyName) preferredName; … … 33 39 - (NSDictionary *) dictionaryRepresentation; 34 40 41 - (void) registerWithConnection:(MVChatConnection *) connection; 35 42 - (void) registerWithApplicableConnections; 43 - (void) unregisterWithConnection:(MVChatConnection *) connection; 36 44 - (void) unregisterWithApplicableConnections; 37 45 … … 65 73 - (NSString *) givenNickname; 66 74 - (NSString *) speechVoice; 75 - (NSString *) uniqueIdentifier; 67 76 68 77 - (void) setFirstName:(NSString *) name; … … 71 80 - (void) setGivenNickname:(NSString *) name; 72 81 - (void) setSpeechVoice:(NSString *) voice; 73 - (NSString *) uniqueIdentifier;74 - (ABPerson *) person;75 82 83 - (ABPerson *) addressBookPersonRecord; 76 84 - (void) editInAddressBook; 77 85 - (void) viewInAddressBook; trunk/Models/JVBuddy.m
r3418 r3484 1 1 #import "JVBuddy.h" 2 2 #import "MVConnectionsController.h" 3 4 #import <ChatCore/NSStringAdditions.h> 3 5 4 6 NSString *JVBuddyCameOnlineNotification = @"JVBuddyCameOnlineNotification"; … … 30 32 - (id) initWithDictionaryRepresentation:(NSDictionary *) dictionary { 31 33 if( ( self = [super init] ) ) { 32 _rules = [[NSMutableArray allocWithZone:nil] initWithCapacity: 10];34 _rules = [[NSMutableArray allocWithZone:nil] initWithCapacity:5]; 33 35 _users = [[NSMutableArray allocWithZone:nil] initWithCapacity:5]; 34 _activeUser = nil; 36 37 NSData *data = [dictionary objectForKey:@"picture"]; 38 if( [data isKindOfClass:[NSData class]] && [data length] ) 39 _picture = [[NSKeyedUnarchiver unarchiveObjectWithData:data] retain]; 40 41 NSString *string = [dictionary objectForKey:@"firstName"]; 42 if( [string isKindOfClass:[NSString class]] ) 43 _firstName = [string copyWithZone:nil]; 44 45 string = [dictionary objectForKey:@"lastName"]; 46 if( [string isKindOfClass:[NSString class]] ) 47 _lastName = [string copyWithZone:nil]; 48 49 string = [dictionary objectForKey:@"primaryEmail"]; 50 if( [string isKindOfClass:[NSString class]] ) 51 _primaryEmail = [string copyWithZone:nil]; 52 53 string = [dictionary objectForKey:@"givenNickname"]; 54 if( [string isKindOfClass:[NSString class]] ) 55 _givenNickname = [string copyWithZone:nil]; 56 57 string = [dictionary objectForKey:@"speechVoice"]; 58 if( [string isKindOfClass:[NSString class]] ) 59 _speechVoice = [string copyWithZone:nil]; 60 61 string = [dictionary objectForKey:@"uniqueIdentifier"]; 62 if( [string isKindOfClass:[NSString class]] ) 63 _uniqueIdentifier = [string copyWithZone:nil]; 64 if( ! [_uniqueIdentifier length] ) 65 _uniqueIdentifier = [[NSString locallyUniqueString] retain]; 66 67 string = [dictionary objectForKey:@"addressBookPersonRecord"]; 68 if( [string isKindOfClass:[NSString class]] ) 69 _person = [[[ABAddressBook sharedAddressBook] recordForUniqueId:string] retain]; 35 70 36 71 NSEnumerator *enumerator = [[dictionary objectForKey:@"rules"] objectEnumerator]; 37 72 NSDictionary *ruleDictionary = nil; 38 73 while( ( ruleDictionary = [enumerator nextObject] ) ) { 39 MVChatUserWatchRule *rule = [[MVChatUserWatchRule allocWithZone: [self zone]] initWithDictionaryRepresentation:ruleDictionary];74 MVChatUserWatchRule *rule = [[MVChatUserWatchRule allocWithZone:nil] initWithDictionaryRepresentation:ruleDictionary]; 40 75 if( rule ) [self addWatchRule:rule]; 41 76 [rule release]; … … 60 95 [_users release]; 61 96 [_activeUser release]; 97 [_picture release]; 98 [_firstName release]; 99 [_lastName release]; 100 [_primaryEmail release]; 101 [_givenNickname release]; 102 [_speechVoice release]; 103 [_uniqueIdentifier release]; 62 104 63 105 _person = nil; … … 65 107 _rules = nil; 66 108 _activeUser = nil; 109 _picture = nil; 110 _firstName = nil; 111 _lastName = nil; 112 _primaryEmail = nil; 113 _givenNickname = nil; 114 _speechVoice = nil; 115 _uniqueIdentifier = nil; 67 116 68 117 [super dealloc]; … … 72 121 73 122 - (NSDictionary *) dictionaryRepresentation { 74 NSMutableDictionary *dictionary = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:5]; 75 [dictionary setObject:_rules forKey:@"rules"]; 76 return dictionary; 77 } 78 79 #pragma mark - 123 NSMutableDictionary *dictionary = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:8]; 124 125 NSEnumerator *enumerator = [_rules objectEnumerator]; 126 NSMutableArray *rules = [[NSMutableArray allocWithZone:nil] initWithCapacity:[_rules count]]; 127 MVChatUserWatchRule *rule = nil; 128 129 while( ( rule = [enumerator nextObject] ) ) { 130 NSDictionary *dictRep = [rule dictionaryRepresentation]; 131 if( dictRep ) [rules addObject:dictRep]; 132 } 133 134 [dictionary setObject:rules forKey:@"rules"]; 135 [rules release]; 136 137 if( _picture ) { 138 NSData *imageData = [NSKeyedArchiver archivedDataWithRootObject:_picture]; 139 if( imageData ) [dictionary setObject:imageData forKey:@"picture"]; 140 } 141 142 if( _firstName ) 143 [dictionary setObject:_firstName forKey:@"firstName"]; 144 145 if( _lastName ) 146 [dictionary setObject:_lastName forKey:@"lastName"]; 147 148 if( _primaryEmail ) 149 [dictionary setObject:_primaryEmail forKey:@"primaryEmail"]; 150 151 if( _givenNickname ) 152 [dictionary setObject:_givenNickname forKey:@"givenNickname"]; 153 154 if( _speechVoice ) 155 [dictionary setObject:_speechVoice forKey:@"speechVoice"]; 156 157 if( _uniqueIdentifier ) 158 [dictionary setObject:_uniqueIdentifier forKey:@"uniqueIdentifier"]; 159 160 if( _person && [_person uniqueId] ) 161 [dictionary setObject:[_person uniqueId] forKey:@"addressBookPersonRecord"]; 162 163 return [dictionary autorelease]; 164 } 165 166 #pragma mark - 167 168 - (void) registerWithConnection:(MVChatConnection *) connection { 169 NSEnumerator *enumerator = [_rules objectEnumerator]; 170 MVChatUserWatchRule *rule = nil; 171 172 while( ( rule = [enumerator nextObject] ) ) { 173 if( [[rule applicableServerDomains] count] ) { 174 NSEnumerator *domainEnumerator = [[rule applicableServerDomains] objectEnumerator]; 175 NSString *domain = nil; 176 177 while( ( domain = [domainEnumerator nextObject] ) ) { 178 if( [[connection server] compare:domain options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch )] == NSOrderedSame ) { 179 [connection addChatUserWatchRule:rule]; 180 break; 181 } 182 } 183 } else [connection addChatUserWatchRule:rule]; 184 } 185 } 80 186 81 187 - (void) registerWithApplicableConnections { … … 105 211 } 106 212 213 - (void) unregisterWithConnection:(MVChatConnection *) connection { 214 NSEnumerator *enumerator = [_rules objectEnumerator]; 215 MVChatUserWatchRule *rule = nil; 216 217 while( ( rule = [enumerator nextObject] ) ) 218 [connection removeChatUserWatchRule:rule]; 219 } 220 107 221 - (void) unregisterWithApplicableConnections { 108 222 NSEnumerator *enumerator = [_rules objectEnumerator]; … … 110 224 111 225 while( ( rule = [enumerator nextObject] ) ) { 112 if( [[rule applicableServerDomains] count] ) { 113 NSEnumerator *domainEnumerator = [[rule applicableServerDomains] objectEnumerator]; 114 NSString *domain = nil; 115 116 while( ( domain = [domainEnumerator nextObject] ) ) { 117 NSEnumerator *connectionEnumerator = [[[MVConnectionsController defaultController] connectionsForServerAddress:domain] objectEnumerator]; 118 MVChatConnection *connection = nil; 119 120 while( ( connection = [connectionEnumerator nextObject] ) ) 121 [connection removeChatUserWatchRule:rule]; 122 } 123 } else { 124 NSEnumerator *connectionEnumerator = [[[MVConnectionsController defaultController] connections] objectEnumerator]; 125 MVChatConnection *connection = nil; 126 127 while( ( connection = [connectionEnumerator nextObject] ) ) 128 [connection removeChatUserWatchRule:rule]; 129 } 226 NSEnumerator *connectionEnumerator = [[[MVConnectionsController defaultController] connections] objectEnumerator]; 227 MVChatConnection *connection = nil; 228 229 while( ( connection = [connectionEnumerator nextObject] ) ) 230 [connection removeChatUserWatchRule:rule]; 130 231 } 131 232 } … … 138 239 139 240 - (void) setActiveUser:(MVChatUser *) user { 140 [_activeUser autorelease];241 id old = _activeUser; 141 242 _activeUser = [user retain]; 243 [old release]; 142 244 } 143 245 … … 155 257 156 258 - (BOOL) isOnline { 157 return ( [_users count] > 0 ? YES : NO);259 return ( [_users count] > 0 ); 158 260 } 159 261 … … 178 280 default: 179 281 case JVBuddyFullName: 180 return [self compositeName]; 282 if( [[self compositeName] length] ) 283 return [self compositeName]; 181 284 case JVBuddyGivenNickname: 182 285 if( [[self givenNickname] length] ) … … 216 319 217 320 - (NSImage *) picture { 218 return [[[NSImage alloc] initWithData:[_person imageData]] autorelease]; 321 if( _picture ) 322 return _picture; 323 if( _person ) 324 return [[[NSImage alloc] initWithData:[_person imageData]] autorelease]; 325 return nil; 219 326 } 220 327 221 328 - (void) setPicture:(NSImage *) picture { 222 [_person setImageData:[picture TIFFRepresentation]]; 329 id old = _picture; 330 _picture = [picture copyWithZone:nil]; 331 [old release]; 223 332 } 224 333 … … 229 338 NSString *lastName = [self lastName]; 230 339 231 if( ! firstName && lastName ) return lastName; 232 else if( firstName && ! lastName ) return firstName; 233 else if( firstName && lastName ) { 340 if( ! [firstName length] && [lastName length] ) 341 return lastName; 342 if( [firstName length] && ! [lastName length] ) 343 return firstName; 344 if( [firstName length] && [lastName length] ) 234 345 return [NSString stringWithFormat:@"%@ %@", firstName, lastName]; 235 }236 346 237 347 firstName = [self givenNickname]; 238 if( [firstName length] ) return firstName; 348 if( [firstName length] ) 349 return firstName; 239 350 240 351 return [[self activeUser] nickname]; … … 242 353 243 354 - (NSString *) firstName { 244 return [_person valueForProperty:kABFirstNameProperty]; 355 if( _firstName ) return _firstName; 356 if( _person ) return [_person valueForProperty:kABFirstNameProperty]; 357 return nil; 245 358 } 246 359 247 360 - (NSString *) lastName { 248 return [_person valueForProperty:kABLastNameProperty]; 361 if( _lastName ) return _lastName; 362 if( _person ) return [_person valueForProperty:kABLastNameProperty]; 363 return nil; 249 364 } 250 365 251 366 - (NSString *) primaryEmail { 252 ABMultiValue *value = [_person valueForProperty:kABEmailProperty]; 253 return [value valueAtIndex:[value indexForIdentifier:[value primaryIdentifier]]]; 367 if( _primaryEmail ) return _primaryEmail; 368 369 if( _person ) { 370 ABMultiValue *value = [_person valueForProperty:kABEmailProperty]; 371 return [value valueAtIndex:[value indexForIdentifier:[value primaryIdentifier]]]; 372 } 373 374 return nil; 254 375 } 255 376 256 377 - (NSString *) givenNickname { 257 return [_person valueForProperty:kABNicknameProperty]; 378 if( _givenNickname ) return _givenNickname; 379 if( _person ) return [_person valueForProperty:kABNicknameProperty]; 380 return nil; 258 381 } 259 382 260 383 - (NSString *) speechVoice { 261 return [_person valueForProperty:JVBuddyAddressBookSpeechVoiceProperty]; 384 return _speechVoice; 385 } 386 387 - (NSString *) uniqueIdentifier { 388 return _uniqueIdentifier; 262 389 } 263 390 … … 265 392 266 393 - (void) setFirstName:(NSString *) name { 267 [_person setValue:name forProperty:kABFirstNameProperty]; 268 [[ABAddressBook sharedAddressBook] save]; 394 id old = _firstName; 395 _firstName = [name copyWithZone:nil]; 396 [old release]; 269 397 } 270 398 271 399 - (void) setLastName:(NSString *) name { 272 [_person setValue:name forProperty:kABLastNameProperty]; 273 [[ABAddressBook sharedAddressBook] save]; 400 id old = _lastName; 401 _lastName = [name copyWithZone:nil]; 402 [old release]; 274 403 } 275 404 276 405 - (void) setPrimaryEmail:(NSString *) email { 277 ABMutableMultiValue *value = [[[_person valueForProperty:kABEmailProperty] mutableCopy] autorelease]; 278 279 if( ! value ) { 280 value = [[[ABMutableMultiValue alloc] init] autorelease]; 281 [value addValue:email withLabel:kABOtherLabel]; 282 } else [value replaceValueAtIndex:[value indexForIdentifier:[value primaryIdentifier]] withValue:email]; 283 284 [_person setValue:value forProperty:kABEmailProperty]; 285 [[ABAddressBook sharedAddressBook] save]; 406 id old = _primaryEmail; 407 _primaryEmail = [email copyWithZone:nil]; 408 [old release]; 286 409 } 287 410 288 411 - (void) setGivenNickname:(NSString *) name { 289 [_person setValue:name forProperty:kABNicknameProperty]; 290 [[ABAddressBook sharedAddressBook] save]; 412 id old = _givenNickname; 413 _givenNickname = [name copyWithZone:nil]; 414 [old release]; 291 415 } 292 416 293 417 - (void) setSpeechVoice:(NSString *) voice { 294 if( [voice length] ) [_person setValue:voice forProperty:JVBuddyAddressBookSpeechVoiceProperty]; 295 else [_person removeValueForProperty:JVBuddyAddressBookSpeechVoiceProperty]; 296 [[ABAddressBook sharedAddressBook] save]; 297 } 298 299 #pragma mark - 300 301 - (NSString *) uniqueIdentifier { 302 return [_person uniqueId]; 303 } 304 305 - (ABPerson *) person { 418 id old = _speechVoice; 419 _speechVoice = [voice copyWithZone:nil]; 420 [old release]; 421 } 422 423 #pragma mark - 424 425 - (ABPerson *) addressBookPersonRecord { 306 426 return _person; 307 427 } … … 410 530 [_users addObject:user]; 411 531 412 if( [self status] != MVChatUserAvailableStatus ||[self status] != MVChatUserAwayStatus ) [self setActiveUser:user];532 if( [self status] != MVChatUserAvailableStatus && [self status] != MVChatUserAwayStatus ) [self setActiveUser:user]; 413 533 if( cameOnline ) [[NSNotificationCenter defaultCenter] postNotificationName:JVBuddyCameOnlineNotification object:self userInfo:nil]; 414 534 } … … 418 538 [_users removeObject:user]; 419 539 420 if( [[self activeUser] isEqualToChatUser:user] ) { 421 if( [_users count] ) [self setActiveUser:[_users lastObject]]; 422 else [self setActiveUser:nil]; 423 } 540 if( [[self activeUser] isEqualToChatUser:user] ) 541 [self setActiveUser:[_users lastObject]]; 424 542 425 543 if( ! [_users count] ) [[NSNotificationCenter defaultCenter] postNotificationName:JVBuddyWentOfflineNotification object:self userInfo:nil]; … … 440 558 - (void) _registerWithConnection:(NSNotification *) notification { 441 559 MVChatConnection *connection = [notification object]; 442 NSEnumerator *enumerator = [_rules objectEnumerator]; 443 MVChatUserWatchRule *rule = nil; 444 445 while( ( rule = [enumerator nextObject] ) ) { 446 if( [[rule applicableServerDomains] count] ) { 447 NSEnumerator *domainEnumerator = [[rule applicableServerDomains] objectEnumerator]; 448 NSString *domain = nil; 449 450 while( ( domain = [domainEnumerator nextObject] ) ) { 451 if( [[connection server] compare:domain options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch )] == NSOrderedSame ) 452 [connection addChatUserWatchRule:rule]; 453 } 454 } else [connection addChatUserWatchRule:rule]; 455 } 560 [self registerWithConnection:connection]; 456 561 } 457 562 … … 461 566 MVChatUser *user = nil; 462 567 463 while( ( user = [enumerator nextObject] ) ) {464 if( [[user connection] isEqual:connection] ) {568 while( ( user = [enumerator nextObject] ) ) 569 if( [[user connection] isEqual:connection] ) 465 570 [_users removeObject:user]; 466 if( ! [_users count] ) [[NSNotificationCenter defaultCenter] postNotificationName:JVBuddyWentOfflineNotification object:self userInfo:nil];467 }468 }469 571 470 572 if( [[[self activeUser] connection] isEqual:connection] ) 471 573 [self setActiveUser:[_users lastObject]]; 574 575 if( ! [_users count] ) 576 [[NSNotificationCenter defaultCenter] postNotificationName:JVBuddyWentOfflineNotification object:self userInfo:nil]; 472 577 } 473 578 … … 475 580 MVChatUser *user = [[notification userInfo] objectForKey:@"user"]; 476 581 477 [_users addObject:user]; 478 if( ! [self activeUser] ) 479 [self setActiveUser:user]; 480 481 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _buddyOnline: ) name:MVChatConnectionWatchedUserOfflineNotification object:user]; 582 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _buddyOnline: ) name:MVChatConnectionWatchedUserOnlineNotification object:user]; 482 583 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _buddyOffline: ) name:MVChatConnectionWatchedUserOfflineNotification object:user]; 483 584 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _buddyIdleUpdate: ) name:MVChatUserIdleTimeUpdatedNotification object:user];
