#import <Cocoa/Cocoa.h>
#import <ITFoundation/ITOSAScript.h>
+#import <ITFoundation/ITOSAComponent.h>
#import <ITFoundation/ITAppleEventCenter.h>
#import <ITFoundation/ITDebug.h>
children = (
370786C005C0B4D700E6D1BA,
370786C105C0B4D700E6D1BA,
+ 37B9B08005C1C47E00702FDB,
+ 37B9B08105C1C47E00702FDB,
7CA50B2B054E77950074E1D9,
7CA50B2C054E77950074E1D9,
7CA50B2F054E77A00074E1D9,
settings = {
};
};
+ 37B9B08005C1C47E00702FDB = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = ITOSAComponent.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 37B9B08105C1C47E00702FDB = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = ITOSAComponent.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 37B9B08205C1C47E00702FDB = {
+ fileRef = 37B9B08005C1C47E00702FDB;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Public,
+ );
+ };
+ };
+ 37B9B08305C1C47E00702FDB = {
+ fileRef = 37B9B08105C1C47E00702FDB;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
//370
//371
//372
7CA50D7E054E7C600074E1D9,
7CA50B2D054E77950074E1D9,
370786C205C0B4D700E6D1BA,
+ 37B9B08205C1C47E00702FDB,
7CA50B31054E77A00074E1D9,
3D2D8A13055E07D800F59C27,
2AB93A3205705A0C007E748F,
7CF6C939057D65BA007FEC13,
7C97DC2F05B614300013E85F,
370786C305C0B4D700E6D1BA,
+ 37B9B08305C1C47E00702FDB,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
--- /dev/null
+/*
+ * ITFoundation
+ * ITOSAComponent
+ * A Cocoa wrapper for scripting components.
+ *
+ * Original Author : Kent Sutherland <ksutherland@ithinksw.com>
+ * Responsibility : Kent Sutherland <ksutherland@ithinksw.com>
+ * Responsibility : Joseph Spiros <joseph.spiros@ithinksw.com>
+ *
+ * Copyright (c) 2002 - 2004 iThink Software.
+ * All Rights Reserved
+ *
+ */
+
+#import <Foundation/Foundation.h>
+#import <Carbon/Carbon.h>
+
+@interface ITOSAComponent : NSObject {
+ Component _component;
+ ComponentInstance _componentInstance;
+ NSDictionary *_information;
+}
++ (NSArray *)availableComponents;
+
+- (id)initWithSubtype:(unsigned long)subtype;
+- (id)initWithComponent:(Component)component;
+
+- (Component)component;
+- (ComponentInstance)componentInstance;
+- (NSDictionary *)information;
+
+@end
--- /dev/null
+/*
+ * ITFoundation
+ * ITOSAComponent
+ * A Cocoa wrapper for scripting components.
+ *
+ * Original Author : Kent Sutherland <ksutherland@ithinksw.com>
+ * Responsibility : Kent Sutherland <ksutherland@ithinksw.com>
+ * Responsibility : Joseph Spiros <joseph.spiros@ithinksw.com>
+ *
+ * Copyright (c) 2002 - 2004 iThink Software.
+ * All Rights Reserved
+ *
+ */
+
+#import "ITOSAComponent.h"
+
+@implementation ITOSAComponent
+
++ (NSArray *)availableComponents
+{
+ Component currentComponent = 0;
+ ComponentDescription cd;
+
+ cd.componentType = kOSAComponentType;
+ cd.componentSubType = 0;
+ cd.componentManufacturer = 0;
+ cd.componentFlags = 0;
+ cd.componentFlagsMask = 0;
+
+ while ((currentComponent = FindNextComponent(0, &cd)) != 0) {
+ }
+ return [NSArray array];
+}
+
+- (id)initWithSubtype:(unsigned long)subtype
+{
+ ComponentDescription cd;
+ cd.componentType = kOSAComponentType;
+ cd.componentSubType = subtype;
+ cd.componentManufacturer = 0;
+ cd.componentFlags = 0;
+ cd.componentFlagsMask = 0;
+ Component temp = FindNextComponent(0, &cd);
+ if ( (self = [self initWithComponent:temp]) ) {
+ }
+ return self;
+}
+
+- (id)initWithComponent:(Component)component;
+{
+ if ( (self = [super init]) ) {
+ Handle componentName = NewHandle(0);
+ Handle componentInfo = NewHandle(0);
+ ComponentDescription description;
+ NSMutableDictionary *information;
+
+ _component = component;
+ _componentInstance = OpenComponent(component);
+
+ if (GetComponentInfo(component, &description, componentName, componentInfo, nil) != 0) {
+ NSLog(@"FATAL ERROR!");
+ return nil;
+ }
+
+ information = [[NSMutableDictionary alloc] init];
+ [information setObject:[[[NSString alloc] initWithBytes:componentName length:GetHandleSize(componentName) encoding:NSASCIIStringEncoding] autorelease] forKey:@"ITComponentName"];
+ [information setObject:[[[NSString alloc] initWithBytes:componentInfo length:GetHandleSize(componentInfo) encoding:NSASCIIStringEncoding] autorelease] forKey:@"ITComponentInfo"];
+ [information setObject:[NSNumber numberWithUnsignedLong:description.componentSubType] forKey:@"ITComponentSubtype"];
+ [information setObject:[NSNumber numberWithUnsignedLong:description.componentManufacturer] forKey:@"ITComponentManufacturer"];
+
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [_information release];
+}
+
+- (Component)component
+{
+ return _component;
+}
+
+- (ComponentInstance)componentInstance
+{
+ return _componentInstance;
+}
+
+- (NSDictionary *)information
+{
+ return _information;
+}
+
+@end
#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>
+@class ITOSAComponent;
+
@interface ITOSAScript : NSObject {
NSString *_source;
- unsigned long _scriptSubtype;
+ ITOSAComponent *_component;
}
- (id)initWithContentsOfFile:(NSString *)path;
- (NSString *)source;
- (void)setSource:(NSString *)newSource;
-- (unsigned long)scriptSubtype;
-- (void)setScriptSubtype:(unsigned long)newSubtype;
+- (ITOSAComponent *)component;
+- (void)setComponent:(ITOSAComponent *)newComponent;
+
+- (BOOL)compile;
+- (BOOL)isCompiled;
- (NSString *)execute;
*/
#import "ITOSAScript.h"
+#import "ITOSAComponent.h"
@implementation ITOSAScript
{
if ( (self = [super init]) ) {
_source = nil;
- _scriptSubtype = kAppleScriptSubtype; //Default to AppleScript
}
return self;
}
{
if ( (self = [super init]) ) {
_source = [[NSString alloc] initWithContentsOfFile:path];
- _scriptSubtype = kAppleScriptSubtype; //Default to AppleScript
}
return self;
}
{
if ( (self = [super init]) ) {
[self setSource:source];
- _scriptSubtype = kAppleScriptSubtype; //Default to AppleScript
}
return self;
}
_source = [newSource copy];
}
-- (unsigned long)scriptSubtype
+- (ITOSAComponent *)component
{
- return _scriptSubtype;
+ return _component;
}
-- (void)setScriptSubtype:(unsigned long)newSubtype
+- (void)setComponent:(ITOSAComponent *)newComponent
{
- _scriptSubtype = newSubtype;
+ _component = newComponent;
+}
+
+- (BOOL)compile
+{
+ return NO;
+}
+
+- (BOOL)isCompiled
+{
+ return NO;
}
- (NSString *)execute
AECreateDesc(typeChar, [_source cString], [_source cStringLength], &scriptDesc);
- OSADoScript(OpenDefaultComponent(kOSAComponentType, _scriptSubtype), &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc);
+ OSADoScript([_component componentInstance], &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc);
length = AEGetDescDataSize(&resultDesc);
buffer = malloc(length);