// // AsyncAskPassClient.m // Bienvenue // // Created by Hamish Allan on 04/06/2008. // Copyright 2008 Hamish Allan. All rights reserved. // #import "AsyncAskPassClient.h" #import "AsyncAskPassServer.h" @implementation AsyncAskPassClient - (id)init { self = [super init]; if (self) { myAsyncAskPassServer = [[NSConnection rootProxyForConnectionWithRegisteredName:AsyncAskPassServerName host:nil] retain]; if (!myAsyncAskPassServer) { [self release]; return nil; } [myAsyncAskPassServer setProtocolForProxy:@protocol(AsyncAskPassProtocol)]; [myAsyncAskPassServer askQuestion:[[[NSProcessInfo processInfo] arguments] objectAtIndex:1] fromClient:self]; } return self; } - (void)dealloc { [super dealloc]; [myAsyncAskPassServer release]; } - (NSString *)token { return [[[NSProcessInfo processInfo] environment] objectForKey:@"AsyncAskPassToken"]; } - (void)setAnswerText:(NSString *)answerText { if (answerText) { printf("%s\n", [answerText UTF8String]); exit(0); } else exit(-1); } @end