+++ /dev/null
-/*
- * ITFoundation
- * ITAppleEvent
- *
- * Class that provides utilities for sending AppleEvents
- * (and OSA scripts) using Carbon function calls in Cocoa
- *
- * Original Author : Joseph Spiros <joseph.spiros@ithinksw.com>
- * Responsibility : Joseph Spiros <joseph.spiros@ithinksw.com>
- * : Kent Sutherland <kent.sutherland@ithinksw.com>
- *
- * Copyright (c) 2002 - 2003 iThink Software.
- * All Rights Reserved
- *
- */
-
-#import <Cocoa/Cocoa.h>
-#import <Carbon/Carbon.h>
-
-
-@interface ITAppleEvent : NSObject {
- long int osaScriptID;
- AppleEvent event, reply;
-}
-/*
- * INITIALIZATION METHODS - AppleScript
- *
- * These methods initialize an instance of ITAppleEvent
- * with AppleScript/OpenScripting data
- */
-- (id)initWithOSASource:(NSString *)source;
-- (id)initWithOSACompiledData:(NSData *)data;
-- (id)initWithOSAFromContentsOfURL:(NSURL *)url;
-- (id)initWithOSAFromContentsOfPath:(NSString *)path;
-/*
-`* INITIALIZATION METHODS - AppleEvent
- *
- * This method initializes an instance of ITAppleEvent
- * with an AppleEvent class (usually the creator id
- * of the AppleEvent's target) and an AppleEvent ID
- */
-- (id)initWithAppleEventClass:(AEEventClass)eventClass appleEventID:(AEEventID)eventID;
-/*
- * INSTANCE METHODS
- */
-- (NSString *)OSASource;
-- (void)setOSASource:(NSString *)source;
-- (NSData *)OSACompiledData;
-- (void)setOSACompiledData:(NSData *)data;
-- (AEEventClass)appleEventClass;
-- (AEEventID)appleEventID;
-- (NSString *)execute;
-@end
+++ /dev/null
-#import "ITAppleEvent.h"
-
-
-@implementation ITAppleEvent
-
-
-- (id)initWithOSASource:(NSString *)source
-{
-}
-- (id)initWithOSACompiledData:(NSData *)data
-{
-}
-- (id)initWithOSAFromContentsOfURL:(NSURL *)url
-{
-}
-- (id)initWithOSAFromContentsOfPath:(NSString *)path
-{
-}
-- (id)initWithAppleEventClass:(AEEventClass)eventClass appleEventID:(AEEventID)eventID
-{
- OSType AppType = eventClass;
- AEBuildAppleEvent(eventClass, eventID, typeApplSignature, &AppType, sizeof(AppType), kAutoGenerateReturnID, kAnyTransactionID, &event, nil, "");
-}
-- (NSString *)OSASource
-{
-}
-- (void)setOSASource:(NSString *)source
-{
-}
-- (NSData *)OSACompiledData
-{
-}
-- (void)setOSACompiledData:(NSData *)data
-{
-}
-- (AEEventClass)appleEventClass
-{
-}
-- (AEEventID)appleEventID
-{
-}
-- (NSString *)execute
-{
- AESend(&event, &reply, kAENoReply, kAENormalPriority, kAEDefaultTimeout, nil, nil);
- // AEDisposeDesc(&event);
- // AEDisposeDesc(&reply);
-}
-
-@end
+++ /dev/null
-/*
- * ITFoundation
- * ITAppleEventCenter
- * A class for sending and recieving AppleEvent data.
- * Who wants to mess with that Carbon shit anyway?
- *
- * Original Author : Joseph Spiros <joseph.spiros@ithinksw.com>
- * Responsibility : Matt Judy <mjudy@ithinksw.com>
- * Responsibility : Joseph Spiros <joseph.spiros@ithinksw.com>
- *
- * Copyright (c) 2002 - 2003 iThink Software.
- * All Rights Reserved
- *
- */
-
-#import <Foundation/Foundation.h>
-#import <Carbon/Carbon.h>
-
-
-@interface ITAppleEventCenter : NSObject {
- AEIdleUPP idleUPP;
-}
-+ (id)sharedCenter;
-- (NSString*)sendAEWithRequestedKey:(NSString*)key eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-- (long)sendAEWithRequestedKeyForNumber:(NSString*)key eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-- (AEArrayDataPointer)sendAEWithRequestedKeyForArray:(NSString*)key eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-
-
-- (NSString*)sendTwoTierAEWithRequestedKey:(NSString*)key fromObjectByKey:(NSString*)object eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-- (long)sendTwoTierAEWithRequestedKeyForNumber:(NSString*)key fromObjectByKey:(NSString*)object eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-
-- (NSString *)sendAEWithRequestedArray:(NSArray *)array eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-- (void)sendAEWithEventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-
-- (NSString*)sendAEWithSendString:(NSString*)nssendString eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-- (long)sendAEWithSendStringForNumber:(NSString*)string eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-- (AEArrayDataPointer)sendAEWithSendStringForArray:(NSString*)string eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-- (NSData*)sendAEWithSendStringForData:(NSString*)nssendString eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn;
-
-- (void)printCarbonDesc:(AEDesc*)desc;
-@end
+++ /dev/null
-#import "ITAppleEventCenter.h"
-#import "ITDebug.h"
-
-static Boolean MyAEIdleCallback (
- EventRecord * theEvent,
- SInt32 * sleepTime,
- RgnHandle * mouseRgn
- )
-{
- return FALSE;
-}
-
-@implementation ITAppleEventCenter
-
-static ITAppleEventCenter *_sharedAECenter = nil;
-
-+ (id)sharedCenter
-{
- if( _sharedAECenter ) {
- return _sharedAECenter;
- } else {
- return _sharedAECenter = [[ITAppleEventCenter alloc] init];
- }
-}
-
-- (id)init
-{
- if ( ( self = [super init] ) ) {
- idleUPP = NewAEIdleUPP(MyAEIdleCallback);
- }
- return self;
-}
-
-- (void)dealloc
-{
- DisposeAEIdleUPP(idleUPP);
-}
-
-- (NSString*)sendAEWithRequestedKey:(NSString*)key eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- //Add error checking...
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
- int pid;
- NSString *nssendString = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('%s'), from:'null'() }", [key UTF8String]];
- const char *sendString = [nssendString UTF8String];
- NSString *_finalString = nil;
-
- AppleEvent sendEvent, replyEvent;
-
- DescType resultType;
- Size resultSize, charResultSize;
-
- AEBuildError buildError;
- OSStatus err;
- OSErr berr, err2, err3;
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
- [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[nssendString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
-
- [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- unichar *result = 0;
-
- err2 = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
- if (resultSize != 0) {
- result = malloc(resultSize);
- } else {
- return nil;
- }
-
- if (err2) {
- ITDebugLog(@"Error After AESizeOfParam: %i", err2);
- } else {
- err3 = AEGetParamPtr(&replyEvent, keyDirectObject, resultType, NULL, result, resultSize, &charResultSize);
-
- if (err3) {
- ITDebugLog(@"Error After AEGetParamPtr: %i", err3);
- } else {
- _finalString = [NSString stringWithCharacters:result length:charResultSize/sizeof(unichar)];
- }
- }
- free(result);
- }
-
- if (!berr) AEDisposeDesc(&sendEvent);
- if (!err) AEDisposeDesc(&replyEvent);
-
- return _finalString;
-}
-
-- (NSString*)sendAEWithSendString:(NSString*)nssendString eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- //Add error checking...
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
- int pid;
-
- const char *sendString = [nssendString UTF8String];
- NSString *_finalString = nil;
-
- AppleEvent sendEvent, replyEvent;
-
- DescType resultType;
- Size resultSize, charResultSize;
-
- AEBuildError buildError;
- OSStatus berr,err;
- OSErr err2, err3;
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
- if (!berr) [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[nssendString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
- if (!err) [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- unichar *result = 0;
-
- err2 = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
- if (resultSize != 0) {
- result = malloc(resultSize);
- } else {
- return nil;
- }
-
- if (err2) {
- ITDebugLog(@"Error After AESizeOfParam: %i", err2);
- } else {
- err3 = AEGetParamPtr(&replyEvent, keyDirectObject, resultType, NULL, result, resultSize, &charResultSize);
-
- if (err3) {
- ITDebugLog(@"Error After AEGetParamPtr: %i", err3);
- } else {
- _finalString = [NSString stringWithCharacters:result length:charResultSize/sizeof(unichar)];
- }
- }
- free(result);
- }
-
- if (!berr) AEDisposeDesc(&sendEvent);
- if (!err) AEDisposeDesc(&replyEvent);
-
- return _finalString;
-}
-
-- (long)sendAEWithRequestedKeyForNumber:(NSString*)key eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- //Add error checking...
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
- int pid;
-
- NSString *nssendString = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('%s'), from:'null'() }", [key UTF8String]];
- const char *sendString = [nssendString UTF8String];
- long result = 0;
-
- AppleEvent sendEvent, replyEvent;
-
- DescType resultType;
- Size resultSize, charResultSize;
-
- AEBuildError buildError;
- OSStatus err;
- OSErr berr, err2, err3;
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
-
- [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[nssendString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
-
- [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- err2 = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
-
- if (err2) {
- ITDebugLog(@"Error After AESizeOfParam: %i", err2);
- } else {
- err3 = AEGetParamPtr(&replyEvent, keyDirectObject, resultType, NULL, &result, resultSize, &charResultSize);
-
- if (err3) {
- ITDebugLog(@"Error After AEGetParamPtr: %i", err3);
- }
- }
- }
-
- if (!berr) AEDisposeDesc(&sendEvent);
- if (!err) AEDisposeDesc(&replyEvent);
-
- return result;
-}
-
-- (NSString*)sendTwoTierAEWithRequestedKey:(NSString*)key fromObjectByKey:(NSString*)object eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
- int pid;
-
- NSString *nssendString = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('%s'), from:obj { form:'prop', want:type('prop'), seld:type('%s'), from:'null'() } }", [key UTF8String], [object UTF8String]];
- const char *sendString = [nssendString UTF8String];
- NSString *_finalString = nil;
-
- AppleEvent sendEvent, replyEvent;
-
- DescType resultType;
- Size resultSize, charResultSize;
-
- AEBuildError buildError;
- OSStatus berr,err;
- OSErr err2, err3;
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
-
- [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[nssendString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
-
- [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- unichar *result = 0;
-
- err2 = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
- if (resultSize != 0) {
- result = malloc(resultSize);
- } else {
- return nil;
- }
-
- if (err2) {
- ITDebugLog(@"Error After AESizeOfParam: %i", err2);
- } else {
- err3 = AEGetParamPtr(&replyEvent, keyDirectObject, resultType, NULL, result, resultSize, &charResultSize);
-
- if (err3) {
- ITDebugLog(@"Error After AEGetParamPtr: %i", err3);
- } else {
- _finalString = [NSString stringWithCharacters:result length:charResultSize/sizeof(unichar)];
- }
- }
- free(result);
- }
-
- if (!berr) AEDisposeDesc(&sendEvent);
- if (!err) AEDisposeDesc(&replyEvent);
-
- return _finalString;
-}
-
-- (long)sendTwoTierAEWithRequestedKeyForNumber:(NSString*)key fromObjectByKey:(NSString*)object eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
-
- NSString *nssendString = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('%s'), from:obj { form:'prop', want:type('prop'), seld:type('%s'), from:'null'() } }", [key UTF8String], [object UTF8String]];
- const char *sendString = [nssendString UTF8String];
- long result = 0;
-
- AppleEvent sendEvent, replyEvent;
- int pid;
-
- DescType resultType;
- Size resultSize, charResultSize;
-
- AEBuildError buildError;
- OSStatus berr, err;
- OSErr err2, err3;
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
-
- [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[nssendString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
-
- [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- err2 = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
-
- if (err2) {
- ITDebugLog(@"Error After AESizeOfParam: %i", err2);
- } else {
- err3 = AEGetParamPtr(&replyEvent, keyDirectObject, resultType, NULL, &result, resultSize, &charResultSize);
-
- if (err3) {
- ITDebugLog(@"Error After AEGetParamPtr: %i", err3);
- }
- }
- }
-
- if (!berr) AEDisposeDesc(&sendEvent);
- if (!err) AEDisposeDesc(&replyEvent);
-
- return result;
-}
-
-- (NSString *)sendAEWithRequestedArray:(NSArray *)array eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- NSString *buildString = [NSString stringWithFormat:@"{ form:'prop', want:type('prop'), seld:type('%s'), from:'null'() }", [[array objectAtIndex:0] UTF8String]];
- const char *sendString;
- int i;
- NSString *_finalString = nil;
- int pid;
-
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
-
- AppleEvent sendEvent, replyEvent;
-
- DescType resultType;
- Size resultSize, charResultSize;
-
- AEBuildError buildError;
- OSStatus berr, err;
- OSErr err2, err3;
-
- for (i = 1; i < [array count]; i++) {
- NSString *from = [NSString stringWithFormat:@"{ form:'prop', want:type('prop'), seld:type('%s'), from:obj %@ }",
- [[array objectAtIndex:i] UTF8String], buildString];
- buildString = from;
- }
- buildString = [@"'----':obj " stringByAppendingString:buildString];
- sendString = [buildString UTF8String];
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
-
- [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[buildString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
-
- [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- unichar *result = 0;
-
- err2 = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
- if (resultSize != 0) {
- result = malloc(resultSize);
- } else {
- return nil;
- }
- if (err2) {
- ITDebugLog(@"Error After AESizeOfParam: %i", err2);
- } else {
- err3 = AEGetParamPtr(&replyEvent, keyDirectObject, resultType, NULL, result, resultSize, &charResultSize);
- if (err3) {
- ITDebugLog(@"Error After AEGetParamPtr: %i", err3);
- } else {
- _finalString = [NSString stringWithCharacters:result length:charResultSize/sizeof(unichar)];
- }
- }
- free(result);
- }
- if (!berr) AEDisposeDesc(&sendEvent);
- if (!err) AEDisposeDesc(&replyEvent);
- return _finalString;
-}
-
-- (void)sendAEWithEventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
- AEDesc dest;
- int pid;
-
- AppleEvent event, reply;
- OSStatus cerr,cerr2,err;
- //AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, kAnyTransactionID, &event, nil, "");
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return;
- }
- cerr = AECreateDesc(typeProcessSerialNumber,(ProcessSerialNumber*)&psn,sizeof(ProcessSerialNumber),&dest);
- cerr2 = AECreateAppleEvent(eClass,eID,&dest,kAutoGenerateReturnID,kAnyTransactionID,&event);
- [self printCarbonDesc:&event];
- err = AESend(&event, &reply, kAENoReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, nil);
- [self printCarbonDesc:&reply];
- if (!cerr2) AEDisposeDesc(&dest);
- if (!cerr) AEDisposeDesc(&event);
- if (!err) AEDisposeDesc(&reply);
-}
-
-- (void)printCarbonDesc:(AEDesc*)desc {
- Handle xx;
- AEPrintDescToHandle(desc,&xx);
- ITDebugLog(@"AE Descriptor: %s", *xx);
- DisposeHandle(xx);
-}
-
-
-- (AEArrayDataPointer)sendAEWithRequestedKeyForArray:(NSString*)key eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
-
- NSString *nssendString = [NSString stringWithFormat:@"'----':obj { form:'indx', want:'%s', seld:type('all '), from:'null'() }", [key UTF8String]];
- const char *sendString = [nssendString UTF8String];
- AEArrayDataPointer result = nil;
- int pid;
-
- AppleEvent sendEvent, replyEvent;
-
-
- AEBuildError buildError;
- OSStatus err;
-
-if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
- err = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
-
- [self printCarbonDesc:&sendEvent];
-
- if (err) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[nssendString substringToIndex:buildError.fErrorPos]);
- }
-
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
-
- [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- SInt32 count, resultCount;
-
- AECountItems(&replyEvent,&count);
- if ((sizeof(AEDesc)*count) != 0) {
- result=malloc(sizeof(AEDesc)*count);
- } else {
- return nil;
- }
- AEGetArray(&replyEvent, kAEDescArray, result, sizeof(AEDesc)*count, NULL, NULL, &resultCount);
-
- free(result);
- }
-
- AEDisposeDesc(&sendEvent);
- AEDisposeDesc(&replyEvent);
-
- return result;
-}
-
-- (long)sendAEWithSendStringForNumber:(NSString*)string eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- //Add error checking...
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
-
- const char *sendString = [string UTF8String];
- SInt32 result = 0;
- int pid;
-
- AppleEvent sendEvent, replyEvent;
-
- DescType resultType;
- Size resultSize, charResultSize;
-
- AEBuildError buildError;
- OSStatus berr, err;
- OSErr err2, err3;
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
-
- [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[string substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
-
- [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- err2 = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
-
- if (err2) {
- ITDebugLog(@"Error After AESizeOfParam: %i", err2);
- } else {
- err3 = AEGetParamPtr(&replyEvent, keyDirectObject, resultType, NULL, &result, resultSize, &charResultSize);
-
- if (err3) {
- ITDebugLog(@"Error After AEGetParamPtr: %i", err3);
- }
- }
- }
-
-
-if (!berr) AEDisposeDesc(&sendEvent);
-if (!err) AEDisposeDesc(&replyEvent);
-ITDebugLog(@"waffles say %d",result);
-return result;
-}
-
-- (AEArrayDataPointer)sendAEWithSendStringForArray:(NSString*)string eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- //Add error checking...
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
- int pid;
-
- const char *sendString = [string UTF8String];
- AEArrayDataPointer result = NULL;
-
- AppleEvent sendEvent, replyEvent;
-
- AEBuildError buildError;
- OSStatus berr, err;
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
-
- [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[string substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
-
- [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- SInt32 count, resultCount;
-
- AECountItems(&replyEvent,&count);
- if ((sizeof(AEDesc)*count) != 0) {
- result=malloc(sizeof(AEDesc)*count);
- } else {
- return nil;
- }
- AEGetArray(&replyEvent, kAEDescArray, result, sizeof(AEDesc)*count, NULL, NULL, &resultCount);
-
- free(result);
- }
-
- if (!berr) AEDisposeDesc(&sendEvent);
- if (!err) AEDisposeDesc(&replyEvent);
-
- return result;
-}
-
-- (NSData*)sendAEWithSendStringForData:(NSString*)nssendString eventClass:(NSString*)eventClass eventID:(NSString*)eventID appPSN:(ProcessSerialNumber)psn
-{
- //Add error checking...
- AEEventClass eClass = *((unsigned long*)[eventClass UTF8String]);
- AEEventID eID = *((unsigned long*)[eventID UTF8String]);
- int pid;
-
- const char *sendString = [nssendString UTF8String];
- NSData *_finalData = nil;
-
- AppleEvent sendEvent, replyEvent;
-
- DescType resultType;
- Size resultSize, charResultSize;
-
- AEBuildError buildError;
- OSStatus berr,err;
- OSErr err2, err3;
-
- if ((GetProcessPID(&psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(eClass, eID, typeProcessSerialNumber,(ProcessSerialNumber*)&psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, sendString);
- if (!berr) [self printCarbonDesc:&sendEvent];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[nssendString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/30, idleUPP, NULL);
- if (!err) [self printCarbonDesc:&replyEvent];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- } else {
- unichar *result = 0;
-
- err2 = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
- if (resultSize != 0) {
- result = malloc(resultSize);
- } else {
- return nil;
- }
-
- if (err2) {
- ITDebugLog(@"Error After AESizeOfParam: %i", err2);
- } else {
- err3 = AEGetParamPtr(&replyEvent, keyDirectObject, resultType, NULL, result, resultSize, &charResultSize);
-
- if (err3) {
- ITDebugLog(@"Error After AEGetParamPtr: %i", err3);
- } else {
- _finalData = [NSData dataWithBytesNoCopy:result length:charResultSize freeWhenDone:YES];
- }
- }
- }
-
- if (!berr) AEDisposeDesc(&sendEvent);
- if (!err) AEDisposeDesc(&replyEvent);
-
- return _finalData;
-}
-
-@end
\ No newline at end of file
+++ /dev/null
-/*
- * ITAppleEventTools.h
- * ITFoundation
- *
- * Created by Alexander Strange on Wed Feb 11 2004.
- * Copyright (c) 2004 __MyCompanyName__. All rights reserved.
- *
- */
-
-#import <Foundation/Foundation.h>
-#import <Carbon/Carbon.h>
-
-extern NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode evClass, FourCharCode evID,const ProcessSerialNumber *psn);
-NSAppleEventDescriptor *ITSendAEWithStringAndObject(NSString *sendString, const AEDesc *object, FourCharCode evClass, FourCharCode evID,const ProcessSerialNumber *psn);
-extern NSAppleEventDescriptor *ITSendAEWithKey(FourCharCode reqKey, FourCharCode evClass, FourCharCode evID,const ProcessSerialNumber *psn);
-extern NSAppleEventDescriptor *ITSendAE(FourCharCode eClass, FourCharCode eID,const ProcessSerialNumber *psn);
-
-@interface NSAppleEventDescriptor (ITAELogging)
--(void) logDesc;
-@end
\ No newline at end of file
+++ /dev/null
-/*
- * ITAppleEventTools.c
- * ITFoundation
- *
- * Created by Alexander Strange on Wed Feb 11 2004.
- * Copyright (c) 2004 __MyCompanyName__. All rights reserved.
- *
- */
-
-#import "ITDebug.h"
-#import "ITAppleEventTools.h"
-
-NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode evClass, FourCharCode evID,const ProcessSerialNumber *psn)
-{
- //Add error checking...
- pid_t pid;
-
- const char *usendString = [sendString UTF8String];
-
- AppleEvent sendEvent, replyEvent;
- NSAppleEventDescriptor *send, *recv;
- AEDesc resultDesc;
- DescType resultType;
- Size resultSize;
-
- AEBuildError buildError;
- OSStatus berr,err;
-
- if ((GetProcessPID(psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(evClass, evID, typeProcessSerialNumber,psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, usendString);
- send = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&sendEvent] autorelease];
- if (!berr) [send logDesc];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[sendString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/60, NULL, NULL);
-
- err = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
- if (resultSize == 0 || err != 0) {
- return nil;
- }
-
- AEGetParamDesc(&replyEvent, keyDirectObject, resultType, &resultDesc);
-
- recv = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&resultDesc] autorelease];
- [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&replyEvent] autorelease];
- if (!err) [recv logDesc];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- }
- return recv;
-}
-
-NSAppleEventDescriptor *ITSendAEWithStringAndObject(NSString *sendString, const AEDesc *object, FourCharCode evClass, FourCharCode evID,const ProcessSerialNumber *psn)
-{
- //Add error checking...
- pid_t pid;
-
- const char *usendString = [sendString UTF8String];
-
- AppleEvent sendEvent, replyEvent;
- NSAppleEventDescriptor *send, *recv;
- AEDesc resultDesc;
- DescType resultType;
- Size resultSize;
-
- AEBuildError buildError;
- OSStatus berr,err;
-
- if ((GetProcessPID(psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(evClass, evID, typeProcessSerialNumber,psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, usendString);
- send = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&sendEvent] autorelease];
- if (!berr) [send logDesc];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[sendString substringToIndex:buildError.fErrorPos]);
- }
- err = AEPutParamDesc(&sendEvent, keyDirectObject, object);
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/60, NULL, NULL);
-
- err = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
- if (resultSize == 0 || err != 0) {
- return nil;
- }
-
- AEGetParamDesc(&replyEvent, keyDirectObject, resultType, &resultDesc);
-
- recv = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&resultDesc] autorelease];
- [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&replyEvent] autorelease];
- if (!err) [recv logDesc];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- }
- return recv;
-}
-
-NSAppleEventDescriptor *ITSendAEWithKey(FourCharCode reqKey, FourCharCode evClass, FourCharCode evID,const ProcessSerialNumber *psn)
-{
- //Add error checking...
- pid_t pid;
- NSString *sendString = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('%c%c%c%c'), from:'null'() }", (reqKey >> 24), (reqKey >> 16) & 0xff, (reqKey >> 8) & 0xff, reqKey & 0xff];
- const char *usendString = [sendString UTF8String];
-
- AppleEvent sendEvent, replyEvent;
- NSAppleEventDescriptor *send, *recv;
- AEDesc resultDesc;
- DescType resultType;
- Size resultSize;
-
- AEBuildError buildError;
- OSStatus berr,err;
-
- if ((GetProcessPID(psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
-
- berr = AEBuildAppleEvent(evClass, evID, typeProcessSerialNumber,psn, sizeof(ProcessSerialNumber), kAutoGenerateReturnID, 0, &sendEvent, &buildError, usendString);
- send = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&sendEvent] autorelease];
- if (!berr) [send logDesc];
-
- if (berr) {
- ITDebugLog(@"Error: %d:%d at \"%@\"",(int)buildError.fError,buildError.fErrorPos,[sendString substringToIndex:buildError.fErrorPos]);
- }
-
- err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/60, NULL, NULL);
-
- err = AESizeOfParam(&replyEvent, keyDirectObject, &resultType, &resultSize);
- if (resultSize == 0 || err != 0) {
- return nil;
- }
-
- AEGetParamDesc(&replyEvent, keyDirectObject, resultType, &resultDesc);
-
- recv = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&resultDesc] autorelease];
- [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&replyEvent] autorelease];
- if (!err) [recv logDesc];
-
- if (err) {
- ITDebugLog(@"Send Error: %i",err);
- }
- return recv;
-}
-
-NSAppleEventDescriptor *ITSendAE(FourCharCode eClass, FourCharCode eID,const ProcessSerialNumber *psn)
-{
- AEDesc dest;
- int pid;
-
- AppleEvent event, reply;
- OSStatus cerr,cerr2,err;
- NSAppleEventDescriptor *nsd, *nse, *nsr;
- if ((GetProcessPID(psn, &pid) == noErr) && (pid == 0)) {
- ITDebugLog(@"Error getting PID of application.");
- return nil;
- }
- cerr = AECreateDesc(typeProcessSerialNumber,psn,sizeof(ProcessSerialNumber),&dest);
- nsd = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&dest] autorelease];
- cerr2 = AECreateAppleEvent(eClass,eID,&dest,kAutoGenerateReturnID,kAnyTransactionID,&event);
- nse = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&event] autorelease];
- if (!cerr2) [nse logDesc];
- err = AESend(&event, &reply, kAENoReply, kAENormalPriority, /*kAEDefaultTimeout*/60, NULL, NULL);
- nsr = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&reply] autorelease];
- [nsr logDesc];
- return nsr;
-}
-
-@implementation NSAppleEventDescriptor (ITAELogging)
--(void) logDesc
-{
- Handle xx;
- AEPrintDescToHandle([self aeDesc],&xx);
- ITDebugLog(@"AE Descriptor: %s", *xx);
- DisposeHandle(xx);
-}
-@end
\ No newline at end of file
#import <Foundation/Foundation.h>
-#import <Carbon/Carbon.h>
-NSString *NSStringFromFourCharCode(FourCharCode code);
-FourCharCode FourCharCodeFromNSString(NSString *string);
\ No newline at end of file
+NSString *NSStringFromFourCharCode(unsigned long code);
+unsigned long FourCharCodeFromNSString(NSString *string);
\ No newline at end of file
#import "ITCarbonSupport.h"
-NSString *NSStringFromFourCharCode(FourCharCode code) {
+NSString *NSStringFromFourCharCode(unsigned long code) {
return [NSString stringWithUTF8String:&code];
}
-FourCharCode FourCharCodeFromNSString(NSString *string) {
+unsigned long FourCharCodeFromNSString(NSString *string) {
return (*((unsigned long*)[string UTF8String]));
}
\ No newline at end of file
};
08FB77AEFE84172EC02AAC07 = {
children = (
- 37B1C51C0612593F00F99008,
37B1C5280612596900F99008,
37B1C51F0612594A00F99008,
37B1C5190612593A00F99008,
37138AB80661A243006A543D,
- 37B1C5160612592F00F99008,
37B1C5220612595500F99008,
37B1C5250612596000F99008,
37B1C52B0612597100F99008,
//372
//373
//374
- 370786C005C0B4D700E6D1BA = {
- fileEncoding = 30;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = ITOSAScript.h;
- refType = 4;
- sourceTree = "<group>";
- };
- 370786C105C0B4D700E6D1BA = {
- fileEncoding = 30;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.objc;
- path = ITOSAScript.m;
- refType = 4;
- sourceTree = "<group>";
- };
37138AB80661A243006A543D = {
children = (
376AF4DD06597CA900F0979E,
settings = {
};
};
- 37B1C5160612592F00F99008 = {
- children = (
- 370786C005C0B4D700E6D1BA,
- 370786C105C0B4D700E6D1BA,
- 37B9B08005C1C47E00702FDB,
- 37B9B08105C1C47E00702FDB,
- );
- isa = PBXGroup;
- name = ITOSA;
- refType = 4;
- sourceTree = "<group>";
- };
37B1C5190612593A00F99008 = {
children = (
7CA50B2F054E77A00074E1D9,
refType = 4;
sourceTree = "<group>";
};
- 37B1C51C0612593F00F99008 = {
- children = (
- 3D97138805D9FD6B0033607F,
- 3D97138905D9FD6B0033607F,
- 7CA50B2B054E77950074E1D9,
- 7CA50B2C054E77950074E1D9,
- );
- isa = PBXGroup;
- name = ITAppleEvent;
- path = "";
- refType = 4;
- sourceTree = "<group>";
- };
37B1C51F0612594A00F99008 = {
children = (
7C97DC2C05B614300013E85F,
refType = 4;
sourceTree = "<group>";
};
- 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>";
- };
//370
//371
//372
settings = {
};
};
- 3D97138805D9FD6B0033607F = {
- fileEncoding = 4;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = ITAppleEventTools.h;
- refType = 4;
- sourceTree = "<group>";
- };
- 3D97138905D9FD6B0033607F = {
- explicitFileType = sourcecode.c.objc;
- fileEncoding = 4;
- isa = PBXFileReference;
- path = ITAppleEventTools.m;
- refType = 4;
- sourceTree = "<group>";
- };
- 3D97138A05D9FD6B0033607F = {
- fileRef = 3D97138805D9FD6B0033607F;
- isa = PBXBuildFile;
- settings = {
- ATTRIBUTES = (
- Public,
- );
- };
- };
- 3D97138B05D9FD6B0033607F = {
- fileRef = 3D97138905D9FD6B0033607F;
- isa = PBXBuildFile;
- settings = {
- };
- };
//3D0
//3D1
//3D2
settings = {
};
};
- 7CA50B2B054E77950074E1D9 = {
- fileEncoding = 4;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = ITAppleEventCenter.h;
- refType = 4;
- sourceTree = "<group>";
- };
- 7CA50B2C054E77950074E1D9 = {
- fileEncoding = 4;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.objc;
- path = ITAppleEventCenter.m;
- refType = 4;
- sourceTree = "<group>";
- };
- 7CA50B2D054E77950074E1D9 = {
- fileRef = 7CA50B2B054E77950074E1D9;
- isa = PBXBuildFile;
- settings = {
- ATTRIBUTES = (
- Public,
- );
- };
- };
- 7CA50B2E054E77950074E1D9 = {
- fileRef = 7CA50B2C054E77950074E1D9;
- isa = PBXBuildFile;
- settings = {
- };
- };
7CA50B2F054E77A00074E1D9 = {
fileEncoding = 4;
isa = PBXFileReference;
files = (
8DC2EF510486A6940098B216,
7CA50D7E054E7C600074E1D9,
- 7CA50B2D054E77950074E1D9,
7CA50B31054E77A00074E1D9,
3D2D8A13055E07D800F59C27,
2AB93A3205705A0C007E748F,
7C97DC2E05B614300013E85F,
3D97137B05D9FB7C0033607F,
3D97137F05D9FBF40033607F,
- 3D97138A05D9FD6B0033607F,
376AF4DF06597CA900F0979E,
7C058DF9072F10530082E1E9,
7C2D93BF07C2FD6700A487A9,
8DC2EF540486A6940098B216 = {
buildActionMask = 2147483647;
files = (
- 7CA50B2E054E77950074E1D9,
7CA50B32054E77A00074E1D9,
3D2D8A12055E07D800F59C27,
2AB93A3305705A0C007E748F,
7C97DC2F05B614300013E85F,
3D97137C05D9FB7C0033607F,
3D97138105D9FBFA0033607F,
- 3D97138B05D9FD6B0033607F,
376AF4E006597CA900F0979E,
7C058DFA072F10530082E1E9,
7C2D93C007C2FD6700A487A9,
*
*/
-#import <Carbon/Carbon.h>
#import <Foundation/Foundation.h>
+#import <Carbon/Carbon.h>
#import <CoreServices/CoreServices.h>
//These functions check for a match with just the lastPathComponent, so it will handle people moving the app
+++ /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;
-}
-+ (ITOSAComponent *)appleScriptComponent;
-+ (ITOSAComponent *)componentWithCarbonComponent:(Component)component;
-+ (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"
-
-#warning Need to add a constant data store containing all available component instances... could be lazy and build it on class +load.
-
-@implementation ITOSAComponent
-
-+ (ITOSAComponent *)appleScriptComponent
-{
- return [[[ITOSAComponent alloc] initWithSubtype:kAppleScriptSubtype] autorelease];
-}
-
-+ (ITOSAComponent *)componentWithCarbonComponent:(Component)component
-{
- return [[[ITOSAComponent alloc] initWithComponent:component] autorelease];
-}
-
-+ (NSArray *)availableComponents
-{
- Component currentComponent = 0;
- ComponentDescription cd;
- NSMutableArray *components = [[NSMutableArray alloc] init];
-
- cd.componentType = kOSAComponentType;
- cd.componentSubType = 0;
- cd.componentManufacturer = 0;
- cd.componentFlags = 0;
- cd.componentFlagsMask = 0;
- while ((currentComponent = FindNextComponent(currentComponent, &cd)) != 0) {
- [components addObject:[ITOSAComponent componentWithCarbonComponent:currentComponent]];
- }
- return [NSArray arrayWithArray:[components autorelease]];
-}
-
-- (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];
-
- AEDesc name;
- Ptr buffer;
- Size length;
- OSAScriptingComponentName(_componentInstance, &name);
- length = AEGetDescDataSize(&name);
- buffer = malloc(length);
-
- AEGetDescData(&name, buffer, length);
- AEDisposeDesc(&name);
- [information setObject:[NSString stringWithCString:buffer length:length] forKey:@"ITOSAComponentName"];
- free(buffer);
- buffer = NULL;
-
- //[information setObject:[[[NSString alloc] initWithBytes:componentName length:GetHandleSize(componentName) encoding:NSASCIIStringEncoding] autorelease] forKey:@"ITOSAComponentName"];
- [information setObject:[[[NSString alloc] initWithBytes:componentInfo length:GetHandleSize(componentInfo) encoding:NSASCIIStringEncoding] autorelease] forKey:@"ITOSAComponentInfo"];
- [information setObject:[NSNumber numberWithUnsignedLong:description.componentSubType] forKey:@"ITOSAComponentSubtype"];
- [information setObject:[NSNumber numberWithUnsignedLong:description.componentManufacturer] forKey:@"ITOSAComponentManufacturer"];
- _information = [information copy];
- }
- return self;
-}
-
-- (void)dealloc
-{
- [_information release];
-}
-
-- (NSString *)description
-{
- return [_information objectForKey:@"ITOSAComponentName"];
-}
-
-- (Component)component
-{
- return _component;
-}
-
-- (ComponentInstance)componentInstance
-{
- return _componentInstance;
-}
-
-- (NSDictionary *)information
-{
- return _information;
-}
-
-@end
+++ /dev/null
-/*
- * ITFoundation
- * ITOSAScript
- * An extended NSAppleScript that allows any OSA language.
- *
- * 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>
-
-@class ITOSAComponent;
-
-@interface ITOSAScript : NSObject {
- NSString *_source;
- ITOSAComponent *_component;
- OSAID _scriptID;
-}
-
-- (id)initWithContentsOfFile:(NSString *)path;
-- (id)initWithSource:(NSString *)source;
-
-- (NSString *)source;
-
-- (ITOSAComponent *)component;
-- (void)setComponent:(ITOSAComponent *)newComponent;
-
-- (BOOL)compileAndReturnError:(NSDictionary **)errorInfo;
-- (BOOL)isCompiled;
-
-- (NSAppleEventDescriptor *)executeAndReturnError:(NSDictionary **)errorInfo;
-
-@end
+++ /dev/null
-/*
- * ITFoundation
- * ITOSAScript
- * An extended NSAppleScript that allows any OSA language.
- *
- * 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
- *
- */
-
-/*
-Script Subtypes:
- kAppleScriptSubtype - AppleScript (Default)
- 'Jscr' - JavaScript (if installed)
-*/
-
-#import "ITOSAScript.h"
-#import "ITOSAComponent.h"
-
-#warning To do - Error Dictionaries
-
-@implementation ITOSAScript
-
-- (id)init
-{
- return nil; // initWithSource: is the designated initializer for this class
-}
-
-- (id)initWithContentsOfFile:(NSString *)path
-{
- return [self initWithSource:[[[NSString alloc] initWithContentsOfFile:path] autorelease]];
-}
-
-- (id)initWithSource:(NSString *)source
-{
- if ( (self = [super init]) ) {
- _source = [source copy];
- _scriptID = kOSANullScript;
- }
- return self;
-}
-
-- (void)dealloc
-{
- if (_scriptID != kOSANullScript) {
- OSADispose([_component componentInstance], _scriptID);
- }
-
- [_source release];
- [super dealloc];
-}
-
-- (NSString *)source
-{
- return _source;
-}
-
-- (ITOSAComponent *)component
-{
- return _component;
-}
-
-- (void)setComponent:(ITOSAComponent *)newComponent
-{
- _component = newComponent;
-}
-
-- (BOOL)compileAndReturnError:(NSDictionary **)errorInfo
-{
- if ([_component componentInstance] == nil) {
- //Set the error dictionary
- return NO;
- }
-
- AEDesc moof;
- AECreateDesc(typeChar, [_source cString], [_source cStringLength], &moof);
- if (OSACompile([_component componentInstance], &moof, kOSAModeNull, &_scriptID) != 0) {
- NSLog(@"Compile error!");
- return NO;
- }
- return YES;
-}
-
-- (BOOL)isCompiled
-{
- return (_scriptID != kOSANullScript);
-}
-
-- (NSAppleEventDescriptor *)executeAndReturnError:(NSDictionary **)errorInfo
-{
- if ([_component componentInstance] == nil) {
- //Set the error dictionary
- return nil;
- }
-
- NSAppleEventDescriptor *cocoaDesc;
-
- AEDesc scriptDesc, resultDesc;
- OSAID resultID = kOSANullScript;
-
- //If not compiled, compile it
- if (![self isCompiled]) {
- if (![self compileAndReturnError:nil]) {
- //Set the error info dictionary
- return nil;
- }
- }
-
- OSAExecute([_component componentInstance], _scriptID, kOSANullScript, kOSANullMode, &resultID);
-
- OSACoerceToDesc([_component componentInstance], resultID, typeWildCard, kOSAModeNull, &resultDesc); // Using this instead of OSADisplay, as we don't care about human readability, but rather, the integrity of the data.
-
- cocoaDesc = [[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&resultDesc];
-
- AEDisposeDesc(&scriptDesc);
-
- OSADispose([_component componentInstance], resultID);
-
- return [cocoaDesc autorelease];
-}
-
-@end