1.1 --- a/IChatUtils.m Sat May 24 13:24:33 2008 -0700
1.2 +++ b/IChatUtils.m Tue May 12 14:38:30 2009 +0200
1.3 @@ -90,18 +90,22 @@
1.4 return [self iChatInfoForOnlinePerson: abPerson] != nil;
1.5 }
1.6
1.7 -+ (iChatBuddy*) buddyWithInfo: (NSDictionary*)info
1.8 ++ (iChatBuddy*) buddyWithScreenName: (NSString*)screenName
1.9 {
1.10 - NSString *ident = [info objectForKey: IMPersonScreenNameKey];
1.11 - NSPredicate *pred = [NSPredicate predicateWithFormat: @"handle==%@", ident];
1.12 + NSPredicate *pred = [NSPredicate predicateWithFormat: @"handle==%@", screenName];
1.13 @try{
1.14 return [[[[sIChatApp buddies] filteredArrayUsingPredicate: pred] objectAtIndex: 0] get];
1.15 } @catch( NSException *x ) {
1.16 - Log(@"buddyWithInfo got exception: %@",x);
1.17 + Log(@"buddyWithScreenName got exception: %@",x);
1.18 }
1.19 return nil;
1.20 }
1.21
1.22 ++ (iChatBuddy*) buddyWithInfo: (NSDictionary*)info
1.23 +{
1.24 + return [self buddyWithScreenName: [info objectForKey: IMPersonScreenNameKey]];
1.25 +}
1.26 +
1.27 + (BOOL) sendMessage: (NSString*)msg toPerson: (ABPerson*)abPerson
1.28 {
1.29 NSDictionary *info = [self iChatInfoForOnlinePerson: abPerson];
1.30 @@ -116,6 +120,21 @@
1.31 }
1.32
1.33
1.34 ++ (BOOL) sendMessage: (NSString*)msg toBuddyWithScreenName: (NSString*)screenName
1.35 +{
1.36 + iChatBuddy *buddy = [self buddyWithScreenName: screenName];
1.37 + if( buddy ) {
1.38 + @try{
1.39 + [sIChatApp send: msg to: buddy];
1.40 + return YES;
1.41 + } @catch( NSException *x ) {
1.42 + Log(@"sendMessage:toBuddyWithScreenName: got exception: %@",x);
1.43 + }
1.44 + }
1.45 + return NO;
1.46 +}
1.47 +
1.48 +
1.49 @end
1.50
1.51