//
//  AppleScriptHandler.h
//  MaximusPluginTester
//
//  Created by Denis Gryzlov on 01.10.07.
//  Copyright 2007 Art Lebedev Studio. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@protocol AppleScriptHandlerProtocol
- (void) newWorkerSpawned:(id)worker;
- (void) takeResultBack:(id)result forToken:(NSString *)uuid;
@end

@protocol AppleScriptDelegateProtocol 
- (void) takeAppleScriptResult:(id)result forToken:(NSString *)uuid;
- (void) takeAppleEventResult:(id)result forToken:(NSString *)uuid;
@end

/* Single task keys in queue 
  -- (id)			@"delegate"		–>		object we have to return to
  -- (NSString *)	@"type"			–>		@"AppleScript" or @"AppleEvent"
  -- (id)			@"data"			->		specific data
  -- (NSString *)   @"uuid"			->		unique identifier
*/

@interface AppleScriptHandler : NSObject <AppleScriptHandlerProtocol> {
	NSMutableDictionary *myWorkers;
	NSMutableArray *workersInProgress;
	
	NSMutableDictionary *tasksUnderProgress;
	NSMutableArray *tasksQueue;
	id myWorker;
}

+ (AppleScriptHandler*)sharedAppleScriptHandler;
- (void) launchAppleScript:(NSString *)script andReturnTo:(id)delegate withToken:(NSString *)token;

@end
