Changeset 2099
- Timestamp:
- 11/12/04 19:43:11 (4 years ago)
- Files:
-
- branches/overhaul/MVBuddyListController.m (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/overhaul/MVBuddyListController.m
r1948 r2099 302 302 [lastName setObjectValue:[person valueForProperty:kABLastNameProperty]]; 303 303 ABMultiValue *value = [person valueForProperty:kABEmailProperty]; 304 [email setObjectValue:[value valueAtIndex:[value indexForIdentifier:[value primaryIdentifier]]]]; 304 unsigned index = [value indexForIdentifier:[value primaryIdentifier]]; 305 if( index != NSNotFound ) [email setObjectValue:[value valueAtIndex:index]]; 305 306 [image setImage:[[[NSImage alloc] initWithData:[person imageData]] autorelease]]; 306 307 } … … 333 334 NSMutableDictionary *sub = nil; 334 335 335 if( [(NSString *)[firstName objectValue] length] || [(NSString *)[lastName objectValue] length] || [(NSString *)[email objectValue] length] ) 336 [info setObject:[firstName objectValue] forKey:@"First"]; 337 else [info setObject:[nickname objectValue] forKey:@"First"]; 338 if( [(NSString *)[lastName objectValue] length] ) [info setObject:[lastName objectValue] forKey:@"Last"]; 336 if( [(NSString *)[firstName objectValue] length] || [(NSString *)[lastName objectValue] length] || [(NSString *)[email objectValue] length] ) { 337 [info setObject:[firstName objectValue] forKey:kABFirstNameProperty]; 338 } else [info setObject:[nickname objectValue] forKey:kABFirstNameProperty]; 339 340 if( [(NSString *)[lastName objectValue] length] ) 341 [info setObject:[lastName objectValue] forKey:kABLastNameProperty]; 339 342 340 343 if( [(NSString *)[email objectValue] length] ) { … … 342 345 [sub setObject:[NSArray arrayWithObject:kABOtherLabel] forKey:@"labels"]; 343 346 [sub setObject:[NSArray arrayWithObject:[email objectValue]] forKey:@"values"]; 344 [info setObject:sub forKey: @"Email"];347 [info setObject:sub forKey:kABEmailProperty]; 345 348 } 346 349 … … 350 353 [info setObject:sub forKey:@"IRCNickname"]; 351 354 352 [info setObject:[NSString stringWithFormat:NSLocalizedString( @"IRC Nickname: %@ (%@)", "new buddy card note" ), [nickname objectValue], [server titleOfSelectedItem]] forKey: @"Note"];355 [info setObject:[NSString stringWithFormat:NSLocalizedString( @"IRC Nickname: %@ (%@)", "new buddy card note" ), [nickname objectValue], [server titleOfSelectedItem]] forKey:kABNoteProperty]; 353 356 354 357 person = [ABPerson personFromDictionary:info]; … … 363 366 [person setValue:value forProperty:@"IRCNickname"]; 364 367 365 if( [(NSString *)[firstName objectValue] length] || [(NSString *)[lastName objectValue] length] || [(NSString *)[email objectValue] length] ) 368 if( [(NSString *)[firstName objectValue] length] || [(NSString *)[lastName objectValue] length] || [(NSString *)[email objectValue] length] ) { 366 369 [person setValue:[firstName objectValue] forProperty:kABFirstNameProperty]; 367 else [person setValue:[nickname objectValue] forProperty:kABFirstNameProperty];370 } else [person setValue:[nickname objectValue] forProperty:kABFirstNameProperty]; 368 371 [person setValue:[lastName objectValue] forProperty:kABLastNameProperty]; 372 369 373 ABMutableMultiValue *emailValue = [[[person valueForProperty:kABEmailProperty] mutableCopy] autorelease]; 370 if( emailValue ) { 371 [emailValue replaceValueAtIndex:[emailValue indexForIdentifier:[emailValue primaryIdentifier]] withValue:[email objectValue]]; 374 unsigned index = [emailValue indexForIdentifier:[emailValue primaryIdentifier]]; 375 if( emailValue && index != NSNotFound ) { 376 [emailValue replaceValueAtIndex:index withValue:[email objectValue]]; 372 377 } else { 373 378 emailValue = [[[ABMutableMultiValue alloc] init] autorelease]; 374 379 [emailValue addValue:[email objectValue] withLabel:kABOtherLabel]; 375 380 } 381 376 382 [person setValue:emailValue forProperty:kABEmailProperty]; 377 383
