4 * A Cocoa wrapper for scripting components.
6 * Original Author : Kent Sutherland <ksutherland@ithinksw.com>
7 * Responsibility : Kent Sutherland <ksutherland@ithinksw.com>
8 * Responsibility : Joseph Spiros <joseph.spiros@ithinksw.com>
10 * Copyright (c) 2002 - 2004 iThink Software.
15 #import "ITOSAComponent.h"
17 @implementation ITOSAComponent
19 + (NSArray *)availableComponents
21 Component currentComponent = 0;
22 ComponentDescription cd;
24 cd.componentType = kOSAComponentType;
25 cd.componentSubType = 0;
26 cd.componentManufacturer = 0;
27 cd.componentFlags = 0;
28 cd.componentFlagsMask = 0;
30 while ((currentComponent = FindNextComponent(0, &cd)) != 0) {
32 return [NSArray array];
35 - (id)initWithSubtype:(unsigned long)subtype
37 ComponentDescription cd;
38 cd.componentType = kOSAComponentType;
39 cd.componentSubType = subtype;
40 cd.componentManufacturer = 0;
41 cd.componentFlags = 0;
42 cd.componentFlagsMask = 0;
43 Component temp = FindNextComponent(0, &cd);
44 if ( (self = [self initWithComponent:temp]) ) {
49 - (id)initWithComponent:(Component)component;
51 if ( (self = [super init]) ) {
52 Handle componentName = NewHandle(0);
53 Handle componentInfo = NewHandle(0);
54 ComponentDescription description;
55 NSMutableDictionary *information;
57 _component = component;
58 _componentInstance = OpenComponent(component);
60 if (GetComponentInfo(component, &description, componentName, componentInfo, nil) != 0) {
61 NSLog(@"FATAL ERROR!");
65 information = [[NSMutableDictionary alloc] init];
66 [information setObject:[[[NSString alloc] initWithBytes:componentName length:GetHandleSize(componentName) encoding:NSASCIIStringEncoding] autorelease] forKey:@"ITComponentName"];
67 [information setObject:[[[NSString alloc] initWithBytes:componentInfo length:GetHandleSize(componentInfo) encoding:NSASCIIStringEncoding] autorelease] forKey:@"ITComponentInfo"];
68 [information setObject:[NSNumber numberWithUnsignedLong:description.componentSubType] forKey:@"ITComponentSubtype"];
69 [information setObject:[NSNumber numberWithUnsignedLong:description.componentManufacturer] forKey:@"ITComponentManufacturer"];
77 [_information release];
80 - (Component)component
85 - (ComponentInstance)componentInstance
87 return _componentInstance;
90 - (NSDictionary *)information