diff -r e5976864dfe9 -r 2befbe36c746 IChatUtils.m --- a/IChatUtils.m Sat May 24 13:24:33 2008 -0700 +++ b/IChatUtils.m Tue May 12 14:38:30 2009 +0200 @@ -90,18 +90,22 @@ return [self iChatInfoForOnlinePerson: abPerson] != nil; } -+ (iChatBuddy*) buddyWithInfo: (NSDictionary*)info ++ (iChatBuddy*) buddyWithScreenName: (NSString*)screenName { - NSString *ident = [info objectForKey: IMPersonScreenNameKey]; - NSPredicate *pred = [NSPredicate predicateWithFormat: @"handle==%@", ident]; + NSPredicate *pred = [NSPredicate predicateWithFormat: @"handle==%@", screenName]; @try{ return [[[[sIChatApp buddies] filteredArrayUsingPredicate: pred] objectAtIndex: 0] get]; } @catch( NSException *x ) { - Log(@"buddyWithInfo got exception: %@",x); + Log(@"buddyWithScreenName got exception: %@",x); } return nil; } ++ (iChatBuddy*) buddyWithInfo: (NSDictionary*)info +{ + return [self buddyWithScreenName: [info objectForKey: IMPersonScreenNameKey]]; +} + + (BOOL) sendMessage: (NSString*)msg toPerson: (ABPerson*)abPerson { NSDictionary *info = [self iChatInfoForOnlinePerson: abPerson]; @@ -116,6 +120,21 @@ } ++ (BOOL) sendMessage: (NSString*)msg toBuddyWithScreenName: (NSString*)screenName +{ + iChatBuddy *buddy = [self buddyWithScreenName: screenName]; + if( buddy ) { + @try{ + [sIChatApp send: msg to: buddy]; + return YES; + } @catch( NSException *x ) { + Log(@"sendMessage:toBuddyWithScreenName: got exception: %@",x); + } + } + return NO; +} + + @end