Initial checkin.
5 // Created by Jens Alfke on 3/3/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
10 #import "iChatBridge.h"
12 @implementation IChatUtils
15 static iChatApplication *sIChatApp;
20 sIChatApp = [SBApplication applicationWithBundleIdentifier: @"com.apple.iChat"];
21 sIChatApp.timeout = 5*60; // in ticks
26 + (SBApplication*) app {return sIChatApp;}
27 + (BOOL) isRunning {return sIChatApp.isRunning;}
28 + (void) activate {[sIChatApp activate];}
31 + (iChatTextChat*) activeChat
33 if( ! [sIChatApp isRunning] )
35 SBElementArray *chats = sIChatApp.textChats;
38 iChatTextChat *chat = [chats objectAtIndex: 0];
44 + (NSString*) activeChatPartner
46 iChatTextChat *chat = [self activeChat];
49 NSMutableArray *names = $marray();
50 for( iChatBuddy *b in [chat participants] )
51 [names addObject: (b.fullName ?: b.name)];
52 return [names componentsJoinedByString: @", "];
55 + (BOOL) sendMessage: (NSString*)msg
57 iChatTextChat *chat = [self activeChat];
60 [sIChatApp send: msg to: chat];